FastMath dist4

Percentage Accurate: 88.5% → 100.0%
Time: 11.7s
Alternatives: 12
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 12 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.5% 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: 100.0% accurate, 1.7× speedup?

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

\\
d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)
\end{array}
Derivation
  1. Initial program 84.3%

    \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
  2. Step-by-step derivation
    1. distribute-lft-out--N/A

      \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
    2. *-commutativeN/A

      \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
    3. distribute-lft-outN/A

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

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

      \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
    6. associate-+r-N/A

      \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
    7. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
    8. associate-+l+N/A

      \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
    9. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
    10. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
    11. unsub-negN/A

      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
    12. associate--l-N/A

      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
    13. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
    14. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
    15. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
    16. +-lowering-+.f64100.0%

      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
  3. Simplified100.0%

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

Alternative 2: 63.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := d1 \cdot \left(d4 - d3\right)\\ \mathbf{if}\;d2 \leq -3.5 \cdot 10^{+49}:\\ \;\;\;\;d1 \cdot \left(d2 - d1\right)\\ \mathbf{elif}\;d2 \leq -4.6 \cdot 10^{-77}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d2 \leq 5.8 \cdot 10^{-214}:\\ \;\;\;\;d1 \cdot \left(d4 - d1\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (let* ((t_0 (* d1 (- d4 d3))))
   (if (<= d2 -3.5e+49)
     (* d1 (- d2 d1))
     (if (<= d2 -4.6e-77) t_0 (if (<= d2 5.8e-214) (* d1 (- d4 d1)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
	double t_0 = d1 * (d4 - d3);
	double tmp;
	if (d2 <= -3.5e+49) {
		tmp = d1 * (d2 - d1);
	} else if (d2 <= -4.6e-77) {
		tmp = t_0;
	} else if (d2 <= 5.8e-214) {
		tmp = d1 * (d4 - d1);
	} else {
		tmp = t_0;
	}
	return tmp;
}
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 * (d4 - d3)
    if (d2 <= (-3.5d+49)) then
        tmp = d1 * (d2 - d1)
    else if (d2 <= (-4.6d-77)) then
        tmp = t_0
    else if (d2 <= 5.8d-214) then
        tmp = d1 * (d4 - d1)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
	double t_0 = d1 * (d4 - d3);
	double tmp;
	if (d2 <= -3.5e+49) {
		tmp = d1 * (d2 - d1);
	} else if (d2 <= -4.6e-77) {
		tmp = t_0;
	} else if (d2 <= 5.8e-214) {
		tmp = d1 * (d4 - d1);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(d1, d2, d3, d4):
	t_0 = d1 * (d4 - d3)
	tmp = 0
	if d2 <= -3.5e+49:
		tmp = d1 * (d2 - d1)
	elif d2 <= -4.6e-77:
		tmp = t_0
	elif d2 <= 5.8e-214:
		tmp = d1 * (d4 - d1)
	else:
		tmp = t_0
	return tmp
function code(d1, d2, d3, d4)
	t_0 = Float64(d1 * Float64(d4 - d3))
	tmp = 0.0
	if (d2 <= -3.5e+49)
		tmp = Float64(d1 * Float64(d2 - d1));
	elseif (d2 <= -4.6e-77)
		tmp = t_0;
	elseif (d2 <= 5.8e-214)
		tmp = Float64(d1 * Float64(d4 - d1));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(d1, d2, d3, d4)
	t_0 = d1 * (d4 - d3);
	tmp = 0.0;
	if (d2 <= -3.5e+49)
		tmp = d1 * (d2 - d1);
	elseif (d2 <= -4.6e-77)
		tmp = t_0;
	elseif (d2 <= 5.8e-214)
		tmp = d1 * (d4 - d1);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d2, -3.5e+49], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -4.6e-77], t$95$0, If[LessEqual[d2, 5.8e-214], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := d1 \cdot \left(d4 - d3\right)\\
\mathbf{if}\;d2 \leq -3.5 \cdot 10^{+49}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\

\mathbf{elif}\;d2 \leq -4.6 \cdot 10^{-77}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d2 < -3.49999999999999975e49

    1. Initial program 83.0%

      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
    2. Step-by-step derivation
      1. distribute-lft-out--N/A

        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
      2. *-commutativeN/A

        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
      3. distribute-lft-outN/A

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

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

        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
      6. associate-+r-N/A

        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
      8. associate-+l+N/A

        \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
      11. unsub-negN/A

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
      12. associate--l-N/A

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
      13. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
      15. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
      16. +-lowering-+.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d2 - \left(d1 + d3\right)\right)}\right) \]
      2. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
      3. +-lowering-+.f6490.3%

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
    7. Simplified90.3%

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

      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{d1}\right)\right) \]
    9. Step-by-step derivation
      1. Simplified78.8%

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

      if -3.49999999999999975e49 < d2 < -4.59999999999999997e-77 or 5.7999999999999997e-214 < d2

      1. Initial program 85.7%

        \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
      2. Step-by-step derivation
        1. distribute-lft-out--N/A

          \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
        2. *-commutativeN/A

          \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
        3. distribute-lft-outN/A

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

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

          \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
        6. associate-+r-N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
        7. sub-negN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
        8. associate-+l+N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
        9. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
        10. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
        11. unsub-negN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
        12. associate--l-N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
        13. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
        14. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
        15. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
        16. +-lowering-+.f64100.0%

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
      3. Simplified100.0%

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

          \[\leadsto d1 \cdot \left(\left(d4 - \left(d1 + d3\right)\right) + \color{blue}{d2}\right) \]
        2. distribute-lft-inN/A

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

          \[\leadsto \mathsf{+.f64}\left(\left(d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\right), \color{blue}{\left(d1 \cdot d2\right)}\right) \]
        4. *-lowering-*.f64N/A

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

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \left(d1 + d3\right)\right)\right), \left(d1 \cdot d2\right)\right) \]
        6. +-lowering-+.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, d3\right)\right)\right), \left(d1 \cdot d2\right)\right) \]
        7. *-lowering-*.f6493.2%

          \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, d3\right)\right)\right), \mathsf{*.f64}\left(d1, \color{blue}{d2}\right)\right) \]
      6. Applied egg-rr93.2%

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

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

          \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d4 - \left(d1 + d3\right)\right)}\right) \]
        2. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
        3. +-lowering-+.f6479.5%

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
      9. Simplified79.5%

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

        \[\leadsto \color{blue}{d1 \cdot \left(d4 - d3\right)} \]
      11. Step-by-step derivation
        1. remove-double-negN/A

          \[\leadsto \mathsf{neg}\left(\left(\mathsf{neg}\left(d1 \cdot \left(d4 - d3\right)\right)\right)\right) \]
        2. distribute-rgt-neg-outN/A

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

          \[\leadsto \mathsf{neg}\left(d1 \cdot \left(-1 \cdot \left(d4 - d3\right)\right)\right) \]
        4. distribute-rgt-neg-inN/A

          \[\leadsto d1 \cdot \color{blue}{\left(\mathsf{neg}\left(-1 \cdot \left(d4 - d3\right)\right)\right)} \]
        5. *-rgt-identityN/A

          \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\left(-1 \cdot \left(d4 - d3\right)\right) \cdot 1\right)\right) \]
        6. *-inversesN/A

          \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\left(-1 \cdot \left(d4 - d3\right)\right) \cdot \frac{d1}{d1}\right)\right) \]
        7. associate-/l*N/A

          \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\frac{\left(-1 \cdot \left(d4 - d3\right)\right) \cdot d1}{d1}\right)\right) \]
        8. associate-*l/N/A

          \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\frac{-1 \cdot \left(d4 - d3\right)}{d1} \cdot d1\right)\right) \]
        9. associate-*r/N/A

          \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\left(-1 \cdot \frac{d4 - d3}{d1}\right) \cdot d1\right)\right) \]
        10. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\mathsf{neg}\left(\left(-1 \cdot \frac{d4 - d3}{d1}\right) \cdot d1\right)\right)}\right) \]
        11. neg-sub0N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \color{blue}{\left(-1 \cdot \frac{d4 - d3}{d1}\right) \cdot d1}\right)\right) \]
        12. associate-*r/N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \frac{-1 \cdot \left(d4 - d3\right)}{d1} \cdot d1\right)\right) \]
        13. associate-*l/N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \frac{\left(-1 \cdot \left(d4 - d3\right)\right) \cdot d1}{\color{blue}{d1}}\right)\right) \]
        14. associate-/l*N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \left(-1 \cdot \left(d4 - d3\right)\right) \cdot \color{blue}{\frac{d1}{d1}}\right)\right) \]
        15. *-inversesN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \left(-1 \cdot \left(d4 - d3\right)\right) \cdot 1\right)\right) \]
        16. mul-1-negN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \left(\mathsf{neg}\left(\left(d4 - d3\right)\right)\right) \cdot 1\right)\right) \]
        17. cancel-sign-subN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 + \color{blue}{\left(d4 - d3\right) \cdot 1}\right)\right) \]
        18. *-rgt-identityN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 + \left(d4 - \color{blue}{d3}\right)\right)\right) \]
        19. sub-negN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 + \left(d4 + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
        20. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(0 + \left(\left(\mathsf{neg}\left(d3\right)\right) + \color{blue}{d4}\right)\right)\right) \]
        21. associate-+l+N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(0 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \color{blue}{d4}\right)\right) \]
      12. Simplified59.3%

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

      if -4.59999999999999997e-77 < d2 < 5.7999999999999997e-214

      1. Initial program 82.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 \mathsf{\_.f64}\left(\color{blue}{\left(d1 \cdot d4\right)}, \mathsf{*.f64}\left(d1, d1\right)\right) \]
      4. Step-by-step derivation
        1. *-lowering-*.f6465.3%

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(d1, d4\right), \mathsf{*.f64}\left(\color{blue}{d1}, d1\right)\right) \]
      5. Simplified65.3%

        \[\leadsto \color{blue}{d1 \cdot d4} - d1 \cdot d1 \]
      6. Step-by-step derivation
        1. distribute-lft-out--N/A

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

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

          \[\leadsto \mathsf{*.f64}\left(\left(d4 - d1\right), \color{blue}{d1}\right) \]
        4. --lowering--.f6477.8%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(d4, d1\right), d1\right) \]
      7. Applied egg-rr77.8%

        \[\leadsto \color{blue}{\left(d4 - d1\right) \cdot d1} \]
    10. Recombined 3 regimes into one program.
    11. Final simplification68.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;d2 \leq -3.5 \cdot 10^{+49}:\\ \;\;\;\;d1 \cdot \left(d2 - d1\right)\\ \mathbf{elif}\;d2 \leq -4.6 \cdot 10^{-77}:\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \mathbf{elif}\;d2 \leq 5.8 \cdot 10^{-214}:\\ \;\;\;\;d1 \cdot \left(d4 - d1\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \end{array} \]
    12. Add Preprocessing

    Alternative 3: 71.3% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := d1 \cdot \left(d2 - d3\right)\\ \mathbf{if}\;d3 \leq -1.02 \cdot 10^{+89}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d3 \leq -1.5 \cdot 10^{-141}:\\ \;\;\;\;d1 \cdot \left(d2 + d4\right)\\ \mathbf{elif}\;d3 \leq 4 \cdot 10^{+46}:\\ \;\;\;\;d1 \cdot \left(d2 - d1\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (d1 d2 d3 d4)
     :precision binary64
     (let* ((t_0 (* d1 (- d2 d3))))
       (if (<= d3 -1.02e+89)
         t_0
         (if (<= d3 -1.5e-141)
           (* d1 (+ d2 d4))
           (if (<= d3 4e+46) (* d1 (- d2 d1)) t_0)))))
    double code(double d1, double d2, double d3, double d4) {
    	double t_0 = d1 * (d2 - d3);
    	double tmp;
    	if (d3 <= -1.02e+89) {
    		tmp = t_0;
    	} else if (d3 <= -1.5e-141) {
    		tmp = d1 * (d2 + d4);
    	} else if (d3 <= 4e+46) {
    		tmp = d1 * (d2 - d1);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    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 * (d2 - d3)
        if (d3 <= (-1.02d+89)) then
            tmp = t_0
        else if (d3 <= (-1.5d-141)) then
            tmp = d1 * (d2 + d4)
        else if (d3 <= 4d+46) then
            tmp = d1 * (d2 - d1)
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double d1, double d2, double d3, double d4) {
    	double t_0 = d1 * (d2 - d3);
    	double tmp;
    	if (d3 <= -1.02e+89) {
    		tmp = t_0;
    	} else if (d3 <= -1.5e-141) {
    		tmp = d1 * (d2 + d4);
    	} else if (d3 <= 4e+46) {
    		tmp = d1 * (d2 - d1);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(d1, d2, d3, d4):
    	t_0 = d1 * (d2 - d3)
    	tmp = 0
    	if d3 <= -1.02e+89:
    		tmp = t_0
    	elif d3 <= -1.5e-141:
    		tmp = d1 * (d2 + d4)
    	elif d3 <= 4e+46:
    		tmp = d1 * (d2 - d1)
    	else:
    		tmp = t_0
    	return tmp
    
    function code(d1, d2, d3, d4)
    	t_0 = Float64(d1 * Float64(d2 - d3))
    	tmp = 0.0
    	if (d3 <= -1.02e+89)
    		tmp = t_0;
    	elseif (d3 <= -1.5e-141)
    		tmp = Float64(d1 * Float64(d2 + d4));
    	elseif (d3 <= 4e+46)
    		tmp = Float64(d1 * Float64(d2 - d1));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(d1, d2, d3, d4)
    	t_0 = d1 * (d2 - d3);
    	tmp = 0.0;
    	if (d3 <= -1.02e+89)
    		tmp = t_0;
    	elseif (d3 <= -1.5e-141)
    		tmp = d1 * (d2 + d4);
    	elseif (d3 <= 4e+46)
    		tmp = d1 * (d2 - d1);
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -1.02e+89], t$95$0, If[LessEqual[d3, -1.5e-141], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 4e+46], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := d1 \cdot \left(d2 - d3\right)\\
    \mathbf{if}\;d3 \leq -1.02 \cdot 10^{+89}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;d3 \leq -1.5 \cdot 10^{-141}:\\
    \;\;\;\;d1 \cdot \left(d2 + d4\right)\\
    
    \mathbf{elif}\;d3 \leq 4 \cdot 10^{+46}:\\
    \;\;\;\;d1 \cdot \left(d2 - d1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if d3 < -1.0199999999999999e89 or 4e46 < d3

      1. Initial program 80.6%

        \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
      2. Step-by-step derivation
        1. distribute-lft-out--N/A

          \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
        2. *-commutativeN/A

          \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
        3. distribute-lft-outN/A

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

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

          \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
        6. associate-+r-N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
        7. sub-negN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
        8. associate-+l+N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
        9. +-lowering-+.f64N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
        10. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
        11. unsub-negN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
        12. associate--l-N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
        13. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
        14. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
        15. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
        16. +-lowering-+.f64100.0%

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
      3. Simplified100.0%

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

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

          \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d2 - \left(d1 + d3\right)\right)}\right) \]
        2. --lowering--.f64N/A

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
        3. +-lowering-+.f6488.2%

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
      7. Simplified88.2%

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

        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{d3}\right)\right) \]
      9. Step-by-step derivation
        1. Simplified82.5%

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

        if -1.0199999999999999e89 < d3 < -1.49999999999999992e-141

        1. Initial program 91.3%

          \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
        2. Step-by-step derivation
          1. distribute-lft-out--N/A

            \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
          2. *-commutativeN/A

            \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
          3. distribute-lft-outN/A

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

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

            \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
          6. associate-+r-N/A

            \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
          7. sub-negN/A

            \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
          8. associate-+l+N/A

            \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
          9. +-lowering-+.f64N/A

            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
          10. +-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
          11. unsub-negN/A

            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
          12. associate--l-N/A

            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
          13. +-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
          14. --lowering--.f64N/A

            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
          15. +-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
          16. +-lowering-+.f6499.9%

            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
        3. Simplified99.9%

          \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
        4. Add Preprocessing
        5. Taylor expanded in d4 around inf

          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{d4}\right)\right) \]
        6. Step-by-step derivation
          1. Simplified72.1%

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

          if -1.49999999999999992e-141 < d3 < 4e46

          1. Initial program 83.8%

            \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
          2. Step-by-step derivation
            1. distribute-lft-out--N/A

              \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
            2. *-commutativeN/A

              \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
            3. distribute-lft-outN/A

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

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

              \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
            6. associate-+r-N/A

              \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
            7. sub-negN/A

              \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
            8. associate-+l+N/A

              \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
            9. +-lowering-+.f64N/A

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
            10. +-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
            11. unsub-negN/A

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
            12. associate--l-N/A

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
            13. +-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
            14. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
            15. +-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
            16. +-lowering-+.f64100.0%

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
          3. Simplified100.0%

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

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

              \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d2 - \left(d1 + d3\right)\right)}\right) \]
            2. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
            3. +-lowering-+.f6469.8%

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
          7. Simplified69.8%

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

            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{d1}\right)\right) \]
          9. Step-by-step derivation
            1. Simplified67.9%

              \[\leadsto d1 \cdot \left(d2 - \color{blue}{d1}\right) \]
          10. Recombined 3 regimes into one program.
          11. Add Preprocessing

          Alternative 4: 87.8% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d1 \leq -1.55 \cdot 10^{+167}:\\ \;\;\;\;d1 \cdot \left(d2 - d1\right)\\ \mathbf{elif}\;d1 \leq 2.9 \cdot 10^{+44}:\\ \;\;\;\;d1 \cdot \left(d4 + \left(d2 - d3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d1\right)\\ \end{array} \end{array} \]
          (FPCore (d1 d2 d3 d4)
           :precision binary64
           (if (<= d1 -1.55e+167)
             (* d1 (- d2 d1))
             (if (<= d1 2.9e+44) (* d1 (+ d4 (- d2 d3))) (* d1 (- d4 d1)))))
          double code(double d1, double d2, double d3, double d4) {
          	double tmp;
          	if (d1 <= -1.55e+167) {
          		tmp = d1 * (d2 - d1);
          	} else if (d1 <= 2.9e+44) {
          		tmp = d1 * (d4 + (d2 - d3));
          	} else {
          		tmp = d1 * (d4 - d1);
          	}
          	return tmp;
          }
          
          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 <= (-1.55d+167)) then
                  tmp = d1 * (d2 - d1)
              else if (d1 <= 2.9d+44) then
                  tmp = d1 * (d4 + (d2 - d3))
              else
                  tmp = d1 * (d4 - d1)
              end if
              code = tmp
          end function
          
          public static double code(double d1, double d2, double d3, double d4) {
          	double tmp;
          	if (d1 <= -1.55e+167) {
          		tmp = d1 * (d2 - d1);
          	} else if (d1 <= 2.9e+44) {
          		tmp = d1 * (d4 + (d2 - d3));
          	} else {
          		tmp = d1 * (d4 - d1);
          	}
          	return tmp;
          }
          
          def code(d1, d2, d3, d4):
          	tmp = 0
          	if d1 <= -1.55e+167:
          		tmp = d1 * (d2 - d1)
          	elif d1 <= 2.9e+44:
          		tmp = d1 * (d4 + (d2 - d3))
          	else:
          		tmp = d1 * (d4 - d1)
          	return tmp
          
          function code(d1, d2, d3, d4)
          	tmp = 0.0
          	if (d1 <= -1.55e+167)
          		tmp = Float64(d1 * Float64(d2 - d1));
          	elseif (d1 <= 2.9e+44)
          		tmp = Float64(d1 * Float64(d4 + Float64(d2 - d3)));
          	else
          		tmp = Float64(d1 * Float64(d4 - d1));
          	end
          	return tmp
          end
          
          function tmp_2 = code(d1, d2, d3, d4)
          	tmp = 0.0;
          	if (d1 <= -1.55e+167)
          		tmp = d1 * (d2 - d1);
          	elseif (d1 <= 2.9e+44)
          		tmp = d1 * (d4 + (d2 - d3));
          	else
          		tmp = d1 * (d4 - d1);
          	end
          	tmp_2 = tmp;
          end
          
          code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.55e+167], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 2.9e+44], N[(d1 * N[(d4 + N[(d2 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;d1 \leq -1.55 \cdot 10^{+167}:\\
          \;\;\;\;d1 \cdot \left(d2 - d1\right)\\
          
          \mathbf{elif}\;d1 \leq 2.9 \cdot 10^{+44}:\\
          \;\;\;\;d1 \cdot \left(d4 + \left(d2 - d3\right)\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;d1 \cdot \left(d4 - d1\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if d1 < -1.55e167

            1. Initial program 38.2%

              \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
            2. Step-by-step derivation
              1. distribute-lft-out--N/A

                \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
              2. *-commutativeN/A

                \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
              3. distribute-lft-outN/A

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

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

                \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
              6. associate-+r-N/A

                \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
              7. sub-negN/A

                \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
              8. associate-+l+N/A

                \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
              9. +-lowering-+.f64N/A

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
              10. +-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
              11. unsub-negN/A

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
              12. associate--l-N/A

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
              13. +-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
              14. --lowering--.f64N/A

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
              15. +-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
              16. +-lowering-+.f64100.0%

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
            3. Simplified100.0%

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

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

                \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d2 - \left(d1 + d3\right)\right)}\right) \]
              2. --lowering--.f64N/A

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
              3. +-lowering-+.f6494.1%

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
            7. Simplified94.1%

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

              \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{d1}\right)\right) \]
            9. Step-by-step derivation
              1. Simplified91.2%

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

              if -1.55e167 < d1 < 2.9000000000000002e44

              1. Initial program 98.1%

                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
              2. Step-by-step derivation
                1. distribute-lft-out--N/A

                  \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                2. *-commutativeN/A

                  \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                3. distribute-lft-outN/A

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

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

                  \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                6. associate-+r-N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                7. sub-negN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                8. associate-+l+N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                9. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                10. +-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                11. unsub-negN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                12. associate--l-N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                13. +-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                14. --lowering--.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                15. +-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                16. +-lowering-+.f64100.0%

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
              3. Simplified100.0%

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

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

                  \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(d2 + d4\right) - d3\right)}\right) \]
                2. +-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d4 + d2\right) - d3\right)\right) \]
                3. associate--l+N/A

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

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d4, \color{blue}{\left(d2 - d3\right)}\right)\right) \]
                5. --lowering--.f6491.7%

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d4, \mathsf{\_.f64}\left(d2, \color{blue}{d3}\right)\right)\right) \]
              7. Simplified91.7%

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

              if 2.9000000000000002e44 < d1

              1. Initial program 71.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 inf

                \[\leadsto \mathsf{\_.f64}\left(\color{blue}{\left(d1 \cdot d4\right)}, \mathsf{*.f64}\left(d1, d1\right)\right) \]
              4. Step-by-step derivation
                1. *-lowering-*.f6465.3%

                  \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(d1, d4\right), \mathsf{*.f64}\left(\color{blue}{d1}, d1\right)\right) \]
              5. Simplified65.3%

                \[\leadsto \color{blue}{d1 \cdot d4} - d1 \cdot d1 \]
              6. Step-by-step derivation
                1. distribute-lft-out--N/A

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

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

                  \[\leadsto \mathsf{*.f64}\left(\left(d4 - d1\right), \color{blue}{d1}\right) \]
                4. --lowering--.f6474.1%

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(d4, d1\right), d1\right) \]
              7. Applied egg-rr74.1%

                \[\leadsto \color{blue}{\left(d4 - d1\right) \cdot d1} \]
            10. Recombined 3 regimes into one program.
            11. Final simplification87.7%

              \[\leadsto \begin{array}{l} \mathbf{if}\;d1 \leq -1.55 \cdot 10^{+167}:\\ \;\;\;\;d1 \cdot \left(d2 - d1\right)\\ \mathbf{elif}\;d1 \leq 2.9 \cdot 10^{+44}:\\ \;\;\;\;d1 \cdot \left(d4 + \left(d2 - d3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d1\right)\\ \end{array} \]
            12. Add Preprocessing

            Alternative 5: 62.6% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq -1.35 \cdot 10^{-250}:\\ \;\;\;\;d1 \cdot \left(d2 - d3\right)\\ \mathbf{elif}\;d4 \leq 1.6 \cdot 10^{+110}:\\ \;\;\;\;d1 \cdot \left(d2 - d1\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d3\right)\\ \end{array} \end{array} \]
            (FPCore (d1 d2 d3 d4)
             :precision binary64
             (if (<= d4 -1.35e-250)
               (* d1 (- d2 d3))
               (if (<= d4 1.6e+110) (* d1 (- d2 d1)) (* d1 (- d4 d3)))))
            double code(double d1, double d2, double d3, double d4) {
            	double tmp;
            	if (d4 <= -1.35e-250) {
            		tmp = d1 * (d2 - d3);
            	} else if (d4 <= 1.6e+110) {
            		tmp = d1 * (d2 - d1);
            	} else {
            		tmp = d1 * (d4 - d3);
            	}
            	return tmp;
            }
            
            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.35d-250)) then
                    tmp = d1 * (d2 - d3)
                else if (d4 <= 1.6d+110) then
                    tmp = d1 * (d2 - d1)
                else
                    tmp = d1 * (d4 - d3)
                end if
                code = tmp
            end function
            
            public static double code(double d1, double d2, double d3, double d4) {
            	double tmp;
            	if (d4 <= -1.35e-250) {
            		tmp = d1 * (d2 - d3);
            	} else if (d4 <= 1.6e+110) {
            		tmp = d1 * (d2 - d1);
            	} else {
            		tmp = d1 * (d4 - d3);
            	}
            	return tmp;
            }
            
            def code(d1, d2, d3, d4):
            	tmp = 0
            	if d4 <= -1.35e-250:
            		tmp = d1 * (d2 - d3)
            	elif d4 <= 1.6e+110:
            		tmp = d1 * (d2 - d1)
            	else:
            		tmp = d1 * (d4 - d3)
            	return tmp
            
            function code(d1, d2, d3, d4)
            	tmp = 0.0
            	if (d4 <= -1.35e-250)
            		tmp = Float64(d1 * Float64(d2 - d3));
            	elseif (d4 <= 1.6e+110)
            		tmp = Float64(d1 * Float64(d2 - d1));
            	else
            		tmp = Float64(d1 * Float64(d4 - d3));
            	end
            	return tmp
            end
            
            function tmp_2 = code(d1, d2, d3, d4)
            	tmp = 0.0;
            	if (d4 <= -1.35e-250)
            		tmp = d1 * (d2 - d3);
            	elseif (d4 <= 1.6e+110)
            		tmp = d1 * (d2 - d1);
            	else
            		tmp = d1 * (d4 - d3);
            	end
            	tmp_2 = tmp;
            end
            
            code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.35e-250], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.6e+110], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;d4 \leq -1.35 \cdot 10^{-250}:\\
            \;\;\;\;d1 \cdot \left(d2 - d3\right)\\
            
            \mathbf{elif}\;d4 \leq 1.6 \cdot 10^{+110}:\\
            \;\;\;\;d1 \cdot \left(d2 - d1\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;d1 \cdot \left(d4 - d3\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if d4 < -1.35000000000000001e-250

              1. Initial program 81.5%

                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
              2. Step-by-step derivation
                1. distribute-lft-out--N/A

                  \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                2. *-commutativeN/A

                  \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                3. distribute-lft-outN/A

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

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

                  \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                6. associate-+r-N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                7. sub-negN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                8. associate-+l+N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                9. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                10. +-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                11. unsub-negN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                12. associate--l-N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                13. +-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                14. --lowering--.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                15. +-commutativeN/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                16. +-lowering-+.f64100.0%

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
              3. Simplified100.0%

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

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

                  \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d2 - \left(d1 + d3\right)\right)}\right) \]
                2. --lowering--.f64N/A

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
                3. +-lowering-+.f6473.3%

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
              7. Simplified73.3%

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

                \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{d3}\right)\right) \]
              9. Step-by-step derivation
                1. Simplified58.3%

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

                if -1.35000000000000001e-250 < d4 < 1.59999999999999997e110

                1. Initial program 87.2%

                  \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                2. Step-by-step derivation
                  1. distribute-lft-out--N/A

                    \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                  2. *-commutativeN/A

                    \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                  3. distribute-lft-outN/A

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

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

                    \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                  6. associate-+r-N/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                  7. sub-negN/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                  8. associate-+l+N/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                  9. +-lowering-+.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                  10. +-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                  11. unsub-negN/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                  12. associate--l-N/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                  13. +-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                  14. --lowering--.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                  15. +-commutativeN/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                  16. +-lowering-+.f64100.0%

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                3. Simplified100.0%

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

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

                    \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d2 - \left(d1 + d3\right)\right)}\right) \]
                  2. --lowering--.f64N/A

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
                  3. +-lowering-+.f6495.0%

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
                7. Simplified95.0%

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

                  \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{d1}\right)\right) \]
                9. Step-by-step derivation
                  1. Simplified72.9%

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

                  if 1.59999999999999997e110 < d4

                  1. Initial program 86.7%

                    \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                  2. Step-by-step derivation
                    1. distribute-lft-out--N/A

                      \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. *-commutativeN/A

                      \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                    3. distribute-lft-outN/A

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

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

                      \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                    6. associate-+r-N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                    7. sub-negN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                    8. associate-+l+N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                    9. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                    10. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                    11. unsub-negN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                    12. associate--l-N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                    13. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                    14. --lowering--.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                    15. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                    16. +-lowering-+.f64100.0%

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                  3. Simplified100.0%

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

                      \[\leadsto d1 \cdot \left(\left(d4 - \left(d1 + d3\right)\right) + \color{blue}{d2}\right) \]
                    2. distribute-lft-inN/A

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

                      \[\leadsto \mathsf{+.f64}\left(\left(d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\right), \color{blue}{\left(d1 \cdot d2\right)}\right) \]
                    4. *-lowering-*.f64N/A

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

                      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \left(d1 + d3\right)\right)\right), \left(d1 \cdot d2\right)\right) \]
                    6. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, d3\right)\right)\right), \left(d1 \cdot d2\right)\right) \]
                    7. *-lowering-*.f6495.6%

                      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, d3\right)\right)\right), \mathsf{*.f64}\left(d1, \color{blue}{d2}\right)\right) \]
                  6. Applied egg-rr95.6%

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

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

                      \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d4 - \left(d1 + d3\right)\right)}\right) \]
                    2. --lowering--.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
                    3. +-lowering-+.f6491.8%

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
                  9. Simplified91.8%

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

                    \[\leadsto \color{blue}{d1 \cdot \left(d4 - d3\right)} \]
                  11. Step-by-step derivation
                    1. remove-double-negN/A

                      \[\leadsto \mathsf{neg}\left(\left(\mathsf{neg}\left(d1 \cdot \left(d4 - d3\right)\right)\right)\right) \]
                    2. distribute-rgt-neg-outN/A

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

                      \[\leadsto \mathsf{neg}\left(d1 \cdot \left(-1 \cdot \left(d4 - d3\right)\right)\right) \]
                    4. distribute-rgt-neg-inN/A

                      \[\leadsto d1 \cdot \color{blue}{\left(\mathsf{neg}\left(-1 \cdot \left(d4 - d3\right)\right)\right)} \]
                    5. *-rgt-identityN/A

                      \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\left(-1 \cdot \left(d4 - d3\right)\right) \cdot 1\right)\right) \]
                    6. *-inversesN/A

                      \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\left(-1 \cdot \left(d4 - d3\right)\right) \cdot \frac{d1}{d1}\right)\right) \]
                    7. associate-/l*N/A

                      \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\frac{\left(-1 \cdot \left(d4 - d3\right)\right) \cdot d1}{d1}\right)\right) \]
                    8. associate-*l/N/A

                      \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\frac{-1 \cdot \left(d4 - d3\right)}{d1} \cdot d1\right)\right) \]
                    9. associate-*r/N/A

                      \[\leadsto d1 \cdot \left(\mathsf{neg}\left(\left(-1 \cdot \frac{d4 - d3}{d1}\right) \cdot d1\right)\right) \]
                    10. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\mathsf{neg}\left(\left(-1 \cdot \frac{d4 - d3}{d1}\right) \cdot d1\right)\right)}\right) \]
                    11. neg-sub0N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \color{blue}{\left(-1 \cdot \frac{d4 - d3}{d1}\right) \cdot d1}\right)\right) \]
                    12. associate-*r/N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \frac{-1 \cdot \left(d4 - d3\right)}{d1} \cdot d1\right)\right) \]
                    13. associate-*l/N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \frac{\left(-1 \cdot \left(d4 - d3\right)\right) \cdot d1}{\color{blue}{d1}}\right)\right) \]
                    14. associate-/l*N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \left(-1 \cdot \left(d4 - d3\right)\right) \cdot \color{blue}{\frac{d1}{d1}}\right)\right) \]
                    15. *-inversesN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \left(-1 \cdot \left(d4 - d3\right)\right) \cdot 1\right)\right) \]
                    16. mul-1-negN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 - \left(\mathsf{neg}\left(\left(d4 - d3\right)\right)\right) \cdot 1\right)\right) \]
                    17. cancel-sign-subN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 + \color{blue}{\left(d4 - d3\right) \cdot 1}\right)\right) \]
                    18. *-rgt-identityN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 + \left(d4 - \color{blue}{d3}\right)\right)\right) \]
                    19. sub-negN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 + \left(d4 + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                    20. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(0 + \left(\left(\mathsf{neg}\left(d3\right)\right) + \color{blue}{d4}\right)\right)\right) \]
                    21. associate-+l+N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(0 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \color{blue}{d4}\right)\right) \]
                  12. Simplified80.6%

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

                Alternative 6: 67.9% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := 0 - d1 \cdot d3\\ \mathbf{if}\;d3 \leq -3.3 \cdot 10^{+89}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d3 \leq 4.4 \cdot 10^{+178}:\\ \;\;\;\;d1 \cdot \left(d2 + d4\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                (FPCore (d1 d2 d3 d4)
                 :precision binary64
                 (let* ((t_0 (- 0.0 (* d1 d3))))
                   (if (<= d3 -3.3e+89) t_0 (if (<= d3 4.4e+178) (* d1 (+ d2 d4)) t_0))))
                double code(double d1, double d2, double d3, double d4) {
                	double t_0 = 0.0 - (d1 * d3);
                	double tmp;
                	if (d3 <= -3.3e+89) {
                		tmp = t_0;
                	} else if (d3 <= 4.4e+178) {
                		tmp = d1 * (d2 + d4);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                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 = 0.0d0 - (d1 * d3)
                    if (d3 <= (-3.3d+89)) then
                        tmp = t_0
                    else if (d3 <= 4.4d+178) then
                        tmp = d1 * (d2 + d4)
                    else
                        tmp = t_0
                    end if
                    code = tmp
                end function
                
                public static double code(double d1, double d2, double d3, double d4) {
                	double t_0 = 0.0 - (d1 * d3);
                	double tmp;
                	if (d3 <= -3.3e+89) {
                		tmp = t_0;
                	} else if (d3 <= 4.4e+178) {
                		tmp = d1 * (d2 + d4);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(d1, d2, d3, d4):
                	t_0 = 0.0 - (d1 * d3)
                	tmp = 0
                	if d3 <= -3.3e+89:
                		tmp = t_0
                	elif d3 <= 4.4e+178:
                		tmp = d1 * (d2 + d4)
                	else:
                		tmp = t_0
                	return tmp
                
                function code(d1, d2, d3, d4)
                	t_0 = Float64(0.0 - Float64(d1 * d3))
                	tmp = 0.0
                	if (d3 <= -3.3e+89)
                		tmp = t_0;
                	elseif (d3 <= 4.4e+178)
                		tmp = Float64(d1 * Float64(d2 + d4));
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(d1, d2, d3, d4)
                	t_0 = 0.0 - (d1 * d3);
                	tmp = 0.0;
                	if (d3 <= -3.3e+89)
                		tmp = t_0;
                	elseif (d3 <= 4.4e+178)
                		tmp = d1 * (d2 + d4);
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(0.0 - N[(d1 * d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -3.3e+89], t$95$0, If[LessEqual[d3, 4.4e+178], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], t$95$0]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := 0 - d1 \cdot d3\\
                \mathbf{if}\;d3 \leq -3.3 \cdot 10^{+89}:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;d3 \leq 4.4 \cdot 10^{+178}:\\
                \;\;\;\;d1 \cdot \left(d2 + d4\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if d3 < -3.29999999999999974e89 or 4.39999999999999994e178 < d3

                  1. Initial program 77.9%

                    \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                  2. Step-by-step derivation
                    1. distribute-lft-out--N/A

                      \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. *-commutativeN/A

                      \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                    3. distribute-lft-outN/A

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

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

                      \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                    6. associate-+r-N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                    7. sub-negN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                    8. associate-+l+N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                    9. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                    10. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                    11. unsub-negN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                    12. associate--l-N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                    13. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                    14. --lowering--.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                    15. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                    16. +-lowering-+.f64100.0%

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                  3. Simplified100.0%

                    \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
                  4. Add Preprocessing
                  5. Taylor expanded in d3 around inf

                    \[\leadsto \color{blue}{-1 \cdot \left(d1 \cdot d3\right)} \]
                  6. Step-by-step derivation
                    1. mul-1-negN/A

                      \[\leadsto \mathsf{neg}\left(d1 \cdot d3\right) \]
                    2. neg-sub0N/A

                      \[\leadsto 0 - \color{blue}{d1 \cdot d3} \]
                    3. --lowering--.f64N/A

                      \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(d1 \cdot d3\right)}\right) \]
                    4. *-lowering-*.f6483.8%

                      \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(d1, \color{blue}{d3}\right)\right) \]
                  7. Simplified83.8%

                    \[\leadsto \color{blue}{0 - d1 \cdot d3} \]
                  8. Step-by-step derivation
                    1. sub0-negN/A

                      \[\leadsto \mathsf{neg}\left(d1 \cdot d3\right) \]
                    2. neg-lowering-neg.f64N/A

                      \[\leadsto \mathsf{neg.f64}\left(\left(d1 \cdot d3\right)\right) \]
                    3. *-lowering-*.f6483.8%

                      \[\leadsto \mathsf{neg.f64}\left(\mathsf{*.f64}\left(d1, d3\right)\right) \]
                  9. Applied egg-rr83.8%

                    \[\leadsto \color{blue}{-d1 \cdot d3} \]

                  if -3.29999999999999974e89 < d3 < 4.39999999999999994e178

                  1. Initial program 86.7%

                    \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                  2. Step-by-step derivation
                    1. distribute-lft-out--N/A

                      \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. *-commutativeN/A

                      \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                    3. distribute-lft-outN/A

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

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

                      \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                    6. associate-+r-N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                    7. sub-negN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                    8. associate-+l+N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                    9. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                    10. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                    11. unsub-negN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                    12. associate--l-N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                    13. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                    14. --lowering--.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                    15. +-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                    16. +-lowering-+.f64100.0%

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                  3. Simplified100.0%

                    \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
                  4. Add Preprocessing
                  5. Taylor expanded in d4 around inf

                    \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{d4}\right)\right) \]
                  6. Step-by-step derivation
                    1. Simplified66.3%

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;d3 \leq -3.3 \cdot 10^{+89}:\\ \;\;\;\;0 - d1 \cdot d3\\ \mathbf{elif}\;d3 \leq 4.4 \cdot 10^{+178}:\\ \;\;\;\;d1 \cdot \left(d2 + d4\right)\\ \mathbf{else}:\\ \;\;\;\;0 - d1 \cdot d3\\ \end{array} \]
                  9. Add Preprocessing

                  Alternative 7: 40.6% accurate, 1.0× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -8.2 \cdot 10^{+92}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq 1.72 \cdot 10^{-252}:\\ \;\;\;\;0 - d1 \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d4\\ \end{array} \end{array} \]
                  (FPCore (d1 d2 d3 d4)
                   :precision binary64
                   (if (<= d2 -8.2e+92)
                     (* d1 d2)
                     (if (<= d2 1.72e-252) (- 0.0 (* d1 d1)) (* d1 d4))))
                  double code(double d1, double d2, double d3, double d4) {
                  	double tmp;
                  	if (d2 <= -8.2e+92) {
                  		tmp = d1 * d2;
                  	} else if (d2 <= 1.72e-252) {
                  		tmp = 0.0 - (d1 * d1);
                  	} else {
                  		tmp = d1 * d4;
                  	}
                  	return tmp;
                  }
                  
                  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 (d2 <= (-8.2d+92)) then
                          tmp = d1 * d2
                      else if (d2 <= 1.72d-252) then
                          tmp = 0.0d0 - (d1 * d1)
                      else
                          tmp = d1 * d4
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double d1, double d2, double d3, double d4) {
                  	double tmp;
                  	if (d2 <= -8.2e+92) {
                  		tmp = d1 * d2;
                  	} else if (d2 <= 1.72e-252) {
                  		tmp = 0.0 - (d1 * d1);
                  	} else {
                  		tmp = d1 * d4;
                  	}
                  	return tmp;
                  }
                  
                  def code(d1, d2, d3, d4):
                  	tmp = 0
                  	if d2 <= -8.2e+92:
                  		tmp = d1 * d2
                  	elif d2 <= 1.72e-252:
                  		tmp = 0.0 - (d1 * d1)
                  	else:
                  		tmp = d1 * d4
                  	return tmp
                  
                  function code(d1, d2, d3, d4)
                  	tmp = 0.0
                  	if (d2 <= -8.2e+92)
                  		tmp = Float64(d1 * d2);
                  	elseif (d2 <= 1.72e-252)
                  		tmp = Float64(0.0 - Float64(d1 * d1));
                  	else
                  		tmp = Float64(d1 * d4);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(d1, d2, d3, d4)
                  	tmp = 0.0;
                  	if (d2 <= -8.2e+92)
                  		tmp = d1 * d2;
                  	elseif (d2 <= 1.72e-252)
                  		tmp = 0.0 - (d1 * d1);
                  	else
                  		tmp = d1 * d4;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -8.2e+92], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, 1.72e-252], N[(0.0 - N[(d1 * d1), $MachinePrecision]), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;d2 \leq -8.2 \cdot 10^{+92}:\\
                  \;\;\;\;d1 \cdot d2\\
                  
                  \mathbf{elif}\;d2 \leq 1.72 \cdot 10^{-252}:\\
                  \;\;\;\;0 - d1 \cdot d1\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;d1 \cdot d4\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if d2 < -8.20000000000000047e92

                    1. Initial program 81.2%

                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. Step-by-step derivation
                      1. distribute-lft-out--N/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. *-commutativeN/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                      3. distribute-lft-outN/A

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                      6. associate-+r-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                      7. sub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                      8. associate-+l+N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      9. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                      11. unsub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                      12. associate--l-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                      13. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                      14. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                      15. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                      16. +-lowering-+.f64100.0%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                    3. Simplified100.0%

                      \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
                    4. Add Preprocessing
                    5. Taylor expanded in d2 around inf

                      \[\leadsto \color{blue}{d1 \cdot d2} \]
                    6. Step-by-step derivation
                      1. *-lowering-*.f6472.6%

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{d2}\right) \]
                    7. Simplified72.6%

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

                    if -8.20000000000000047e92 < d2 < 1.7200000000000001e-252

                    1. Initial program 85.0%

                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. Step-by-step derivation
                      1. distribute-lft-out--N/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. *-commutativeN/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                      3. distribute-lft-outN/A

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                      6. associate-+r-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                      7. sub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                      8. associate-+l+N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      9. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                      11. unsub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                      12. associate--l-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                      13. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                      14. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                      15. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                      16. +-lowering-+.f64100.0%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                    3. Simplified100.0%

                      \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
                    4. Add Preprocessing
                    5. Taylor expanded in d1 around inf

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

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

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

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

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

                        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(d1, \color{blue}{d1}\right)\right) \]
                    7. Simplified43.2%

                      \[\leadsto \color{blue}{0 - d1 \cdot d1} \]
                    8. Step-by-step derivation
                      1. sub0-negN/A

                        \[\leadsto \mathsf{neg}\left(d1 \cdot d1\right) \]
                      2. neg-lowering-neg.f64N/A

                        \[\leadsto \mathsf{neg.f64}\left(\left(d1 \cdot d1\right)\right) \]
                      3. *-lowering-*.f6443.2%

                        \[\leadsto \mathsf{neg.f64}\left(\mathsf{*.f64}\left(d1, d1\right)\right) \]
                    9. Applied egg-rr43.2%

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

                    if 1.7200000000000001e-252 < d2

                    1. Initial program 85.1%

                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. Step-by-step derivation
                      1. distribute-lft-out--N/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. *-commutativeN/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                      3. distribute-lft-outN/A

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                      6. associate-+r-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                      7. sub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                      8. associate-+l+N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      9. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                      11. unsub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                      12. associate--l-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                      13. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                      14. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                      15. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                      16. +-lowering-+.f64100.0%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                    3. Simplified100.0%

                      \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
                    4. Add Preprocessing
                    5. Taylor expanded in d4 around inf

                      \[\leadsto \color{blue}{d1 \cdot d4} \]
                    6. Step-by-step derivation
                      1. *-lowering-*.f6430.9%

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{d4}\right) \]
                    7. Simplified30.9%

                      \[\leadsto \color{blue}{d1 \cdot d4} \]
                  3. Recombined 3 regimes into one program.
                  4. Final simplification42.9%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;d2 \leq -8.2 \cdot 10^{+92}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq 1.72 \cdot 10^{-252}:\\ \;\;\;\;0 - d1 \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d4\\ \end{array} \]
                  5. Add Preprocessing

                  Alternative 8: 83.6% accurate, 1.2× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -1.35 \cdot 10^{-39}:\\ \;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\ \end{array} \end{array} \]
                  (FPCore (d1 d2 d3 d4)
                   :precision binary64
                   (if (<= d2 -1.35e-39) (* d1 (- d2 (+ d1 d3))) (* d1 (- d4 (+ d1 d3)))))
                  double code(double d1, double d2, double d3, double d4) {
                  	double tmp;
                  	if (d2 <= -1.35e-39) {
                  		tmp = d1 * (d2 - (d1 + d3));
                  	} else {
                  		tmp = d1 * (d4 - (d1 + d3));
                  	}
                  	return tmp;
                  }
                  
                  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 (d2 <= (-1.35d-39)) then
                          tmp = d1 * (d2 - (d1 + d3))
                      else
                          tmp = d1 * (d4 - (d1 + d3))
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double d1, double d2, double d3, double d4) {
                  	double tmp;
                  	if (d2 <= -1.35e-39) {
                  		tmp = d1 * (d2 - (d1 + d3));
                  	} else {
                  		tmp = d1 * (d4 - (d1 + d3));
                  	}
                  	return tmp;
                  }
                  
                  def code(d1, d2, d3, d4):
                  	tmp = 0
                  	if d2 <= -1.35e-39:
                  		tmp = d1 * (d2 - (d1 + d3))
                  	else:
                  		tmp = d1 * (d4 - (d1 + d3))
                  	return tmp
                  
                  function code(d1, d2, d3, d4)
                  	tmp = 0.0
                  	if (d2 <= -1.35e-39)
                  		tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3)));
                  	else
                  		tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3)));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(d1, d2, d3, d4)
                  	tmp = 0.0;
                  	if (d2 <= -1.35e-39)
                  		tmp = d1 * (d2 - (d1 + d3));
                  	else
                  		tmp = d1 * (d4 - (d1 + d3));
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.35e-39], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;d2 \leq -1.35 \cdot 10^{-39}:\\
                  \;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if d2 < -1.35e-39

                    1. Initial program 85.3%

                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. Step-by-step derivation
                      1. distribute-lft-out--N/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. *-commutativeN/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                      3. distribute-lft-outN/A

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                      6. associate-+r-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                      7. sub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                      8. associate-+l+N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      9. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                      11. unsub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                      12. associate--l-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                      13. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                      14. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                      15. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                      16. +-lowering-+.f64100.0%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                    3. Simplified100.0%

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d2 - \left(d1 + d3\right)\right)}\right) \]
                      2. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
                      3. +-lowering-+.f6488.5%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
                    7. Simplified88.5%

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

                    if -1.35e-39 < d2

                    1. Initial program 84.0%

                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. Step-by-step derivation
                      1. distribute-lft-out--N/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. *-commutativeN/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                      3. distribute-lft-outN/A

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                      6. associate-+r-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                      7. sub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                      8. associate-+l+N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      9. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                      11. unsub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                      12. associate--l-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                      13. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                      14. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                      15. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                      16. +-lowering-+.f64100.0%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                    3. Simplified100.0%

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

                        \[\leadsto d1 \cdot \left(\left(d4 - \left(d1 + d3\right)\right) + \color{blue}{d2}\right) \]
                      2. distribute-lft-inN/A

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

                        \[\leadsto \mathsf{+.f64}\left(\left(d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\right), \color{blue}{\left(d1 \cdot d2\right)}\right) \]
                      4. *-lowering-*.f64N/A

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

                        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \left(d1 + d3\right)\right)\right), \left(d1 \cdot d2\right)\right) \]
                      6. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, d3\right)\right)\right), \left(d1 \cdot d2\right)\right) \]
                      7. *-lowering-*.f6495.6%

                        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, d3\right)\right)\right), \mathsf{*.f64}\left(d1, \color{blue}{d2}\right)\right) \]
                    6. Applied egg-rr95.6%

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d4 - \left(d1 + d3\right)\right)}\right) \]
                      2. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
                      3. +-lowering-+.f6486.7%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
                    9. Simplified86.7%

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

                  Alternative 9: 84.7% accurate, 1.2× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq 4 \cdot 10^{+116}:\\ \;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 + \left(d2 - d3\right)\right)\\ \end{array} \end{array} \]
                  (FPCore (d1 d2 d3 d4)
                   :precision binary64
                   (if (<= d4 4e+116) (* d1 (- d2 (+ d1 d3))) (* d1 (+ d4 (- d2 d3)))))
                  double code(double d1, double d2, double d3, double d4) {
                  	double tmp;
                  	if (d4 <= 4e+116) {
                  		tmp = d1 * (d2 - (d1 + d3));
                  	} else {
                  		tmp = d1 * (d4 + (d2 - d3));
                  	}
                  	return tmp;
                  }
                  
                  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 <= 4d+116) then
                          tmp = d1 * (d2 - (d1 + d3))
                      else
                          tmp = d1 * (d4 + (d2 - d3))
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double d1, double d2, double d3, double d4) {
                  	double tmp;
                  	if (d4 <= 4e+116) {
                  		tmp = d1 * (d2 - (d1 + d3));
                  	} else {
                  		tmp = d1 * (d4 + (d2 - d3));
                  	}
                  	return tmp;
                  }
                  
                  def code(d1, d2, d3, d4):
                  	tmp = 0
                  	if d4 <= 4e+116:
                  		tmp = d1 * (d2 - (d1 + d3))
                  	else:
                  		tmp = d1 * (d4 + (d2 - d3))
                  	return tmp
                  
                  function code(d1, d2, d3, d4)
                  	tmp = 0.0
                  	if (d4 <= 4e+116)
                  		tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3)));
                  	else
                  		tmp = Float64(d1 * Float64(d4 + Float64(d2 - d3)));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(d1, d2, d3, d4)
                  	tmp = 0.0;
                  	if (d4 <= 4e+116)
                  		tmp = d1 * (d2 - (d1 + d3));
                  	else
                  		tmp = d1 * (d4 + (d2 - d3));
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4e+116], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 + N[(d2 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;d4 \leq 4 \cdot 10^{+116}:\\
                  \;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;d1 \cdot \left(d4 + \left(d2 - d3\right)\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if d4 < 4.00000000000000006e116

                    1. Initial program 84.0%

                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. Step-by-step derivation
                      1. distribute-lft-out--N/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. *-commutativeN/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                      3. distribute-lft-outN/A

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                      6. associate-+r-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                      7. sub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                      8. associate-+l+N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      9. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                      11. unsub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                      12. associate--l-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                      13. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                      14. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                      15. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                      16. +-lowering-+.f64100.0%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                    3. Simplified100.0%

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d2 - \left(d1 + d3\right)\right)}\right) \]
                      2. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
                      3. +-lowering-+.f6481.9%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
                    7. Simplified81.9%

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

                    if 4.00000000000000006e116 < d4

                    1. Initial program 86.0%

                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. Step-by-step derivation
                      1. distribute-lft-out--N/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. *-commutativeN/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                      3. distribute-lft-outN/A

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                      6. associate-+r-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                      7. sub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                      8. associate-+l+N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      9. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                      11. unsub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                      12. associate--l-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                      13. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                      14. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                      15. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                      16. +-lowering-+.f64100.0%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                    3. Simplified100.0%

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(d2 + d4\right) - d3\right)}\right) \]
                      2. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d4 + d2\right) - d3\right)\right) \]
                      3. associate--l+N/A

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d4, \color{blue}{\left(d2 - d3\right)}\right)\right) \]
                      5. --lowering--.f6490.7%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d4, \mathsf{\_.f64}\left(d2, \color{blue}{d3}\right)\right)\right) \]
                    7. Simplified90.7%

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

                  Alternative 10: 61.9% accurate, 1.5× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq 8.5 \cdot 10^{+116}:\\ \;\;\;\;d1 \cdot \left(d2 - d1\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d2 + d4\right)\\ \end{array} \end{array} \]
                  (FPCore (d1 d2 d3 d4)
                   :precision binary64
                   (if (<= d4 8.5e+116) (* d1 (- d2 d1)) (* d1 (+ d2 d4))))
                  double code(double d1, double d2, double d3, double d4) {
                  	double tmp;
                  	if (d4 <= 8.5e+116) {
                  		tmp = d1 * (d2 - d1);
                  	} else {
                  		tmp = d1 * (d2 + d4);
                  	}
                  	return tmp;
                  }
                  
                  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 <= 8.5d+116) then
                          tmp = d1 * (d2 - d1)
                      else
                          tmp = d1 * (d2 + d4)
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double d1, double d2, double d3, double d4) {
                  	double tmp;
                  	if (d4 <= 8.5e+116) {
                  		tmp = d1 * (d2 - d1);
                  	} else {
                  		tmp = d1 * (d2 + d4);
                  	}
                  	return tmp;
                  }
                  
                  def code(d1, d2, d3, d4):
                  	tmp = 0
                  	if d4 <= 8.5e+116:
                  		tmp = d1 * (d2 - d1)
                  	else:
                  		tmp = d1 * (d2 + d4)
                  	return tmp
                  
                  function code(d1, d2, d3, d4)
                  	tmp = 0.0
                  	if (d4 <= 8.5e+116)
                  		tmp = Float64(d1 * Float64(d2 - d1));
                  	else
                  		tmp = Float64(d1 * Float64(d2 + d4));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(d1, d2, d3, d4)
                  	tmp = 0.0;
                  	if (d4 <= 8.5e+116)
                  		tmp = d1 * (d2 - d1);
                  	else
                  		tmp = d1 * (d2 + d4);
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 8.5e+116], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;d4 \leq 8.5 \cdot 10^{+116}:\\
                  \;\;\;\;d1 \cdot \left(d2 - d1\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;d1 \cdot \left(d2 + d4\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if d4 < 8.5000000000000002e116

                    1. Initial program 84.0%

                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                    2. Step-by-step derivation
                      1. distribute-lft-out--N/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. *-commutativeN/A

                        \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                      3. distribute-lft-outN/A

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                      6. associate-+r-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                      7. sub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                      8. associate-+l+N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      9. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                      10. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                      11. unsub-negN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                      12. associate--l-N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                      13. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                      14. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                      15. +-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                      16. +-lowering-+.f64100.0%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                    3. Simplified100.0%

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

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

                        \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(d2 - \left(d1 + d3\right)\right)}\right) \]
                      2. --lowering--.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{\left(d1 + d3\right)}\right)\right) \]
                      3. +-lowering-+.f6481.9%

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right) \]
                    7. Simplified81.9%

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

                      \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{\_.f64}\left(d2, \color{blue}{d1}\right)\right) \]
                    9. Step-by-step derivation
                      1. Simplified60.2%

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

                      if 8.5000000000000002e116 < d4

                      1. Initial program 86.0%

                        \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. Step-by-step derivation
                        1. distribute-lft-out--N/A

                          \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                        2. *-commutativeN/A

                          \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                        3. distribute-lft-outN/A

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

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

                          \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                        6. associate-+r-N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                        7. sub-negN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                        8. associate-+l+N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                        9. +-lowering-+.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                        10. +-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                        11. unsub-negN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                        12. associate--l-N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                        13. +-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                        14. --lowering--.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                        15. +-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                        16. +-lowering-+.f64100.0%

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                      3. Simplified100.0%

                        \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
                      4. Add Preprocessing
                      5. Taylor expanded in d4 around inf

                        \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{d4}\right)\right) \]
                      6. Step-by-step derivation
                        1. Simplified75.1%

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

                      Alternative 11: 38.7% accurate, 1.9× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq 1.1 \cdot 10^{-13}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d4\\ \end{array} \end{array} \]
                      (FPCore (d1 d2 d3 d4)
                       :precision binary64
                       (if (<= d4 1.1e-13) (* d1 d2) (* d1 d4)))
                      double code(double d1, double d2, double d3, double d4) {
                      	double tmp;
                      	if (d4 <= 1.1e-13) {
                      		tmp = d1 * d2;
                      	} else {
                      		tmp = d1 * d4;
                      	}
                      	return tmp;
                      }
                      
                      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.1d-13) then
                              tmp = d1 * d2
                          else
                              tmp = d1 * d4
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double d1, double d2, double d3, double d4) {
                      	double tmp;
                      	if (d4 <= 1.1e-13) {
                      		tmp = d1 * d2;
                      	} else {
                      		tmp = d1 * d4;
                      	}
                      	return tmp;
                      }
                      
                      def code(d1, d2, d3, d4):
                      	tmp = 0
                      	if d4 <= 1.1e-13:
                      		tmp = d1 * d2
                      	else:
                      		tmp = d1 * d4
                      	return tmp
                      
                      function code(d1, d2, d3, d4)
                      	tmp = 0.0
                      	if (d4 <= 1.1e-13)
                      		tmp = Float64(d1 * d2);
                      	else
                      		tmp = Float64(d1 * d4);
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(d1, d2, d3, d4)
                      	tmp = 0.0;
                      	if (d4 <= 1.1e-13)
                      		tmp = d1 * d2;
                      	else
                      		tmp = d1 * d4;
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.1e-13], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;d4 \leq 1.1 \cdot 10^{-13}:\\
                      \;\;\;\;d1 \cdot d2\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;d1 \cdot d4\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if d4 < 1.09999999999999998e-13

                        1. Initial program 83.8%

                          \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                        2. Step-by-step derivation
                          1. distribute-lft-out--N/A

                            \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                          2. *-commutativeN/A

                            \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                          3. distribute-lft-outN/A

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

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

                            \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                          6. associate-+r-N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                          7. sub-negN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                          8. associate-+l+N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                          9. +-lowering-+.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                          10. +-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                          11. unsub-negN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                          12. associate--l-N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                          13. +-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                          14. --lowering--.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                          15. +-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                          16. +-lowering-+.f64100.0%

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                        3. Simplified100.0%

                          \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
                        4. Add Preprocessing
                        5. Taylor expanded in d2 around inf

                          \[\leadsto \color{blue}{d1 \cdot d2} \]
                        6. Step-by-step derivation
                          1. *-lowering-*.f6433.4%

                            \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{d2}\right) \]
                        7. Simplified33.4%

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

                        if 1.09999999999999998e-13 < d4

                        1. Initial program 85.9%

                          \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                        2. Step-by-step derivation
                          1. distribute-lft-out--N/A

                            \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                          2. *-commutativeN/A

                            \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                          3. distribute-lft-outN/A

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

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

                            \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                          6. associate-+r-N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                          7. sub-negN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                          8. associate-+l+N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                          9. +-lowering-+.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                          10. +-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                          11. unsub-negN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                          12. associate--l-N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                          13. +-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                          14. --lowering--.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                          15. +-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                          16. +-lowering-+.f64100.0%

                            \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                        3. Simplified100.0%

                          \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
                        4. Add Preprocessing
                        5. Taylor expanded in d4 around inf

                          \[\leadsto \color{blue}{d1 \cdot d4} \]
                        6. Step-by-step derivation
                          1. *-lowering-*.f6453.0%

                            \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{d4}\right) \]
                        7. Simplified53.0%

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

                      Alternative 12: 30.9% accurate, 5.0× speedup?

                      \[\begin{array}{l} \\ d1 \cdot d2 \end{array} \]
                      (FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
                      double code(double d1, double d2, double d3, double d4) {
                      	return d1 * d2;
                      }
                      
                      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
                      end function
                      
                      public static double code(double d1, double d2, double d3, double d4) {
                      	return d1 * d2;
                      }
                      
                      def code(d1, d2, d3, d4):
                      	return d1 * d2
                      
                      function code(d1, d2, d3, d4)
                      	return Float64(d1 * d2)
                      end
                      
                      function tmp = code(d1, d2, d3, d4)
                      	tmp = d1 * d2;
                      end
                      
                      code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      d1 \cdot d2
                      \end{array}
                      
                      Derivation
                      1. Initial program 84.3%

                        \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                      2. Step-by-step derivation
                        1. distribute-lft-out--N/A

                          \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                        2. *-commutativeN/A

                          \[\leadsto \left(d1 \cdot \left(d2 - d3\right) + d1 \cdot d4\right) - d1 \cdot d1 \]
                        3. distribute-lft-outN/A

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

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

                          \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{\left(\left(\left(d2 - d3\right) + d4\right) - d1\right)}\right) \]
                        6. associate-+r-N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 - d3\right) + \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                        7. sub-negN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \left(\left(d2 + \left(\mathsf{neg}\left(d3\right)\right)\right) + \left(\color{blue}{d4} - d1\right)\right)\right) \]
                        8. associate-+l+N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \left(d2 + \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                        9. +-lowering-+.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \color{blue}{\left(\left(\mathsf{neg}\left(d3\right)\right) + \left(d4 - d1\right)\right)}\right)\right) \]
                        10. +-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) + \color{blue}{\left(\mathsf{neg}\left(d3\right)\right)}\right)\right)\right) \]
                        11. unsub-negN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(\left(d4 - d1\right) - \color{blue}{d3}\right)\right)\right) \]
                        12. associate--l-N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \color{blue}{\left(d1 + d3\right)}\right)\right)\right) \]
                        13. +-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \left(d4 - \left(d3 + \color{blue}{d1}\right)\right)\right)\right) \]
                        14. --lowering--.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \color{blue}{\left(d3 + d1\right)}\right)\right)\right) \]
                        15. +-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \left(d1 + \color{blue}{d3}\right)\right)\right)\right) \]
                        16. +-lowering-+.f64100.0%

                          \[\leadsto \mathsf{*.f64}\left(d1, \mathsf{+.f64}\left(d2, \mathsf{\_.f64}\left(d4, \mathsf{+.f64}\left(d1, \color{blue}{d3}\right)\right)\right)\right) \]
                      3. Simplified100.0%

                        \[\leadsto \color{blue}{d1 \cdot \left(d2 + \left(d4 - \left(d1 + d3\right)\right)\right)} \]
                      4. Add Preprocessing
                      5. Taylor expanded in d2 around inf

                        \[\leadsto \color{blue}{d1 \cdot d2} \]
                      6. Step-by-step derivation
                        1. *-lowering-*.f6430.3%

                          \[\leadsto \mathsf{*.f64}\left(d1, \color{blue}{d2}\right) \]
                      7. Simplified30.3%

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

                      Developer Target 1: 100.0% accurate, 1.7× 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 2024156 
                      (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)))