Radioactive exchange between two surfaces

Percentage Accurate: 86.2% → 99.9%
Time: 6.2s
Alternatives: 6
Speedup: 7.4×

Specification

?
\[\begin{array}{l} \\ {x}^{4} - {y}^{4} \end{array} \]
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
double code(double x, double y) {
	return pow(x, 4.0) - pow(y, 4.0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x ** 4.0d0) - (y ** 4.0d0)
end function
public static double code(double x, double y) {
	return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
def code(x, y):
	return math.pow(x, 4.0) - math.pow(y, 4.0)
function code(x, y)
	return Float64((x ^ 4.0) - (y ^ 4.0))
end
function tmp = code(x, y)
	tmp = (x ^ 4.0) - (y ^ 4.0);
end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{x}^{4} - {y}^{4}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 86.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ {x}^{4} - {y}^{4} \end{array} \]
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
double code(double x, double y) {
	return pow(x, 4.0) - pow(y, 4.0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x ** 4.0d0) - (y ** 4.0d0)
end function
public static double code(double x, double y) {
	return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
def code(x, y):
	return math.pow(x, 4.0) - math.pow(y, 4.0)
function code(x, y)
	return Float64((x ^ 4.0) - (y ^ 4.0))
end
function tmp = code(x, y)
	tmp = (x ^ 4.0) - (y ^ 4.0);
end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{x}^{4} - {y}^{4}
\end{array}

Alternative 1: 99.9% accurate, 7.4× speedup?

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

\\
\left(\left(x - y\right) \cdot \mathsf{fma}\left(y, y, x \cdot x\right)\right) \cdot \left(x + y\right)
\end{array}
Derivation
  1. Initial program 85.5%

    \[{x}^{4} - {y}^{4} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{{x}^{4} - {y}^{4}} \]
    2. sub-negN/A

      \[\leadsto \color{blue}{{x}^{4} + \left(\mathsf{neg}\left({y}^{4}\right)\right)} \]
    3. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left({y}^{4}\right)\right) + {x}^{4}} \]
    4. lift-pow.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{{y}^{4}}\right)\right) + {x}^{4} \]
    5. sqr-powN/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}}\right)\right) + {x}^{4} \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left({y}^{\left(\frac{4}{2}\right)}\right)\right) \cdot {y}^{\left(\frac{4}{2}\right)}} + {x}^{4} \]
    7. metadata-evalN/A

      \[\leadsto \left(\mathsf{neg}\left({y}^{\left(\frac{4}{2}\right)}\right)\right) \cdot {y}^{\color{blue}{2}} + {x}^{4} \]
    8. unpow2N/A

      \[\leadsto \left(\mathsf{neg}\left({y}^{\left(\frac{4}{2}\right)}\right)\right) \cdot \color{blue}{\left(y \cdot y\right)} + {x}^{4} \]
    9. associate-*r*N/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left({y}^{\left(\frac{4}{2}\right)}\right)\right) \cdot y\right) \cdot y} + {x}^{4} \]
    10. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\mathsf{neg}\left({y}^{\left(\frac{4}{2}\right)}\right)\right) \cdot y, y, {x}^{4}\right)} \]
    11. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left({y}^{\left(\frac{4}{2}\right)}\right)\right) \cdot y}, y, {x}^{4}\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left({y}^{\color{blue}{2}}\right)\right) \cdot y, y, {x}^{4}\right) \]
    13. unpow2N/A

      \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{y \cdot y}\right)\right) \cdot y, y, {x}^{4}\right) \]
    14. distribute-lft-neg-inN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) \cdot y\right)} \cdot y, y, {x}^{4}\right) \]
    15. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) \cdot y\right)} \cdot y, y, {x}^{4}\right) \]
    16. lower-neg.f6487.4

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\left(-y\right)} \cdot y\right) \cdot y, y, {x}^{4}\right) \]
  4. Applied rewrites87.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\left(-y\right) \cdot y\right) \cdot y, y, {x}^{4}\right)} \]
  5. Applied rewrites78.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(y, y, x \cdot x\right), \left(x - y\right) \cdot x, \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot y\right)\right)} \]
  6. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot x\right) + \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot y\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot x\right) + \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot y\right)} \]
    3. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x - y\right) \cdot x\right)} + \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot y\right) \]
    4. associate-*r*N/A

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x - y\right)\right) \cdot x} + \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot y\right) \]
    5. lift-*.f64N/A

      \[\leadsto \left(\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x - y\right)\right) \cdot x + \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x - y\right) \cdot y\right)} \]
    6. associate-*r*N/A

      \[\leadsto \left(\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x - y\right)\right) \cdot x + \color{blue}{\left(\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x - y\right)\right) \cdot y} \]
    7. distribute-lft-outN/A

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x - y\right)\right) \cdot \left(x + y\right)} \]
    8. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x - y\right)\right) \cdot \left(x + y\right)} \]
    9. *-commutativeN/A

      \[\leadsto \color{blue}{\left(\left(x - y\right) \cdot \mathsf{fma}\left(y, y, x \cdot x\right)\right)} \cdot \left(x + y\right) \]
    10. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\left(x - y\right) \cdot \mathsf{fma}\left(y, y, x \cdot x\right)\right)} \cdot \left(x + y\right) \]
    11. lower-+.f6499.8

      \[\leadsto \left(\left(x - y\right) \cdot \mathsf{fma}\left(y, y, x \cdot x\right)\right) \cdot \color{blue}{\left(x + y\right)} \]
  7. Applied rewrites99.8%

    \[\leadsto \color{blue}{\left(\left(x - y\right) \cdot \mathsf{fma}\left(y, y, x \cdot x\right)\right) \cdot \left(x + y\right)} \]
  8. Add Preprocessing

Alternative 2: 99.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{4} - {y}^{4}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-323}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(\left(-y\right) \cdot y\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- (pow x 4.0) (pow y 4.0))))
   (if (<= t_0 -1e-323)
     (* (* y y) (* (- y) y))
     (if (<= t_0 INFINITY)
       (* (fma y y (* x x)) (* x x))
       (* (* y y) (* (+ x y) (- x y)))))))
double code(double x, double y) {
	double t_0 = pow(x, 4.0) - pow(y, 4.0);
	double tmp;
	if (t_0 <= -1e-323) {
		tmp = (y * y) * (-y * y);
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = fma(y, y, (x * x)) * (x * x);
	} else {
		tmp = (y * y) * ((x + y) * (x - y));
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64((x ^ 4.0) - (y ^ 4.0))
	tmp = 0.0
	if (t_0 <= -1e-323)
		tmp = Float64(Float64(y * y) * Float64(Float64(-y) * y));
	elseif (t_0 <= Inf)
		tmp = Float64(fma(y, y, Float64(x * x)) * Float64(x * x));
	else
		tmp = Float64(Float64(y * y) * Float64(Float64(x + y) * Float64(x - y)));
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-323], N[(N[(y * y), $MachinePrecision] * N[((-y) * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(y * y + N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{4} - {y}^{4}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-323}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(\left(-y\right) \cdot y\right)\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -9.88131e-324

    1. Initial program 100.0%

      \[{x}^{4} - {y}^{4} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{{x}^{4} - {y}^{4}} \]
      2. lift-pow.f64N/A

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{4}} \]
      5. sqr-powN/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}} \]
      6. difference-of-squaresN/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{\left({y}^{\left(\frac{4}{2}\right)} + {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. metadata-evalN/A

        \[\leadsto \left({y}^{\color{blue}{2}} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. unpow2N/A

        \[\leadsto \left(\color{blue}{y \cdot y} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, {x}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      18. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      19. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      20. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      21. lower-+.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x + y\right)} \cdot \left(x - y\right)\right) \]
      22. lower--.f6499.7

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \color{blue}{\left(x - y\right)}\right) \]
    4. Applied rewrites99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    5. Taylor expanded in x around inf

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)} \]
      2. distribute-lft1-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot \frac{y}{x}\right)}\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(\color{blue}{0} \cdot \frac{y}{x}\right)\right) \]
      4. mul0-lftN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{0}\right) \]
      5. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + 0\right)\right)} \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot \color{blue}{1}\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{{x}^{2}} \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
      9. lower-*.f642.0

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    7. Applied rewrites2.0%

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    8. Taylor expanded in x around 0

      \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x\right) \]
    9. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
      2. lower-*.f642.0

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
    10. Applied rewrites2.0%

      \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
    11. Taylor expanded in x around 0

      \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(-1 \cdot {y}^{2} + x \cdot \left(y + -1 \cdot y\right)\right)} \]
    12. Step-by-step derivation
      1. distribute-rgt1-inN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + x \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot y\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + x \cdot \left(\color{blue}{0} \cdot y\right)\right) \]
      3. mul0-lftN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + x \cdot \color{blue}{0}\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + \color{blue}{0 \cdot x}\right) \]
      5. mul0-lftN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + \color{blue}{0}\right) \]
      6. +-rgt-identityN/A

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(-1 \cdot {y}^{2}\right)} \]
      7. unpow2N/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot \color{blue}{\left(y \cdot y\right)}\right) \]
      8. associate-*r*N/A

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot y\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot y\right)} \]
      10. mul-1-negN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot y\right) \]
      11. lower-neg.f6499.7

        \[\leadsto \left(y \cdot y\right) \cdot \left(\color{blue}{\left(-y\right)} \cdot y\right) \]
    13. Applied rewrites99.7%

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

    if -9.88131e-324 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < +inf.0

    1. Initial program 100.0%

      \[{x}^{4} - {y}^{4} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{{x}^{4} - {y}^{4}} \]
      2. lift-pow.f64N/A

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{4}} \]
      5. sqr-powN/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}} \]
      6. difference-of-squaresN/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{\left({y}^{\left(\frac{4}{2}\right)} + {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. metadata-evalN/A

        \[\leadsto \left({y}^{\color{blue}{2}} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. unpow2N/A

        \[\leadsto \left(\color{blue}{y \cdot y} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, {x}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      18. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      19. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      20. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      21. lower-+.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x + y\right)} \cdot \left(x - y\right)\right) \]
      22. lower--.f6499.9

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \color{blue}{\left(x - y\right)}\right) \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    5. Taylor expanded in x around inf

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)} \]
      2. distribute-lft1-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot \frac{y}{x}\right)}\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(\color{blue}{0} \cdot \frac{y}{x}\right)\right) \]
      4. mul0-lftN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{0}\right) \]
      5. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + 0\right)\right)} \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot \color{blue}{1}\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{{x}^{2}} \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
      9. lower-*.f6499.7

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    7. Applied rewrites99.7%

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

    if +inf.0 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64)))

    1. Initial program 0.0%

      \[{x}^{4} - {y}^{4} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{{x}^{4} - {y}^{4}} \]
      2. lift-pow.f64N/A

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{4}} \]
      5. sqr-powN/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}} \]
      6. difference-of-squaresN/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{\left({y}^{\left(\frac{4}{2}\right)} + {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. metadata-evalN/A

        \[\leadsto \left({y}^{\color{blue}{2}} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. unpow2N/A

        \[\leadsto \left(\color{blue}{y \cdot y} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, {x}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      18. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      19. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      20. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      21. lower-+.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x + y\right)} \cdot \left(x - y\right)\right) \]
      22. lower--.f64100.0

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \color{blue}{\left(x - y\right)}\right) \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \color{blue}{{y}^{2}} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
      2. lower-*.f64100.0

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
    7. Applied rewrites100.0%

      \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 69.9% accurate, 6.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.75 \cdot 10^{+131} \lor \neg \left(x \leq 2.4 \cdot 10^{+128}\right):\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(\left(-y\right) \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -1.75e+131) (not (<= x 2.4e+128)))
   (* (* y y) (* x x))
   (* (* y y) (* (- y) y))))
double code(double x, double y) {
	double tmp;
	if ((x <= -1.75e+131) || !(x <= 2.4e+128)) {
		tmp = (y * y) * (x * x);
	} else {
		tmp = (y * y) * (-y * y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-1.75d+131)) .or. (.not. (x <= 2.4d+128))) then
        tmp = (y * y) * (x * x)
    else
        tmp = (y * y) * (-y * y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -1.75e+131) || !(x <= 2.4e+128)) {
		tmp = (y * y) * (x * x);
	} else {
		tmp = (y * y) * (-y * y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -1.75e+131) or not (x <= 2.4e+128):
		tmp = (y * y) * (x * x)
	else:
		tmp = (y * y) * (-y * y)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -1.75e+131) || !(x <= 2.4e+128))
		tmp = Float64(Float64(y * y) * Float64(x * x));
	else
		tmp = Float64(Float64(y * y) * Float64(Float64(-y) * y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -1.75e+131) || ~((x <= 2.4e+128)))
		tmp = (y * y) * (x * x);
	else
		tmp = (y * y) * (-y * y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -1.75e+131], N[Not[LessEqual[x, 2.4e+128]], $MachinePrecision]], N[(N[(y * y), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[((-y) * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{+131} \lor \neg \left(x \leq 2.4 \cdot 10^{+128}\right):\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(\left(-y\right) \cdot y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.7499999999999999e131 or 2.4000000000000002e128 < x

    1. Initial program 64.5%

      \[{x}^{4} - {y}^{4} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{{x}^{4} - {y}^{4}} \]
      2. lift-pow.f64N/A

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{4}} \]
      5. sqr-powN/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}} \]
      6. difference-of-squaresN/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{\left({y}^{\left(\frac{4}{2}\right)} + {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. metadata-evalN/A

        \[\leadsto \left({y}^{\color{blue}{2}} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. unpow2N/A

        \[\leadsto \left(\color{blue}{y \cdot y} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, {x}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      18. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      19. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      20. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      21. lower-+.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x + y\right)} \cdot \left(x - y\right)\right) \]
      22. lower--.f64100.0

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \color{blue}{\left(x - y\right)}\right) \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    5. Taylor expanded in x around inf

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)} \]
      2. distribute-lft1-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot \frac{y}{x}\right)}\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(\color{blue}{0} \cdot \frac{y}{x}\right)\right) \]
      4. mul0-lftN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{0}\right) \]
      5. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + 0\right)\right)} \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot \color{blue}{1}\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{{x}^{2}} \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
      9. lower-*.f6492.1

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    7. Applied rewrites92.1%

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    8. Taylor expanded in x around 0

      \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x\right) \]
    9. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
      2. lower-*.f6468.7

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
    10. Applied rewrites68.7%

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

    if -1.7499999999999999e131 < x < 2.4000000000000002e128

    1. Initial program 94.4%

      \[{x}^{4} - {y}^{4} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{{x}^{4} - {y}^{4}} \]
      2. lift-pow.f64N/A

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      4. lift-pow.f64N/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{4}} \]
      5. sqr-powN/A

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}} \]
      6. difference-of-squaresN/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
      8. +-commutativeN/A

        \[\leadsto \color{blue}{\left({y}^{\left(\frac{4}{2}\right)} + {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. metadata-evalN/A

        \[\leadsto \left({y}^{\color{blue}{2}} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. unpow2N/A

        \[\leadsto \left(\color{blue}{y \cdot y} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, {x}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      18. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      19. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      20. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
      21. lower-+.f64N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x + y\right)} \cdot \left(x - y\right)\right) \]
      22. lower--.f6499.8

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \color{blue}{\left(x - y\right)}\right) \]
    4. Applied rewrites99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    5. Taylor expanded in x around inf

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)} \]
      2. distribute-lft1-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot \frac{y}{x}\right)}\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(\color{blue}{0} \cdot \frac{y}{x}\right)\right) \]
      4. mul0-lftN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{0}\right) \]
      5. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + 0\right)\right)} \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot \color{blue}{1}\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{{x}^{2}} \]
      8. unpow2N/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
      9. lower-*.f6444.7

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    7. Applied rewrites44.7%

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    8. Taylor expanded in x around 0

      \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x\right) \]
    9. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
      2. lower-*.f6423.0

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
    10. Applied rewrites23.0%

      \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
    11. Taylor expanded in x around 0

      \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(-1 \cdot {y}^{2} + x \cdot \left(y + -1 \cdot y\right)\right)} \]
    12. Step-by-step derivation
      1. distribute-rgt1-inN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + x \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot y\right)}\right) \]
      2. metadata-evalN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + x \cdot \left(\color{blue}{0} \cdot y\right)\right) \]
      3. mul0-lftN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + x \cdot \color{blue}{0}\right) \]
      4. *-commutativeN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + \color{blue}{0 \cdot x}\right) \]
      5. mul0-lftN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot {y}^{2} + \color{blue}{0}\right) \]
      6. +-rgt-identityN/A

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(-1 \cdot {y}^{2}\right)} \]
      7. unpow2N/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot \color{blue}{\left(y \cdot y\right)}\right) \]
      8. associate-*r*N/A

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot y\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot y\right)} \]
      10. mul-1-negN/A

        \[\leadsto \left(y \cdot y\right) \cdot \left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot y\right) \]
      11. lower-neg.f6477.0

        \[\leadsto \left(y \cdot y\right) \cdot \left(\color{blue}{\left(-y\right)} \cdot y\right) \]
    13. Applied rewrites77.0%

      \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(\left(-y\right) \cdot y\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification74.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.75 \cdot 10^{+131} \lor \neg \left(x \leq 2.4 \cdot 10^{+128}\right):\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(\left(-y\right) \cdot y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 75.1% accurate, 9.4× speedup?

\[\begin{array}{l} \\ \left(y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \end{array} \]
(FPCore (x y) :precision binary64 (* (* y y) (* (+ x y) (- x y))))
double code(double x, double y) {
	return (y * y) * ((x + y) * (x - y));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (y * y) * ((x + y) * (x - y))
end function
public static double code(double x, double y) {
	return (y * y) * ((x + y) * (x - y));
}
def code(x, y):
	return (y * y) * ((x + y) * (x - y))
function code(x, y)
	return Float64(Float64(y * y) * Float64(Float64(x + y) * Float64(x - y)))
end
function tmp = code(x, y)
	tmp = (y * y) * ((x + y) * (x - y));
end
code[x_, y_] := N[(N[(y * y), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)
\end{array}
Derivation
  1. Initial program 85.5%

    \[{x}^{4} - {y}^{4} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{{x}^{4} - {y}^{4}} \]
    2. lift-pow.f64N/A

      \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
    3. sqr-powN/A

      \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
    4. lift-pow.f64N/A

      \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{4}} \]
    5. sqr-powN/A

      \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}} \]
    6. difference-of-squaresN/A

      \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
    8. +-commutativeN/A

      \[\leadsto \color{blue}{\left({y}^{\left(\frac{4}{2}\right)} + {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    9. metadata-evalN/A

      \[\leadsto \left({y}^{\color{blue}{2}} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    10. unpow2N/A

      \[\leadsto \left(\color{blue}{y \cdot y} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    11. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(y, y, {x}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    13. unpow2N/A

      \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    14. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    15. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    16. unpow2N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    17. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
    18. unpow2N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    19. difference-of-squaresN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    20. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    21. lower-+.f64N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x + y\right)} \cdot \left(x - y\right)\right) \]
    22. lower--.f6499.8

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \color{blue}{\left(x - y\right)}\right) \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{y}^{2}} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
  6. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
    2. lower-*.f6477.5

      \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
  7. Applied rewrites77.5%

    \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
  8. Add Preprocessing

Alternative 5: 31.6% accurate, 12.9× speedup?

\[\begin{array}{l} \\ \left(y \cdot y\right) \cdot \left(x \cdot x\right) \end{array} \]
(FPCore (x y) :precision binary64 (* (* y y) (* x x)))
double code(double x, double y) {
	return (y * y) * (x * x);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (y * y) * (x * x)
end function
public static double code(double x, double y) {
	return (y * y) * (x * x);
}
def code(x, y):
	return (y * y) * (x * x)
function code(x, y)
	return Float64(Float64(y * y) * Float64(x * x))
end
function tmp = code(x, y)
	tmp = (y * y) * (x * x);
end
code[x_, y_] := N[(N[(y * y), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(y \cdot y\right) \cdot \left(x \cdot x\right)
\end{array}
Derivation
  1. Initial program 85.5%

    \[{x}^{4} - {y}^{4} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{{x}^{4} - {y}^{4}} \]
    2. lift-pow.f64N/A

      \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
    3. sqr-powN/A

      \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
    4. lift-pow.f64N/A

      \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{4}} \]
    5. sqr-powN/A

      \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}} \]
    6. difference-of-squaresN/A

      \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)} \]
    8. +-commutativeN/A

      \[\leadsto \color{blue}{\left({y}^{\left(\frac{4}{2}\right)} + {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    9. metadata-evalN/A

      \[\leadsto \left({y}^{\color{blue}{2}} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    10. unpow2N/A

      \[\leadsto \left(\color{blue}{y \cdot y} + {x}^{\left(\frac{4}{2}\right)}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    11. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, {x}^{\left(\frac{4}{2}\right)}\right)} \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(y, y, {x}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    13. unpow2N/A

      \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    14. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    15. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    16. unpow2N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    17. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
    18. unpow2N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    19. difference-of-squaresN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    20. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    21. lower-+.f64N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x + y\right)} \cdot \left(x - y\right)\right) \]
    22. lower--.f6499.8

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \color{blue}{\left(x - y\right)}\right) \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
  5. Taylor expanded in x around inf

    \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)\right)} \]
  6. Step-by-step derivation
    1. distribute-lft-inN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(-1 \cdot \frac{y}{x} + \frac{y}{x}\right)\right)} \]
    2. distribute-lft1-inN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot \frac{y}{x}\right)}\right) \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \left(\color{blue}{0} \cdot \frac{y}{x}\right)\right) \]
    4. mul0-lftN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot 1 + {x}^{2} \cdot \color{blue}{0}\right) \]
    5. distribute-lft-inN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left({x}^{2} \cdot \left(1 + 0\right)\right)} \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left({x}^{2} \cdot \color{blue}{1}\right) \]
    7. *-rgt-identityN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{{x}^{2}} \]
    8. unpow2N/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    9. lower-*.f6458.8

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
  7. Applied rewrites58.8%

    \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
  8. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x\right) \]
  9. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
    2. lower-*.f6436.5

      \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
  10. Applied rewrites36.5%

    \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x\right) \]
  11. Add Preprocessing

Alternative 6: 21.6% accurate, 12.9× speedup?

\[\begin{array}{l} \\ \left(y \cdot y\right) \cdot \left(y \cdot y\right) \end{array} \]
(FPCore (x y) :precision binary64 (* (* y y) (* y y)))
double code(double x, double y) {
	return (y * y) * (y * y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (y * y) * (y * y)
end function
public static double code(double x, double y) {
	return (y * y) * (y * y);
}
def code(x, y):
	return (y * y) * (y * y)
function code(x, y)
	return Float64(Float64(y * y) * Float64(y * y))
end
function tmp = code(x, y)
	tmp = (y * y) * (y * y);
end
code[x_, y_] := N[(N[(y * y), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(y \cdot y\right) \cdot \left(y \cdot y\right)
\end{array}
Derivation
  1. Initial program 85.5%

    \[{x}^{4} - {y}^{4} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{-1 \cdot {y}^{4}} \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left({y}^{4}\right)} \]
    2. lower-neg.f64N/A

      \[\leadsto \color{blue}{-{y}^{4}} \]
    3. lower-pow.f6456.8

      \[\leadsto -\color{blue}{{y}^{4}} \]
  5. Applied rewrites56.8%

    \[\leadsto \color{blue}{-{y}^{4}} \]
  6. Applied rewrites24.5%

    \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(y \cdot y\right)} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024299 
(FPCore (x y)
  :name "Radioactive exchange between two surfaces"
  :precision binary64
  (- (pow x 4.0) (pow y 4.0)))