Radioactive exchange between two surfaces

Percentage Accurate: 86.1% → 99.8%
Time: 10.0s
Alternatives: 8
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 8 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.1% 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.8% accurate, 4.6× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{4} \cdot {x}^{4} - {y}^{4} \cdot {y}^{4}}{{x}^{4} + {y}^{4}}} \]
    2. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{4} + {y}^{4}}{{x}^{4} \cdot {x}^{4} - {y}^{4} \cdot {y}^{4}}}} \]
    3. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{4} + {y}^{4}}{{x}^{4} \cdot {x}^{4} - {y}^{4} \cdot {y}^{4}}}} \]
    4. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{4} \cdot {x}^{4} - {y}^{4} \cdot {y}^{4}}{{x}^{4} + {y}^{4}}}}} \]
    5. flip--N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{{x}^{4} - {y}^{4}}}} \]
    6. /-lowering-/.f64N/A

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

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

      \[\leadsto \frac{1}{\frac{1}{{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)}}}} \]
    9. difference-of-squaresN/A

      \[\leadsto \frac{1}{\frac{1}{\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)}}} \]
    10. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\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)}}} \]
    11. metadata-evalN/A

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{1}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)}} \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)}}} \]
  5. Step-by-step derivation
    1. associate-*r*N/A

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}{x - y}}} \]
    3. /-lowering-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}{x - y}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}}{x - y}} \]
    5. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{\frac{\frac{1}{\color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}}{x - y}} \]
    6. accelerator-lowering-fma.f64N/A

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

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

      \[\leadsto \frac{1}{\frac{\frac{1}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x + y\right)}}}{x - y}} \]
    9. --lowering--.f6499.8

      \[\leadsto \frac{1}{\frac{\frac{1}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x + y\right)}}{\color{blue}{x - y}}} \]
  6. Applied egg-rr99.8%

    \[\leadsto \frac{1}{\color{blue}{\frac{\frac{1}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x + y\right)}}{x - y}}} \]
  7. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \color{blue}{\frac{x - y}{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{x - y}{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}} \]
    3. --lowering--.f64N/A

      \[\leadsto \frac{\color{blue}{x - y}}{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \frac{x - y}{\color{blue}{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}} \]
    5. *-lowering-*.f64N/A

      \[\leadsto \frac{x - y}{\frac{1}{\color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}} \]
    6. accelerator-lowering-fma.f64N/A

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

      \[\leadsto \frac{x - y}{\frac{1}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left(x + y\right)}} \]
    8. +-lowering-+.f6499.9

      \[\leadsto \frac{x - y}{\frac{1}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x + y\right)}}} \]
  8. Applied egg-rr99.9%

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

Alternative 2: 92.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{x}^{4} - {y}^{4} \leq -5 \cdot 10^{-261}:\\ \;\;\;\;y \cdot \left(y \cdot \left(y \cdot \left(-y\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (- (pow x 4.0) (pow y 4.0)) -5e-261)
   (* y (* y (* y (- y))))
   (* x (* x (* x x)))))
double code(double x, double y) {
	double tmp;
	if ((pow(x, 4.0) - pow(y, 4.0)) <= -5e-261) {
		tmp = y * (y * (y * -y));
	} else {
		tmp = x * (x * (x * x));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (((x ** 4.0d0) - (y ** 4.0d0)) <= (-5d-261)) then
        tmp = y * (y * (y * -y))
    else
        tmp = x * (x * (x * x))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((Math.pow(x, 4.0) - Math.pow(y, 4.0)) <= -5e-261) {
		tmp = y * (y * (y * -y));
	} else {
		tmp = x * (x * (x * x));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (math.pow(x, 4.0) - math.pow(y, 4.0)) <= -5e-261:
		tmp = y * (y * (y * -y))
	else:
		tmp = x * (x * (x * x))
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64((x ^ 4.0) - (y ^ 4.0)) <= -5e-261)
		tmp = Float64(y * Float64(y * Float64(y * Float64(-y))));
	else
		tmp = Float64(x * Float64(x * Float64(x * x)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (((x ^ 4.0) - (y ^ 4.0)) <= -5e-261)
		tmp = y * (y * (y * -y));
	else
		tmp = x * (x * (x * x));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], -5e-261], N[(y * N[(y * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} - {y}^{4} \leq -5 \cdot 10^{-261}:\\
\;\;\;\;y \cdot \left(y \cdot \left(y \cdot \left(-y\right)\right)\right)\\

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


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

    1. Initial program 100.0%

      \[{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. neg-lowering-neg.f64N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left({y}^{4}\right)} \]
      3. pow-lowering-pow.f64100.0

        \[\leadsto -\color{blue}{{y}^{4}} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{-{y}^{4}} \]
    6. Step-by-step derivation
      1. metadata-evalN/A

        \[\leadsto \mathsf{neg}\left({y}^{\color{blue}{\left(2 \cdot 2\right)}}\right) \]
      2. pow-powN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{{\left({y}^{2}\right)}^{2}}\right) \]
      3. pow2N/A

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

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

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(y \cdot y\right) \cdot y\right) \cdot y}\right) \]
      6. pow3N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{{y}^{3}} \cdot y\right) \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{{y}^{3} \cdot \left(\mathsf{neg}\left(y\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{{y}^{3} \cdot \left(\mathsf{neg}\left(y\right)\right)} \]
      9. cube-multN/A

        \[\leadsto \color{blue}{\left(y \cdot \left(y \cdot y\right)\right)} \cdot \left(\mathsf{neg}\left(y\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(y \cdot \left(y \cdot y\right)\right)} \cdot \left(\mathsf{neg}\left(y\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \left(y \cdot \color{blue}{\left(y \cdot y\right)}\right) \cdot \left(\mathsf{neg}\left(y\right)\right) \]
      12. neg-lowering-neg.f6499.9

        \[\leadsto \left(y \cdot \left(y \cdot y\right)\right) \cdot \color{blue}{\left(-y\right)} \]
    7. Applied egg-rr99.9%

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

    if -4.99999999999999981e-261 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64)))

    1. Initial program 76.6%

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

      \[\leadsto \color{blue}{{x}^{4}} \]
    4. Step-by-step derivation
      1. pow-lowering-pow.f6489.5

        \[\leadsto \color{blue}{{x}^{4}} \]
    5. Simplified89.5%

      \[\leadsto \color{blue}{{x}^{4}} \]
    6. Step-by-step derivation
      1. metadata-evalN/A

        \[\leadsto {x}^{\color{blue}{\left(3 + 1\right)}} \]
      2. pow-plusN/A

        \[\leadsto \color{blue}{{x}^{3} \cdot x} \]
      3. cube-unmultN/A

        \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot x \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot x\right)\right) \cdot x} \]
      5. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot x \]
      6. *-lowering-*.f6489.4

        \[\leadsto \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot x \]
    7. Applied egg-rr89.4%

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot x\right)\right) \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{x}^{4} - {y}^{4} \leq -5 \cdot 10^{-261}:\\ \;\;\;\;y \cdot \left(y \cdot \left(y \cdot \left(-y\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.8% accurate, 4.6× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{4} \cdot {x}^{4} - {y}^{4} \cdot {y}^{4}}{{x}^{4} + {y}^{4}}} \]
    2. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{4} + {y}^{4}}{{x}^{4} \cdot {x}^{4} - {y}^{4} \cdot {y}^{4}}}} \]
    3. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{4} + {y}^{4}}{{x}^{4} \cdot {x}^{4} - {y}^{4} \cdot {y}^{4}}}} \]
    4. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{4} \cdot {x}^{4} - {y}^{4} \cdot {y}^{4}}{{x}^{4} + {y}^{4}}}}} \]
    5. flip--N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{{x}^{4} - {y}^{4}}}} \]
    6. /-lowering-/.f64N/A

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

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

      \[\leadsto \frac{1}{\frac{1}{{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)}}}} \]
    9. difference-of-squaresN/A

      \[\leadsto \frac{1}{\frac{1}{\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)}}} \]
    10. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\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)}}} \]
    11. metadata-evalN/A

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{1}{\mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right)}} \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)}}} \]
  5. Step-by-step derivation
    1. associate-*r*N/A

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}{x - y}}} \]
    3. /-lowering-/.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}{x - y}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}}{x - y}} \]
    5. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{\frac{\frac{1}{\color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}}{x - y}} \]
    6. accelerator-lowering-fma.f64N/A

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

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

      \[\leadsto \frac{1}{\frac{\frac{1}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x + y\right)}}}{x - y}} \]
    9. --lowering--.f6499.8

      \[\leadsto \frac{1}{\frac{\frac{1}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x + y\right)}}{\color{blue}{x - y}}} \]
  6. Applied egg-rr99.8%

    \[\leadsto \frac{1}{\color{blue}{\frac{\frac{1}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x + y\right)}}{x - y}}} \]
  7. Step-by-step derivation
    1. div-invN/A

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{1}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}}{\frac{1}{x - y}}} \]
    3. remove-double-divN/A

      \[\leadsto \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}{\frac{1}{x - y}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}{\frac{1}{x - y}}} \]
    5. *-lowering-*.f64N/A

      \[\leadsto \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x + y\right)}}{\frac{1}{x - y}} \]
    6. accelerator-lowering-fma.f64N/A

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

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

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

      \[\leadsto \frac{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x + y\right)}{\color{blue}{\frac{1}{x - y}}} \]
    10. --lowering--.f6499.8

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

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

Alternative 4: 99.8% accurate, 4.6× speedup?

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

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

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

      \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
    2. 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)}} \]
    3. 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)} \]
    4. *-lowering-*.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)} \]
    5. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
  5. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{\frac{1}{\color{blue}{x + y}}}\right) \]
    6. un-div-invN/A

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

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

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

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \frac{x - y}{\color{blue}{\frac{1}{x + y}}} \]
    10. +-lowering-+.f6499.8

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \frac{x - y}{\frac{1}{\color{blue}{x + y}}} \]
  6. Applied egg-rr99.8%

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

Alternative 5: 99.8% accurate, 7.4× speedup?

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

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

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

      \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
    2. 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)}} \]
    3. 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)} \]
    4. *-lowering-*.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)} \]
    5. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y \cdot y + x \cdot x\right)} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
    2. accelerator-lowering-fma.f64N/A

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

      \[\leadsto \mathsf{fma}\left(y, y, \color{blue}{x \cdot x}\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right) \]
  6. Applied egg-rr99.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) \]
  7. Final simplification99.8%

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

Alternative 6: 99.8% accurate, 7.4× speedup?

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

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

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

      \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
    2. 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)}} \]
    3. 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)} \]
    4. *-lowering-*.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)} \]
    5. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
  5. Final simplification99.8%

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

Alternative 7: 57.7% accurate, 12.9× speedup?

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

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

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

    \[\leadsto \color{blue}{{x}^{4}} \]
  4. Step-by-step derivation
    1. pow-lowering-pow.f6460.4

      \[\leadsto \color{blue}{{x}^{4}} \]
  5. Simplified60.4%

    \[\leadsto \color{blue}{{x}^{4}} \]
  6. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto {x}^{\color{blue}{\left(3 + 1\right)}} \]
    2. pow-plusN/A

      \[\leadsto \color{blue}{{x}^{3} \cdot x} \]
    3. cube-unmultN/A

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot x \]
    4. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot x\right)\right) \cdot x} \]
    5. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot x \]
    6. *-lowering-*.f6460.3

      \[\leadsto \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot x \]
  7. Applied egg-rr60.3%

    \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot x\right)\right) \cdot x} \]
  8. Final simplification60.3%

    \[\leadsto x \cdot \left(x \cdot \left(x \cdot x\right)\right) \]
  9. Add Preprocessing

Alternative 8: 57.7% accurate, 12.9× speedup?

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

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

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

    \[\leadsto \color{blue}{{x}^{4}} \]
  4. Step-by-step derivation
    1. pow-lowering-pow.f6460.4

      \[\leadsto \color{blue}{{x}^{4}} \]
  5. Simplified60.4%

    \[\leadsto \color{blue}{{x}^{4}} \]
  6. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto {x}^{\color{blue}{\left(2 + 2\right)}} \]
    2. pow-prod-upN/A

      \[\leadsto \color{blue}{{x}^{2} \cdot {x}^{2}} \]
    3. pow2N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot {x}^{2} \]
    4. pow2N/A

      \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    5. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \]
    6. *-lowering-*.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \left(x \cdot x\right) \]
    7. *-lowering-*.f6460.2

      \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
  7. Applied egg-rr60.2%

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

Reproduce

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