Average Error: 0.2 → 0.2
Time: 6.7s
Precision: binary64
Cost: 13184
\[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
\[\mathsf{fma}\left(0.954929658551372, x, {x}^{3} \cdot -0.12900613773279798\right) \]
(FPCore (x)
 :precision binary64
 (- (* 0.954929658551372 x) (* 0.12900613773279798 (* (* x x) x))))
(FPCore (x)
 :precision binary64
 (fma 0.954929658551372 x (* (pow x 3.0) -0.12900613773279798)))
double code(double x) {
	return (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x));
}
double code(double x) {
	return fma(0.954929658551372, x, (pow(x, 3.0) * -0.12900613773279798));
}
function code(x)
	return Float64(Float64(0.954929658551372 * x) - Float64(0.12900613773279798 * Float64(Float64(x * x) * x)))
end
function code(x)
	return fma(0.954929658551372, x, Float64((x ^ 3.0) * -0.12900613773279798))
end
code[x_] := N[(N[(0.954929658551372 * x), $MachinePrecision] - N[(0.12900613773279798 * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(0.954929658551372 * x + N[(N[Power[x, 3.0], $MachinePrecision] * -0.12900613773279798), $MachinePrecision]), $MachinePrecision]
0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right)
\mathsf{fma}\left(0.954929658551372, x, {x}^{3} \cdot -0.12900613773279798\right)

Error

Derivation

  1. Initial program 0.2

    \[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
  2. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.954929658551372, x, {x}^{3} \cdot -0.12900613773279798\right)} \]
    Proof
    (fma.f64 238732414637843/250000000000000 x (*.f64 (pow.f64 x 3) -6450306886639899/50000000000000000)): 0 points increase in error, 0 points decrease in error
    (fma.f64 238732414637843/250000000000000 x (*.f64 (Rewrite<= cube-unmult_binary64 (*.f64 x (*.f64 x x))) -6450306886639899/50000000000000000)): 12 points increase in error, 3 points decrease in error
    (fma.f64 238732414637843/250000000000000 x (*.f64 (*.f64 x (*.f64 x x)) (Rewrite<= metadata-eval (neg.f64 6450306886639899/50000000000000000)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 238732414637843/250000000000000 x (*.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 x x) x)) (neg.f64 6450306886639899/50000000000000000))): 0 points increase in error, 0 points decrease in error
    (fma.f64 238732414637843/250000000000000 x (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 (*.f64 (*.f64 x x) x) 6450306886639899/50000000000000000)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 238732414637843/250000000000000 x (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 6450306886639899/50000000000000000 (*.f64 (*.f64 x x) x))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 238732414637843/250000000000000 x) (*.f64 6450306886639899/50000000000000000 (*.f64 (*.f64 x x) x)))): 1 points increase in error, 0 points decrease in error
  3. Final simplification0.2

    \[\leadsto \mathsf{fma}\left(0.954929658551372, x, {x}^{3} \cdot -0.12900613773279798\right) \]

Alternatives

Alternative 1
Error0.2
Cost6976
\[\mathsf{fma}\left(x \cdot -0.12900613773279798, x \cdot x, 0.954929658551372 \cdot x\right) \]
Alternative 2
Error0.2
Cost6848
\[x \cdot \mathsf{fma}\left(x, x \cdot -0.12900613773279798, 0.954929658551372\right) \]
Alternative 3
Error0.2
Cost6848
\[x \cdot \mathsf{fma}\left(x \cdot x, -0.12900613773279798, 0.954929658551372\right) \]
Alternative 4
Error1.1
Cost712
\[\begin{array}{l} t_0 := x \cdot \left(-0.12900613773279798 \cdot \left(x \cdot x\right)\right)\\ \mathbf{if}\;x \leq -2.7:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.7:\\ \;\;\;\;0.954929658551372 \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.1
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -2.7:\\ \;\;\;\;x \cdot \left(-0.12900613773279798 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;x \leq 2.7:\\ \;\;\;\;0.954929658551372 \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot -0.12900613773279798\right)\right)\\ \end{array} \]
Alternative 6
Error1.1
Cost712
\[\begin{array}{l} t_0 := \left(x \cdot x\right) \cdot \left(x \cdot -0.12900613773279798\right)\\ \mathbf{if}\;x \leq -2.7:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.7:\\ \;\;\;\;0.954929658551372 \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error0.2
Cost576
\[x \cdot \left(0.954929658551372 - x \cdot \left(x \cdot 0.12900613773279798\right)\right) \]
Alternative 8
Error16.3
Cost192
\[0.954929658551372 \cdot x \]

Error

Reproduce

herbie shell --seed 2022329 
(FPCore (x)
  :name "Rosa's Benchmark"
  :precision binary64
  (- (* 0.954929658551372 x) (* 0.12900613773279798 (* (* x x) x))))