FastMath dist4

Percentage Accurate: 87.4% → 98.4%
Time: 4.9s
Alternatives: 13
Speedup: 1.3×

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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
    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.4% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
    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.4% 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(d4 - 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))
   (* (- (- d4 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 = ((d4 - 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(d4 - 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[(d4 - 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(d4 - d3\right) - d1\right) \cdot d1\\


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

    1. Initial program 100.0%

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

        \[\leadsto \left(d4 \cdot d1 - \color{blue}{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 d2 around 0

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

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

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

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

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

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

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

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

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

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

    \[\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(d1, d4 - d1, \left(d2 - d3\right) \cdot d1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 39.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq -1.45 \cdot 10^{-110}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d4 \leq 1.65 \cdot 10^{-298}:\\ \;\;\;\;\left(-d1\right) \cdot d1\\ \mathbf{elif}\;d4 \leq 10^{+56}:\\ \;\;\;\;\left(-d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (if (<= d4 -1.45e-110)
   (* d1 d2)
   (if (<= d4 1.65e-298)
     (* (- d1) d1)
     (if (<= d4 1e+56) (* (- d3) d1) (* d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if (d4 <= -1.45e-110) {
		tmp = d1 * d2;
	} else if (d4 <= 1.65e-298) {
		tmp = -d1 * d1;
	} else if (d4 <= 1e+56) {
		tmp = -d3 * d1;
	} else {
		tmp = d4 * d1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
    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.45d-110)) then
        tmp = d1 * d2
    else if (d4 <= 1.65d-298) then
        tmp = -d1 * d1
    else if (d4 <= 1d+56) 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.45e-110) {
		tmp = d1 * d2;
	} else if (d4 <= 1.65e-298) {
		tmp = -d1 * d1;
	} else if (d4 <= 1e+56) {
		tmp = -d3 * d1;
	} else {
		tmp = d4 * d1;
	}
	return tmp;
}
def code(d1, d2, d3, d4):
	tmp = 0
	if d4 <= -1.45e-110:
		tmp = d1 * d2
	elif d4 <= 1.65e-298:
		tmp = -d1 * d1
	elif d4 <= 1e+56:
		tmp = -d3 * d1
	else:
		tmp = d4 * d1
	return tmp
function code(d1, d2, d3, d4)
	tmp = 0.0
	if (d4 <= -1.45e-110)
		tmp = Float64(d1 * d2);
	elseif (d4 <= 1.65e-298)
		tmp = Float64(Float64(-d1) * d1);
	elseif (d4 <= 1e+56)
		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.45e-110)
		tmp = d1 * d2;
	elseif (d4 <= 1.65e-298)
		tmp = -d1 * d1;
	elseif (d4 <= 1e+56)
		tmp = -d3 * d1;
	else
		tmp = d4 * d1;
	end
	tmp_2 = tmp;
end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.45e-110], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.65e-298], N[((-d1) * d1), $MachinePrecision], If[LessEqual[d4, 1e+56], N[((-d3) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -1.45 \cdot 10^{-110}:\\
\;\;\;\;d1 \cdot d2\\

\mathbf{elif}\;d4 \leq 1.65 \cdot 10^{-298}:\\
\;\;\;\;\left(-d1\right) \cdot d1\\

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

\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\


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

    1. Initial program 84.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. 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. lower-fma.f64N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, 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(-d1, d3, 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. lower-*.f6432.3

        \[\leadsto \color{blue}{d1 \cdot d2} \]
    7. Applied rewrites32.3%

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

    if -1.4500000000000001e-110 < d4 < 1.6500000000000001e-298

    1. Initial program 88.6%

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

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

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

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

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

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

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

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

    if 1.6500000000000001e-298 < d4 < 1.00000000000000009e56

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

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

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

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

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

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

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

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

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

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

      if 1.00000000000000009e56 < d4

      1. Initial program 85.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. 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. lower-fma.f64N/A

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, d1 \cdot \left(d4 - d1\right)\right)\right)} \]
      5. Step-by-step derivation
        1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 3: 88.9% accurate, 1.2× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d1 \leq -4 \cdot 10^{+112}:\\ \;\;\;\;\left(\left(-d1\right) - d3\right) \cdot d1\\ \mathbf{elif}\;d1 \leq 3 \cdot 10^{+98}:\\ \;\;\;\;\left(\left(d4 + d2\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 (<= d1 -4e+112)
       (* (- (- d1) d3) d1)
       (if (<= d1 3e+98) (* (- (+ d4 d2) d3) d1) (* (- d4 d1) d1))))
    double code(double d1, double d2, double d3, double d4) {
    	double tmp;
    	if (d1 <= -4e+112) {
    		tmp = (-d1 - d3) * d1;
    	} else if (d1 <= 3e+98) {
    		tmp = ((d4 + d2) - d3) * d1;
    	} else {
    		tmp = (d4 - d1) * d1;
    	}
    	return tmp;
    }
    
    module fmin_fmax_functions
        implicit none
        private
        public fmax
        public fmin
    
        interface fmax
            module procedure fmax88
            module procedure fmax44
            module procedure fmax84
            module procedure fmax48
        end interface
        interface fmin
            module procedure fmin88
            module procedure fmin44
            module procedure fmin84
            module procedure fmin48
        end interface
    contains
        real(8) function fmax88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(4) function fmax44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(8) function fmax84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmax48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
        end function
        real(8) function fmin88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(4) function fmin44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(8) function fmin84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmin48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
        end function
    end module
    
    real(8) function code(d1, d2, d3, d4)
    use fmin_fmax_functions
        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 <= (-4d+112)) then
            tmp = (-d1 - d3) * d1
        else if (d1 <= 3d+98) then
            tmp = ((d4 + 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 (d1 <= -4e+112) {
    		tmp = (-d1 - d3) * d1;
    	} else if (d1 <= 3e+98) {
    		tmp = ((d4 + d2) - d3) * d1;
    	} else {
    		tmp = (d4 - d1) * d1;
    	}
    	return tmp;
    }
    
    def code(d1, d2, d3, d4):
    	tmp = 0
    	if d1 <= -4e+112:
    		tmp = (-d1 - d3) * d1
    	elif d1 <= 3e+98:
    		tmp = ((d4 + d2) - d3) * d1
    	else:
    		tmp = (d4 - d1) * d1
    	return tmp
    
    function code(d1, d2, d3, d4)
    	tmp = 0.0
    	if (d1 <= -4e+112)
    		tmp = Float64(Float64(Float64(-d1) - d3) * d1);
    	elseif (d1 <= 3e+98)
    		tmp = Float64(Float64(Float64(d4 + 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 (d1 <= -4e+112)
    		tmp = (-d1 - d3) * d1;
    	elseif (d1 <= 3e+98)
    		tmp = ((d4 + d2) - d3) * d1;
    	else
    		tmp = (d4 - d1) * d1;
    	end
    	tmp_2 = tmp;
    end
    
    code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -4e+112], N[(N[((-d1) - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 3e+98], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;d1 \leq -4 \cdot 10^{+112}:\\
    \;\;\;\;\left(\left(-d1\right) - d3\right) \cdot d1\\
    
    \mathbf{elif}\;d1 \leq 3 \cdot 10^{+98}:\\
    \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(d4 - d1\right) \cdot d1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if d1 < -3.9999999999999997e112

      1. Initial program 51.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. lower--.f64N/A

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

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

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

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

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

        if -3.9999999999999997e112 < d1 < 3.0000000000000001e98

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

        if 3.0000000000000001e98 < d1

        1. Initial program 64.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        Alternative 4: 62.8% accurate, 1.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -1.25 \cdot 10^{+63}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{elif}\;d2 \leq -7.8 \cdot 10^{-188}:\\ \;\;\;\;\left(\left(-d1\right) - 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 -1.25e+63)
           (* (- d2 d3) d1)
           (if (<= d2 -7.8e-188) (* (- (- d1) d3) d1) (* (- d4 d3) d1))))
        double code(double d1, double d2, double d3, double d4) {
        	double tmp;
        	if (d2 <= -1.25e+63) {
        		tmp = (d2 - d3) * d1;
        	} else if (d2 <= -7.8e-188) {
        		tmp = (-d1 - d3) * d1;
        	} else {
        		tmp = (d4 - d3) * d1;
        	}
        	return tmp;
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(d1, d2, d3, d4)
        use fmin_fmax_functions
            real(8), intent (in) :: d1
            real(8), intent (in) :: d2
            real(8), intent (in) :: d3
            real(8), intent (in) :: d4
            real(8) :: tmp
            if (d2 <= (-1.25d+63)) then
                tmp = (d2 - d3) * d1
            else if (d2 <= (-7.8d-188)) then
                tmp = (-d1 - 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 <= -1.25e+63) {
        		tmp = (d2 - d3) * d1;
        	} else if (d2 <= -7.8e-188) {
        		tmp = (-d1 - d3) * d1;
        	} else {
        		tmp = (d4 - d3) * d1;
        	}
        	return tmp;
        }
        
        def code(d1, d2, d3, d4):
        	tmp = 0
        	if d2 <= -1.25e+63:
        		tmp = (d2 - d3) * d1
        	elif d2 <= -7.8e-188:
        		tmp = (-d1 - d3) * d1
        	else:
        		tmp = (d4 - d3) * d1
        	return tmp
        
        function code(d1, d2, d3, d4)
        	tmp = 0.0
        	if (d2 <= -1.25e+63)
        		tmp = Float64(Float64(d2 - d3) * d1);
        	elseif (d2 <= -7.8e-188)
        		tmp = Float64(Float64(Float64(-d1) - 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 <= -1.25e+63)
        		tmp = (d2 - d3) * d1;
        	elseif (d2 <= -7.8e-188)
        		tmp = (-d1 - d3) * d1;
        	else
        		tmp = (d4 - d3) * d1;
        	end
        	tmp_2 = tmp;
        end
        
        code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.25e+63], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d2, -7.8e-188], N[(N[((-d1) - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;d2 \leq -1.25 \cdot 10^{+63}:\\
        \;\;\;\;\left(d2 - d3\right) \cdot d1\\
        
        \mathbf{elif}\;d2 \leq -7.8 \cdot 10^{-188}:\\
        \;\;\;\;\left(\left(-d1\right) - d3\right) \cdot d1\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(d4 - d3\right) \cdot d1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if d2 < -1.25000000000000003e63

          1. Initial program 81.6%

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

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

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

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

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

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

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

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

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

            if -1.25000000000000003e63 < d2 < -7.79999999999999954e-188

            1. Initial program 91.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

              if -7.79999999999999954e-188 < d2

              1. Initial program 87.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. lower--.f64N/A

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

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

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

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

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

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

              Alternative 5: 96.8% accurate, 1.3× speedup?

              \[\begin{array}{l} \\ \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, d1 \cdot \left(d4 - d1\right)\right)\right) \end{array} \]
              (FPCore (d1 d2 d3 d4)
               :precision binary64
               (fma d2 d1 (fma (- d1) d3 (* d1 (- d4 d1)))))
              double code(double d1, double d2, double d3, double d4) {
              	return fma(d2, d1, fma(-d1, d3, (d1 * (d4 - d1))));
              }
              
              function code(d1, d2, d3, d4)
              	return fma(d2, d1, fma(Float64(-d1), d3, Float64(d1 * Float64(d4 - d1))))
              end
              
              code[d1_, d2_, d3_, d4_] := N[(d2 * d1 + N[((-d1) * d3 + N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, d1 \cdot \left(d4 - d1\right)\right)\right)
              \end{array}
              
              Derivation
              1. Initial program 87.1%

                \[\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. lower-fma.f64N/A

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

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

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

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

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

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

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

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

              Alternative 6: 65.2% accurate, 1.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d1 \leq -6.3 \cdot 10^{+69} \lor \neg \left(d1 \leq 1.65 \cdot 10^{+114}\right):\\ \;\;\;\;\left(-d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 + d2\right) \cdot d1\\ \end{array} \end{array} \]
              (FPCore (d1 d2 d3 d4)
               :precision binary64
               (if (or (<= d1 -6.3e+69) (not (<= d1 1.65e+114)))
                 (* (- d1) d1)
                 (* (+ d4 d2) d1)))
              double code(double d1, double d2, double d3, double d4) {
              	double tmp;
              	if ((d1 <= -6.3e+69) || !(d1 <= 1.65e+114)) {
              		tmp = -d1 * d1;
              	} else {
              		tmp = (d4 + d2) * d1;
              	}
              	return tmp;
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(d1, d2, d3, d4)
              use fmin_fmax_functions
                  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 <= (-6.3d+69)) .or. (.not. (d1 <= 1.65d+114))) then
                      tmp = -d1 * d1
                  else
                      tmp = (d4 + d2) * d1
                  end if
                  code = tmp
              end function
              
              public static double code(double d1, double d2, double d3, double d4) {
              	double tmp;
              	if ((d1 <= -6.3e+69) || !(d1 <= 1.65e+114)) {
              		tmp = -d1 * d1;
              	} else {
              		tmp = (d4 + d2) * d1;
              	}
              	return tmp;
              }
              
              def code(d1, d2, d3, d4):
              	tmp = 0
              	if (d1 <= -6.3e+69) or not (d1 <= 1.65e+114):
              		tmp = -d1 * d1
              	else:
              		tmp = (d4 + d2) * d1
              	return tmp
              
              function code(d1, d2, d3, d4)
              	tmp = 0.0
              	if ((d1 <= -6.3e+69) || !(d1 <= 1.65e+114))
              		tmp = Float64(Float64(-d1) * d1);
              	else
              		tmp = Float64(Float64(d4 + d2) * d1);
              	end
              	return tmp
              end
              
              function tmp_2 = code(d1, d2, d3, d4)
              	tmp = 0.0;
              	if ((d1 <= -6.3e+69) || ~((d1 <= 1.65e+114)))
              		tmp = -d1 * d1;
              	else
              		tmp = (d4 + d2) * d1;
              	end
              	tmp_2 = tmp;
              end
              
              code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -6.3e+69], N[Not[LessEqual[d1, 1.65e+114]], $MachinePrecision]], N[((-d1) * d1), $MachinePrecision], N[(N[(d4 + d2), $MachinePrecision] * d1), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;d1 \leq -6.3 \cdot 10^{+69} \lor \neg \left(d1 \leq 1.65 \cdot 10^{+114}\right):\\
              \;\;\;\;\left(-d1\right) \cdot d1\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(d4 + d2\right) \cdot d1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if d1 < -6.30000000000000007e69 or 1.65e114 < d1

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

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

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

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

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

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

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

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

                if -6.30000000000000007e69 < d1 < 1.65e114

                1. Initial program 100.0%

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

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

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

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

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

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

                    \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d3\right) \cdot d1 \]
                5. Applied rewrites93.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 rewrites64.3%

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

                  \[\leadsto \begin{array}{l} \mathbf{if}\;d1 \leq -6.3 \cdot 10^{+69} \lor \neg \left(d1 \leq 1.65 \cdot 10^{+114}\right):\\ \;\;\;\;\left(-d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 + d2\right) \cdot d1\\ \end{array} \]
                10. Add Preprocessing

                Alternative 7: 63.9% accurate, 1.4× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -9.8 \cdot 10^{+27}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{elif}\;d2 \leq -3.8 \cdot 10^{-140}:\\ \;\;\;\;\left(d4 - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \end{array} \end{array} \]
                (FPCore (d1 d2 d3 d4)
                 :precision binary64
                 (if (<= d2 -9.8e+27)
                   (* (- d2 d3) d1)
                   (if (<= d2 -3.8e-140) (* (- d4 d1) d1) (* (- d4 d3) d1))))
                double code(double d1, double d2, double d3, double d4) {
                	double tmp;
                	if (d2 <= -9.8e+27) {
                		tmp = (d2 - d3) * d1;
                	} else if (d2 <= -3.8e-140) {
                		tmp = (d4 - d1) * d1;
                	} else {
                		tmp = (d4 - d3) * d1;
                	}
                	return tmp;
                }
                
                module fmin_fmax_functions
                    implicit none
                    private
                    public fmax
                    public fmin
                
                    interface fmax
                        module procedure fmax88
                        module procedure fmax44
                        module procedure fmax84
                        module procedure fmax48
                    end interface
                    interface fmin
                        module procedure fmin88
                        module procedure fmin44
                        module procedure fmin84
                        module procedure fmin48
                    end interface
                contains
                    real(8) function fmax88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmax44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmax84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmax48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                    end function
                    real(8) function fmin88(x, y) result (res)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(4) function fmin44(x, y) result (res)
                        real(4), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                    end function
                    real(8) function fmin84(x, y) result(res)
                        real(8), intent (in) :: x
                        real(4), intent (in) :: y
                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                    end function
                    real(8) function fmin48(x, y) result(res)
                        real(4), intent (in) :: x
                        real(8), intent (in) :: y
                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                    end function
                end module
                
                real(8) function code(d1, d2, d3, d4)
                use fmin_fmax_functions
                    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 <= (-9.8d+27)) then
                        tmp = (d2 - d3) * d1
                    else if (d2 <= (-3.8d-140)) then
                        tmp = (d4 - d1) * d1
                    else
                        tmp = (d4 - d3) * d1
                    end if
                    code = tmp
                end function
                
                public static double code(double d1, double d2, double d3, double d4) {
                	double tmp;
                	if (d2 <= -9.8e+27) {
                		tmp = (d2 - d3) * d1;
                	} else if (d2 <= -3.8e-140) {
                		tmp = (d4 - d1) * d1;
                	} else {
                		tmp = (d4 - d3) * d1;
                	}
                	return tmp;
                }
                
                def code(d1, d2, d3, d4):
                	tmp = 0
                	if d2 <= -9.8e+27:
                		tmp = (d2 - d3) * d1
                	elif d2 <= -3.8e-140:
                		tmp = (d4 - d1) * d1
                	else:
                		tmp = (d4 - d3) * d1
                	return tmp
                
                function code(d1, d2, d3, d4)
                	tmp = 0.0
                	if (d2 <= -9.8e+27)
                		tmp = Float64(Float64(d2 - d3) * d1);
                	elseif (d2 <= -3.8e-140)
                		tmp = Float64(Float64(d4 - d1) * d1);
                	else
                		tmp = Float64(Float64(d4 - d3) * d1);
                	end
                	return tmp
                end
                
                function tmp_2 = code(d1, d2, d3, d4)
                	tmp = 0.0;
                	if (d2 <= -9.8e+27)
                		tmp = (d2 - d3) * d1;
                	elseif (d2 <= -3.8e-140)
                		tmp = (d4 - d1) * d1;
                	else
                		tmp = (d4 - d3) * d1;
                	end
                	tmp_2 = tmp;
                end
                
                code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -9.8e+27], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d2, -3.8e-140], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;d2 \leq -9.8 \cdot 10^{+27}:\\
                \;\;\;\;\left(d2 - d3\right) \cdot d1\\
                
                \mathbf{elif}\;d2 \leq -3.8 \cdot 10^{-140}:\\
                \;\;\;\;\left(d4 - d1\right) \cdot d1\\
                
                \mathbf{else}:\\
                \;\;\;\;\left(d4 - d3\right) \cdot d1\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if d2 < -9.8000000000000003e27

                  1. Initial program 82.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-+.f6485.7

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

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

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

                    if -9.8000000000000003e27 < d2 < -3.79999999999999998e-140

                    1. Initial program 91.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

                      if -3.79999999999999998e-140 < d2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      Alternative 8: 39.7% accurate, 1.5× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq -1.05 \cdot 10^{-63}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d4 \leq 10^{+56}:\\ \;\;\;\;\left(-d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
                      (FPCore (d1 d2 d3 d4)
                       :precision binary64
                       (if (<= d4 -1.05e-63) (* d1 d2) (if (<= d4 1e+56) (* (- d3) d1) (* d4 d1))))
                      double code(double d1, double d2, double d3, double d4) {
                      	double tmp;
                      	if (d4 <= -1.05e-63) {
                      		tmp = d1 * d2;
                      	} else if (d4 <= 1e+56) {
                      		tmp = -d3 * d1;
                      	} else {
                      		tmp = d4 * d1;
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(d1, d2, d3, d4)
                      use fmin_fmax_functions
                          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.05d-63)) then
                              tmp = d1 * d2
                          else if (d4 <= 1d+56) 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.05e-63) {
                      		tmp = d1 * d2;
                      	} else if (d4 <= 1e+56) {
                      		tmp = -d3 * d1;
                      	} else {
                      		tmp = d4 * d1;
                      	}
                      	return tmp;
                      }
                      
                      def code(d1, d2, d3, d4):
                      	tmp = 0
                      	if d4 <= -1.05e-63:
                      		tmp = d1 * d2
                      	elif d4 <= 1e+56:
                      		tmp = -d3 * d1
                      	else:
                      		tmp = d4 * d1
                      	return tmp
                      
                      function code(d1, d2, d3, d4)
                      	tmp = 0.0
                      	if (d4 <= -1.05e-63)
                      		tmp = Float64(d1 * d2);
                      	elseif (d4 <= 1e+56)
                      		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.05e-63)
                      		tmp = d1 * d2;
                      	elseif (d4 <= 1e+56)
                      		tmp = -d3 * d1;
                      	else
                      		tmp = d4 * d1;
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.05e-63], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1e+56], N[((-d3) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;d4 \leq -1.05 \cdot 10^{-63}:\\
                      \;\;\;\;d1 \cdot d2\\
                      
                      \mathbf{elif}\;d4 \leq 10^{+56}:\\
                      \;\;\;\;\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.05e-63

                        1. Initial program 82.1%

                          \[\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. lower-fma.f64N/A

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

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

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

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

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

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

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

                          \[\leadsto \color{blue}{\mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, 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. lower-*.f6430.4

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

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

                        if -1.05e-63 < d4 < 1.00000000000000009e56

                        1. Initial program 90.3%

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

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

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

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

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

                          if 1.00000000000000009e56 < d4

                          1. Initial program 85.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. 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. lower-fma.f64N/A

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

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

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

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

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

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

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

                            \[\leadsto \color{blue}{\mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, d1 \cdot \left(d4 - d1\right)\right)\right)} \]
                          5. Step-by-step derivation
                            1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 9: 85.5% accurate, 1.7× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -5.8 \cdot 10^{+62}:\\ \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\ \end{array} \end{array} \]
                        (FPCore (d1 d2 d3 d4)
                         :precision binary64
                         (if (<= d2 -5.8e+62) (* (- (+ d4 d2) d3) d1) (* (- (- d4 d3) d1) d1)))
                        double code(double d1, double d2, double d3, double d4) {
                        	double tmp;
                        	if (d2 <= -5.8e+62) {
                        		tmp = ((d4 + d2) - d3) * d1;
                        	} else {
                        		tmp = ((d4 - d3) - d1) * d1;
                        	}
                        	return tmp;
                        }
                        
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(d1, d2, d3, d4)
                        use fmin_fmax_functions
                            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+62)) then
                                tmp = ((d4 + d2) - d3) * d1
                            else
                                tmp = ((d4 - d3) - d1) * d1
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double d1, double d2, double d3, double d4) {
                        	double tmp;
                        	if (d2 <= -5.8e+62) {
                        		tmp = ((d4 + d2) - d3) * d1;
                        	} else {
                        		tmp = ((d4 - d3) - d1) * d1;
                        	}
                        	return tmp;
                        }
                        
                        def code(d1, d2, d3, d4):
                        	tmp = 0
                        	if d2 <= -5.8e+62:
                        		tmp = ((d4 + d2) - d3) * d1
                        	else:
                        		tmp = ((d4 - d3) - d1) * d1
                        	return tmp
                        
                        function code(d1, d2, d3, d4)
                        	tmp = 0.0
                        	if (d2 <= -5.8e+62)
                        		tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1);
                        	else
                        		tmp = Float64(Float64(Float64(d4 - d3) - d1) * d1);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(d1, d2, d3, d4)
                        	tmp = 0.0;
                        	if (d2 <= -5.8e+62)
                        		tmp = ((d4 + d2) - d3) * d1;
                        	else
                        		tmp = ((d4 - d3) - d1) * d1;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.8e+62], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;d2 \leq -5.8 \cdot 10^{+62}:\\
                        \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if d2 < -5.79999999999999968e62

                          1. Initial program 81.6%

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

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

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

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

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

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

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

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

                          if -5.79999999999999968e62 < d2

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

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

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

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

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

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

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

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

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

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

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

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

                        Alternative 10: 63.1% accurate, 2.0× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -9.8 \cdot 10^{+27}:\\ \;\;\;\;\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 (<= d2 -9.8e+27) (* (- d2 d3) d1) (* (- d4 d1) d1)))
                        double code(double d1, double d2, double d3, double d4) {
                        	double tmp;
                        	if (d2 <= -9.8e+27) {
                        		tmp = (d2 - d3) * d1;
                        	} else {
                        		tmp = (d4 - d1) * d1;
                        	}
                        	return tmp;
                        }
                        
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(d1, d2, d3, d4)
                        use fmin_fmax_functions
                            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 <= (-9.8d+27)) 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 (d2 <= -9.8e+27) {
                        		tmp = (d2 - d3) * d1;
                        	} else {
                        		tmp = (d4 - d1) * d1;
                        	}
                        	return tmp;
                        }
                        
                        def code(d1, d2, d3, d4):
                        	tmp = 0
                        	if d2 <= -9.8e+27:
                        		tmp = (d2 - d3) * d1
                        	else:
                        		tmp = (d4 - d1) * d1
                        	return tmp
                        
                        function code(d1, d2, d3, d4)
                        	tmp = 0.0
                        	if (d2 <= -9.8e+27)
                        		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 (d2 <= -9.8e+27)
                        		tmp = (d2 - d3) * d1;
                        	else
                        		tmp = (d4 - d1) * d1;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -9.8e+27], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;d2 \leq -9.8 \cdot 10^{+27}:\\
                        \;\;\;\;\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 d2 < -9.8000000000000003e27

                          1. Initial program 82.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-+.f6485.7

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

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

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

                            if -9.8000000000000003e27 < d2

                            1. Initial program 88.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            Alternative 11: 64.4% accurate, 2.0× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d4 \leq 10^{+56}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 + d2\right) \cdot d1\\ \end{array} \end{array} \]
                            (FPCore (d1 d2 d3 d4)
                             :precision binary64
                             (if (<= d4 1e+56) (* (- d2 d3) d1) (* (+ d4 d2) d1)))
                            double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 1e+56) {
                            		tmp = (d2 - d3) * d1;
                            	} else {
                            		tmp = (d4 + d2) * d1;
                            	}
                            	return tmp;
                            }
                            
                            module fmin_fmax_functions
                                implicit none
                                private
                                public fmax
                                public fmin
                            
                                interface fmax
                                    module procedure fmax88
                                    module procedure fmax44
                                    module procedure fmax84
                                    module procedure fmax48
                                end interface
                                interface fmin
                                    module procedure fmin88
                                    module procedure fmin44
                                    module procedure fmin84
                                    module procedure fmin48
                                end interface
                            contains
                                real(8) function fmax88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmax44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmax84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmax48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                end function
                                real(8) function fmin88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmin44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmin84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmin48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                end function
                            end module
                            
                            real(8) function code(d1, d2, d3, d4)
                            use fmin_fmax_functions
                                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 <= 1d+56) then
                                    tmp = (d2 - d3) * d1
                                else
                                    tmp = (d4 + d2) * d1
                                end if
                                code = tmp
                            end function
                            
                            public static double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if (d4 <= 1e+56) {
                            		tmp = (d2 - d3) * d1;
                            	} else {
                            		tmp = (d4 + d2) * d1;
                            	}
                            	return tmp;
                            }
                            
                            def code(d1, d2, d3, d4):
                            	tmp = 0
                            	if d4 <= 1e+56:
                            		tmp = (d2 - d3) * d1
                            	else:
                            		tmp = (d4 + d2) * d1
                            	return tmp
                            
                            function code(d1, d2, d3, d4)
                            	tmp = 0.0
                            	if (d4 <= 1e+56)
                            		tmp = Float64(Float64(d2 - d3) * d1);
                            	else
                            		tmp = Float64(Float64(d4 + d2) * d1);
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(d1, d2, d3, d4)
                            	tmp = 0.0;
                            	if (d4 <= 1e+56)
                            		tmp = (d2 - d3) * d1;
                            	else
                            		tmp = (d4 + d2) * d1;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1e+56], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 + d2), $MachinePrecision] * d1), $MachinePrecision]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;d4 \leq 10^{+56}:\\
                            \;\;\;\;\left(d2 - d3\right) \cdot d1\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\left(d4 + d2\right) \cdot d1\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if d4 < 1.00000000000000009e56

                              1. Initial program 87.6%

                                \[\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-+.f6477.6

                                  \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d3\right) \cdot d1 \]
                              5. Applied rewrites77.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 rewrites65.3%

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

                                if 1.00000000000000009e56 < d4

                                1. Initial program 85.2%

                                  \[\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-+.f6489.6

                                    \[\leadsto \left(\color{blue}{\left(d4 + d2\right)} - d3\right) \cdot d1 \]
                                5. Applied rewrites89.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 rewrites83.8%

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

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

                                Alternative 12: 39.5% accurate, 2.5× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -1.35 \cdot 10^{+63}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
                                (FPCore (d1 d2 d3 d4)
                                 :precision binary64
                                 (if (<= d2 -1.35e+63) (* d1 d2) (* d4 d1)))
                                double code(double d1, double d2, double d3, double d4) {
                                	double tmp;
                                	if (d2 <= -1.35e+63) {
                                		tmp = d1 * d2;
                                	} else {
                                		tmp = d4 * d1;
                                	}
                                	return tmp;
                                }
                                
                                module fmin_fmax_functions
                                    implicit none
                                    private
                                    public fmax
                                    public fmin
                                
                                    interface fmax
                                        module procedure fmax88
                                        module procedure fmax44
                                        module procedure fmax84
                                        module procedure fmax48
                                    end interface
                                    interface fmin
                                        module procedure fmin88
                                        module procedure fmin44
                                        module procedure fmin84
                                        module procedure fmin48
                                    end interface
                                contains
                                    real(8) function fmax88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmax44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmax84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmax48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmin44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmin48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                    end function
                                end module
                                
                                real(8) function code(d1, d2, d3, d4)
                                use fmin_fmax_functions
                                    real(8), intent (in) :: d1
                                    real(8), intent (in) :: d2
                                    real(8), intent (in) :: d3
                                    real(8), intent (in) :: d4
                                    real(8) :: tmp
                                    if (d2 <= (-1.35d+63)) then
                                        tmp = d1 * d2
                                    else
                                        tmp = d4 * d1
                                    end if
                                    code = tmp
                                end function
                                
                                public static double code(double d1, double d2, double d3, double d4) {
                                	double tmp;
                                	if (d2 <= -1.35e+63) {
                                		tmp = d1 * d2;
                                	} else {
                                		tmp = d4 * d1;
                                	}
                                	return tmp;
                                }
                                
                                def code(d1, d2, d3, d4):
                                	tmp = 0
                                	if d2 <= -1.35e+63:
                                		tmp = d1 * d2
                                	else:
                                		tmp = d4 * d1
                                	return tmp
                                
                                function code(d1, d2, d3, d4)
                                	tmp = 0.0
                                	if (d2 <= -1.35e+63)
                                		tmp = Float64(d1 * d2);
                                	else
                                		tmp = Float64(d4 * d1);
                                	end
                                	return tmp
                                end
                                
                                function tmp_2 = code(d1, d2, d3, d4)
                                	tmp = 0.0;
                                	if (d2 <= -1.35e+63)
                                		tmp = d1 * d2;
                                	else
                                		tmp = d4 * d1;
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.35e+63], N[(d1 * d2), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;d2 \leq -1.35 \cdot 10^{+63}:\\
                                \;\;\;\;d1 \cdot d2\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;d4 \cdot d1\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if d2 < -1.35000000000000009e63

                                  1. Initial program 81.6%

                                    \[\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. lower-fma.f64N/A

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

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

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

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

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

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

                                      \[\leadsto \mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, 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(-d1, d3, 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. lower-*.f6465.3

                                      \[\leadsto \color{blue}{d1 \cdot d2} \]
                                  7. Applied rewrites65.3%

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

                                  if -1.35000000000000009e63 < d2

                                  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. lower-fma.f64N/A

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

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

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

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

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

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

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

                                    \[\leadsto \color{blue}{\mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, d1 \cdot \left(d4 - d1\right)\right)\right)} \]
                                  5. Step-by-step derivation
                                    1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \color{blue}{d4 \cdot d1} \]
                                  9. Applied rewrites31.1%

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

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

                                Alternative 13: 30.7% accurate, 5.0× speedup?

                                \[\begin{array}{l} \\ d1 \cdot d2 \end{array} \]
                                (FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
                                double code(double d1, double d2, double d3, double d4) {
                                	return d1 * d2;
                                }
                                
                                module fmin_fmax_functions
                                    implicit none
                                    private
                                    public fmax
                                    public fmin
                                
                                    interface fmax
                                        module procedure fmax88
                                        module procedure fmax44
                                        module procedure fmax84
                                        module procedure fmax48
                                    end interface
                                    interface fmin
                                        module procedure fmin88
                                        module procedure fmin44
                                        module procedure fmin84
                                        module procedure fmin48
                                    end interface
                                contains
                                    real(8) function fmax88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmax44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmax84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmax48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmin44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmin48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                    end function
                                end module
                                
                                real(8) function code(d1, d2, d3, d4)
                                use fmin_fmax_functions
                                    real(8), intent (in) :: d1
                                    real(8), intent (in) :: d2
                                    real(8), intent (in) :: d3
                                    real(8), intent (in) :: d4
                                    code = d1 * d2
                                end function
                                
                                public static double code(double d1, double d2, double d3, double d4) {
                                	return d1 * d2;
                                }
                                
                                def code(d1, d2, d3, d4):
                                	return d1 * d2
                                
                                function code(d1, d2, d3, d4)
                                	return Float64(d1 * d2)
                                end
                                
                                function tmp = code(d1, d2, d3, d4)
                                	tmp = d1 * d2;
                                end
                                
                                code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
                                
                                \begin{array}{l}
                                
                                \\
                                d1 \cdot d2
                                \end{array}
                                
                                Derivation
                                1. Initial program 87.1%

                                  \[\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. lower-fma.f64N/A

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

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

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

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

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

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

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

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, 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. lower-*.f6435.5

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

                                  \[\leadsto \color{blue}{d1 \cdot d2} \]
                                8. Final simplification35.5%

                                  \[\leadsto d1 \cdot d2 \]
                                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);
                                }
                                
                                module fmin_fmax_functions
                                    implicit none
                                    private
                                    public fmax
                                    public fmin
                                
                                    interface fmax
                                        module procedure fmax88
                                        module procedure fmax44
                                        module procedure fmax84
                                        module procedure fmax48
                                    end interface
                                    interface fmin
                                        module procedure fmin88
                                        module procedure fmin44
                                        module procedure fmin84
                                        module procedure fmin48
                                    end interface
                                contains
                                    real(8) function fmax88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmax44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmax84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmax48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmin44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmin48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                    end function
                                end module
                                
                                real(8) function code(d1, d2, d3, d4)
                                use fmin_fmax_functions
                                    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 2025017 
                                (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)))