FastMath dist4

Percentage Accurate: 87.1% → 98.3%
Time: 7.0s
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: 87.1% 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.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, d1 \cdot \left(d4 - d1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (if (<= (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)) INFINITY)
   (fma d2 d1 (fma (- d3) d1 (* d1 (- d4 d1))))
   (* (- (- d2 d3) d1) d1)))
double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= ((double) INFINITY)) {
		tmp = fma(d2, d1, fma(-d3, d1, (d1 * (d4 - d1))));
	} else {
		tmp = ((d2 - d3) - d1) * d1;
	}
	return tmp;
}
function code(d1, d2, d3, d4)
	tmp = 0.0
	if (Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) <= Inf)
		tmp = fma(d2, d1, fma(Float64(-d3), d1, Float64(d1 * Float64(d4 - d1))));
	else
		tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1);
	end
	return tmp
end
code[d1_, d2_, d3_, d4_] := If[LessEqual[N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision], Infinity], N[(d2 * d1 + N[((-d3) * d1 + N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, d1 \cdot \left(d4 - d1\right)\right)\right)\\

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


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

    1. Initial program 100.0%

      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

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

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

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

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

        \[\leadsto \left(d1 \cdot d2 - \color{blue}{d1 \cdot d3}\right) + \left(d4 \cdot d1 - d1 \cdot d1\right) \]
      6. fp-cancel-sub-sign-invN/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(d2, d1, \color{blue}{d3 \cdot \left(\mathsf{neg}\left(d1\right)\right)} + \left(d4 \cdot d1 - d1 \cdot d1\right)\right) \]
      12. distribute-rgt-neg-inN/A

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

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

        \[\leadsto \mathsf{fma}\left(d2, d1, \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d3\right), d1, d4 \cdot d1 - d1 \cdot d1\right)}\right) \]
      15. lower-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(\color{blue}{-d3}, d1, d4 \cdot d1 - d1 \cdot d1\right)\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, \color{blue}{d4 \cdot d1} - d1 \cdot d1\right)\right) \]
      17. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, d4 \cdot d1 - \color{blue}{d1 \cdot d1}\right)\right) \]
      18. distribute-rgt-out--N/A

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

        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, \color{blue}{d1 \cdot \left(d4 - d1\right)}\right)\right) \]
      20. lower--.f64100.0

        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, d1 \cdot \color{blue}{\left(d4 - d1\right)}\right)\right) \]
    4. Applied rewrites100.0%

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

    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 d4 around 0

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 63.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq 9.2 \cdot 10^{-40}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{elif}\;d4 \leq 8 \cdot 10^{+29}:\\ \;\;\;\;\left(d2 - d1\right) \cdot d1\\ \mathbf{elif}\;d4 \leq 4.2 \cdot 10^{+139}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d2 + d4\right) \cdot d1\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (if (<= d4 9.2e-40)
   (* (- d2 d3) d1)
   (if (<= d4 8e+29)
     (* (- d2 d1) d1)
     (if (<= d4 4.2e+139) (* (- d4 d3) d1) (* (+ d2 d4) d1)))))
double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if (d4 <= 9.2e-40) {
		tmp = (d2 - d3) * d1;
	} else if (d4 <= 8e+29) {
		tmp = (d2 - d1) * d1;
	} else if (d4 <= 4.2e+139) {
		tmp = (d4 - d3) * d1;
	} else {
		tmp = (d2 + 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 (d4 <= 9.2d-40) then
        tmp = (d2 - d3) * d1
    else if (d4 <= 8d+29) then
        tmp = (d2 - d1) * d1
    else if (d4 <= 4.2d+139) then
        tmp = (d4 - d3) * d1
    else
        tmp = (d2 + d4) * d1
    end if
    code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if (d4 <= 9.2e-40) {
		tmp = (d2 - d3) * d1;
	} else if (d4 <= 8e+29) {
		tmp = (d2 - d1) * d1;
	} else if (d4 <= 4.2e+139) {
		tmp = (d4 - d3) * d1;
	} else {
		tmp = (d2 + d4) * d1;
	}
	return tmp;
}
def code(d1, d2, d3, d4):
	tmp = 0
	if d4 <= 9.2e-40:
		tmp = (d2 - d3) * d1
	elif d4 <= 8e+29:
		tmp = (d2 - d1) * d1
	elif d4 <= 4.2e+139:
		tmp = (d4 - d3) * d1
	else:
		tmp = (d2 + d4) * d1
	return tmp
function code(d1, d2, d3, d4)
	tmp = 0.0
	if (d4 <= 9.2e-40)
		tmp = Float64(Float64(d2 - d3) * d1);
	elseif (d4 <= 8e+29)
		tmp = Float64(Float64(d2 - d1) * d1);
	elseif (d4 <= 4.2e+139)
		tmp = Float64(Float64(d4 - d3) * d1);
	else
		tmp = Float64(Float64(d2 + d4) * d1);
	end
	return tmp
end
function tmp_2 = code(d1, d2, d3, d4)
	tmp = 0.0;
	if (d4 <= 9.2e-40)
		tmp = (d2 - d3) * d1;
	elseif (d4 <= 8e+29)
		tmp = (d2 - d1) * d1;
	elseif (d4 <= 4.2e+139)
		tmp = (d4 - d3) * d1;
	else
		tmp = (d2 + d4) * d1;
	end
	tmp_2 = tmp;
end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 9.2e-40], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d4, 8e+29], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d4, 4.2e+139], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 9.2 \cdot 10^{-40}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\

\mathbf{elif}\;d4 \leq 8 \cdot 10^{+29}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\

\mathbf{elif}\;d4 \leq 4.2 \cdot 10^{+139}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d4 < 9.2e-40

    1. Initial program 88.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-+.f6484.9

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

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

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

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

      if 9.2e-40 < d4 < 7.99999999999999931e29

      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 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. *-commutativeN/A

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

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

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

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

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

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

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

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

        if 7.99999999999999931e29 < d4 < 4.1999999999999997e139

        1. Initial program 76.7%

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

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

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

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

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

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

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

          \[\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 rewrites58.3%

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

          if 4.1999999999999997e139 < d4

          1. Initial program 78.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. *-commutativeN/A

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

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

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

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

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

            \[\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 rewrites89.3%

              \[\leadsto \left(d2 + d4\right) \cdot d1 \]
          8. Recombined 4 regimes into one program.
          9. Final simplification68.0%

            \[\leadsto \begin{array}{l} \mathbf{if}\;d4 \leq 9.2 \cdot 10^{-40}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{elif}\;d4 \leq 8 \cdot 10^{+29}:\\ \;\;\;\;\left(d2 - d1\right) \cdot d1\\ \mathbf{elif}\;d4 \leq 4.2 \cdot 10^{+139}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d2 + d4\right) \cdot d1\\ \end{array} \]
          10. Add Preprocessing

          Alternative 3: 93.5% accurate, 1.2× speedup?

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

            1. Initial program 82.8%

              \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
            2. Add Preprocessing
            3. Taylor expanded in 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-+.f6496.8

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

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

            if -3.59999999999999978e65 < d3 < 6e103

            1. Initial program 88.3%

              \[\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. *-commutativeN/A

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

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

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

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

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

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

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

          Alternative 4: 89.0% accurate, 1.2× speedup?

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

            1. Initial program 84.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-+.f6498.6

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

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

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

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

              if -1.01999999999999996e129 < d3 < 4.80000000000000002e120

              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 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. *-commutativeN/A

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

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

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

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

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

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

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

            Alternative 5: 83.5% accurate, 1.2× speedup?

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

              1. Initial program 88.8%

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

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

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

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

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

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

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

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

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

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

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

              if 2.80000000000000018e46 < d4 < 4.1999999999999997e139

              1. Initial program 73.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-*.f6436.5

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

                \[\leadsto \color{blue}{d4 \cdot d1} \]
              6. Taylor expanded in d2 around 0

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

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

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

                  \[\leadsto d1 \cdot d4 - \color{blue}{d1 \cdot \left(d1 + d3\right)} \]
                4. fp-cancel-sub-sign-invN/A

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

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

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

                  \[\leadsto d1 \cdot d4 + \color{blue}{d1 \cdot \left(-1 \cdot \left(d1 + d3\right)\right)} \]
                8. distribute-lft-outN/A

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

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

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

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

                  \[\leadsto \color{blue}{\left(\left(d4 + -1 \cdot d1\right) + -1 \cdot d3\right)} \cdot d1 \]
                13. fp-cancel-sign-sub-invN/A

                  \[\leadsto \color{blue}{\left(\left(d4 + -1 \cdot d1\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right)} \cdot d1 \]
                14. fp-cancel-sign-sub-invN/A

                  \[\leadsto \left(\color{blue}{\left(d4 - \left(\mathsf{neg}\left(-1\right)\right) \cdot d1\right)} - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right) \cdot d1 \]
                15. metadata-evalN/A

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

                  \[\leadsto \left(\left(d4 - \color{blue}{d1}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right) \cdot d1 \]
                17. metadata-evalN/A

                  \[\leadsto \left(\left(d4 - d1\right) - \color{blue}{1} \cdot d3\right) \cdot d1 \]
                18. *-lft-identityN/A

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

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

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

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

              if 4.1999999999999997e139 < d4

              1. Initial program 78.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. *-commutativeN/A

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

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

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

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

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

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;d4 \leq 2.8 \cdot 10^{+46}:\\ \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\ \mathbf{elif}\;d4 \leq 4.2 \cdot 10^{+139}:\\ \;\;\;\;\left(\left(d4 - d1\right) - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 + d2\right) - d1\right) \cdot d1\\ \end{array} \]
            5. Add Preprocessing

            Alternative 6: 62.3% accurate, 1.3× speedup?

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

              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-+.f6491.1

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

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

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

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

                if 1.38000000000000006e-245 < d4 < 3.29999999999999991e80

                1. Initial program 90.4%

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

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

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

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

                  \[\leadsto \color{blue}{d4 \cdot d1} \]
                6. Taylor expanded in d2 around 0

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

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

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

                    \[\leadsto d1 \cdot d4 - \color{blue}{d1 \cdot \left(d1 + d3\right)} \]
                  4. fp-cancel-sub-sign-invN/A

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

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

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

                    \[\leadsto d1 \cdot d4 + \color{blue}{d1 \cdot \left(-1 \cdot \left(d1 + d3\right)\right)} \]
                  8. distribute-lft-outN/A

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

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

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

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

                    \[\leadsto \color{blue}{\left(\left(d4 + -1 \cdot d1\right) + -1 \cdot d3\right)} \cdot d1 \]
                  13. fp-cancel-sign-sub-invN/A

                    \[\leadsto \color{blue}{\left(\left(d4 + -1 \cdot d1\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right)} \cdot d1 \]
                  14. fp-cancel-sign-sub-invN/A

                    \[\leadsto \left(\color{blue}{\left(d4 - \left(\mathsf{neg}\left(-1\right)\right) \cdot d1\right)} - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right) \cdot d1 \]
                  15. metadata-evalN/A

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

                    \[\leadsto \left(\left(d4 - \color{blue}{d1}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right) \cdot d1 \]
                  17. metadata-evalN/A

                    \[\leadsto \left(\left(d4 - d1\right) - \color{blue}{1} \cdot d3\right) \cdot d1 \]
                  18. *-lft-identityN/A

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

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

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

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

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

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

                  if 3.29999999999999991e80 < d4

                  1. Initial program 75.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. *-commutativeN/A

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

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

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

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

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

                    \[\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 rewrites78.1%

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

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

                  Alternative 7: 66.8% accurate, 1.4× speedup?

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

                    1. Initial program 81.8%

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

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

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

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

                      \[\leadsto \color{blue}{d4 \cdot d1} \]
                    6. Taylor expanded in d2 around 0

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

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

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

                        \[\leadsto d1 \cdot d4 - \color{blue}{d1 \cdot \left(d1 + d3\right)} \]
                      4. fp-cancel-sub-sign-invN/A

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

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

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

                        \[\leadsto d1 \cdot d4 + \color{blue}{d1 \cdot \left(-1 \cdot \left(d1 + d3\right)\right)} \]
                      8. distribute-lft-outN/A

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

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

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

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

                        \[\leadsto \color{blue}{\left(\left(d4 + -1 \cdot d1\right) + -1 \cdot d3\right)} \cdot d1 \]
                      13. fp-cancel-sign-sub-invN/A

                        \[\leadsto \color{blue}{\left(\left(d4 + -1 \cdot d1\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right)} \cdot d1 \]
                      14. fp-cancel-sign-sub-invN/A

                        \[\leadsto \left(\color{blue}{\left(d4 - \left(\mathsf{neg}\left(-1\right)\right) \cdot d1\right)} - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right) \cdot d1 \]
                      15. metadata-evalN/A

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

                        \[\leadsto \left(\left(d4 - \color{blue}{d1}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right) \cdot d1 \]
                      17. metadata-evalN/A

                        \[\leadsto \left(\left(d4 - d1\right) - \color{blue}{1} \cdot d3\right) \cdot d1 \]
                      18. *-lft-identityN/A

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

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

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

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

                      \[\leadsto \left(-1 \cdot \left(d1 + d3\right)\right) \cdot d1 \]
                    10. Step-by-step derivation
                      1. Applied rewrites83.3%

                        \[\leadsto \left(\left(-d1\right) - d3\right) \cdot d1 \]
                      2. Taylor expanded in d1 around 0

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

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

                        if -1.5999999999999999e238 < d3 < 3.7999999999999998e124

                        1. Initial program 87.5%

                          \[\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. *-commutativeN/A

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

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

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

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

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

                          \[\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.1%

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

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

                        Alternative 8: 39.5% accurate, 1.5× speedup?

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

                          1. Initial program 87.0%

                            \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                          2. Add Preprocessing
                          3. Step-by-step derivation
                            1. lift--.f64N/A

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

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

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

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

                              \[\leadsto \left(d1 \cdot d2 - \color{blue}{d1 \cdot d3}\right) + \left(d4 \cdot d1 - d1 \cdot d1\right) \]
                            6. fp-cancel-sub-sign-invN/A

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

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(d2, d1, \color{blue}{d3 \cdot \left(\mathsf{neg}\left(d1\right)\right)} + \left(d4 \cdot d1 - d1 \cdot d1\right)\right) \]
                            12. distribute-rgt-neg-inN/A

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

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

                              \[\leadsto \mathsf{fma}\left(d2, d1, \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d3\right), d1, d4 \cdot d1 - d1 \cdot d1\right)}\right) \]
                            15. lower-neg.f64N/A

                              \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(\color{blue}{-d3}, d1, d4 \cdot d1 - d1 \cdot d1\right)\right) \]
                            16. lift-*.f64N/A

                              \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, \color{blue}{d4 \cdot d1} - d1 \cdot d1\right)\right) \]
                            17. lift-*.f64N/A

                              \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, d4 \cdot d1 - \color{blue}{d1 \cdot d1}\right)\right) \]
                            18. distribute-rgt-out--N/A

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

                              \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, \color{blue}{d1 \cdot \left(d4 - d1\right)}\right)\right) \]
                            20. lower--.f6496.6

                              \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, d1 \cdot \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                          4. Applied rewrites96.6%

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

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

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

                              \[\leadsto \color{blue}{d2 \cdot d1} \]
                          7. Applied rewrites41.5%

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

                          if 1.2999999999999999e-216 < d4 < 1.04999999999999995e71

                          1. Initial program 91.3%

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

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

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

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

                            \[\leadsto \color{blue}{d4 \cdot d1} \]
                          6. Taylor expanded in d2 around 0

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

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

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

                              \[\leadsto d1 \cdot d4 - \color{blue}{d1 \cdot \left(d1 + d3\right)} \]
                            4. fp-cancel-sub-sign-invN/A

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

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

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

                              \[\leadsto d1 \cdot d4 + \color{blue}{d1 \cdot \left(-1 \cdot \left(d1 + d3\right)\right)} \]
                            8. distribute-lft-outN/A

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

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

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

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

                              \[\leadsto \color{blue}{\left(\left(d4 + -1 \cdot d1\right) + -1 \cdot d3\right)} \cdot d1 \]
                            13. fp-cancel-sign-sub-invN/A

                              \[\leadsto \color{blue}{\left(\left(d4 + -1 \cdot d1\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right)} \cdot d1 \]
                            14. fp-cancel-sign-sub-invN/A

                              \[\leadsto \left(\color{blue}{\left(d4 - \left(\mathsf{neg}\left(-1\right)\right) \cdot d1\right)} - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right) \cdot d1 \]
                            15. metadata-evalN/A

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

                              \[\leadsto \left(\left(d4 - \color{blue}{d1}\right) - \left(\mathsf{neg}\left(-1\right)\right) \cdot d3\right) \cdot d1 \]
                            17. metadata-evalN/A

                              \[\leadsto \left(\left(d4 - d1\right) - \color{blue}{1} \cdot d3\right) \cdot d1 \]
                            18. *-lft-identityN/A

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

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

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

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

                            \[\leadsto \left(-1 \cdot \left(d1 + d3\right)\right) \cdot d1 \]
                          10. Step-by-step derivation
                            1. Applied rewrites72.2%

                              \[\leadsto \left(\left(-d1\right) - d3\right) \cdot d1 \]
                            2. Taylor expanded in d1 around 0

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

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

                              if 1.04999999999999995e71 < d4

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

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

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

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

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

                              \[\leadsto \begin{array}{l} \mathbf{if}\;d4 \leq 1.3 \cdot 10^{-216}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{elif}\;d4 \leq 1.05 \cdot 10^{+71}:\\ \;\;\;\;\left(-d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \]
                            6. Add Preprocessing

                            Alternative 9: 83.8% accurate, 1.7× speedup?

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

                              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 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--.f6484.0

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

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

                              if 3.29999999999999991e80 < d4

                              1. Initial program 75.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. *-commutativeN/A

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

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

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

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

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

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

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

                            Alternative 10: 63.0% accurate, 2.0× speedup?

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

                              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 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.1

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

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

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

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

                                if 8.6000000000000002e70 < d4

                                1. Initial program 75.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. *-commutativeN/A

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

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

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

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

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

                                  \[\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 rewrites78.1%

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

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

                                Alternative 11: 62.8% accurate, 2.0× speedup?

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

                                  1. Initial program 88.7%

                                    \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

                                    if 1.01999999999999995e37 < d4

                                    1. Initial program 76.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. *-commutativeN/A

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

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

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

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

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

                                      \[\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 rewrites74.6%

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

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

                                    Alternative 12: 39.0% accurate, 2.5× speedup?

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

                                      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. Step-by-step derivation
                                        1. lift--.f64N/A

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

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

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

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

                                          \[\leadsto \left(d1 \cdot d2 - \color{blue}{d1 \cdot d3}\right) + \left(d4 \cdot d1 - d1 \cdot d1\right) \]
                                        6. fp-cancel-sub-sign-invN/A

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

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

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

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

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

                                          \[\leadsto \mathsf{fma}\left(d2, d1, \color{blue}{d3 \cdot \left(\mathsf{neg}\left(d1\right)\right)} + \left(d4 \cdot d1 - d1 \cdot d1\right)\right) \]
                                        12. distribute-rgt-neg-inN/A

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

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

                                          \[\leadsto \mathsf{fma}\left(d2, d1, \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d3\right), d1, d4 \cdot d1 - d1 \cdot d1\right)}\right) \]
                                        15. lower-neg.f64N/A

                                          \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(\color{blue}{-d3}, d1, d4 \cdot d1 - d1 \cdot d1\right)\right) \]
                                        16. lift-*.f64N/A

                                          \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, \color{blue}{d4 \cdot d1} - d1 \cdot d1\right)\right) \]
                                        17. lift-*.f64N/A

                                          \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, d4 \cdot d1 - \color{blue}{d1 \cdot d1}\right)\right) \]
                                        18. distribute-rgt-out--N/A

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

                                          \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, \color{blue}{d1 \cdot \left(d4 - d1\right)}\right)\right) \]
                                        20. lower--.f6497.4

                                          \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, d1 \cdot \color{blue}{\left(d4 - d1\right)}\right)\right) \]
                                      4. Applied rewrites97.4%

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

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

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

                                          \[\leadsto \color{blue}{d2 \cdot d1} \]
                                      7. Applied rewrites39.8%

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

                                      if 7.99999999999999984e-12 < d4

                                      1. Initial program 80.3%

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

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

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

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

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

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;d4 \leq 8 \cdot 10^{-12}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \]
                                    5. Add Preprocessing

                                    Alternative 13: 31.2% 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 86.3%

                                      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                                    2. Add Preprocessing
                                    3. Step-by-step derivation
                                      1. lift--.f64N/A

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

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

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

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

                                        \[\leadsto \left(d1 \cdot d2 - \color{blue}{d1 \cdot d3}\right) + \left(d4 \cdot d1 - d1 \cdot d1\right) \]
                                      6. fp-cancel-sub-sign-invN/A

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

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

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

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

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

                                        \[\leadsto \mathsf{fma}\left(d2, d1, \color{blue}{d3 \cdot \left(\mathsf{neg}\left(d1\right)\right)} + \left(d4 \cdot d1 - d1 \cdot d1\right)\right) \]
                                      12. distribute-rgt-neg-inN/A

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

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

                                        \[\leadsto \mathsf{fma}\left(d2, d1, \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d3\right), d1, d4 \cdot d1 - d1 \cdot d1\right)}\right) \]
                                      15. lower-neg.f64N/A

                                        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(\color{blue}{-d3}, d1, d4 \cdot d1 - d1 \cdot d1\right)\right) \]
                                      16. lift-*.f64N/A

                                        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, \color{blue}{d4 \cdot d1} - d1 \cdot d1\right)\right) \]
                                      17. lift-*.f64N/A

                                        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, d4 \cdot d1 - \color{blue}{d1 \cdot d1}\right)\right) \]
                                      18. distribute-rgt-out--N/A

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

                                        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d3, d1, \color{blue}{d1 \cdot \left(d4 - d1\right)}\right)\right) \]
                                      20. lower--.f6496.5

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

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

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

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

                                        \[\leadsto \color{blue}{d2 \cdot d1} \]
                                    7. Applied rewrites37.4%

                                      \[\leadsto \color{blue}{d2 \cdot d1} \]
                                    8. 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 2024343 
                                    (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)))