Average Error: 0.2 → 0.1
Time: 10.1s
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} - 12 \cdot x\right)\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
3 + \left(9 \cdot {x}^{2} - 12 \cdot x\right)
double f(double x) {
        double r713169 = 3.0;
        double r713170 = x;
        double r713171 = r713170 * r713169;
        double r713172 = r713171 * r713170;
        double r713173 = 4.0;
        double r713174 = r713170 * r713173;
        double r713175 = r713172 - r713174;
        double r713176 = 1.0;
        double r713177 = r713175 + r713176;
        double r713178 = r713169 * r713177;
        return r713178;
}

double f(double x) {
        double r713179 = 3.0;
        double r713180 = 9.0;
        double r713181 = x;
        double r713182 = 2.0;
        double r713183 = pow(r713181, r713182);
        double r713184 = r713180 * r713183;
        double r713185 = 12.0;
        double r713186 = r713185 * r713181;
        double r713187 = r713184 - r713186;
        double r713188 = r713179 + r713187;
        return r713188;
}

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(9 \cdot x - 12\right)}\]
  4. Using strategy rm
  5. Applied flip--0.2

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

    \[\leadsto 3 + x \cdot \frac{\color{blue}{\mathsf{fma}\left(9, x, 12\right) \cdot \mathsf{fma}\left(9, x, -12\right)}}{9 \cdot x + 12}\]
  7. Simplified0.2

    \[\leadsto 3 + x \cdot \frac{\mathsf{fma}\left(9, x, 12\right) \cdot \mathsf{fma}\left(9, x, -12\right)}{\color{blue}{\mathsf{fma}\left(9, x, 12\right)}}\]
  8. Taylor expanded around 0 0.1

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

    \[\leadsto 3 + \left(9 \cdot {x}^{2} - 12 \cdot x\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)))