FastMath dist4

Percentage Accurate: 88.3% → 98.6%
Time: 10.9s
Alternatives: 13
Speedup: 1.7×

Specification

?
\[\begin{array}{l} \\ \left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8), intent (in) :: d4
    code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4):
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4)
	return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1))
end
function tmp = code(d1, d2, d3, d4)
	tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 13 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: 88.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8), intent (in) :: d4
    code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4):
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4)
	return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1))
end
function tmp = code(d1, d2, d3, d4)
	tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}

Alternative 1: 98.6% accurate, 0.5× speedup?

\[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} t_0 := \left(d4 \cdot d1 + \left(d2 \cdot d1 - d3 \cdot d1\right)\right) - d1 \cdot d1\\ \mathbf{if}\;t\_0 \leq \infty:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\ \end{array} \end{array} \]
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (let* ((t_0 (- (+ (* d4 d1) (- (* d2 d1) (* d3 d1))) (* d1 d1))))
   (if (<= t_0 INFINITY) t_0 (* (- (- d4 d3) d1) d1))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
	double t_0 = ((d4 * d1) + ((d2 * d1) - (d3 * d1))) - (d1 * d1);
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0;
	} else {
		tmp = ((d4 - d3) - d1) * d1;
	}
	return tmp;
}
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
	double t_0 = ((d4 * d1) + ((d2 * d1) - (d3 * d1))) - (d1 * d1);
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else {
		tmp = ((d4 - d3) - d1) * d1;
	}
	return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4])
def code(d1, d2, d3, d4):
	t_0 = ((d4 * d1) + ((d2 * d1) - (d3 * d1))) - (d1 * d1)
	tmp = 0
	if t_0 <= math.inf:
		tmp = t_0
	else:
		tmp = ((d4 - d3) - d1) * d1
	return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4])
function code(d1, d2, d3, d4)
	t_0 = Float64(Float64(Float64(d4 * d1) + Float64(Float64(d2 * d1) - Float64(d3 * d1))) - Float64(d1 * d1))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(d4 - d3) - d1) * d1);
	end
	return tmp
end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
	t_0 = ((d4 * d1) + ((d2 * d1) - (d3 * d1))) - (d1 * d1);
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = ((d4 - d3) - d1) * d1;
	end
	tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(N[(d4 * d1), $MachinePrecision] + N[(N[(d2 * d1), $MachinePrecision] - N[(d3 * d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], t$95$0, N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := \left(d4 \cdot d1 + \left(d2 \cdot d1 - d3 \cdot d1\right)\right) - d1 \cdot d1\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) < +inf.0

    1. Initial program 100.0%

      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
    2. Add Preprocessing

    if +inf.0 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1))

    1. Initial program 0.0%

      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
    2. Add Preprocessing
    3. Taylor expanded in d2 around 0

      \[\leadsto \color{blue}{d1 \cdot d4 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
    4. Step-by-step derivation
      1. associate--r+N/A

        \[\leadsto \color{blue}{\left(d1 \cdot d4 - d1 \cdot d3\right) - {d1}^{2}} \]
      2. distribute-lft-out--N/A

        \[\leadsto \color{blue}{d1 \cdot \left(d4 - d3\right)} - {d1}^{2} \]
      3. unpow2N/A

        \[\leadsto d1 \cdot \left(d4 - d3\right) - \color{blue}{d1 \cdot d1} \]
      4. distribute-lft-out--N/A

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d4 - d3\right) - d1\right)} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
      7. lower--.f64N/A

        \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right)} \cdot d1 \]
      8. lower--.f6488.9

        \[\leadsto \left(\color{blue}{\left(d4 - d3\right)} - d1\right) \cdot d1 \]
    5. Applied rewrites88.9%

      \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(d4 \cdot d1 + \left(d2 \cdot d1 - d3 \cdot d1\right)\right) - d1 \cdot d1 \leq \infty:\\ \;\;\;\;\left(d4 \cdot d1 + \left(d2 \cdot d1 - d3 \cdot d1\right)\right) - d1 \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 74.2% accurate, 1.1× speedup?

\[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} t_0 := \left(d2 - d3\right) \cdot d1\\ \mathbf{if}\;d4 \leq 1.5 \cdot 10^{-286}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d4 \leq 2.8 \cdot 10^{-161}:\\ \;\;\;\;\left(d2 - d1\right) \cdot d1\\ \mathbf{elif}\;d4 \leq 5 \cdot 10^{+27}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \end{array} \end{array} \]
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (let* ((t_0 (* (- d2 d3) d1)))
   (if (<= d4 1.5e-286)
     t_0
     (if (<= d4 2.8e-161)
       (* (- d2 d1) d1)
       (if (<= d4 5e+27) t_0 (* (- d4 d3) d1))))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
	double t_0 = (d2 - d3) * d1;
	double tmp;
	if (d4 <= 1.5e-286) {
		tmp = t_0;
	} else if (d4 <= 2.8e-161) {
		tmp = (d2 - d1) * d1;
	} else if (d4 <= 5e+27) {
		tmp = t_0;
	} else {
		tmp = (d4 - d3) * d1;
	}
	return tmp;
}
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
real(8) function code(d1, d2, d3, d4)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8), intent (in) :: d4
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (d2 - d3) * d1
    if (d4 <= 1.5d-286) then
        tmp = t_0
    else if (d4 <= 2.8d-161) then
        tmp = (d2 - d1) * d1
    else if (d4 <= 5d+27) then
        tmp = t_0
    else
        tmp = (d4 - d3) * d1
    end if
    code = tmp
end function
assert d1 < d2 && d2 < d3 && d3 < d4;
public static double code(double d1, double d2, double d3, double d4) {
	double t_0 = (d2 - d3) * d1;
	double tmp;
	if (d4 <= 1.5e-286) {
		tmp = t_0;
	} else if (d4 <= 2.8e-161) {
		tmp = (d2 - d1) * d1;
	} else if (d4 <= 5e+27) {
		tmp = t_0;
	} else {
		tmp = (d4 - d3) * d1;
	}
	return tmp;
}
[d1, d2, d3, d4] = sort([d1, d2, d3, d4])
def code(d1, d2, d3, d4):
	t_0 = (d2 - d3) * d1
	tmp = 0
	if d4 <= 1.5e-286:
		tmp = t_0
	elif d4 <= 2.8e-161:
		tmp = (d2 - d1) * d1
	elif d4 <= 5e+27:
		tmp = t_0
	else:
		tmp = (d4 - d3) * d1
	return tmp
d1, d2, d3, d4 = sort([d1, d2, d3, d4])
function code(d1, d2, d3, d4)
	t_0 = Float64(Float64(d2 - d3) * d1)
	tmp = 0.0
	if (d4 <= 1.5e-286)
		tmp = t_0;
	elseif (d4 <= 2.8e-161)
		tmp = Float64(Float64(d2 - d1) * d1);
	elseif (d4 <= 5e+27)
		tmp = t_0;
	else
		tmp = Float64(Float64(d4 - d3) * d1);
	end
	return tmp
end
d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
function tmp_2 = code(d1, d2, d3, d4)
	t_0 = (d2 - d3) * d1;
	tmp = 0.0;
	if (d4 <= 1.5e-286)
		tmp = t_0;
	elseif (d4 <= 2.8e-161)
		tmp = (d2 - d1) * d1;
	elseif (d4 <= 5e+27)
		tmp = t_0;
	else
		tmp = (d4 - d3) * d1;
	end
	tmp_2 = tmp;
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision]}, If[LessEqual[d4, 1.5e-286], t$95$0, If[LessEqual[d4, 2.8e-161], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d4, 5e+27], t$95$0, N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
t_0 := \left(d2 - d3\right) \cdot d1\\
\mathbf{if}\;d4 \leq 1.5 \cdot 10^{-286}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d4 \leq 2.8 \cdot 10^{-161}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\

\mathbf{elif}\;d4 \leq 5 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d4 < 1.5e-286 or 2.79999999999999992e-161 < d4 < 4.99999999999999979e27

    1. Initial program 88.9%

      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
    2. Add Preprocessing
    3. Taylor expanded in d4 around 0

      \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
    4. Step-by-step derivation
      1. associate--r+N/A

        \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
      2. distribute-lft-out--N/A

        \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
      3. unpow2N/A

        \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
      4. distribute-lft-out--N/A

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
      7. lower--.f64N/A

        \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
      8. lower--.f6480.5

        \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
    5. Applied rewrites80.5%

      \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
    6. Taylor expanded in d1 around 0

      \[\leadsto \left(d2 - d3\right) \cdot d1 \]
    7. Step-by-step derivation
      1. Applied rewrites56.0%

        \[\leadsto \left(d2 - d3\right) \cdot d1 \]

      if 1.5e-286 < d4 < 2.79999999999999992e-161

      1. Initial program 90.9%

        \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
      2. Add Preprocessing
      3. Taylor expanded in d4 around 0

        \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
      4. Step-by-step derivation
        1. associate--r+N/A

          \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
        2. distribute-lft-out--N/A

          \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
        3. unpow2N/A

          \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
        4. distribute-lft-out--N/A

          \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
        5. *-commutativeN/A

          \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
        6. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
        7. lower--.f64N/A

          \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
        8. lower--.f64100.0

          \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
      5. Applied rewrites100.0%

        \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
      6. Taylor expanded in d3 around 0

        \[\leadsto \left(d2 - d1\right) \cdot d1 \]
      7. Step-by-step derivation
        1. Applied rewrites86.7%

          \[\leadsto \left(d2 - d1\right) \cdot d1 \]

        if 4.99999999999999979e27 < d4

        1. Initial program 90.7%

          \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
        2. Add Preprocessing
        3. Taylor expanded in d2 around 0

          \[\leadsto \color{blue}{d1 \cdot d4 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
        4. Step-by-step derivation
          1. associate--r+N/A

            \[\leadsto \color{blue}{\left(d1 \cdot d4 - d1 \cdot d3\right) - {d1}^{2}} \]
          2. distribute-lft-out--N/A

            \[\leadsto \color{blue}{d1 \cdot \left(d4 - d3\right)} - {d1}^{2} \]
          3. unpow2N/A

            \[\leadsto d1 \cdot \left(d4 - d3\right) - \color{blue}{d1 \cdot d1} \]
          4. distribute-lft-out--N/A

            \[\leadsto \color{blue}{d1 \cdot \left(\left(d4 - d3\right) - d1\right)} \]
          5. *-commutativeN/A

            \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
          6. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
          7. lower--.f64N/A

            \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right)} \cdot d1 \]
          8. lower--.f6494.5

            \[\leadsto \left(\color{blue}{\left(d4 - d3\right)} - d1\right) \cdot d1 \]
        5. Applied rewrites94.5%

          \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
        6. Taylor expanded in d1 around 0

          \[\leadsto \left(d4 - d3\right) \cdot d1 \]
        7. Step-by-step derivation
          1. Applied rewrites82.7%

            \[\leadsto \left(d4 - d3\right) \cdot d1 \]
        8. Recombined 3 regimes into one program.
        9. Add Preprocessing

        Alternative 3: 92.1% accurate, 1.2× speedup?

        \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d1 \leq -9 \cdot 10^{+73}:\\ \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\ \mathbf{elif}\;d1 \leq 3.55 \cdot 10^{+106}:\\ \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d1\right) \cdot d1\\ \end{array} \end{array} \]
        NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
        (FPCore (d1 d2 d3 d4)
         :precision binary64
         (if (<= d1 -9e+73)
           (* (- (- d2 d3) d1) d1)
           (if (<= d1 3.55e+106) (* (- (+ d4 d2) d3) d1) (* (- d4 d1) d1))))
        assert(d1 < d2 && d2 < d3 && d3 < d4);
        double code(double d1, double d2, double d3, double d4) {
        	double tmp;
        	if (d1 <= -9e+73) {
        		tmp = ((d2 - d3) - d1) * d1;
        	} else if (d1 <= 3.55e+106) {
        		tmp = ((d4 + d2) - d3) * d1;
        	} else {
        		tmp = (d4 - d1) * d1;
        	}
        	return tmp;
        }
        
        NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
        real(8) function code(d1, d2, d3, d4)
            real(8), intent (in) :: d1
            real(8), intent (in) :: d2
            real(8), intent (in) :: d3
            real(8), intent (in) :: d4
            real(8) :: tmp
            if (d1 <= (-9d+73)) then
                tmp = ((d2 - d3) - d1) * d1
            else if (d1 <= 3.55d+106) then
                tmp = ((d4 + d2) - d3) * d1
            else
                tmp = (d4 - d1) * d1
            end if
            code = tmp
        end function
        
        assert d1 < d2 && d2 < d3 && d3 < d4;
        public static double code(double d1, double d2, double d3, double d4) {
        	double tmp;
        	if (d1 <= -9e+73) {
        		tmp = ((d2 - d3) - d1) * d1;
        	} else if (d1 <= 3.55e+106) {
        		tmp = ((d4 + d2) - d3) * d1;
        	} else {
        		tmp = (d4 - d1) * d1;
        	}
        	return tmp;
        }
        
        [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
        def code(d1, d2, d3, d4):
        	tmp = 0
        	if d1 <= -9e+73:
        		tmp = ((d2 - d3) - d1) * d1
        	elif d1 <= 3.55e+106:
        		tmp = ((d4 + d2) - d3) * d1
        	else:
        		tmp = (d4 - d1) * d1
        	return tmp
        
        d1, d2, d3, d4 = sort([d1, d2, d3, d4])
        function code(d1, d2, d3, d4)
        	tmp = 0.0
        	if (d1 <= -9e+73)
        		tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1);
        	elseif (d1 <= 3.55e+106)
        		tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1);
        	else
        		tmp = Float64(Float64(d4 - d1) * d1);
        	end
        	return tmp
        end
        
        d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
        function tmp_2 = code(d1, d2, d3, d4)
        	tmp = 0.0;
        	if (d1 <= -9e+73)
        		tmp = ((d2 - d3) - d1) * d1;
        	elseif (d1 <= 3.55e+106)
        		tmp = ((d4 + d2) - d3) * d1;
        	else
        		tmp = (d4 - d1) * d1;
        	end
        	tmp_2 = tmp;
        end
        
        NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
        code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -9e+73], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 3.55e+106], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]]
        
        \begin{array}{l}
        [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;d1 \leq -9 \cdot 10^{+73}:\\
        \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
        
        \mathbf{elif}\;d1 \leq 3.55 \cdot 10^{+106}:\\
        \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(d4 - d1\right) \cdot d1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if d1 < -8.99999999999999969e73

          1. Initial program 76.6%

            \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
          2. Add Preprocessing
          3. Taylor expanded in d4 around 0

            \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
          4. Step-by-step derivation
            1. associate--r+N/A

              \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
            2. distribute-lft-out--N/A

              \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
            3. unpow2N/A

              \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
            4. distribute-lft-out--N/A

              \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
            5. *-commutativeN/A

              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
            6. lower-*.f64N/A

              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
            7. lower--.f64N/A

              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
            8. lower--.f6491.7

              \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
          5. Applied rewrites91.7%

            \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]

          if -8.99999999999999969e73 < d1 < 3.55000000000000015e106

          1. Initial program 100.0%

            \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
          2. Add Preprocessing
          3. Taylor expanded in d1 around 0

            \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 + d4\right) - d3\right)} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{\left(\left(d2 + d4\right) - d3\right) \cdot d1} \]
            2. lower-*.f64N/A

              \[\leadsto \color{blue}{\left(\left(d2 + d4\right) - d3\right) \cdot d1} \]
            3. lower--.f64N/A

              \[\leadsto \color{blue}{\left(\left(d2 + d4\right) - d3\right)} \cdot d1 \]
            4. +-commutativeN/A

              \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d3\right) \cdot d1 \]
            5. lower-+.f6495.5

              \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d3\right) \cdot d1 \]
          5. Applied rewrites95.5%

            \[\leadsto \color{blue}{\left(\left(d4 + d2\right) - d3\right) \cdot d1} \]

          if 3.55000000000000015e106 < d1

          1. Initial program 61.0%

            \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
          2. Add Preprocessing
          3. Taylor expanded in d2 around 0

            \[\leadsto \color{blue}{d1 \cdot d4 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
          4. Step-by-step derivation
            1. associate--r+N/A

              \[\leadsto \color{blue}{\left(d1 \cdot d4 - d1 \cdot d3\right) - {d1}^{2}} \]
            2. distribute-lft-out--N/A

              \[\leadsto \color{blue}{d1 \cdot \left(d4 - d3\right)} - {d1}^{2} \]
            3. unpow2N/A

              \[\leadsto d1 \cdot \left(d4 - d3\right) - \color{blue}{d1 \cdot d1} \]
            4. distribute-lft-out--N/A

              \[\leadsto \color{blue}{d1 \cdot \left(\left(d4 - d3\right) - d1\right)} \]
            5. *-commutativeN/A

              \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
            6. lower-*.f64N/A

              \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
            7. lower--.f64N/A

              \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right)} \cdot d1 \]
            8. lower--.f6488.6

              \[\leadsto \left(\color{blue}{\left(d4 - d3\right)} - d1\right) \cdot d1 \]
          5. Applied rewrites88.6%

            \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
          6. Taylor expanded in d3 around 0

            \[\leadsto \left(d4 - d1\right) \cdot d1 \]
          7. Step-by-step derivation
            1. Applied rewrites83.7%

              \[\leadsto \left(d4 - d1\right) \cdot d1 \]
          8. Recombined 3 regimes into one program.
          9. Add Preprocessing

          Alternative 4: 91.2% accurate, 1.2× speedup?

          \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d1 \leq -2.6 \cdot 10^{+143}:\\ \;\;\;\;\left(d2 - d1\right) \cdot d1\\ \mathbf{elif}\;d1 \leq 3.55 \cdot 10^{+106}:\\ \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d1\right) \cdot d1\\ \end{array} \end{array} \]
          NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
          (FPCore (d1 d2 d3 d4)
           :precision binary64
           (if (<= d1 -2.6e+143)
             (* (- d2 d1) d1)
             (if (<= d1 3.55e+106) (* (- (+ d4 d2) d3) d1) (* (- d4 d1) d1))))
          assert(d1 < d2 && d2 < d3 && d3 < d4);
          double code(double d1, double d2, double d3, double d4) {
          	double tmp;
          	if (d1 <= -2.6e+143) {
          		tmp = (d2 - d1) * d1;
          	} else if (d1 <= 3.55e+106) {
          		tmp = ((d4 + d2) - d3) * d1;
          	} else {
          		tmp = (d4 - d1) * d1;
          	}
          	return tmp;
          }
          
          NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
          real(8) function code(d1, d2, d3, d4)
              real(8), intent (in) :: d1
              real(8), intent (in) :: d2
              real(8), intent (in) :: d3
              real(8), intent (in) :: d4
              real(8) :: tmp
              if (d1 <= (-2.6d+143)) then
                  tmp = (d2 - d1) * d1
              else if (d1 <= 3.55d+106) then
                  tmp = ((d4 + d2) - d3) * d1
              else
                  tmp = (d4 - d1) * d1
              end if
              code = tmp
          end function
          
          assert d1 < d2 && d2 < d3 && d3 < d4;
          public static double code(double d1, double d2, double d3, double d4) {
          	double tmp;
          	if (d1 <= -2.6e+143) {
          		tmp = (d2 - d1) * d1;
          	} else if (d1 <= 3.55e+106) {
          		tmp = ((d4 + d2) - d3) * d1;
          	} else {
          		tmp = (d4 - d1) * d1;
          	}
          	return tmp;
          }
          
          [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
          def code(d1, d2, d3, d4):
          	tmp = 0
          	if d1 <= -2.6e+143:
          		tmp = (d2 - d1) * d1
          	elif d1 <= 3.55e+106:
          		tmp = ((d4 + d2) - d3) * d1
          	else:
          		tmp = (d4 - d1) * d1
          	return tmp
          
          d1, d2, d3, d4 = sort([d1, d2, d3, d4])
          function code(d1, d2, d3, d4)
          	tmp = 0.0
          	if (d1 <= -2.6e+143)
          		tmp = Float64(Float64(d2 - d1) * d1);
          	elseif (d1 <= 3.55e+106)
          		tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1);
          	else
          		tmp = Float64(Float64(d4 - d1) * d1);
          	end
          	return tmp
          end
          
          d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
          function tmp_2 = code(d1, d2, d3, d4)
          	tmp = 0.0;
          	if (d1 <= -2.6e+143)
          		tmp = (d2 - d1) * d1;
          	elseif (d1 <= 3.55e+106)
          		tmp = ((d4 + d2) - d3) * d1;
          	else
          		tmp = (d4 - d1) * d1;
          	end
          	tmp_2 = tmp;
          end
          
          NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
          code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -2.6e+143], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 3.55e+106], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]]
          
          \begin{array}{l}
          [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
          \\
          \begin{array}{l}
          \mathbf{if}\;d1 \leq -2.6 \cdot 10^{+143}:\\
          \;\;\;\;\left(d2 - d1\right) \cdot d1\\
          
          \mathbf{elif}\;d1 \leq 3.55 \cdot 10^{+106}:\\
          \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(d4 - d1\right) \cdot d1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if d1 < -2.5999999999999999e143

            1. Initial program 69.7%

              \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
            2. Add Preprocessing
            3. Taylor expanded in d4 around 0

              \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
            4. Step-by-step derivation
              1. associate--r+N/A

                \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
              2. distribute-lft-out--N/A

                \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
              3. unpow2N/A

                \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
              4. distribute-lft-out--N/A

                \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
              5. *-commutativeN/A

                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
              6. lower-*.f64N/A

                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
              7. lower--.f64N/A

                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
              8. lower--.f6497.0

                \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
            5. Applied rewrites97.0%

              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
            6. Taylor expanded in d3 around 0

              \[\leadsto \left(d2 - d1\right) \cdot d1 \]
            7. Step-by-step derivation
              1. Applied rewrites90.9%

                \[\leadsto \left(d2 - d1\right) \cdot d1 \]

              if -2.5999999999999999e143 < d1 < 3.55000000000000015e106

              1. Initial program 99.4%

                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
              2. Add Preprocessing
              3. Taylor expanded in d1 around 0

                \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 + d4\right) - d3\right)} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \color{blue}{\left(\left(d2 + d4\right) - d3\right) \cdot d1} \]
                2. lower-*.f64N/A

                  \[\leadsto \color{blue}{\left(\left(d2 + d4\right) - d3\right) \cdot d1} \]
                3. lower--.f64N/A

                  \[\leadsto \color{blue}{\left(\left(d2 + d4\right) - d3\right)} \cdot d1 \]
                4. +-commutativeN/A

                  \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d3\right) \cdot d1 \]
                5. lower-+.f6493.8

                  \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d3\right) \cdot d1 \]
              5. Applied rewrites93.8%

                \[\leadsto \color{blue}{\left(\left(d4 + d2\right) - d3\right) \cdot d1} \]

              if 3.55000000000000015e106 < d1

              1. Initial program 61.0%

                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
              2. Add Preprocessing
              3. Taylor expanded in d2 around 0

                \[\leadsto \color{blue}{d1 \cdot d4 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
              4. Step-by-step derivation
                1. associate--r+N/A

                  \[\leadsto \color{blue}{\left(d1 \cdot d4 - d1 \cdot d3\right) - {d1}^{2}} \]
                2. distribute-lft-out--N/A

                  \[\leadsto \color{blue}{d1 \cdot \left(d4 - d3\right)} - {d1}^{2} \]
                3. unpow2N/A

                  \[\leadsto d1 \cdot \left(d4 - d3\right) - \color{blue}{d1 \cdot d1} \]
                4. distribute-lft-out--N/A

                  \[\leadsto \color{blue}{d1 \cdot \left(\left(d4 - d3\right) - d1\right)} \]
                5. *-commutativeN/A

                  \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
                6. lower-*.f64N/A

                  \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
                7. lower--.f64N/A

                  \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right)} \cdot d1 \]
                8. lower--.f6488.6

                  \[\leadsto \left(\color{blue}{\left(d4 - d3\right)} - d1\right) \cdot d1 \]
              5. Applied rewrites88.6%

                \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
              6. Taylor expanded in d3 around 0

                \[\leadsto \left(d4 - d1\right) \cdot d1 \]
              7. Step-by-step derivation
                1. Applied rewrites83.7%

                  \[\leadsto \left(d4 - d1\right) \cdot d1 \]
              8. Recombined 3 regimes into one program.
              9. Add Preprocessing

              Alternative 5: 70.1% accurate, 1.4× speedup?

              \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d1 \leq -3.9 \cdot 10^{+74}:\\ \;\;\;\;\left(d2 - d1\right) \cdot d1\\ \mathbf{elif}\;d1 \leq 6.2 \cdot 10^{+68}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d1\right) \cdot d1\\ \end{array} \end{array} \]
              NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
              (FPCore (d1 d2 d3 d4)
               :precision binary64
               (if (<= d1 -3.9e+74)
                 (* (- d2 d1) d1)
                 (if (<= d1 6.2e+68) (* (- d2 d3) d1) (* (- d4 d1) d1))))
              assert(d1 < d2 && d2 < d3 && d3 < d4);
              double code(double d1, double d2, double d3, double d4) {
              	double tmp;
              	if (d1 <= -3.9e+74) {
              		tmp = (d2 - d1) * d1;
              	} else if (d1 <= 6.2e+68) {
              		tmp = (d2 - d3) * d1;
              	} else {
              		tmp = (d4 - d1) * d1;
              	}
              	return tmp;
              }
              
              NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
              real(8) function code(d1, d2, d3, d4)
                  real(8), intent (in) :: d1
                  real(8), intent (in) :: d2
                  real(8), intent (in) :: d3
                  real(8), intent (in) :: d4
                  real(8) :: tmp
                  if (d1 <= (-3.9d+74)) then
                      tmp = (d2 - d1) * d1
                  else if (d1 <= 6.2d+68) then
                      tmp = (d2 - d3) * d1
                  else
                      tmp = (d4 - d1) * d1
                  end if
                  code = tmp
              end function
              
              assert d1 < d2 && d2 < d3 && d3 < d4;
              public static double code(double d1, double d2, double d3, double d4) {
              	double tmp;
              	if (d1 <= -3.9e+74) {
              		tmp = (d2 - d1) * d1;
              	} else if (d1 <= 6.2e+68) {
              		tmp = (d2 - d3) * d1;
              	} else {
              		tmp = (d4 - d1) * d1;
              	}
              	return tmp;
              }
              
              [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
              def code(d1, d2, d3, d4):
              	tmp = 0
              	if d1 <= -3.9e+74:
              		tmp = (d2 - d1) * d1
              	elif d1 <= 6.2e+68:
              		tmp = (d2 - d3) * d1
              	else:
              		tmp = (d4 - d1) * d1
              	return tmp
              
              d1, d2, d3, d4 = sort([d1, d2, d3, d4])
              function code(d1, d2, d3, d4)
              	tmp = 0.0
              	if (d1 <= -3.9e+74)
              		tmp = Float64(Float64(d2 - d1) * d1);
              	elseif (d1 <= 6.2e+68)
              		tmp = Float64(Float64(d2 - d3) * d1);
              	else
              		tmp = Float64(Float64(d4 - d1) * d1);
              	end
              	return tmp
              end
              
              d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
              function tmp_2 = code(d1, d2, d3, d4)
              	tmp = 0.0;
              	if (d1 <= -3.9e+74)
              		tmp = (d2 - d1) * d1;
              	elseif (d1 <= 6.2e+68)
              		tmp = (d2 - d3) * d1;
              	else
              		tmp = (d4 - d1) * d1;
              	end
              	tmp_2 = tmp;
              end
              
              NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
              code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -3.9e+74], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 6.2e+68], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]]
              
              \begin{array}{l}
              [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
              \\
              \begin{array}{l}
              \mathbf{if}\;d1 \leq -3.9 \cdot 10^{+74}:\\
              \;\;\;\;\left(d2 - d1\right) \cdot d1\\
              
              \mathbf{elif}\;d1 \leq 6.2 \cdot 10^{+68}:\\
              \;\;\;\;\left(d2 - d3\right) \cdot d1\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(d4 - d1\right) \cdot d1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if d1 < -3.90000000000000008e74

                1. Initial program 76.6%

                  \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                2. Add Preprocessing
                3. Taylor expanded in d4 around 0

                  \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                4. Step-by-step derivation
                  1. associate--r+N/A

                    \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                  2. distribute-lft-out--N/A

                    \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                  3. unpow2N/A

                    \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                  4. distribute-lft-out--N/A

                    \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                  5. *-commutativeN/A

                    \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                  6. lower-*.f64N/A

                    \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                  7. lower--.f64N/A

                    \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                  8. lower--.f6491.7

                    \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                5. Applied rewrites91.7%

                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                6. Taylor expanded in d3 around 0

                  \[\leadsto \left(d2 - d1\right) \cdot d1 \]
                7. Step-by-step derivation
                  1. Applied rewrites81.2%

                    \[\leadsto \left(d2 - d1\right) \cdot d1 \]

                  if -3.90000000000000008e74 < d1 < 6.1999999999999997e68

                  1. Initial program 100.0%

                    \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                  2. Add Preprocessing
                  3. Taylor expanded in d4 around 0

                    \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                  4. Step-by-step derivation
                    1. associate--r+N/A

                      \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                    2. distribute-lft-out--N/A

                      \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                    3. unpow2N/A

                      \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                    4. distribute-lft-out--N/A

                      \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                    5. *-commutativeN/A

                      \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                    6. lower-*.f64N/A

                      \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                    7. lower--.f64N/A

                      \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                    8. lower--.f6464.5

                      \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                  5. Applied rewrites64.5%

                    \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                  6. Taylor expanded in d1 around 0

                    \[\leadsto \left(d2 - d3\right) \cdot d1 \]
                  7. Step-by-step derivation
                    1. Applied rewrites63.1%

                      \[\leadsto \left(d2 - d3\right) \cdot d1 \]

                    if 6.1999999999999997e68 < d1

                    1. Initial program 68.6%

                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. Add Preprocessing
                    3. Taylor expanded in d2 around 0

                      \[\leadsto \color{blue}{d1 \cdot d4 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                    4. Step-by-step derivation
                      1. associate--r+N/A

                        \[\leadsto \color{blue}{\left(d1 \cdot d4 - d1 \cdot d3\right) - {d1}^{2}} \]
                      2. distribute-lft-out--N/A

                        \[\leadsto \color{blue}{d1 \cdot \left(d4 - d3\right)} - {d1}^{2} \]
                      3. unpow2N/A

                        \[\leadsto d1 \cdot \left(d4 - d3\right) - \color{blue}{d1 \cdot d1} \]
                      4. distribute-lft-out--N/A

                        \[\leadsto \color{blue}{d1 \cdot \left(\left(d4 - d3\right) - d1\right)} \]
                      5. *-commutativeN/A

                        \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
                      6. lower-*.f64N/A

                        \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
                      7. lower--.f64N/A

                        \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right)} \cdot d1 \]
                      8. lower--.f6483.2

                        \[\leadsto \left(\color{blue}{\left(d4 - d3\right)} - d1\right) \cdot d1 \]
                    5. Applied rewrites83.2%

                      \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
                    6. Taylor expanded in d3 around 0

                      \[\leadsto \left(d4 - d1\right) \cdot d1 \]
                    7. Step-by-step derivation
                      1. Applied rewrites75.5%

                        \[\leadsto \left(d4 - d1\right) \cdot d1 \]
                    8. Recombined 3 regimes into one program.
                    9. Add Preprocessing

                    Alternative 6: 68.7% accurate, 1.4× speedup?

                    \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} t_0 := \left(d2 - d1\right) \cdot d1\\ \mathbf{if}\;d1 \leq -3.9 \cdot 10^{+74}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d1 \leq 9.5 \cdot 10^{+67}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                    NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                    (FPCore (d1 d2 d3 d4)
                     :precision binary64
                     (let* ((t_0 (* (- d2 d1) d1)))
                       (if (<= d1 -3.9e+74) t_0 (if (<= d1 9.5e+67) (* (- d2 d3) d1) t_0))))
                    assert(d1 < d2 && d2 < d3 && d3 < d4);
                    double code(double d1, double d2, double d3, double d4) {
                    	double t_0 = (d2 - d1) * d1;
                    	double tmp;
                    	if (d1 <= -3.9e+74) {
                    		tmp = t_0;
                    	} else if (d1 <= 9.5e+67) {
                    		tmp = (d2 - d3) * d1;
                    	} else {
                    		tmp = t_0;
                    	}
                    	return tmp;
                    }
                    
                    NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                    real(8) function code(d1, d2, d3, d4)
                        real(8), intent (in) :: d1
                        real(8), intent (in) :: d2
                        real(8), intent (in) :: d3
                        real(8), intent (in) :: d4
                        real(8) :: t_0
                        real(8) :: tmp
                        t_0 = (d2 - d1) * d1
                        if (d1 <= (-3.9d+74)) then
                            tmp = t_0
                        else if (d1 <= 9.5d+67) then
                            tmp = (d2 - d3) * d1
                        else
                            tmp = t_0
                        end if
                        code = tmp
                    end function
                    
                    assert d1 < d2 && d2 < d3 && d3 < d4;
                    public static double code(double d1, double d2, double d3, double d4) {
                    	double t_0 = (d2 - d1) * d1;
                    	double tmp;
                    	if (d1 <= -3.9e+74) {
                    		tmp = t_0;
                    	} else if (d1 <= 9.5e+67) {
                    		tmp = (d2 - d3) * d1;
                    	} else {
                    		tmp = t_0;
                    	}
                    	return tmp;
                    }
                    
                    [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                    def code(d1, d2, d3, d4):
                    	t_0 = (d2 - d1) * d1
                    	tmp = 0
                    	if d1 <= -3.9e+74:
                    		tmp = t_0
                    	elif d1 <= 9.5e+67:
                    		tmp = (d2 - d3) * d1
                    	else:
                    		tmp = t_0
                    	return tmp
                    
                    d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                    function code(d1, d2, d3, d4)
                    	t_0 = Float64(Float64(d2 - d1) * d1)
                    	tmp = 0.0
                    	if (d1 <= -3.9e+74)
                    		tmp = t_0;
                    	elseif (d1 <= 9.5e+67)
                    		tmp = Float64(Float64(d2 - d3) * d1);
                    	else
                    		tmp = t_0;
                    	end
                    	return tmp
                    end
                    
                    d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                    function tmp_2 = code(d1, d2, d3, d4)
                    	t_0 = (d2 - d1) * d1;
                    	tmp = 0.0;
                    	if (d1 <= -3.9e+74)
                    		tmp = t_0;
                    	elseif (d1 <= 9.5e+67)
                    		tmp = (d2 - d3) * d1;
                    	else
                    		tmp = t_0;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                    code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision]}, If[LessEqual[d1, -3.9e+74], t$95$0, If[LessEqual[d1, 9.5e+67], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]
                    
                    \begin{array}{l}
                    [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                    \\
                    \begin{array}{l}
                    t_0 := \left(d2 - d1\right) \cdot d1\\
                    \mathbf{if}\;d1 \leq -3.9 \cdot 10^{+74}:\\
                    \;\;\;\;t\_0\\
                    
                    \mathbf{elif}\;d1 \leq 9.5 \cdot 10^{+67}:\\
                    \;\;\;\;\left(d2 - d3\right) \cdot d1\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;t\_0\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if d1 < -3.90000000000000008e74 or 9.5000000000000002e67 < d1

                      1. Initial program 72.7%

                        \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. Add Preprocessing
                      3. Taylor expanded in d4 around 0

                        \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                      4. Step-by-step derivation
                        1. associate--r+N/A

                          \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                        2. distribute-lft-out--N/A

                          \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                        3. unpow2N/A

                          \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                        4. distribute-lft-out--N/A

                          \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                        5. *-commutativeN/A

                          \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                        6. lower-*.f64N/A

                          \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                        7. lower--.f64N/A

                          \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                        8. lower--.f6492.0

                          \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                      5. Applied rewrites92.0%

                        \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                      6. Taylor expanded in d3 around 0

                        \[\leadsto \left(d2 - d1\right) \cdot d1 \]
                      7. Step-by-step derivation
                        1. Applied rewrites85.5%

                          \[\leadsto \left(d2 - d1\right) \cdot d1 \]

                        if -3.90000000000000008e74 < d1 < 9.5000000000000002e67

                        1. Initial program 100.0%

                          \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                        2. Add Preprocessing
                        3. Taylor expanded in d4 around 0

                          \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                        4. Step-by-step derivation
                          1. associate--r+N/A

                            \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                          2. distribute-lft-out--N/A

                            \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                          3. unpow2N/A

                            \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                          4. distribute-lft-out--N/A

                            \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                          5. *-commutativeN/A

                            \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                          6. lower-*.f64N/A

                            \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                          7. lower--.f64N/A

                            \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                          8. lower--.f6464.3

                            \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                        5. Applied rewrites64.3%

                          \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                        6. Taylor expanded in d1 around 0

                          \[\leadsto \left(d2 - d3\right) \cdot d1 \]
                        7. Step-by-step derivation
                          1. Applied rewrites62.9%

                            \[\leadsto \left(d2 - d3\right) \cdot d1 \]
                        8. Recombined 2 regimes into one program.
                        9. Add Preprocessing

                        Alternative 7: 65.6% accurate, 1.4× speedup?

                        \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} t_0 := \left(-d1\right) \cdot d3\\ \mathbf{if}\;d3 \leq -1.02 \cdot 10^{+147}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d3 \leq 2 \cdot 10^{+98}:\\ \;\;\;\;\left(d2 - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                        NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                        (FPCore (d1 d2 d3 d4)
                         :precision binary64
                         (let* ((t_0 (* (- d1) d3)))
                           (if (<= d3 -1.02e+147) t_0 (if (<= d3 2e+98) (* (- d2 d1) d1) t_0))))
                        assert(d1 < d2 && d2 < d3 && d3 < d4);
                        double code(double d1, double d2, double d3, double d4) {
                        	double t_0 = -d1 * d3;
                        	double tmp;
                        	if (d3 <= -1.02e+147) {
                        		tmp = t_0;
                        	} else if (d3 <= 2e+98) {
                        		tmp = (d2 - d1) * d1;
                        	} else {
                        		tmp = t_0;
                        	}
                        	return tmp;
                        }
                        
                        NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                        real(8) function code(d1, d2, d3, d4)
                            real(8), intent (in) :: d1
                            real(8), intent (in) :: d2
                            real(8), intent (in) :: d3
                            real(8), intent (in) :: d4
                            real(8) :: t_0
                            real(8) :: tmp
                            t_0 = -d1 * d3
                            if (d3 <= (-1.02d+147)) then
                                tmp = t_0
                            else if (d3 <= 2d+98) then
                                tmp = (d2 - d1) * d1
                            else
                                tmp = t_0
                            end if
                            code = tmp
                        end function
                        
                        assert d1 < d2 && d2 < d3 && d3 < d4;
                        public static double code(double d1, double d2, double d3, double d4) {
                        	double t_0 = -d1 * d3;
                        	double tmp;
                        	if (d3 <= -1.02e+147) {
                        		tmp = t_0;
                        	} else if (d3 <= 2e+98) {
                        		tmp = (d2 - d1) * d1;
                        	} else {
                        		tmp = t_0;
                        	}
                        	return tmp;
                        }
                        
                        [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                        def code(d1, d2, d3, d4):
                        	t_0 = -d1 * d3
                        	tmp = 0
                        	if d3 <= -1.02e+147:
                        		tmp = t_0
                        	elif d3 <= 2e+98:
                        		tmp = (d2 - d1) * d1
                        	else:
                        		tmp = t_0
                        	return tmp
                        
                        d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                        function code(d1, d2, d3, d4)
                        	t_0 = Float64(Float64(-d1) * d3)
                        	tmp = 0.0
                        	if (d3 <= -1.02e+147)
                        		tmp = t_0;
                        	elseif (d3 <= 2e+98)
                        		tmp = Float64(Float64(d2 - d1) * d1);
                        	else
                        		tmp = t_0;
                        	end
                        	return tmp
                        end
                        
                        d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                        function tmp_2 = code(d1, d2, d3, d4)
                        	t_0 = -d1 * d3;
                        	tmp = 0.0;
                        	if (d3 <= -1.02e+147)
                        		tmp = t_0;
                        	elseif (d3 <= 2e+98)
                        		tmp = (d2 - d1) * d1;
                        	else
                        		tmp = t_0;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                        code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[((-d1) * d3), $MachinePrecision]}, If[LessEqual[d3, -1.02e+147], t$95$0, If[LessEqual[d3, 2e+98], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]
                        
                        \begin{array}{l}
                        [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                        \\
                        \begin{array}{l}
                        t_0 := \left(-d1\right) \cdot d3\\
                        \mathbf{if}\;d3 \leq -1.02 \cdot 10^{+147}:\\
                        \;\;\;\;t\_0\\
                        
                        \mathbf{elif}\;d3 \leq 2 \cdot 10^{+98}:\\
                        \;\;\;\;\left(d2 - d1\right) \cdot d1\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;t\_0\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if d3 < -1.0199999999999999e147 or 2e98 < d3

                          1. Initial program 86.4%

                            \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                          2. Add Preprocessing
                          3. Taylor expanded in d4 around 0

                            \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                          4. Step-by-step derivation
                            1. associate--r+N/A

                              \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                            2. distribute-lft-out--N/A

                              \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                            3. unpow2N/A

                              \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                            4. distribute-lft-out--N/A

                              \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                            5. *-commutativeN/A

                              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                            6. lower-*.f64N/A

                              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                            7. lower--.f64N/A

                              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                            8. lower--.f6483.0

                              \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                          5. Applied rewrites83.0%

                            \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                          6. Taylor expanded in d3 around inf

                            \[\leadsto \color{blue}{-1 \cdot \left(d1 \cdot d3\right)} \]
                          7. Step-by-step derivation
                            1. associate-*r*N/A

                              \[\leadsto \color{blue}{\left(-1 \cdot d1\right) \cdot d3} \]
                            2. lower-*.f64N/A

                              \[\leadsto \color{blue}{\left(-1 \cdot d1\right) \cdot d3} \]
                            3. mul-1-negN/A

                              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d1\right)\right)} \cdot d3 \]
                            4. lower-neg.f6473.1

                              \[\leadsto \color{blue}{\left(-d1\right)} \cdot d3 \]
                          8. Applied rewrites73.1%

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

                          if -1.0199999999999999e147 < d3 < 2e98

                          1. Initial program 90.8%

                            \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                          2. Add Preprocessing
                          3. Taylor expanded in d4 around 0

                            \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                          4. Step-by-step derivation
                            1. associate--r+N/A

                              \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                            2. distribute-lft-out--N/A

                              \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                            3. unpow2N/A

                              \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                            4. distribute-lft-out--N/A

                              \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                            5. *-commutativeN/A

                              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                            6. lower-*.f64N/A

                              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                            7. lower--.f64N/A

                              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                            8. lower--.f6471.3

                              \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                          5. Applied rewrites71.3%

                            \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                          6. Taylor expanded in d3 around 0

                            \[\leadsto \left(d2 - d1\right) \cdot d1 \]
                          7. Step-by-step derivation
                            1. Applied rewrites66.9%

                              \[\leadsto \left(d2 - d1\right) \cdot d1 \]
                          8. Recombined 2 regimes into one program.
                          9. Add Preprocessing

                          Alternative 8: 68.5% accurate, 1.4× speedup?

                          \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} t_0 := \left(-d1\right) \cdot d3\\ \mathbf{if}\;d3 \leq -1.6 \cdot 10^{+165}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d3 \leq 1.52 \cdot 10^{+122}:\\ \;\;\;\;\left(d4 + d2\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                          NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                          (FPCore (d1 d2 d3 d4)
                           :precision binary64
                           (let* ((t_0 (* (- d1) d3)))
                             (if (<= d3 -1.6e+165) t_0 (if (<= d3 1.52e+122) (* (+ d4 d2) d1) t_0))))
                          assert(d1 < d2 && d2 < d3 && d3 < d4);
                          double code(double d1, double d2, double d3, double d4) {
                          	double t_0 = -d1 * d3;
                          	double tmp;
                          	if (d3 <= -1.6e+165) {
                          		tmp = t_0;
                          	} else if (d3 <= 1.52e+122) {
                          		tmp = (d4 + d2) * d1;
                          	} else {
                          		tmp = t_0;
                          	}
                          	return tmp;
                          }
                          
                          NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                          real(8) function code(d1, d2, d3, d4)
                              real(8), intent (in) :: d1
                              real(8), intent (in) :: d2
                              real(8), intent (in) :: d3
                              real(8), intent (in) :: d4
                              real(8) :: t_0
                              real(8) :: tmp
                              t_0 = -d1 * d3
                              if (d3 <= (-1.6d+165)) then
                                  tmp = t_0
                              else if (d3 <= 1.52d+122) then
                                  tmp = (d4 + d2) * d1
                              else
                                  tmp = t_0
                              end if
                              code = tmp
                          end function
                          
                          assert d1 < d2 && d2 < d3 && d3 < d4;
                          public static double code(double d1, double d2, double d3, double d4) {
                          	double t_0 = -d1 * d3;
                          	double tmp;
                          	if (d3 <= -1.6e+165) {
                          		tmp = t_0;
                          	} else if (d3 <= 1.52e+122) {
                          		tmp = (d4 + d2) * d1;
                          	} else {
                          		tmp = t_0;
                          	}
                          	return tmp;
                          }
                          
                          [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                          def code(d1, d2, d3, d4):
                          	t_0 = -d1 * d3
                          	tmp = 0
                          	if d3 <= -1.6e+165:
                          		tmp = t_0
                          	elif d3 <= 1.52e+122:
                          		tmp = (d4 + d2) * d1
                          	else:
                          		tmp = t_0
                          	return tmp
                          
                          d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                          function code(d1, d2, d3, d4)
                          	t_0 = Float64(Float64(-d1) * d3)
                          	tmp = 0.0
                          	if (d3 <= -1.6e+165)
                          		tmp = t_0;
                          	elseif (d3 <= 1.52e+122)
                          		tmp = Float64(Float64(d4 + d2) * d1);
                          	else
                          		tmp = t_0;
                          	end
                          	return tmp
                          end
                          
                          d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                          function tmp_2 = code(d1, d2, d3, d4)
                          	t_0 = -d1 * d3;
                          	tmp = 0.0;
                          	if (d3 <= -1.6e+165)
                          		tmp = t_0;
                          	elseif (d3 <= 1.52e+122)
                          		tmp = (d4 + d2) * d1;
                          	else
                          		tmp = t_0;
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                          code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[((-d1) * d3), $MachinePrecision]}, If[LessEqual[d3, -1.6e+165], t$95$0, If[LessEqual[d3, 1.52e+122], N[(N[(d4 + d2), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]
                          
                          \begin{array}{l}
                          [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                          \\
                          \begin{array}{l}
                          t_0 := \left(-d1\right) \cdot d3\\
                          \mathbf{if}\;d3 \leq -1.6 \cdot 10^{+165}:\\
                          \;\;\;\;t\_0\\
                          
                          \mathbf{elif}\;d3 \leq 1.52 \cdot 10^{+122}:\\
                          \;\;\;\;\left(d4 + d2\right) \cdot d1\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;t\_0\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if d3 < -1.6e165 or 1.52e122 < d3

                            1. Initial program 86.3%

                              \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                            2. Add Preprocessing
                            3. Taylor expanded in d4 around 0

                              \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                            4. Step-by-step derivation
                              1. associate--r+N/A

                                \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                              2. distribute-lft-out--N/A

                                \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                              3. unpow2N/A

                                \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                              4. distribute-lft-out--N/A

                                \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                              5. *-commutativeN/A

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                              6. lower-*.f64N/A

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                              7. lower--.f64N/A

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                              8. lower--.f6487.2

                                \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                            5. Applied rewrites87.2%

                              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                            6. Taylor expanded in d3 around inf

                              \[\leadsto \color{blue}{-1 \cdot \left(d1 \cdot d3\right)} \]
                            7. Step-by-step derivation
                              1. associate-*r*N/A

                                \[\leadsto \color{blue}{\left(-1 \cdot d1\right) \cdot d3} \]
                              2. lower-*.f64N/A

                                \[\leadsto \color{blue}{\left(-1 \cdot d1\right) \cdot d3} \]
                              3. mul-1-negN/A

                                \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d1\right)\right)} \cdot d3 \]
                              4. lower-neg.f6477.7

                                \[\leadsto \color{blue}{\left(-d1\right)} \cdot d3 \]
                            8. Applied rewrites77.7%

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

                            if -1.6e165 < d3 < 1.52e122

                            1. Initial program 90.7%

                              \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                            2. Add Preprocessing
                            3. Taylor expanded in d1 around 0

                              \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 + d4\right) - d3\right)} \]
                            4. Step-by-step derivation
                              1. *-commutativeN/A

                                \[\leadsto \color{blue}{\left(\left(d2 + d4\right) - d3\right) \cdot d1} \]
                              2. lower-*.f64N/A

                                \[\leadsto \color{blue}{\left(\left(d2 + d4\right) - d3\right) \cdot d1} \]
                              3. lower--.f64N/A

                                \[\leadsto \color{blue}{\left(\left(d2 + d4\right) - d3\right)} \cdot d1 \]
                              4. +-commutativeN/A

                                \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d3\right) \cdot d1 \]
                              5. lower-+.f6471.8

                                \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d3\right) \cdot d1 \]
                            5. Applied rewrites71.8%

                              \[\leadsto \color{blue}{\left(\left(d4 + d2\right) - d3\right) \cdot d1} \]
                            6. Taylor expanded in d3 around 0

                              \[\leadsto d1 \cdot \color{blue}{\left(d2 + d4\right)} \]
                            7. Step-by-step derivation
                              1. Applied rewrites66.8%

                                \[\leadsto \left(d4 + d2\right) \cdot \color{blue}{d1} \]
                            8. Recombined 2 regimes into one program.
                            9. Add Preprocessing

                            Alternative 9: 53.1% accurate, 1.5× speedup?

                            \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d4 \leq 1.42 \cdot 10^{-154}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{elif}\;d4 \leq 1.95 \cdot 10^{+74}:\\ \;\;\;\;\left(-d1\right) \cdot d3\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            (FPCore (d1 d2 d3 d4)
                             :precision binary64
                             (if (<= d4 1.42e-154)
                               (* d2 d1)
                               (if (<= d4 1.95e+74) (* (- d1) d3) (* d4 d1))))
                            assert(d1 < d2 && d2 < d3 && d3 < d4);
                            double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 1.42e-154) {
                            		tmp = d2 * d1;
                            	} else if (d4 <= 1.95e+74) {
                            		tmp = -d1 * d3;
                            	} else {
                            		tmp = d4 * d1;
                            	}
                            	return tmp;
                            }
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            real(8) function code(d1, d2, d3, d4)
                                real(8), intent (in) :: d1
                                real(8), intent (in) :: d2
                                real(8), intent (in) :: d3
                                real(8), intent (in) :: d4
                                real(8) :: tmp
                                if (d4 <= 1.42d-154) then
                                    tmp = d2 * d1
                                else if (d4 <= 1.95d+74) then
                                    tmp = -d1 * d3
                                else
                                    tmp = d4 * d1
                                end if
                                code = tmp
                            end function
                            
                            assert d1 < d2 && d2 < d3 && d3 < d4;
                            public static double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 1.42e-154) {
                            		tmp = d2 * d1;
                            	} else if (d4 <= 1.95e+74) {
                            		tmp = -d1 * d3;
                            	} else {
                            		tmp = d4 * d1;
                            	}
                            	return tmp;
                            }
                            
                            [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                            def code(d1, d2, d3, d4):
                            	tmp = 0
                            	if d4 <= 1.42e-154:
                            		tmp = d2 * d1
                            	elif d4 <= 1.95e+74:
                            		tmp = -d1 * d3
                            	else:
                            		tmp = d4 * d1
                            	return tmp
                            
                            d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                            function code(d1, d2, d3, d4)
                            	tmp = 0.0
                            	if (d4 <= 1.42e-154)
                            		tmp = Float64(d2 * d1);
                            	elseif (d4 <= 1.95e+74)
                            		tmp = Float64(Float64(-d1) * d3);
                            	else
                            		tmp = Float64(d4 * d1);
                            	end
                            	return tmp
                            end
                            
                            d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                            function tmp_2 = code(d1, d2, d3, d4)
                            	tmp = 0.0;
                            	if (d4 <= 1.42e-154)
                            		tmp = d2 * d1;
                            	elseif (d4 <= 1.95e+74)
                            		tmp = -d1 * d3;
                            	else
                            		tmp = d4 * d1;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.42e-154], N[(d2 * d1), $MachinePrecision], If[LessEqual[d4, 1.95e+74], N[((-d1) * d3), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
                            
                            \begin{array}{l}
                            [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;d4 \leq 1.42 \cdot 10^{-154}:\\
                            \;\;\;\;d2 \cdot d1\\
                            
                            \mathbf{elif}\;d4 \leq 1.95 \cdot 10^{+74}:\\
                            \;\;\;\;\left(-d1\right) \cdot d3\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;d4 \cdot d1\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if d4 < 1.42e-154

                              1. Initial program 89.0%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d4 around 0

                                \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                              4. Step-by-step derivation
                                1. associate--r+N/A

                                  \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                                2. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                                3. unpow2N/A

                                  \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                                4. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                                5. *-commutativeN/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                6. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                7. lower--.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                                8. lower--.f6478.6

                                  \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                              5. Applied rewrites78.6%

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                              6. Taylor expanded in d2 around inf

                                \[\leadsto \color{blue}{d1 \cdot d2} \]
                              7. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \color{blue}{d2 \cdot d1} \]
                                2. lower-*.f6431.3

                                  \[\leadsto \color{blue}{d2 \cdot d1} \]
                              8. Applied rewrites31.3%

                                \[\leadsto \color{blue}{d2 \cdot d1} \]

                              if 1.42e-154 < d4 < 1.95000000000000004e74

                              1. Initial program 90.7%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d4 around 0

                                \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                              4. Step-by-step derivation
                                1. associate--r+N/A

                                  \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                                2. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                                3. unpow2N/A

                                  \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                                4. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                                5. *-commutativeN/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                6. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                7. lower--.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                                8. lower--.f64100.0

                                  \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                              5. Applied rewrites100.0%

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                              6. Taylor expanded in d3 around inf

                                \[\leadsto \color{blue}{-1 \cdot \left(d1 \cdot d3\right)} \]
                              7. Step-by-step derivation
                                1. associate-*r*N/A

                                  \[\leadsto \color{blue}{\left(-1 \cdot d1\right) \cdot d3} \]
                                2. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\left(-1 \cdot d1\right) \cdot d3} \]
                                3. mul-1-negN/A

                                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d1\right)\right)} \cdot d3 \]
                                4. lower-neg.f6441.2

                                  \[\leadsto \color{blue}{\left(-d1\right)} \cdot d3 \]
                              8. Applied rewrites41.2%

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

                              if 1.95000000000000004e74 < d4

                              1. Initial program 89.8%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d4 around inf

                                \[\leadsto \color{blue}{d1 \cdot d4} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \color{blue}{d4 \cdot d1} \]
                                2. lower-*.f6469.8

                                  \[\leadsto \color{blue}{d4 \cdot d1} \]
                              5. Applied rewrites69.8%

                                \[\leadsto \color{blue}{d4 \cdot d1} \]
                            3. Recombined 3 regimes into one program.
                            4. Add Preprocessing

                            Alternative 10: 53.6% accurate, 1.5× speedup?

                            \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d4 \leq 1.65 \cdot 10^{-282}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{elif}\;d4 \leq 6.1 \cdot 10^{+60}:\\ \;\;\;\;\left(-d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            (FPCore (d1 d2 d3 d4)
                             :precision binary64
                             (if (<= d4 1.65e-282) (* d2 d1) (if (<= d4 6.1e+60) (* (- d1) d1) (* d4 d1))))
                            assert(d1 < d2 && d2 < d3 && d3 < d4);
                            double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 1.65e-282) {
                            		tmp = d2 * d1;
                            	} else if (d4 <= 6.1e+60) {
                            		tmp = -d1 * d1;
                            	} else {
                            		tmp = d4 * d1;
                            	}
                            	return tmp;
                            }
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            real(8) function code(d1, d2, d3, d4)
                                real(8), intent (in) :: d1
                                real(8), intent (in) :: d2
                                real(8), intent (in) :: d3
                                real(8), intent (in) :: d4
                                real(8) :: tmp
                                if (d4 <= 1.65d-282) then
                                    tmp = d2 * d1
                                else if (d4 <= 6.1d+60) then
                                    tmp = -d1 * d1
                                else
                                    tmp = d4 * d1
                                end if
                                code = tmp
                            end function
                            
                            assert d1 < d2 && d2 < d3 && d3 < d4;
                            public static double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 1.65e-282) {
                            		tmp = d2 * d1;
                            	} else if (d4 <= 6.1e+60) {
                            		tmp = -d1 * d1;
                            	} else {
                            		tmp = d4 * d1;
                            	}
                            	return tmp;
                            }
                            
                            [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                            def code(d1, d2, d3, d4):
                            	tmp = 0
                            	if d4 <= 1.65e-282:
                            		tmp = d2 * d1
                            	elif d4 <= 6.1e+60:
                            		tmp = -d1 * d1
                            	else:
                            		tmp = d4 * d1
                            	return tmp
                            
                            d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                            function code(d1, d2, d3, d4)
                            	tmp = 0.0
                            	if (d4 <= 1.65e-282)
                            		tmp = Float64(d2 * d1);
                            	elseif (d4 <= 6.1e+60)
                            		tmp = Float64(Float64(-d1) * d1);
                            	else
                            		tmp = Float64(d4 * d1);
                            	end
                            	return tmp
                            end
                            
                            d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                            function tmp_2 = code(d1, d2, d3, d4)
                            	tmp = 0.0;
                            	if (d4 <= 1.65e-282)
                            		tmp = d2 * d1;
                            	elseif (d4 <= 6.1e+60)
                            		tmp = -d1 * d1;
                            	else
                            		tmp = d4 * d1;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.65e-282], N[(d2 * d1), $MachinePrecision], If[LessEqual[d4, 6.1e+60], N[((-d1) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
                            
                            \begin{array}{l}
                            [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;d4 \leq 1.65 \cdot 10^{-282}:\\
                            \;\;\;\;d2 \cdot d1\\
                            
                            \mathbf{elif}\;d4 \leq 6.1 \cdot 10^{+60}:\\
                            \;\;\;\;\left(-d1\right) \cdot d1\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;d4 \cdot d1\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if d4 < 1.65e-282

                              1. Initial program 88.8%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d4 around 0

                                \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                              4. Step-by-step derivation
                                1. associate--r+N/A

                                  \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                                2. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                                3. unpow2N/A

                                  \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                                4. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                                5. *-commutativeN/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                6. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                7. lower--.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                                8. lower--.f6475.4

                                  \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                              5. Applied rewrites75.4%

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                              6. Taylor expanded in d2 around inf

                                \[\leadsto \color{blue}{d1 \cdot d2} \]
                              7. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \color{blue}{d2 \cdot d1} \]
                                2. lower-*.f6429.3

                                  \[\leadsto \color{blue}{d2 \cdot d1} \]
                              8. Applied rewrites29.3%

                                \[\leadsto \color{blue}{d2 \cdot d1} \]

                              if 1.65e-282 < d4 < 6.0999999999999999e60

                              1. Initial program 90.3%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d1 around inf

                                \[\leadsto \color{blue}{-1 \cdot {d1}^{2}} \]
                              4. Step-by-step derivation
                                1. unpow2N/A

                                  \[\leadsto -1 \cdot \color{blue}{\left(d1 \cdot d1\right)} \]
                                2. associate-*r*N/A

                                  \[\leadsto \color{blue}{\left(-1 \cdot d1\right) \cdot d1} \]
                                3. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\left(-1 \cdot d1\right) \cdot d1} \]
                                4. mul-1-negN/A

                                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d1\right)\right)} \cdot d1 \]
                                5. lower-neg.f6439.3

                                  \[\leadsto \color{blue}{\left(-d1\right)} \cdot d1 \]
                              5. Applied rewrites39.3%

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

                              if 6.0999999999999999e60 < d4

                              1. Initial program 90.2%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d4 around inf

                                \[\leadsto \color{blue}{d1 \cdot d4} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \color{blue}{d4 \cdot d1} \]
                                2. lower-*.f6467.3

                                  \[\leadsto \color{blue}{d4 \cdot d1} \]
                              5. Applied rewrites67.3%

                                \[\leadsto \color{blue}{d4 \cdot d1} \]
                            3. Recombined 3 regimes into one program.
                            4. Add Preprocessing

                            Alternative 11: 93.8% accurate, 1.7× speedup?

                            \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d4 \leq 5 \cdot 10^{+27}:\\ \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\ \end{array} \end{array} \]
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            (FPCore (d1 d2 d3 d4)
                             :precision binary64
                             (if (<= d4 5e+27) (* (- (- d2 d3) d1) d1) (* (- (- d4 d3) d1) d1)))
                            assert(d1 < d2 && d2 < d3 && d3 < d4);
                            double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 5e+27) {
                            		tmp = ((d2 - d3) - d1) * d1;
                            	} else {
                            		tmp = ((d4 - d3) - d1) * d1;
                            	}
                            	return tmp;
                            }
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            real(8) function code(d1, d2, d3, d4)
                                real(8), intent (in) :: d1
                                real(8), intent (in) :: d2
                                real(8), intent (in) :: d3
                                real(8), intent (in) :: d4
                                real(8) :: tmp
                                if (d4 <= 5d+27) then
                                    tmp = ((d2 - d3) - d1) * d1
                                else
                                    tmp = ((d4 - d3) - d1) * d1
                                end if
                                code = tmp
                            end function
                            
                            assert d1 < d2 && d2 < d3 && d3 < d4;
                            public static double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 5e+27) {
                            		tmp = ((d2 - d3) - d1) * d1;
                            	} else {
                            		tmp = ((d4 - d3) - d1) * d1;
                            	}
                            	return tmp;
                            }
                            
                            [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                            def code(d1, d2, d3, d4):
                            	tmp = 0
                            	if d4 <= 5e+27:
                            		tmp = ((d2 - d3) - d1) * d1
                            	else:
                            		tmp = ((d4 - d3) - d1) * d1
                            	return tmp
                            
                            d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                            function code(d1, d2, d3, d4)
                            	tmp = 0.0
                            	if (d4 <= 5e+27)
                            		tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1);
                            	else
                            		tmp = Float64(Float64(Float64(d4 - d3) - d1) * d1);
                            	end
                            	return tmp
                            end
                            
                            d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                            function tmp_2 = code(d1, d2, d3, d4)
                            	tmp = 0.0;
                            	if (d4 <= 5e+27)
                            		tmp = ((d2 - d3) - d1) * d1;
                            	else
                            		tmp = ((d4 - d3) - d1) * d1;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 5e+27], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]
                            
                            \begin{array}{l}
                            [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;d4 \leq 5 \cdot 10^{+27}:\\
                            \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if d4 < 4.99999999999999979e27

                              1. Initial program 89.1%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d4 around 0

                                \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                              4. Step-by-step derivation
                                1. associate--r+N/A

                                  \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                                2. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                                3. unpow2N/A

                                  \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                                4. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                                5. *-commutativeN/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                6. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                7. lower--.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                                8. lower--.f6482.6

                                  \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                              5. Applied rewrites82.6%

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]

                              if 4.99999999999999979e27 < d4

                              1. Initial program 90.7%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d2 around 0

                                \[\leadsto \color{blue}{d1 \cdot d4 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                              4. Step-by-step derivation
                                1. associate--r+N/A

                                  \[\leadsto \color{blue}{\left(d1 \cdot d4 - d1 \cdot d3\right) - {d1}^{2}} \]
                                2. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(d4 - d3\right)} - {d1}^{2} \]
                                3. unpow2N/A

                                  \[\leadsto d1 \cdot \left(d4 - d3\right) - \color{blue}{d1 \cdot d1} \]
                                4. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(\left(d4 - d3\right) - d1\right)} \]
                                5. *-commutativeN/A

                                  \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
                                6. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right) \cdot d1} \]
                                7. lower--.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d4 - d3\right) - d1\right)} \cdot d1 \]
                                8. lower--.f6494.5

                                  \[\leadsto \left(\color{blue}{\left(d4 - d3\right)} - d1\right) \cdot d1 \]
                              5. Applied rewrites94.5%

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

                            Alternative 12: 50.4% accurate, 2.5× speedup?

                            \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d4 \leq 5.6 \cdot 10^{+31}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            (FPCore (d1 d2 d3 d4)
                             :precision binary64
                             (if (<= d4 5.6e+31) (* d2 d1) (* d4 d1)))
                            assert(d1 < d2 && d2 < d3 && d3 < d4);
                            double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 5.6e+31) {
                            		tmp = d2 * d1;
                            	} else {
                            		tmp = d4 * d1;
                            	}
                            	return tmp;
                            }
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            real(8) function code(d1, d2, d3, d4)
                                real(8), intent (in) :: d1
                                real(8), intent (in) :: d2
                                real(8), intent (in) :: d3
                                real(8), intent (in) :: d4
                                real(8) :: tmp
                                if (d4 <= 5.6d+31) then
                                    tmp = d2 * d1
                                else
                                    tmp = d4 * d1
                                end if
                                code = tmp
                            end function
                            
                            assert d1 < d2 && d2 < d3 && d3 < d4;
                            public static double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 5.6e+31) {
                            		tmp = d2 * d1;
                            	} else {
                            		tmp = d4 * d1;
                            	}
                            	return tmp;
                            }
                            
                            [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                            def code(d1, d2, d3, d4):
                            	tmp = 0
                            	if d4 <= 5.6e+31:
                            		tmp = d2 * d1
                            	else:
                            		tmp = d4 * d1
                            	return tmp
                            
                            d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                            function code(d1, d2, d3, d4)
                            	tmp = 0.0
                            	if (d4 <= 5.6e+31)
                            		tmp = Float64(d2 * d1);
                            	else
                            		tmp = Float64(d4 * d1);
                            	end
                            	return tmp
                            end
                            
                            d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                            function tmp_2 = code(d1, d2, d3, d4)
                            	tmp = 0.0;
                            	if (d4 <= 5.6e+31)
                            		tmp = d2 * d1;
                            	else
                            		tmp = d4 * d1;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 5.6e+31], N[(d2 * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
                            
                            \begin{array}{l}
                            [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;d4 \leq 5.6 \cdot 10^{+31}:\\
                            \;\;\;\;d2 \cdot d1\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;d4 \cdot d1\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if d4 < 5.60000000000000034e31

                              1. Initial program 89.1%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d4 around 0

                                \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                              4. Step-by-step derivation
                                1. associate--r+N/A

                                  \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                                2. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                                3. unpow2N/A

                                  \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                                4. distribute-lft-out--N/A

                                  \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                                5. *-commutativeN/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                6. lower-*.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                                7. lower--.f64N/A

                                  \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                                8. lower--.f6482.7

                                  \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                              5. Applied rewrites82.7%

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                              6. Taylor expanded in d2 around inf

                                \[\leadsto \color{blue}{d1 \cdot d2} \]
                              7. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \color{blue}{d2 \cdot d1} \]
                                2. lower-*.f6431.5

                                  \[\leadsto \color{blue}{d2 \cdot d1} \]
                              8. Applied rewrites31.5%

                                \[\leadsto \color{blue}{d2 \cdot d1} \]

                              if 5.60000000000000034e31 < d4

                              1. Initial program 90.5%

                                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                              2. Add Preprocessing
                              3. Taylor expanded in d4 around inf

                                \[\leadsto \color{blue}{d1 \cdot d4} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \color{blue}{d4 \cdot d1} \]
                                2. lower-*.f6464.8

                                  \[\leadsto \color{blue}{d4 \cdot d1} \]
                              5. Applied rewrites64.8%

                                \[\leadsto \color{blue}{d4 \cdot d1} \]
                            3. Recombined 2 regimes into one program.
                            4. Add Preprocessing

                            Alternative 13: 31.2% accurate, 5.0× speedup?

                            \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ d2 \cdot d1 \end{array} \]
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            (FPCore (d1 d2 d3 d4) :precision binary64 (* d2 d1))
                            assert(d1 < d2 && d2 < d3 && d3 < d4);
                            double code(double d1, double d2, double d3, double d4) {
                            	return d2 * d1;
                            }
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            real(8) function code(d1, d2, d3, d4)
                                real(8), intent (in) :: d1
                                real(8), intent (in) :: d2
                                real(8), intent (in) :: d3
                                real(8), intent (in) :: d4
                                code = d2 * d1
                            end function
                            
                            assert d1 < d2 && d2 < d3 && d3 < d4;
                            public static double code(double d1, double d2, double d3, double d4) {
                            	return d2 * d1;
                            }
                            
                            [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                            def code(d1, d2, d3, d4):
                            	return d2 * d1
                            
                            d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                            function code(d1, d2, d3, d4)
                            	return Float64(d2 * d1)
                            end
                            
                            d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                            function tmp = code(d1, d2, d3, d4)
                            	tmp = d2 * d1;
                            end
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            code[d1_, d2_, d3_, d4_] := N[(d2 * d1), $MachinePrecision]
                            
                            \begin{array}{l}
                            [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                            \\
                            d2 \cdot d1
                            \end{array}
                            
                            Derivation
                            1. Initial program 89.4%

                              \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                            2. Add Preprocessing
                            3. Taylor expanded in d4 around 0

                              \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                            4. Step-by-step derivation
                              1. associate--r+N/A

                                \[\leadsto \color{blue}{\left(d1 \cdot d2 - d1 \cdot d3\right) - {d1}^{2}} \]
                              2. distribute-lft-out--N/A

                                \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right)} - {d1}^{2} \]
                              3. unpow2N/A

                                \[\leadsto d1 \cdot \left(d2 - d3\right) - \color{blue}{d1 \cdot d1} \]
                              4. distribute-lft-out--N/A

                                \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) - d1\right)} \]
                              5. *-commutativeN/A

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                              6. lower-*.f64N/A

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                              7. lower--.f64N/A

                                \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right)} \cdot d1 \]
                              8. lower--.f6475.0

                                \[\leadsto \left(\color{blue}{\left(d2 - d3\right)} - d1\right) \cdot d1 \]
                            5. Applied rewrites75.0%

                              \[\leadsto \color{blue}{\left(\left(d2 - d3\right) - d1\right) \cdot d1} \]
                            6. Taylor expanded in d2 around inf

                              \[\leadsto \color{blue}{d1 \cdot d2} \]
                            7. Step-by-step derivation
                              1. *-commutativeN/A

                                \[\leadsto \color{blue}{d2 \cdot d1} \]
                              2. lower-*.f6427.0

                                \[\leadsto \color{blue}{d2 \cdot d1} \]
                            8. Applied rewrites27.0%

                              \[\leadsto \color{blue}{d2 \cdot d1} \]
                            9. Add Preprocessing

                            Developer Target 1: 100.0% accurate, 2.0× speedup?

                            \[\begin{array}{l} \\ d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right) \end{array} \]
                            (FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
                            double code(double d1, double d2, double d3, double d4) {
                            	return d1 * (((d2 - d3) + d4) - d1);
                            }
                            
                            real(8) function code(d1, d2, d3, d4)
                                real(8), intent (in) :: d1
                                real(8), intent (in) :: d2
                                real(8), intent (in) :: d3
                                real(8), intent (in) :: d4
                                code = d1 * (((d2 - d3) + d4) - d1)
                            end function
                            
                            public static double code(double d1, double d2, double d3, double d4) {
                            	return d1 * (((d2 - d3) + d4) - d1);
                            }
                            
                            def code(d1, d2, d3, d4):
                            	return d1 * (((d2 - d3) + d4) - d1)
                            
                            function code(d1, d2, d3, d4)
                            	return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1))
                            end
                            
                            function tmp = code(d1, d2, d3, d4)
                            	tmp = d1 * (((d2 - d3) + d4) - d1);
                            end
                            
                            code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
                            
                            \begin{array}{l}
                            
                            \\
                            d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
                            \end{array}
                            

                            Reproduce

                            ?
                            herbie shell --seed 2024332 
                            (FPCore (d1 d2 d3 d4)
                              :name "FastMath dist4"
                              :precision binary64
                            
                              :alt
                              (! :herbie-platform default (* d1 (- (+ (- d2 d3) d4) d1)))
                            
                              (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))