Average Error: 0.1 → 0.1
Time: 14.4s
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 r452142 = 3.0;
        double r452143 = x;
        double r452144 = r452143 * r452142;
        double r452145 = r452144 * r452143;
        double r452146 = 4.0;
        double r452147 = r452143 * r452146;
        double r452148 = r452145 - r452147;
        double r452149 = 1.0;
        double r452150 = r452148 + r452149;
        double r452151 = r452142 * r452150;
        return r452151;
}

double f(double x) {
        double r452152 = 3.0;
        double r452153 = x;
        double r452154 = 9.0;
        double r452155 = r452153 * r452154;
        double r452156 = 12.0;
        double r452157 = r452155 - r452156;
        double r452158 = r452153 * r452157;
        double r452159 = r452152 + r452158;
        return r452159;
}

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 2019305 +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)))