FastMath dist4

Percentage Accurate: 88.1% → 99.9%
Time: 14.3s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 88.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: 99.9% 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 10^{+302}:\\ \;\;\;\;\mathsf{fma}\left(d2 - d3, d1, d1 \cdot \left(d4 - d1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(d1, \frac{\left(d4 - d1\right) - d3}{d2}, d1\right) \cdot d2\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (if (<= (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)) 1e+302)
   (fma (- d2 d3) d1 (* d1 (- d4 d1)))
   (* (fma d1 (/ (- (- d4 d1) d3) d2) d1) d2)))
double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= 1e+302) {
		tmp = fma((d2 - d3), d1, (d1 * (d4 - d1)));
	} else {
		tmp = fma(d1, (((d4 - d1) - d3) / d2), d1) * d2;
	}
	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)) <= 1e+302)
		tmp = fma(Float64(d2 - d3), d1, Float64(d1 * Float64(d4 - d1)));
	else
		tmp = Float64(fma(d1, Float64(Float64(Float64(d4 - d1) - d3) / d2), d1) * d2);
	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], 1e+302], N[(N[(d2 - d3), $MachinePrecision] * d1 + N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d1 * N[(N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision] / d2), $MachinePrecision] + d1), $MachinePrecision] * d2), $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 10^{+302}:\\
\;\;\;\;\mathsf{fma}\left(d2 - d3, d1, d1 \cdot \left(d4 - d1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(d1, \frac{\left(d4 - d1\right) - d3}{d2}, d1\right) \cdot d2\\


\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)) < 1.0000000000000001e302

    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(\color{blue}{d1 \cdot d2} - d1 \cdot d3\right) + \left(d4 \cdot d1 - d1 \cdot d1\right) \]
      6. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

    if 1.0000000000000001e302 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1))

    1. Initial program 33.3%

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

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

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

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

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

Alternative 2: 98.6% accurate, 0.6× 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 - d3, d1, d1 \cdot \left(d4 - d1\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 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 - 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(Float64(d2 - 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[(N[(d2 - d3), $MachinePrecision] * d1 + N[(d1 * N[(d4 - d1), $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 - d3, d1, d1 \cdot \left(d4 - d1\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(\color{blue}{d1 \cdot d2} - d1 \cdot d3\right) + \left(d4 \cdot d1 - d1 \cdot d1\right) \]
      6. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(d2 - d3, d1, d1 \cdot \left(d4 - d1\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--.f6492.3

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

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

Alternative 3: 98.6% accurate, 0.6× 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(d1, d4 - d1, \left(d2 - d3\right) \cdot d1\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 d1 (- d4 d1) (* (- d2 d3) 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(d1, (d4 - d1), ((d2 - d3) * 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(d1, Float64(d4 - d1), Float64(Float64(d2 - d3) * 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[(d1 * N[(d4 - d1), $MachinePrecision] + N[(N[(d2 - d3), $MachinePrecision] * d1), $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(d1, d4 - d1, \left(d2 - d3\right) \cdot d1\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(d1, d4 - d1, \left(d2 - d3\right) \cdot d1\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--.f6492.3

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

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

Alternative 4: 88.5% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d1 \leq -1.36 \cdot 10^{+115} \lor \neg \left(d1 \leq 2 \cdot 10^{+208}\right):\\ \;\;\;\;\left(\left(-d1\right) - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (if (or (<= d1 -1.36e+115) (not (<= d1 2e+208)))
   (* (- (- d1) d3) d1)
   (* (- (+ d4 d2) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if ((d1 <= -1.36e+115) || !(d1 <= 2e+208)) {
		tmp = (-d1 - d3) * d1;
	} else {
		tmp = ((d4 + d2) - d3) * d1;
	}
	return tmp;
}
real(8) function code(d1, d2, d3, d4)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8), intent (in) :: d4
    real(8) :: tmp
    if ((d1 <= (-1.36d+115)) .or. (.not. (d1 <= 2d+208))) then
        tmp = (-d1 - d3) * d1
    else
        tmp = ((d4 + d2) - d3) * d1
    end if
    code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if ((d1 <= -1.36e+115) || !(d1 <= 2e+208)) {
		tmp = (-d1 - d3) * d1;
	} else {
		tmp = ((d4 + d2) - d3) * d1;
	}
	return tmp;
}
def code(d1, d2, d3, d4):
	tmp = 0
	if (d1 <= -1.36e+115) or not (d1 <= 2e+208):
		tmp = (-d1 - d3) * d1
	else:
		tmp = ((d4 + d2) - d3) * d1
	return tmp
function code(d1, d2, d3, d4)
	tmp = 0.0
	if ((d1 <= -1.36e+115) || !(d1 <= 2e+208))
		tmp = Float64(Float64(Float64(-d1) - d3) * d1);
	else
		tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1);
	end
	return tmp
end
function tmp_2 = code(d1, d2, d3, d4)
	tmp = 0.0;
	if ((d1 <= -1.36e+115) || ~((d1 <= 2e+208)))
		tmp = (-d1 - d3) * d1;
	else
		tmp = ((d4 + d2) - d3) * d1;
	end
	tmp_2 = tmp;
end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -1.36e+115], N[Not[LessEqual[d1, 2e+208]], $MachinePrecision]], N[(N[((-d1) - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.36 \cdot 10^{+115} \lor \neg \left(d1 \leq 2 \cdot 10^{+208}\right):\\
\;\;\;\;\left(\left(-d1\right) - d3\right) \cdot d1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d1 < -1.36e115 or 2e208 < d1

    1. Initial program 58.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -1.36e115 < d1 < 2e208

      1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

    Alternative 5: 67.8% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d3 \leq -1.15 \cdot 10^{+71} \lor \neg \left(d3 \leq 2.8 \cdot 10^{+172}\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.15e+71) (not (<= d3 2.8e+172)))
       (* (- d3) d1)
       (* (+ d2 d4) d1)))
    double code(double d1, double d2, double d3, double d4) {
    	double tmp;
    	if ((d3 <= -1.15e+71) || !(d3 <= 2.8e+172)) {
    		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.15d+71)) .or. (.not. (d3 <= 2.8d+172))) 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.15e+71) || !(d3 <= 2.8e+172)) {
    		tmp = -d3 * d1;
    	} else {
    		tmp = (d2 + d4) * d1;
    	}
    	return tmp;
    }
    
    def code(d1, d2, d3, d4):
    	tmp = 0
    	if (d3 <= -1.15e+71) or not (d3 <= 2.8e+172):
    		tmp = -d3 * d1
    	else:
    		tmp = (d2 + d4) * d1
    	return tmp
    
    function code(d1, d2, d3, d4)
    	tmp = 0.0
    	if ((d3 <= -1.15e+71) || !(d3 <= 2.8e+172))
    		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.15e+71) || ~((d3 <= 2.8e+172)))
    		tmp = -d3 * d1;
    	else
    		tmp = (d2 + d4) * d1;
    	end
    	tmp_2 = tmp;
    end
    
    code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.15e+71], N[Not[LessEqual[d3, 2.8e+172]], $MachinePrecision]], N[((-d3) * d1), $MachinePrecision], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;d3 \leq -1.15 \cdot 10^{+71} \lor \neg \left(d3 \leq 2.8 \cdot 10^{+172}\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.1500000000000001e71 or 2.8e172 < d3

      1. Initial program 84.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--.f6492.9

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

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

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

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

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

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

          if -1.1500000000000001e71 < d3 < 2.8e172

          1. Initial program 93.1%

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

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

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

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

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

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

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

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

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

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

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

          Alternative 6: 39.2% accurate, 1.5× speedup?

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

            1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(d1, d4 - d1, \left(d2 - d3\right) \cdot d1\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-*.f6469.8

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

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

            if -5.99999999999999971e100 < d2 < -3.6999999999999999e-295

            1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if -3.6999999999999999e-295 < d2

                1. Initial program 92.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-*.f6434.3

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

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

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

              Alternative 7: 84.4% accurate, 1.7× speedup?

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

                1. Initial program 77.2%

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

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

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

                if -5.80000000000000051e89 < d2

                1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 8: 85.7% accurate, 1.7× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq 0.0026:\\ \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\ \end{array} \end{array} \]
              (FPCore (d1 d2 d3 d4)
               :precision binary64
               (if (<= d4 0.0026) (* (- (- d2 d3) d1) d1) (* (- (+ d4 d2) d3) d1)))
              double code(double d1, double d2, double d3, double d4) {
              	double tmp;
              	if (d4 <= 0.0026) {
              		tmp = ((d2 - d3) - d1) * d1;
              	} else {
              		tmp = ((d4 + d2) - d3) * d1;
              	}
              	return tmp;
              }
              
              real(8) function code(d1, d2, d3, d4)
                  real(8), intent (in) :: d1
                  real(8), intent (in) :: d2
                  real(8), intent (in) :: d3
                  real(8), intent (in) :: d4
                  real(8) :: tmp
                  if (d4 <= 0.0026d0) then
                      tmp = ((d2 - d3) - d1) * d1
                  else
                      tmp = ((d4 + d2) - d3) * d1
                  end if
                  code = tmp
              end function
              
              public static double code(double d1, double d2, double d3, double d4) {
              	double tmp;
              	if (d4 <= 0.0026) {
              		tmp = ((d2 - d3) - d1) * d1;
              	} else {
              		tmp = ((d4 + d2) - d3) * d1;
              	}
              	return tmp;
              }
              
              def code(d1, d2, d3, d4):
              	tmp = 0
              	if d4 <= 0.0026:
              		tmp = ((d2 - d3) - d1) * d1
              	else:
              		tmp = ((d4 + d2) - d3) * d1
              	return tmp
              
              function code(d1, d2, d3, d4)
              	tmp = 0.0
              	if (d4 <= 0.0026)
              		tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1);
              	else
              		tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1);
              	end
              	return tmp
              end
              
              function tmp_2 = code(d1, d2, d3, d4)
              	tmp = 0.0;
              	if (d4 <= 0.0026)
              		tmp = ((d2 - d3) - d1) * d1;
              	else
              		tmp = ((d4 + d2) - d3) * d1;
              	end
              	tmp_2 = tmp;
              end
              
              code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 0.0026], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;d4 \leq 0.0026:\\
              \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if d4 < 0.0025999999999999999

                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 0

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

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

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

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

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

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

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

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

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

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

                if 0.0025999999999999999 < d4

                1. Initial program 87.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-+.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} \]
              3. Recombined 2 regimes into one program.
              4. Add Preprocessing

              Alternative 9: 64.7% accurate, 2.0× speedup?

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

                1. Initial program 77.2%

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

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

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

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

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

                  if -3.99999999999999998e89 < d2

                  1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 10: 65.1% accurate, 2.0× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq 1.06 \cdot 10^{+47}:\\ \;\;\;\;\left(d2 - 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 1.06e+47) (* (- d2 d3) d1) (* (+ d2 d4) d1)))
                  double code(double d1, double d2, double d3, double d4) {
                  	double tmp;
                  	if (d4 <= 1.06e+47) {
                  		tmp = (d2 - 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 <= 1.06d+47) then
                          tmp = (d2 - 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 <= 1.06e+47) {
                  		tmp = (d2 - d3) * d1;
                  	} else {
                  		tmp = (d2 + d4) * d1;
                  	}
                  	return tmp;
                  }
                  
                  def code(d1, d2, d3, d4):
                  	tmp = 0
                  	if d4 <= 1.06e+47:
                  		tmp = (d2 - d3) * d1
                  	else:
                  		tmp = (d2 + d4) * d1
                  	return tmp
                  
                  function code(d1, d2, d3, d4)
                  	tmp = 0.0
                  	if (d4 <= 1.06e+47)
                  		tmp = Float64(Float64(d2 - 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 <= 1.06e+47)
                  		tmp = (d2 - d3) * d1;
                  	else
                  		tmp = (d2 + d4) * d1;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.06e+47], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;d4 \leq 1.06 \cdot 10^{+47}:\\
                  \;\;\;\;\left(d2 - 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 d4 < 1.05999999999999996e47

                    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

                      if 1.05999999999999996e47 < d4

                      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-+.f6496.4

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

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

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

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

                      Alternative 11: 39.7% accurate, 2.5× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -3.1 \cdot 10^{+67}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
                      (FPCore (d1 d2 d3 d4)
                       :precision binary64
                       (if (<= d2 -3.1e+67) (* d2 d1) (* d4 d1)))
                      double code(double d1, double d2, double d3, double d4) {
                      	double tmp;
                      	if (d2 <= -3.1e+67) {
                      		tmp = d2 * d1;
                      	} else {
                      		tmp = d4 * d1;
                      	}
                      	return tmp;
                      }
                      
                      real(8) function code(d1, d2, d3, d4)
                          real(8), intent (in) :: d1
                          real(8), intent (in) :: d2
                          real(8), intent (in) :: d3
                          real(8), intent (in) :: d4
                          real(8) :: tmp
                          if (d2 <= (-3.1d+67)) then
                              tmp = d2 * d1
                          else
                              tmp = d4 * d1
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double d1, double d2, double d3, double d4) {
                      	double tmp;
                      	if (d2 <= -3.1e+67) {
                      		tmp = d2 * d1;
                      	} else {
                      		tmp = d4 * d1;
                      	}
                      	return tmp;
                      }
                      
                      def code(d1, d2, d3, d4):
                      	tmp = 0
                      	if d2 <= -3.1e+67:
                      		tmp = d2 * d1
                      	else:
                      		tmp = d4 * d1
                      	return tmp
                      
                      function code(d1, d2, d3, d4)
                      	tmp = 0.0
                      	if (d2 <= -3.1e+67)
                      		tmp = Float64(d2 * d1);
                      	else
                      		tmp = Float64(d4 * d1);
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(d1, d2, d3, d4)
                      	tmp = 0.0;
                      	if (d2 <= -3.1e+67)
                      		tmp = d2 * d1;
                      	else
                      		tmp = d4 * d1;
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.1e+67], N[(d2 * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;d2 \leq -3.1 \cdot 10^{+67}:\\
                      \;\;\;\;d2 \cdot d1\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;d4 \cdot d1\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if d2 < -3.09999999999999996e67

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \color{blue}{\mathsf{fma}\left(d1, d4 - d1, \left(d2 - d3\right) \cdot d1\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-*.f6463.8

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

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

                        if -3.09999999999999996e67 < d2

                        1. Initial program 93.2%

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

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

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

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

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

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

                      Alternative 12: 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 89.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\mathsf{fma}\left(d1, d4 - d1, \left(d2 - d3\right) \cdot d1\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-*.f6429.9

                          \[\leadsto \color{blue}{d2 \cdot d1} \]
                      7. Applied rewrites29.9%

                        \[\leadsto \color{blue}{d2 \cdot d1} \]
                      8. Final simplification29.9%

                        \[\leadsto d2 \cdot d1 \]
                      9. Add Preprocessing

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

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

                      Reproduce

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