Average Error: 0.1 → 0.1
Time: 12.3s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[3 + x \cdot \left(x \cdot 9 - 12\right)\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
3 + x \cdot \left(x \cdot 9 - 12\right)
double f(double x) {
        double r513844 = 3.0;
        double r513845 = x;
        double r513846 = r513845 * r513844;
        double r513847 = r513846 * r513845;
        double r513848 = 4.0;
        double r513849 = r513845 * r513848;
        double r513850 = r513847 - r513849;
        double r513851 = 1.0;
        double r513852 = r513850 + r513851;
        double r513853 = r513844 * r513852;
        return r513853;
}

double f(double x) {
        double r513854 = 3.0;
        double r513855 = x;
        double r513856 = 9.0;
        double r513857 = r513855 * r513856;
        double r513858 = 12.0;
        double r513859 = r513857 - r513858;
        double r513860 = r513855 * r513859;
        double r513861 = r513854 + r513860;
        return r513861;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 0.1

    \[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. Final simplification0.1

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

Reproduce

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