Average Error: 0.1 → 0.1
Time: 1.9s
Precision: binary64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
\[\mathsf{fma}\left(9, x \cdot x, 3\right) - x \cdot 12 \]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\mathsf{fma}\left(9, x \cdot x, 3\right) - x \cdot 12
(FPCore (x) :precision binary64 (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))
(FPCore (x) :precision binary64 (- (fma 9.0 (* x x) 3.0) (* x 12.0)))
double code(double x) {
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
double code(double x) {
	return fma(9.0, (x * x), 3.0) - (x * 12.0);
}

Error

Bits error versus x

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}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, 9, -12\right), 3\right)} \]
  3. Taylor expanded in x around 0 0.1

    \[\leadsto \color{blue}{\left(3 + 9 \cdot {x}^{2}\right) - 12 \cdot x} \]
  4. Applied add-cube-cbrt_binary640.1

    \[\leadsto \left(3 + \color{blue}{\left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \sqrt[3]{9}\right)} \cdot {x}^{2}\right) - 12 \cdot x \]
  5. Applied associate-*l*_binary640.1

    \[\leadsto \left(3 + \color{blue}{\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot {x}^{2}\right)}\right) - 12 \cdot x \]
  6. Taylor expanded in x around 0 0.1

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

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

    \[\leadsto \mathsf{fma}\left(9, x \cdot x, 3\right) - x \cdot 12 \]

Reproduce

herbie shell --seed 2022125 
(FPCore (x)
  :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, D"
  :precision binary64

  :herbie-target
  (+ 3.0 (- (* (* 9.0 x) x) (* 12.0 x)))

  (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))