Average Error: 0.1 → 0.1
Time: 19.9s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[3 + \left(9 \cdot x - 12\right) \cdot x\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
3 + \left(9 \cdot x - 12\right) \cdot x
double f(double x) {
        double r28338672 = 3.0;
        double r28338673 = x;
        double r28338674 = r28338673 * r28338672;
        double r28338675 = r28338674 * r28338673;
        double r28338676 = 4.0;
        double r28338677 = r28338673 * r28338676;
        double r28338678 = r28338675 - r28338677;
        double r28338679 = 1.0;
        double r28338680 = r28338678 + r28338679;
        double r28338681 = r28338672 * r28338680;
        return r28338681;
}

double f(double x) {
        double r28338682 = 3.0;
        double r28338683 = 9.0;
        double r28338684 = x;
        double r28338685 = r28338683 * r28338684;
        double r28338686 = 12.0;
        double r28338687 = r28338685 - r28338686;
        double r28338688 = r28338687 * r28338684;
        double r28338689 = r28338682 + r28338688;
        return r28338689;
}

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. Using strategy rm
  3. Applied add-sqr-sqrt0.3

    \[\leadsto 3 \cdot \color{blue}{\left(\sqrt{\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1} \cdot \sqrt{\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1}\right)}\]
  4. Applied associate-*r*0.3

    \[\leadsto \color{blue}{\left(3 \cdot \sqrt{\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1}\right) \cdot \sqrt{\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1}}\]
  5. Taylor expanded around 0 0.1

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

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

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

Reproduce

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