Complex division, imag part

Percentage Accurate: 61.6% → 82.6%
Time: 4.1s
Alternatives: 9
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}

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 9 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.6% 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: 82.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{if}\;c \leq -1.65 \cdot 10^{+129}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -5.5 \cdot 10^{+31}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{elif}\;c \leq -1.1 \cdot 10^{-90}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{-152}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 4 \cdot 10^{+96}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* b c) (* a d)) (fma c c (* d d)))))
   (if (<= c -1.65e+129)
     (/ (- b (* a (/ d c))) c)
     (if (<= c -5.5e+31)
       (/ (fma b (/ c d) (- a)) d)
       (if (<= c -1.1e-90)
         t_0
         (if (<= c 5.5e-152)
           (/ (- (/ (* b c) d) a) d)
           (if (<= c 4e+96) t_0 (/ (- b (* d (/ a c))) c))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((b * c) - (a * d)) / fma(c, c, (d * d));
	double tmp;
	if (c <= -1.65e+129) {
		tmp = (b - (a * (d / c))) / c;
	} else if (c <= -5.5e+31) {
		tmp = fma(b, (c / d), -a) / d;
	} else if (c <= -1.1e-90) {
		tmp = t_0;
	} else if (c <= 5.5e-152) {
		tmp = (((b * c) / d) - a) / d;
	} else if (c <= 4e+96) {
		tmp = t_0;
	} else {
		tmp = (b - (d * (a / c))) / c;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / fma(c, c, Float64(d * d)))
	tmp = 0.0
	if (c <= -1.65e+129)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (c <= -5.5e+31)
		tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d);
	elseif (c <= -1.1e-90)
		tmp = t_0;
	elseif (c <= 5.5e-152)
		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
	elseif (c <= 4e+96)
		tmp = t_0;
	else
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.65e+129], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -5.5e+31], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, -1.1e-90], t$95$0, If[LessEqual[c, 5.5e-152], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4e+96], t$95$0, N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{if}\;c \leq -1.65 \cdot 10^{+129}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

\mathbf{elif}\;c \leq -5.5 \cdot 10^{+31}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\

\mathbf{elif}\;c \leq -1.1 \cdot 10^{-90}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 4 \cdot 10^{+96}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if c < -1.64999999999999995e129

    1. Initial program 34.9%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\color{blue}{c}} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{a \cdot d}{c}}{c} \]
      3. metadata-evalN/A

        \[\leadsto \frac{b - 1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. metadata-evalN/A

        \[\leadsto \frac{b - \frac{-1}{-1} \cdot \frac{a \cdot d}{c}}{c} \]
      5. times-fracN/A

        \[\leadsto \frac{b - \frac{-1 \cdot \left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      6. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      7. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{\mathsf{neg}\left(c\right)}}{c} \]
      8. frac-2negN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      9. lower--.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      11. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      12. lower-*.f6480.3

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
    4. Applied rewrites80.3%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      3. *-commutativeN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. associate-/l*N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      6. lower-/.f6486.0

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
    6. Applied rewrites86.0%

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

    if -1.64999999999999995e129 < c < -5.50000000000000002e31

    1. Initial program 72.2%

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

      \[\leadsto \color{blue}{\frac{-1 \cdot a + \frac{b \cdot c}{d}}{d}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot a + \frac{b \cdot c}{d}}{\color{blue}{d}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} + -1 \cdot a}{d} \]
      3. associate-/l*N/A

        \[\leadsto \frac{b \cdot \frac{c}{d} + -1 \cdot a}{d} \]
      4. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, -1 \cdot a\right)}{d} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, -1 \cdot a\right)}{d} \]
      6. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, \mathsf{neg}\left(a\right)\right)}{d} \]
      7. lower-neg.f6435.4

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d} \]
    4. Applied rewrites35.4%

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

    if -5.50000000000000002e31 < c < -1.09999999999999993e-90 or 5.4999999999999998e-152 < c < 4.0000000000000002e96

    1. Initial program 76.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c + d \cdot d}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c} + d \cdot d} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + \color{blue}{d \cdot d}} \]
      4. pow2N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + \color{blue}{{d}^{2}}} \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, {d}^{2}\right)}} \]
      6. pow2N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \]
      7. lift-*.f6476.8

        \[\leadsto \frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \]
    3. Applied rewrites76.8%

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

    if -1.09999999999999993e-90 < c < 5.4999999999999998e-152

    1. Initial program 70.7%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      3. lower-/.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      4. +-commutativeN/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      5. lower-+.f64N/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      6. mul-1-negN/A

        \[\leadsto -\frac{\left(\mathsf{neg}\left(\frac{b \cdot c}{d}\right)\right) + a}{d} \]
      7. lower-neg.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      8. lower-/.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      9. *-commutativeN/A

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
      10. lower-*.f6491.3

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
    4. Applied rewrites91.3%

      \[\leadsto \color{blue}{-\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d}} \]
    5. Taylor expanded in d around inf

      \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      2. lower--.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      4. lower-*.f6491.3

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
    7. Applied rewrites91.3%

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

    if 4.0000000000000002e96 < c

    1. Initial program 35.7%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\color{blue}{c}} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{a \cdot d}{c}}{c} \]
      3. metadata-evalN/A

        \[\leadsto \frac{b - 1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. metadata-evalN/A

        \[\leadsto \frac{b - \frac{-1}{-1} \cdot \frac{a \cdot d}{c}}{c} \]
      5. times-fracN/A

        \[\leadsto \frac{b - \frac{-1 \cdot \left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      6. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      7. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{\mathsf{neg}\left(c\right)}}{c} \]
      8. frac-2negN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      9. lower--.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      11. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      12. lower-*.f6478.2

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
    4. Applied rewrites78.2%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      3. associate-/l*N/A

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
      5. lower-/.f6485.2

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
    6. Applied rewrites85.2%

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

Alternative 2: 80.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.85 \cdot 10^{+142}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

\mathbf{elif}\;c \leq -1.25 \cdot 10^{-90}:\\
\;\;\;\;\left(-b\right) \cdot \frac{\mathsf{fma}\left(a, \frac{d}{b}, -c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

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

\mathbf{elif}\;c \leq 4 \cdot 10^{+96}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if c < -1.8499999999999999e142

    1. Initial program 33.1%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\color{blue}{c}} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{a \cdot d}{c}}{c} \]
      3. metadata-evalN/A

        \[\leadsto \frac{b - 1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. metadata-evalN/A

        \[\leadsto \frac{b - \frac{-1}{-1} \cdot \frac{a \cdot d}{c}}{c} \]
      5. times-fracN/A

        \[\leadsto \frac{b - \frac{-1 \cdot \left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      6. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      7. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{\mathsf{neg}\left(c\right)}}{c} \]
      8. frac-2negN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      9. lower--.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      11. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      12. lower-*.f6481.9

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
    4. Applied rewrites81.9%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      3. *-commutativeN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. associate-/l*N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      6. lower-/.f6488.1

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
    6. Applied rewrites88.1%

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

    if -1.8499999999999999e142 < c < -1.25000000000000005e-90

    1. Initial program 73.8%

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

      \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \left(-1 \cdot \frac{c}{{c}^{2} + {d}^{2}} + \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)} \]
    3. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(-1 \cdot b\right) \cdot \color{blue}{\left(-1 \cdot \frac{c}{{c}^{2} + {d}^{2}} + \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \left(-1 \cdot b\right) \cdot \color{blue}{\left(-1 \cdot \frac{c}{{c}^{2} + {d}^{2}} + \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right)} \]
      3. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(b\right)\right) \cdot \left(\color{blue}{-1 \cdot \frac{c}{{c}^{2} + {d}^{2}}} + \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \]
      4. lower-neg.f64N/A

        \[\leadsto \left(-b\right) \cdot \left(\color{blue}{-1 \cdot \frac{c}{{c}^{2} + {d}^{2}}} + \frac{a \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \]
      5. associate-*r/N/A

        \[\leadsto \left(-b\right) \cdot \left(\frac{-1 \cdot c}{{c}^{2} + {d}^{2}} + \frac{\color{blue}{a \cdot d}}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \]
      6. mul-1-negN/A

        \[\leadsto \left(-b\right) \cdot \left(\frac{\mathsf{neg}\left(c\right)}{{c}^{2} + {d}^{2}} + \frac{\color{blue}{a} \cdot d}{b \cdot \left({c}^{2} + {d}^{2}\right)}\right) \]
      7. associate-/r*N/A

        \[\leadsto \left(-b\right) \cdot \left(\frac{\mathsf{neg}\left(c\right)}{{c}^{2} + {d}^{2}} + \frac{\frac{a \cdot d}{b}}{\color{blue}{{c}^{2} + {d}^{2}}}\right) \]
      8. div-add-revN/A

        \[\leadsto \left(-b\right) \cdot \frac{\left(\mathsf{neg}\left(c\right)\right) + \frac{a \cdot d}{b}}{\color{blue}{{c}^{2} + {d}^{2}}} \]
      9. mul-1-negN/A

        \[\leadsto \left(-b\right) \cdot \frac{-1 \cdot c + \frac{a \cdot d}{b}}{{\color{blue}{c}}^{2} + {d}^{2}} \]
      10. lower-/.f64N/A

        \[\leadsto \left(-b\right) \cdot \frac{-1 \cdot c + \frac{a \cdot d}{b}}{\color{blue}{{c}^{2} + {d}^{2}}} \]
    4. Applied rewrites68.4%

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

    if -1.25000000000000005e-90 < c < 5.4999999999999998e-152

    1. Initial program 70.7%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      3. lower-/.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      4. +-commutativeN/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      5. lower-+.f64N/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      6. mul-1-negN/A

        \[\leadsto -\frac{\left(\mathsf{neg}\left(\frac{b \cdot c}{d}\right)\right) + a}{d} \]
      7. lower-neg.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      8. lower-/.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      9. *-commutativeN/A

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
      10. lower-*.f6491.3

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
    4. Applied rewrites91.3%

      \[\leadsto \color{blue}{-\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d}} \]
    5. Taylor expanded in d around inf

      \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      2. lower--.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      4. lower-*.f6491.3

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
    7. Applied rewrites91.3%

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

    if 5.4999999999999998e-152 < c < 4.0000000000000002e96

    1. Initial program 76.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c + d \cdot d}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c} + d \cdot d} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + \color{blue}{d \cdot d}} \]
      4. pow2N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + \color{blue}{{d}^{2}}} \]
      5. lower-fma.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, {d}^{2}\right)}} \]
      6. pow2N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \]
      7. lift-*.f6476.9

        \[\leadsto \frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \]
    3. Applied rewrites76.9%

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

    if 4.0000000000000002e96 < c

    1. Initial program 35.7%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\color{blue}{c}} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{a \cdot d}{c}}{c} \]
      3. metadata-evalN/A

        \[\leadsto \frac{b - 1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. metadata-evalN/A

        \[\leadsto \frac{b - \frac{-1}{-1} \cdot \frac{a \cdot d}{c}}{c} \]
      5. times-fracN/A

        \[\leadsto \frac{b - \frac{-1 \cdot \left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      6. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      7. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{\mathsf{neg}\left(c\right)}}{c} \]
      8. frac-2negN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      9. lower--.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      11. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      12. lower-*.f6478.2

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
    4. Applied rewrites78.2%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      3. associate-/l*N/A

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
      5. lower-/.f6485.2

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
    6. Applied rewrites85.2%

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

Alternative 3: 77.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.65 \cdot 10^{+129}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

\mathbf{elif}\;c \leq 3 \cdot 10^{-6}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\

\mathbf{elif}\;c \leq 7.8 \cdot 10^{+99}:\\
\;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.64999999999999995e129

    1. Initial program 34.9%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\color{blue}{c}} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{a \cdot d}{c}}{c} \]
      3. metadata-evalN/A

        \[\leadsto \frac{b - 1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. metadata-evalN/A

        \[\leadsto \frac{b - \frac{-1}{-1} \cdot \frac{a \cdot d}{c}}{c} \]
      5. times-fracN/A

        \[\leadsto \frac{b - \frac{-1 \cdot \left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      6. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      7. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{\mathsf{neg}\left(c\right)}}{c} \]
      8. frac-2negN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      9. lower--.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      11. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      12. lower-*.f6480.3

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
    4. Applied rewrites80.3%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      3. *-commutativeN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. associate-/l*N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      6. lower-/.f6486.0

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
    6. Applied rewrites86.0%

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

    if -1.64999999999999995e129 < c < 3.0000000000000001e-6

    1. Initial program 73.4%

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

      \[\leadsto \color{blue}{\frac{-1 \cdot a + \frac{b \cdot c}{d}}{d}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot a + \frac{b \cdot c}{d}}{\color{blue}{d}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} + -1 \cdot a}{d} \]
      3. associate-/l*N/A

        \[\leadsto \frac{b \cdot \frac{c}{d} + -1 \cdot a}{d} \]
      4. lower-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, -1 \cdot a\right)}{d} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, -1 \cdot a\right)}{d} \]
      6. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, \mathsf{neg}\left(a\right)\right)}{d} \]
      7. lower-neg.f6473.9

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d} \]
    4. Applied rewrites73.9%

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

    if 3.0000000000000001e-6 < c < 7.79999999999999989e99

    1. Initial program 74.1%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
    3. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      2. lower-*.f64N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto b \cdot \frac{c}{\color{blue}{{c}^{2} + {d}^{2}}} \]
      4. +-commutativeN/A

        \[\leadsto b \cdot \frac{c}{{d}^{2} + \color{blue}{{c}^{2}}} \]
      5. pow2N/A

        \[\leadsto b \cdot \frac{c}{d \cdot d + {\color{blue}{c}}^{2}} \]
      6. lower-fma.f64N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, \color{blue}{d}, {c}^{2}\right)} \]
      7. pow2N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      8. lift-*.f6460.8

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
    4. Applied rewrites60.8%

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

    if 7.79999999999999989e99 < c

    1. Initial program 35.5%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\color{blue}{c}} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{a \cdot d}{c}}{c} \]
      3. metadata-evalN/A

        \[\leadsto \frac{b - 1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. metadata-evalN/A

        \[\leadsto \frac{b - \frac{-1}{-1} \cdot \frac{a \cdot d}{c}}{c} \]
      5. times-fracN/A

        \[\leadsto \frac{b - \frac{-1 \cdot \left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      6. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      7. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{\mathsf{neg}\left(c\right)}}{c} \]
      8. frac-2negN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      9. lower--.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      11. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      12. lower-*.f6478.3

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
    4. Applied rewrites78.3%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      3. associate-/l*N/A

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
      5. lower-/.f6485.5

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
    6. Applied rewrites85.5%

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

Alternative 4: 77.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+105}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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

\mathbf{elif}\;c \leq 7.8 \cdot 10^{+99}:\\
\;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -2.1000000000000001e105

    1. Initial program 38.0%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\color{blue}{c}} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{a \cdot d}{c}}{c} \]
      3. metadata-evalN/A

        \[\leadsto \frac{b - 1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. metadata-evalN/A

        \[\leadsto \frac{b - \frac{-1}{-1} \cdot \frac{a \cdot d}{c}}{c} \]
      5. times-fracN/A

        \[\leadsto \frac{b - \frac{-1 \cdot \left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      6. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      7. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{\mathsf{neg}\left(c\right)}}{c} \]
      8. frac-2negN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      9. lower--.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      11. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      12. lower-*.f6480.1

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
    4. Applied rewrites80.1%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      3. *-commutativeN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. associate-/l*N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      6. lower-/.f6485.1

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
    6. Applied rewrites85.1%

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

    if -2.1000000000000001e105 < c < 3.0000000000000001e-6

    1. Initial program 73.7%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      3. lower-/.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      4. +-commutativeN/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      5. lower-+.f64N/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      6. mul-1-negN/A

        \[\leadsto -\frac{\left(\mathsf{neg}\left(\frac{b \cdot c}{d}\right)\right) + a}{d} \]
      7. lower-neg.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      8. lower-/.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      9. *-commutativeN/A

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
      10. lower-*.f6475.2

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
    4. Applied rewrites75.2%

      \[\leadsto \color{blue}{-\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d}} \]
    5. Taylor expanded in d around inf

      \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      2. lower--.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      4. lower-*.f6475.2

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
    7. Applied rewrites75.2%

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

    if 3.0000000000000001e-6 < c < 7.79999999999999989e99

    1. Initial program 74.1%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
    3. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      2. lower-*.f64N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto b \cdot \frac{c}{\color{blue}{{c}^{2} + {d}^{2}}} \]
      4. +-commutativeN/A

        \[\leadsto b \cdot \frac{c}{{d}^{2} + \color{blue}{{c}^{2}}} \]
      5. pow2N/A

        \[\leadsto b \cdot \frac{c}{d \cdot d + {\color{blue}{c}}^{2}} \]
      6. lower-fma.f64N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, \color{blue}{d}, {c}^{2}\right)} \]
      7. pow2N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      8. lift-*.f6460.8

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
    4. Applied rewrites60.8%

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

    if 7.79999999999999989e99 < c

    1. Initial program 35.5%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\color{blue}{c}} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{a \cdot d}{c}}{c} \]
      3. metadata-evalN/A

        \[\leadsto \frac{b - 1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. metadata-evalN/A

        \[\leadsto \frac{b - \frac{-1}{-1} \cdot \frac{a \cdot d}{c}}{c} \]
      5. times-fracN/A

        \[\leadsto \frac{b - \frac{-1 \cdot \left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      6. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      7. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{\mathsf{neg}\left(c\right)}}{c} \]
      8. frac-2negN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      9. lower--.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      11. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      12. lower-*.f6478.3

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
    4. Applied rewrites78.3%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      3. associate-/l*N/A

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
      5. lower-/.f6485.5

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
    6. Applied rewrites85.5%

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

Alternative 5: 76.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{if}\;c \leq -2.1 \cdot 10^{+105}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{+99}:\\ \;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- b (* a (/ d c))) c)))
   (if (<= c -2.1e+105)
     t_0
     (if (<= c 3e-6)
       (/ (- (/ (* b c) d) a) d)
       (if (<= c 7.8e+99) (* b (/ c (fma d d (* c c)))) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = (b - (a * (d / c))) / c;
	double tmp;
	if (c <= -2.1e+105) {
		tmp = t_0;
	} else if (c <= 3e-6) {
		tmp = (((b * c) / d) - a) / d;
	} else if (c <= 7.8e+99) {
		tmp = b * (c / fma(d, d, (c * c)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(b - Float64(a * Float64(d / c))) / c)
	tmp = 0.0
	if (c <= -2.1e+105)
		tmp = t_0;
	elseif (c <= 3e-6)
		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
	elseif (c <= 7.8e+99)
		tmp = Float64(b * Float64(c / fma(d, d, Float64(c * c))));
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -2.1e+105], t$95$0, If[LessEqual[c, 3e-6], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 7.8e+99], N[(b * N[(c / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+105}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 7.8 \cdot 10^{+99}:\\
\;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.1000000000000001e105 or 7.79999999999999989e99 < c

    1. Initial program 36.7%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\color{blue}{c}} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1\right)\right) \cdot \frac{a \cdot d}{c}}{c} \]
      3. metadata-evalN/A

        \[\leadsto \frac{b - 1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. metadata-evalN/A

        \[\leadsto \frac{b - \frac{-1}{-1} \cdot \frac{a \cdot d}{c}}{c} \]
      5. times-fracN/A

        \[\leadsto \frac{b - \frac{-1 \cdot \left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      6. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{-1 \cdot c}}{c} \]
      7. mul-1-negN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot d\right)}{\mathsf{neg}\left(c\right)}}{c} \]
      8. frac-2negN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      9. lower--.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      10. lower-/.f64N/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      11. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      12. lower-*.f6479.2

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
    4. Applied rewrites79.2%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \frac{d \cdot a}{c}}{c} \]
      3. *-commutativeN/A

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. associate-/l*N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
      6. lower-/.f6484.6

        \[\leadsto \frac{b - a \cdot \frac{d}{c}}{c} \]
    6. Applied rewrites84.6%

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

    if -2.1000000000000001e105 < c < 3.0000000000000001e-6

    1. Initial program 73.7%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      3. lower-/.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      4. +-commutativeN/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      5. lower-+.f64N/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      6. mul-1-negN/A

        \[\leadsto -\frac{\left(\mathsf{neg}\left(\frac{b \cdot c}{d}\right)\right) + a}{d} \]
      7. lower-neg.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      8. lower-/.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      9. *-commutativeN/A

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
      10. lower-*.f6475.2

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
    4. Applied rewrites75.2%

      \[\leadsto \color{blue}{-\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d}} \]
    5. Taylor expanded in d around inf

      \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      2. lower--.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      4. lower-*.f6475.2

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
    7. Applied rewrites75.2%

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

    if 3.0000000000000001e-6 < c < 7.79999999999999989e99

    1. Initial program 74.1%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
    3. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      2. lower-*.f64N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto b \cdot \frac{c}{\color{blue}{{c}^{2} + {d}^{2}}} \]
      4. +-commutativeN/A

        \[\leadsto b \cdot \frac{c}{{d}^{2} + \color{blue}{{c}^{2}}} \]
      5. pow2N/A

        \[\leadsto b \cdot \frac{c}{d \cdot d + {\color{blue}{c}}^{2}} \]
      6. lower-fma.f64N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, \color{blue}{d}, {c}^{2}\right)} \]
      7. pow2N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      8. lift-*.f6460.8

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
    4. Applied rewrites60.8%

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

Alternative 6: 74.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -7 \cdot 10^{+97}:\\
\;\;\;\;\frac{b}{c}\\

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

\mathbf{elif}\;c \leq 2.7 \cdot 10^{+140}:\\
\;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -7.0000000000000001e97 or 2.70000000000000018e140 < c

    1. Initial program 34.6%

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

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f6475.2

        \[\leadsto \frac{b}{\color{blue}{c}} \]
    4. Applied rewrites75.2%

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

    if -7.0000000000000001e97 < c < 3.0000000000000001e-6

    1. Initial program 73.8%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      3. lower-/.f64N/A

        \[\leadsto -\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d} \]
      4. +-commutativeN/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      5. lower-+.f64N/A

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} + a}{d} \]
      6. mul-1-negN/A

        \[\leadsto -\frac{\left(\mathsf{neg}\left(\frac{b \cdot c}{d}\right)\right) + a}{d} \]
      7. lower-neg.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      8. lower-/.f64N/A

        \[\leadsto -\frac{\left(-\frac{b \cdot c}{d}\right) + a}{d} \]
      9. *-commutativeN/A

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
      10. lower-*.f6475.8

        \[\leadsto -\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d} \]
    4. Applied rewrites75.8%

      \[\leadsto \color{blue}{-\frac{\left(-\frac{c \cdot b}{d}\right) + a}{d}} \]
    5. Taylor expanded in d around inf

      \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      2. lower--.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
      4. lower-*.f6475.8

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{d} \]
    7. Applied rewrites75.8%

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

    if 3.0000000000000001e-6 < c < 2.70000000000000018e140

    1. Initial program 72.2%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
    3. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      2. lower-*.f64N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto b \cdot \frac{c}{\color{blue}{{c}^{2} + {d}^{2}}} \]
      4. +-commutativeN/A

        \[\leadsto b \cdot \frac{c}{{d}^{2} + \color{blue}{{c}^{2}}} \]
      5. pow2N/A

        \[\leadsto b \cdot \frac{c}{d \cdot d + {\color{blue}{c}}^{2}} \]
      6. lower-fma.f64N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, \color{blue}{d}, {c}^{2}\right)} \]
      7. pow2N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      8. lift-*.f6462.4

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
    4. Applied rewrites62.4%

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

Alternative 7: 65.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.6 \cdot 10^{+61}:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{elif}\;c \leq 1.2 \cdot 10^{-125}:\\
\;\;\;\;\frac{-a}{d}\\

\mathbf{elif}\;c \leq 2.7 \cdot 10^{+140}:\\
\;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -6.5999999999999995e61 or 2.70000000000000018e140 < c

    1. Initial program 38.2%

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

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f6472.9

        \[\leadsto \frac{b}{\color{blue}{c}} \]
    4. Applied rewrites72.9%

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

    if -6.5999999999999995e61 < c < 1.2000000000000001e-125

    1. Initial program 72.7%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot a}{\color{blue}{d}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot a}{\color{blue}{d}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(a\right)}{d} \]
      4. lower-neg.f6464.6

        \[\leadsto \frac{-a}{d} \]
    4. Applied rewrites64.6%

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

    if 1.2000000000000001e-125 < c < 2.70000000000000018e140

    1. Initial program 75.2%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
    3. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      2. lower-*.f64N/A

        \[\leadsto b \cdot \color{blue}{\frac{c}{{c}^{2} + {d}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto b \cdot \frac{c}{\color{blue}{{c}^{2} + {d}^{2}}} \]
      4. +-commutativeN/A

        \[\leadsto b \cdot \frac{c}{{d}^{2} + \color{blue}{{c}^{2}}} \]
      5. pow2N/A

        \[\leadsto b \cdot \frac{c}{d \cdot d + {\color{blue}{c}}^{2}} \]
      6. lower-fma.f64N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, \color{blue}{d}, {c}^{2}\right)} \]
      7. pow2N/A

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      8. lift-*.f6456.0

        \[\leadsto b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
    4. Applied rewrites56.0%

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

Alternative 8: 64.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -6.6 \cdot 10^{+61}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{-33}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -6.6e+61) (/ b c) (if (<= c 4.5e-33) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -6.6e+61) {
		tmp = b / c;
	} else if (c <= 4.5e-33) {
		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 (c <= (-6.6d+61)) then
        tmp = b / c
    else if (c <= 4.5d-33) 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 (c <= -6.6e+61) {
		tmp = b / c;
	} else if (c <= 4.5e-33) {
		tmp = -a / d;
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -6.6e+61:
		tmp = b / c
	elif c <= 4.5e-33:
		tmp = -a / d
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -6.6e+61)
		tmp = Float64(b / c);
	elseif (c <= 4.5e-33)
		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 (c <= -6.6e+61)
		tmp = b / c;
	elseif (c <= 4.5e-33)
		tmp = -a / d;
	else
		tmp = b / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -6.6e+61], N[(b / c), $MachinePrecision], If[LessEqual[c, 4.5e-33], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.6 \cdot 10^{+61}:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{elif}\;c \leq 4.5 \cdot 10^{-33}:\\
\;\;\;\;\frac{-a}{d}\\

\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -6.5999999999999995e61 or 4.49999999999999991e-33 < c

    1. Initial program 48.2%

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

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    3. Step-by-step derivation
      1. lower-/.f6466.0

        \[\leadsto \frac{b}{\color{blue}{c}} \]
    4. Applied rewrites66.0%

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

    if -6.5999999999999995e61 < c < 4.49999999999999991e-33

    1. Initial program 73.7%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    3. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot a}{\color{blue}{d}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{-1 \cdot a}{\color{blue}{d}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(a\right)}{d} \]
      4. lower-neg.f6462.5

        \[\leadsto \frac{-a}{d} \]
    4. Applied rewrites62.5%

      \[\leadsto \color{blue}{\frac{-a}{d}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 43.4% 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 61.6%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Step-by-step derivation
    1. lower-/.f6443.4

      \[\leadsto \frac{b}{\color{blue}{c}} \]
  4. Applied rewrites43.4%

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

Reproduce

?
herbie shell --seed 2025101 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64
  (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))