Average Error: 0.1 → 0.1
Time: 6.6s
Precision: 64
\[3.0 \cdot \left(\left(\left(x \cdot 3.0\right) \cdot x - x \cdot 4.0\right) + 1.0\right)\]
\[\left(9.0 \cdot x\right) \cdot x + \left(3.0 - 12.0 \cdot x\right)\]
3.0 \cdot \left(\left(\left(x \cdot 3.0\right) \cdot x - x \cdot 4.0\right) + 1.0\right)
\left(9.0 \cdot x\right) \cdot x + \left(3.0 - 12.0 \cdot x\right)
double f(double x) {
        double r12630883 = 3.0;
        double r12630884 = x;
        double r12630885 = r12630884 * r12630883;
        double r12630886 = r12630885 * r12630884;
        double r12630887 = 4.0;
        double r12630888 = r12630884 * r12630887;
        double r12630889 = r12630886 - r12630888;
        double r12630890 = 1.0;
        double r12630891 = r12630889 + r12630890;
        double r12630892 = r12630883 * r12630891;
        return r12630892;
}

double f(double x) {
        double r12630893 = 9.0;
        double r12630894 = x;
        double r12630895 = r12630893 * r12630894;
        double r12630896 = r12630895 * r12630894;
        double r12630897 = 3.0;
        double r12630898 = 12.0;
        double r12630899 = r12630898 * r12630894;
        double r12630900 = r12630897 - r12630899;
        double r12630901 = r12630896 + r12630900;
        return r12630901;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.1
Target0.1
Herbie0.1
\[3.0 + \left(\left(9.0 \cdot x\right) \cdot x - 12.0 \cdot x\right)\]

Derivation

  1. Initial program 0.1

    \[3.0 \cdot \left(\left(\left(x \cdot 3.0\right) \cdot x - x \cdot 4.0\right) + 1.0\right)\]
  2. Simplified0.1

    \[\leadsto \color{blue}{3.0 \cdot \left(x \cdot \left(x \cdot 3.0 - 4.0\right) + 1.0\right)}\]
  3. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{\left(9.0 \cdot {x}^{2} + 3.0\right) - 12.0 \cdot x}\]
  4. Simplified0.1

    \[\leadsto \color{blue}{9.0 \cdot \left(x \cdot x\right) + \left(3.0 - x \cdot 12.0\right)}\]
  5. Using strategy rm
  6. Applied associate-*r*0.1

    \[\leadsto \color{blue}{\left(9.0 \cdot x\right) \cdot x} + \left(3.0 - x \cdot 12.0\right)\]
  7. Final simplification0.1

    \[\leadsto \left(9.0 \cdot x\right) \cdot x + \left(3.0 - 12.0 \cdot x\right)\]

Reproduce

herbie shell --seed 2019156 
(FPCore (x)
  :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, D"

  :herbie-target
  (+ 3.0 (- (* (* 9.0 x) x) (* 12.0 x)))

  (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))