Average Error: 31.6 → 0.2
Time: 26.5s
Precision: 64
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.03029376308050287305850822860975313233212:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 2.40127543424934719595853493956383317709:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{729}{64000}, {x}^{6}, -{\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)}^{3}\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right), \mathsf{fma}\left(\frac{9}{40} \cdot x, x, \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right), {x}^{4} \cdot \frac{81}{1600}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\sin x}{x \cdot \cos x} + \left(\frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot {\left(\cos x\right)}^{2}} + 1\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot \cos x}\right)\\ \end{array}\]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
\mathbf{if}\;x \le -0.03029376308050287305850822860975313233212:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\

\mathbf{elif}\;x \le 2.40127543424934719595853493956383317709:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{729}{64000}, {x}^{6}, -{\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)}^{3}\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right), \mathsf{fma}\left(\frac{9}{40} \cdot x, x, \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right), {x}^{4} \cdot \frac{81}{1600}\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{\sin x}{x \cdot \cos x} + \left(\frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot {\left(\cos x\right)}^{2}} + 1\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot \cos x}\right)\\

\end{array}
double f(double x) {
        double r20650 = x;
        double r20651 = sin(r20650);
        double r20652 = r20650 - r20651;
        double r20653 = tan(r20650);
        double r20654 = r20650 - r20653;
        double r20655 = r20652 / r20654;
        return r20655;
}

double f(double x) {
        double r20656 = x;
        double r20657 = -0.030293763080502873;
        bool r20658 = r20656 <= r20657;
        double r20659 = sin(r20656);
        double r20660 = r20656 - r20659;
        double r20661 = tan(r20656);
        double r20662 = r20656 - r20661;
        double r20663 = r20660 / r20662;
        double r20664 = 2.401275434249347;
        bool r20665 = r20656 <= r20664;
        double r20666 = 0.011390625;
        double r20667 = 6.0;
        double r20668 = pow(r20656, r20667);
        double r20669 = 0.009642857142857142;
        double r20670 = 4.0;
        double r20671 = pow(r20656, r20670);
        double r20672 = 0.5;
        double r20673 = fma(r20669, r20671, r20672);
        double r20674 = 3.0;
        double r20675 = pow(r20673, r20674);
        double r20676 = -r20675;
        double r20677 = fma(r20666, r20668, r20676);
        double r20678 = 0.225;
        double r20679 = r20678 * r20656;
        double r20680 = fma(r20679, r20656, r20673);
        double r20681 = 0.050625;
        double r20682 = r20671 * r20681;
        double r20683 = fma(r20673, r20680, r20682);
        double r20684 = r20677 / r20683;
        double r20685 = cos(r20656);
        double r20686 = r20656 * r20685;
        double r20687 = r20659 / r20686;
        double r20688 = 2.0;
        double r20689 = pow(r20659, r20688);
        double r20690 = pow(r20656, r20688);
        double r20691 = pow(r20685, r20688);
        double r20692 = r20690 * r20691;
        double r20693 = r20689 / r20692;
        double r20694 = 1.0;
        double r20695 = r20693 + r20694;
        double r20696 = r20687 + r20695;
        double r20697 = r20659 / r20656;
        double r20698 = r20690 * r20685;
        double r20699 = r20689 / r20698;
        double r20700 = r20697 + r20699;
        double r20701 = r20696 - r20700;
        double r20702 = r20665 ? r20684 : r20701;
        double r20703 = r20658 ? r20663 : r20702;
        return r20703;
}

Error

Bits error versus x

Derivation

  1. Split input into 3 regimes
  2. if x < -0.030293763080502873

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]

    if -0.030293763080502873 < x < 2.401275434249347

    1. Initial program 63.1

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around 0 0.1

      \[\leadsto \color{blue}{\frac{9}{40} \cdot {x}^{2} - \left(\frac{27}{2800} \cdot {x}^{4} + \frac{1}{2}\right)}\]
    3. Simplified0.1

      \[\leadsto \color{blue}{\frac{9}{40} \cdot {x}^{2} - \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)}\]
    4. Using strategy rm
    5. Applied unpow20.1

      \[\leadsto \frac{9}{40} \cdot \color{blue}{\left(x \cdot x\right)} - \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\]
    6. Applied associate-*r*0.1

      \[\leadsto \color{blue}{\left(\frac{9}{40} \cdot x\right) \cdot x} - \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\]
    7. Using strategy rm
    8. Applied flip3--0.1

      \[\leadsto \color{blue}{\frac{{\left(\left(\frac{9}{40} \cdot x\right) \cdot x\right)}^{3} - {\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)}^{3}}{\left(\left(\frac{9}{40} \cdot x\right) \cdot x\right) \cdot \left(\left(\frac{9}{40} \cdot x\right) \cdot x\right) + \left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right) \cdot \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right) + \left(\left(\frac{9}{40} \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)}}\]
    9. Simplified0.1

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{729}{64000}, {x}^{6}, -{\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)}^{3}\right)}}{\left(\left(\frac{9}{40} \cdot x\right) \cdot x\right) \cdot \left(\left(\frac{9}{40} \cdot x\right) \cdot x\right) + \left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right) \cdot \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right) + \left(\left(\frac{9}{40} \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)}\]
    10. Simplified0.1

      \[\leadsto \frac{\mathsf{fma}\left(\frac{729}{64000}, {x}^{6}, -{\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)}^{3}\right)}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right), \mathsf{fma}\left(\frac{9}{40} \cdot x, x, \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right), {x}^{4} \cdot \frac{81}{1600}\right)}}\]

    if 2.401275434249347 < x

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around inf 0.3

      \[\leadsto \color{blue}{\left(\frac{\sin x}{x \cdot \cos x} + \left(\frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot {\left(\cos x\right)}^{2}} + 1\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot \cos x}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.03029376308050287305850822860975313233212:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 2.40127543424934719595853493956383317709:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{729}{64000}, {x}^{6}, -{\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right)}^{3}\right)}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right), \mathsf{fma}\left(\frac{9}{40} \cdot x, x, \mathsf{fma}\left(\frac{27}{2800}, {x}^{4}, \frac{1}{2}\right)\right), {x}^{4} \cdot \frac{81}{1600}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\sin x}{x \cdot \cos x} + \left(\frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot {\left(\cos x\right)}^{2}} + 1\right)\right) - \left(\frac{\sin x}{x} + \frac{{\left(\sin x\right)}^{2}}{{x}^{2} \cdot \cos x}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019326 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))