?

Average Accuracy: 100.0% → 100.0%
Time: 1.3s
Precision: binary64
Cost: 6656

?

\[x - y \cdot y \]
\[\mathsf{fma}\left(y, -y, x\right) \]
(FPCore (x y) :precision binary64 (- x (* y y)))
(FPCore (x y) :precision binary64 (fma y (- y) x))
double code(double x, double y) {
	return x - (y * y);
}
double code(double x, double y) {
	return fma(y, -y, x);
}
function code(x, y)
	return Float64(x - Float64(y * y))
end
function code(x, y)
	return fma(y, Float64(-y), x)
end
code[x_, y_] := N[(x - N[(y * y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(y * (-y) + x), $MachinePrecision]
x - y \cdot y
\mathsf{fma}\left(y, -y, x\right)

Error?

Derivation?

  1. Initial program 100.0%

    \[x - y \cdot y \]
  2. Taylor expanded in x around 0 100.0%

    \[\leadsto \color{blue}{-1 \cdot {y}^{2} + x} \]
  3. Simplified100.0%

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

    [Start]100.0

    \[ -1 \cdot {y}^{2} + x \]

    mul-1-neg [=>]100.0

    \[ \color{blue}{\left(-{y}^{2}\right)} + x \]

    unpow2 [=>]100.0

    \[ \left(-\color{blue}{y \cdot y}\right) + x \]

    distribute-rgt-neg-out [<=]100.0

    \[ \color{blue}{y \cdot \left(-y\right)} + x \]

    fma-def [=>]100.0

    \[ \color{blue}{\mathsf{fma}\left(y, -y, x\right)} \]
  4. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy82.2%
Cost521
\[\begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{+33} \lor \neg \left(y \leq 1.4 \cdot 10^{-38}\right):\\ \;\;\;\;y \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy100.0%
Cost320
\[x - y \cdot y \]
Alternative 3
Accuracy66.9%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023129 
(FPCore (x y)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1"
  :precision binary64
  (- x (* y y)))