FastMath dist4

Percentage Accurate: 88.6% → 100.0%
Time: 2.5s
Alternatives: 12
Speedup: 1.8×

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}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 88.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: 100.0% accurate, 1.8× speedup?

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

\\
d1 \cdot \left(\left(d4 - \left(d3 - d2\right)\right) - d1\right)
\end{array}
Derivation
  1. Initial program 88.6%

    \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
  2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
    18. sub-negate-revN/A

      \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
    19. sub-flip-reverseN/A

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

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

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

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

Alternative 2: 92.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d1 \leq -1.9 \cdot 10^{+74}:\\ \;\;\;\;\left(d2 - \left(d1 - d4\right)\right) \cdot d1\\ \mathbf{elif}\;d1 \leq 1.75 \cdot 10^{+81}:\\ \;\;\;\;\mathsf{fma}\left(d4 - d3, d1, d1 \cdot d2\right)\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(\left(d4 - d3\right) - d1\right)\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3 d4)
 :precision binary64
 (if (<= d1 -1.9e+74)
   (* (- d2 (- d1 d4)) d1)
   (if (<= d1 1.75e+81) (fma (- d4 d3) d1 (* d1 d2)) (* d1 (- (- d4 d3) d1)))))
double code(double d1, double d2, double d3, double d4) {
	double tmp;
	if (d1 <= -1.9e+74) {
		tmp = (d2 - (d1 - d4)) * d1;
	} else if (d1 <= 1.75e+81) {
		tmp = fma((d4 - d3), d1, (d1 * d2));
	} else {
		tmp = d1 * ((d4 - d3) - d1);
	}
	return tmp;
}
function code(d1, d2, d3, d4)
	tmp = 0.0
	if (d1 <= -1.9e+74)
		tmp = Float64(Float64(d2 - Float64(d1 - d4)) * d1);
	elseif (d1 <= 1.75e+81)
		tmp = fma(Float64(d4 - d3), d1, Float64(d1 * d2));
	else
		tmp = Float64(d1 * Float64(Float64(d4 - d3) - d1));
	end
	return tmp
end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.9e+74], N[(N[(d2 - N[(d1 - d4), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 1.75e+81], N[(N[(d4 - d3), $MachinePrecision] * d1 + N[(d1 * d2), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.9 \cdot 10^{+74}:\\
\;\;\;\;\left(d2 - \left(d1 - d4\right)\right) \cdot d1\\

\mathbf{elif}\;d1 \leq 1.75 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(d4 - d3, d1, d1 \cdot d2\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d1 < -1.8999999999999999e74

    1. Initial program 88.6%

      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
    2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
      18. sub-negate-revN/A

        \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
      19. sub-flip-reverseN/A

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

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

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

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

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

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

        \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
    6. Applied rewrites77.3%

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

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

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

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

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

        \[\leadsto \left(\left(d2 + d4\right) - d1\right) \cdot d1 \]
      6. associate--l+N/A

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

        \[\leadsto \left(d2 - \color{blue}{\left(\mathsf{neg}\left(\left(d4 - d1\right)\right)\right)}\right) \cdot d1 \]
      8. sub-negate-revN/A

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

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

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

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

    if -1.8999999999999999e74 < d1 < 1.75e81

    1. Initial program 88.6%

      \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
    2. Applied rewrites97.2%

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

      \[\leadsto \mathsf{fma}\left(d4 - d3, d1, d1 \cdot \color{blue}{d2}\right) \]
    4. Step-by-step derivation
      1. Applied rewrites80.6%

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

      if 1.75e81 < d1

      1. Initial program 88.6%

        \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
      2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
        18. sub-negate-revN/A

          \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
        19. sub-flip-reverseN/A

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

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

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

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

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

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

      Alternative 3: 92.5% accurate, 1.2× speedup?

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

        1. Initial program 88.6%

          \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
        2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
          18. sub-negate-revN/A

            \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
          19. sub-flip-reverseN/A

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

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

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

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

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

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

            \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
        6. Applied rewrites77.3%

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

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

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

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

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

            \[\leadsto \left(\left(d2 + d4\right) - d1\right) \cdot d1 \]
          6. associate--l+N/A

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

            \[\leadsto \left(d2 - \color{blue}{\left(\mathsf{neg}\left(\left(d4 - d1\right)\right)\right)}\right) \cdot d1 \]
          8. sub-negate-revN/A

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

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

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

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

        if -1.8999999999999999e74 < d1 < 1.75e81

        1. Initial program 88.6%

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

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

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

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

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

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

        if 1.75e81 < d1

        1. Initial program 88.6%

          \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
        2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
          18. sub-negate-revN/A

            \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
          19. sub-flip-reverseN/A

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

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

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

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

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

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

        Alternative 4: 84.4% accurate, 1.6× speedup?

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

          1. Initial program 88.6%

            \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
          2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
            18. sub-negate-revN/A

              \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
            19. sub-flip-reverseN/A

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

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

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

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

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

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

              \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
          6. Applied rewrites77.3%

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

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

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

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

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

              \[\leadsto \left(\left(d2 + d4\right) - d1\right) \cdot d1 \]
            6. associate--l+N/A

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

              \[\leadsto \left(d2 - \color{blue}{\left(\mathsf{neg}\left(\left(d4 - d1\right)\right)\right)}\right) \cdot d1 \]
            8. sub-negate-revN/A

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

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

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

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

          if -2.94999999999999984e88 < d2

          1. Initial program 88.6%

            \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
          2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
            18. sub-negate-revN/A

              \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
            19. sub-flip-reverseN/A

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

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

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

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

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

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

          Alternative 5: 82.0% accurate, 1.6× speedup?

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

            1. Initial program 88.6%

              \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
            2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
              18. sub-negate-revN/A

                \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
              19. sub-flip-reverseN/A

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

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

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

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

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

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

                \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
            6. Applied rewrites77.3%

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

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

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

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

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

                \[\leadsto \left(\left(d2 + d4\right) - d1\right) \cdot d1 \]
              6. associate--l+N/A

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

                \[\leadsto \left(d2 - \color{blue}{\left(\mathsf{neg}\left(\left(d4 - d1\right)\right)\right)}\right) \cdot d1 \]
              8. sub-negate-revN/A

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

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

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

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

              \[\leadsto \left(d2 - \color{blue}{d1}\right) \cdot d1 \]
            10. Step-by-step derivation
              1. lower--.f6454.1

                \[\leadsto \left(d2 - d1\right) \cdot d1 \]
            11. Applied rewrites54.1%

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

            if -7.50000000000000031e88 < d2

            1. Initial program 88.6%

              \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
            2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
              18. sub-negate-revN/A

                \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
              19. sub-flip-reverseN/A

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

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

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

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

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

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

            Alternative 6: 64.4% accurate, 1.2× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := d1 \cdot \left(d2 - d3\right)\\ \mathbf{if}\;d4 \leq -3.7 \cdot 10^{-278}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d4 \leq 2.6 \cdot 10^{-119}:\\ \;\;\;\;\left(d2 - d1\right) \cdot d1\\ \mathbf{elif}\;d4 \leq 3.7 \cdot 10^{-23}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d4 - d1\right)\\ \end{array} \end{array} \]
            (FPCore (d1 d2 d3 d4)
             :precision binary64
             (let* ((t_0 (* d1 (- d2 d3))))
               (if (<= d4 -3.7e-278)
                 t_0
                 (if (<= d4 2.6e-119)
                   (* (- d2 d1) d1)
                   (if (<= d4 3.7e-23) t_0 (* d1 (- d4 d1)))))))
            double code(double d1, double d2, double d3, double d4) {
            	double t_0 = d1 * (d2 - d3);
            	double tmp;
            	if (d4 <= -3.7e-278) {
            		tmp = t_0;
            	} else if (d4 <= 2.6e-119) {
            		tmp = (d2 - d1) * d1;
            	} else if (d4 <= 3.7e-23) {
            		tmp = t_0;
            	} else {
            		tmp = d1 * (d4 - d1);
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(d1, d2, d3, d4)
            use fmin_fmax_functions
                real(8), intent (in) :: d1
                real(8), intent (in) :: d2
                real(8), intent (in) :: d3
                real(8), intent (in) :: d4
                real(8) :: t_0
                real(8) :: tmp
                t_0 = d1 * (d2 - d3)
                if (d4 <= (-3.7d-278)) then
                    tmp = t_0
                else if (d4 <= 2.6d-119) then
                    tmp = (d2 - d1) * d1
                else if (d4 <= 3.7d-23) then
                    tmp = t_0
                else
                    tmp = d1 * (d4 - d1)
                end if
                code = tmp
            end function
            
            public static double code(double d1, double d2, double d3, double d4) {
            	double t_0 = d1 * (d2 - d3);
            	double tmp;
            	if (d4 <= -3.7e-278) {
            		tmp = t_0;
            	} else if (d4 <= 2.6e-119) {
            		tmp = (d2 - d1) * d1;
            	} else if (d4 <= 3.7e-23) {
            		tmp = t_0;
            	} else {
            		tmp = d1 * (d4 - d1);
            	}
            	return tmp;
            }
            
            def code(d1, d2, d3, d4):
            	t_0 = d1 * (d2 - d3)
            	tmp = 0
            	if d4 <= -3.7e-278:
            		tmp = t_0
            	elif d4 <= 2.6e-119:
            		tmp = (d2 - d1) * d1
            	elif d4 <= 3.7e-23:
            		tmp = t_0
            	else:
            		tmp = d1 * (d4 - d1)
            	return tmp
            
            function code(d1, d2, d3, d4)
            	t_0 = Float64(d1 * Float64(d2 - d3))
            	tmp = 0.0
            	if (d4 <= -3.7e-278)
            		tmp = t_0;
            	elseif (d4 <= 2.6e-119)
            		tmp = Float64(Float64(d2 - d1) * d1);
            	elseif (d4 <= 3.7e-23)
            		tmp = t_0;
            	else
            		tmp = Float64(d1 * Float64(d4 - d1));
            	end
            	return tmp
            end
            
            function tmp_2 = code(d1, d2, d3, d4)
            	t_0 = d1 * (d2 - d3);
            	tmp = 0.0;
            	if (d4 <= -3.7e-278)
            		tmp = t_0;
            	elseif (d4 <= 2.6e-119)
            		tmp = (d2 - d1) * d1;
            	elseif (d4 <= 3.7e-23)
            		tmp = t_0;
            	else
            		tmp = d1 * (d4 - d1);
            	end
            	tmp_2 = tmp;
            end
            
            code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d4, -3.7e-278], t$95$0, If[LessEqual[d4, 2.6e-119], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d4, 3.7e-23], t$95$0, N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := d1 \cdot \left(d2 - d3\right)\\
            \mathbf{if}\;d4 \leq -3.7 \cdot 10^{-278}:\\
            \;\;\;\;t\_0\\
            
            \mathbf{elif}\;d4 \leq 2.6 \cdot 10^{-119}:\\
            \;\;\;\;\left(d2 - d1\right) \cdot d1\\
            
            \mathbf{elif}\;d4 \leq 3.7 \cdot 10^{-23}:\\
            \;\;\;\;t\_0\\
            
            \mathbf{else}:\\
            \;\;\;\;d1 \cdot \left(d4 - d1\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if d4 < -3.70000000000000022e-278 or 2.60000000000000012e-119 < d4 < 3.7000000000000003e-23

              1. Initial program 88.6%

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

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

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

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

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

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

                \[\leadsto d1 \cdot \left(d2 - \color{blue}{d3}\right) \]
              6. Step-by-step derivation
                1. lower--.f6456.8

                  \[\leadsto d1 \cdot \left(d2 - d3\right) \]
              7. Applied rewrites56.8%

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

              if -3.70000000000000022e-278 < d4 < 2.60000000000000012e-119

              1. Initial program 88.6%

                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
              2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
                18. sub-negate-revN/A

                  \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
                19. sub-flip-reverseN/A

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

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

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

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

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

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

                  \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
              6. Applied rewrites77.3%

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

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

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

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

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

                  \[\leadsto \left(\left(d2 + d4\right) - d1\right) \cdot d1 \]
                6. associate--l+N/A

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

                  \[\leadsto \left(d2 - \color{blue}{\left(\mathsf{neg}\left(\left(d4 - d1\right)\right)\right)}\right) \cdot d1 \]
                8. sub-negate-revN/A

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

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

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

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

                \[\leadsto \left(d2 - \color{blue}{d1}\right) \cdot d1 \]
              10. Step-by-step derivation
                1. lower--.f6454.1

                  \[\leadsto \left(d2 - d1\right) \cdot d1 \]
              11. Applied rewrites54.1%

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

              if 3.7000000000000003e-23 < d4

              1. Initial program 88.6%

                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
              2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
                18. sub-negate-revN/A

                  \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
                19. sub-flip-reverseN/A

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

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

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

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

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

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

                  \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
              6. Applied rewrites77.3%

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

                \[\leadsto d1 \cdot \left(d4 - \color{blue}{d1}\right) \]
              8. Step-by-step derivation
                1. lower--.f6453.8

                  \[\leadsto d1 \cdot \left(d4 - d1\right) \]
              9. Applied rewrites53.8%

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

            Alternative 7: 62.9% accurate, 2.0× speedup?

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

              1. Initial program 88.6%

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

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

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

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

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

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

                \[\leadsto d1 \cdot \left(d2 - \color{blue}{d3}\right) \]
              6. Step-by-step derivation
                1. lower--.f6456.8

                  \[\leadsto d1 \cdot \left(d2 - d3\right) \]
              7. Applied rewrites56.8%

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

              if -1.10000000000000003e-42 < d2

              1. Initial program 88.6%

                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
              2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
                18. sub-negate-revN/A

                  \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
                19. sub-flip-reverseN/A

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

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

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

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

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

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

                  \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
              6. Applied rewrites77.3%

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

                \[\leadsto d1 \cdot \left(d4 - \color{blue}{d1}\right) \]
              8. Step-by-step derivation
                1. lower--.f6453.8

                  \[\leadsto d1 \cdot \left(d4 - d1\right) \]
              9. Applied rewrites53.8%

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

            Alternative 8: 61.9% accurate, 2.0× speedup?

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

              1. Initial program 88.6%

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

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

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

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

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

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

                \[\leadsto d1 \cdot \left(d2 - \color{blue}{d3}\right) \]
              6. Step-by-step derivation
                1. lower--.f6456.8

                  \[\leadsto d1 \cdot \left(d2 - d3\right) \]
              7. Applied rewrites56.8%

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

              if -2.6e12 < d2

              1. Initial program 88.6%

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

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

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

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

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

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

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

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

              Alternative 9: 61.8% accurate, 2.0× speedup?

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

                1. Initial program 88.6%

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

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

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

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

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

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

                  \[\leadsto d1 \cdot \left(d2 - \color{blue}{d3}\right) \]
                6. Step-by-step derivation
                  1. lower--.f6456.8

                    \[\leadsto d1 \cdot \left(d2 - d3\right) \]
                7. Applied rewrites56.8%

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

                if 1.45e122 < d4

                1. Initial program 88.6%

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

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

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

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

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

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

                  \[\leadsto \color{blue}{d1 \cdot d4} \]
                6. Step-by-step derivation
                  1. lower-*.f6431.2

                    \[\leadsto d1 \cdot \color{blue}{d4} \]
                7. Applied rewrites31.2%

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

              Alternative 10: 39.9% accurate, 1.7× speedup?

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

                1. Initial program 88.6%

                  \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
                  18. sub-negate-revN/A

                    \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
                  19. sub-flip-reverseN/A

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

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

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

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

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

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

                    \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
                6. Applied rewrites77.3%

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

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

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

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

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

                    \[\leadsto \left(\left(d2 + d4\right) - d1\right) \cdot d1 \]
                  6. associate--l+N/A

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

                    \[\leadsto \left(d2 - \color{blue}{\left(\mathsf{neg}\left(\left(d4 - d1\right)\right)\right)}\right) \cdot d1 \]
                  8. sub-negate-revN/A

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

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

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

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

                  \[\leadsto \color{blue}{d1 \cdot d2} \]
                10. Step-by-step derivation
                  1. lower-*.f6431.8

                    \[\leadsto d1 \cdot \color{blue}{d2} \]
                11. Applied rewrites31.8%

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

                if -3.4999999999999997e-272 < d4 < 1.06e135

                1. Initial program 88.6%

                  \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
                  18. sub-negate-revN/A

                    \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
                  19. sub-flip-reverseN/A

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

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

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

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

                  \[\leadsto d1 \cdot \color{blue}{\left(-1 \cdot d1\right)} \]
                5. Step-by-step derivation
                  1. lower-*.f6430.6

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

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

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

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

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

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

                    \[\leadsto \left(\mathsf{neg}\left(d1\right)\right) \cdot d1 \]
                  6. lower-neg.f6430.6

                    \[\leadsto \left(-d1\right) \cdot d1 \]
                8. Applied rewrites30.6%

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

                if 1.06e135 < d4

                1. Initial program 88.6%

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

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

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

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

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

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

                  \[\leadsto \color{blue}{d1 \cdot d4} \]
                6. Step-by-step derivation
                  1. lower-*.f6431.2

                    \[\leadsto d1 \cdot \color{blue}{d4} \]
                7. Applied rewrites31.2%

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

              Alternative 11: 39.2% accurate, 2.7× speedup?

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

                1. Initial program 88.6%

                  \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
                2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
                  18. sub-negate-revN/A

                    \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
                  19. sub-flip-reverseN/A

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

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

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

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

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

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

                    \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
                6. Applied rewrites77.3%

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

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

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

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

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

                    \[\leadsto \left(\left(d2 + d4\right) - d1\right) \cdot d1 \]
                  6. associate--l+N/A

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

                    \[\leadsto \left(d2 - \color{blue}{\left(\mathsf{neg}\left(\left(d4 - d1\right)\right)\right)}\right) \cdot d1 \]
                  8. sub-negate-revN/A

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

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

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

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

                  \[\leadsto \color{blue}{d1 \cdot d2} \]
                10. Step-by-step derivation
                  1. lower-*.f6431.8

                    \[\leadsto d1 \cdot \color{blue}{d2} \]
                11. Applied rewrites31.8%

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

                if -8.8e15 < d2

                1. Initial program 88.6%

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

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

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

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

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

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

                  \[\leadsto \color{blue}{d1 \cdot d4} \]
                6. Step-by-step derivation
                  1. lower-*.f6431.2

                    \[\leadsto d1 \cdot \color{blue}{d4} \]
                7. Applied rewrites31.2%

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

              Alternative 12: 31.8% accurate, 5.3× speedup?

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

                \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \]
              2. 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. sub-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto d1 \cdot \left(\color{blue}{\left(d4 + \left(d2 - d3\right)\right)} - d1\right) \]
                18. sub-negate-revN/A

                  \[\leadsto d1 \cdot \left(\left(d4 + \color{blue}{\left(\mathsf{neg}\left(\left(d3 - d2\right)\right)\right)}\right) - d1\right) \]
                19. sub-flip-reverseN/A

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

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

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

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

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

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

                  \[\leadsto d1 \cdot \left(\left(d2 + d4\right) - d1\right) \]
              6. Applied rewrites77.3%

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

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

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

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

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

                  \[\leadsto \left(\left(d2 + d4\right) - d1\right) \cdot d1 \]
                6. associate--l+N/A

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

                  \[\leadsto \left(d2 - \color{blue}{\left(\mathsf{neg}\left(\left(d4 - d1\right)\right)\right)}\right) \cdot d1 \]
                8. sub-negate-revN/A

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

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

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

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

                \[\leadsto \color{blue}{d1 \cdot d2} \]
              10. Step-by-step derivation
                1. lower-*.f6431.8

                  \[\leadsto d1 \cdot \color{blue}{d2} \]
              11. Applied rewrites31.8%

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

              Developer Target 1: 100.0% accurate, 1.7× 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 2025159 
              (FPCore (d1 d2 d3 d4)
                :name "FastMath dist4"
                :precision binary64
              
                :alt
                (! :herbie-platform c (* d1 (- (+ (- d2 d3) d4) d1)))
              
                (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))