Radioactive exchange between two surfaces

Percentage Accurate: 85.6% → 96.3%
Time: 3.1s
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: 85.6% 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.3% accurate, 12.0× speedup?

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.60000000000000004e145

    1. Initial program 89.7%

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

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow89.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-squares96.7%

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

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

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

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

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

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

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

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

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

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

    if 1.60000000000000004e145 < y

    1. Initial program 65.6%

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

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow65.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-squares78.1%

        \[\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-eval78.1%

        \[\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. pow278.1%

        \[\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-eval78.1%

        \[\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. pow278.1%

        \[\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-eval78.1%

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

        \[\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-eval78.1%

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

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

      \[\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 90.6%

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

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

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \color{blue}{\left(-y \cdot y\right)} \]
      3. distribute-rgt-neg-out90.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.6 \cdot 10^{+145}:\\ \;\;\;\;\left(x \cdot x + 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) - x \cdot x\right)\\ \end{array} \]

Alternative 2: 68.7% accurate, 11.3× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 2.65 \cdot 10^{-62} \lor \neg \left(x \leq 7 \cdot 10^{-55}\right) \land x \leq 1.15 \cdot 10^{+22}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right) - x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y)
 :precision binary64
 (if (or (<= x 2.65e-62) (and (not (<= x 7e-55)) (<= x 1.15e+22)))
   (* (* y y) (- (* y (- y)) (* x x)))
   (* (* x x) (+ (* x x) (* y y)))))
y = abs(y);
double code(double x, double y) {
	double tmp;
	if ((x <= 2.65e-62) || (!(x <= 7e-55) && (x <= 1.15e+22))) {
		tmp = (y * y) * ((y * -y) - (x * x));
	} else {
		tmp = (x * x) * ((x * x) + (y * y));
	}
	return tmp;
}
NOTE: y 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 <= 2.65d-62) .or. (.not. (x <= 7d-55)) .and. (x <= 1.15d+22)) then
        tmp = (y * y) * ((y * -y) - (x * x))
    else
        tmp = (x * x) * ((x * x) + (y * y))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
	double tmp;
	if ((x <= 2.65e-62) || (!(x <= 7e-55) && (x <= 1.15e+22))) {
		tmp = (y * y) * ((y * -y) - (x * x));
	} else {
		tmp = (x * x) * ((x * x) + (y * y));
	}
	return tmp;
}
y = abs(y)
def code(x, y):
	tmp = 0
	if (x <= 2.65e-62) or (not (x <= 7e-55) and (x <= 1.15e+22)):
		tmp = (y * y) * ((y * -y) - (x * x))
	else:
		tmp = (x * x) * ((x * x) + (y * y))
	return tmp
y = abs(y)
function code(x, y)
	tmp = 0.0
	if ((x <= 2.65e-62) || (!(x <= 7e-55) && (x <= 1.15e+22)))
		tmp = Float64(Float64(y * y) * Float64(Float64(y * Float64(-y)) - Float64(x * x)));
	else
		tmp = Float64(Float64(x * x) * Float64(Float64(x * x) + Float64(y * y)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= 2.65e-62) || (~((x <= 7e-55)) && (x <= 1.15e+22)))
		tmp = (y * y) * ((y * -y) - (x * x));
	else
		tmp = (x * x) * ((x * x) + (y * y));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_] := If[Or[LessEqual[x, 2.65e-62], And[N[Not[LessEqual[x, 7e-55]], $MachinePrecision], LessEqual[x, 1.15e+22]]], N[(N[(y * y), $MachinePrecision] * N[(N[(y * (-y)), $MachinePrecision] - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.65 \cdot 10^{-62} \lor \neg \left(x \leq 7 \cdot 10^{-55}\right) \land x \leq 1.15 \cdot 10^{+22}:\\
\;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right) - x \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.6499999999999998e-62 or 7.00000000000000051e-55 < x < 1.1500000000000001e22

    1. Initial program 90.7%

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

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow90.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-squares96.2%

        \[\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-eval96.2%

        \[\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. pow296.2%

        \[\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-eval96.2%

        \[\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. pow296.2%

        \[\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-eval96.2%

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

        \[\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-eval96.2%

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

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

      \[\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 68.9%

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

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

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

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

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

    if 2.6499999999999998e-62 < x < 7.00000000000000051e-55 or 1.1500000000000001e22 < x

    1. Initial program 74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.65 \cdot 10^{-62} \lor \neg \left(x \leq 7 \cdot 10^{-55}\right) \land x \leq 1.15 \cdot 10^{+22}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right) - x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\ \end{array} \]

Alternative 3: 69.5% accurate, 15.7× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 5.50000000000000041e127

    1. Initial program 90.1%

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

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow89.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-squares96.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-eval96.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. pow296.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-eval96.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. pow296.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-eval96.6%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow296.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-eval96.6%

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

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied egg-rr96.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 66.6%

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

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

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

    if 5.50000000000000041e127 < y

    1. Initial program 63.6%

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

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow63.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-squares78.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-eval78.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. pow278.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-eval78.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. pow278.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-eval78.8%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow278.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-eval78.8%

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

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied egg-rr78.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 87.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{-{y}^{2} \cdot {x}^{2}} \]
      2. unpow260.7%

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

        \[\leadsto -\left(y \cdot y\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
      4. *-commutative60.7%

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

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

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

Alternative 4: 45.1% accurate, 20.4× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.0000000000000001e128

    1. Initial program 90.1%

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

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow89.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-squares96.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-eval96.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. pow296.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-eval96.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. pow296.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-eval96.6%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow296.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-eval96.6%

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

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied egg-rr96.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 66.6%

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

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

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

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

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

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

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

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

    if 1.0000000000000001e128 < y

    1. Initial program 63.6%

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

        \[\leadsto \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]
      2. sqr-pow63.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-squares78.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-eval78.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. pow278.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-eval78.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. pow278.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-eval78.8%

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      9. pow278.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-eval78.8%

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

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied egg-rr78.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 87.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{-{y}^{2} \cdot {x}^{2}} \]
      2. unpow260.7%

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

        \[\leadsto -\left(y \cdot y\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
      4. *-commutative60.7%

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

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

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

Alternative 5: 31.9% accurate, 29.3× speedup?

\[\begin{array}{l} y = |y|\\ \\ \left(x \cdot x\right) \cdot \left(y \cdot y\right) \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y) :precision binary64 (* (* x x) (* y y)))
y = abs(y);
double code(double x, double y) {
	return (x * x) * (y * y);
}
NOTE: y 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
y = Math.abs(y);
public static double code(double x, double y) {
	return (x * x) * (y * y);
}
y = abs(y)
def code(x, y):
	return (x * x) * (y * y)
y = abs(y)
function code(x, y)
	return Float64(Float64(x * x) * Float64(y * y))
end
y = abs(y)
function tmp = code(x, y)
	tmp = (x * x) * (y * y);
end
NOTE: y should be positive before calling this function
code[x_, y_] := N[(N[(x * x), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\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-squares94.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-eval94.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. pow294.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-eval94.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. pow294.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-eval94.3%

      \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left({x}^{\color{blue}{2}} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    9. pow294.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-eval94.3%

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

      \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
  3. Applied egg-rr94.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 inf 59.6%

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

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

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

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

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

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

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

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

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

Reproduce

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