Average Error: 9.7 → 0.8
Time: 8.0s
Precision: 64
\[\sin x - x\]
\[\begin{array}{l} \mathbf{if}\;\sin x - x \le -11427567992489.953125 \lor \neg \left(\sin x - x \le 6.352649526211728847613358084345236420631 \cdot 10^{-14}\right):\\ \;\;\;\;\sin x - x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{120} \cdot {x}^{5} - \left(\frac{1}{5040} \cdot {x}^{7} + \sqrt{\frac{1}{6}} \cdot \left(\sqrt{\frac{1}{6}} \cdot {x}^{3}\right)\right)\\ \end{array}\]
\sin x - x
\begin{array}{l}
\mathbf{if}\;\sin x - x \le -11427567992489.953125 \lor \neg \left(\sin x - x \le 6.352649526211728847613358084345236420631 \cdot 10^{-14}\right):\\
\;\;\;\;\sin x - x\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{120} \cdot {x}^{5} - \left(\frac{1}{5040} \cdot {x}^{7} + \sqrt{\frac{1}{6}} \cdot \left(\sqrt{\frac{1}{6}} \cdot {x}^{3}\right)\right)\\

\end{array}
double f(double x) {
        double r698765 = x;
        double r698766 = sin(r698765);
        double r698767 = r698766 - r698765;
        return r698767;
}

double f(double x) {
        double r698768 = x;
        double r698769 = sin(r698768);
        double r698770 = r698769 - r698768;
        double r698771 = -11427567992489.953;
        bool r698772 = r698770 <= r698771;
        double r698773 = 6.352649526211729e-14;
        bool r698774 = r698770 <= r698773;
        double r698775 = !r698774;
        bool r698776 = r698772 || r698775;
        double r698777 = 0.008333333333333333;
        double r698778 = 5.0;
        double r698779 = pow(r698768, r698778);
        double r698780 = r698777 * r698779;
        double r698781 = 0.0001984126984126984;
        double r698782 = 7.0;
        double r698783 = pow(r698768, r698782);
        double r698784 = r698781 * r698783;
        double r698785 = 0.16666666666666666;
        double r698786 = sqrt(r698785);
        double r698787 = 3.0;
        double r698788 = pow(r698768, r698787);
        double r698789 = r698786 * r698788;
        double r698790 = r698786 * r698789;
        double r698791 = r698784 + r698790;
        double r698792 = r698780 - r698791;
        double r698793 = r698776 ? r698770 : r698792;
        return r698793;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (- (sin x) x) < -11427567992489.953 or 6.352649526211729e-14 < (- (sin x) x)

    1. Initial program 0.1

      \[\sin x - x\]

    if -11427567992489.953 < (- (sin x) x) < 6.352649526211729e-14

    1. Initial program 19.2

      \[\sin x - x\]
    2. Taylor expanded around 0 1.4

      \[\leadsto \color{blue}{\frac{1}{120} \cdot {x}^{5} - \left(\frac{1}{5040} \cdot {x}^{7} + \frac{1}{6} \cdot {x}^{3}\right)}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt1.4

      \[\leadsto \frac{1}{120} \cdot {x}^{5} - \left(\frac{1}{5040} \cdot {x}^{7} + \color{blue}{\left(\sqrt{\frac{1}{6}} \cdot \sqrt{\frac{1}{6}}\right)} \cdot {x}^{3}\right)\]
    5. Applied associate-*l*1.4

      \[\leadsto \frac{1}{120} \cdot {x}^{5} - \left(\frac{1}{5040} \cdot {x}^{7} + \color{blue}{\sqrt{\frac{1}{6}} \cdot \left(\sqrt{\frac{1}{6}} \cdot {x}^{3}\right)}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin x - x \le -11427567992489.953125 \lor \neg \left(\sin x - x \le 6.352649526211728847613358084345236420631 \cdot 10^{-14}\right):\\ \;\;\;\;\sin x - x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{120} \cdot {x}^{5} - \left(\frac{1}{5040} \cdot {x}^{7} + \sqrt{\frac{1}{6}} \cdot \left(\sqrt{\frac{1}{6}} \cdot {x}^{3}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x)
  :name "sin(x) - x"
  :precision binary64
  (- (sin x) x))