Average Error: 0.2 → 0.2
Time: 7.6s
Precision: binary64
Cost: 6848
\[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
\[x \cdot \mathsf{fma}\left(x, x \cdot -0.12900613773279798, 0.954929658551372\right) \]
(FPCore (x)
 :precision binary64
 (- (* 0.954929658551372 x) (* 0.12900613773279798 (* (* x x) x))))
(FPCore (x)
 :precision binary64
 (* x (fma x (* x -0.12900613773279798) 0.954929658551372)))
double code(double x) {
	return (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x));
}
double code(double x) {
	return x * fma(x, (x * -0.12900613773279798), 0.954929658551372);
}
function code(x)
	return Float64(Float64(0.954929658551372 * x) - Float64(0.12900613773279798 * Float64(Float64(x * x) * x)))
end
function code(x)
	return Float64(x * fma(x, Float64(x * -0.12900613773279798), 0.954929658551372))
end
code[x_] := N[(N[(0.954929658551372 * x), $MachinePrecision] - N[(0.12900613773279798 * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(x * N[(x * N[(x * -0.12900613773279798), $MachinePrecision] + 0.954929658551372), $MachinePrecision]), $MachinePrecision]
0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right)
x \cdot \mathsf{fma}\left(x, x \cdot -0.12900613773279798, 0.954929658551372\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. Taylor expanded in x around 0 0.2

    \[\leadsto \color{blue}{-0.12900613773279798 \cdot {x}^{3} + 0.954929658551372 \cdot x} \]
  3. Simplified0.2

    \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x, x \cdot -0.12900613773279798, 0.954929658551372\right)} \]
    Proof
    (*.f64 x (fma.f64 x (*.f64 x -6450306886639899/50000000000000000) 238732414637843/250000000000000)): 0 points increase in error, 0 points decrease in error
    (*.f64 x (fma.f64 x (Rewrite<= *-commutative_binary64 (*.f64 -6450306886639899/50000000000000000 x)) 238732414637843/250000000000000)): 0 points increase in error, 0 points decrease in error
    (*.f64 x (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (*.f64 -6450306886639899/50000000000000000 x)) 238732414637843/250000000000000))): 1 points increase in error, 0 points decrease in error
    (*.f64 x (+.f64 (Rewrite=> *-commutative_binary64 (*.f64 (*.f64 -6450306886639899/50000000000000000 x) x)) 238732414637843/250000000000000)): 0 points increase in error, 0 points decrease in error
    (*.f64 x (+.f64 (Rewrite<= associate-*r*_binary64 (*.f64 -6450306886639899/50000000000000000 (*.f64 x x))) 238732414637843/250000000000000)): 15 points increase in error, 6 points decrease in error
    (Rewrite<= distribute-rgt-out_binary64 (+.f64 (*.f64 (*.f64 -6450306886639899/50000000000000000 (*.f64 x x)) x) (*.f64 238732414637843/250000000000000 x))): 2 points increase in error, 2 points decrease in error
    (+.f64 (Rewrite<= associate-*r*_binary64 (*.f64 -6450306886639899/50000000000000000 (*.f64 (*.f64 x x) x))) (*.f64 238732414637843/250000000000000 x)): 10 points increase in error, 12 points decrease in error
    (+.f64 (*.f64 -6450306886639899/50000000000000000 (Rewrite<= unpow3_binary64 (pow.f64 x 3))) (*.f64 238732414637843/250000000000000 x)): 3 points increase in error, 12 points decrease in error
  4. Final simplification0.2

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

Alternatives

Alternative 1
Error1.6
Cost712
\[\begin{array}{l} t_0 := \frac{x}{\frac{\frac{-7.751569170074954}{x}}{x}}\\ \mathbf{if}\;x \leq -13.248795400824125:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.2847777077475873 \cdot 10^{-8}:\\ \;\;\;\;x \cdot 0.954929658551372\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error1.6
Cost712
\[\begin{array}{l} t_0 := x \cdot \left(x \cdot \left(x \cdot -0.12900613773279798\right)\right)\\ \mathbf{if}\;x \leq -13.248795400824125:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.2847777077475873 \cdot 10^{-8}:\\ \;\;\;\;x \cdot 0.954929658551372\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.2
Cost576
\[x \cdot \left(0.954929658551372 + x \cdot \left(x \cdot -0.12900613773279798\right)\right) \]
Alternative 4
Error17.0
Cost192
\[\frac{x}{1.0471975511965979} \]
Alternative 5
Error16.7
Cost192
\[x \cdot 0.954929658551372 \]

Error

Reproduce

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