Complex division, imag part

Percentage Accurate: 61.6% → 80.2%
Time: 7.7s
Alternatives: 10
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 61.6% accurate, 1.0× speedup?

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

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

Alternative 1: 80.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -2.35 \cdot 10^{+113}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\ \mathbf{elif}\;c \leq 5.05 \cdot 10^{-141}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{+70}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -2.35e+113)
   (fma
    (fma (- (* (/ a (pow c 4.0)) d) (/ b (pow c 3.0))) d (/ (/ (- a) c) c))
    d
    (/ b c))
   (if (<= c -2.6e+19)
     (* (/ c (fma c c (* d d))) b)
     (if (<= c 5.05e-141)
       (/ (- (/ (* b c) d) a) d)
       (if (<= c 1.4e+70)
         (/ (fma (- d) a (* b c)) (fma d d (* c c)))
         (/ (- b (* (/ a c) d)) c))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -2.35e+113) {
		tmp = fma(fma((((a / pow(c, 4.0)) * d) - (b / pow(c, 3.0))), d, ((-a / c) / c)), d, (b / c));
	} else if (c <= -2.6e+19) {
		tmp = (c / fma(c, c, (d * d))) * b;
	} else if (c <= 5.05e-141) {
		tmp = (((b * c) / d) - a) / d;
	} else if (c <= 1.4e+70) {
		tmp = fma(-d, a, (b * c)) / fma(d, d, (c * c));
	} else {
		tmp = (b - ((a / c) * d)) / c;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -2.35e+113)
		tmp = fma(fma(Float64(Float64(Float64(a / (c ^ 4.0)) * d) - Float64(b / (c ^ 3.0))), d, Float64(Float64(Float64(-a) / c) / c)), d, Float64(b / c));
	elseif (c <= -2.6e+19)
		tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * b);
	elseif (c <= 5.05e-141)
		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
	elseif (c <= 1.4e+70)
		tmp = Float64(fma(Float64(-d), a, Float64(b * c)) / fma(d, d, Float64(c * c)));
	else
		tmp = Float64(Float64(b - Float64(Float64(a / c) * d)) / c);
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.35e+113], N[(N[(N[(N[(N[(a / N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision] - N[(b / N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d + N[(N[((-a) / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] * d + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.6e+19], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], If[LessEqual[c, 5.05e-141], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.4e+70], N[(N[((-d) * a + N[(b * c), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.35 \cdot 10^{+113}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\

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

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

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

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


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

    1. Initial program 38.0%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \frac{a}{{c}^{2}} + d \cdot \left(\frac{a \cdot d}{{c}^{4}} - \frac{b}{{c}^{3}}\right), d, \frac{b}{c}\right)} \]
    5. Applied rewrites93.6%

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

    if -2.3499999999999999e113 < c < -2.6e19

    1. Initial program 89.6%

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

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

        \[\leadsto \color{blue}{\frac{b}{c}} \]
    5. Applied rewrites75.3%

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    6. Taylor expanded in b around inf

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

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

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

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

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

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

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

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

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

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

    if -2.6e19 < c < 5.05000000000000014e-141

    1. Initial program 67.1%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
      10. lower-*.f6484.4

        \[\leadsto \frac{\frac{\color{blue}{b \cdot c}}{d} - a}{d} \]
    5. Applied rewrites84.4%

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

    if 5.05000000000000014e-141 < c < 1.39999999999999995e70

    1. Initial program 83.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. 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. sub-negN/A

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), a, b \cdot c\right)}}{c \cdot c + d \cdot d} \]
      8. lower-neg.f6483.8

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
      12. lower-fma.f6483.8

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

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

    if 1.39999999999999995e70 < c

    1. Initial program 41.5%

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

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

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

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

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

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

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. lower-*.f6487.0

        \[\leadsto \frac{b - \frac{\color{blue}{a \cdot d}}{c}}{c} \]
    5. Applied rewrites87.0%

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

        \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
    7. Recombined 5 regimes into one program.
    8. Final simplification87.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.35 \cdot 10^{+113}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\ \mathbf{elif}\;c \leq 5.05 \cdot 10^{-141}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{+70}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 2: 80.6% accurate, 0.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\ \mathbf{if}\;c \leq -7.5 \cdot 10^{+113}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\ \mathbf{elif}\;c \leq 5.05 \cdot 10^{-141}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{+70}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (/ (- b (* (/ a c) d)) c)))
       (if (<= c -7.5e+113)
         t_0
         (if (<= c -2.6e+19)
           (* (/ c (fma c c (* d d))) b)
           (if (<= c 5.05e-141)
             (/ (- (/ (* b c) d) a) d)
             (if (<= c 1.4e+70)
               (/ (fma (- d) a (* b c)) (fma d d (* c c)))
               t_0))))))
    double code(double a, double b, double c, double d) {
    	double t_0 = (b - ((a / c) * d)) / c;
    	double tmp;
    	if (c <= -7.5e+113) {
    		tmp = t_0;
    	} else if (c <= -2.6e+19) {
    		tmp = (c / fma(c, c, (d * d))) * b;
    	} else if (c <= 5.05e-141) {
    		tmp = (((b * c) / d) - a) / d;
    	} else if (c <= 1.4e+70) {
    		tmp = fma(-d, a, (b * c)) / fma(d, d, (c * c));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c)
    	tmp = 0.0
    	if (c <= -7.5e+113)
    		tmp = t_0;
    	elseif (c <= -2.6e+19)
    		tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * b);
    	elseif (c <= 5.05e-141)
    		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
    	elseif (c <= 1.4e+70)
    		tmp = Float64(fma(Float64(-d), a, Float64(b * c)) / fma(d, d, Float64(c * c)));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -7.5e+113], t$95$0, If[LessEqual[c, -2.6e+19], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], If[LessEqual[c, 5.05e-141], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.4e+70], N[(N[((-d) * a + N[(b * c), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
    \mathbf{if}\;c \leq -7.5 \cdot 10^{+113}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;c \leq -2.6 \cdot 10^{+19}:\\
    \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\
    
    \mathbf{elif}\;c \leq 5.05 \cdot 10^{-141}:\\
    \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
    
    \mathbf{elif}\;c \leq 1.4 \cdot 10^{+70}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if c < -7.5000000000000001e113 or 1.39999999999999995e70 < c

      1. Initial program 40.1%

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

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

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

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

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

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

          \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
        6. lower-*.f6488.9

          \[\leadsto \frac{b - \frac{\color{blue}{a \cdot d}}{c}}{c} \]
      5. Applied rewrites88.9%

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

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

        if -7.5000000000000001e113 < c < -2.6e19

        1. Initial program 89.6%

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

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

            \[\leadsto \color{blue}{\frac{b}{c}} \]
        5. Applied rewrites75.3%

          \[\leadsto \color{blue}{\frac{b}{c}} \]
        6. Taylor expanded in b around inf

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

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

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

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

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

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

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

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

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

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

        if -2.6e19 < c < 5.05000000000000014e-141

        1. Initial program 67.1%

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

          \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
          10. lower-*.f6484.4

            \[\leadsto \frac{\frac{\color{blue}{b \cdot c}}{d} - a}{d} \]
        5. Applied rewrites84.4%

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

        if 5.05000000000000014e-141 < c < 1.39999999999999995e70

        1. Initial program 83.8%

          \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
        2. Add Preprocessing
        3. 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. sub-negN/A

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), a, b \cdot c\right)}}{c \cdot c + d \cdot d} \]
          8. lower-neg.f6483.8

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

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

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

            \[\leadsto \frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\color{blue}{d \cdot d} + c \cdot c} \]
          12. lower-fma.f6483.8

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

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      7. Recombined 4 regimes into one program.
      8. Final simplification87.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.5 \cdot 10^{+113}:\\ \;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\ \mathbf{elif}\;c \leq 5.05 \cdot 10^{-141}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{+70}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\ \end{array} \]
      9. Add Preprocessing

      Alternative 3: 78.3% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\ \mathbf{if}\;c \leq -7.5 \cdot 10^{+113}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\ \mathbf{elif}\;c \leq 3800:\\ \;\;\;\;\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 -7.5e+113)
           t_0
           (if (<= c -2.6e+19)
             (* (/ c (fma c c (* d d))) b)
             (if (<= c 3800.0) (/ (- (/ (* 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 <= -7.5e+113) {
      		tmp = t_0;
      	} else if (c <= -2.6e+19) {
      		tmp = (c / fma(c, c, (d * d))) * b;
      	} else if (c <= 3800.0) {
      		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 <= -7.5e+113)
      		tmp = t_0;
      	elseif (c <= -2.6e+19)
      		tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * b);
      	elseif (c <= 3800.0)
      		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
      	else
      		tmp = t_0;
      	end
      	return 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, -7.5e+113], t$95$0, If[LessEqual[c, -2.6e+19], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], If[LessEqual[c, 3800.0], 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 -7.5 \cdot 10^{+113}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;c \leq -2.6 \cdot 10^{+19}:\\
      \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\
      
      \mathbf{elif}\;c \leq 3800:\\
      \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if c < -7.5000000000000001e113 or 3800 < c

        1. Initial program 46.7%

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

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

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

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

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

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

            \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
          6. lower-*.f6485.4

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

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

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

          if -7.5000000000000001e113 < c < -2.6e19

          1. Initial program 89.6%

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

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

              \[\leadsto \color{blue}{\frac{b}{c}} \]
          5. Applied rewrites75.3%

            \[\leadsto \color{blue}{\frac{b}{c}} \]
          6. Taylor expanded in b around inf

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

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

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

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

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

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

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

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

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

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

          if -2.6e19 < c < 3800

          1. Initial program 70.8%

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

            \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
            10. lower-*.f6477.4

              \[\leadsto \frac{\frac{\color{blue}{b \cdot c}}{d} - a}{d} \]
          5. Applied rewrites77.4%

            \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
        7. Recombined 3 regimes into one program.
        8. Final simplification82.2%

          \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.5 \cdot 10^{+113}:\\ \;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\ \mathbf{elif}\;c \leq 3800:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\ \end{array} \]
        9. Add Preprocessing

        Alternative 4: 64.9% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 1.02 \cdot 10^{-136}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 5.2 \cdot 10^{+128}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (if (<= c -2.6e+19)
           (/ b c)
           (if (<= c 1.02e-136)
             (/ (- a) d)
             (if (<= c 5.2e+128) (* (/ c (fma c c (* d d))) b) (/ b c)))))
        double code(double a, double b, double c, double d) {
        	double tmp;
        	if (c <= -2.6e+19) {
        		tmp = b / c;
        	} else if (c <= 1.02e-136) {
        		tmp = -a / d;
        	} else if (c <= 5.2e+128) {
        		tmp = (c / fma(c, c, (d * d))) * b;
        	} else {
        		tmp = b / c;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	tmp = 0.0
        	if (c <= -2.6e+19)
        		tmp = Float64(b / c);
        	elseif (c <= 1.02e-136)
        		tmp = Float64(Float64(-a) / d);
        	elseif (c <= 5.2e+128)
        		tmp = Float64(Float64(c / fma(c, c, Float64(d * d))) * b);
        	else
        		tmp = Float64(b / c);
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := If[LessEqual[c, -2.6e+19], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.02e-136], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 5.2e+128], N[(N[(c / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;c \leq -2.6 \cdot 10^{+19}:\\
        \;\;\;\;\frac{b}{c}\\
        
        \mathbf{elif}\;c \leq 1.02 \cdot 10^{-136}:\\
        \;\;\;\;\frac{-a}{d}\\
        
        \mathbf{elif}\;c \leq 5.2 \cdot 10^{+128}:\\
        \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{b}{c}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if c < -2.6e19 or 5.2e128 < c

          1. Initial program 46.7%

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

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

              \[\leadsto \color{blue}{\frac{b}{c}} \]
          5. Applied rewrites80.2%

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

          if -2.6e19 < c < 1.0200000000000001e-136

          1. Initial program 67.1%

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

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

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

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

              \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
            4. lower-neg.f6467.1

              \[\leadsto \frac{\color{blue}{-a}}{d} \]
          5. Applied rewrites67.1%

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

          if 1.0200000000000001e-136 < c < 5.2e128

          1. Initial program 82.4%

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

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

              \[\leadsto \color{blue}{\frac{b}{c}} \]
          5. Applied rewrites33.9%

            \[\leadsto \color{blue}{\frac{b}{c}} \]
          6. Taylor expanded in b around inf

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

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

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

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

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

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

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

              \[\leadsto \frac{c}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \cdot b \]
            8. lower-*.f6455.5

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

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

        Alternative 5: 64.5% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-120}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{+122}:\\ \;\;\;\;\frac{b}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot c\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (if (<= c -2.6e+19)
           (/ b c)
           (if (<= c 2.8e-120)
             (/ (- a) d)
             (if (<= c 1.7e+122) (* (/ b (fma c c (* d d))) c) (/ b c)))))
        double code(double a, double b, double c, double d) {
        	double tmp;
        	if (c <= -2.6e+19) {
        		tmp = b / c;
        	} else if (c <= 2.8e-120) {
        		tmp = -a / d;
        	} else if (c <= 1.7e+122) {
        		tmp = (b / fma(c, c, (d * d))) * c;
        	} else {
        		tmp = b / c;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	tmp = 0.0
        	if (c <= -2.6e+19)
        		tmp = Float64(b / c);
        	elseif (c <= 2.8e-120)
        		tmp = Float64(Float64(-a) / d);
        	elseif (c <= 1.7e+122)
        		tmp = Float64(Float64(b / fma(c, c, Float64(d * d))) * c);
        	else
        		tmp = Float64(b / c);
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := If[LessEqual[c, -2.6e+19], N[(b / c), $MachinePrecision], If[LessEqual[c, 2.8e-120], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 1.7e+122], N[(N[(b / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;c \leq -2.6 \cdot 10^{+19}:\\
        \;\;\;\;\frac{b}{c}\\
        
        \mathbf{elif}\;c \leq 2.8 \cdot 10^{-120}:\\
        \;\;\;\;\frac{-a}{d}\\
        
        \mathbf{elif}\;c \leq 1.7 \cdot 10^{+122}:\\
        \;\;\;\;\frac{b}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot c\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{b}{c}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if c < -2.6e19 or 1.7e122 < c

          1. Initial program 46.7%

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

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

              \[\leadsto \color{blue}{\frac{b}{c}} \]
          5. Applied rewrites80.2%

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

          if -2.6e19 < c < 2.79999999999999994e-120

          1. Initial program 67.6%

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

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

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

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

              \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
            4. lower-neg.f6465.3

              \[\leadsto \frac{\color{blue}{-a}}{d} \]
          5. Applied rewrites65.3%

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

          if 2.79999999999999994e-120 < c < 1.7e122

          1. Initial program 83.1%

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{b}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \cdot c \]
            9. lower-*.f6453.2

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

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

        Alternative 6: 76.0% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -7 \cdot 10^{+34}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{+90}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (if (<= d -7e+34)
           (/ (fma (/ c d) b (- a)) d)
           (if (<= d 1.8e+90) (/ (- b (/ (* d a) c)) c) (/ (- (/ (* b c) d) a) d))))
        double code(double a, double b, double c, double d) {
        	double tmp;
        	if (d <= -7e+34) {
        		tmp = fma((c / d), b, -a) / d;
        	} else if (d <= 1.8e+90) {
        		tmp = (b - ((d * a) / c)) / c;
        	} else {
        		tmp = (((b * c) / d) - a) / d;
        	}
        	return tmp;
        }
        
        function code(a, b, c, d)
        	tmp = 0.0
        	if (d <= -7e+34)
        		tmp = Float64(fma(Float64(c / d), b, Float64(-a)) / d);
        	elseif (d <= 1.8e+90)
        		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
        	else
        		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
        	end
        	return tmp
        end
        
        code[a_, b_, c_, d_] := If[LessEqual[d, -7e+34], N[(N[(N[(c / d), $MachinePrecision] * b + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 1.8e+90], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;d \leq -7 \cdot 10^{+34}:\\
        \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\
        
        \mathbf{elif}\;d \leq 1.8 \cdot 10^{+90}:\\
        \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if d < -6.99999999999999996e34

          1. Initial program 53.9%

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

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

              \[\leadsto \color{blue}{\frac{b}{c}} \]
          5. Applied rewrites23.7%

            \[\leadsto \color{blue}{\frac{b}{c}} \]
          6. Taylor expanded in c around 0

            \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
          7. Step-by-step derivation
            1. +-commutativeN/A

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
            7. sub-negN/A

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\mathsf{fma}\left(\frac{c}{d}, b, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
            17. lower-neg.f6481.9

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

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

          if -6.99999999999999996e34 < d < 1.8e90

          1. Initial program 73.4%

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

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

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

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

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

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

              \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
            6. lower-*.f6479.7

              \[\leadsto \frac{b - \frac{\color{blue}{a \cdot d}}{c}}{c} \]
          5. Applied rewrites79.7%

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

          if 1.8e90 < d

          1. Initial program 40.0%

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

            \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
            10. lower-*.f6482.5

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

            \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
        3. Recombined 3 regimes into one program.
        4. Final simplification80.7%

          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7 \cdot 10^{+34}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{c}{d}, b, -a\right)}{d}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{+90}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 7: 71.9% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -1.02 \cdot 10^{+40}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+133}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (let* ((t_0 (/ (- a) d)))
           (if (<= d -1.02e+40)
             t_0
             (if (<= d 3.3e+133) (/ (- b (/ (* d a) c)) c) t_0))))
        double code(double a, double b, double c, double d) {
        	double t_0 = -a / d;
        	double tmp;
        	if (d <= -1.02e+40) {
        		tmp = t_0;
        	} else if (d <= 3.3e+133) {
        		tmp = (b - ((d * a) / c)) / c;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        real(8) function code(a, b, c, d)
            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 <= (-1.02d+40)) then
                tmp = t_0
            else if (d <= 3.3d+133) then
                tmp = (b - ((d * a) / c)) / 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 <= -1.02e+40) {
        		tmp = t_0;
        	} else if (d <= 3.3e+133) {
        		tmp = (b - ((d * a) / c)) / c;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(a, b, c, d):
        	t_0 = -a / d
        	tmp = 0
        	if d <= -1.02e+40:
        		tmp = t_0
        	elif d <= 3.3e+133:
        		tmp = (b - ((d * a) / c)) / c
        	else:
        		tmp = t_0
        	return tmp
        
        function code(a, b, c, d)
        	t_0 = Float64(Float64(-a) / d)
        	tmp = 0.0
        	if (d <= -1.02e+40)
        		tmp = t_0;
        	elseif (d <= 3.3e+133)
        		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / 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 <= -1.02e+40)
        		tmp = t_0;
        	elseif (d <= 3.3e+133)
        		tmp = (b - ((d * a) / c)) / 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, -1.02e+40], t$95$0, If[LessEqual[d, 3.3e+133], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{-a}{d}\\
        \mathbf{if}\;d \leq -1.02 \cdot 10^{+40}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;d \leq 3.3 \cdot 10^{+133}:\\
        \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if d < -1.02e40 or 3.3e133 < d

          1. Initial program 48.2%

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

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

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

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

              \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
            4. lower-neg.f6471.8

              \[\leadsto \frac{\color{blue}{-a}}{d} \]
          5. Applied rewrites71.8%

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

          if -1.02e40 < d < 3.3e133

          1. Initial program 72.8%

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

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

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

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

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

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

              \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
            6. lower-*.f6478.1

              \[\leadsto \frac{b - \frac{\color{blue}{a \cdot d}}{c}}{c} \]
          5. Applied rewrites78.1%

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.02 \cdot 10^{+40}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+133}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 8: 71.5% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -1.02 \cdot 10^{+40}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{+134}:\\ \;\;\;\;\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 -1.02e+40)
             t_0
             (if (<= d 5.4e+134) (/ (- 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 <= -1.02e+40) {
        		tmp = t_0;
        	} else if (d <= 5.4e+134) {
        		tmp = (b - ((a / c) * d)) / c;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        real(8) function code(a, b, c, d)
            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 <= (-1.02d+40)) then
                tmp = t_0
            else if (d <= 5.4d+134) 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 <= -1.02e+40) {
        		tmp = t_0;
        	} else if (d <= 5.4e+134) {
        		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 <= -1.02e+40:
        		tmp = t_0
        	elif d <= 5.4e+134:
        		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 <= -1.02e+40)
        		tmp = t_0;
        	elseif (d <= 5.4e+134)
        		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 <= -1.02e+40)
        		tmp = t_0;
        	elseif (d <= 5.4e+134)
        		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, -1.02e+40], t$95$0, If[LessEqual[d, 5.4e+134], 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 -1.02 \cdot 10^{+40}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;d \leq 5.4 \cdot 10^{+134}:\\
        \;\;\;\;\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 < -1.02e40 or 5.4e134 < d

          1. Initial program 48.2%

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

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

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

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

              \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
            4. lower-neg.f6471.8

              \[\leadsto \frac{\color{blue}{-a}}{d} \]
          5. Applied rewrites71.8%

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

          if -1.02e40 < d < 5.4e134

          1. Initial program 72.8%

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

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

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

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

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

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

              \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
            6. lower-*.f6478.1

              \[\leadsto \frac{b - \frac{\color{blue}{a \cdot d}}{c}}{c} \]
          5. Applied rewrites78.1%

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

              \[\leadsto \frac{b - d \cdot \frac{a}{c}}{c} \]
          7. Recombined 2 regimes into one program.
          8. Final simplification74.5%

            \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.02 \cdot 10^{+40}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{+134}:\\ \;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
          9. Add Preprocessing

          Alternative 9: 63.5% accurate, 1.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -2.6 \cdot 10^{+19}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{-52}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
          (FPCore (a b c d)
           :precision binary64
           (if (<= c -2.6e+19) (/ b c) (if (<= c 1.05e-52) (/ (- a) d) (/ b c))))
          double code(double a, double b, double c, double d) {
          	double tmp;
          	if (c <= -2.6e+19) {
          		tmp = b / c;
          	} else if (c <= 1.05e-52) {
          		tmp = -a / d;
          	} else {
          		tmp = b / c;
          	}
          	return tmp;
          }
          
          real(8) function code(a, b, c, d)
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              real(8), intent (in) :: c
              real(8), intent (in) :: d
              real(8) :: tmp
              if (c <= (-2.6d+19)) then
                  tmp = b / c
              else if (c <= 1.05d-52) then
                  tmp = -a / d
              else
                  tmp = b / c
              end if
              code = tmp
          end function
          
          public static double code(double a, double b, double c, double d) {
          	double tmp;
          	if (c <= -2.6e+19) {
          		tmp = b / c;
          	} else if (c <= 1.05e-52) {
          		tmp = -a / d;
          	} else {
          		tmp = b / c;
          	}
          	return tmp;
          }
          
          def code(a, b, c, d):
          	tmp = 0
          	if c <= -2.6e+19:
          		tmp = b / c
          	elif c <= 1.05e-52:
          		tmp = -a / d
          	else:
          		tmp = b / c
          	return tmp
          
          function code(a, b, c, d)
          	tmp = 0.0
          	if (c <= -2.6e+19)
          		tmp = Float64(b / c);
          	elseif (c <= 1.05e-52)
          		tmp = Float64(Float64(-a) / d);
          	else
          		tmp = Float64(b / c);
          	end
          	return tmp
          end
          
          function tmp_2 = code(a, b, c, d)
          	tmp = 0.0;
          	if (c <= -2.6e+19)
          		tmp = b / c;
          	elseif (c <= 1.05e-52)
          		tmp = -a / d;
          	else
          		tmp = b / c;
          	end
          	tmp_2 = tmp;
          end
          
          code[a_, b_, c_, d_] := If[LessEqual[c, -2.6e+19], N[(b / c), $MachinePrecision], If[LessEqual[c, 1.05e-52], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;c \leq -2.6 \cdot 10^{+19}:\\
          \;\;\;\;\frac{b}{c}\\
          
          \mathbf{elif}\;c \leq 1.05 \cdot 10^{-52}:\\
          \;\;\;\;\frac{-a}{d}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{b}{c}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if c < -2.6e19 or 1.0499999999999999e-52 < c

            1. Initial program 55.9%

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

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

                \[\leadsto \color{blue}{\frac{b}{c}} \]
            5. Applied rewrites67.5%

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

            if -2.6e19 < c < 1.0499999999999999e-52

            1. Initial program 70.7%

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

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

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

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

                \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
              4. lower-neg.f6463.3

                \[\leadsto \frac{\color{blue}{-a}}{d} \]
            5. Applied rewrites63.3%

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

          Alternative 10: 42.9% accurate, 3.2× speedup?

          \[\begin{array}{l} \\ \frac{b}{c} \end{array} \]
          (FPCore (a b c d) :precision binary64 (/ b c))
          double code(double a, double b, double c, double d) {
          	return b / c;
          }
          
          real(8) function code(a, b, c, d)
              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 63.0%

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

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

              \[\leadsto \color{blue}{\frac{b}{c}} \]
          5. Applied rewrites45.0%

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

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

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
          (FPCore (a b c d)
           :precision binary64
           (if (< (fabs d) (fabs c))
             (/ (- b (* a (/ d c))) (+ c (* d (/ d c))))
             (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
          double code(double a, double b, double c, double d) {
          	double tmp;
          	if (fabs(d) < fabs(c)) {
          		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
          	} else {
          		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
          	}
          	return tmp;
          }
          
          real(8) function code(a, b, c, d)
              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 2024255 
          (FPCore (a b c d)
            :name "Complex division, imag part"
            :precision binary64
          
            :alt
            (! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
          
            (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))