Average Error: 0.2 → 0.1
Time: 11.6s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[3 + \left(\left(-12 \cdot x\right) + \left(x \cdot x\right) \cdot 9\right)\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
3 + \left(\left(-12 \cdot x\right) + \left(x \cdot x\right) \cdot 9\right)
double f(double x) {
        double r598297 = 3.0;
        double r598298 = x;
        double r598299 = r598298 * r598297;
        double r598300 = r598299 * r598298;
        double r598301 = 4.0;
        double r598302 = r598298 * r598301;
        double r598303 = r598300 - r598302;
        double r598304 = 1.0;
        double r598305 = r598303 + r598304;
        double r598306 = r598297 * r598305;
        return r598306;
}

double f(double x) {
        double r598307 = 3.0;
        double r598308 = 12.0;
        double r598309 = x;
        double r598310 = r598308 * r598309;
        double r598311 = -r598310;
        double r598312 = r598309 * r598309;
        double r598313 = 9.0;
        double r598314 = r598312 * r598313;
        double r598315 = r598311 + r598314;
        double r598316 = r598307 + r598315;
        return r598316;
}

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}{\mathsf{fma}\left(x, 3 \cdot x - 4, 1\right) \cdot 3}\]
  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. Using strategy rm
  6. Applied sub-neg0.1

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

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

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

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

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

Reproduce

herbie shell --seed 2019194 +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)))