FastMath dist4

Percentage Accurate: 88.3% → 98.5%
Time: 11.3s
Alternatives: 13
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 88.3% accurate, 1.0× speedup?

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

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

Alternative 1: 98.5% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 100.0%

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

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

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{\left(d1 \cdot d2 + d1 \cdot d4\right) - {d1}^{2}} \]
    4. Step-by-step derivation
      1. distribute-lft-outN/A

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

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

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

        \[\leadsto d1 \cdot \color{blue}{\left(\left(d2 + d4\right) + \left(\mathsf{neg}\left(d1\right)\right)\right)} \]
      5. mul-1-negN/A

        \[\leadsto d1 \cdot \left(\left(d2 + d4\right) + \color{blue}{-1 \cdot d1}\right) \]
      6. associate-+r+N/A

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

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

        \[\leadsto \color{blue}{\left(d2 + \left(d4 + -1 \cdot d1\right)\right) \cdot d1} \]
      9. associate-+r+N/A

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d1\right) \cdot d1 \]
      14. lower-+.f6496.4

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

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

Alternative 2: 64.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -1.6 \cdot 10^{+19}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{elif}\;d2 \leq -1.05 \cdot 10^{-57} \lor \neg \left(d2 \leq -3.6 \cdot 10^{-171} \lor \neg \left(d2 \leq 2.6 \cdot 10^{-230}\right)\right):\\ \;\;\;\;\left(d4 - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (if (<= d2 -1.6e+19)
   (* (- d2 d3) d1)
   (if (or (<= d2 -1.05e-57)
           (not (or (<= d2 -3.6e-171) (not (<= d2 2.6e-230)))))
     (* (- d4 d1) d1)
     (* (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if (d2 <= -1.6e+19) {
		tmp = (d2 - d3) * d1;
	} else if ((d2 <= -1.05e-57) || !((d2 <= -3.6e-171) || !(d2 <= 2.6e-230))) {
		tmp = (d4 - d1) * d1;
	} else {
		tmp = (d4 - d3) * 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 (d2 <= (-1.6d+19)) then
        tmp = (d2 - d3) * d1
    else if ((d2 <= (-1.05d-57)) .or. (.not. (d2 <= (-3.6d-171)) .or. (.not. (d2 <= 2.6d-230)))) then
        tmp = (d4 - d1) * d1
    else
        tmp = (d4 - d3) * d1
    end if
    code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if (d2 <= -1.6e+19) {
		tmp = (d2 - d3) * d1;
	} else if ((d2 <= -1.05e-57) || !((d2 <= -3.6e-171) || !(d2 <= 2.6e-230))) {
		tmp = (d4 - d1) * d1;
	} else {
		tmp = (d4 - d3) * d1;
	}
	return tmp;
}
def code(d1, d2, d3, d4):
	tmp = 0
	if d2 <= -1.6e+19:
		tmp = (d2 - d3) * d1
	elif (d2 <= -1.05e-57) or not ((d2 <= -3.6e-171) or not (d2 <= 2.6e-230)):
		tmp = (d4 - d1) * d1
	else:
		tmp = (d4 - d3) * d1
	return tmp
function code(d1, d2, d3, d4)
	tmp = 0.0
	if (d2 <= -1.6e+19)
		tmp = Float64(Float64(d2 - d3) * d1);
	elseif ((d2 <= -1.05e-57) || !((d2 <= -3.6e-171) || !(d2 <= 2.6e-230)))
		tmp = Float64(Float64(d4 - d1) * d1);
	else
		tmp = Float64(Float64(d4 - d3) * d1);
	end
	return tmp
end
function tmp_2 = code(d1, d2, d3, d4)
	tmp = 0.0;
	if (d2 <= -1.6e+19)
		tmp = (d2 - d3) * d1;
	elseif ((d2 <= -1.05e-57) || ~(((d2 <= -3.6e-171) || ~((d2 <= 2.6e-230)))))
		tmp = (d4 - d1) * d1;
	else
		tmp = (d4 - d3) * d1;
	end
	tmp_2 = tmp;
end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.6e+19], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[Or[LessEqual[d2, -1.05e-57], N[Not[Or[LessEqual[d2, -3.6e-171], N[Not[LessEqual[d2, 2.6e-230]], $MachinePrecision]]], $MachinePrecision]], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.6 \cdot 10^{+19}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\

\mathbf{elif}\;d2 \leq -1.05 \cdot 10^{-57} \lor \neg \left(d2 \leq -3.6 \cdot 10^{-171} \lor \neg \left(d2 \leq 2.6 \cdot 10^{-230}\right)\right):\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\

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


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

    1. Initial program 85.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -1.6e19 < d2 < -1.05e-57 or -3.60000000000000003e-171 < d2 < 2.6000000000000001e-230

      1. Initial program 91.2%

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

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + d1 \cdot d4\right) - {d1}^{2}} \]
      4. Step-by-step derivation
        1. distribute-lft-outN/A

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

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

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

          \[\leadsto d1 \cdot \color{blue}{\left(\left(d2 + d4\right) + \left(\mathsf{neg}\left(d1\right)\right)\right)} \]
        5. mul-1-negN/A

          \[\leadsto d1 \cdot \left(\left(d2 + d4\right) + \color{blue}{-1 \cdot d1}\right) \]
        6. associate-+r+N/A

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

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

          \[\leadsto \color{blue}{\left(d2 + \left(d4 + -1 \cdot d1\right)\right) \cdot d1} \]
        9. associate-+r+N/A

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

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

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

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

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

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

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

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

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

        if -1.05e-57 < d2 < -3.60000000000000003e-171 or 2.6000000000000001e-230 < d2

        1. Initial program 89.4%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;d2 \leq -1.6 \cdot 10^{+19}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{elif}\;d2 \leq -1.05 \cdot 10^{-57} \lor \neg \left(d2 \leq -3.6 \cdot 10^{-171} \lor \neg \left(d2 \leq 2.6 \cdot 10^{-230}\right)\right):\\ \;\;\;\;\left(d4 - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \end{array} \]
        10. Add Preprocessing

        Alternative 3: 64.8% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -5.5 \cdot 10^{+73}:\\ \;\;\;\;\left(d4 + d2\right) \cdot d1\\ \mathbf{elif}\;d2 \leq -1.05 \cdot 10^{-57} \lor \neg \left(d2 \leq -3.6 \cdot 10^{-171} \lor \neg \left(d2 \leq 2.6 \cdot 10^{-230}\right)\right):\\ \;\;\;\;\left(d4 - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \end{array} \end{array} \]
        (FPCore (d1 d2 d3 d4)
         :precision binary64
         (if (<= d2 -5.5e+73)
           (* (+ d4 d2) d1)
           (if (or (<= d2 -1.05e-57)
                   (not (or (<= d2 -3.6e-171) (not (<= d2 2.6e-230)))))
             (* (- d4 d1) d1)
             (* (- d4 d3) d1))))
        double code(double d1, double d2, double d3, double d4) {
        	double tmp;
        	if (d2 <= -5.5e+73) {
        		tmp = (d4 + d2) * d1;
        	} else if ((d2 <= -1.05e-57) || !((d2 <= -3.6e-171) || !(d2 <= 2.6e-230))) {
        		tmp = (d4 - d1) * d1;
        	} else {
        		tmp = (d4 - d3) * 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 (d2 <= (-5.5d+73)) then
                tmp = (d4 + d2) * d1
            else if ((d2 <= (-1.05d-57)) .or. (.not. (d2 <= (-3.6d-171)) .or. (.not. (d2 <= 2.6d-230)))) then
                tmp = (d4 - d1) * d1
            else
                tmp = (d4 - d3) * d1
            end if
            code = tmp
        end function
        
        public static double code(double d1, double d2, double d3, double d4) {
        	double tmp;
        	if (d2 <= -5.5e+73) {
        		tmp = (d4 + d2) * d1;
        	} else if ((d2 <= -1.05e-57) || !((d2 <= -3.6e-171) || !(d2 <= 2.6e-230))) {
        		tmp = (d4 - d1) * d1;
        	} else {
        		tmp = (d4 - d3) * d1;
        	}
        	return tmp;
        }
        
        def code(d1, d2, d3, d4):
        	tmp = 0
        	if d2 <= -5.5e+73:
        		tmp = (d4 + d2) * d1
        	elif (d2 <= -1.05e-57) or not ((d2 <= -3.6e-171) or not (d2 <= 2.6e-230)):
        		tmp = (d4 - d1) * d1
        	else:
        		tmp = (d4 - d3) * d1
        	return tmp
        
        function code(d1, d2, d3, d4)
        	tmp = 0.0
        	if (d2 <= -5.5e+73)
        		tmp = Float64(Float64(d4 + d2) * d1);
        	elseif ((d2 <= -1.05e-57) || !((d2 <= -3.6e-171) || !(d2 <= 2.6e-230)))
        		tmp = Float64(Float64(d4 - d1) * d1);
        	else
        		tmp = Float64(Float64(d4 - d3) * d1);
        	end
        	return tmp
        end
        
        function tmp_2 = code(d1, d2, d3, d4)
        	tmp = 0.0;
        	if (d2 <= -5.5e+73)
        		tmp = (d4 + d2) * d1;
        	elseif ((d2 <= -1.05e-57) || ~(((d2 <= -3.6e-171) || ~((d2 <= 2.6e-230)))))
        		tmp = (d4 - d1) * d1;
        	else
        		tmp = (d4 - d3) * d1;
        	end
        	tmp_2 = tmp;
        end
        
        code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.5e+73], N[(N[(d4 + d2), $MachinePrecision] * d1), $MachinePrecision], If[Or[LessEqual[d2, -1.05e-57], N[Not[Or[LessEqual[d2, -3.6e-171], N[Not[LessEqual[d2, 2.6e-230]], $MachinePrecision]]], $MachinePrecision]], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;d2 \leq -5.5 \cdot 10^{+73}:\\
        \;\;\;\;\left(d4 + d2\right) \cdot d1\\
        
        \mathbf{elif}\;d2 \leq -1.05 \cdot 10^{-57} \lor \neg \left(d2 \leq -3.6 \cdot 10^{-171} \lor \neg \left(d2 \leq 2.6 \cdot 10^{-230}\right)\right):\\
        \;\;\;\;\left(d4 - d1\right) \cdot d1\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(d4 - d3\right) \cdot d1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if d2 < -5.5000000000000003e73

          1. Initial program 88.9%

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

            \[\leadsto \color{blue}{\left(d1 \cdot d2 + d1 \cdot d4\right) - {d1}^{2}} \]
          4. Step-by-step derivation
            1. distribute-lft-outN/A

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

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

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

              \[\leadsto d1 \cdot \color{blue}{\left(\left(d2 + d4\right) + \left(\mathsf{neg}\left(d1\right)\right)\right)} \]
            5. mul-1-negN/A

              \[\leadsto d1 \cdot \left(\left(d2 + d4\right) + \color{blue}{-1 \cdot d1}\right) \]
            6. associate-+r+N/A

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

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

              \[\leadsto \color{blue}{\left(d2 + \left(d4 + -1 \cdot d1\right)\right) \cdot d1} \]
            9. associate-+r+N/A

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

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

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

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

              \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d1\right) \cdot d1 \]
            14. lower-+.f6486.3

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

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

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

              \[\leadsto \left(d4 + d2\right) \cdot d1 \]

            if -5.5000000000000003e73 < d2 < -1.05e-57 or -3.60000000000000003e-171 < d2 < 2.6000000000000001e-230

            1. Initial program 88.4%

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

              \[\leadsto \color{blue}{\left(d1 \cdot d2 + d1 \cdot d4\right) - {d1}^{2}} \]
            4. Step-by-step derivation
              1. distribute-lft-outN/A

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

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

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

                \[\leadsto d1 \cdot \color{blue}{\left(\left(d2 + d4\right) + \left(\mathsf{neg}\left(d1\right)\right)\right)} \]
              5. mul-1-negN/A

                \[\leadsto d1 \cdot \left(\left(d2 + d4\right) + \color{blue}{-1 \cdot d1}\right) \]
              6. associate-+r+N/A

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

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

                \[\leadsto \color{blue}{\left(d2 + \left(d4 + -1 \cdot d1\right)\right) \cdot d1} \]
              9. associate-+r+N/A

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

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

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

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

                \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d1\right) \cdot d1 \]
              14. lower-+.f6481.9

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

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

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

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

              if -1.05e-57 < d2 < -3.60000000000000003e-171 or 2.6000000000000001e-230 < d2

              1. Initial program 89.4%

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(d4 - d3\right) \cdot d1 \]
              8. Recombined 3 regimes into one program.
              9. Final simplification72.4%

                \[\leadsto \begin{array}{l} \mathbf{if}\;d2 \leq -5.5 \cdot 10^{+73}:\\ \;\;\;\;\left(d4 + d2\right) \cdot d1\\ \mathbf{elif}\;d2 \leq -1.05 \cdot 10^{-57} \lor \neg \left(d2 \leq -3.6 \cdot 10^{-171} \lor \neg \left(d2 \leq 2.6 \cdot 10^{-230}\right)\right):\\ \;\;\;\;\left(d4 - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \end{array} \]
              10. Add Preprocessing

              Alternative 4: 40.8% accurate, 0.9× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-d1\right) \cdot d1\\ \mathbf{if}\;d2 \leq -5.5 \cdot 10^{+73}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{elif}\;d2 \leq -1.7 \cdot 10^{-53}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d2 \leq -3.6 \cdot 10^{-171}:\\ \;\;\;\;\left(-d3\right) \cdot d1\\ \mathbf{elif}\;d2 \leq 3.5 \cdot 10^{-242}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
              (FPCore (d1 d2 d3 d4)
               :precision binary64
               (let* ((t_0 (* (- d1) d1)))
                 (if (<= d2 -5.5e+73)
                   (* d2 d1)
                   (if (<= d2 -1.7e-53)
                     t_0
                     (if (<= d2 -3.6e-171)
                       (* (- d3) d1)
                       (if (<= d2 3.5e-242) t_0 (* d4 d1)))))))
              double code(double d1, double d2, double d3, double d4) {
              	double t_0 = -d1 * d1;
              	double tmp;
              	if (d2 <= -5.5e+73) {
              		tmp = d2 * d1;
              	} else if (d2 <= -1.7e-53) {
              		tmp = t_0;
              	} else if (d2 <= -3.6e-171) {
              		tmp = -d3 * d1;
              	} else if (d2 <= 3.5e-242) {
              		tmp = t_0;
              	} else {
              		tmp = 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) :: t_0
                  real(8) :: tmp
                  t_0 = -d1 * d1
                  if (d2 <= (-5.5d+73)) then
                      tmp = d2 * d1
                  else if (d2 <= (-1.7d-53)) then
                      tmp = t_0
                  else if (d2 <= (-3.6d-171)) then
                      tmp = -d3 * d1
                  else if (d2 <= 3.5d-242) then
                      tmp = t_0
                  else
                      tmp = d4 * d1
                  end if
                  code = tmp
              end function
              
              public static double code(double d1, double d2, double d3, double d4) {
              	double t_0 = -d1 * d1;
              	double tmp;
              	if (d2 <= -5.5e+73) {
              		tmp = d2 * d1;
              	} else if (d2 <= -1.7e-53) {
              		tmp = t_0;
              	} else if (d2 <= -3.6e-171) {
              		tmp = -d3 * d1;
              	} else if (d2 <= 3.5e-242) {
              		tmp = t_0;
              	} else {
              		tmp = d4 * d1;
              	}
              	return tmp;
              }
              
              def code(d1, d2, d3, d4):
              	t_0 = -d1 * d1
              	tmp = 0
              	if d2 <= -5.5e+73:
              		tmp = d2 * d1
              	elif d2 <= -1.7e-53:
              		tmp = t_0
              	elif d2 <= -3.6e-171:
              		tmp = -d3 * d1
              	elif d2 <= 3.5e-242:
              		tmp = t_0
              	else:
              		tmp = d4 * d1
              	return tmp
              
              function code(d1, d2, d3, d4)
              	t_0 = Float64(Float64(-d1) * d1)
              	tmp = 0.0
              	if (d2 <= -5.5e+73)
              		tmp = Float64(d2 * d1);
              	elseif (d2 <= -1.7e-53)
              		tmp = t_0;
              	elseif (d2 <= -3.6e-171)
              		tmp = Float64(Float64(-d3) * d1);
              	elseif (d2 <= 3.5e-242)
              		tmp = t_0;
              	else
              		tmp = Float64(d4 * d1);
              	end
              	return tmp
              end
              
              function tmp_2 = code(d1, d2, d3, d4)
              	t_0 = -d1 * d1;
              	tmp = 0.0;
              	if (d2 <= -5.5e+73)
              		tmp = d2 * d1;
              	elseif (d2 <= -1.7e-53)
              		tmp = t_0;
              	elseif (d2 <= -3.6e-171)
              		tmp = -d3 * d1;
              	elseif (d2 <= 3.5e-242)
              		tmp = t_0;
              	else
              		tmp = d4 * d1;
              	end
              	tmp_2 = tmp;
              end
              
              code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[((-d1) * d1), $MachinePrecision]}, If[LessEqual[d2, -5.5e+73], N[(d2 * d1), $MachinePrecision], If[LessEqual[d2, -1.7e-53], t$95$0, If[LessEqual[d2, -3.6e-171], N[((-d3) * d1), $MachinePrecision], If[LessEqual[d2, 3.5e-242], t$95$0, N[(d4 * d1), $MachinePrecision]]]]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \left(-d1\right) \cdot d1\\
              \mathbf{if}\;d2 \leq -5.5 \cdot 10^{+73}:\\
              \;\;\;\;d2 \cdot d1\\
              
              \mathbf{elif}\;d2 \leq -1.7 \cdot 10^{-53}:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;d2 \leq -3.6 \cdot 10^{-171}:\\
              \;\;\;\;\left(-d3\right) \cdot d1\\
              
              \mathbf{elif}\;d2 \leq 3.5 \cdot 10^{-242}:\\
              \;\;\;\;t\_0\\
              
              \mathbf{else}:\\
              \;\;\;\;d4 \cdot d1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 4 regimes
              2. if d2 < -5.5000000000000003e73

                1. Initial program 88.9%

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

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

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

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

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

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

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

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

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

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

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

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

                if -5.5000000000000003e73 < d2 < -1.7e-53 or -3.60000000000000003e-171 < d2 < 3.4999999999999999e-242

                1. Initial program 88.1%

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

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

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

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

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

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

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

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

                if -1.7e-53 < d2 < -3.60000000000000003e-171

                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if 3.4999999999999999e-242 < d2

                1. Initial program 86.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 \color{blue}{d1 \cdot d4} \]
                4. Step-by-step derivation
                  1. *-commutativeN/A

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

                    \[\leadsto \color{blue}{d4 \cdot d1} \]
                5. Applied rewrites31.4%

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

              Alternative 5: 92.2% accurate, 1.2× speedup?

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

                1. Initial program 72.0%

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

                  \[\leadsto \color{blue}{\left(d1 \cdot d2 + d1 \cdot d4\right) - {d1}^{2}} \]
                4. Step-by-step derivation
                  1. distribute-lft-outN/A

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

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

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

                    \[\leadsto d1 \cdot \color{blue}{\left(\left(d2 + d4\right) + \left(\mathsf{neg}\left(d1\right)\right)\right)} \]
                  5. mul-1-negN/A

                    \[\leadsto d1 \cdot \left(\left(d2 + d4\right) + \color{blue}{-1 \cdot d1}\right) \]
                  6. associate-+r+N/A

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

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

                    \[\leadsto \color{blue}{\left(d2 + \left(d4 + -1 \cdot d1\right)\right) \cdot d1} \]
                  9. associate-+r+N/A

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

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

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

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

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

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

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

                if -2.9000000000000002e53 < d1 < 9.0000000000000001e33

                1. Initial program 100.0%

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

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

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

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

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

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

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

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;d1 \leq -2.9 \cdot 10^{+53} \lor \neg \left(d1 \leq 9 \cdot 10^{+33}\right):\\ \;\;\;\;\left(\left(d4 + d2\right) - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\ \end{array} \]
              5. Add Preprocessing

              Alternative 6: 88.6% accurate, 1.2× speedup?

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

                1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

                  if -5.60000000000000004e71 < d3 < 4.80000000000000016e139

                  1. Initial program 90.6%

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

                    \[\leadsto \color{blue}{\left(d1 \cdot d2 + d1 \cdot d4\right) - {d1}^{2}} \]
                  4. Step-by-step derivation
                    1. distribute-lft-outN/A

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

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

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

                      \[\leadsto d1 \cdot \color{blue}{\left(\left(d2 + d4\right) + \left(\mathsf{neg}\left(d1\right)\right)\right)} \]
                    5. mul-1-negN/A

                      \[\leadsto d1 \cdot \left(\left(d2 + d4\right) + \color{blue}{-1 \cdot d1}\right) \]
                    6. associate-+r+N/A

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

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

                      \[\leadsto \color{blue}{\left(d2 + \left(d4 + -1 \cdot d1\right)\right) \cdot d1} \]
                    9. associate-+r+N/A

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

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

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

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

                      \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d1\right) \cdot d1 \]
                    14. lower-+.f6497.2

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

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

                  if 4.80000000000000016e139 < d3

                  1. Initial program 83.3%

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

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

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

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

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

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

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

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

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

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

                  Alternative 7: 64.3% accurate, 1.3× speedup?

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

                    1. Initial program 88.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

                      if -5.5000000000000003e73 < d2 < 3.4999999999999999e-242

                      1. Initial program 91.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

                        if 3.4999999999999999e-242 < d2

                        1. Initial program 86.9%

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

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

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

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

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

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

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

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

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

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

                        Alternative 8: 67.6% accurate, 1.4× speedup?

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

                          1. Initial program 85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          if -3.80000000000000006e72 < d3 < 4.2e161

                          1. Initial program 90.8%

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

                            \[\leadsto \color{blue}{\left(d1 \cdot d2 + d1 \cdot d4\right) - {d1}^{2}} \]
                          4. Step-by-step derivation
                            1. distribute-lft-outN/A

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

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

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

                              \[\leadsto d1 \cdot \color{blue}{\left(\left(d2 + d4\right) + \left(\mathsf{neg}\left(d1\right)\right)\right)} \]
                            5. mul-1-negN/A

                              \[\leadsto d1 \cdot \left(\left(d2 + d4\right) + \color{blue}{-1 \cdot d1}\right) \]
                            6. associate-+r+N/A

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

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

                              \[\leadsto \color{blue}{\left(d2 + \left(d4 + -1 \cdot d1\right)\right) \cdot d1} \]
                            9. associate-+r+N/A

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

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

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

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

                              \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d1\right) \cdot d1 \]
                            14. lower-+.f6496.6

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

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

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

                              \[\leadsto \left(d4 + d2\right) \cdot d1 \]
                          8. Recombined 2 regimes into one program.
                          9. Final simplification72.6%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;d3 \leq -3.8 \cdot 10^{+72} \lor \neg \left(d3 \leq 4.2 \cdot 10^{+161}\right):\\ \;\;\;\;\left(-d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 + d2\right) \cdot d1\\ \end{array} \]
                          10. Add Preprocessing

                          Alternative 9: 41.1% accurate, 1.5× speedup?

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

                            1. Initial program 88.9%

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

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

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

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

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

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

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

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

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

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

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

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

                            if -5.5000000000000003e73 < d2 < 3.4999999999999999e-242

                            1. Initial program 91.7%

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

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

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

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

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

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

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

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

                            if 3.4999999999999999e-242 < d2

                            1. Initial program 86.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 \color{blue}{d1 \cdot d4} \]
                            4. Step-by-step derivation
                              1. *-commutativeN/A

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

                                \[\leadsto \color{blue}{d4 \cdot d1} \]
                            5. Applied rewrites31.4%

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

                          Alternative 10: 85.0% accurate, 1.7× speedup?

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

                            1. Initial program 89.6%

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

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

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

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

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

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

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

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

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

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

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

                            if 1.4e27 < d4

                            1. Initial program 87.3%

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

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

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

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

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

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

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

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

                          Alternative 11: 63.2% accurate, 2.0× speedup?

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

                            1. Initial program 88.9%

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

                              \[\leadsto \color{blue}{\left(d1 \cdot d2 + d1 \cdot d4\right) - {d1}^{2}} \]
                            4. Step-by-step derivation
                              1. distribute-lft-outN/A

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

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

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

                                \[\leadsto d1 \cdot \color{blue}{\left(\left(d2 + d4\right) + \left(\mathsf{neg}\left(d1\right)\right)\right)} \]
                              5. mul-1-negN/A

                                \[\leadsto d1 \cdot \left(\left(d2 + d4\right) + \color{blue}{-1 \cdot d1}\right) \]
                              6. associate-+r+N/A

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

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

                                \[\leadsto \color{blue}{\left(d2 + \left(d4 + -1 \cdot d1\right)\right) \cdot d1} \]
                              9. associate-+r+N/A

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

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

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

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

                                \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d1\right) \cdot d1 \]
                              14. lower-+.f6486.3

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

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

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

                                \[\leadsto \left(d4 + d2\right) \cdot d1 \]

                              if -5.5000000000000003e73 < d2

                              1. Initial program 89.1%

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

                                \[\leadsto \color{blue}{\left(d1 \cdot d2 + d1 \cdot d4\right) - {d1}^{2}} \]
                              4. Step-by-step derivation
                                1. distribute-lft-outN/A

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

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

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

                                  \[\leadsto d1 \cdot \color{blue}{\left(\left(d2 + d4\right) + \left(\mathsf{neg}\left(d1\right)\right)\right)} \]
                                5. mul-1-negN/A

                                  \[\leadsto d1 \cdot \left(\left(d2 + d4\right) + \color{blue}{-1 \cdot d1}\right) \]
                                6. associate-+r+N/A

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

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

                                  \[\leadsto \color{blue}{\left(d2 + \left(d4 + -1 \cdot d1\right)\right) \cdot d1} \]
                                9. associate-+r+N/A

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

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

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

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

                                  \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d1\right) \cdot d1 \]
                                14. lower-+.f6476.2

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

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

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

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

                              Alternative 12: 39.8% accurate, 2.5× speedup?

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

                                1. Initial program 85.9%

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

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

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

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

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

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

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

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

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

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

                                    \[\leadsto \color{blue}{d2 \cdot d1} \]
                                8. Applied rewrites55.6%

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

                                if -1.6e19 < d2

                                1. Initial program 89.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 \color{blue}{d1 \cdot d4} \]
                                4. Step-by-step derivation
                                  1. *-commutativeN/A

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

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

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

                              Alternative 13: 31.0% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              Reproduce

                              ?
                              herbie shell --seed 2024308 
                              (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)))