Average Error: 0.2 → 0.1
Time: 11.0s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[\left(\left(x \cdot x\right) \cdot 9 + x \cdot \left(-12\right)\right) + 3\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\left(\left(x \cdot x\right) \cdot 9 + x \cdot \left(-12\right)\right) + 3
double f(double x) {
        double r759091 = 3.0;
        double r759092 = x;
        double r759093 = r759092 * r759091;
        double r759094 = r759093 * r759092;
        double r759095 = 4.0;
        double r759096 = r759092 * r759095;
        double r759097 = r759094 - r759096;
        double r759098 = 1.0;
        double r759099 = r759097 + r759098;
        double r759100 = r759091 * r759099;
        return r759100;
}

double f(double x) {
        double r759101 = x;
        double r759102 = r759101 * r759101;
        double r759103 = 9.0;
        double r759104 = r759102 * r759103;
        double r759105 = 12.0;
        double r759106 = -r759105;
        double r759107 = r759101 * r759106;
        double r759108 = r759104 + r759107;
        double r759109 = 3.0;
        double r759110 = r759108 + r759109;
        return r759110;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.2
Target0.1
Herbie0.1
\[3 + \left(\left(9 \cdot x\right) \cdot x - 12 \cdot x\right)\]

Derivation

  1. Initial program 0.2

    \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
  2. Simplified0.2

    \[\leadsto \color{blue}{3 \cdot \mathsf{fma}\left(x, x \cdot 3 - 4, 1\right)}\]
  3. Taylor expanded around 0 0.1

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

    \[\leadsto \color{blue}{x \cdot \left(x \cdot 9 - 12\right) + 3}\]
  5. Using strategy rm
  6. Applied sub-neg0.1

    \[\leadsto x \cdot \color{blue}{\left(x \cdot 9 + \left(-12\right)\right)} + 3\]
  7. Applied distribute-lft-in0.1

    \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 9\right) + x \cdot \left(-12\right)\right)} + 3\]
  8. Simplified0.1

    \[\leadsto \left(\color{blue}{\left(x \cdot x\right) \cdot 9} + x \cdot \left(-12\right)\right) + 3\]
  9. Final simplification0.1

    \[\leadsto \left(\left(x \cdot x\right) \cdot 9 + x \cdot \left(-12\right)\right) + 3\]

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(FPCore (x)
  :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, D"
  :precision binary64

  :herbie-target
  (+ 3 (- (* (* 9 x) x) (* 12 x)))

  (* 3 (+ (- (* (* x 3) x) (* x 4)) 1)))