Complex division, imag part

Percentage Accurate: 61.8% → 80.7%
Time: 3.2s
Alternatives: 8
Speedup: 1.5×

Specification

?
\[\begin{array}{l} \\ \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
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(a, b, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 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: 61.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
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(a, b, c, d)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}

Alternative 1: 80.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -7.8 \cdot 10^{-19}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b}{d}, \frac{c}{d}, \frac{-a}{d}\right)\\ \mathbf{elif}\;d \leq 3.9 \cdot 10^{-107}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;d \leq 1.38 \cdot 10^{+147}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -7.8e-19)
   (fma (/ b d) (/ c d) (/ (- a) d))
   (if (<= d 3.9e-107)
     (/ (- b (* d (/ a c))) c)
     (if (<= d 1.38e+147)
       (/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
       (/ (fma b (/ c d) (- a)) d)))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -7.8e-19) {
		tmp = fma((b / d), (c / d), (-a / d));
	} else if (d <= 3.9e-107) {
		tmp = (b - (d * (a / c))) / c;
	} else if (d <= 1.38e+147) {
		tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
	} else {
		tmp = fma(b, (c / d), -a) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -7.8e-19)
		tmp = fma(Float64(b / d), Float64(c / d), Float64(Float64(-a) / d));
	elseif (d <= 3.9e-107)
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	elseif (d <= 1.38e+147)
		tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)));
	else
		tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[d, -7.8e-19], N[(N[(b / d), $MachinePrecision] * N[(c / d), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.9e-107], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.38e+147], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.8 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{d}, \frac{c}{d}, \frac{-a}{d}\right)\\

\mathbf{elif}\;d \leq 3.9 \cdot 10^{-107}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

\mathbf{elif}\;d \leq 1.38 \cdot 10^{+147}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -7.7999999999999999e-19

    1. Initial program 48.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. Applied rewrites76.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{b}{d}, \frac{c}{d}, \frac{-a}{d}\right)} \]

      if -7.7999999999999999e-19 < d < 3.9000000000000001e-107

      1. Initial program 70.4%

        \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
      2. Add Preprocessing
      3. Taylor expanded in c around inf

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      4. Step-by-step derivation
        1. Applied rewrites90.6%

          \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
        2. Step-by-step derivation
          1. Applied rewrites92.8%

            \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]

          if 3.9000000000000001e-107 < d < 1.37999999999999991e147

          1. Initial program 79.7%

            \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
          2. Add Preprocessing

          if 1.37999999999999991e147 < d

          1. Initial program 31.8%

            \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
          2. Add Preprocessing
          3. Taylor expanded in d around inf

            \[\leadsto \color{blue}{\frac{-1 \cdot a + \frac{b \cdot c}{d}}{d}} \]
          4. Step-by-step derivation
            1. Applied rewrites82.7%

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}} \]
          5. Recombined 4 regimes into one program.
          6. Add Preprocessing

          Alternative 2: 80.5% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -7.8 \cdot 10^{-19}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 3.9 \cdot 10^{-107}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;d \leq 1.38 \cdot 10^{+147}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (a b c d)
           :precision binary64
           (let* ((t_0 (/ (fma b (/ c d) (- a)) d)))
             (if (<= d -7.8e-19)
               t_0
               (if (<= d 3.9e-107)
                 (/ (- b (* d (/ a c))) c)
                 (if (<= d 1.38e+147)
                   (/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
                   t_0)))))
          double code(double a, double b, double c, double d) {
          	double t_0 = fma(b, (c / d), -a) / d;
          	double tmp;
          	if (d <= -7.8e-19) {
          		tmp = t_0;
          	} else if (d <= 3.9e-107) {
          		tmp = (b - (d * (a / c))) / c;
          	} else if (d <= 1.38e+147) {
          		tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          function code(a, b, c, d)
          	t_0 = Float64(fma(b, Float64(c / d), Float64(-a)) / d)
          	tmp = 0.0
          	if (d <= -7.8e-19)
          		tmp = t_0;
          	elseif (d <= 3.9e-107)
          		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
          	elseif (d <= 1.38e+147)
          		tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)));
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -7.8e-19], t$95$0, If[LessEqual[d, 3.9e-107], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.38e+147], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\
          \mathbf{if}\;d \leq -7.8 \cdot 10^{-19}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;d \leq 3.9 \cdot 10^{-107}:\\
          \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
          
          \mathbf{elif}\;d \leq 1.38 \cdot 10^{+147}:\\
          \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if d < -7.7999999999999999e-19 or 1.37999999999999991e147 < d

            1. Initial program 41.8%

              \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
            2. Add Preprocessing
            3. Taylor expanded in d around inf

              \[\leadsto \color{blue}{\frac{-1 \cdot a + \frac{b \cdot c}{d}}{d}} \]
            4. Step-by-step derivation
              1. Applied rewrites79.1%

                \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}} \]

              if -7.7999999999999999e-19 < d < 3.9000000000000001e-107

              1. Initial program 70.4%

                \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
              2. Add Preprocessing
              3. Taylor expanded in c around inf

                \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
              4. Step-by-step derivation
                1. Applied rewrites90.6%

                  \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
                2. Step-by-step derivation
                  1. Applied rewrites92.8%

                    \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]

                  if 3.9000000000000001e-107 < d < 1.37999999999999991e147

                  1. Initial program 79.7%

                    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                  2. Add Preprocessing
                3. Recombined 3 regimes into one program.
                4. Add Preprocessing

                Alternative 3: 74.3% accurate, 0.7× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ t_1 := \frac{b \cdot c - a \cdot d}{d \cdot d}\\ \mathbf{if}\;d \leq -3.9 \cdot 10^{+123}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -7.8 \cdot 10^{-19}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-5}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;d \leq 4.6 \cdot 10^{+117}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                (FPCore (a b c d)
                 :precision binary64
                 (let* ((t_0 (/ (- a) d)) (t_1 (/ (- (* b c) (* a d)) (* d d))))
                   (if (<= d -3.9e+123)
                     t_0
                     (if (<= d -7.8e-19)
                       t_1
                       (if (<= d 1.25e-5)
                         (/ (- b (* d (/ a c))) c)
                         (if (<= d 4.6e+117) t_1 t_0))))))
                double code(double a, double b, double c, double d) {
                	double t_0 = -a / d;
                	double t_1 = ((b * c) - (a * d)) / (d * d);
                	double tmp;
                	if (d <= -3.9e+123) {
                		tmp = t_0;
                	} else if (d <= -7.8e-19) {
                		tmp = t_1;
                	} else if (d <= 1.25e-5) {
                		tmp = (b - (d * (a / c))) / c;
                	} else if (d <= 4.6e+117) {
                		tmp = t_1;
                	} else {
                		tmp = t_0;
                	}
                	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(a, b, c, d)
                use fmin_fmax_functions
                    real(8), intent (in) :: a
                    real(8), intent (in) :: b
                    real(8), intent (in) :: c
                    real(8), intent (in) :: d
                    real(8) :: t_0
                    real(8) :: t_1
                    real(8) :: tmp
                    t_0 = -a / d
                    t_1 = ((b * c) - (a * d)) / (d * d)
                    if (d <= (-3.9d+123)) then
                        tmp = t_0
                    else if (d <= (-7.8d-19)) then
                        tmp = t_1
                    else if (d <= 1.25d-5) then
                        tmp = (b - (d * (a / c))) / c
                    else if (d <= 4.6d+117) then
                        tmp = t_1
                    else
                        tmp = t_0
                    end if
                    code = tmp
                end function
                
                public static double code(double a, double b, double c, double d) {
                	double t_0 = -a / d;
                	double t_1 = ((b * c) - (a * d)) / (d * d);
                	double tmp;
                	if (d <= -3.9e+123) {
                		tmp = t_0;
                	} else if (d <= -7.8e-19) {
                		tmp = t_1;
                	} else if (d <= 1.25e-5) {
                		tmp = (b - (d * (a / c))) / c;
                	} else if (d <= 4.6e+117) {
                		tmp = t_1;
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(a, b, c, d):
                	t_0 = -a / d
                	t_1 = ((b * c) - (a * d)) / (d * d)
                	tmp = 0
                	if d <= -3.9e+123:
                		tmp = t_0
                	elif d <= -7.8e-19:
                		tmp = t_1
                	elif d <= 1.25e-5:
                		tmp = (b - (d * (a / c))) / c
                	elif d <= 4.6e+117:
                		tmp = t_1
                	else:
                		tmp = t_0
                	return tmp
                
                function code(a, b, c, d)
                	t_0 = Float64(Float64(-a) / d)
                	t_1 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(d * d))
                	tmp = 0.0
                	if (d <= -3.9e+123)
                		tmp = t_0;
                	elseif (d <= -7.8e-19)
                		tmp = t_1;
                	elseif (d <= 1.25e-5)
                		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
                	elseif (d <= 4.6e+117)
                		tmp = t_1;
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(a, b, c, d)
                	t_0 = -a / d;
                	t_1 = ((b * c) - (a * d)) / (d * d);
                	tmp = 0.0;
                	if (d <= -3.9e+123)
                		tmp = t_0;
                	elseif (d <= -7.8e-19)
                		tmp = t_1;
                	elseif (d <= 1.25e-5)
                		tmp = (b - (d * (a / c))) / c;
                	elseif (d <= 4.6e+117)
                		tmp = t_1;
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.9e+123], t$95$0, If[LessEqual[d, -7.8e-19], t$95$1, If[LessEqual[d, 1.25e-5], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.6e+117], t$95$1, t$95$0]]]]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := \frac{-a}{d}\\
                t_1 := \frac{b \cdot c - a \cdot d}{d \cdot d}\\
                \mathbf{if}\;d \leq -3.9 \cdot 10^{+123}:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;d \leq -7.8 \cdot 10^{-19}:\\
                \;\;\;\;t\_1\\
                
                \mathbf{elif}\;d \leq 1.25 \cdot 10^{-5}:\\
                \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
                
                \mathbf{elif}\;d \leq 4.6 \cdot 10^{+117}:\\
                \;\;\;\;t\_1\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if d < -3.89999999999999993e123 or 4.59999999999999976e117 < d

                  1. Initial program 29.5%

                    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                  2. Add Preprocessing
                  3. Taylor expanded in c around 0

                    \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
                  4. Step-by-step derivation
                    1. Applied rewrites69.3%

                      \[\leadsto \color{blue}{\frac{-a}{d}} \]

                    if -3.89999999999999993e123 < d < -7.7999999999999999e-19 or 1.25000000000000006e-5 < d < 4.59999999999999976e117

                    1. Initial program 81.9%

                      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                    2. Add Preprocessing
                    3. Taylor expanded in c around 0

                      \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{{d}^{2}}} \]
                    4. Step-by-step derivation
                      1. Applied rewrites67.9%

                        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{d \cdot d}} \]

                      if -7.7999999999999999e-19 < d < 1.25000000000000006e-5

                      1. Initial program 72.3%

                        \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                      2. Add Preprocessing
                      3. Taylor expanded in c around inf

                        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
                      4. Step-by-step derivation
                        1. Applied rewrites85.2%

                          \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
                        2. Step-by-step derivation
                          1. Applied rewrites86.9%

                            \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
                        3. Recombined 3 regimes into one program.
                        4. Add Preprocessing

                        Alternative 4: 66.7% accurate, 0.7× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ t_1 := \frac{b \cdot c - a \cdot d}{d \cdot d}\\ \mathbf{if}\;d \leq -3.9 \cdot 10^{+123}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -3.9 \cdot 10^{-20}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-6}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 4.6 \cdot 10^{+117}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                        (FPCore (a b c d)
                         :precision binary64
                         (let* ((t_0 (/ (- a) d)) (t_1 (/ (- (* b c) (* a d)) (* d d))))
                           (if (<= d -3.9e+123)
                             t_0
                             (if (<= d -3.9e-20)
                               t_1
                               (if (<= d 3e-6) (/ b c) (if (<= d 4.6e+117) t_1 t_0))))))
                        double code(double a, double b, double c, double d) {
                        	double t_0 = -a / d;
                        	double t_1 = ((b * c) - (a * d)) / (d * d);
                        	double tmp;
                        	if (d <= -3.9e+123) {
                        		tmp = t_0;
                        	} else if (d <= -3.9e-20) {
                        		tmp = t_1;
                        	} else if (d <= 3e-6) {
                        		tmp = b / c;
                        	} else if (d <= 4.6e+117) {
                        		tmp = t_1;
                        	} else {
                        		tmp = t_0;
                        	}
                        	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(a, b, c, d)
                        use fmin_fmax_functions
                            real(8), intent (in) :: a
                            real(8), intent (in) :: b
                            real(8), intent (in) :: c
                            real(8), intent (in) :: d
                            real(8) :: t_0
                            real(8) :: t_1
                            real(8) :: tmp
                            t_0 = -a / d
                            t_1 = ((b * c) - (a * d)) / (d * d)
                            if (d <= (-3.9d+123)) then
                                tmp = t_0
                            else if (d <= (-3.9d-20)) then
                                tmp = t_1
                            else if (d <= 3d-6) then
                                tmp = b / c
                            else if (d <= 4.6d+117) then
                                tmp = t_1
                            else
                                tmp = t_0
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double a, double b, double c, double d) {
                        	double t_0 = -a / d;
                        	double t_1 = ((b * c) - (a * d)) / (d * d);
                        	double tmp;
                        	if (d <= -3.9e+123) {
                        		tmp = t_0;
                        	} else if (d <= -3.9e-20) {
                        		tmp = t_1;
                        	} else if (d <= 3e-6) {
                        		tmp = b / c;
                        	} else if (d <= 4.6e+117) {
                        		tmp = t_1;
                        	} else {
                        		tmp = t_0;
                        	}
                        	return tmp;
                        }
                        
                        def code(a, b, c, d):
                        	t_0 = -a / d
                        	t_1 = ((b * c) - (a * d)) / (d * d)
                        	tmp = 0
                        	if d <= -3.9e+123:
                        		tmp = t_0
                        	elif d <= -3.9e-20:
                        		tmp = t_1
                        	elif d <= 3e-6:
                        		tmp = b / c
                        	elif d <= 4.6e+117:
                        		tmp = t_1
                        	else:
                        		tmp = t_0
                        	return tmp
                        
                        function code(a, b, c, d)
                        	t_0 = Float64(Float64(-a) / d)
                        	t_1 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(d * d))
                        	tmp = 0.0
                        	if (d <= -3.9e+123)
                        		tmp = t_0;
                        	elseif (d <= -3.9e-20)
                        		tmp = t_1;
                        	elseif (d <= 3e-6)
                        		tmp = Float64(b / c);
                        	elseif (d <= 4.6e+117)
                        		tmp = t_1;
                        	else
                        		tmp = t_0;
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(a, b, c, d)
                        	t_0 = -a / d;
                        	t_1 = ((b * c) - (a * d)) / (d * d);
                        	tmp = 0.0;
                        	if (d <= -3.9e+123)
                        		tmp = t_0;
                        	elseif (d <= -3.9e-20)
                        		tmp = t_1;
                        	elseif (d <= 3e-6)
                        		tmp = b / c;
                        	elseif (d <= 4.6e+117)
                        		tmp = t_1;
                        	else
                        		tmp = t_0;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.9e+123], t$95$0, If[LessEqual[d, -3.9e-20], t$95$1, If[LessEqual[d, 3e-6], N[(b / c), $MachinePrecision], If[LessEqual[d, 4.6e+117], t$95$1, t$95$0]]]]]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        t_0 := \frac{-a}{d}\\
                        t_1 := \frac{b \cdot c - a \cdot d}{d \cdot d}\\
                        \mathbf{if}\;d \leq -3.9 \cdot 10^{+123}:\\
                        \;\;\;\;t\_0\\
                        
                        \mathbf{elif}\;d \leq -3.9 \cdot 10^{-20}:\\
                        \;\;\;\;t\_1\\
                        
                        \mathbf{elif}\;d \leq 3 \cdot 10^{-6}:\\
                        \;\;\;\;\frac{b}{c}\\
                        
                        \mathbf{elif}\;d \leq 4.6 \cdot 10^{+117}:\\
                        \;\;\;\;t\_1\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;t\_0\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 3 regimes
                        2. if d < -3.89999999999999993e123 or 4.59999999999999976e117 < d

                          1. Initial program 29.5%

                            \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                          2. Add Preprocessing
                          3. Taylor expanded in c around 0

                            \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
                          4. Step-by-step derivation
                            1. Applied rewrites69.3%

                              \[\leadsto \color{blue}{\frac{-a}{d}} \]

                            if -3.89999999999999993e123 < d < -3.90000000000000007e-20 or 3.0000000000000001e-6 < d < 4.59999999999999976e117

                            1. Initial program 81.9%

                              \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                            2. Add Preprocessing
                            3. Taylor expanded in c around 0

                              \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{{d}^{2}}} \]
                            4. Step-by-step derivation
                              1. Applied rewrites67.9%

                                \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{d \cdot d}} \]

                              if -3.90000000000000007e-20 < d < 3.0000000000000001e-6

                              1. Initial program 72.3%

                                \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                              2. Add Preprocessing
                              3. Taylor expanded in c around inf

                                \[\leadsto \color{blue}{\frac{b}{c}} \]
                              4. Step-by-step derivation
                                1. Applied rewrites72.7%

                                  \[\leadsto \color{blue}{\frac{b}{c}} \]
                              5. Recombined 3 regimes into one program.
                              6. Add Preprocessing

                              Alternative 5: 66.7% accurate, 0.7× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1.1 \cdot 10^{+56}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -5.2 \cdot 10^{-72}:\\ \;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-43}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 1.22 \cdot 10^{+89}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
                              (FPCore (a b c d)
                               :precision binary64
                               (if (<= c -1.1e+56)
                                 (/ b c)
                                 (if (<= c -5.2e-72)
                                   (* b (/ c (fma d d (* c c))))
                                   (if (<= c 3.4e-43)
                                     (/ (- a) d)
                                     (if (<= c 1.22e+89) (/ (- (* b c) (* a d)) (* c c)) (/ b c))))))
                              double code(double a, double b, double c, double d) {
                              	double tmp;
                              	if (c <= -1.1e+56) {
                              		tmp = b / c;
                              	} else if (c <= -5.2e-72) {
                              		tmp = b * (c / fma(d, d, (c * c)));
                              	} else if (c <= 3.4e-43) {
                              		tmp = -a / d;
                              	} else if (c <= 1.22e+89) {
                              		tmp = ((b * c) - (a * d)) / (c * c);
                              	} else {
                              		tmp = b / c;
                              	}
                              	return tmp;
                              }
                              
                              function code(a, b, c, d)
                              	tmp = 0.0
                              	if (c <= -1.1e+56)
                              		tmp = Float64(b / c);
                              	elseif (c <= -5.2e-72)
                              		tmp = Float64(b * Float64(c / fma(d, d, Float64(c * c))));
                              	elseif (c <= 3.4e-43)
                              		tmp = Float64(Float64(-a) / d);
                              	elseif (c <= 1.22e+89)
                              		tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(c * c));
                              	else
                              		tmp = Float64(b / c);
                              	end
                              	return tmp
                              end
                              
                              code[a_, b_, c_, d_] := If[LessEqual[c, -1.1e+56], N[(b / c), $MachinePrecision], If[LessEqual[c, -5.2e-72], N[(b * N[(c / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.4e-43], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 1.22e+89], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;c \leq -1.1 \cdot 10^{+56}:\\
                              \;\;\;\;\frac{b}{c}\\
                              
                              \mathbf{elif}\;c \leq -5.2 \cdot 10^{-72}:\\
                              \;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
                              
                              \mathbf{elif}\;c \leq 3.4 \cdot 10^{-43}:\\
                              \;\;\;\;\frac{-a}{d}\\
                              
                              \mathbf{elif}\;c \leq 1.22 \cdot 10^{+89}:\\
                              \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c}\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;\frac{b}{c}\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 4 regimes
                              2. if c < -1.10000000000000008e56 or 1.22e89 < c

                                1. Initial program 40.2%

                                  \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                                2. Add Preprocessing
                                3. Taylor expanded in c around inf

                                  \[\leadsto \color{blue}{\frac{b}{c}} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites74.9%

                                    \[\leadsto \color{blue}{\frac{b}{c}} \]

                                  if -1.10000000000000008e56 < c < -5.19999999999999992e-72

                                  1. Initial program 70.7%

                                    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in a around 0

                                    \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
                                  4. Step-by-step derivation
                                    1. Applied rewrites57.5%

                                      \[\leadsto \color{blue}{b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]

                                    if -5.19999999999999992e-72 < c < 3.4000000000000001e-43

                                    1. Initial program 71.8%

                                      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in c around 0

                                      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites73.1%

                                        \[\leadsto \color{blue}{\frac{-a}{d}} \]

                                      if 3.4000000000000001e-43 < c < 1.22e89

                                      1. Initial program 76.1%

                                        \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in c around inf

                                        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{{c}^{2}}} \]
                                      4. Step-by-step derivation
                                        1. Applied rewrites56.5%

                                          \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c}} \]
                                      5. Recombined 4 regimes into one program.
                                      6. Add Preprocessing

                                      Alternative 6: 78.6% accurate, 0.9× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -7.8 \cdot 10^{-19} \lor \neg \left(d \leq 1.25 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \end{array} \]
                                      (FPCore (a b c d)
                                       :precision binary64
                                       (if (or (<= d -7.8e-19) (not (<= d 1.25e-5)))
                                         (/ (fma b (/ c d) (- a)) d)
                                         (/ (- b (* d (/ a c))) c)))
                                      double code(double a, double b, double c, double d) {
                                      	double tmp;
                                      	if ((d <= -7.8e-19) || !(d <= 1.25e-5)) {
                                      		tmp = fma(b, (c / d), -a) / d;
                                      	} else {
                                      		tmp = (b - (d * (a / c))) / c;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      function code(a, b, c, d)
                                      	tmp = 0.0
                                      	if ((d <= -7.8e-19) || !(d <= 1.25e-5))
                                      		tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d);
                                      	else
                                      		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
                                      	end
                                      	return tmp
                                      end
                                      
                                      code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.8e-19], N[Not[LessEqual[d, 1.25e-5]], $MachinePrecision]], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;d \leq -7.8 \cdot 10^{-19} \lor \neg \left(d \leq 1.25 \cdot 10^{-5}\right):\\
                                      \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if d < -7.7999999999999999e-19 or 1.25000000000000006e-5 < d

                                        1. Initial program 49.7%

                                          \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in d around inf

                                          \[\leadsto \color{blue}{\frac{-1 \cdot a + \frac{b \cdot c}{d}}{d}} \]
                                        4. Step-by-step derivation
                                          1. Applied rewrites76.5%

                                            \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}} \]

                                          if -7.7999999999999999e-19 < d < 1.25000000000000006e-5

                                          1. Initial program 72.3%

                                            \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in c around inf

                                            \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
                                          4. Step-by-step derivation
                                            1. Applied rewrites85.2%

                                              \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
                                            2. Step-by-step derivation
                                              1. Applied rewrites86.9%

                                                \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
                                            3. Recombined 2 regimes into one program.
                                            4. Final simplification81.2%

                                              \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.8 \cdot 10^{-19} \lor \neg \left(d \leq 1.25 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]
                                            5. Add Preprocessing

                                            Alternative 7: 65.4% accurate, 1.5× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{-16} \lor \neg \left(d \leq 0.00105\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
                                            (FPCore (a b c d)
                                             :precision binary64
                                             (if (or (<= d -2.4e-16) (not (<= d 0.00105))) (/ (- a) d) (/ b c)))
                                            double code(double a, double b, double c, double d) {
                                            	double tmp;
                                            	if ((d <= -2.4e-16) || !(d <= 0.00105)) {
                                            		tmp = -a / d;
                                            	} else {
                                            		tmp = b / c;
                                            	}
                                            	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(a, b, c, d)
                                            use fmin_fmax_functions
                                                real(8), intent (in) :: a
                                                real(8), intent (in) :: b
                                                real(8), intent (in) :: c
                                                real(8), intent (in) :: d
                                                real(8) :: tmp
                                                if ((d <= (-2.4d-16)) .or. (.not. (d <= 0.00105d0))) then
                                                    tmp = -a / d
                                                else
                                                    tmp = b / c
                                                end if
                                                code = tmp
                                            end function
                                            
                                            public static double code(double a, double b, double c, double d) {
                                            	double tmp;
                                            	if ((d <= -2.4e-16) || !(d <= 0.00105)) {
                                            		tmp = -a / d;
                                            	} else {
                                            		tmp = b / c;
                                            	}
                                            	return tmp;
                                            }
                                            
                                            def code(a, b, c, d):
                                            	tmp = 0
                                            	if (d <= -2.4e-16) or not (d <= 0.00105):
                                            		tmp = -a / d
                                            	else:
                                            		tmp = b / c
                                            	return tmp
                                            
                                            function code(a, b, c, d)
                                            	tmp = 0.0
                                            	if ((d <= -2.4e-16) || !(d <= 0.00105))
                                            		tmp = Float64(Float64(-a) / d);
                                            	else
                                            		tmp = Float64(b / c);
                                            	end
                                            	return tmp
                                            end
                                            
                                            function tmp_2 = code(a, b, c, d)
                                            	tmp = 0.0;
                                            	if ((d <= -2.4e-16) || ~((d <= 0.00105)))
                                            		tmp = -a / d;
                                            	else
                                            		tmp = b / c;
                                            	end
                                            	tmp_2 = tmp;
                                            end
                                            
                                            code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.4e-16], N[Not[LessEqual[d, 0.00105]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \begin{array}{l}
                                            \mathbf{if}\;d \leq -2.4 \cdot 10^{-16} \lor \neg \left(d \leq 0.00105\right):\\
                                            \;\;\;\;\frac{-a}{d}\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\frac{b}{c}\\
                                            
                                            
                                            \end{array}
                                            \end{array}
                                            
                                            Derivation
                                            1. Split input into 2 regimes
                                            2. if d < -2.40000000000000005e-16 or 0.00104999999999999994 < d

                                              1. Initial program 49.7%

                                                \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in c around 0

                                                \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
                                              4. Step-by-step derivation
                                                1. Applied rewrites60.9%

                                                  \[\leadsto \color{blue}{\frac{-a}{d}} \]

                                                if -2.40000000000000005e-16 < d < 0.00104999999999999994

                                                1. Initial program 72.3%

                                                  \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in c around inf

                                                  \[\leadsto \color{blue}{\frac{b}{c}} \]
                                                4. Step-by-step derivation
                                                  1. Applied rewrites72.7%

                                                    \[\leadsto \color{blue}{\frac{b}{c}} \]
                                                5. Recombined 2 regimes into one program.
                                                6. Final simplification66.2%

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.4 \cdot 10^{-16} \lor \neg \left(d \leq 0.00105\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
                                                7. Add Preprocessing

                                                Alternative 8: 43.2% accurate, 3.2× speedup?

                                                \[\begin{array}{l} \\ \frac{b}{c} \end{array} \]
                                                (FPCore (a b c d) :precision binary64 (/ b c))
                                                double code(double a, double b, double c, double d) {
                                                	return b / c;
                                                }
                                                
                                                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(a, b, c, d)
                                                use fmin_fmax_functions
                                                    real(8), intent (in) :: a
                                                    real(8), intent (in) :: b
                                                    real(8), intent (in) :: c
                                                    real(8), intent (in) :: d
                                                    code = b / c
                                                end function
                                                
                                                public static double code(double a, double b, double c, double d) {
                                                	return b / c;
                                                }
                                                
                                                def code(a, b, c, d):
                                                	return b / c
                                                
                                                function code(a, b, c, d)
                                                	return Float64(b / c)
                                                end
                                                
                                                function tmp = code(a, b, c, d)
                                                	tmp = b / c;
                                                end
                                                
                                                code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \frac{b}{c}
                                                \end{array}
                                                
                                                Derivation
                                                1. Initial program 60.0%

                                                  \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in c around inf

                                                  \[\leadsto \color{blue}{\frac{b}{c}} \]
                                                4. Step-by-step derivation
                                                  1. Applied rewrites45.0%

                                                    \[\leadsto \color{blue}{\frac{b}{c}} \]
                                                  2. Add Preprocessing

                                                  Developer Target 1: 99.2% accurate, 0.6× speedup?

                                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
                                                  (FPCore (a b c d)
                                                   :precision binary64
                                                   (if (< (fabs d) (fabs c))
                                                     (/ (- b (* a (/ d c))) (+ c (* d (/ d c))))
                                                     (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
                                                  double code(double a, double b, double c, double d) {
                                                  	double tmp;
                                                  	if (fabs(d) < fabs(c)) {
                                                  		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
                                                  	} else {
                                                  		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
                                                  	}
                                                  	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(a, b, c, d)
                                                  use fmin_fmax_functions
                                                      real(8), intent (in) :: a
                                                      real(8), intent (in) :: b
                                                      real(8), intent (in) :: c
                                                      real(8), intent (in) :: d
                                                      real(8) :: tmp
                                                      if (abs(d) < abs(c)) then
                                                          tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
                                                      else
                                                          tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
                                                      end if
                                                      code = tmp
                                                  end function
                                                  
                                                  public static double code(double a, double b, double c, double d) {
                                                  	double tmp;
                                                  	if (Math.abs(d) < Math.abs(c)) {
                                                  		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
                                                  	} else {
                                                  		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
                                                  	}
                                                  	return tmp;
                                                  }
                                                  
                                                  def code(a, b, c, d):
                                                  	tmp = 0
                                                  	if math.fabs(d) < math.fabs(c):
                                                  		tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
                                                  	else:
                                                  		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
                                                  	return tmp
                                                  
                                                  function code(a, b, c, d)
                                                  	tmp = 0.0
                                                  	if (abs(d) < abs(c))
                                                  		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
                                                  	else
                                                  		tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
                                                  	end
                                                  	return tmp
                                                  end
                                                  
                                                  function tmp_2 = code(a, b, c, d)
                                                  	tmp = 0.0;
                                                  	if (abs(d) < abs(c))
                                                  		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
                                                  	else
                                                  		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
                                                  	end
                                                  	tmp_2 = tmp;
                                                  end
                                                  
                                                  code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                  
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  \begin{array}{l}
                                                  \mathbf{if}\;\left|d\right| < \left|c\right|:\\
                                                  \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
                                                  
                                                  
                                                  \end{array}
                                                  \end{array}
                                                  

                                                  Reproduce

                                                  ?
                                                  herbie shell --seed 2025026 
                                                  (FPCore (a b c d)
                                                    :name "Complex division, imag part"
                                                    :precision binary64
                                                  
                                                    :alt
                                                    (! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
                                                  
                                                    (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))