Radioactive exchange between two surfaces

Percentage Accurate: 85.5% → 99.9%
Time: 2.5s
Alternatives: 7
Speedup: 1.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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    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}

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 7 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.5% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

Alternative 1: 99.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{4} - {y}^{4}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-294}:\\ \;\;\;\;-{y}^{4}\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- (pow x 4.0) (pow y 4.0))))
   (if (<= t_0 -4e-294)
     (- (pow y 4.0))
     (if (<= t_0 INFINITY)
       (* (* (* x x) x) (+ x y))
       (* (* (+ x y) (- x y)) (* y y))))))
double code(double x, double y) {
	double t_0 = pow(x, 4.0) - pow(y, 4.0);
	double tmp;
	if (t_0 <= -4e-294) {
		tmp = -pow(y, 4.0);
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = ((x * x) * x) * (x + y);
	} else {
		tmp = ((x + y) * (x - y)) * (y * y);
	}
	return tmp;
}
public static double code(double x, double y) {
	double t_0 = Math.pow(x, 4.0) - Math.pow(y, 4.0);
	double tmp;
	if (t_0 <= -4e-294) {
		tmp = -Math.pow(y, 4.0);
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = ((x * x) * x) * (x + y);
	} else {
		tmp = ((x + y) * (x - y)) * (y * y);
	}
	return tmp;
}
def code(x, y):
	t_0 = math.pow(x, 4.0) - math.pow(y, 4.0)
	tmp = 0
	if t_0 <= -4e-294:
		tmp = -math.pow(y, 4.0)
	elif t_0 <= math.inf:
		tmp = ((x * x) * x) * (x + y)
	else:
		tmp = ((x + y) * (x - y)) * (y * y)
	return tmp
function code(x, y)
	t_0 = Float64((x ^ 4.0) - (y ^ 4.0))
	tmp = 0.0
	if (t_0 <= -4e-294)
		tmp = Float64(-(y ^ 4.0));
	elseif (t_0 <= Inf)
		tmp = Float64(Float64(Float64(x * x) * x) * Float64(x + y));
	else
		tmp = Float64(Float64(Float64(x + y) * Float64(x - y)) * Float64(y * y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x ^ 4.0) - (y ^ 4.0);
	tmp = 0.0;
	if (t_0 <= -4e-294)
		tmp = -(y ^ 4.0);
	elseif (t_0 <= Inf)
		tmp = ((x * x) * x) * (x + y);
	else
		tmp = ((x + y) * (x - y)) * (y * y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-294], (-N[Power[y, 4.0], $MachinePrecision]), If[LessEqual[t$95$0, Infinity], N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{4} - {y}^{4}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-294}:\\
\;\;\;\;-{y}^{4}\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -4.00000000000000007e-294

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Taylor expanded in x around 0

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

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

        \[\leadsto -{y}^{4} \]
      3. sqr-powN/A

        \[\leadsto -{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)} \]
      4. lower-*.f64N/A

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

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{\left(\frac{4}{2}\right)} \]
      7. lower-*.f64N/A

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{2} \]
      9. unpow2N/A

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      10. lower-*.f6457.4

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
    4. Applied rewrites57.4%

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

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      2. pow2N/A

        \[\leadsto -{\left(y \cdot y\right)}^{2} \]
      3. lift-*.f64N/A

        \[\leadsto -{\left(y \cdot y\right)}^{2} \]
      4. unpow-prod-downN/A

        \[\leadsto -{y}^{2} \cdot {y}^{2} \]
      5. pow-prod-upN/A

        \[\leadsto -{y}^{\left(2 + 2\right)} \]
      6. metadata-evalN/A

        \[\leadsto -{y}^{4} \]
      7. lift-pow.f6457.5

        \[\leadsto -{y}^{4} \]
    6. Applied rewrites57.5%

      \[\leadsto -{y}^{4} \]

    if -4.00000000000000007e-294 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < +inf.0

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower--.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      20. lower-*.f6493.3

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied rewrites93.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

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

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

        \[\leadsto \left(\color{blue}{y \cdot y} + x \cdot x\right) \cdot \left(x \cdot x - y \cdot y\right) \]
      7. lower-fma.f6493.3

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

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

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

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      11. sqr-neg-revN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      12. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right) \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right)} \]
      13. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x - y\right)} \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. add-flipN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{x \cdot x} + {y}^{2}\right) \cdot \left(x - y\right)\right) \cdot \left(x + y\right) \]
      14. lower-fma.f64N/A

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x - y\right)}\right) \cdot \left(x + y\right) \]
      18. lift-+.f6499.9

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

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

      \[\leadsto \color{blue}{{x}^{3}} \cdot \left(x + y\right) \]
    9. Step-by-step derivation
      1. unpow3N/A

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

        \[\leadsto \left({x}^{2} \cdot x\right) \cdot \left(x + y\right) \]
      3. lower-*.f64N/A

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

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right) \]
      5. lift-*.f6461.9

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right) \]
    10. Applied rewrites61.9%

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

    if +inf.0 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64)))

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower--.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      20. lower-*.f6493.3

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied rewrites93.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around 0

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

        \[\leadsto \left(y \cdot \color{blue}{y}\right) \cdot \left(x \cdot x - y \cdot y\right) \]
      2. lift-*.f6468.7

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x + y\right)} \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
      12. lift--.f6475.1

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

        \[\leadsto \left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
      14. pow275.1

        \[\leadsto \left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
      15. +-commutative75.1

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

        \[\leadsto \left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
      17. pow275.1

        \[\leadsto \left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
    8. Applied rewrites75.1%

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

Alternative 2: 99.2% accurate, 1.7× speedup?

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

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

    \[{x}^{4} - {y}^{4} \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

      \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
    3. sqr-powN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    14. lower--.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    20. lower-*.f6493.3

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
  3. Applied rewrites93.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
  4. Step-by-step derivation
    1. lift-fma.f64N/A

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

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

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

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

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

      \[\leadsto \left(\color{blue}{y \cdot y} + x \cdot x\right) \cdot \left(x \cdot x - y \cdot y\right) \]
    7. lower-fma.f6493.3

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

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

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

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    11. sqr-neg-revN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \left(\mathsf{neg}\left(y\right)\right)}\right) \]
    12. difference-of-squaresN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right) \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right)} \]
    13. sub-flipN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x - y\right)} \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
    14. add-flipN/A

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)} \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\color{blue}{x \cdot x} + {y}^{2}\right) \cdot \left(x - y\right)\right) \cdot \left(x + y\right) \]
    14. lower-fma.f64N/A

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

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

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

      \[\leadsto \left(\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x - y\right)}\right) \cdot \left(x + y\right) \]
    18. lift-+.f6499.9

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

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

Alternative 3: 99.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{4} - {y}^{4}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-294}:\\ \;\;\;\;-\left(\left(y \cdot y\right) \cdot y\right) \cdot y\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- (pow x 4.0) (pow y 4.0))))
   (if (<= t_0 -4e-294)
     (- (* (* (* y y) y) y))
     (if (<= t_0 INFINITY)
       (* (* (* x x) x) (+ x y))
       (* (* (+ x y) (- x y)) (* y y))))))
double code(double x, double y) {
	double t_0 = pow(x, 4.0) - pow(y, 4.0);
	double tmp;
	if (t_0 <= -4e-294) {
		tmp = -(((y * y) * y) * y);
	} else if (t_0 <= ((double) INFINITY)) {
		tmp = ((x * x) * x) * (x + y);
	} else {
		tmp = ((x + y) * (x - y)) * (y * y);
	}
	return tmp;
}
public static double code(double x, double y) {
	double t_0 = Math.pow(x, 4.0) - Math.pow(y, 4.0);
	double tmp;
	if (t_0 <= -4e-294) {
		tmp = -(((y * y) * y) * y);
	} else if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = ((x * x) * x) * (x + y);
	} else {
		tmp = ((x + y) * (x - y)) * (y * y);
	}
	return tmp;
}
def code(x, y):
	t_0 = math.pow(x, 4.0) - math.pow(y, 4.0)
	tmp = 0
	if t_0 <= -4e-294:
		tmp = -(((y * y) * y) * y)
	elif t_0 <= math.inf:
		tmp = ((x * x) * x) * (x + y)
	else:
		tmp = ((x + y) * (x - y)) * (y * y)
	return tmp
function code(x, y)
	t_0 = Float64((x ^ 4.0) - (y ^ 4.0))
	tmp = 0.0
	if (t_0 <= -4e-294)
		tmp = Float64(-Float64(Float64(Float64(y * y) * y) * y));
	elseif (t_0 <= Inf)
		tmp = Float64(Float64(Float64(x * x) * x) * Float64(x + y));
	else
		tmp = Float64(Float64(Float64(x + y) * Float64(x - y)) * Float64(y * y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x ^ 4.0) - (y ^ 4.0);
	tmp = 0.0;
	if (t_0 <= -4e-294)
		tmp = -(((y * y) * y) * y);
	elseif (t_0 <= Inf)
		tmp = ((x * x) * x) * (x + y);
	else
		tmp = ((x + y) * (x - y)) * (y * y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-294], (-N[(N[(N[(y * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]), If[LessEqual[t$95$0, Infinity], N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + y), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{4} - {y}^{4}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-294}:\\
\;\;\;\;-\left(\left(y \cdot y\right) \cdot y\right) \cdot y\\

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -4.00000000000000007e-294

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Taylor expanded in x around 0

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

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

        \[\leadsto -{y}^{4} \]
      3. sqr-powN/A

        \[\leadsto -{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)} \]
      4. lower-*.f64N/A

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

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{\left(\frac{4}{2}\right)} \]
      7. lower-*.f64N/A

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{2} \]
      9. unpow2N/A

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      10. lower-*.f6457.4

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
    4. Applied rewrites57.4%

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

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      2. lift-*.f64N/A

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      3. associate-*r*N/A

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

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
      5. pow3N/A

        \[\leadsto -{y}^{3} \cdot y \]
      6. lower-*.f64N/A

        \[\leadsto -{y}^{3} \cdot y \]
      7. pow3N/A

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
      8. lift-*.f64N/A

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
      9. lower-*.f6457.4

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
    6. Applied rewrites57.4%

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

    if -4.00000000000000007e-294 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < +inf.0

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower--.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      20. lower-*.f6493.3

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied rewrites93.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

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

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

        \[\leadsto \left(\color{blue}{y \cdot y} + x \cdot x\right) \cdot \left(x \cdot x - y \cdot y\right) \]
      7. lower-fma.f6493.3

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

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

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

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      11. sqr-neg-revN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      12. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right) \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right)} \]
      13. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x - y\right)} \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. add-flipN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{x \cdot x} + {y}^{2}\right) \cdot \left(x - y\right)\right) \cdot \left(x + y\right) \]
      14. lower-fma.f64N/A

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x - y\right)}\right) \cdot \left(x + y\right) \]
      18. lift-+.f6499.9

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

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

      \[\leadsto \color{blue}{{x}^{3}} \cdot \left(x + y\right) \]
    9. Step-by-step derivation
      1. unpow3N/A

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

        \[\leadsto \left({x}^{2} \cdot x\right) \cdot \left(x + y\right) \]
      3. lower-*.f64N/A

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

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right) \]
      5. lift-*.f6461.9

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right) \]
    10. Applied rewrites61.9%

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

    if +inf.0 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64)))

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower--.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      20. lower-*.f6493.3

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied rewrites93.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Taylor expanded in x around 0

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

        \[\leadsto \left(y \cdot \color{blue}{y}\right) \cdot \left(x \cdot x - y \cdot y\right) \]
      2. lift-*.f6468.7

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x + y\right)} \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
      12. lift--.f6475.1

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

        \[\leadsto \left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
      14. pow275.1

        \[\leadsto \left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
      15. +-commutative75.1

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

        \[\leadsto \left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
      17. pow275.1

        \[\leadsto \left(\left(x + y\right) \cdot \left(x - y\right)\right) \cdot \left(y \cdot y\right) \]
    8. Applied rewrites75.1%

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

Alternative 4: 95.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{x}^{4} - {y}^{4} \leq -4 \cdot 10^{-294}:\\ \;\;\;\;-\left(\left(y \cdot y\right) \cdot y\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (- (pow x 4.0) (pow y 4.0)) -4e-294)
   (- (* (* (* y y) y) y))
   (* (* (* x x) x) (+ x y))))
double code(double x, double y) {
	double tmp;
	if ((pow(x, 4.0) - pow(y, 4.0)) <= -4e-294) {
		tmp = -(((y * y) * y) * y);
	} else {
		tmp = ((x * x) * x) * (x + y);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (((x ** 4.0d0) - (y ** 4.0d0)) <= (-4d-294)) then
        tmp = -(((y * y) * y) * y)
    else
        tmp = ((x * x) * x) * (x + y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((Math.pow(x, 4.0) - Math.pow(y, 4.0)) <= -4e-294) {
		tmp = -(((y * y) * y) * y);
	} else {
		tmp = ((x * x) * x) * (x + y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (math.pow(x, 4.0) - math.pow(y, 4.0)) <= -4e-294:
		tmp = -(((y * y) * y) * y)
	else:
		tmp = ((x * x) * x) * (x + y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64((x ^ 4.0) - (y ^ 4.0)) <= -4e-294)
		tmp = Float64(-Float64(Float64(Float64(y * y) * y) * y));
	else
		tmp = Float64(Float64(Float64(x * x) * x) * Float64(x + y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (((x ^ 4.0) - (y ^ 4.0)) <= -4e-294)
		tmp = -(((y * y) * y) * y);
	else
		tmp = ((x * x) * x) * (x + y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], -4e-294], (-N[(N[(N[(y * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]), N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} - {y}^{4} \leq -4 \cdot 10^{-294}:\\
\;\;\;\;-\left(\left(y \cdot y\right) \cdot y\right) \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -4.00000000000000007e-294

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Taylor expanded in x around 0

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

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

        \[\leadsto -{y}^{4} \]
      3. sqr-powN/A

        \[\leadsto -{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)} \]
      4. lower-*.f64N/A

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

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{\left(\frac{4}{2}\right)} \]
      7. lower-*.f64N/A

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{2} \]
      9. unpow2N/A

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      10. lower-*.f6457.4

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
    4. Applied rewrites57.4%

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

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      2. lift-*.f64N/A

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      3. associate-*r*N/A

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

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
      5. pow3N/A

        \[\leadsto -{y}^{3} \cdot y \]
      6. lower-*.f64N/A

        \[\leadsto -{y}^{3} \cdot y \]
      7. pow3N/A

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
      8. lift-*.f64N/A

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
      9. lower-*.f6457.4

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
    6. Applied rewrites57.4%

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

    if -4.00000000000000007e-294 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64)))

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower--.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      20. lower-*.f6493.3

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied rewrites93.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

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

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

        \[\leadsto \left(\color{blue}{y \cdot y} + x \cdot x\right) \cdot \left(x \cdot x - y \cdot y\right) \]
      7. lower-fma.f6493.3

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

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

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

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      11. sqr-neg-revN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      12. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right) \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right)} \]
      13. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x - y\right)} \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. add-flipN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{x \cdot x} + {y}^{2}\right) \cdot \left(x - y\right)\right) \cdot \left(x + y\right) \]
      14. lower-fma.f64N/A

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x - y\right)}\right) \cdot \left(x + y\right) \]
      18. lift-+.f6499.9

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

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

      \[\leadsto \color{blue}{{x}^{3}} \cdot \left(x + y\right) \]
    9. Step-by-step derivation
      1. unpow3N/A

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

        \[\leadsto \left({x}^{2} \cdot x\right) \cdot \left(x + y\right) \]
      3. lower-*.f64N/A

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

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right) \]
      5. lift-*.f6461.9

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x + y\right) \]
    10. Applied rewrites61.9%

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

Alternative 5: 92.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{x}^{4} - {y}^{4} \leq -4 \cdot 10^{-294}:\\ \;\;\;\;-\left(\left(y \cdot y\right) \cdot y\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (- (pow x 4.0) (pow y 4.0)) -4e-294)
   (- (* (* (* y y) y) y))
   (* (* x x) (* x x))))
double code(double x, double y) {
	double tmp;
	if ((pow(x, 4.0) - pow(y, 4.0)) <= -4e-294) {
		tmp = -(((y * y) * y) * y);
	} else {
		tmp = (x * x) * (x * x);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (((x ** 4.0d0) - (y ** 4.0d0)) <= (-4d-294)) then
        tmp = -(((y * y) * y) * y)
    else
        tmp = (x * x) * (x * x)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((Math.pow(x, 4.0) - Math.pow(y, 4.0)) <= -4e-294) {
		tmp = -(((y * y) * y) * y);
	} else {
		tmp = (x * x) * (x * x);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (math.pow(x, 4.0) - math.pow(y, 4.0)) <= -4e-294:
		tmp = -(((y * y) * y) * y)
	else:
		tmp = (x * x) * (x * x)
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64((x ^ 4.0) - (y ^ 4.0)) <= -4e-294)
		tmp = Float64(-Float64(Float64(Float64(y * y) * y) * y));
	else
		tmp = Float64(Float64(x * x) * Float64(x * x));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (((x ^ 4.0) - (y ^ 4.0)) <= -4e-294)
		tmp = -(((y * y) * y) * y);
	else
		tmp = (x * x) * (x * x);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], -4e-294], (-N[(N[(N[(y * y), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]), N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} - {y}^{4} \leq -4 \cdot 10^{-294}:\\
\;\;\;\;-\left(\left(y \cdot y\right) \cdot y\right) \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -4.00000000000000007e-294

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Taylor expanded in x around 0

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

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

        \[\leadsto -{y}^{4} \]
      3. sqr-powN/A

        \[\leadsto -{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)} \]
      4. lower-*.f64N/A

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

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{\left(\frac{4}{2}\right)} \]
      7. lower-*.f64N/A

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{2} \]
      9. unpow2N/A

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      10. lower-*.f6457.4

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
    4. Applied rewrites57.4%

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

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      2. lift-*.f64N/A

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      3. associate-*r*N/A

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

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
      5. pow3N/A

        \[\leadsto -{y}^{3} \cdot y \]
      6. lower-*.f64N/A

        \[\leadsto -{y}^{3} \cdot y \]
      7. pow3N/A

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
      8. lift-*.f64N/A

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
      9. lower-*.f6457.4

        \[\leadsto -\left(\left(y \cdot y\right) \cdot y\right) \cdot y \]
    6. Applied rewrites57.4%

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

    if -4.00000000000000007e-294 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64)))

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower--.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      20. lower-*.f6493.3

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied rewrites93.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

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

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

        \[\leadsto \left(\color{blue}{y \cdot y} + x \cdot x\right) \cdot \left(x \cdot x - y \cdot y\right) \]
      7. lower-fma.f6493.3

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

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

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

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      11. sqr-neg-revN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      12. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right) \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right)} \]
      13. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x - y\right)} \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. add-flipN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{x \cdot x} + {y}^{2}\right) \cdot \left(x - y\right)\right) \cdot \left(x + y\right) \]
      14. lower-fma.f64N/A

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x - y\right)}\right) \cdot \left(x + y\right) \]
      18. lift-+.f6499.9

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

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

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

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

        \[\leadsto {x}^{2} \cdot \color{blue}{{x}^{2}} \]
      3. lower-*.f64N/A

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

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

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

        \[\leadsto \left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
      7. lift-*.f6457.5

        \[\leadsto \left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    10. Applied rewrites57.5%

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 92.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;{x}^{4} - {y}^{4} \leq -4 \cdot 10^{-294}:\\ \;\;\;\;-\left(y \cdot y\right) \cdot \left(y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (- (pow x 4.0) (pow y 4.0)) -4e-294)
   (- (* (* y y) (* y y)))
   (* (* x x) (* x x))))
double code(double x, double y) {
	double tmp;
	if ((pow(x, 4.0) - pow(y, 4.0)) <= -4e-294) {
		tmp = -((y * y) * (y * y));
	} else {
		tmp = (x * x) * (x * x);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (((x ** 4.0d0) - (y ** 4.0d0)) <= (-4d-294)) then
        tmp = -((y * y) * (y * y))
    else
        tmp = (x * x) * (x * x)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((Math.pow(x, 4.0) - Math.pow(y, 4.0)) <= -4e-294) {
		tmp = -((y * y) * (y * y));
	} else {
		tmp = (x * x) * (x * x);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (math.pow(x, 4.0) - math.pow(y, 4.0)) <= -4e-294:
		tmp = -((y * y) * (y * y))
	else:
		tmp = (x * x) * (x * x)
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64((x ^ 4.0) - (y ^ 4.0)) <= -4e-294)
		tmp = Float64(-Float64(Float64(y * y) * Float64(y * y)));
	else
		tmp = Float64(Float64(x * x) * Float64(x * x));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (((x ^ 4.0) - (y ^ 4.0)) <= -4e-294)
		tmp = -((y * y) * (y * y));
	else
		tmp = (x * x) * (x * x);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], -4e-294], (-N[(N[(y * y), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]), N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;{x}^{4} - {y}^{4} \leq -4 \cdot 10^{-294}:\\
\;\;\;\;-\left(y \cdot y\right) \cdot \left(y \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64))) < -4.00000000000000007e-294

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Taylor expanded in x around 0

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

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

        \[\leadsto -{y}^{4} \]
      3. sqr-powN/A

        \[\leadsto -{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)} \]
      4. lower-*.f64N/A

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

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{\left(\frac{4}{2}\right)} \]
      7. lower-*.f64N/A

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

        \[\leadsto -\left(y \cdot y\right) \cdot {y}^{2} \]
      9. unpow2N/A

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
      10. lower-*.f6457.4

        \[\leadsto -\left(y \cdot y\right) \cdot \left(y \cdot y\right) \]
    4. Applied rewrites57.4%

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

    if -4.00000000000000007e-294 < (-.f64 (pow.f64 x #s(literal 4 binary64)) (pow.f64 y #s(literal 4 binary64)))

    1. Initial program 85.5%

      \[{x}^{4} - {y}^{4} \]
    2. Step-by-step derivation
      1. lift--.f64N/A

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

        \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
      3. sqr-powN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
      14. lower--.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      20. lower-*.f6493.3

        \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Applied rewrites93.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
    4. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

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

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

        \[\leadsto \left(\color{blue}{y \cdot y} + x \cdot x\right) \cdot \left(x \cdot x - y \cdot y\right) \]
      7. lower-fma.f6493.3

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

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

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

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
      11. sqr-neg-revN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      12. difference-of-squaresN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right) \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right)} \]
      13. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x - y\right)} \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. add-flipN/A

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\color{blue}{x \cdot x} + {y}^{2}\right) \cdot \left(x - y\right)\right) \cdot \left(x + y\right) \]
      14. lower-fma.f64N/A

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

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

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

        \[\leadsto \left(\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x - y\right)}\right) \cdot \left(x + y\right) \]
      18. lift-+.f6499.9

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

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

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

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

        \[\leadsto {x}^{2} \cdot \color{blue}{{x}^{2}} \]
      3. lower-*.f64N/A

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

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

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

        \[\leadsto \left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
      7. lift-*.f6457.5

        \[\leadsto \left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    10. Applied rewrites57.5%

      \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(x \cdot x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 57.5% accurate, 3.6× 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    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.5%

    \[{x}^{4} - {y}^{4} \]
  2. Step-by-step derivation
    1. lift--.f64N/A

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

      \[\leadsto \color{blue}{{x}^{4}} - {y}^{4} \]
    3. sqr-powN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{y \cdot y}\right) \cdot \left({x}^{\left(\frac{4}{2}\right)} - {y}^{\left(\frac{4}{2}\right)}\right) \]
    14. lower--.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    20. lower-*.f6493.3

      \[\leadsto \mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
  3. Applied rewrites93.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)} \]
  4. Step-by-step derivation
    1. lift-fma.f64N/A

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

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

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

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

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

      \[\leadsto \left(\color{blue}{y \cdot y} + x \cdot x\right) \cdot \left(x \cdot x - y \cdot y\right) \]
    7. lower-fma.f6493.3

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

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

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

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    11. sqr-neg-revN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(x \cdot x - \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot \left(\mathsf{neg}\left(y\right)\right)}\right) \]
    12. difference-of-squaresN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \color{blue}{\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right) \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right)} \]
    13. sub-flipN/A

      \[\leadsto \mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\color{blue}{\left(x - y\right)} \cdot \left(x - \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
    14. add-flipN/A

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, x \cdot x\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)} \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\left(\color{blue}{x \cdot x} + {y}^{2}\right) \cdot \left(x - y\right)\right) \cdot \left(x + y\right) \]
    14. lower-fma.f64N/A

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

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

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

      \[\leadsto \left(\mathsf{fma}\left(x, x, y \cdot y\right) \cdot \color{blue}{\left(x - y\right)}\right) \cdot \left(x + y\right) \]
    18. lift-+.f6499.9

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

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

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

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

      \[\leadsto {x}^{2} \cdot \color{blue}{{x}^{2}} \]
    3. lower-*.f64N/A

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

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

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

      \[\leadsto \left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
    7. lift-*.f6457.5

      \[\leadsto \left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{x}\right) \]
  10. Applied rewrites57.5%

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

Reproduce

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