Average Error: 0.2 → 0.1
Time: 13.3s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[3 + \left(9 \cdot {x}^{2} + x \cdot \left(-12\right)\right)\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
3 + \left(9 \cdot {x}^{2} + x \cdot \left(-12\right)\right)
double f(double x) {
        double r657817 = 3.0;
        double r657818 = x;
        double r657819 = r657818 * r657817;
        double r657820 = r657819 * r657818;
        double r657821 = 4.0;
        double r657822 = r657818 * r657821;
        double r657823 = r657820 - r657822;
        double r657824 = 1.0;
        double r657825 = r657823 + r657824;
        double r657826 = r657817 * r657825;
        return r657826;
}

double f(double x) {
        double r657827 = 3.0;
        double r657828 = 9.0;
        double r657829 = x;
        double r657830 = 2.0;
        double r657831 = pow(r657829, r657830);
        double r657832 = r657828 * r657831;
        double r657833 = 12.0;
        double r657834 = -r657833;
        double r657835 = r657829 * r657834;
        double r657836 = r657832 + r657835;
        double r657837 = r657827 + r657836;
        return r657837;
}

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. Taylor expanded around 0 0.1

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

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

    \[\leadsto 3 + x \cdot \color{blue}{\mathsf{fma}\left(x, 9, -12\right)}\]
  6. Using strategy rm
  7. Applied fma-udef0.1

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

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

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

    \[\leadsto 3 + \left(9 \cdot {x}^{2} + x \cdot \left(-12\right)\right)\]

Reproduce

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