Radioactive exchange between two surfaces

Percentage Accurate: 86.1% → 99.9%
Time: 7.6s
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.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.9% accurate, 7.4× speedup?

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

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

    \[{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. 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) \]
    9. 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) \]
    10. lower-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) \]
    11. 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) \]
    12. 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) \]
    13. lower-*.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) \]
    14. 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) \]
    15. 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) \]
    16. metadata-evalN/A

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

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    18. 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)} \]
    19. lower-*.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)} \]
    20. lower-+.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) \]
    21. lower--.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 rewrites99.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. lift-*.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)} \]
    2. lift-*.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)} \]
    3. associate-*r*N/A

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

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

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

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

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

Alternative 2: 99.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{4} - {y}^{4}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-292}:\\ \;\;\;\;y \cdot \left(y \cdot \left(y \cdot \left(-y\right)\right)\right)\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\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-292)
     (* y (* y (* y (- y))))
     (if (<= t_0 INFINITY)
       (* 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-292) {
		tmp = y * (y * (y * -y));
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = x * (x * (x * x));
	} else {
		tmp = (y * y) * ((x - y) * (x + y));
	}
	return tmp;
}
public static double code(double x, double y) {
	double t_0 = Math.pow(x, 4.0) - Math.pow(y, 4.0);
	double tmp;
	if (t_0 <= -1e-292) {
		tmp = y * (y * (y * -y));
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = x * (x * (x * x));
	} else {
		tmp = (y * y) * ((x - y) * (x + y));
	}
	return tmp;
}
def code(x, y):
	t_0 = math.pow(x, 4.0) - math.pow(y, 4.0)
	tmp = 0
	if t_0 <= -1e-292:
		tmp = y * (y * (y * -y))
	elif t_0 <= math.inf:
		tmp = 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-292)
		tmp = Float64(y * Float64(y * Float64(y * Float64(-y))));
	elseif (t_0 <= Inf)
		tmp = Float64(x * Float64(x * Float64(x * x)));
	else
		tmp = Float64(Float64(y * y) * Float64(Float64(x - y) * Float64(x + y)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x ^ 4.0) - (y ^ 4.0);
	tmp = 0.0;
	if (t_0 <= -1e-292)
		tmp = y * (y * (y * -y));
	elseif (t_0 <= Inf)
		tmp = x * (x * (x * x));
	else
		tmp = (y * y) * ((x - y) * (x + y));
	end
	tmp_2 = 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-292], N[(y * N[(y * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(x * N[(x * N[(x * x), $MachinePrecision]), $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^{-292}:\\
\;\;\;\;y \cdot \left(y \cdot \left(y \cdot \left(-y\right)\right)\right)\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\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))) < -1.0000000000000001e-292

    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. flip--N/A

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{4} + {y}^{4}}{{x}^{4} \cdot {x}^{4} - {y}^{4} \cdot {y}^{4}}}} \]
      5. 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}}}}} \]
      6. flip--N/A

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{{x}^{4} - {y}^{4}}}} \]
      8. lower-/.f6499.9

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

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{{x}^{4}} - {y}^{4}}} \]
      11. 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}}} \]
      12. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{1}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{4}}}} \]
      13. 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)}}}} \]
      14. 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)}}} \]
      15. lower-*.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)}}} \]
    4. Applied rewrites99.7%

      \[\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. Taylor expanded in x around 0

      \[\leadsto \frac{1}{\frac{1}{\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 \frac{1}{\frac{1}{\color{blue}{\left(y \cdot y\right)} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)}} \]
      2. lower-*.f6499.4

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

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\left(y \cdot y\right)} \cdot \left(\left(x + y\right) \cdot \left(x - y\right)\right)}} \]
    8. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

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

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

        \[\leadsto \left(y \cdot y\right) \cdot \left(\left(x + y\right) \cdot \color{blue}{\left(x - y\right)}\right) \]
      7. difference-of-squaresN/A

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot y}{\frac{1}{y \cdot y}}} \]
      14. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot y}{\frac{1}{y \cdot y}}} \]
    9. Applied rewrites99.4%

      \[\leadsto \color{blue}{\frac{\left(x - y\right) \cdot \left(x + y\right)}{\frac{1}{y \cdot y}}} \]
    10. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-1 \cdot {y}^{4}} \]
    11. 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}{\mathsf{neg}\left({y}^{4}\right)} \]
      3. metadata-evalN/A

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

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

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

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

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

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

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

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

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

    if -1.0000000000000001e-292 < (-.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. Taylor expanded in x around inf

      \[\leadsto \color{blue}{{x}^{4}} \]
    4. Step-by-step derivation
      1. lower-pow.f6499.3

        \[\leadsto \color{blue}{{x}^{4}} \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{{x}^{4}} \]
    6. Step-by-step derivation
      1. Applied rewrites99.1%

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

      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. 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) \]
        9. 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) \]
        10. lower-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) \]
        11. 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) \]
        12. 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) \]
        13. lower-*.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) \]
        14. 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) \]
        15. 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) \]
        16. metadata-evalN/A

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

          \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
        18. 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)} \]
        19. lower-*.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)} \]
        20. lower-+.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) \]
        21. lower--.f64100.0

          \[\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 rewrites100.0%

        \[\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. 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) \]
    7. Recombined 3 regimes into one program.
    8. Final simplification99.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;{x}^{4} - {y}^{4} \leq -1 \cdot 10^{-292}:\\ \;\;\;\;y \cdot \left(y \cdot \left(y \cdot \left(-y\right)\right)\right)\\ \mathbf{elif}\;{x}^{4} - {y}^{4} \leq \infty:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)\\ \end{array} \]
    9. Add Preprocessing

    Reproduce

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