FastMath dist4

Percentage Accurate: 87.6% → 98.9%
Time: 6.1s
Alternatives: 15
Speedup: 1.7×

Specification

?
\[\begin{array}{l} \\ \left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
	return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
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 15 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.6% 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.9% accurate, 1.0× speedup?

\[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d1 \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, d1 \cdot \left(d4 - d1\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (if (<= d1 -1.35e+154)
   (* (- (- d2 d3) d1) d1)
   (fma d2 d1 (fma (- d1) d3 (* d1 (- d4 d1))))))
assert(d1 < d2 && d2 < d3 && d3 < d4);
double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if (d1 <= -1.35e+154) {
		tmp = ((d2 - d3) - d1) * d1;
	} else {
		tmp = fma(d2, d1, fma(-d1, d3, (d1 * (d4 - d1))));
	}
	return tmp;
}
d1, d2, d3, d4 = sort([d1, d2, d3, d4])
function code(d1, d2, d3, d4)
	tmp = 0.0
	if (d1 <= -1.35e+154)
		tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1);
	else
		tmp = fma(d2, d1, fma(Float64(-d1), d3, Float64(d1 * Float64(d4 - d1))));
	end
	return tmp
end
NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.35e+154], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(d2 * d1 + N[((-d1) * d3 + N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d1 < -1.35000000000000003e154

    1. Initial program 48.5%

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

      \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
    4. Step-by-step derivation
      1. Applied rewrites90.9%

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

      if -1.35000000000000003e154 < d1

      1. Initial program 96.3%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(d2, d1, \left(\mathsf{neg}\left(d1\right)\right) \cdot d3 + \left(d4 \cdot d1 - d1 \cdot d1\right)\right)} \]
        11. 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--.f6499.0

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

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

    Alternative 2: 71.7% accurate, 1.1× speedup?

    \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} t_0 := \left(d2 - d3\right) \cdot d1\\ \mathbf{if}\;d3 \leq -4.5 \cdot 10^{+51}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d3 \leq -1.5 \cdot 10^{-146}:\\ \;\;\;\;\left(d2 - d1\right) \cdot d1\\ \mathbf{elif}\;d3 \leq 3.6 \cdot 10^{+50}:\\ \;\;\;\;\left(d2 + d4\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
    (FPCore (d1 d2 d3 d4)
     :precision binary64
     (let* ((t_0 (* (- d2 d3) d1)))
       (if (<= d3 -4.5e+51)
         t_0
         (if (<= d3 -1.5e-146)
           (* (- d2 d1) d1)
           (if (<= d3 3.6e+50) (* (+ d2 d4) d1) t_0)))))
    assert(d1 < d2 && d2 < d3 && d3 < d4);
    double code(double d1, double d2, double d3, double d4) {
    	double t_0 = (d2 - d3) * d1;
    	double tmp;
    	if (d3 <= -4.5e+51) {
    		tmp = t_0;
    	} else if (d3 <= -1.5e-146) {
    		tmp = (d2 - d1) * d1;
    	} else if (d3 <= 3.6e+50) {
    		tmp = (d2 + d4) * d1;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
    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) :: t_0
        real(8) :: tmp
        t_0 = (d2 - d3) * d1
        if (d3 <= (-4.5d+51)) then
            tmp = t_0
        else if (d3 <= (-1.5d-146)) then
            tmp = (d2 - d1) * d1
        else if (d3 <= 3.6d+50) then
            tmp = (d2 + d4) * d1
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    assert d1 < d2 && d2 < d3 && d3 < d4;
    public static double code(double d1, double d2, double d3, double d4) {
    	double t_0 = (d2 - d3) * d1;
    	double tmp;
    	if (d3 <= -4.5e+51) {
    		tmp = t_0;
    	} else if (d3 <= -1.5e-146) {
    		tmp = (d2 - d1) * d1;
    	} else if (d3 <= 3.6e+50) {
    		tmp = (d2 + d4) * d1;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
    def code(d1, d2, d3, d4):
    	t_0 = (d2 - d3) * d1
    	tmp = 0
    	if d3 <= -4.5e+51:
    		tmp = t_0
    	elif d3 <= -1.5e-146:
    		tmp = (d2 - d1) * d1
    	elif d3 <= 3.6e+50:
    		tmp = (d2 + d4) * d1
    	else:
    		tmp = t_0
    	return tmp
    
    d1, d2, d3, d4 = sort([d1, d2, d3, d4])
    function code(d1, d2, d3, d4)
    	t_0 = Float64(Float64(d2 - d3) * d1)
    	tmp = 0.0
    	if (d3 <= -4.5e+51)
    		tmp = t_0;
    	elseif (d3 <= -1.5e-146)
    		tmp = Float64(Float64(d2 - d1) * d1);
    	elseif (d3 <= 3.6e+50)
    		tmp = Float64(Float64(d2 + d4) * d1);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
    function tmp_2 = code(d1, d2, d3, d4)
    	t_0 = (d2 - d3) * d1;
    	tmp = 0.0;
    	if (d3 <= -4.5e+51)
    		tmp = t_0;
    	elseif (d3 <= -1.5e-146)
    		tmp = (d2 - d1) * d1;
    	elseif (d3 <= 3.6e+50)
    		tmp = (d2 + d4) * d1;
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
    code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision]}, If[LessEqual[d3, -4.5e+51], t$95$0, If[LessEqual[d3, -1.5e-146], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d3, 3.6e+50], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]]
    
    \begin{array}{l}
    [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
    \\
    \begin{array}{l}
    t_0 := \left(d2 - d3\right) \cdot d1\\
    \mathbf{if}\;d3 \leq -4.5 \cdot 10^{+51}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;d3 \leq -1.5 \cdot 10^{-146}:\\
    \;\;\;\;\left(d2 - d1\right) \cdot d1\\
    
    \mathbf{elif}\;d3 \leq 3.6 \cdot 10^{+50}:\\
    \;\;\;\;\left(d2 + d4\right) \cdot d1\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if d3 < -4.5e51 or 3.59999999999999986e50 < d3

      1. Initial program 89.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. Applied rewrites93.8%

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

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

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

          if -4.5e51 < d3 < -1.50000000000000009e-146

          1. Initial program 92.5%

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

            \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
          4. Step-by-step derivation
            1. Applied rewrites81.8%

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

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

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

              if -1.50000000000000009e-146 < d3 < 3.59999999999999986e50

              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. Applied rewrites77.6%

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

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

                    \[\leadsto \left(d2 + d4\right) \cdot d1 \]
                4. Recombined 3 regimes into one program.
                5. Add Preprocessing

                Alternative 3: 71.4% accurate, 1.1× speedup?

                \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} t_0 := \left(d2 - d3\right) \cdot d1\\ \mathbf{if}\;d3 \leq -14000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d3 \leq -1 \cdot 10^{-145}:\\ \;\;\;\;\left(d4 - d1\right) \cdot d1\\ \mathbf{elif}\;d3 \leq 3.6 \cdot 10^{+50}:\\ \;\;\;\;\left(d2 + d4\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                (FPCore (d1 d2 d3 d4)
                 :precision binary64
                 (let* ((t_0 (* (- d2 d3) d1)))
                   (if (<= d3 -14000.0)
                     t_0
                     (if (<= d3 -1e-145)
                       (* (- d4 d1) d1)
                       (if (<= d3 3.6e+50) (* (+ d2 d4) d1) t_0)))))
                assert(d1 < d2 && d2 < d3 && d3 < d4);
                double code(double d1, double d2, double d3, double d4) {
                	double t_0 = (d2 - d3) * d1;
                	double tmp;
                	if (d3 <= -14000.0) {
                		tmp = t_0;
                	} else if (d3 <= -1e-145) {
                		tmp = (d4 - d1) * d1;
                	} else if (d3 <= 3.6e+50) {
                		tmp = (d2 + d4) * d1;
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                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) :: t_0
                    real(8) :: tmp
                    t_0 = (d2 - d3) * d1
                    if (d3 <= (-14000.0d0)) then
                        tmp = t_0
                    else if (d3 <= (-1d-145)) then
                        tmp = (d4 - d1) * d1
                    else if (d3 <= 3.6d+50) then
                        tmp = (d2 + d4) * d1
                    else
                        tmp = t_0
                    end if
                    code = tmp
                end function
                
                assert d1 < d2 && d2 < d3 && d3 < d4;
                public static double code(double d1, double d2, double d3, double d4) {
                	double t_0 = (d2 - d3) * d1;
                	double tmp;
                	if (d3 <= -14000.0) {
                		tmp = t_0;
                	} else if (d3 <= -1e-145) {
                		tmp = (d4 - d1) * d1;
                	} else if (d3 <= 3.6e+50) {
                		tmp = (d2 + d4) * d1;
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                def code(d1, d2, d3, d4):
                	t_0 = (d2 - d3) * d1
                	tmp = 0
                	if d3 <= -14000.0:
                		tmp = t_0
                	elif d3 <= -1e-145:
                		tmp = (d4 - d1) * d1
                	elif d3 <= 3.6e+50:
                		tmp = (d2 + d4) * d1
                	else:
                		tmp = t_0
                	return tmp
                
                d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                function code(d1, d2, d3, d4)
                	t_0 = Float64(Float64(d2 - d3) * d1)
                	tmp = 0.0
                	if (d3 <= -14000.0)
                		tmp = t_0;
                	elseif (d3 <= -1e-145)
                		tmp = Float64(Float64(d4 - d1) * d1);
                	elseif (d3 <= 3.6e+50)
                		tmp = Float64(Float64(d2 + d4) * d1);
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                function tmp_2 = code(d1, d2, d3, d4)
                	t_0 = (d2 - d3) * d1;
                	tmp = 0.0;
                	if (d3 <= -14000.0)
                		tmp = t_0;
                	elseif (d3 <= -1e-145)
                		tmp = (d4 - d1) * d1;
                	elseif (d3 <= 3.6e+50)
                		tmp = (d2 + d4) * d1;
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision]}, If[LessEqual[d3, -14000.0], t$95$0, If[LessEqual[d3, -1e-145], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d3, 3.6e+50], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]]
                
                \begin{array}{l}
                [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                \\
                \begin{array}{l}
                t_0 := \left(d2 - d3\right) \cdot d1\\
                \mathbf{if}\;d3 \leq -14000:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;d3 \leq -1 \cdot 10^{-145}:\\
                \;\;\;\;\left(d4 - d1\right) \cdot d1\\
                
                \mathbf{elif}\;d3 \leq 3.6 \cdot 10^{+50}:\\
                \;\;\;\;\left(d2 + d4\right) \cdot d1\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if d3 < -14000 or 3.59999999999999986e50 < d3

                  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. Applied rewrites92.7%

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

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

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

                      if -14000 < d3 < -9.99999999999999915e-146

                      1. Initial program 89.3%

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

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

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

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

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

                          if -9.99999999999999915e-146 < d3 < 3.59999999999999986e50

                          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. Applied rewrites77.6%

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

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

                                \[\leadsto \left(d2 + d4\right) \cdot d1 \]
                            4. Recombined 3 regimes into one program.
                            5. Add Preprocessing

                            Alternative 4: 89.1% accurate, 1.2× speedup?

                            \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d1 \leq -3.7 \cdot 10^{+134} \lor \neg \left(d1 \leq 4.5 \cdot 10^{+62}\right):\\ \;\;\;\;\left(d2 - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\ \end{array} \end{array} \]
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            (FPCore (d1 d2 d3 d4)
                             :precision binary64
                             (if (or (<= d1 -3.7e+134) (not (<= d1 4.5e+62)))
                               (* (- d2 d1) d1)
                               (* (- (+ d4 d2) d3) d1)))
                            assert(d1 < d2 && d2 < d3 && d3 < d4);
                            double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if ((d1 <= -3.7e+134) || !(d1 <= 4.5e+62)) {
                            		tmp = (d2 - d1) * d1;
                            	} else {
                            		tmp = ((d4 + d2) - d3) * d1;
                            	}
                            	return tmp;
                            }
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            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 <= (-3.7d+134)) .or. (.not. (d1 <= 4.5d+62))) then
                                    tmp = (d2 - d1) * d1
                                else
                                    tmp = ((d4 + d2) - d3) * d1
                                end if
                                code = tmp
                            end function
                            
                            assert d1 < d2 && d2 < d3 && d3 < d4;
                            public static double code(double d1, double d2, double d3, double d4) {
                            	double tmp;
                            	if ((d1 <= -3.7e+134) || !(d1 <= 4.5e+62)) {
                            		tmp = (d2 - d1) * d1;
                            	} else {
                            		tmp = ((d4 + d2) - d3) * d1;
                            	}
                            	return tmp;
                            }
                            
                            [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                            def code(d1, d2, d3, d4):
                            	tmp = 0
                            	if (d1 <= -3.7e+134) or not (d1 <= 4.5e+62):
                            		tmp = (d2 - d1) * d1
                            	else:
                            		tmp = ((d4 + d2) - d3) * d1
                            	return tmp
                            
                            d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                            function code(d1, d2, d3, d4)
                            	tmp = 0.0
                            	if ((d1 <= -3.7e+134) || !(d1 <= 4.5e+62))
                            		tmp = Float64(Float64(d2 - d1) * d1);
                            	else
                            		tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1);
                            	end
                            	return tmp
                            end
                            
                            d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                            function tmp_2 = code(d1, d2, d3, d4)
                            	tmp = 0.0;
                            	if ((d1 <= -3.7e+134) || ~((d1 <= 4.5e+62)))
                            		tmp = (d2 - d1) * d1;
                            	else
                            		tmp = ((d4 + d2) - d3) * d1;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                            code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -3.7e+134], N[Not[LessEqual[d1, 4.5e+62]], $MachinePrecision]], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
                            
                            \begin{array}{l}
                            [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;d1 \leq -3.7 \cdot 10^{+134} \lor \neg \left(d1 \leq 4.5 \cdot 10^{+62}\right):\\
                            \;\;\;\;\left(d2 - d1\right) \cdot d1\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if d1 < -3.70000000000000013e134 or 4.49999999999999999e62 < d1

                              1. Initial program 66.2%

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

                                \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                              4. Step-by-step derivation
                                1. Applied rewrites94.0%

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

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

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

                                  if -3.70000000000000013e134 < d1 < 4.49999999999999999e62

                                  1. Initial program 99.9%

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

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

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

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

                                  Alternative 5: 99.0% accurate, 1.2× speedup?

                                  \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d1 \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(d2 - d3, d1, d1 \cdot \left(d4 - d1\right)\right)\\ \end{array} \end{array} \]
                                  NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                  (FPCore (d1 d2 d3 d4)
                                   :precision binary64
                                   (if (<= d1 -1.35e+154)
                                     (* (- (- d2 d3) d1) d1)
                                     (fma (- d2 d3) d1 (* d1 (- d4 d1)))))
                                  assert(d1 < d2 && d2 < d3 && d3 < d4);
                                  double code(double d1, double d2, double d3, double d4) {
                                  	double tmp;
                                  	if (d1 <= -1.35e+154) {
                                  		tmp = ((d2 - d3) - d1) * d1;
                                  	} else {
                                  		tmp = fma((d2 - d3), d1, (d1 * (d4 - d1)));
                                  	}
                                  	return tmp;
                                  }
                                  
                                  d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                  function code(d1, d2, d3, d4)
                                  	tmp = 0.0
                                  	if (d1 <= -1.35e+154)
                                  		tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1);
                                  	else
                                  		tmp = fma(Float64(d2 - d3), d1, Float64(d1 * Float64(d4 - d1)));
                                  	end
                                  	return tmp
                                  end
                                  
                                  NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                  code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.35e+154], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d2 - d3), $MachinePrecision] * d1 + N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;d1 \leq -1.35 \cdot 10^{+154}:\\
                                  \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\mathsf{fma}\left(d2 - d3, d1, d1 \cdot \left(d4 - d1\right)\right)\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if d1 < -1.35000000000000003e154

                                    1. Initial program 48.5%

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

                                      \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites90.9%

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

                                      if -1.35000000000000003e154 < d1

                                      1. Initial program 96.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    Alternative 6: 75.2% accurate, 1.3× speedup?

                                    \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d2 \leq -1.45 \cdot 10^{-24}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{elif}\;d2 \leq 7.2 \cdot 10^{-204}:\\ \;\;\;\;\left(\left(-d1\right) - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \end{array} \end{array} \]
                                    NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                    (FPCore (d1 d2 d3 d4)
                                     :precision binary64
                                     (if (<= d2 -1.45e-24)
                                       (* (- d2 d3) d1)
                                       (if (<= d2 7.2e-204) (* (- (- d1) d3) d1) (* (- d4 d3) d1))))
                                    assert(d1 < d2 && d2 < d3 && d3 < d4);
                                    double code(double d1, double d2, double d3, double d4) {
                                    	double tmp;
                                    	if (d2 <= -1.45e-24) {
                                    		tmp = (d2 - d3) * d1;
                                    	} else if (d2 <= 7.2e-204) {
                                    		tmp = (-d1 - d3) * d1;
                                    	} else {
                                    		tmp = (d4 - d3) * d1;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                    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.45d-24)) then
                                            tmp = (d2 - d3) * d1
                                        else if (d2 <= 7.2d-204) then
                                            tmp = (-d1 - d3) * d1
                                        else
                                            tmp = (d4 - d3) * d1
                                        end if
                                        code = tmp
                                    end function
                                    
                                    assert d1 < d2 && d2 < d3 && d3 < d4;
                                    public static double code(double d1, double d2, double d3, double d4) {
                                    	double tmp;
                                    	if (d2 <= -1.45e-24) {
                                    		tmp = (d2 - d3) * d1;
                                    	} else if (d2 <= 7.2e-204) {
                                    		tmp = (-d1 - d3) * d1;
                                    	} else {
                                    		tmp = (d4 - d3) * d1;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                    def code(d1, d2, d3, d4):
                                    	tmp = 0
                                    	if d2 <= -1.45e-24:
                                    		tmp = (d2 - d3) * d1
                                    	elif d2 <= 7.2e-204:
                                    		tmp = (-d1 - d3) * d1
                                    	else:
                                    		tmp = (d4 - d3) * d1
                                    	return tmp
                                    
                                    d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                    function code(d1, d2, d3, d4)
                                    	tmp = 0.0
                                    	if (d2 <= -1.45e-24)
                                    		tmp = Float64(Float64(d2 - d3) * d1);
                                    	elseif (d2 <= 7.2e-204)
                                    		tmp = Float64(Float64(Float64(-d1) - d3) * d1);
                                    	else
                                    		tmp = Float64(Float64(d4 - d3) * d1);
                                    	end
                                    	return tmp
                                    end
                                    
                                    d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                    function tmp_2 = code(d1, d2, d3, d4)
                                    	tmp = 0.0;
                                    	if (d2 <= -1.45e-24)
                                    		tmp = (d2 - d3) * d1;
                                    	elseif (d2 <= 7.2e-204)
                                    		tmp = (-d1 - d3) * d1;
                                    	else
                                    		tmp = (d4 - d3) * d1;
                                    	end
                                    	tmp_2 = tmp;
                                    end
                                    
                                    NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                    code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.45e-24], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d2, 7.2e-204], N[(N[((-d1) - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
                                    
                                    \begin{array}{l}
                                    [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                    \\
                                    \begin{array}{l}
                                    \mathbf{if}\;d2 \leq -1.45 \cdot 10^{-24}:\\
                                    \;\;\;\;\left(d2 - d3\right) \cdot d1\\
                                    
                                    \mathbf{elif}\;d2 \leq 7.2 \cdot 10^{-204}:\\
                                    \;\;\;\;\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.4499999999999999e-24

                                      1. Initial program 86.7%

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

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

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

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

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

                                          if -1.4499999999999999e-24 < d2 < 7.1999999999999993e-204

                                          1. Initial program 94.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. Applied rewrites99.9%

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

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

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

                                              if 7.1999999999999993e-204 < d2

                                              1. Initial program 89.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. Applied rewrites73.3%

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

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

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

                                                Alternative 7: 67.6% accurate, 1.4× speedup?

                                                \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d3 \leq -7.5 \cdot 10^{+123} \lor \neg \left(d3 \leq 2 \cdot 10^{+69}\right):\\ \;\;\;\;\left(-d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d2 + d4\right) \cdot d1\\ \end{array} \end{array} \]
                                                NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                (FPCore (d1 d2 d3 d4)
                                                 :precision binary64
                                                 (if (or (<= d3 -7.5e+123) (not (<= d3 2e+69)))
                                                   (* (- d3) d1)
                                                   (* (+ d2 d4) d1)))
                                                assert(d1 < d2 && d2 < d3 && d3 < d4);
                                                double code(double d1, double d2, double d3, double d4) {
                                                	double tmp;
                                                	if ((d3 <= -7.5e+123) || !(d3 <= 2e+69)) {
                                                		tmp = -d3 * d1;
                                                	} else {
                                                		tmp = (d2 + d4) * d1;
                                                	}
                                                	return tmp;
                                                }
                                                
                                                NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                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 ((d3 <= (-7.5d+123)) .or. (.not. (d3 <= 2d+69))) then
                                                        tmp = -d3 * d1
                                                    else
                                                        tmp = (d2 + d4) * d1
                                                    end if
                                                    code = tmp
                                                end function
                                                
                                                assert d1 < d2 && d2 < d3 && d3 < d4;
                                                public static double code(double d1, double d2, double d3, double d4) {
                                                	double tmp;
                                                	if ((d3 <= -7.5e+123) || !(d3 <= 2e+69)) {
                                                		tmp = -d3 * d1;
                                                	} else {
                                                		tmp = (d2 + d4) * d1;
                                                	}
                                                	return tmp;
                                                }
                                                
                                                [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                                def code(d1, d2, d3, d4):
                                                	tmp = 0
                                                	if (d3 <= -7.5e+123) or not (d3 <= 2e+69):
                                                		tmp = -d3 * d1
                                                	else:
                                                		tmp = (d2 + d4) * d1
                                                	return tmp
                                                
                                                d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                                function code(d1, d2, d3, d4)
                                                	tmp = 0.0
                                                	if ((d3 <= -7.5e+123) || !(d3 <= 2e+69))
                                                		tmp = Float64(Float64(-d3) * d1);
                                                	else
                                                		tmp = Float64(Float64(d2 + d4) * d1);
                                                	end
                                                	return tmp
                                                end
                                                
                                                d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                                function tmp_2 = code(d1, d2, d3, d4)
                                                	tmp = 0.0;
                                                	if ((d3 <= -7.5e+123) || ~((d3 <= 2e+69)))
                                                		tmp = -d3 * d1;
                                                	else
                                                		tmp = (d2 + d4) * d1;
                                                	end
                                                	tmp_2 = tmp;
                                                end
                                                
                                                NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -7.5e+123], N[Not[LessEqual[d3, 2e+69]], $MachinePrecision]], N[((-d3) * d1), $MachinePrecision], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;d3 \leq -7.5 \cdot 10^{+123} \lor \neg \left(d3 \leq 2 \cdot 10^{+69}\right):\\
                                                \;\;\;\;\left(-d3\right) \cdot d1\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\left(d2 + d4\right) \cdot d1\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if d3 < -7.4999999999999999e123 or 2.0000000000000001e69 < d3

                                                  1. Initial program 87.5%

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

                                                    \[\leadsto \color{blue}{-1 \cdot \left(d1 \cdot d3\right)} \]
                                                  4. Step-by-step derivation
                                                    1. Applied rewrites74.4%

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

                                                    if -7.4999999999999999e123 < d3 < 2.0000000000000001e69

                                                    1. Initial program 91.4%

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

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

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

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

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

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

                                                      Alternative 8: 53.6% accurate, 1.5× speedup?

                                                      \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d2 \leq -1.48 \cdot 10^{+35}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{elif}\;d2 \leq -4 \cdot 10^{-294}:\\ \;\;\;\;\left(-d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
                                                      NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                      (FPCore (d1 d2 d3 d4)
                                                       :precision binary64
                                                       (if (<= d2 -1.48e+35) (* d2 d1) (if (<= d2 -4e-294) (* (- d3) d1) (* d4 d1))))
                                                      assert(d1 < d2 && d2 < d3 && d3 < d4);
                                                      double code(double d1, double d2, double d3, double d4) {
                                                      	double tmp;
                                                      	if (d2 <= -1.48e+35) {
                                                      		tmp = d2 * d1;
                                                      	} else if (d2 <= -4e-294) {
                                                      		tmp = -d3 * d1;
                                                      	} else {
                                                      		tmp = d4 * d1;
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                      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.48d+35)) then
                                                              tmp = d2 * d1
                                                          else if (d2 <= (-4d-294)) then
                                                              tmp = -d3 * d1
                                                          else
                                                              tmp = d4 * d1
                                                          end if
                                                          code = tmp
                                                      end function
                                                      
                                                      assert d1 < d2 && d2 < d3 && d3 < d4;
                                                      public static double code(double d1, double d2, double d3, double d4) {
                                                      	double tmp;
                                                      	if (d2 <= -1.48e+35) {
                                                      		tmp = d2 * d1;
                                                      	} else if (d2 <= -4e-294) {
                                                      		tmp = -d3 * d1;
                                                      	} else {
                                                      		tmp = d4 * d1;
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                                      def code(d1, d2, d3, d4):
                                                      	tmp = 0
                                                      	if d2 <= -1.48e+35:
                                                      		tmp = d2 * d1
                                                      	elif d2 <= -4e-294:
                                                      		tmp = -d3 * d1
                                                      	else:
                                                      		tmp = d4 * d1
                                                      	return tmp
                                                      
                                                      d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                                      function code(d1, d2, d3, d4)
                                                      	tmp = 0.0
                                                      	if (d2 <= -1.48e+35)
                                                      		tmp = Float64(d2 * d1);
                                                      	elseif (d2 <= -4e-294)
                                                      		tmp = Float64(Float64(-d3) * d1);
                                                      	else
                                                      		tmp = Float64(d4 * d1);
                                                      	end
                                                      	return tmp
                                                      end
                                                      
                                                      d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                                      function tmp_2 = code(d1, d2, d3, d4)
                                                      	tmp = 0.0;
                                                      	if (d2 <= -1.48e+35)
                                                      		tmp = d2 * d1;
                                                      	elseif (d2 <= -4e-294)
                                                      		tmp = -d3 * d1;
                                                      	else
                                                      		tmp = d4 * d1;
                                                      	end
                                                      	tmp_2 = tmp;
                                                      end
                                                      
                                                      NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                      code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.48e+35], N[(d2 * d1), $MachinePrecision], If[LessEqual[d2, -4e-294], N[((-d3) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
                                                      
                                                      \begin{array}{l}
                                                      [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                                      \\
                                                      \begin{array}{l}
                                                      \mathbf{if}\;d2 \leq -1.48 \cdot 10^{+35}:\\
                                                      \;\;\;\;d2 \cdot d1\\
                                                      
                                                      \mathbf{elif}\;d2 \leq -4 \cdot 10^{-294}:\\
                                                      \;\;\;\;\left(-d3\right) \cdot d1\\
                                                      
                                                      \mathbf{else}:\\
                                                      \;\;\;\;d4 \cdot d1\\
                                                      
                                                      
                                                      \end{array}
                                                      \end{array}
                                                      
                                                      Derivation
                                                      1. Split input into 3 regimes
                                                      2. if d2 < -1.48000000000000003e35

                                                        1. Initial program 85.9%

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

                                                          \[\leadsto \color{blue}{d1 \cdot d2} \]
                                                        4. Step-by-step derivation
                                                          1. Applied rewrites61.0%

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

                                                          if -1.48000000000000003e35 < d2 < -4.00000000000000007e-294

                                                          1. Initial program 94.1%

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

                                                            \[\leadsto \color{blue}{-1 \cdot \left(d1 \cdot d3\right)} \]
                                                          4. Step-by-step derivation
                                                            1. Applied rewrites50.9%

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

                                                            if -4.00000000000000007e-294 < d2

                                                            1. Initial program 90.2%

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

                                                              \[\leadsto \color{blue}{d1 \cdot d4} \]
                                                            4. Step-by-step derivation
                                                              1. Applied rewrites34.2%

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

                                                            Alternative 9: 52.2% accurate, 1.5× speedup?

                                                            \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d2 \leq -6 \cdot 10^{-30}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{elif}\;d2 \leq 4 \cdot 10^{-202}:\\ \;\;\;\;\left(-d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
                                                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                            (FPCore (d1 d2 d3 d4)
                                                             :precision binary64
                                                             (if (<= d2 -6e-30) (* d2 d1) (if (<= d2 4e-202) (* (- d1) d1) (* d4 d1))))
                                                            assert(d1 < d2 && d2 < d3 && d3 < d4);
                                                            double code(double d1, double d2, double d3, double d4) {
                                                            	double tmp;
                                                            	if (d2 <= -6e-30) {
                                                            		tmp = d2 * d1;
                                                            	} else if (d2 <= 4e-202) {
                                                            		tmp = -d1 * d1;
                                                            	} else {
                                                            		tmp = d4 * d1;
                                                            	}
                                                            	return tmp;
                                                            }
                                                            
                                                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                            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 <= (-6d-30)) then
                                                                    tmp = d2 * d1
                                                                else if (d2 <= 4d-202) then
                                                                    tmp = -d1 * d1
                                                                else
                                                                    tmp = d4 * d1
                                                                end if
                                                                code = tmp
                                                            end function
                                                            
                                                            assert d1 < d2 && d2 < d3 && d3 < d4;
                                                            public static double code(double d1, double d2, double d3, double d4) {
                                                            	double tmp;
                                                            	if (d2 <= -6e-30) {
                                                            		tmp = d2 * d1;
                                                            	} else if (d2 <= 4e-202) {
                                                            		tmp = -d1 * d1;
                                                            	} else {
                                                            		tmp = d4 * d1;
                                                            	}
                                                            	return tmp;
                                                            }
                                                            
                                                            [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                                            def code(d1, d2, d3, d4):
                                                            	tmp = 0
                                                            	if d2 <= -6e-30:
                                                            		tmp = d2 * d1
                                                            	elif d2 <= 4e-202:
                                                            		tmp = -d1 * d1
                                                            	else:
                                                            		tmp = d4 * d1
                                                            	return tmp
                                                            
                                                            d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                                            function code(d1, d2, d3, d4)
                                                            	tmp = 0.0
                                                            	if (d2 <= -6e-30)
                                                            		tmp = Float64(d2 * d1);
                                                            	elseif (d2 <= 4e-202)
                                                            		tmp = Float64(Float64(-d1) * d1);
                                                            	else
                                                            		tmp = Float64(d4 * d1);
                                                            	end
                                                            	return tmp
                                                            end
                                                            
                                                            d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                                            function tmp_2 = code(d1, d2, d3, d4)
                                                            	tmp = 0.0;
                                                            	if (d2 <= -6e-30)
                                                            		tmp = d2 * d1;
                                                            	elseif (d2 <= 4e-202)
                                                            		tmp = -d1 * d1;
                                                            	else
                                                            		tmp = d4 * d1;
                                                            	end
                                                            	tmp_2 = tmp;
                                                            end
                                                            
                                                            NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                            code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -6e-30], N[(d2 * d1), $MachinePrecision], If[LessEqual[d2, 4e-202], N[((-d1) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
                                                            
                                                            \begin{array}{l}
                                                            [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                                            \\
                                                            \begin{array}{l}
                                                            \mathbf{if}\;d2 \leq -6 \cdot 10^{-30}:\\
                                                            \;\;\;\;d2 \cdot d1\\
                                                            
                                                            \mathbf{elif}\;d2 \leq 4 \cdot 10^{-202}:\\
                                                            \;\;\;\;\left(-d1\right) \cdot d1\\
                                                            
                                                            \mathbf{else}:\\
                                                            \;\;\;\;d4 \cdot d1\\
                                                            
                                                            
                                                            \end{array}
                                                            \end{array}
                                                            
                                                            Derivation
                                                            1. Split input into 3 regimes
                                                            2. if d2 < -5.9999999999999998e-30

                                                              1. Initial program 86.9%

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

                                                                \[\leadsto \color{blue}{d1 \cdot d2} \]
                                                              4. Step-by-step derivation
                                                                1. Applied rewrites58.2%

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

                                                                if -5.9999999999999998e-30 < d2 < 4.0000000000000001e-202

                                                                1. Initial program 94.1%

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

                                                                  \[\leadsto \color{blue}{-1 \cdot {d1}^{2}} \]
                                                                4. Step-by-step derivation
                                                                  1. Applied rewrites38.0%

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

                                                                  if 4.0000000000000001e-202 < d2

                                                                  1. Initial program 89.0%

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

                                                                    \[\leadsto \color{blue}{d1 \cdot d4} \]
                                                                  4. Step-by-step derivation
                                                                    1. Applied rewrites32.6%

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

                                                                  Alternative 10: 94.4% accurate, 1.7× speedup?

                                                                  \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d2 \leq -1.8 \cdot 10^{-8}:\\ \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 - d1\right) - d3\right) \cdot d1\\ \end{array} \end{array} \]
                                                                  NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                  (FPCore (d1 d2 d3 d4)
                                                                   :precision binary64
                                                                   (if (<= d2 -1.8e-8) (* (- (- d2 d3) d1) d1) (* (- (- d4 d1) d3) d1)))
                                                                  assert(d1 < d2 && d2 < d3 && d3 < d4);
                                                                  double code(double d1, double d2, double d3, double d4) {
                                                                  	double tmp;
                                                                  	if (d2 <= -1.8e-8) {
                                                                  		tmp = ((d2 - d3) - d1) * d1;
                                                                  	} else {
                                                                  		tmp = ((d4 - d1) - d3) * d1;
                                                                  	}
                                                                  	return tmp;
                                                                  }
                                                                  
                                                                  NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                  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.8d-8)) then
                                                                          tmp = ((d2 - d3) - d1) * d1
                                                                      else
                                                                          tmp = ((d4 - d1) - d3) * d1
                                                                      end if
                                                                      code = tmp
                                                                  end function
                                                                  
                                                                  assert d1 < d2 && d2 < d3 && d3 < d4;
                                                                  public static double code(double d1, double d2, double d3, double d4) {
                                                                  	double tmp;
                                                                  	if (d2 <= -1.8e-8) {
                                                                  		tmp = ((d2 - d3) - d1) * d1;
                                                                  	} else {
                                                                  		tmp = ((d4 - d1) - d3) * d1;
                                                                  	}
                                                                  	return tmp;
                                                                  }
                                                                  
                                                                  [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                                                  def code(d1, d2, d3, d4):
                                                                  	tmp = 0
                                                                  	if d2 <= -1.8e-8:
                                                                  		tmp = ((d2 - d3) - d1) * d1
                                                                  	else:
                                                                  		tmp = ((d4 - d1) - d3) * d1
                                                                  	return tmp
                                                                  
                                                                  d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                                                  function code(d1, d2, d3, d4)
                                                                  	tmp = 0.0
                                                                  	if (d2 <= -1.8e-8)
                                                                  		tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1);
                                                                  	else
                                                                  		tmp = Float64(Float64(Float64(d4 - d1) - d3) * d1);
                                                                  	end
                                                                  	return tmp
                                                                  end
                                                                  
                                                                  d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                                                  function tmp_2 = code(d1, d2, d3, d4)
                                                                  	tmp = 0.0;
                                                                  	if (d2 <= -1.8e-8)
                                                                  		tmp = ((d2 - d3) - d1) * d1;
                                                                  	else
                                                                  		tmp = ((d4 - d1) - d3) * d1;
                                                                  	end
                                                                  	tmp_2 = tmp;
                                                                  end
                                                                  
                                                                  NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                  code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.8e-8], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
                                                                  
                                                                  \begin{array}{l}
                                                                  [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                                                  \\
                                                                  \begin{array}{l}
                                                                  \mathbf{if}\;d2 \leq -1.8 \cdot 10^{-8}:\\
                                                                  \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
                                                                  
                                                                  \mathbf{else}:\\
                                                                  \;\;\;\;\left(\left(d4 - d1\right) - d3\right) \cdot d1\\
                                                                  
                                                                  
                                                                  \end{array}
                                                                  \end{array}
                                                                  
                                                                  Derivation
                                                                  1. Split input into 2 regimes
                                                                  2. if d2 < -1.79999999999999991e-8

                                                                    1. Initial program 86.5%

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

                                                                      \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                                                                    4. Step-by-step derivation
                                                                      1. Applied rewrites88.8%

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

                                                                      if -1.79999999999999991e-8 < d2

                                                                      1. Initial program 91.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. Applied rewrites85.7%

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

                                                                      Alternative 11: 93.5% accurate, 1.7× speedup?

                                                                      \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d4 \leq 1.75 \cdot 10^{+24}:\\ \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\ \end{array} \end{array} \]
                                                                      NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                      (FPCore (d1 d2 d3 d4)
                                                                       :precision binary64
                                                                       (if (<= d4 1.75e+24) (* (- (- d2 d3) d1) d1) (* (- (+ d4 d2) d3) d1)))
                                                                      assert(d1 < d2 && d2 < d3 && d3 < d4);
                                                                      double code(double d1, double d2, double d3, double d4) {
                                                                      	double tmp;
                                                                      	if (d4 <= 1.75e+24) {
                                                                      		tmp = ((d2 - d3) - d1) * d1;
                                                                      	} else {
                                                                      		tmp = ((d4 + d2) - d3) * d1;
                                                                      	}
                                                                      	return tmp;
                                                                      }
                                                                      
                                                                      NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                      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.75d+24) then
                                                                              tmp = ((d2 - d3) - d1) * d1
                                                                          else
                                                                              tmp = ((d4 + d2) - d3) * d1
                                                                          end if
                                                                          code = tmp
                                                                      end function
                                                                      
                                                                      assert d1 < d2 && d2 < d3 && d3 < d4;
                                                                      public static double code(double d1, double d2, double d3, double d4) {
                                                                      	double tmp;
                                                                      	if (d4 <= 1.75e+24) {
                                                                      		tmp = ((d2 - d3) - d1) * d1;
                                                                      	} else {
                                                                      		tmp = ((d4 + d2) - d3) * d1;
                                                                      	}
                                                                      	return tmp;
                                                                      }
                                                                      
                                                                      [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                                                      def code(d1, d2, d3, d4):
                                                                      	tmp = 0
                                                                      	if d4 <= 1.75e+24:
                                                                      		tmp = ((d2 - d3) - d1) * d1
                                                                      	else:
                                                                      		tmp = ((d4 + d2) - d3) * d1
                                                                      	return tmp
                                                                      
                                                                      d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                                                      function code(d1, d2, d3, d4)
                                                                      	tmp = 0.0
                                                                      	if (d4 <= 1.75e+24)
                                                                      		tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1);
                                                                      	else
                                                                      		tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1);
                                                                      	end
                                                                      	return tmp
                                                                      end
                                                                      
                                                                      d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                                                      function tmp_2 = code(d1, d2, d3, d4)
                                                                      	tmp = 0.0;
                                                                      	if (d4 <= 1.75e+24)
                                                                      		tmp = ((d2 - d3) - d1) * d1;
                                                                      	else
                                                                      		tmp = ((d4 + d2) - d3) * d1;
                                                                      	end
                                                                      	tmp_2 = tmp;
                                                                      end
                                                                      
                                                                      NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                      code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.75e+24], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
                                                                      
                                                                      \begin{array}{l}
                                                                      [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                                                      \\
                                                                      \begin{array}{l}
                                                                      \mathbf{if}\;d4 \leq 1.75 \cdot 10^{+24}:\\
                                                                      \;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
                                                                      
                                                                      \mathbf{else}:\\
                                                                      \;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
                                                                      
                                                                      
                                                                      \end{array}
                                                                      \end{array}
                                                                      
                                                                      Derivation
                                                                      1. Split input into 2 regimes
                                                                      2. if d4 < 1.7500000000000001e24

                                                                        1. Initial program 89.6%

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

                                                                          \[\leadsto \color{blue}{d1 \cdot d2 - \left(d1 \cdot d3 + {d1}^{2}\right)} \]
                                                                        4. Step-by-step derivation
                                                                          1. Applied rewrites84.3%

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

                                                                          if 1.7500000000000001e24 < d4

                                                                          1. Initial program 92.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. Applied rewrites90.1%

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

                                                                          Alternative 12: 74.4% accurate, 2.0× speedup?

                                                                          \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d2 \leq -1.8 \cdot 10^{-8}:\\ \;\;\;\;\left(d2 - d3\right) \cdot d1\\ \mathbf{else}:\\ \;\;\;\;\left(d4 - d3\right) \cdot d1\\ \end{array} \end{array} \]
                                                                          NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                          (FPCore (d1 d2 d3 d4)
                                                                           :precision binary64
                                                                           (if (<= d2 -1.8e-8) (* (- d2 d3) d1) (* (- d4 d3) d1)))
                                                                          assert(d1 < d2 && d2 < d3 && d3 < d4);
                                                                          double code(double d1, double d2, double d3, double d4) {
                                                                          	double tmp;
                                                                          	if (d2 <= -1.8e-8) {
                                                                          		tmp = (d2 - d3) * d1;
                                                                          	} else {
                                                                          		tmp = (d4 - d3) * d1;
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                          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.8d-8)) then
                                                                                  tmp = (d2 - d3) * d1
                                                                              else
                                                                                  tmp = (d4 - d3) * d1
                                                                              end if
                                                                              code = tmp
                                                                          end function
                                                                          
                                                                          assert d1 < d2 && d2 < d3 && d3 < d4;
                                                                          public static double code(double d1, double d2, double d3, double d4) {
                                                                          	double tmp;
                                                                          	if (d2 <= -1.8e-8) {
                                                                          		tmp = (d2 - d3) * d1;
                                                                          	} else {
                                                                          		tmp = (d4 - d3) * d1;
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                                                          def code(d1, d2, d3, d4):
                                                                          	tmp = 0
                                                                          	if d2 <= -1.8e-8:
                                                                          		tmp = (d2 - d3) * d1
                                                                          	else:
                                                                          		tmp = (d4 - d3) * d1
                                                                          	return tmp
                                                                          
                                                                          d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                                                          function code(d1, d2, d3, d4)
                                                                          	tmp = 0.0
                                                                          	if (d2 <= -1.8e-8)
                                                                          		tmp = Float64(Float64(d2 - d3) * d1);
                                                                          	else
                                                                          		tmp = Float64(Float64(d4 - d3) * d1);
                                                                          	end
                                                                          	return tmp
                                                                          end
                                                                          
                                                                          d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                                                          function tmp_2 = code(d1, d2, d3, d4)
                                                                          	tmp = 0.0;
                                                                          	if (d2 <= -1.8e-8)
                                                                          		tmp = (d2 - d3) * d1;
                                                                          	else
                                                                          		tmp = (d4 - d3) * d1;
                                                                          	end
                                                                          	tmp_2 = tmp;
                                                                          end
                                                                          
                                                                          NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                          code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.8e-8], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]
                                                                          
                                                                          \begin{array}{l}
                                                                          [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                                                          \\
                                                                          \begin{array}{l}
                                                                          \mathbf{if}\;d2 \leq -1.8 \cdot 10^{-8}:\\
                                                                          \;\;\;\;\left(d2 - d3\right) \cdot d1\\
                                                                          
                                                                          \mathbf{else}:\\
                                                                          \;\;\;\;\left(d4 - d3\right) \cdot d1\\
                                                                          
                                                                          
                                                                          \end{array}
                                                                          \end{array}
                                                                          
                                                                          Derivation
                                                                          1. Split input into 2 regimes
                                                                          2. if d2 < -1.79999999999999991e-8

                                                                            1. Initial program 86.5%

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

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

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

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

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

                                                                                if -1.79999999999999991e-8 < d2

                                                                                1. Initial program 91.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. Applied rewrites85.7%

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

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

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

                                                                                  Alternative 13: 49.6% accurate, 2.5× speedup?

                                                                                  \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ \begin{array}{l} \mathbf{if}\;d2 \leq -1.8 \cdot 10^{-52}:\\ \;\;\;\;d2 \cdot d1\\ \mathbf{else}:\\ \;\;\;\;d4 \cdot d1\\ \end{array} \end{array} \]
                                                                                  NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                                  (FPCore (d1 d2 d3 d4)
                                                                                   :precision binary64
                                                                                   (if (<= d2 -1.8e-52) (* d2 d1) (* d4 d1)))
                                                                                  assert(d1 < d2 && d2 < d3 && d3 < d4);
                                                                                  double code(double d1, double d2, double d3, double d4) {
                                                                                  	double tmp;
                                                                                  	if (d2 <= -1.8e-52) {
                                                                                  		tmp = d2 * d1;
                                                                                  	} else {
                                                                                  		tmp = d4 * d1;
                                                                                  	}
                                                                                  	return tmp;
                                                                                  }
                                                                                  
                                                                                  NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                                  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.8d-52)) then
                                                                                          tmp = d2 * d1
                                                                                      else
                                                                                          tmp = d4 * d1
                                                                                      end if
                                                                                      code = tmp
                                                                                  end function
                                                                                  
                                                                                  assert d1 < d2 && d2 < d3 && d3 < d4;
                                                                                  public static double code(double d1, double d2, double d3, double d4) {
                                                                                  	double tmp;
                                                                                  	if (d2 <= -1.8e-52) {
                                                                                  		tmp = d2 * d1;
                                                                                  	} else {
                                                                                  		tmp = d4 * d1;
                                                                                  	}
                                                                                  	return tmp;
                                                                                  }
                                                                                  
                                                                                  [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                                                                  def code(d1, d2, d3, d4):
                                                                                  	tmp = 0
                                                                                  	if d2 <= -1.8e-52:
                                                                                  		tmp = d2 * d1
                                                                                  	else:
                                                                                  		tmp = d4 * d1
                                                                                  	return tmp
                                                                                  
                                                                                  d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                                                                  function code(d1, d2, d3, d4)
                                                                                  	tmp = 0.0
                                                                                  	if (d2 <= -1.8e-52)
                                                                                  		tmp = Float64(d2 * d1);
                                                                                  	else
                                                                                  		tmp = Float64(d4 * d1);
                                                                                  	end
                                                                                  	return tmp
                                                                                  end
                                                                                  
                                                                                  d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                                                                  function tmp_2 = code(d1, d2, d3, d4)
                                                                                  	tmp = 0.0;
                                                                                  	if (d2 <= -1.8e-52)
                                                                                  		tmp = d2 * d1;
                                                                                  	else
                                                                                  		tmp = d4 * d1;
                                                                                  	end
                                                                                  	tmp_2 = tmp;
                                                                                  end
                                                                                  
                                                                                  NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                                  code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.8e-52], N[(d2 * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
                                                                                  
                                                                                  \begin{array}{l}
                                                                                  [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                                                                  \\
                                                                                  \begin{array}{l}
                                                                                  \mathbf{if}\;d2 \leq -1.8 \cdot 10^{-52}:\\
                                                                                  \;\;\;\;d2 \cdot d1\\
                                                                                  
                                                                                  \mathbf{else}:\\
                                                                                  \;\;\;\;d4 \cdot d1\\
                                                                                  
                                                                                  
                                                                                  \end{array}
                                                                                  \end{array}
                                                                                  
                                                                                  Derivation
                                                                                  1. Split input into 2 regimes
                                                                                  2. if d2 < -1.79999999999999994e-52

                                                                                    1. Initial program 87.5%

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

                                                                                      \[\leadsto \color{blue}{d1 \cdot d2} \]
                                                                                    4. Step-by-step derivation
                                                                                      1. Applied rewrites56.0%

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

                                                                                      if -1.79999999999999994e-52 < d2

                                                                                      1. Initial program 91.2%

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

                                                                                        \[\leadsto \color{blue}{d1 \cdot d4} \]
                                                                                      4. Step-by-step derivation
                                                                                        1. Applied rewrites33.1%

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

                                                                                      Alternative 14: 31.3% accurate, 5.0× speedup?

                                                                                      \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ d2 \cdot d1 \end{array} \]
                                                                                      NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                                      (FPCore (d1 d2 d3 d4) :precision binary64 (* d2 d1))
                                                                                      assert(d1 < d2 && d2 < d3 && d3 < d4);
                                                                                      double code(double d1, double d2, double d3, double d4) {
                                                                                      	return d2 * d1;
                                                                                      }
                                                                                      
                                                                                      NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                                      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 = d2 * d1
                                                                                      end function
                                                                                      
                                                                                      assert d1 < d2 && d2 < d3 && d3 < d4;
                                                                                      public static double code(double d1, double d2, double d3, double d4) {
                                                                                      	return d2 * d1;
                                                                                      }
                                                                                      
                                                                                      [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                                                                      def code(d1, d2, d3, d4):
                                                                                      	return d2 * d1
                                                                                      
                                                                                      d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                                                                      function code(d1, d2, d3, d4)
                                                                                      	return Float64(d2 * d1)
                                                                                      end
                                                                                      
                                                                                      d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                                                                      function tmp = code(d1, d2, d3, d4)
                                                                                      	tmp = d2 * d1;
                                                                                      end
                                                                                      
                                                                                      NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                                      code[d1_, d2_, d3_, d4_] := N[(d2 * d1), $MachinePrecision]
                                                                                      
                                                                                      \begin{array}{l}
                                                                                      [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                                                                      \\
                                                                                      d2 \cdot d1
                                                                                      \end{array}
                                                                                      
                                                                                      Derivation
                                                                                      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 d2 around inf

                                                                                        \[\leadsto \color{blue}{d1 \cdot d2} \]
                                                                                      4. Step-by-step derivation
                                                                                        1. Applied rewrites32.5%

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

                                                                                        Alternative 15: 7.3% accurate, 5.0× speedup?

                                                                                        \[\begin{array}{l} [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\ \\ d1 \cdot d1 \end{array} \]
                                                                                        NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                                        (FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d1))
                                                                                        assert(d1 < d2 && d2 < d3 && d3 < d4);
                                                                                        double code(double d1, double d2, double d3, double d4) {
                                                                                        	return d1 * d1;
                                                                                        }
                                                                                        
                                                                                        NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                                        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 * d1
                                                                                        end function
                                                                                        
                                                                                        assert d1 < d2 && d2 < d3 && d3 < d4;
                                                                                        public static double code(double d1, double d2, double d3, double d4) {
                                                                                        	return d1 * d1;
                                                                                        }
                                                                                        
                                                                                        [d1, d2, d3, d4] = sort([d1, d2, d3, d4])
                                                                                        def code(d1, d2, d3, d4):
                                                                                        	return d1 * d1
                                                                                        
                                                                                        d1, d2, d3, d4 = sort([d1, d2, d3, d4])
                                                                                        function code(d1, d2, d3, d4)
                                                                                        	return Float64(d1 * d1)
                                                                                        end
                                                                                        
                                                                                        d1, d2, d3, d4 = num2cell(sort([d1, d2, d3, d4])){:}
                                                                                        function tmp = code(d1, d2, d3, d4)
                                                                                        	tmp = d1 * d1;
                                                                                        end
                                                                                        
                                                                                        NOTE: d1, d2, d3, and d4 should be sorted in increasing order before calling this function.
                                                                                        code[d1_, d2_, d3_, d4_] := N[(d1 * d1), $MachinePrecision]
                                                                                        
                                                                                        \begin{array}{l}
                                                                                        [d1, d2, d3, d4] = \mathsf{sort}([d1, d2, d3, d4])\\
                                                                                        \\
                                                                                        d1 \cdot d1
                                                                                        \end{array}
                                                                                        
                                                                                        Derivation
                                                                                        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 inf

                                                                                          \[\leadsto \color{blue}{-1 \cdot {d1}^{2}} \]
                                                                                        4. Step-by-step derivation
                                                                                          1. Applied rewrites29.5%

                                                                                            \[\leadsto \color{blue}{\left(-d1\right) \cdot d1} \]
                                                                                          2. Step-by-step derivation
                                                                                            1. Applied rewrites6.1%

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