Radioactive exchange between two surfaces

Percentage Accurate: 85.8% → 99.8%
Time: 11.0s
Alternatives: 5
Speedup: 13.7×

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.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ {x}^{4} - {y}^{4} \end{array} \]
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
double code(double x, double y) {
	return pow(x, 4.0) - pow(y, 4.0);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x ** 4.0d0) - (y ** 4.0d0)
end function
public static double code(double x, double y) {
	return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
def code(x, y):
	return math.pow(x, 4.0) - math.pow(y, 4.0)
function code(x, y)
	return Float64((x ^ 4.0) - (y ^ 4.0))
end
function tmp = code(x, y)
	tmp = (x ^ 4.0) - (y ^ 4.0);
end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{x}^{4} - {y}^{4}
\end{array}

Alternative 1: 99.8% accurate, 13.7× speedup?

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

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

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

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

      \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)} \cdot \color{blue}{{y}^{\left(\frac{4}{2}\right)}} \]
    3. difference-of-squaresN/A

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

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

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

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

      \[\leadsto \left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \mathsf{fma}\left(x, x, \mathsf{neg}\left({y}^{2}\right)\right) \]
    8. unpow2N/A

      \[\leadsto \left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \mathsf{fma}\left(x, x, \mathsf{neg}\left(y \cdot y\right)\right) \]
    9. *-commutativeN/A

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

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

    \[\leadsto \color{blue}{\left(x \cdot x - y \cdot y\right) \cdot \left(y \cdot y + x \cdot x\right)} \]
  5. Step-by-step derivation
    1. difference-of-squaresN/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, y\right), \left(x + y\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\color{blue}{y}, y\right), \mathsf{*.f64}\left(x, x\right)\right)\right) \]
    5. +-lowering-+.f6499.9%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, y\right), \mathsf{+.f64}\left(x, y\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(y, \color{blue}{y}\right), \mathsf{*.f64}\left(x, x\right)\right)\right) \]
  6. Applied egg-rr99.9%

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

Alternative 2: 90.3% accurate, 6.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(y \cdot \left(0 - y \cdot y\right)\right)\\ t_1 := \left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{if}\;y \leq -1.75 \cdot 10^{+195}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-52}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{-69}:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+116}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (* y (- 0.0 (* y y)))))
        (t_1 (* (* y y) (- (* x x) (* y y)))))
   (if (<= y -1.75e+195)
     t_0
     (if (<= y -3.9e-52)
       t_1
       (if (<= y 1.22e-69)
         (* x (* x (* x x)))
         (if (<= y 2.2e+116) t_1 t_0))))))
double code(double x, double y) {
	double t_0 = y * (y * (0.0 - (y * y)));
	double t_1 = (y * y) * ((x * x) - (y * y));
	double tmp;
	if (y <= -1.75e+195) {
		tmp = t_0;
	} else if (y <= -3.9e-52) {
		tmp = t_1;
	} else if (y <= 1.22e-69) {
		tmp = x * (x * (x * x));
	} else if (y <= 2.2e+116) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y * (y * (0.0d0 - (y * y)))
    t_1 = (y * y) * ((x * x) - (y * y))
    if (y <= (-1.75d+195)) then
        tmp = t_0
    else if (y <= (-3.9d-52)) then
        tmp = t_1
    else if (y <= 1.22d-69) then
        tmp = x * (x * (x * x))
    else if (y <= 2.2d+116) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = y * (y * (0.0 - (y * y)));
	double t_1 = (y * y) * ((x * x) - (y * y));
	double tmp;
	if (y <= -1.75e+195) {
		tmp = t_0;
	} else if (y <= -3.9e-52) {
		tmp = t_1;
	} else if (y <= 1.22e-69) {
		tmp = x * (x * (x * x));
	} else if (y <= 2.2e+116) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = y * (y * (0.0 - (y * y)))
	t_1 = (y * y) * ((x * x) - (y * y))
	tmp = 0
	if y <= -1.75e+195:
		tmp = t_0
	elif y <= -3.9e-52:
		tmp = t_1
	elif y <= 1.22e-69:
		tmp = x * (x * (x * x))
	elif y <= 2.2e+116:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(y * Float64(y * Float64(0.0 - Float64(y * y))))
	t_1 = Float64(Float64(y * y) * Float64(Float64(x * x) - Float64(y * y)))
	tmp = 0.0
	if (y <= -1.75e+195)
		tmp = t_0;
	elseif (y <= -3.9e-52)
		tmp = t_1;
	elseif (y <= 1.22e-69)
		tmp = Float64(x * Float64(x * Float64(x * x)));
	elseif (y <= 2.2e+116)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = y * (y * (0.0 - (y * y)));
	t_1 = (y * y) * ((x * x) - (y * y));
	tmp = 0.0;
	if (y <= -1.75e+195)
		tmp = t_0;
	elseif (y <= -3.9e-52)
		tmp = t_1;
	elseif (y <= 1.22e-69)
		tmp = x * (x * (x * x));
	elseif (y <= 2.2e+116)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * N[(0.0 - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y * y), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.75e+195], t$95$0, If[LessEqual[y, -3.9e-52], t$95$1, If[LessEqual[y, 1.22e-69], N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e+116], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot \left(0 - y \cdot y\right)\right)\\
t_1 := \left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+195}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -3.9 \cdot 10^{-52}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 1.22 \cdot 10^{-69}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\

\mathbf{elif}\;y \leq 2.2 \cdot 10^{+116}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.7500000000000001e195 or 2.2e116 < y

    1. Initial program 61.4%

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

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

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)} \cdot \color{blue}{{y}^{\left(\frac{4}{2}\right)}} \]
      3. difference-of-squaresN/A

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

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

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

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

        \[\leadsto \left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \mathsf{fma}\left(x, x, \mathsf{neg}\left({y}^{2}\right)\right) \]
      8. unpow2N/A

        \[\leadsto \left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \mathsf{fma}\left(x, x, \mathsf{neg}\left(y \cdot y\right)\right) \]
      9. *-commutativeN/A

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

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{fma}\left(x, x, \mathsf{neg}\left(y \cdot y\right)\right)\right), \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right)}\right) \]
    4. Applied egg-rr74.3%

      \[\leadsto \color{blue}{\left(x \cdot x - y \cdot y\right) \cdot \left(y \cdot y + x \cdot x\right)} \]
    5. Step-by-step derivation
      1. difference-of-squaresN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, y\right), \left(x + y\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\color{blue}{y}, y\right), \mathsf{*.f64}\left(x, x\right)\right)\right) \]
      5. +-lowering-+.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, y\right), \mathsf{+.f64}\left(x, y\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(y, \color{blue}{y}\right), \mathsf{*.f64}\left(x, x\right)\right)\right) \]
    6. Applied egg-rr100.0%

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

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

        \[\leadsto \left(x \cdot x - y \cdot y\right) \cdot \left(\color{blue}{y \cdot y} + x \cdot x\right) \]
      3. flip--N/A

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

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

        \[\leadsto \frac{x \cdot \left(x \cdot \left(x \cdot x\right)\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)}{x \cdot x + y \cdot y} \cdot \left(y \cdot y + x \cdot x\right) \]
      6. +-commutativeN/A

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

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

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

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

        \[\leadsto \frac{\frac{1}{x \cdot x + y \cdot y}}{\frac{1}{x \cdot \left(x \cdot \left(x \cdot x\right)\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)}} \cdot \left(y \cdot y + x \cdot x\right) \]
      11. +-commutativeN/A

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

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

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot y}{\frac{1}{y \cdot y + x \cdot x}}} \]
    9. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-1 \cdot {y}^{4}} \]
    10. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left({y}^{4}\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{{y}^{4}} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left({y}^{4}\right)}\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{\_.f64}\left(0, \left({y}^{\left(3 + \color{blue}{1}\right)}\right)\right) \]
      5. pow-plusN/A

        \[\leadsto \mathsf{\_.f64}\left(0, \left({y}^{3} \cdot \color{blue}{y}\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(0, \left(y \cdot \color{blue}{{y}^{3}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \color{blue}{\left({y}^{3}\right)}\right)\right) \]
      8. cube-multN/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \left(y \cdot \color{blue}{\left(y \cdot y\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \left(y \cdot {y}^{\color{blue}{2}}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \color{blue}{\left({y}^{2}\right)}\right)\right)\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left(y \cdot \color{blue}{y}\right)\right)\right)\right) \]
      12. *-lowering-*.f6490.0%

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \color{blue}{y}\right)\right)\right)\right) \]
    11. Simplified90.0%

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

    if -1.7500000000000001e195 < y < -3.90000000000000018e-52 or 1.22000000000000002e-69 < y < 2.2e116

    1. Initial program 87.2%

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

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

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)} \cdot \color{blue}{{y}^{\left(\frac{4}{2}\right)}} \]
      3. difference-of-squaresN/A

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

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

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

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

        \[\leadsto \left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \mathsf{fma}\left(x, x, \mathsf{neg}\left({y}^{2}\right)\right) \]
      8. unpow2N/A

        \[\leadsto \left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \mathsf{fma}\left(x, x, \mathsf{neg}\left(y \cdot y\right)\right) \]
      9. *-commutativeN/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(y, y\right)\right), \color{blue}{\left({y}^{2}\right)}\right) \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(y, y\right)\right), \left(y \cdot \color{blue}{y}\right)\right) \]
      2. *-lowering-*.f6487.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(y, y\right)\right), \mathsf{*.f64}\left(y, \color{blue}{y}\right)\right) \]
    7. Simplified87.8%

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

    if -3.90000000000000018e-52 < y < 1.22000000000000002e-69

    1. Initial program 100.0%

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

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

        \[\leadsto \mathsf{pow.f64}\left(x, \color{blue}{4}\right) \]
    5. Simplified96.7%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \left(x \cdot x\right)\right), x\right) \]
      6. *-lowering-*.f6496.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, x\right)\right), x\right) \]
    7. Applied egg-rr96.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+195}:\\ \;\;\;\;y \cdot \left(y \cdot \left(0 - y \cdot y\right)\right)\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-52}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{-69}:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+116}:\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(y \cdot \left(0 - y \cdot y\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.6% accurate, 10.8× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \left(y \cdot \left(0 - y \cdot y\right)\right)\\
\mathbf{if}\;y \leq -6 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.15 \cdot 10^{+86}:\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.99999999999999964e78 or 1.14999999999999995e86 < y

    1. Initial program 66.7%

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

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

        \[\leadsto {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)} \cdot \color{blue}{{y}^{\left(\frac{4}{2}\right)}} \]
      3. difference-of-squaresN/A

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

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

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

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

        \[\leadsto \left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \mathsf{fma}\left(x, x, \mathsf{neg}\left({y}^{2}\right)\right) \]
      8. unpow2N/A

        \[\leadsto \left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right) \cdot \mathsf{fma}\left(x, x, \mathsf{neg}\left(y \cdot y\right)\right) \]
      9. *-commutativeN/A

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

        \[\leadsto \mathsf{*.f64}\left(\left(\mathsf{fma}\left(x, x, \mathsf{neg}\left(y \cdot y\right)\right)\right), \color{blue}{\left({x}^{\left(\frac{4}{2}\right)} + {y}^{\left(\frac{4}{2}\right)}\right)}\right) \]
    4. Applied egg-rr82.4%

      \[\leadsto \color{blue}{\left(x \cdot x - y \cdot y\right) \cdot \left(y \cdot y + x \cdot x\right)} \]
    5. Step-by-step derivation
      1. difference-of-squaresN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, y\right), \left(x + y\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\color{blue}{y}, y\right), \mathsf{*.f64}\left(x, x\right)\right)\right) \]
      5. +-lowering-+.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(x, y\right), \mathsf{+.f64}\left(x, y\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(y, \color{blue}{y}\right), \mathsf{*.f64}\left(x, x\right)\right)\right) \]
    6. Applied egg-rr100.0%

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

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

        \[\leadsto \left(x \cdot x - y \cdot y\right) \cdot \left(\color{blue}{y \cdot y} + x \cdot x\right) \]
      3. flip--N/A

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

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

        \[\leadsto \frac{x \cdot \left(x \cdot \left(x \cdot x\right)\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)}{x \cdot x + y \cdot y} \cdot \left(y \cdot y + x \cdot x\right) \]
      6. +-commutativeN/A

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

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

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

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

        \[\leadsto \frac{\frac{1}{x \cdot x + y \cdot y}}{\frac{1}{x \cdot \left(x \cdot \left(x \cdot x\right)\right) - y \cdot \left(y \cdot \left(y \cdot y\right)\right)}} \cdot \left(y \cdot y + x \cdot x\right) \]
      11. +-commutativeN/A

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

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

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot y}{\frac{1}{y \cdot y + x \cdot x}}} \]
    9. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-1 \cdot {y}^{4}} \]
    10. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left({y}^{4}\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{{y}^{4}} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left({y}^{4}\right)}\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{\_.f64}\left(0, \left({y}^{\left(3 + \color{blue}{1}\right)}\right)\right) \]
      5. pow-plusN/A

        \[\leadsto \mathsf{\_.f64}\left(0, \left({y}^{3} \cdot \color{blue}{y}\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(0, \left(y \cdot \color{blue}{{y}^{3}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \color{blue}{\left({y}^{3}\right)}\right)\right) \]
      8. cube-multN/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \left(y \cdot \color{blue}{\left(y \cdot y\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \left(y \cdot {y}^{\color{blue}{2}}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \color{blue}{\left({y}^{2}\right)}\right)\right)\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \left(y \cdot \color{blue}{y}\right)\right)\right)\right) \]
      12. *-lowering-*.f6489.2%

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, \color{blue}{y}\right)\right)\right)\right) \]
    11. Simplified89.2%

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

    if -5.99999999999999964e78 < y < 1.14999999999999995e86

    1. Initial program 97.4%

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

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

        \[\leadsto \mathsf{pow.f64}\left(x, \color{blue}{4}\right) \]
    5. Simplified82.1%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \left(x \cdot x\right)\right), x\right) \]
      6. *-lowering-*.f6482.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, x\right)\right), x\right) \]
    7. Applied egg-rr82.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+78}:\\ \;\;\;\;y \cdot \left(y \cdot \left(0 - y \cdot y\right)\right)\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+86}:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(y \cdot \left(0 - y \cdot y\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 57.5% accurate, 29.3× speedup?

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

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

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

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

      \[\leadsto \mathsf{pow.f64}\left(x, \color{blue}{4}\right) \]
  5. Simplified54.0%

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \left(x \cdot x\right)\right), x\right) \]
    6. *-lowering-*.f6454.0%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, x\right)\right), x\right) \]
  7. Applied egg-rr54.0%

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

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

Alternative 5: 57.5% accurate, 29.3× speedup?

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

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

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

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

      \[\leadsto \mathsf{pow.f64}\left(x, \color{blue}{4}\right) \]
  5. Simplified54.0%

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \left(\color{blue}{x} \cdot x\right)\right) \]
    7. *-lowering-*.f6453.9%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right) \]
  7. Applied egg-rr53.9%

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

Reproduce

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