Average Error: 0.2 → 0.1
Time: 15.5s
Precision: 64
\[3.0 \cdot \left(\left(\left(x \cdot 3.0\right) \cdot x - x \cdot 4.0\right) + 1.0\right)\]
\[3.0 + \left(9.0 \cdot x - 12.0\right) \cdot x\]
3.0 \cdot \left(\left(\left(x \cdot 3.0\right) \cdot x - x \cdot 4.0\right) + 1.0\right)
3.0 + \left(9.0 \cdot x - 12.0\right) \cdot x
double f(double x) {
        double r37420193 = 3.0;
        double r37420194 = x;
        double r37420195 = r37420194 * r37420193;
        double r37420196 = r37420195 * r37420194;
        double r37420197 = 4.0;
        double r37420198 = r37420194 * r37420197;
        double r37420199 = r37420196 - r37420198;
        double r37420200 = 1.0;
        double r37420201 = r37420199 + r37420200;
        double r37420202 = r37420193 * r37420201;
        return r37420202;
}

double f(double x) {
        double r37420203 = 3.0;
        double r37420204 = 9.0;
        double r37420205 = x;
        double r37420206 = r37420204 * r37420205;
        double r37420207 = 12.0;
        double r37420208 = r37420206 - r37420207;
        double r37420209 = r37420208 * r37420205;
        double r37420210 = r37420203 + r37420209;
        return r37420210;
}

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.0 + \left(\left(9.0 \cdot x\right) \cdot x - 12.0 \cdot x\right)\]

Derivation

  1. Initial program 0.2

    \[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(1.0 - \left(4.0 - x \cdot 3.0\right) \cdot x\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}{3.0 + x \cdot \left(9.0 \cdot x - 12.0\right)}\]
  5. Final simplification0.1

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

Reproduce

herbie shell --seed 2019162 
(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)))