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 r20647 = x;
        double r20648 = sin(r20647);
        double r20649 = r20647 - r20648;
        double r20650 = tan(r20647);
        double r20651 = r20647 - r20650;
        double r20652 = r20649 / r20651;
        return r20652;
}

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

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))))