Average Error: 0.1 → 0.1
Time: 8.0s
Precision: binary64
Cost: 13120
\[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
\[\mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.12, -0.253\right), 1\right) \]
(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
(FPCore (x) :precision binary64 (fma x (fma x -0.12 -0.253) 1.0))
double code(double x) {
	return 1.0 - (x * (0.253 + (x * 0.12)));
}
double code(double x) {
	return fma(x, fma(x, -0.12, -0.253), 1.0);
}
function code(x)
	return Float64(1.0 - Float64(x * Float64(0.253 + Float64(x * 0.12))))
end
function code(x)
	return fma(x, fma(x, -0.12, -0.253), 1.0)
end
code[x_] := N[(1.0 - N[(x * N[(0.253 + N[(x * 0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(x * N[(x * -0.12 + -0.253), $MachinePrecision] + 1.0), $MachinePrecision]
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.12, -0.253\right), 1\right)

Error

Derivation

  1. Initial program 0.1

    \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.12, -0.253\right), 1\right)} \]
    Proof
    (fma.f64 x (fma.f64 x -3/25 -253/1000) 1): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (fma.f64 x (Rewrite<= metadata-eval (neg.f64 3/25)) -253/1000) 1): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (fma.f64 x (neg.f64 3/25) (Rewrite<= metadata-eval (neg.f64 253/1000))) 1): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (neg.f64 3/25)) (neg.f64 253/1000))) 1): 2 points increase in error, 1 points decrease in error
    (fma.f64 x (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 x 3/25))) (neg.f64 253/1000)) 1): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 253/1000) (neg.f64 (*.f64 x 3/25)))) 1): 0 points increase in error, 0 points decrease in error
    (fma.f64 x (Rewrite<= distribute-neg-in_binary64 (neg.f64 (+.f64 253/1000 (*.f64 x 3/25)))) 1): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (neg.f64 (+.f64 253/1000 (*.f64 x 3/25)))) 1)): 1 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 x (+.f64 253/1000 (*.f64 x 3/25))))) 1): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= distribute-lft-neg-out_binary64 (*.f64 (neg.f64 x) (+.f64 253/1000 (*.f64 x 3/25)))) 1): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 1 (*.f64 (neg.f64 x) (+.f64 253/1000 (*.f64 x 3/25))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 1 (*.f64 x (+.f64 253/1000 (*.f64 x 3/25))))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.12, -0.253\right), 1\right) \]

Alternatives

Alternative 1
Error0.2
Cost704
\[1 + \left(-0.12 \cdot \left(x \cdot x\right) - x \cdot 0.253\right) \]
Alternative 2
Error2.2
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(x \cdot -0.12\right)\\ \mathbf{if}\;x \leq -861073.7899806314:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7.135383061402566 \cdot 10^{-9}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error2.2
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -861073.7899806314:\\ \;\;\;\;-0.12 \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;x \leq 7.135383061402566 \cdot 10^{-9}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot -0.12\right)\\ \end{array} \]
Alternative 4
Error1.9
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -861073.7899806314:\\ \;\;\;\;-0.12 \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;x \leq 7.135383061402566 \cdot 10^{-9}:\\ \;\;\;\;1 - x \cdot 0.253\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot -0.12\right)\\ \end{array} \]
Alternative 5
Error0.1
Cost576
\[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
Alternative 6
Error1.9
Cost448
\[1 + -0.12 \cdot \left(x \cdot x\right) \]
Alternative 7
Error22.3
Cost64
\[1 \]

Error

Reproduce

herbie shell --seed 2022317 
(FPCore (x)
  :name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A"
  :precision binary64
  (- 1.0 (* x (+ 0.253 (* x 0.12)))))