Average Error: 0.1 → 0.1
Time: 17.4s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[\left(9 \cdot x - 12\right) \cdot x + 3\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\left(9 \cdot x - 12\right) \cdot x + 3
double f(double x) {
        double r400887 = 3.0;
        double r400888 = x;
        double r400889 = r400888 * r400887;
        double r400890 = r400889 * r400888;
        double r400891 = 4.0;
        double r400892 = r400888 * r400891;
        double r400893 = r400890 - r400892;
        double r400894 = 1.0;
        double r400895 = r400893 + r400894;
        double r400896 = r400887 * r400895;
        return r400896;
}

double f(double x) {
        double r400897 = 9.0;
        double r400898 = x;
        double r400899 = r400897 * r400898;
        double r400900 = 12.0;
        double r400901 = r400899 - r400900;
        double r400902 = r400901 * r400898;
        double r400903 = 3.0;
        double r400904 = r400902 + r400903;
        return r400904;
}

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}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 9, -12\right), 3\right)}\]
  5. Using strategy rm
  6. Applied fma-udef0.1

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

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

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

Reproduce

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