Complex division, imag part

Percentage Accurate: 61.4% → 80.9%
Time: 7.4s
Alternatives: 12
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 12 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.4% accurate, 1.0× speedup?

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

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

Alternative 1: 80.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\ t_1 := \mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\ \mathbf{if}\;c \leq -1.15 \cdot 10^{+138}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -2.5 \cdot 10^{-148}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{b}{t\_0}}{a}, c, \frac{-d}{t\_0}\right) \cdot a\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-146}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{+114}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-b, c, d \cdot a\right)}{-\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma c c (* d d)))
        (t_1
         (fma
          (fma
           (- (* (/ a (pow c 4.0)) d) (/ b (pow c 3.0)))
           d
           (/ (/ (- a) c) c))
          d
          (/ b c))))
   (if (<= c -1.15e+138)
     t_1
     (if (<= c -2.5e-148)
       (* (fma (/ (/ b t_0) a) c (/ (- d) t_0)) a)
       (if (<= c 9e-146)
         (/ (- (/ (* b c) d) a) d)
         (if (<= c 1.05e+114)
           (/ (fma (- b) c (* d a)) (- (fma d d (* c c))))
           t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(c, c, (d * d));
	double t_1 = fma(fma((((a / pow(c, 4.0)) * d) - (b / pow(c, 3.0))), d, ((-a / c) / c)), d, (b / c));
	double tmp;
	if (c <= -1.15e+138) {
		tmp = t_1;
	} else if (c <= -2.5e-148) {
		tmp = fma(((b / t_0) / a), c, (-d / t_0)) * a;
	} else if (c <= 9e-146) {
		tmp = (((b * c) / d) - a) / d;
	} else if (c <= 1.05e+114) {
		tmp = fma(-b, c, (d * a)) / -fma(d, d, (c * c));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(c, c, Float64(d * d))
	t_1 = fma(fma(Float64(Float64(Float64(a / (c ^ 4.0)) * d) - Float64(b / (c ^ 3.0))), d, Float64(Float64(Float64(-a) / c) / c)), d, Float64(b / c))
	tmp = 0.0
	if (c <= -1.15e+138)
		tmp = t_1;
	elseif (c <= -2.5e-148)
		tmp = Float64(fma(Float64(Float64(b / t_0) / a), c, Float64(Float64(-d) / t_0)) * a);
	elseif (c <= 9e-146)
		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
	elseif (c <= 1.05e+114)
		tmp = Float64(fma(Float64(-b), c, Float64(d * a)) / Float64(-fma(d, d, Float64(c * c))));
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(a / N[Power[c, 4.0], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision] - N[(b / N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d + N[(N[((-a) / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] * d + N[(b / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.15e+138], t$95$1, If[LessEqual[c, -2.5e-148], N[(N[(N[(N[(b / t$95$0), $MachinePrecision] / a), $MachinePrecision] * c + N[((-d) / t$95$0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[c, 9e-146], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.05e+114], N[(N[((-b) * c + N[(d * a), $MachinePrecision]), $MachinePrecision] / (-N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.15000000000000004e138 or 1.05e114 < c

    1. Initial program 32.9%

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

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

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

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

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

    if -1.15000000000000004e138 < c < -2.4999999999999999e-148

    1. Initial program 70.8%

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

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

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

        \[\leadsto a \cdot \left(\color{blue}{\left(0 - \frac{d}{{c}^{2} + {d}^{2}}\right)} + \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right) \]
      3. associate-+l-N/A

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

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

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

        \[\leadsto a \cdot \left(0 - \color{blue}{\left(-1 \cdot \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)} + \frac{d}{{c}^{2} + {d}^{2}}\right)}\right) \]
      7. neg-sub0N/A

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

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

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

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

    if -2.4999999999999999e-148 < c < 9.0000000000000001e-146

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

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

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

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

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

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

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

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

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

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

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

    if 9.0000000000000001e-146 < c < 1.05e114

    1. Initial program 79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.15 \cdot 10^{+138}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\ \mathbf{elif}\;c \leq -2.5 \cdot 10^{-148}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{b}{\mathsf{fma}\left(c, c, d \cdot d\right)}}{a}, c, \frac{-d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right) \cdot a\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-146}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{+114}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-b, c, d \cdot a\right)}{-\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{a}{{c}^{4}} \cdot d - \frac{b}{{c}^{3}}, d, \frac{\frac{-a}{c}}{c}\right), d, \frac{b}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 82.7% accurate, 0.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.8e53 or 3.25000000000000004e124 < d

    1. Initial program 40.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.8e53 < d < -1.3e-144

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.3e-144 < d < 2.9999999999999999e-30

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

    if 2.9999999999999999e-30 < d < 3.25000000000000004e124

    1. Initial program 59.6%

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

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

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

        \[\leadsto a \cdot \left(\color{blue}{\left(0 - \frac{d}{{c}^{2} + {d}^{2}}\right)} + \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right) \]
      3. associate-+l-N/A

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

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

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

        \[\leadsto a \cdot \left(0 - \color{blue}{\left(-1 \cdot \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)} + \frac{d}{{c}^{2} + {d}^{2}}\right)}\right) \]
      7. neg-sub0N/A

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

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(-1 \cdot \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)} + \frac{d}{{c}^{2} + {d}^{2}}\right)\right)\right) \cdot a} \]
    5. Applied rewrites75.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.8 \cdot 10^{+53}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{d}, \frac{b}{d}, \frac{-a}{d}\right)\\ \mathbf{elif}\;d \leq -1.3 \cdot 10^{-144}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-b, c, d \cdot a\right)}{-\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-30}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 3.25 \cdot 10^{+124}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{b}{\mathsf{fma}\left(c, c, d \cdot d\right)}}{a}, c, \frac{-d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{d}, \frac{b}{d}, \frac{-a}{d}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 66.4% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq -2.8 \cdot 10^{-60}:\\
\;\;\;\;\frac{t\_1}{d \cdot d}\\

\mathbf{elif}\;d \leq -1.45 \cdot 10^{-149}:\\
\;\;\;\;\frac{t\_1}{c \cdot c}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -6.79999999999999995e53 or 2.69999999999999978e124 < d

    1. Initial program 40.9%

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

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

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

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

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

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

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

    if -6.79999999999999995e53 < d < -2.8000000000000002e-60

    1. Initial program 78.0%

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

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

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

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

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

    if -2.8000000000000002e-60 < d < -1.45e-149

    1. Initial program 91.1%

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

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

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

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

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

    if -1.45e-149 < d < 1.8999999999999999e-114

    1. Initial program 74.0%

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

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

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

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

    if 1.8999999999999999e-114 < d < 2.69999999999999978e124

    1. Initial program 62.5%

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

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

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

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

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

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

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

        \[\leadsto \left(-a\right) \cdot \color{blue}{\frac{d}{{c}^{2} + {d}^{2}}} \]
      7. unpow2N/A

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

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

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

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

      \[\leadsto \color{blue}{\left(-a\right) \cdot \frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification70.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.8 \cdot 10^{+53}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -2.8 \cdot 10^{-60}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq -1.45 \cdot 10^{-149}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c}\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-114}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+124}:\\ \;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 78.5% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;c \leq 6.7 \cdot 10^{+137}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-b, c, d \cdot a\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.10000000000000012e-35 or 6.6999999999999999e137 < c

    1. Initial program 45.4%

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

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

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

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

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

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

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

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

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

    if -3.10000000000000012e-35 < c < 9.0000000000000001e-146

    1. Initial program 70.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.0000000000000001e-146 < c < 6.6999999999999999e137

    1. Initial program 78.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.1 \cdot 10^{-35}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-146}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 6.7 \cdot 10^{+137}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-b, c, d \cdot a\right)}{-\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 78.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{if}\;c \leq -3.1 \cdot 10^{-35}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-146}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 6.7 \cdot 10^{+137}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- b (/ (* d a) c)) c)))
   (if (<= c -3.1e-35)
     t_0
     (if (<= c 9e-146)
       (/ (- (/ (* b c) d) a) d)
       (if (<= c 6.7e+137) (/ (- (* b c) (* d a)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = (b - ((d * a) / c)) / c;
	double tmp;
	if (c <= -3.1e-35) {
		tmp = t_0;
	} else if (c <= 9e-146) {
		tmp = (((b * c) / d) - a) / d;
	} else if (c <= 6.7e+137) {
		tmp = ((b * c) - (d * a)) / ((c * c) + (d * d));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (b - ((d * a) / c)) / c
    if (c <= (-3.1d-35)) then
        tmp = t_0
    else if (c <= 9d-146) then
        tmp = (((b * c) / d) - a) / d
    else if (c <= 6.7d+137) then
        tmp = ((b * c) - (d * a)) / ((c * c) + (d * d))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (b - ((d * a) / c)) / c;
	double tmp;
	if (c <= -3.1e-35) {
		tmp = t_0;
	} else if (c <= 9e-146) {
		tmp = (((b * c) / d) - a) / d;
	} else if (c <= 6.7e+137) {
		tmp = ((b * c) - (d * a)) / ((c * c) + (d * d));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b - ((d * a) / c)) / c
	tmp = 0
	if c <= -3.1e-35:
		tmp = t_0
	elif c <= 9e-146:
		tmp = (((b * c) / d) - a) / d
	elif c <= 6.7e+137:
		tmp = ((b * c) - (d * a)) / ((c * c) + (d * d))
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c)
	tmp = 0.0
	if (c <= -3.1e-35)
		tmp = t_0;
	elseif (c <= 9e-146)
		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
	elseif (c <= 6.7e+137)
		tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b - ((d * a) / c)) / c;
	tmp = 0.0;
	if (c <= -3.1e-35)
		tmp = t_0;
	elseif (c <= 9e-146)
		tmp = (((b * c) / d) - a) / d;
	elseif (c <= 6.7e+137)
		tmp = ((b * c) - (d * a)) / ((c * c) + (d * d));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.1e-35], t$95$0, If[LessEqual[c, 9e-146], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6.7e+137], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.10000000000000012e-35 or 6.6999999999999999e137 < c

    1. Initial program 45.4%

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

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

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

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

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

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

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

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

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

    if -3.10000000000000012e-35 < c < 9.0000000000000001e-146

    1. Initial program 70.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.0000000000000001e-146 < c < 6.6999999999999999e137

    1. Initial program 78.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.1 \cdot 10^{-35}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-146}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 6.7 \cdot 10^{+137}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 65.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -4 \cdot 10^{-54}:\\
\;\;\;\;t\_0\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -4.0000000000000001e-54 or 2.69999999999999978e124 < d

    1. Initial program 48.7%

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

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

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

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

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

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

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

    if -4.0000000000000001e-54 < d < -1.45e-149

    1. Initial program 91.9%

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

      \[\leadsto \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-*.f6477.1

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

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

    if -1.45e-149 < d < 1.8999999999999999e-114

    1. Initial program 74.0%

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

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

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

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

    if 1.8999999999999999e-114 < d < 2.69999999999999978e124

    1. Initial program 62.5%

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

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

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

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

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

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

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

        \[\leadsto \left(-a\right) \cdot \color{blue}{\frac{d}{{c}^{2} + {d}^{2}}} \]
      7. unpow2N/A

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4 \cdot 10^{-54}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -1.45 \cdot 10^{-149}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c}\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-114}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+124}:\\ \;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 67.1% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;d \leq -8.6 \cdot 10^{-98}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 2.7 \cdot 10^{+124}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.2999999999999999e147 or 2.69999999999999978e124 < d

    1. Initial program 37.0%

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

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

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

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

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

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

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

    if -1.2999999999999999e147 < d < -8.59999999999999977e-98 or 1.8999999999999999e-114 < d < 2.69999999999999978e124

    1. Initial program 66.5%

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

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

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

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

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

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

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

        \[\leadsto \left(-a\right) \cdot \color{blue}{\frac{d}{{c}^{2} + {d}^{2}}} \]
      7. unpow2N/A

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

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

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

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

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

    if -8.59999999999999977e-98 < d < 1.8999999999999999e-114

    1. Initial program 77.3%

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

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

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

      \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification68.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.3 \cdot 10^{+147}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -8.6 \cdot 10^{-98}:\\ \;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-114}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+124}:\\ \;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 66.8% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;c \leq -2.7 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 1.02 \cdot 10^{+114}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.00000000000000002e141 or 1.01999999999999999e114 < c

    1. Initial program 33.9%

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

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

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

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

    if -1.00000000000000002e141 < c < -2.6999999999999997e-35 or 1.30000000000000007e-114 < c < 1.01999999999999999e114

    1. Initial program 73.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-/.f6436.1

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

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

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

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

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

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

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

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

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

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

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

    if -2.6999999999999997e-35 < c < 1.30000000000000007e-114

    1. Initial program 71.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1 \cdot 10^{+141}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -2.7 \cdot 10^{-35}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-114}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 1.02 \cdot 10^{+114}:\\ \;\;\;\;\frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot b\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 72.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -6.8 \cdot 10^{+53}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -3.1 \cdot 10^{-60}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq 2.1 \cdot 10^{+122}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- a) d)))
   (if (<= d -6.8e+53)
     t_0
     (if (<= d -3.1e-60)
       (/ (- (* b c) (* d a)) (* d d))
       (if (<= d 2.1e+122) (/ (- b (/ (* d a) c)) c) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = -a / d;
	double tmp;
	if (d <= -6.8e+53) {
		tmp = t_0;
	} else if (d <= -3.1e-60) {
		tmp = ((b * c) - (d * a)) / (d * d);
	} else if (d <= 2.1e+122) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -a / d
    if (d <= (-6.8d+53)) then
        tmp = t_0
    else if (d <= (-3.1d-60)) then
        tmp = ((b * c) - (d * a)) / (d * d)
    else if (d <= 2.1d+122) then
        tmp = (b - ((d * a) / c)) / c
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = -a / d;
	double tmp;
	if (d <= -6.8e+53) {
		tmp = t_0;
	} else if (d <= -3.1e-60) {
		tmp = ((b * c) - (d * a)) / (d * d);
	} else if (d <= 2.1e+122) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = -a / d
	tmp = 0
	if d <= -6.8e+53:
		tmp = t_0
	elif d <= -3.1e-60:
		tmp = ((b * c) - (d * a)) / (d * d)
	elif d <= 2.1e+122:
		tmp = (b - ((d * a) / c)) / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(-a) / d)
	tmp = 0.0
	if (d <= -6.8e+53)
		tmp = t_0;
	elseif (d <= -3.1e-60)
		tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(d * d));
	elseif (d <= 2.1e+122)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = -a / d;
	tmp = 0.0;
	if (d <= -6.8e+53)
		tmp = t_0;
	elseif (d <= -3.1e-60)
		tmp = ((b * c) - (d * a)) / (d * d);
	elseif (d <= 2.1e+122)
		tmp = (b - ((d * a) / c)) / c;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -6.8e+53], t$95$0, If[LessEqual[d, -3.1e-60], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.1e+122], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -6.8 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.79999999999999995e53 or 2.10000000000000016e122 < d

    1. Initial program 40.5%

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

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

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

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

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

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

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

    if -6.79999999999999995e53 < d < -3.09999999999999988e-60

    1. Initial program 78.0%

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

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

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

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

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

    if -3.09999999999999988e-60 < d < 2.10000000000000016e122

    1. Initial program 72.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.8 \cdot 10^{+53}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -3.1 \cdot 10^{-60}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq 2.1 \cdot 10^{+122}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 75.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{if}\;c \leq -3.1 \cdot 10^{-35}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 5 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- b (/ (* d a) c)) c)))
   (if (<= c -3.1e-35) t_0 (if (<= c 5e-52) (/ (- (/ (* b c) d) a) d) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = (b - ((d * a) / c)) / c;
	double tmp;
	if (c <= -3.1e-35) {
		tmp = t_0;
	} else if (c <= 5e-52) {
		tmp = (((b * c) / d) - a) / d;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (b - ((d * a) / c)) / c
    if (c <= (-3.1d-35)) then
        tmp = t_0
    else if (c <= 5d-52) then
        tmp = (((b * c) / d) - a) / d
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (b - ((d * a) / c)) / c;
	double tmp;
	if (c <= -3.1e-35) {
		tmp = t_0;
	} else if (c <= 5e-52) {
		tmp = (((b * c) / d) - a) / d;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b - ((d * a) / c)) / c
	tmp = 0
	if c <= -3.1e-35:
		tmp = t_0
	elif c <= 5e-52:
		tmp = (((b * c) / d) - a) / d
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b - Float64(Float64(d * a) / c)) / c)
	tmp = 0.0
	if (c <= -3.1e-35)
		tmp = t_0;
	elseif (c <= 5e-52)
		tmp = Float64(Float64(Float64(Float64(b * c) / d) - a) / d);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b - ((d * a) / c)) / c;
	tmp = 0.0;
	if (c <= -3.1e-35)
		tmp = t_0;
	elseif (c <= 5e-52)
		tmp = (((b * c) / d) - a) / d;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.1e-35], t$95$0, If[LessEqual[c, 5e-52], N[(N[(N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -3.10000000000000012e-35 or 5e-52 < c

    1. Initial program 52.5%

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

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

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

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

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

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

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

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

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

    if -3.10000000000000012e-35 < c < 5e-52

    1. Initial program 73.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.1 \cdot 10^{-35}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;c \leq 5 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 63.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -1.8 \cdot 10^{-39}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{-30}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- a) d)))
   (if (<= d -1.8e-39) t_0 (if (<= d 3.1e-30) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = -a / d;
	double tmp;
	if (d <= -1.8e-39) {
		tmp = t_0;
	} else if (d <= 3.1e-30) {
		tmp = b / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -a / d
    if (d <= (-1.8d-39)) then
        tmp = t_0
    else if (d <= 3.1d-30) then
        tmp = b / c
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = -a / d;
	double tmp;
	if (d <= -1.8e-39) {
		tmp = t_0;
	} else if (d <= 3.1e-30) {
		tmp = b / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = -a / d
	tmp = 0
	if d <= -1.8e-39:
		tmp = t_0
	elif d <= 3.1e-30:
		tmp = b / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(-a) / d)
	tmp = 0.0
	if (d <= -1.8e-39)
		tmp = t_0;
	elseif (d <= 3.1e-30)
		tmp = Float64(b / c);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = -a / d;
	tmp = 0.0;
	if (d <= -1.8e-39)
		tmp = t_0;
	elseif (d <= 3.1e-30)
		tmp = b / c;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -1.8e-39], t$95$0, If[LessEqual[d, 3.1e-30], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -1.8 \cdot 10^{-39}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 3.1 \cdot 10^{-30}:\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.8e-39 or 3.09999999999999991e-30 < d

    1. Initial program 51.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}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

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

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

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

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

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

    if -1.8e-39 < d < 3.09999999999999991e-30

    1. Initial program 75.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}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f6463.9

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

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

Alternative 12: 42.9% accurate, 3.2× speedup?

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

\\
\frac{b}{c}
\end{array}
Derivation
  1. Initial program 62.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-/.f6442.4

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

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

Developer Target 1: 99.3% 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 2024249 
(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))))