Complex division, imag part

Percentage Accurate: 61.6% → 83.9%
Time: 6.2s
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: 83.9% accurate, 0.5× speedup?

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

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

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

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

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

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


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

    1. Initial program 37.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. fp-cancel-sign-sub-invN/A

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

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

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

        \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
      6. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -7.9999999999999998e107 < c < -2.09999999999999977e-53

      1. Initial program 76.8%

        \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
      2. Add Preprocessing
      3. Applied rewrites80.6%

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

      if -2.09999999999999977e-53 < c < 6.8000000000000002e-67

      1. Initial program 63.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. fp-cancel-sign-sub-invN/A

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

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

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

          \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
        6. *-lft-identityN/A

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

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

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

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

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

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

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

      if 6.8000000000000002e-67 < c < 4.29999999999999996e108

      1. Initial program 87.5%

        \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
      2. Add Preprocessing
      3. Applied rewrites96.6%

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

      if 4.29999999999999996e108 < c

      1. Initial program 27.9%

        \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
      2. Add Preprocessing
      3. Applied rewrites29.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8 \cdot 10^{+107}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, a, -b\right)}{-c}\\ \mathbf{elif}\;c \leq -2.1 \cdot 10^{-53}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}, b, \left(-d\right) \cdot \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{+108}:\\ \;\;\;\;\mathsf{fma}\left(-a, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{a}{c}, -b\right)}{-c}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 2: 84.0% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ t_1 := \mathsf{fma}\left(-a, \frac{d}{t\_0}, \frac{c}{t\_0} \cdot b\right)\\ \mathbf{if}\;c \leq -6.4 \cdot 10^{+105}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, a, -b\right)}{-c}\\ \mathbf{elif}\;c \leq -2.1 \cdot 10^{-53}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{+108}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{a}{c}, -b\right)}{-c}\\ \end{array} \end{array} \]
    (FPCore (a b c d)
     :precision binary64
     (let* ((t_0 (fma d d (* c c))) (t_1 (fma (- a) (/ d t_0) (* (/ c t_0) b))))
       (if (<= c -6.4e+105)
         (/ (fma (/ d c) a (- b)) (- c))
         (if (<= c -2.1e-53)
           t_1
           (if (<= c 6.8e-67)
             (/ (- (/ (* b c) d) a) d)
             (if (<= c 4.3e+108) t_1 (/ (fma d (/ a c) (- b)) (- c))))))))
    double code(double a, double b, double c, double d) {
    	double t_0 = fma(d, d, (c * c));
    	double t_1 = fma(-a, (d / t_0), ((c / t_0) * b));
    	double tmp;
    	if (c <= -6.4e+105) {
    		tmp = fma((d / c), a, -b) / -c;
    	} else if (c <= -2.1e-53) {
    		tmp = t_1;
    	} else if (c <= 6.8e-67) {
    		tmp = (((b * c) / d) - a) / d;
    	} else if (c <= 4.3e+108) {
    		tmp = t_1;
    	} else {
    		tmp = fma(d, (a / c), -b) / -c;
    	}
    	return tmp;
    }
    
    function code(a, b, c, d)
    	t_0 = fma(d, d, Float64(c * c))
    	t_1 = fma(Float64(-a), Float64(d / t_0), Float64(Float64(c / t_0) * b))
    	tmp = 0.0
    	if (c <= -6.4e+105)
    		tmp = Float64(fma(Float64(d / c), a, Float64(-b)) / Float64(-c));
    	elseif (c <= -2.1e-53)
    		tmp = t_1;
    	elseif (c <= 6.8e-67)
    		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
    	elseif (c <= 4.3e+108)
    		tmp = t_1;
    	else
    		tmp = Float64(fma(d, Float64(a / c), Float64(-b)) / Float64(-c));
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-a) * N[(d / t$95$0), $MachinePrecision] + N[(N[(c / t$95$0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -6.4e+105], N[(N[(N[(d / c), $MachinePrecision] * a + (-b)), $MachinePrecision] / (-c)), $MachinePrecision], If[LessEqual[c, -2.1e-53], t$95$1, If[LessEqual[c, 6.8e-67], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.3e+108], t$95$1, N[(N[(d * N[(a / c), $MachinePrecision] + (-b)), $MachinePrecision] / (-c)), $MachinePrecision]]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
    t_1 := \mathsf{fma}\left(-a, \frac{d}{t\_0}, \frac{c}{t\_0} \cdot b\right)\\
    \mathbf{if}\;c \leq -6.4 \cdot 10^{+105}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, a, -b\right)}{-c}\\
    
    \mathbf{elif}\;c \leq -2.1 \cdot 10^{-53}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;c \leq 6.8 \cdot 10^{-67}:\\
    \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\
    
    \mathbf{elif}\;c \leq 4.3 \cdot 10^{+108}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{a}{c}, -b\right)}{-c}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if c < -6.4e105

      1. Initial program 37.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. fp-cancel-sign-sub-invN/A

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

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

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

          \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
        6. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -6.4e105 < c < -2.09999999999999977e-53 or 6.8000000000000002e-67 < c < 4.29999999999999996e108

        1. Initial program 82.3%

          \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
        2. Add Preprocessing
        3. Applied rewrites88.1%

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

        if -2.09999999999999977e-53 < c < 6.8000000000000002e-67

        1. Initial program 63.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. fp-cancel-sign-sub-invN/A

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

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

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

            \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
          6. *-lft-identityN/A

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

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

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

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

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

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

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

        if 4.29999999999999996e108 < c

        1. Initial program 27.9%

          \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
        2. Add Preprocessing
        3. Applied rewrites29.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6.4 \cdot 10^{+105}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, a, -b\right)}{-c}\\ \mathbf{elif}\;c \leq -2.1 \cdot 10^{-53}:\\ \;\;\;\;\mathsf{fma}\left(-a, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot b\right)\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{+108}:\\ \;\;\;\;\mathsf{fma}\left(-a, \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(d, \frac{a}{c}, -b\right)}{-c}\\ \end{array} \]
      9. Add Preprocessing

      Alternative 3: 77.6% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(\frac{d}{c}, a, -b\right)}{-c}\\ \mathbf{if}\;c \leq -3.05 \cdot 10^{+77}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-67}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+26}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-a, d, 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 (/ (fma (/ d c) a (- b)) (- c))))
         (if (<= c -3.05e+77)
           t_0
           (if (<= c 3.4e-67)
             (/ (- (* c (/ b d)) a) d)
             (if (<= c 6e+26) (/ (fma (- a) d (* b c)) (fma d d (* c c))) t_0)))))
      double code(double a, double b, double c, double d) {
      	double t_0 = fma((d / c), a, -b) / -c;
      	double tmp;
      	if (c <= -3.05e+77) {
      		tmp = t_0;
      	} else if (c <= 3.4e-67) {
      		tmp = ((c * (b / d)) - a) / d;
      	} else if (c <= 6e+26) {
      		tmp = fma(-a, d, (b * c)) / fma(d, d, (c * c));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(a, b, c, d)
      	t_0 = Float64(fma(Float64(d / c), a, Float64(-b)) / Float64(-c))
      	tmp = 0.0
      	if (c <= -3.05e+77)
      		tmp = t_0;
      	elseif (c <= 3.4e-67)
      		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
      	elseif (c <= 6e+26)
      		tmp = Float64(fma(Float64(-a), d, 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[(N[(d / c), $MachinePrecision] * a + (-b)), $MachinePrecision] / (-c)), $MachinePrecision]}, If[LessEqual[c, -3.05e+77], t$95$0, If[LessEqual[c, 3.4e-67], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6e+26], N[(N[((-a) * d + 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{\mathsf{fma}\left(\frac{d}{c}, a, -b\right)}{-c}\\
      \mathbf{if}\;c \leq -3.05 \cdot 10^{+77}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;c \leq 3.4 \cdot 10^{-67}:\\
      \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
      
      \mathbf{elif}\;c \leq 6 \cdot 10^{+26}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(-a, d, 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 3 regimes
      2. if c < -3.05000000000000016e77 or 5.99999999999999994e26 < c

        1. Initial program 42.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. fp-cancel-sign-sub-invN/A

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

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

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

            \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
          6. *-lft-identityN/A

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

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

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

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

            \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
          11. lower-*.f6412.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -3.05000000000000016e77 < c < 3.4000000000000001e-67

          1. Initial program 65.4%

            \[\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. fp-cancel-sign-sub-invN/A

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

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

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

              \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
            6. *-lft-identityN/A

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

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

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

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

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

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

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

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

            if 3.4000000000000001e-67 < c < 5.99999999999999994e26

            1. Initial program 99.4%

              \[\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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.05 \cdot 10^{+77}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, a, -b\right)}{-c}\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-67}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+26}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-a, d, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{d}{c}, a, -b\right)}{-c}\\ \end{array} \]
          9. Add Preprocessing

          Alternative 4: 73.2% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -5.8 \cdot 10^{+152}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -5.1 \cdot 10^{-48}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{d \cdot d}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{+25}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (a b c d)
           :precision binary64
           (let* ((t_0 (/ (- a) d)))
             (if (<= d -5.8e+152)
               t_0
               (if (<= d -5.1e-48)
                 (/ (fma (- d) a (* b c)) (* d d))
                 (if (<= d 5.5e+25) (/ (- b (/ (* a d) c)) c) t_0)))))
          double code(double a, double b, double c, double d) {
          	double t_0 = -a / d;
          	double tmp;
          	if (d <= -5.8e+152) {
          		tmp = t_0;
          	} else if (d <= -5.1e-48) {
          		tmp = fma(-d, a, (b * c)) / (d * d);
          	} else if (d <= 5.5e+25) {
          		tmp = (b - ((a * d) / 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 <= -5.8e+152)
          		tmp = t_0;
          	elseif (d <= -5.1e-48)
          		tmp = Float64(fma(Float64(-d), a, Float64(b * c)) / Float64(d * d));
          	elseif (d <= 5.5e+25)
          		tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c);
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -5.8e+152], t$95$0, If[LessEqual[d, -5.1e-48], N[(N[((-d) * a + N[(b * c), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.5e+25], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{-a}{d}\\
          \mathbf{if}\;d \leq -5.8 \cdot 10^{+152}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;d \leq -5.1 \cdot 10^{-48}:\\
          \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{d \cdot d}\\
          
          \mathbf{elif}\;d \leq 5.5 \cdot 10^{+25}:\\
          \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if d < -5.7999999999999997e152 or 5.50000000000000018e25 < d

            1. Initial program 35.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. mul-1-negN/A

                \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{a}{d}\right)} \]
              2. distribute-neg-frac2N/A

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

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

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

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

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

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

            if -5.7999999999999997e152 < d < -5.10000000000000011e-48

            1. Initial program 86.4%

              \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
            2. Add Preprocessing
            3. Applied rewrites87.5%

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

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

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

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

                \[\leadsto \color{blue}{\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \cdot b + \left(-a\right) \cdot \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
              5. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
            6. Taylor expanded in c around 0

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

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

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

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

            if -5.10000000000000011e-48 < d < 5.50000000000000018e25

            1. Initial program 65.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. fp-cancel-sign-sub-invN/A

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

                \[\leadsto \frac{b - \color{blue}{1} \cdot \frac{a \cdot d}{c}}{c} \]
              4. *-lft-identityN/A

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.8 \cdot 10^{+152}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -5.1 \cdot 10^{-48}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{d \cdot d}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{+25}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 5: 64.2% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1.16 \cdot 10^{+48}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 8.5 \cdot 10^{-55}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+31}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
          (FPCore (a b c d)
           :precision binary64
           (if (<= c -1.16e+48)
             (/ b c)
             (if (<= c 8.5e-55)
               (/ (- a) d)
               (if (<= c 2.1e+31) (/ (- (* b c) (* a d)) (* c c)) (/ b c)))))
          double code(double a, double b, double c, double d) {
          	double tmp;
          	if (c <= -1.16e+48) {
          		tmp = b / c;
          	} else if (c <= 8.5e-55) {
          		tmp = -a / d;
          	} else if (c <= 2.1e+31) {
          		tmp = ((b * c) - (a * d)) / (c * c);
          	} 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 <= (-1.16d+48)) then
                  tmp = b / c
              else if (c <= 8.5d-55) then
                  tmp = -a / d
              else if (c <= 2.1d+31) then
                  tmp = ((b * c) - (a * d)) / (c * c)
              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 <= -1.16e+48) {
          		tmp = b / c;
          	} else if (c <= 8.5e-55) {
          		tmp = -a / d;
          	} else if (c <= 2.1e+31) {
          		tmp = ((b * c) - (a * d)) / (c * c);
          	} else {
          		tmp = b / c;
          	}
          	return tmp;
          }
          
          def code(a, b, c, d):
          	tmp = 0
          	if c <= -1.16e+48:
          		tmp = b / c
          	elif c <= 8.5e-55:
          		tmp = -a / d
          	elif c <= 2.1e+31:
          		tmp = ((b * c) - (a * d)) / (c * c)
          	else:
          		tmp = b / c
          	return tmp
          
          function code(a, b, c, d)
          	tmp = 0.0
          	if (c <= -1.16e+48)
          		tmp = Float64(b / c);
          	elseif (c <= 8.5e-55)
          		tmp = Float64(Float64(-a) / d);
          	elseif (c <= 2.1e+31)
          		tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(c * c));
          	else
          		tmp = Float64(b / c);
          	end
          	return tmp
          end
          
          function tmp_2 = code(a, b, c, d)
          	tmp = 0.0;
          	if (c <= -1.16e+48)
          		tmp = b / c;
          	elseif (c <= 8.5e-55)
          		tmp = -a / d;
          	elseif (c <= 2.1e+31)
          		tmp = ((b * c) - (a * d)) / (c * c);
          	else
          		tmp = b / c;
          	end
          	tmp_2 = tmp;
          end
          
          code[a_, b_, c_, d_] := If[LessEqual[c, -1.16e+48], N[(b / c), $MachinePrecision], If[LessEqual[c, 8.5e-55], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 2.1e+31], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;c \leq -1.16 \cdot 10^{+48}:\\
          \;\;\;\;\frac{b}{c}\\
          
          \mathbf{elif}\;c \leq 8.5 \cdot 10^{-55}:\\
          \;\;\;\;\frac{-a}{d}\\
          
          \mathbf{elif}\;c \leq 2.1 \cdot 10^{+31}:\\
          \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{b}{c}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if c < -1.15999999999999992e48 or 2.09999999999999979e31 < c

            1. Initial program 41.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-/.f6472.8

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

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

            if -1.15999999999999992e48 < c < 8.49999999999999968e-55

            1. Initial program 65.8%

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

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

                \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{a}{d}\right)} \]
              2. distribute-neg-frac2N/A

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

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

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

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

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

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

            if 8.49999999999999968e-55 < c < 2.09999999999999979e31

            1. Initial program 99.2%

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.16 \cdot 10^{+48}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 8.5 \cdot 10^{-55}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+31}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 6: 75.6% accurate, 0.8× speedup?

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

            1. Initial program 49.7%

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

              \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \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. fp-cancel-sign-sub-invN/A

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

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

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

                \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
              6. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if -3.05000000000000016e77 < c < 8.99999999999999941e-55

              1. Initial program 65.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} + \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. fp-cancel-sign-sub-invN/A

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

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

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

                  \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
                6. *-lft-identityN/A

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

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

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

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

                  \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
                11. lower-*.f6483.2

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

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

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

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

              Alternative 7: 75.8% accurate, 0.8× speedup?

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

                1. Initial program 49.7%

                  \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                2. Add Preprocessing
                3. Applied rewrites55.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if -3.05000000000000016e77 < c < 8.99999999999999941e-55

                1. Initial program 65.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} + \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. fp-cancel-sign-sub-invN/A

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

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

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

                    \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
                  6. *-lft-identityN/A

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

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

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

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

                    \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
                  11. lower-*.f6483.2

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

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

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

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

                Alternative 8: 73.7% accurate, 0.9× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -3.05 \cdot 10^{+77} \lor \neg \left(c \leq 9 \cdot 10^{-55}\right):\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \end{array} \]
                (FPCore (a b c d)
                 :precision binary64
                 (if (or (<= c -3.05e+77) (not (<= c 9e-55)))
                   (/ (- b (/ (* a d) c)) c)
                   (/ (- (* c (/ b d)) a) d)))
                double code(double a, double b, double c, double d) {
                	double tmp;
                	if ((c <= -3.05e+77) || !(c <= 9e-55)) {
                		tmp = (b - ((a * d) / c)) / c;
                	} else {
                		tmp = ((c * (b / d)) - a) / 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 ((c <= (-3.05d+77)) .or. (.not. (c <= 9d-55))) then
                        tmp = (b - ((a * d) / c)) / c
                    else
                        tmp = ((c * (b / d)) - a) / d
                    end if
                    code = tmp
                end function
                
                public static double code(double a, double b, double c, double d) {
                	double tmp;
                	if ((c <= -3.05e+77) || !(c <= 9e-55)) {
                		tmp = (b - ((a * d) / c)) / c;
                	} else {
                		tmp = ((c * (b / d)) - a) / d;
                	}
                	return tmp;
                }
                
                def code(a, b, c, d):
                	tmp = 0
                	if (c <= -3.05e+77) or not (c <= 9e-55):
                		tmp = (b - ((a * d) / c)) / c
                	else:
                		tmp = ((c * (b / d)) - a) / d
                	return tmp
                
                function code(a, b, c, d)
                	tmp = 0.0
                	if ((c <= -3.05e+77) || !(c <= 9e-55))
                		tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c);
                	else
                		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
                	end
                	return tmp
                end
                
                function tmp_2 = code(a, b, c, d)
                	tmp = 0.0;
                	if ((c <= -3.05e+77) || ~((c <= 9e-55)))
                		tmp = (b - ((a * d) / c)) / c;
                	else
                		tmp = ((c * (b / d)) - a) / d;
                	end
                	tmp_2 = tmp;
                end
                
                code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3.05e+77], N[Not[LessEqual[c, 9e-55]], $MachinePrecision]], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;c \leq -3.05 \cdot 10^{+77} \lor \neg \left(c \leq 9 \cdot 10^{-55}\right):\\
                \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if c < -3.05000000000000016e77 or 8.99999999999999941e-55 < c

                  1. Initial program 49.7%

                    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
                  2. Add Preprocessing
                  3. Taylor expanded in c around 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. fp-cancel-sign-sub-invN/A

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

                      \[\leadsto \frac{b - \color{blue}{1} \cdot \frac{a \cdot d}{c}}{c} \]
                    4. *-lft-identityN/A

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

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

                      \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
                    7. 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}} \]

                  if -3.05000000000000016e77 < c < 8.99999999999999941e-55

                  1. Initial program 65.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} + \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. fp-cancel-sign-sub-invN/A

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

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

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

                      \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \color{blue}{1} \cdot \frac{a}{d} \]
                    6. *-lft-identityN/A

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

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

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

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

                      \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
                    11. lower-*.f6483.2

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

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

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.05 \cdot 10^{+77} \lor \neg \left(c \leq 9 \cdot 10^{-55}\right):\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
                  9. Add Preprocessing

                  Alternative 9: 63.3% accurate, 1.5× speedup?

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

                    1. Initial program 49.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-/.f6468.0

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

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

                    if -1.15999999999999992e48 < c < 2.09999999999999995e-45

                    1. Initial program 66.3%

                      \[\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. mul-1-negN/A

                        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{a}{d}\right)} \]
                      2. distribute-neg-frac2N/A

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

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

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

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

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

                      \[\leadsto \color{blue}{\frac{a}{-d}} \]
                  3. Recombined 2 regimes into one program.
                  4. Final simplification67.7%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.16 \cdot 10^{+48} \lor \neg \left(c \leq 2.1 \cdot 10^{-45}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
                  5. Add Preprocessing

                  Alternative 10: 42.1% 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 58.2%

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

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

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

                    \[\leadsto \color{blue}{\frac{b}{c}} \]
                  6. Final simplification40.5%

                    \[\leadsto \frac{b}{c} \]
                  7. Add Preprocessing

                  Developer Target 1: 99.4% 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 2024326 
                  (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))))