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

Error

Derivation

  1. Initial program 0.0

    \[\left(x + 1\right) \cdot y - x \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, y\right) - x} \]
    Proof
    (-.f64 (fma.f64 x y y) x): 0 points increase in error, 0 points decrease in error
    (-.f64 (Rewrite=> fma-udef_binary64 (+.f64 (*.f64 x y) y)) x): 1 points increase in error, 0 points decrease in error
    (-.f64 (Rewrite=> distribute-lft1-in_binary64 (*.f64 (+.f64 x 1) y)) x): 1 points increase in error, 1 points decrease in error
  3. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(x, y, y\right) - x \]

Alternatives

Alternative 1
Error18.6
Cost984
\[\begin{array}{l} \mathbf{if}\;y \leq -1.4036274192456728 \cdot 10^{-9}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.2955365779880831 \cdot 10^{-29}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 646180.6945878172:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 4964495694362770:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 1.0088307958376626 \cdot 10^{+35}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+48}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 2
Error9.8
Cost584
\[\begin{array}{l} t_0 := y + x \cdot y\\ \mathbf{if}\;y \leq -1.4036274192456728 \cdot 10^{-9}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.2955365779880831 \cdot 10^{-29}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error9.8
Cost584
\[\begin{array}{l} t_0 := x \cdot y - x\\ \mathbf{if}\;x \leq -13074684.626674337:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7.123178213401636 \cdot 10^{-57}:\\ \;\;\;\;y + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error9.8
Cost584
\[\begin{array}{l} t_0 := x \cdot y - x\\ \mathbf{if}\;x \leq -13074684.626674337:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7.123178213401636 \cdot 10^{-57}:\\ \;\;\;\;y \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error9.8
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -13074684.626674337:\\ \;\;\;\;x \cdot y - x\\ \mathbf{elif}\;x \leq 7.123178213401636 \cdot 10^{-57}:\\ \;\;\;\;y \cdot \left(x + 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[\left(y + x \cdot y\right) - x \]
Alternative 7
Error18.6
Cost392
\[\begin{array}{l} \mathbf{if}\;x \leq -9.89106774016047 \cdot 10^{-5}:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq 7.123178213401636 \cdot 10^{-57}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
Alternative 8
Error36.1
Cost64
\[y \]

Error

Reproduce

herbie shell --seed 2022308 
(FPCore (x y)
  :name "Data.Colour.SRGB:transferFunction from colour-2.3.3"
  :precision binary64
  (- (* (+ x 1.0) y) x))