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

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): 3 points increase in error, 1 points decrease in error
  3. Taylor expanded in x around 0 0.0

    \[\leadsto \color{blue}{\left(y - 1\right) \cdot x + y} \]
  4. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, y - x\right)} \]
    Proof
    (fma.f64 y x (-.f64 y x)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y x) (-.f64 y x))): 2 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y x) (Rewrite<= unsub-neg_binary64 (+.f64 y (neg.f64 x)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y x) (+.f64 y (Rewrite<= mul-1-neg_binary64 (*.f64 -1 x)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 y x) (Rewrite=> +-commutative_binary64 (+.f64 (*.f64 -1 x) y))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (*.f64 y x) (*.f64 -1 x)) y)): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= distribute-rgt-in_binary64 (*.f64 x (+.f64 y -1))) y): 2 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 x (+.f64 y (Rewrite<= metadata-eval (neg.f64 1)))) y): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 x (Rewrite<= sub-neg_binary64 (-.f64 y 1))) y): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 y 1) x)) y): 0 points increase in error, 0 points decrease in error
  5. Final simplification0.0

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

Alternatives

Alternative 1
Error19.6
Cost984
\[\begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{+79}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -9034363349901394:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -1.0119576914670136 \cdot 10^{-13}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.6843551990494734 \cdot 10^{-28}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 2.342093802916112 \cdot 10^{+36}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+83}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 2
Error10.2
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1065249413986918 \cdot 10^{+21}:\\ \;\;\;\;y - x\\ \mathbf{elif}\;y \leq -9034363349901394:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 2.342093802916112 \cdot 10^{+36}:\\ \;\;\;\;y - x\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+83}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 3
Error0.9
Cost584
\[\begin{array}{l} t_0 := y + y \cdot x\\ \mathbf{if}\;y \leq -3579.0988771741213:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.18327023206112672:\\ \;\;\;\;y - x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error0.0
Cost448
\[\left(y + y \cdot x\right) - x \]
Alternative 5
Error18.9
Cost392
\[\begin{array}{l} \mathbf{if}\;y \leq -1.0119576914670136 \cdot 10^{-13}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.6843551990494734 \cdot 10^{-28}:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 6
Error36.1
Cost64
\[y \]

Error

Reproduce

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