Radioactive exchange between two surfaces

Percentage Accurate: 86.1% → 94.9%
Time: 3.2s
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.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: 94.9% accurate, 12.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot x + y \cdot y\\ \mathbf{if}\;x \leq -8 \cdot 10^{+179}:\\ \;\;\;\;\left(x \cdot x\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (* x x) (* y y))))
   (if (<= x -8e+179) (* (* x x) t_0) (* t_0 (- (* x x) (* y y))))))
double code(double x, double y) {
	double t_0 = (x * x) + (y * y);
	double tmp;
	if (x <= -8e+179) {
		tmp = (x * x) * t_0;
	} else {
		tmp = t_0 * ((x * x) - (y * y));
	}
	return tmp;
}
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 <= (-8d+179)) then
        tmp = (x * x) * t_0
    else
        tmp = t_0 * ((x * x) - (y * y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (x * x) + (y * y);
	double tmp;
	if (x <= -8e+179) {
		tmp = (x * x) * t_0;
	} else {
		tmp = t_0 * ((x * x) - (y * y));
	}
	return tmp;
}
def code(x, y):
	t_0 = (x * x) + (y * y)
	tmp = 0
	if x <= -8e+179:
		tmp = (x * x) * t_0
	else:
		tmp = t_0 * ((x * x) - (y * y))
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x * x) + Float64(y * y))
	tmp = 0.0
	if (x <= -8e+179)
		tmp = Float64(Float64(x * x) * t_0);
	else
		tmp = Float64(t_0 * Float64(Float64(x * x) - Float64(y * y)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x * x) + (y * y);
	tmp = 0.0;
	if (x <= -8e+179)
		tmp = (x * x) * t_0;
	else
		tmp = t_0 * ((x * x) - (y * y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8e+179], N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot x + y \cdot y\\
\mathbf{if}\;x \leq -8 \cdot 10^{+179}:\\
\;\;\;\;\left(x \cdot x\right) \cdot t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.99999999999999984e179

    1. Initial program 62.5%

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

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

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

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

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

    if -7.99999999999999984e179 < x

    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.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-eval96.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. pow296.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-eval96.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. pow296.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-eval96.3%

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

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

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

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

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

Alternative 2: 82.0% accurate, 12.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+43} \lor \neg \left(y \leq 1.2 \cdot 10^{+16}\right):\\
\;\;\;\;\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 y < -1.2500000000000001e43 or 1.2e16 < y

    1. Initial program 70.6%

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

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

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

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

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

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

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

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

    if -1.2500000000000001e43 < y < 1.2e16

    1. Initial program 100.0%

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

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

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

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \color{blue}{\left(x \cdot x\right)} \]
    6. Simplified90.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 simplification86.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+43} \lor \neg \left(y \leq 1.2 \cdot 10^{+16}\right):\\ \;\;\;\;\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.8% accurate, 13.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{+137} \lor \neg \left(y \leq 1.8 \cdot 10^{+151}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\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 y < -5.29999999999999968e137 or 1.8e151 < y

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.29999999999999968e137 < y < 1.8e151

    1. Initial program 94.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.3 \cdot 10^{+137} \lor \neg \left(y \leq 1.8 \cdot 10^{+151}\right):\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\ \end{array} \]

Alternative 4: 44.7% accurate, 16.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+150} \lor \neg \left(x \leq 4.6 \cdot 10^{+115}\right):\\
\;\;\;\;\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 x < -5.20000000000000012e150 or 4.60000000000000007e115 < x

    1. Initial program 68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.20000000000000012e150 < x < 4.60000000000000007e115

    1. Initial program 95.6%

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

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

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

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

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

        \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied egg-rr99.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 0 80.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. unpow280.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-neg80.6%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{+150} \lor \neg \left(x \leq 4.6 \cdot 10^{+115}\right):\\ \;\;\;\;\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: 32.0% accurate, 29.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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