Complex division, imag part

Percentage Accurate: 62.2% → 84.0%
Time: 3.6s
Alternatives: 14
Speedup: 1.7×

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 14 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: 62.2% 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: 84.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;c \leq -1.06 \cdot 10^{-135}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot d, \frac{-1}{c} \cdot c, b \cdot c\right)}{t\_0}\\

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

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

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


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

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

    if -2.6000000000000001e41 < c < -1.06000000000000004e-135

    1. Initial program 62.2%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b} - a \cdot d}{c \cdot c + d \cdot d} \]
      3. lower-*.f6462.2

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

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

        \[\leadsto \frac{c \cdot b - \color{blue}{d \cdot a}}{c \cdot c + d \cdot d} \]
      6. lower-*.f6462.2

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

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

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      10. sqr-abs-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left(\mathsf{neg}\left(\left|c\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      15. remove-double-negN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left|c\right|}\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      16. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      17. sqr-abs-revN/A

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      19. lower-fma.f6462.2

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

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

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

    if -1.06000000000000004e-135 < c < 9.00000000000000031e-84

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      6. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - a \cdot 1}{d} \]
      8. *-rgt-identity51.8

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

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

    if 9.00000000000000031e-84 < c < 1.5e117

    1. Initial program 62.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied rewrites62.0%

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

    if 1.5e117 < c

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

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

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

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. mult-flipN/A

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right) \cdot \frac{1}{c}}{c} \]
      6. distribute-lft-neg-outN/A

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

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(-1 \cdot a\right) \cdot d\right)\right) \cdot \frac{1}{c}}{c} \]
      9. distribute-lft-neg-outN/A

        \[\leadsto \frac{b - \left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot d\right) \cdot \frac{1}{c}}{c} \]
      10. associate-*l*N/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \left(d \cdot \frac{1}{c}\right)}{c} \]
      11. mult-flipN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \frac{d}{c}}{c} \]
      12. *-commutativeN/A

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

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

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{c} \]
      16. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{c} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(a \cdot 1\right)}{c} \]
      19. *-rgt-identity55.1

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

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

Alternative 2: 83.8% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;c \leq -1.06 \cdot 10^{-135}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot d, \frac{-1}{c} \cdot c, b \cdot c\right)}{t\_0}\\

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

\mathbf{elif}\;c \leq 3.7 \cdot 10^{+118}:\\
\;\;\;\;\frac{b}{t\_0} \cdot c - \frac{a}{t\_0} \cdot d\\

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


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

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

    if -2.6000000000000001e41 < c < -1.06000000000000004e-135

    1. Initial program 62.2%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b} - a \cdot d}{c \cdot c + d \cdot d} \]
      3. lower-*.f6462.2

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

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

        \[\leadsto \frac{c \cdot b - \color{blue}{d \cdot a}}{c \cdot c + d \cdot d} \]
      6. lower-*.f6462.2

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

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

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      10. sqr-abs-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left(\mathsf{neg}\left(\left|c\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      15. remove-double-negN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left|c\right|}\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      16. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      17. sqr-abs-revN/A

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      19. lower-fma.f6462.2

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

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

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

    if -1.06000000000000004e-135 < c < 1.34999999999999996e-83

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      6. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - a \cdot 1}{d} \]
      8. *-rgt-identity51.8

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

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

    if 1.34999999999999996e-83 < c < 3.69999999999999987e118

    1. Initial program 62.2%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
    3. Applied rewrites59.5%

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

    if 3.69999999999999987e118 < c

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

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

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

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. mult-flipN/A

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right) \cdot \frac{1}{c}}{c} \]
      6. distribute-lft-neg-outN/A

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

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(-1 \cdot a\right) \cdot d\right)\right) \cdot \frac{1}{c}}{c} \]
      9. distribute-lft-neg-outN/A

        \[\leadsto \frac{b - \left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot d\right) \cdot \frac{1}{c}}{c} \]
      10. associate-*l*N/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \left(d \cdot \frac{1}{c}\right)}{c} \]
      11. mult-flipN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \frac{d}{c}}{c} \]
      12. *-commutativeN/A

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

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

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{c} \]
      16. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{c} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(a \cdot 1\right)}{c} \]
      19. *-rgt-identity55.1

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

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

Alternative 3: 83.4% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;c \leq -1.06 \cdot 10^{-135}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a \cdot d, \frac{-1}{c} \cdot c, b \cdot c\right)}{t\_0}\\

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

\mathbf{elif}\;c \leq 1.5 \cdot 10^{+117}:\\
\;\;\;\;c \cdot \frac{b - d \cdot \frac{a}{c}}{t\_0}\\

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


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

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

    if -2.6000000000000001e41 < c < -1.06000000000000004e-135

    1. Initial program 62.2%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b} - a \cdot d}{c \cdot c + d \cdot d} \]
      3. lower-*.f6462.2

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

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

        \[\leadsto \frac{c \cdot b - \color{blue}{d \cdot a}}{c \cdot c + d \cdot d} \]
      6. lower-*.f6462.2

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

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

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      10. sqr-abs-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left(\mathsf{neg}\left(\left|c\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      15. remove-double-negN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left|c\right|}\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      16. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      17. sqr-abs-revN/A

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      19. lower-fma.f6462.2

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

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

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

    if -1.06000000000000004e-135 < c < 1.89999999999999988e-83

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      6. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - a \cdot 1}{d} \]
      8. *-rgt-identity51.8

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

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

    if 1.89999999999999988e-83 < c < 1.5e117

    1. Initial program 62.2%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b} - a \cdot d}{c \cdot c + d \cdot d} \]
      3. lower-*.f6462.2

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

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

        \[\leadsto \frac{c \cdot b - \color{blue}{d \cdot a}}{c \cdot c + d \cdot d} \]
      6. lower-*.f6462.2

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

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

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      10. sqr-abs-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left(\mathsf{neg}\left(\left|c\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      15. remove-double-negN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left|c\right|}\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      16. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      17. sqr-abs-revN/A

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      19. lower-fma.f6462.2

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

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

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

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

    if 1.5e117 < c

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

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

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

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. mult-flipN/A

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right) \cdot \frac{1}{c}}{c} \]
      6. distribute-lft-neg-outN/A

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

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(-1 \cdot a\right) \cdot d\right)\right) \cdot \frac{1}{c}}{c} \]
      9. distribute-lft-neg-outN/A

        \[\leadsto \frac{b - \left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot d\right) \cdot \frac{1}{c}}{c} \]
      10. associate-*l*N/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \left(d \cdot \frac{1}{c}\right)}{c} \]
      11. mult-flipN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \frac{d}{c}}{c} \]
      12. *-commutativeN/A

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

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

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{c} \]
      16. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{c} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(a \cdot 1\right)}{c} \]
      19. *-rgt-identity55.1

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

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

Alternative 4: 83.4% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;c \leq -1.06 \cdot 10^{-135}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{t\_0}\\

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

\mathbf{elif}\;c \leq 1.5 \cdot 10^{+117}:\\
\;\;\;\;c \cdot \frac{b - d \cdot \frac{a}{c}}{t\_0}\\

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


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

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

    if -2.6000000000000001e41 < c < -1.06000000000000004e-135

    1. Initial program 62.2%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b} - a \cdot d}{c \cdot c + d \cdot d} \]
      3. lower-*.f6462.2

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

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

        \[\leadsto \frac{c \cdot b - \color{blue}{d \cdot a}}{c \cdot c + d \cdot d} \]
      6. lower-*.f6462.2

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

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

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      10. sqr-abs-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left(\mathsf{neg}\left(\left|c\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      15. remove-double-negN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left|c\right|}\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      16. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      17. sqr-abs-revN/A

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      19. lower-fma.f6462.2

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

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

    if -1.06000000000000004e-135 < c < 1.89999999999999988e-83

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      6. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - a \cdot 1}{d} \]
      8. *-rgt-identity51.8

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

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

    if 1.89999999999999988e-83 < c < 1.5e117

    1. Initial program 62.2%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b} - a \cdot d}{c \cdot c + d \cdot d} \]
      3. lower-*.f6462.2

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

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

        \[\leadsto \frac{c \cdot b - \color{blue}{d \cdot a}}{c \cdot c + d \cdot d} \]
      6. lower-*.f6462.2

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

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

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      10. sqr-abs-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left(\mathsf{neg}\left(\left|c\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      15. remove-double-negN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left|c\right|}\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      16. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      17. sqr-abs-revN/A

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      19. lower-fma.f6462.2

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

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

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

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

    if 1.5e117 < c

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

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

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

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. mult-flipN/A

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right) \cdot \frac{1}{c}}{c} \]
      6. distribute-lft-neg-outN/A

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

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(-1 \cdot a\right) \cdot d\right)\right) \cdot \frac{1}{c}}{c} \]
      9. distribute-lft-neg-outN/A

        \[\leadsto \frac{b - \left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot d\right) \cdot \frac{1}{c}}{c} \]
      10. associate-*l*N/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \left(d \cdot \frac{1}{c}\right)}{c} \]
      11. mult-flipN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \frac{d}{c}}{c} \]
      12. *-commutativeN/A

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

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

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{c} \]
      16. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{c} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(a \cdot 1\right)}{c} \]
      19. *-rgt-identity55.1

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

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

Alternative 5: 83.3% accurate, 0.6× speedup?

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

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

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

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

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

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


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

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

    if -2.6000000000000001e41 < c < -1.06000000000000004e-135

    1. Initial program 62.2%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b} - a \cdot d}{c \cdot c + d \cdot d} \]
      3. lower-*.f6462.2

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

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

        \[\leadsto \frac{c \cdot b - \color{blue}{d \cdot a}}{c \cdot c + d \cdot d} \]
      6. lower-*.f6462.2

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

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

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      10. sqr-abs-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left(\mathsf{neg}\left(\left|c\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      15. remove-double-negN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left|c\right|}\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      16. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      17. sqr-abs-revN/A

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      19. lower-fma.f6462.2

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

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

    if -1.06000000000000004e-135 < c < 2.50000000000000007e-140

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      6. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - a \cdot 1}{d} \]
      8. *-rgt-identity51.8

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

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

    if 2.50000000000000007e-140 < c < 3.54999999999999996e50

    1. Initial program 62.2%

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

    if 3.54999999999999996e50 < c

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(b + -1 \cdot \frac{a \cdot d}{c}\right)\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)}} \]
      4. remove-double-negN/A

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(c\right)\right)}\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{-1 \cdot \frac{a \cdot d}{c} + b}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(c\right)\right)}\right)} \]
      7. div-addN/A

        \[\leadsto \frac{-1 \cdot \frac{a \cdot d}{c}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} + \color{blue}{\frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)}} \]
      8. remove-double-negN/A

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\frac{a \cdot d}{c}\right)}{c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      12. distribute-neg-fracN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(a \cdot d\right)}{c}}{c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      13. associate-/l/N/A

        \[\leadsto \frac{\mathsf{neg}\left(a \cdot d\right)}{c \cdot c} + \frac{\color{blue}{b}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      14. lift-*.f64N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(d \cdot a\right)}{c \cdot c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      16. distribute-lft-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(d\right)\right) \cdot a}{c \cdot c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      17. times-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(d\right)}{c} \cdot \frac{a}{c} + \frac{\color{blue}{b}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      18. distribute-neg-fracN/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{d}{c}\right)\right) \cdot \frac{a}{c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      19. distribute-neg-frac2N/A

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

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

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

        \[\leadsto \left(\mathsf{neg}\left(\frac{d}{c}\right)\right) \cdot \frac{a}{c} + \frac{b}{\color{blue}{c}} \]
    6. Applied rewrites53.7%

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

Alternative 6: 83.3% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;c \leq -1.06 \cdot 10^{-135}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 3.55 \cdot 10^{+50}:\\
\;\;\;\;t\_0\\

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


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

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

    if -2.6000000000000001e41 < c < -1.06000000000000004e-135 or 2.50000000000000007e-140 < c < 3.54999999999999996e50

    1. Initial program 62.2%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b} - a \cdot d}{c \cdot c + d \cdot d} \]
      3. lower-*.f6462.2

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

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

        \[\leadsto \frac{c \cdot b - \color{blue}{d \cdot a}}{c \cdot c + d \cdot d} \]
      6. lower-*.f6462.2

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

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

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      10. sqr-abs-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      11. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left(\mathsf{neg}\left(\left|c\right|\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      12. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      13. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)}} \]
      14. lift-*.f64N/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{\color{blue}{d \cdot d} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left|c\right|\right)\right)\right)\right)\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      15. remove-double-negN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \left(\mathsf{neg}\left(\color{blue}{\left|c\right|}\right)\right) \cdot \left(\mathsf{neg}\left(\left|c\right|\right)\right)} \]
      16. sqr-neg-revN/A

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{\left|c\right| \cdot \left|c\right|}} \]
      17. sqr-abs-revN/A

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

        \[\leadsto \frac{c \cdot b - d \cdot a}{d \cdot d + \color{blue}{c \cdot c}} \]
      19. lower-fma.f6462.2

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

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

    if -1.06000000000000004e-135 < c < 2.50000000000000007e-140

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      6. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - a \cdot 1}{d} \]
      8. *-rgt-identity51.8

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

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

    if 3.54999999999999996e50 < c

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(b + -1 \cdot \frac{a \cdot d}{c}\right)\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)}} \]
      4. remove-double-negN/A

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(c\right)\right)}\right)} \]
      6. +-commutativeN/A

        \[\leadsto \frac{-1 \cdot \frac{a \cdot d}{c} + b}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(c\right)\right)}\right)} \]
      7. div-addN/A

        \[\leadsto \frac{-1 \cdot \frac{a \cdot d}{c}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} + \color{blue}{\frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)}} \]
      8. remove-double-negN/A

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\frac{a \cdot d}{c}\right)}{c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      12. distribute-neg-fracN/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(a \cdot d\right)}{c}}{c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      13. associate-/l/N/A

        \[\leadsto \frac{\mathsf{neg}\left(a \cdot d\right)}{c \cdot c} + \frac{\color{blue}{b}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      14. lift-*.f64N/A

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

        \[\leadsto \frac{\mathsf{neg}\left(d \cdot a\right)}{c \cdot c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      16. distribute-lft-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(d\right)\right) \cdot a}{c \cdot c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      17. times-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(d\right)}{c} \cdot \frac{a}{c} + \frac{\color{blue}{b}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      18. distribute-neg-fracN/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{d}{c}\right)\right) \cdot \frac{a}{c} + \frac{b}{\mathsf{neg}\left(\left(\mathsf{neg}\left(c\right)\right)\right)} \]
      19. distribute-neg-frac2N/A

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

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

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

        \[\leadsto \left(\mathsf{neg}\left(\frac{d}{c}\right)\right) \cdot \frac{a}{c} + \frac{b}{\color{blue}{c}} \]
    6. Applied rewrites53.7%

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

Alternative 7: 77.9% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.69999999999999999e41 or 9.00000000000000034e81 < d

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, \mathsf{neg}\left(a\right)\right)}{d} \]
      11. *-rgt-identityN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, \mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)\right)}{d} \]
      13. distribute-rgt-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, \mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)\right)}{d} \]
      14. *-commutativeN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -\left(\mathsf{neg}\left(-1 \cdot a\right)\right)\right)}{d} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{d} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -a \cdot 1\right)}{d} \]
      19. *-rgt-identity53.0

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

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

    if -1.69999999999999999e41 < d < 9.00000000000000034e81

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\mathsf{neg}\left(-1 \cdot \left(a \cdot d\right)\right)}{\mathsf{neg}\left(c\right)} + b}{c} \]
      8. associate-*l*N/A

        \[\leadsto \frac{\frac{\mathsf{neg}\left(\left(-1 \cdot a\right) \cdot d\right)}{\mathsf{neg}\left(c\right)} + b}{c} \]
      9. distribute-lft-neg-outN/A

        \[\leadsto \frac{\frac{\left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot d}{\mathsf{neg}\left(c\right)} + b}{c} \]
      10. associate-/l*N/A

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{neg}\left(\frac{d}{c}\right), \mathsf{neg}\left(-1 \cdot a\right), b\right)}{c} \]
      14. distribute-neg-fracN/A

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{-d}{c}, \mathsf{neg}\left(-1 \cdot a\right), b\right)}{c} \]
      17. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{-d}{c}, \mathsf{neg}\left(a \cdot -1\right), b\right)}{c} \]
      18. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{-d}{c}, a \cdot 1, b\right)}{c} \]
      20. *-rgt-identity55.1

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

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

Alternative 8: 77.4% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.69999999999999999e41 or 9.00000000000000034e81 < d

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, \mathsf{neg}\left(a\right)\right)}{d} \]
      11. *-rgt-identityN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, \mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)\right)}{d} \]
      13. distribute-rgt-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, \mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)\right)}{d} \]
      14. *-commutativeN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -\left(\mathsf{neg}\left(-1 \cdot a\right)\right)\right)}{d} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{d} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -a \cdot 1\right)}{d} \]
      19. *-rgt-identity53.0

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

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

    if -1.69999999999999999e41 < d < 9.00000000000000034e81

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

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

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

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. mult-flipN/A

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right) \cdot \frac{1}{c}}{c} \]
      6. distribute-lft-neg-outN/A

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

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(-1 \cdot a\right) \cdot d\right)\right) \cdot \frac{1}{c}}{c} \]
      9. distribute-lft-neg-outN/A

        \[\leadsto \frac{b - \left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot d\right) \cdot \frac{1}{c}}{c} \]
      10. associate-*l*N/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \left(d \cdot \frac{1}{c}\right)}{c} \]
      11. mult-flipN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \frac{d}{c}}{c} \]
      12. *-commutativeN/A

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

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

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{c} \]
      16. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{c} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(a \cdot 1\right)}{c} \]
      19. *-rgt-identity55.1

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

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

Alternative 9: 77.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\ \mathbf{if}\;c \leq -1.22 \cdot 10^{-28}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 5.2 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- b (* (/ a c) d)) c)))
   (if (<= c -1.22e-28)
     t_0
     (if (<= c 5.2e-79) (/ (- (/ (* b c) d) a) d) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = (b - ((a / c) * d)) / c;
	double tmp;
	if (c <= -1.22e-28) {
		tmp = t_0;
	} else if (c <= 5.2e-79) {
		tmp = (((b * c) / d) - a) / d;
	} 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) :: tmp
    t_0 = (b - ((a / c) * d)) / c
    if (c <= (-1.22d-28)) then
        tmp = t_0
    else if (c <= 5.2d-79) then
        tmp = (((b * c) / d) - a) / d
    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 = (b - ((a / c) * d)) / c;
	double tmp;
	if (c <= -1.22e-28) {
		tmp = t_0;
	} else if (c <= 5.2e-79) {
		tmp = (((b * c) / d) - a) / d;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b - ((a / c) * d)) / c
	tmp = 0
	if c <= -1.22e-28:
		tmp = t_0
	elif c <= 5.2e-79:
		tmp = (((b * c) / d) - a) / d
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c)
	tmp = 0.0
	if (c <= -1.22e-28)
		tmp = t_0;
	elseif (c <= 5.2e-79)
		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b - ((a / c) * d)) / c;
	tmp = 0.0;
	if (c <= -1.22e-28)
		tmp = t_0;
	elseif (c <= 5.2e-79)
		tmp = (((b * c) / d) - a) / d;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.22e-28], t$95$0, If[LessEqual[c, 5.2e-79], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.22e-28 or 5.19999999999999987e-79 < c

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

    if -1.22e-28 < c < 5.19999999999999987e-79

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      6. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\frac{b \cdot c}{d} - a \cdot 1}{d} \]
      8. *-rgt-identity51.8

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

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

Alternative 10: 77.0% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.69999999999999999e41 or 9.00000000000000034e81 < d

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d}} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, \mathsf{neg}\left(a\right)\right)}{d} \]
      11. *-rgt-identityN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, \mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)\right)}{d} \]
      13. distribute-rgt-neg-outN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, \mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)\right)}{d} \]
      14. *-commutativeN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -\left(\mathsf{neg}\left(-1 \cdot a\right)\right)\right)}{d} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{d} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -a \cdot 1\right)}{d} \]
      19. *-rgt-identity53.0

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

      \[\leadsto \frac{\mathsf{fma}\left(\frac{b}{d}, c, -a\right)}{d} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

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

        \[\leadsto \frac{\frac{b}{d} \cdot c + \left(\mathsf{neg}\left(a\right)\right)}{d} \]
      3. sub-flip-reverseN/A

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{d} \cdot b - a}{d} \]
      10. lower-*.f6453.6

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

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

    if -1.69999999999999999e41 < d < 9.00000000000000034e81

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

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

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

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. mult-flipN/A

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right) \cdot \frac{1}{c}}{c} \]
      6. distribute-lft-neg-outN/A

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

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(-1 \cdot a\right) \cdot d\right)\right) \cdot \frac{1}{c}}{c} \]
      9. distribute-lft-neg-outN/A

        \[\leadsto \frac{b - \left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot d\right) \cdot \frac{1}{c}}{c} \]
      10. associate-*l*N/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \left(d \cdot \frac{1}{c}\right)}{c} \]
      11. mult-flipN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \frac{d}{c}}{c} \]
      12. *-commutativeN/A

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

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

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{c} \]
      16. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{c} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(a \cdot 1\right)}{c} \]
      19. *-rgt-identity55.1

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

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

Alternative 11: 73.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.5999999999999999e44 or 9.00000000000000034e81 < d

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

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

      \[\leadsto \frac{-1 \cdot a}{d} \]
    6. Step-by-step derivation
      1. lower-*.f6442.5

        \[\leadsto \frac{-1 \cdot a}{d} \]
    7. Applied rewrites42.5%

      \[\leadsto \frac{-1 \cdot a}{d} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-1 \cdot a}{d} \]
      2. remove-double-negN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right)\right)\right) \cdot a}{d} \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot a\right)}{d} \]
      4. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right)\right)}{d} \]
      5. lift-*.f64N/A

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

        \[\leadsto \frac{-\left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{-\left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      8. *-commutativeN/A

        \[\leadsto \frac{-\left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      9. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{-a \cdot 1}{d} \]
      11. *-rgt-identity42.5

        \[\leadsto \frac{-a}{d} \]
    9. Applied rewrites42.5%

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

    if -2.5999999999999999e44 < d < 9.00000000000000034e81

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

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

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

        \[\leadsto \frac{b - \frac{a \cdot d}{c}}{c} \]
      4. mult-flipN/A

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot d\right)\right)\right)\right) \cdot \frac{1}{c}}{c} \]
      6. distribute-lft-neg-outN/A

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

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

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(\left(-1 \cdot a\right) \cdot d\right)\right) \cdot \frac{1}{c}}{c} \]
      9. distribute-lft-neg-outN/A

        \[\leadsto \frac{b - \left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot d\right) \cdot \frac{1}{c}}{c} \]
      10. associate-*l*N/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \left(d \cdot \frac{1}{c}\right)}{c} \]
      11. mult-flipN/A

        \[\leadsto \frac{b - \left(\mathsf{neg}\left(-1 \cdot a\right)\right) \cdot \frac{d}{c}}{c} \]
      12. *-commutativeN/A

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

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

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{c} \]
      16. *-commutativeN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(\mathsf{neg}\left(a \cdot -1\right)\right)}{c} \]
      17. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{d}{c} \cdot \left(a \cdot 1\right)}{c} \]
      19. *-rgt-identity55.1

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

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

Alternative 12: 72.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.5999999999999999e44 or 9.00000000000000034e81 < d

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

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

      \[\leadsto \frac{-1 \cdot a}{d} \]
    6. Step-by-step derivation
      1. lower-*.f6442.5

        \[\leadsto \frac{-1 \cdot a}{d} \]
    7. Applied rewrites42.5%

      \[\leadsto \frac{-1 \cdot a}{d} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-1 \cdot a}{d} \]
      2. remove-double-negN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right)\right)\right) \cdot a}{d} \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot a\right)}{d} \]
      4. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right)\right)}{d} \]
      5. lift-*.f64N/A

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

        \[\leadsto \frac{-\left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{-\left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      8. *-commutativeN/A

        \[\leadsto \frac{-\left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      9. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{-a \cdot 1}{d} \]
      11. *-rgt-identity42.5

        \[\leadsto \frac{-a}{d} \]
    9. Applied rewrites42.5%

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

    if -2.5999999999999999e44 < d < 9.00000000000000034e81

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

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

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

        \[\leadsto \frac{b + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      5. lower-*.f6453.3

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

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

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

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

        \[\leadsto \frac{b + \left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}{c} \]
      4. sub-flip-reverseN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      13. *-rgt-identityN/A

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot \left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      15. distribute-rgt-neg-outN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot -1\right)\right)\right)}{\mathsf{neg}\left(c\right)} \cdot d}{c} \]
      16. *-commutativeN/A

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

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

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(-1 \cdot a\right)}{c} \cdot d}{c} \]
      19. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\mathsf{neg}\left(a \cdot -1\right)}{c} \cdot d}{c} \]
      20. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{b - \frac{a \cdot 1}{c} \cdot d}{c} \]
      22. *-rgt-identity54.5

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

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

Alternative 13: 63.5% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -2.35 \cdot 10^{+44}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 9 \cdot 10^{+81}:\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.35000000000000009e44 or 9.00000000000000034e81 < d

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-1, a, \frac{b \cdot c}{d}\right)}{d} \]
      4. lower-*.f6451.8

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

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

      \[\leadsto \frac{-1 \cdot a}{d} \]
    6. Step-by-step derivation
      1. lower-*.f6442.5

        \[\leadsto \frac{-1 \cdot a}{d} \]
    7. Applied rewrites42.5%

      \[\leadsto \frac{-1 \cdot a}{d} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{-1 \cdot a}{d} \]
      2. remove-double-negN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right)\right)\right) \cdot a}{d} \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right) \cdot a\right)}{d} \]
      4. distribute-lft-neg-outN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1 \cdot a\right)\right)\right)}{d} \]
      5. lift-*.f64N/A

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

        \[\leadsto \frac{-\left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{-\left(\mathsf{neg}\left(-1 \cdot a\right)\right)}{d} \]
      8. *-commutativeN/A

        \[\leadsto \frac{-\left(\mathsf{neg}\left(a \cdot -1\right)\right)}{d} \]
      9. distribute-rgt-neg-outN/A

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

        \[\leadsto \frac{-a \cdot 1}{d} \]
      11. *-rgt-identity42.5

        \[\leadsto \frac{-a}{d} \]
    9. Applied rewrites42.5%

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

    if -2.35000000000000009e44 < d < 9.00000000000000034e81

    1. Initial program 62.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-/.f6443.4

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

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

Alternative 14: 43.4% accurate, 4.9× 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 62.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-/.f6443.4

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

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

Developer Target 1: 99.3% accurate, 0.7× 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 2025156 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (! :herbie-platform c (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))))