Radioactive exchange between two surfaces

Percentage Accurate: 86.2% → 96.7%
Time: 4.9s
Alternatives: 5
Speedup: 12.0×

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 5 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: 96.7% accurate, 12.0× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} t_0 := x \cdot x + y \cdot y\\ \mathbf{if}\;x \leq 1.95 \cdot 10^{+148}:\\ \;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot t_0\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (* x x) (* y y))))
   (if (<= x 1.95e+148) (* t_0 (- (* x x) (* y y))) (* (* x x) t_0))))
x = abs(x);
double code(double x, double y) {
	double t_0 = (x * x) + (y * y);
	double tmp;
	if (x <= 1.95e+148) {
		tmp = t_0 * ((x * x) - (y * y));
	} else {
		tmp = (x * x) * t_0;
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x * x) + (y * y)
    if (x <= 1.95d+148) then
        tmp = t_0 * ((x * x) - (y * y))
    else
        tmp = (x * x) * t_0
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
	double t_0 = (x * x) + (y * y);
	double tmp;
	if (x <= 1.95e+148) {
		tmp = t_0 * ((x * x) - (y * y));
	} else {
		tmp = (x * x) * t_0;
	}
	return tmp;
}
x = abs(x)
def code(x, y):
	t_0 = (x * x) + (y * y)
	tmp = 0
	if x <= 1.95e+148:
		tmp = t_0 * ((x * x) - (y * y))
	else:
		tmp = (x * x) * t_0
	return tmp
x = abs(x)
function code(x, y)
	t_0 = Float64(Float64(x * x) + Float64(y * y))
	tmp = 0.0
	if (x <= 1.95e+148)
		tmp = Float64(t_0 * Float64(Float64(x * x) - Float64(y * y)));
	else
		tmp = Float64(Float64(x * x) * t_0);
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x, y)
	t_0 = (x * x) + (y * y);
	tmp = 0.0;
	if (x <= 1.95e+148)
		tmp = t_0 * ((x * x) - (y * y));
	else
		tmp = (x * x) * t_0;
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.95e+148], N[(t$95$0 * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := x \cdot x + y \cdot y\\
\mathbf{if}\;x \leq 1.95 \cdot 10^{+148}:\\
\;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.95000000000000001e148

    1. Initial program 88.8%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. sqr-pow88.7%

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow88.6%

        \[\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-squares95.5%

        \[\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. metadata-eval95.5%

        \[\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) \]
      5. pow295.5%

        \[\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) \]
      6. metadata-eval95.5%

        \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      7. pow295.5%

        \[\leadsto \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      8. metadata-eval95.5%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow295.5%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. metadata-eval95.5%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      11. pow295.5%

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

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

    if 1.95000000000000001e148 < x

    1. Initial program 66.7%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. sqr-pow66.7%

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow66.7%

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

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

        \[\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) \]
      5. pow275.0%

        \[\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) \]
      6. metadata-eval75.0%

        \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      7. pow275.0%

        \[\leadsto \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      8. metadata-eval75.0%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow275.0%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. metadata-eval75.0%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      11. pow275.0%

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

      \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around inf 87.5%

      \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \color{blue}{{x}^{2}} \]
    5. Step-by-step derivation
      1. unpow287.5%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    6. Simplified87.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.95 \cdot 10^{+148}:\\ \;\;\;\;\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\ \end{array} \]

Alternative 2: 74.2% accurate, 13.6× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 3.5 \cdot 10^{-80}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+149}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (if (<= y 3.5e-80)
   (* (* x x) (+ (* x x) (* y y)))
   (if (<= y 3.2e+149)
     (* (* y y) (- (* x x) (* y y)))
     (* (* y y) (* y (- y))))))
x = abs(x);
double code(double x, double y) {
	double tmp;
	if (y <= 3.5e-80) {
		tmp = (x * x) * ((x * x) + (y * y));
	} else if (y <= 3.2e+149) {
		tmp = (y * y) * ((x * x) - (y * y));
	} else {
		tmp = (y * y) * (y * -y);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= 3.5d-80) then
        tmp = (x * x) * ((x * x) + (y * y))
    else if (y <= 3.2d+149) then
        tmp = (y * y) * ((x * x) - (y * y))
    else
        tmp = (y * y) * (y * -y)
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
	double tmp;
	if (y <= 3.5e-80) {
		tmp = (x * x) * ((x * x) + (y * y));
	} else if (y <= 3.2e+149) {
		tmp = (y * y) * ((x * x) - (y * y));
	} else {
		tmp = (y * y) * (y * -y);
	}
	return tmp;
}
x = abs(x)
def code(x, y):
	tmp = 0
	if y <= 3.5e-80:
		tmp = (x * x) * ((x * x) + (y * y))
	elif y <= 3.2e+149:
		tmp = (y * y) * ((x * x) - (y * y))
	else:
		tmp = (y * y) * (y * -y)
	return tmp
x = abs(x)
function code(x, y)
	tmp = 0.0
	if (y <= 3.5e-80)
		tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y)));
	elseif (y <= 3.2e+149)
		tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y)));
	else
		tmp = Float64(Float64(y * y) * Float64(y * Float64(-y)));
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 3.5e-80)
		tmp = (x * x) * ((x * x) + (y * y));
	elseif (y <= 3.2e+149)
		tmp = (y * y) * ((x * x) - (y * y));
	else
		tmp = (y * y) * (y * -y);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_, y_] := If[LessEqual[y, 3.5e-80], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+149], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{-80}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\

\mathbf{elif}\;y \leq 3.2 \cdot 10^{+149}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < 3.50000000000000015e-80

    1. Initial program 91.0%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. sqr-pow90.9%

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow90.8%

        \[\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-squares95.6%

        \[\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. metadata-eval95.6%

        \[\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) \]
      5. pow295.6%

        \[\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) \]
      6. metadata-eval95.6%

        \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      7. pow295.6%

        \[\leadsto \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      8. metadata-eval95.6%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow295.6%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. metadata-eval95.6%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      11. pow295.6%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied egg-rr95.6%

      \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around inf 69.1%

      \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \color{blue}{{x}^{2}} \]
    5. Step-by-step derivation
      1. unpow269.1%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    6. Simplified69.1%

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

    if 3.50000000000000015e-80 < y < 3.2000000000000002e149

    1. Initial program 88.9%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. sqr-pow88.9%

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow88.7%

        \[\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-squares99.8%

        \[\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. metadata-eval99.8%

        \[\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) \]
      5. pow299.8%

        \[\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) \]
      6. metadata-eval99.8%

        \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      7. pow299.8%

        \[\leadsto \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      8. metadata-eval99.8%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow299.8%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. metadata-eval99.8%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      11. pow299.8%

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

      \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around 0 89.5%

      \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x - y \cdot y\right) \]
    5. Step-by-step derivation
      1. unpow289.5%

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x - y \cdot y\right) \]
    6. Simplified89.5%

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

    if 3.2000000000000002e149 < y

    1. Initial program 62.9%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. sqr-pow62.9%

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow62.9%

        \[\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-squares74.3%

        \[\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. metadata-eval74.3%

        \[\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) \]
      5. pow274.3%

        \[\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) \]
      6. metadata-eval74.3%

        \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      7. pow274.3%

        \[\leadsto \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      8. metadata-eval74.3%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow274.3%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. metadata-eval74.3%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      11. pow274.3%

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

      \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around 0 74.3%

      \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x - y \cdot y\right) \]
    5. Step-by-step derivation
      1. unpow274.3%

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x - y \cdot y\right) \]
    6. Simplified74.3%

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

      \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(-1 \cdot {y}^{2}\right)} \]
    8. Step-by-step derivation
      1. unpow282.9%

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot \color{blue}{\left(y \cdot y\right)}\right) \]
      2. mul-1-neg82.9%

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(-y \cdot y\right)} \]
      3. distribute-rgt-neg-out82.9%

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(y \cdot \left(-y\right)\right)} \]
    9. Simplified82.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.5 \cdot 10^{-80}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+149}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\ \end{array} \]

Alternative 3: 71.4% accurate, 15.7× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.05 \cdot 10^{+154}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (if (<= x 1.05e+154) (* (* y y) (- (* x x) (* y y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
	double tmp;
	if (x <= 1.05e+154) {
		tmp = (y * y) * ((x * x) - (y * y));
	} else {
		tmp = (x * x) * (y * y);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 1.05d+154) then
        tmp = (y * y) * ((x * x) - (y * y))
    else
        tmp = (x * x) * (y * y)
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
	double tmp;
	if (x <= 1.05e+154) {
		tmp = (y * y) * ((x * x) - (y * y));
	} else {
		tmp = (x * x) * (y * y);
	}
	return tmp;
}
x = abs(x)
def code(x, y):
	tmp = 0
	if x <= 1.05e+154:
		tmp = (y * y) * ((x * x) - (y * y))
	else:
		tmp = (x * x) * (y * y)
	return tmp
x = abs(x)
function code(x, y)
	tmp = 0.0
	if (x <= 1.05e+154)
		tmp = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y)));
	else
		tmp = Float64(Float64(x * x) * Float64(y * y));
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 1.05e+154)
		tmp = (y * y) * ((x * x) - (y * y));
	else
		tmp = (x * x) * (y * y);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_, y_] := If[LessEqual[x, 1.05e+154], N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.05 \cdot 10^{+154}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.04999999999999997e154

    1. Initial program 88.8%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. sqr-pow88.7%

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow88.6%

        \[\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-squares95.5%

        \[\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. metadata-eval95.5%

        \[\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) \]
      5. pow295.5%

        \[\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) \]
      6. metadata-eval95.5%

        \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      7. pow295.5%

        \[\leadsto \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      8. metadata-eval95.5%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow295.5%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. metadata-eval95.5%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      11. pow295.5%

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

      \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around 0 73.6%

      \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x - y \cdot y\right) \]
    5. Step-by-step derivation
      1. unpow273.6%

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x - y \cdot y\right) \]
    6. Simplified73.6%

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

    if 1.04999999999999997e154 < x

    1. Initial program 65.2%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. sqr-pow65.2%

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow65.2%

        \[\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-squares73.9%

        \[\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. metadata-eval73.9%

        \[\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) \]
      5. pow273.9%

        \[\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) \]
      6. metadata-eval73.9%

        \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      7. pow273.9%

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

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow273.9%

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

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      11. pow273.9%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied egg-rr73.9%

      \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around 0 60.9%

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

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x - y \cdot y\right) \]
    6. Simplified60.9%

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

      \[\leadsto \color{blue}{{x}^{2} \cdot {y}^{2}} \]
    8. Step-by-step derivation
      1. unpow273.9%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot {y}^{2} \]
      2. unpow273.9%

        \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{\left(y \cdot y\right)} \]
      3. *-commutative73.9%

        \[\leadsto \color{blue}{\left(y \cdot y\right) \cdot \left(x \cdot x\right)} \]
    9. Simplified73.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.05 \cdot 10^{+154}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\ \end{array} \]

Alternative 4: 69.8% accurate, 20.4× speedup?

\[\begin{array}{l} x = |x|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.6 \cdot 10^{+141}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (if (<= x 1.6e+141) (* (* y y) (* y (- y))) (* (* x x) (* y y))))
x = abs(x);
double code(double x, double y) {
	double tmp;
	if (x <= 1.6e+141) {
		tmp = (y * y) * (y * -y);
	} else {
		tmp = (x * x) * (y * y);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 1.6d+141) then
        tmp = (y * y) * (y * -y)
    else
        tmp = (x * x) * (y * y)
    end if
    code = tmp
end function
x = Math.abs(x);
public static double code(double x, double y) {
	double tmp;
	if (x <= 1.6e+141) {
		tmp = (y * y) * (y * -y);
	} else {
		tmp = (x * x) * (y * y);
	}
	return tmp;
}
x = abs(x)
def code(x, y):
	tmp = 0
	if x <= 1.6e+141:
		tmp = (y * y) * (y * -y)
	else:
		tmp = (x * x) * (y * y)
	return tmp
x = abs(x)
function code(x, y)
	tmp = 0.0
	if (x <= 1.6e+141)
		tmp = Float64(Float64(y * y) * Float64(y * Float64(-y)));
	else
		tmp = Float64(Float64(x * x) * Float64(y * y));
	end
	return tmp
end
x = abs(x)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 1.6e+141)
		tmp = (y * y) * (y * -y);
	else
		tmp = (x * x) * (y * y);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
code[x_, y_] := If[LessEqual[x, 1.6e+141], N[(N[(y * y), $MachinePrecision] * N[(y * (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{+141}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.60000000000000009e141

    1. Initial program 89.2%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. sqr-pow89.1%

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow89.0%

        \[\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-squares95.4%

        \[\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. metadata-eval95.4%

        \[\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) \]
      5. pow295.4%

        \[\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) \]
      6. metadata-eval95.4%

        \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      7. pow295.4%

        \[\leadsto \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      8. metadata-eval95.4%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow295.4%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. metadata-eval95.4%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      11. pow295.4%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied egg-rr95.4%

      \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around 0 73.8%

      \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x - y \cdot y\right) \]
    5. Step-by-step derivation
      1. unpow273.8%

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x - y \cdot y\right) \]
    6. Simplified73.8%

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

      \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(-1 \cdot {y}^{2}\right)} \]
    8. Step-by-step derivation
      1. unpow264.0%

        \[\leadsto \left(y \cdot y\right) \cdot \left(-1 \cdot \color{blue}{\left(y \cdot y\right)}\right) \]
      2. mul-1-neg64.0%

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(-y \cdot y\right)} \]
      3. distribute-rgt-neg-out64.0%

        \[\leadsto \left(y \cdot y\right) \cdot \color{blue}{\left(y \cdot \left(-y\right)\right)} \]
    9. Simplified64.0%

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

    if 1.60000000000000009e141 < x

    1. Initial program 64.0%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. sqr-pow64.0%

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow64.0%

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

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

        \[\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) \]
      5. pow276.0%

        \[\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) \]
      6. metadata-eval76.0%

        \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      7. pow276.0%

        \[\leadsto \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      8. metadata-eval76.0%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow276.0%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      10. metadata-eval76.0%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
      11. pow276.0%

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

      \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around 0 60.1%

      \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x - y \cdot y\right) \]
    5. Step-by-step derivation
      1. unpow260.1%

        \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x - y \cdot y\right) \]
    6. Simplified60.1%

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

      \[\leadsto \color{blue}{{x}^{2} \cdot {y}^{2}} \]
    8. Step-by-step derivation
      1. unpow268.1%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot {y}^{2} \]
      2. unpow268.1%

        \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{\left(y \cdot y\right)} \]
      3. *-commutative68.1%

        \[\leadsto \color{blue}{\left(y \cdot y\right) \cdot \left(x \cdot x\right)} \]
    9. Simplified68.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.6 \cdot 10^{+141}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\ \end{array} \]

Alternative 5: 32.1% accurate, 29.3× speedup?

\[\begin{array}{l} x = |x|\\ \\ \left(x \cdot x\right) \cdot \left(y \cdot y\right) \end{array} \]
NOTE: x should be positive before calling this function
(FPCore (x y) :precision binary64 (* (* x x) (* y y)))
x = abs(x);
double code(double x, double y) {
	return (x * x) * (y * y);
}
NOTE: x should be positive before calling this function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x * x) * (y * y)
end function
x = Math.abs(x);
public static double code(double x, double y) {
	return (x * x) * (y * y);
}
x = abs(x)
def code(x, y):
	return (x * x) * (y * y)
x = abs(x)
function code(x, y)
	return Float64(Float64(x * x) * Float64(y * y))
end
x = abs(x)
function tmp = code(x, y)
	tmp = (x * x) * (y * y);
end
NOTE: x should be positive before calling this function
code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
\left(x \cdot x\right) \cdot \left(y \cdot y\right)
\end{array}
Derivation
  1. Initial program 86.7%

    \[{x}^{4} - {y}^{4} \]
  2. Step-by-step derivation
    1. sqr-pow86.6%

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

      \[\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-squares93.5%

      \[\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. metadata-eval93.5%

      \[\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) \]
    5. pow293.5%

      \[\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) \]
    6. metadata-eval93.5%

      \[\leadsto \left(x \cdot x + {y}^{\color{blue}{2}}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    7. pow293.5%

      \[\leadsto \left(x \cdot x + \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    8. metadata-eval93.5%

      \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    9. pow293.5%

      \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\color{blue}{x \cdot x} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    10. metadata-eval93.5%

      \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]
    11. pow293.5%

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

    \[\leadsto \color{blue}{\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
  4. Taylor expanded in x around 0 72.4%

    \[\leadsto \color{blue}{{y}^{2}} \cdot \left(x \cdot x - y \cdot y\right) \]
  5. Step-by-step derivation
    1. unpow272.4%

      \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot \left(x \cdot x - y \cdot y\right) \]
  6. Simplified72.4%

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

    \[\leadsto \color{blue}{{x}^{2} \cdot {y}^{2}} \]
  8. Step-by-step derivation
    1. unpow235.8%

      \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot {y}^{2} \]
    2. unpow235.8%

      \[\leadsto \left(x \cdot x\right) \cdot \color{blue}{\left(y \cdot y\right)} \]
    3. *-commutative35.8%

      \[\leadsto \color{blue}{\left(y \cdot y\right) \cdot \left(x \cdot x\right)} \]
  9. Simplified35.8%

    \[\leadsto \color{blue}{\left(y \cdot y\right) \cdot \left(x \cdot x\right)} \]
  10. Final simplification35.8%

    \[\leadsto \left(x \cdot x\right) \cdot \left(y \cdot y\right) \]

Reproduce

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