Average Error: 54.3 → 0.4
Time: 22.1s
Precision: 64
\[\frac{\left(1 - \frac{{x}^{2}}{2}\right) - \cos x}{{x}^{4}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.12153203655906179:\\ \;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{1}{2}}{x \cdot x} + \frac{\frac{\cos x}{x \cdot x}}{x \cdot x}\right)\\ \mathbf{elif}\;x \le 0.09809591180606583:\\ \;\;\;\;\left(\frac{-1}{40320} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \frac{x \cdot x}{720}\right) - \frac{1}{24}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{1}{2}}{x \cdot x} + \frac{\frac{\cos x}{x \cdot x}}{x \cdot x}\right)\\ \end{array}\]
\frac{\left(1 - \frac{{x}^{2}}{2}\right) - \cos x}{{x}^{4}}
\begin{array}{l}
\mathbf{if}\;x \le -0.12153203655906179:\\
\;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{1}{2}}{x \cdot x} + \frac{\frac{\cos x}{x \cdot x}}{x \cdot x}\right)\\

\mathbf{elif}\;x \le 0.09809591180606583:\\
\;\;\;\;\left(\frac{-1}{40320} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \frac{x \cdot x}{720}\right) - \frac{1}{24}\\

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

\end{array}
double f(double x) {
        double r12610683 = 1.0;
        double r12610684 = x;
        double r12610685 = 2.0;
        double r12610686 = pow(r12610684, r12610685);
        double r12610687 = r12610686 / r12610685;
        double r12610688 = r12610683 - r12610687;
        double r12610689 = cos(r12610684);
        double r12610690 = r12610688 - r12610689;
        double r12610691 = 4.0;
        double r12610692 = pow(r12610684, r12610691);
        double r12610693 = r12610690 / r12610692;
        return r12610693;
}

double f(double x) {
        double r12610694 = x;
        double r12610695 = -0.12153203655906179;
        bool r12610696 = r12610694 <= r12610695;
        double r12610697 = 1.0;
        double r12610698 = r12610694 * r12610694;
        double r12610699 = r12610698 * r12610698;
        double r12610700 = r12610697 / r12610699;
        double r12610701 = 0.5;
        double r12610702 = r12610701 / r12610698;
        double r12610703 = cos(r12610694);
        double r12610704 = r12610703 / r12610698;
        double r12610705 = r12610704 / r12610698;
        double r12610706 = r12610702 + r12610705;
        double r12610707 = r12610700 - r12610706;
        double r12610708 = 0.09809591180606583;
        bool r12610709 = r12610694 <= r12610708;
        double r12610710 = -2.48015873015873e-05;
        double r12610711 = r12610710 * r12610699;
        double r12610712 = 720.0;
        double r12610713 = r12610698 / r12610712;
        double r12610714 = r12610711 + r12610713;
        double r12610715 = 0.041666666666666664;
        double r12610716 = r12610714 - r12610715;
        double r12610717 = r12610709 ? r12610716 : r12610707;
        double r12610718 = r12610696 ? r12610707 : r12610717;
        return r12610718;
}

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 x < -0.12153203655906179 or 0.09809591180606583 < x

    1. Initial program 45.9

      \[\frac{\left(1 - \frac{{x}^{2}}{2}\right) - \cos x}{{x}^{4}}\]
    2. Simplified45.9

      \[\leadsto \color{blue}{\frac{\left(1 - \frac{x \cdot x}{2}\right) - \cos x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}\]
    3. Taylor expanded around -inf 0.8

      \[\leadsto \color{blue}{\frac{1}{{x}^{4}} - \left(\frac{1}{2} \cdot \frac{1}{{x}^{2}} + \frac{\cos x}{{x}^{4}}\right)}\]
    4. Simplified0.8

      \[\leadsto \color{blue}{\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{1}{2}}{x \cdot x} + \frac{\frac{\cos x}{x \cdot x}}{x \cdot x}\right)}\]

    if -0.12153203655906179 < x < 0.09809591180606583

    1. Initial program 62.8

      \[\frac{\left(1 - \frac{{x}^{2}}{2}\right) - \cos x}{{x}^{4}}\]
    2. Simplified62.8

      \[\leadsto \color{blue}{\frac{\left(1 - \frac{x \cdot x}{2}\right) - \cos x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)}}\]
    3. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\frac{1}{720} \cdot {x}^{2} - \left(\frac{1}{40320} \cdot {x}^{4} + \frac{1}{24}\right)}\]
    4. Simplified0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.12153203655906179:\\ \;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{1}{2}}{x \cdot x} + \frac{\frac{\cos x}{x \cdot x}}{x \cdot x}\right)\\ \mathbf{elif}\;x \le 0.09809591180606583:\\ \;\;\;\;\left(\frac{-1}{40320} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \frac{x \cdot x}{720}\right) - \frac{1}{24}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} - \left(\frac{\frac{1}{2}}{x \cdot x} + \frac{\frac{\cos x}{x \cdot x}}{x \cdot x}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x)
  :name "(1-x^2/2-cos(x))/x^4"
  (/ (- (- 1 (/ (pow x 2) 2)) (cos x)) (pow x 4)))