Average Error: 0.2 → 0.1
Time: 11.2s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[3 + x \cdot \left(9 \cdot x - 12\right)\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
3 + x \cdot \left(9 \cdot x - 12\right)
double f(double x) {
        double r503170 = 3.0;
        double r503171 = x;
        double r503172 = r503171 * r503170;
        double r503173 = r503172 * r503171;
        double r503174 = 4.0;
        double r503175 = r503171 * r503174;
        double r503176 = r503173 - r503175;
        double r503177 = 1.0;
        double r503178 = r503176 + r503177;
        double r503179 = r503170 * r503178;
        return r503179;
}

double f(double x) {
        double r503180 = 3.0;
        double r503181 = x;
        double r503182 = 9.0;
        double r503183 = r503182 * r503181;
        double r503184 = 12.0;
        double r503185 = r503183 - r503184;
        double r503186 = r503181 * r503185;
        double r503187 = r503180 + r503186;
        return r503187;
}

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.1

    \[\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}{3 + x \cdot \left(x \cdot 9 - 12\right)}\]
  5. Taylor expanded around 0 0.1

    \[\leadsto 3 + \color{blue}{\left(9 \cdot {x}^{2} - 12 \cdot x\right)}\]
  6. Taylor expanded around 0 0.1

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

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

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

Reproduce

herbie shell --seed 2019198 +o rules:numerics
(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)))