Average Error: 0.1 → 0.1
Time: 15.8s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[3 + \left(x \cdot \left(9 \cdot x\right) + 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(x \cdot \left(9 \cdot x\right) + x \cdot \left(-12\right)\right)
double f(double x) {
        double r42716744 = 3.0;
        double r42716745 = x;
        double r42716746 = r42716745 * r42716744;
        double r42716747 = r42716746 * r42716745;
        double r42716748 = 4.0;
        double r42716749 = r42716745 * r42716748;
        double r42716750 = r42716747 - r42716749;
        double r42716751 = 1.0;
        double r42716752 = r42716750 + r42716751;
        double r42716753 = r42716744 * r42716752;
        return r42716753;
}

double f(double x) {
        double r42716754 = 3.0;
        double r42716755 = x;
        double r42716756 = 9.0;
        double r42716757 = r42716756 * r42716755;
        double r42716758 = r42716755 * r42716757;
        double r42716759 = 12.0;
        double r42716760 = -r42716759;
        double r42716761 = r42716755 * r42716760;
        double r42716762 = r42716758 + r42716761;
        double r42716763 = r42716754 + r42716762;
        return r42716763;
}

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(9 \cdot x - 12\right)}\]
  5. Using strategy rm
  6. Applied sub-neg0.1

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

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

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

Reproduce

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