Complex division, imag part

Percentage Accurate: 61.5% → 83.2%
Time: 11.0s
Alternatives: 14
Speedup: 1.4×

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 14 alternatives:

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

Initial Program: 61.5% 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.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\ t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \mathbf{if}\;d \leq -6.5 \cdot 10^{+136}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-68}:\\ \;\;\;\;\mathsf{fma}\left(d, \frac{0 - a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{-165}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\ \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 (/ b d) (- 0.0 a)) d)))
   (if (<= d -6.5e+136)
     t_1
     (if (<= d -7.5e-68)
       (fma d (/ (- 0.0 a) t_0) (/ (* c b) t_0))
       (if (<= d 3.4e-165)
         (/ (- b (* a (/ d c))) c)
         (if (<= d 7e+79) (/ (- (* c b) (* d a)) (+ (* 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(c, (b / d), (0.0 - a)) / d;
	double tmp;
	if (d <= -6.5e+136) {
		tmp = t_1;
	} else if (d <= -7.5e-68) {
		tmp = fma(d, ((0.0 - a) / t_0), ((c * b) / t_0));
	} else if (d <= 3.4e-165) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= 7e+79) {
		tmp = ((c * b) - (d * a)) / ((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 = Float64(fma(c, Float64(b / d), Float64(0.0 - a)) / d)
	tmp = 0.0
	if (d <= -6.5e+136)
		tmp = t_1;
	elseif (d <= -7.5e-68)
		tmp = fma(d, Float64(Float64(0.0 - a) / t_0), Float64(Float64(c * b) / t_0));
	elseif (d <= 3.4e-165)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (d <= 7e+79)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(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[(c * N[(b / d), $MachinePrecision] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6.5e+136], t$95$1, If[LessEqual[d, -7.5e-68], N[(d * N[(N[(0.0 - a), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.4e-165], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7e+79], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + 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 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{+136}:\\
\;\;\;\;t\_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -6.4999999999999998e136 or 6.99999999999999961e79 < d

    1. Initial program 39.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{0 - a}\right)}{d} \]
      16. --lowering--.f6489.9

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

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

    if -6.4999999999999998e136 < d < -7.50000000000000081e-68

    1. Initial program 82.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(d, \mathsf{neg}\left(\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right), \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      16. *-lowering-*.f6493.0

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

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

    if -7.50000000000000081e-68 < d < 3.4e-165

    1. Initial program 69.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. /-lowering-/.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. --lowering--.f64N/A

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

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

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. *-lowering-*.f6494.1

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

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

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

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

        \[\leadsto \frac{b - \color{blue}{a \cdot \frac{d}{c}}}{c} \]
      4. /-lowering-/.f6494.2

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{d}{c}}}{c} \]
    7. Applied egg-rr94.2%

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

    if 3.4e-165 < d < 6.99999999999999961e79

    1. Initial program 81.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.5 \cdot 10^{+136}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-68}:\\ \;\;\;\;\mathsf{fma}\left(d, \frac{0 - a}{\mathsf{fma}\left(c, c, d \cdot d\right)}, \frac{c \cdot b}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right)\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{-165}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 82.9% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq -7 \cdot 10^{-84}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 1.5 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -9.3000000000000005e42 or 1.49999999999999999e81 < d

    1. Initial program 45.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. 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. /-lowering-/.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{0 - a}\right)}{d} \]
      16. --lowering--.f6487.4

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

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

    if -9.3000000000000005e42 < d < -7.0000000000000002e-84 or 3.4e-165 < d < 1.49999999999999999e81

    1. Initial program 85.6%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing

    if -7.0000000000000002e-84 < d < 3.4e-165

    1. Initial program 69.1%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

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

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

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. *-lowering-*.f6494.9

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

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

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

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

        \[\leadsto \frac{b - \color{blue}{a \cdot \frac{d}{c}}}{c} \]
      4. /-lowering-/.f6494.9

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{d}{c}}}{c} \]
    7. Applied egg-rr94.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.3 \cdot 10^{+42}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \mathbf{elif}\;d \leq -7 \cdot 10^{-84}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{-165}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{+81}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 63.1% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c}\\
\mathbf{if}\;c \leq -1.15 \cdot 10^{+86}:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{elif}\;c \leq -8.2 \cdot 10^{-69}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;c \leq 3.3 \cdot 10^{-158}:\\
\;\;\;\;\frac{a}{0 - d}\\

\mathbf{elif}\;c \leq 38000000:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.14999999999999995e86 or 2.39999999999999989e45 < c

    1. Initial program 49.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. /-lowering-/.f6477.4

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

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

    if -1.14999999999999995e86 < c < -8.1999999999999998e-69 or 3.3000000000000002e-158 < c < 3.8e7

    1. Initial program 79.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 \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. *-lowering-*.f6456.5

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

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

    if -8.1999999999999998e-69 < c < 3.3000000000000002e-158

    1. Initial program 68.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. 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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6476.2

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

      \[\leadsto \color{blue}{\frac{a}{0 - d}} \]
    6. Step-by-step derivation
      1. neg-sub0N/A

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

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr76.2%

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

    if 3.8e7 < c < 2.39999999999999989e45

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1}{\frac{\left(b \cdot c\right) \cdot \left(b \cdot c\right) + \left(\left(a \cdot d\right) \cdot \left(a \cdot d\right) + \left(b \cdot c\right) \cdot \left(a \cdot d\right)\right)}{{\left(b \cdot c\right)}^{3} - {\left(a \cdot d\right)}^{3}} \cdot \left(\mathsf{neg}\left(\left(c \cdot c + d \cdot d\right)\right)\right)}} \]
    4. Applied egg-rr99.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a \cdot d}{\mathsf{neg}\left(\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)\right)} \]
      12. *-lowering-*.f6484.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.15 \cdot 10^{+86}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -8.2 \cdot 10^{-69}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c}\\ \mathbf{elif}\;c \leq 3.3 \cdot 10^{-158}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{elif}\;c \leq 38000000:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c}\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{+45}:\\ \;\;\;\;\frac{d \cdot a}{0 - \mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 66.2% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq -5.3 \cdot 10^{-28}:\\
\;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

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

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

\mathbf{elif}\;d \leq 5.1 \cdot 10^{+98}:\\
\;\;\;\;\frac{t\_1}{d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -1.29999999999999994e154 or 5.09999999999999988e98 < d

    1. Initial program 38.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in 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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6477.0

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

      \[\leadsto \color{blue}{\frac{a}{0 - d}} \]
    6. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      2. neg-lowering-neg.f6477.0

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr77.0%

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

    if -1.29999999999999994e154 < d < -5.29999999999999988e-28

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(d, \mathsf{neg}\left(\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right), \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      16. *-lowering-*.f6488.7

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{a \cdot \frac{d}{{c}^{2} + {d}^{2}}} \]
      5. *-lowering-*.f64N/A

        \[\leadsto 0 - \color{blue}{a \cdot \frac{d}{{c}^{2} + {d}^{2}}} \]
      6. /-lowering-/.f64N/A

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

        \[\leadsto 0 - a \cdot \frac{d}{\color{blue}{c \cdot c} + {d}^{2}} \]
      8. accelerator-lowering-fma.f64N/A

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

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

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

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

    if -5.29999999999999988e-28 < d < 7.5000000000000004e-222

    1. Initial program 72.1%

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

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

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

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

    if 7.5000000000000004e-222 < d < 1.25e-70

    1. Initial program 82.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. *-lowering-*.f6467.9

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

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

    if 1.25e-70 < d < 5.09999999999999988e98

    1. Initial program 77.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 \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. *-lowering-*.f6457.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.3 \cdot 10^{+154}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{elif}\;d \leq -5.3 \cdot 10^{-28}:\\ \;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{-222}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-70}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c}\\ \mathbf{elif}\;d \leq 5.1 \cdot 10^{+98}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{0 - d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 62.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ t_1 := \frac{t\_0}{c \cdot c}\\ \mathbf{if}\;c \leq -5.4 \cdot 10^{+79}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -5.2 \cdot 10^{-68}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq 3.3 \cdot 10^{-158}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{elif}\;c \leq 1.18 \cdot 10^{-73}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{+45}:\\ \;\;\;\;\frac{t\_0}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (* c c))))
   (if (<= c -5.4e+79)
     (/ b c)
     (if (<= c -5.2e-68)
       t_1
       (if (<= c 3.3e-158)
         (/ a (- 0.0 d))
         (if (<= c 1.18e-73)
           t_1
           (if (<= c 4.8e+45) (/ t_0 (* d d)) (/ b c))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = t_0 / (c * c);
	double tmp;
	if (c <= -5.4e+79) {
		tmp = b / c;
	} else if (c <= -5.2e-68) {
		tmp = t_1;
	} else if (c <= 3.3e-158) {
		tmp = a / (0.0 - d);
	} else if (c <= 1.18e-73) {
		tmp = t_1;
	} else if (c <= 4.8e+45) {
		tmp = t_0 / (d * d);
	} else {
		tmp = b / c;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (c * b) - (d * a)
    t_1 = t_0 / (c * c)
    if (c <= (-5.4d+79)) then
        tmp = b / c
    else if (c <= (-5.2d-68)) then
        tmp = t_1
    else if (c <= 3.3d-158) then
        tmp = a / (0.0d0 - d)
    else if (c <= 1.18d-73) then
        tmp = t_1
    else if (c <= 4.8d+45) then
        tmp = t_0 / (d * d)
    else
        tmp = b / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = t_0 / (c * c);
	double tmp;
	if (c <= -5.4e+79) {
		tmp = b / c;
	} else if (c <= -5.2e-68) {
		tmp = t_1;
	} else if (c <= 3.3e-158) {
		tmp = a / (0.0 - d);
	} else if (c <= 1.18e-73) {
		tmp = t_1;
	} else if (c <= 4.8e+45) {
		tmp = t_0 / (d * d);
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	t_1 = t_0 / (c * c)
	tmp = 0
	if c <= -5.4e+79:
		tmp = b / c
	elif c <= -5.2e-68:
		tmp = t_1
	elif c <= 3.3e-158:
		tmp = a / (0.0 - d)
	elif c <= 1.18e-73:
		tmp = t_1
	elif c <= 4.8e+45:
		tmp = t_0 / (d * d)
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	t_1 = Float64(t_0 / Float64(c * c))
	tmp = 0.0
	if (c <= -5.4e+79)
		tmp = Float64(b / c);
	elseif (c <= -5.2e-68)
		tmp = t_1;
	elseif (c <= 3.3e-158)
		tmp = Float64(a / Float64(0.0 - d));
	elseif (c <= 1.18e-73)
		tmp = t_1;
	elseif (c <= 4.8e+45)
		tmp = Float64(t_0 / Float64(d * d));
	else
		tmp = Float64(b / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	t_1 = t_0 / (c * c);
	tmp = 0.0;
	if (c <= -5.4e+79)
		tmp = b / c;
	elseif (c <= -5.2e-68)
		tmp = t_1;
	elseif (c <= 3.3e-158)
		tmp = a / (0.0 - d);
	elseif (c <= 1.18e-73)
		tmp = t_1;
	elseif (c <= 4.8e+45)
		tmp = t_0 / (d * d);
	else
		tmp = b / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.4e+79], N[(b / c), $MachinePrecision], If[LessEqual[c, -5.2e-68], t$95$1, If[LessEqual[c, 3.3e-158], N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.18e-73], t$95$1, If[LessEqual[c, 4.8e+45], N[(t$95$0 / N[(d * d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -5.2 \cdot 10^{-68}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;c \leq 3.3 \cdot 10^{-158}:\\
\;\;\;\;\frac{a}{0 - d}\\

\mathbf{elif}\;c \leq 1.18 \cdot 10^{-73}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;c \leq 4.8 \cdot 10^{+45}:\\
\;\;\;\;\frac{t\_0}{d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -5.3999999999999999e79 or 4.79999999999999979e45 < c

    1. Initial program 49.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. /-lowering-/.f6477.4

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

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

    if -5.3999999999999999e79 < c < -5.1999999999999996e-68 or 3.3000000000000002e-158 < c < 1.17999999999999993e-73

    1. Initial program 75.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 \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. *-lowering-*.f6460.3

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

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

    if -5.1999999999999996e-68 < c < 3.3000000000000002e-158

    1. Initial program 68.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. 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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6476.2

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

      \[\leadsto \color{blue}{\frac{a}{0 - d}} \]
    6. Step-by-step derivation
      1. neg-sub0N/A

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

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr76.2%

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

    if 1.17999999999999993e-73 < c < 4.79999999999999979e45

    1. Initial program 96.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. *-lowering-*.f6467.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.4 \cdot 10^{+79}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -5.2 \cdot 10^{-68}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c}\\ \mathbf{elif}\;c \leq 3.3 \cdot 10^{-158}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{elif}\;c \leq 1.18 \cdot 10^{-73}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c}\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{+45}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 64.1% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;d \leq -1.6 \cdot 10^{-27}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 260000000000:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.7999999999999998e42 or 2.6e11 < d

    1. Initial program 49.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. 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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6470.2

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

      \[\leadsto \color{blue}{\frac{a}{0 - d}} \]
    6. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      2. neg-lowering-neg.f6470.2

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr70.2%

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

    if -3.7999999999999998e42 < d < -1.59999999999999995e-27 or 3.6999999999999999e-159 < d < 2.6e11

    1. Initial program 88.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a \cdot d}{\mathsf{neg}\left(\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)\right)} \]
      12. *-lowering-*.f6460.8

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

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

    if -1.59999999999999995e-27 < d < 3.6999999999999999e-159

    1. Initial program 72.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. /-lowering-/.f6475.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.8 \cdot 10^{+42}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{elif}\;d \leq -1.6 \cdot 10^{-27}:\\ \;\;\;\;\frac{d \cdot a}{0 - \mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 3.7 \cdot 10^{-159}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 260000000000:\\ \;\;\;\;\frac{d \cdot a}{0 - \mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{0 - d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 74.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{0 - d}\\ \mathbf{if}\;d \leq -2.55 \cdot 10^{+153}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -5.8 \cdot 10^{-26}:\\ \;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{+37}:\\ \;\;\;\;\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 (- 0.0 d))))
   (if (<= d -2.55e+153)
     t_0
     (if (<= d -5.8e-26)
       (* a (/ (- 0.0 d) (fma c c (* d d))))
       (if (<= d 7.8e+37) (/ (- b (/ (* d a) c)) c) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = a / (0.0 - d);
	double tmp;
	if (d <= -2.55e+153) {
		tmp = t_0;
	} else if (d <= -5.8e-26) {
		tmp = a * ((0.0 - d) / fma(c, c, (d * d)));
	} else if (d <= 7.8e+37) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(a / Float64(0.0 - d))
	tmp = 0.0
	if (d <= -2.55e+153)
		tmp = t_0;
	elseif (d <= -5.8e-26)
		tmp = Float64(a * Float64(Float64(0.0 - d) / fma(c, c, Float64(d * d))));
	elseif (d <= 7.8e+37)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.55e+153], t$95$0, If[LessEqual[d, -5.8e-26], N[(a * N[(N[(0.0 - d), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.8e+37], 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}{0 - d}\\
\mathbf{if}\;d \leq -2.55 \cdot 10^{+153}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq -5.8 \cdot 10^{-26}:\\
\;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

\mathbf{elif}\;d \leq 7.8 \cdot 10^{+37}:\\
\;\;\;\;\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 < -2.55000000000000018e153 or 7.7999999999999997e37 < d

    1. Initial program 45.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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6475.0

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

      \[\leadsto \color{blue}{\frac{a}{0 - d}} \]
    6. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      2. neg-lowering-neg.f6475.0

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr75.0%

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

    if -2.55000000000000018e153 < d < -5.7999999999999996e-26

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(d, \mathsf{neg}\left(\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right), \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      16. *-lowering-*.f6488.7

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{a \cdot \frac{d}{{c}^{2} + {d}^{2}}} \]
      5. *-lowering-*.f64N/A

        \[\leadsto 0 - \color{blue}{a \cdot \frac{d}{{c}^{2} + {d}^{2}}} \]
      6. /-lowering-/.f64N/A

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

        \[\leadsto 0 - a \cdot \frac{d}{\color{blue}{c \cdot c} + {d}^{2}} \]
      8. accelerator-lowering-fma.f64N/A

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

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

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

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

    if -5.7999999999999996e-26 < d < 7.7999999999999997e37

    1. Initial program 74.1%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

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

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

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. *-lowering-*.f6483.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.55 \cdot 10^{+153}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{elif}\;d \leq -5.8 \cdot 10^{-26}:\\ \;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{+37}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{0 - d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 74.2% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;d \leq -5.2 \cdot 10^{-25}:\\
\;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.29999999999999994e154 or 7.20000000000000051e41 < d

    1. Initial program 45.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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6475.0

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

      \[\leadsto \color{blue}{\frac{a}{0 - d}} \]
    6. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      2. neg-lowering-neg.f6475.0

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr75.0%

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

    if -1.29999999999999994e154 < d < -5.2e-25

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(d, \mathsf{neg}\left(\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right), \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      16. *-lowering-*.f6488.7

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{a \cdot \frac{d}{{c}^{2} + {d}^{2}}} \]
      5. *-lowering-*.f64N/A

        \[\leadsto 0 - \color{blue}{a \cdot \frac{d}{{c}^{2} + {d}^{2}}} \]
      6. /-lowering-/.f64N/A

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

        \[\leadsto 0 - a \cdot \frac{d}{\color{blue}{c \cdot c} + {d}^{2}} \]
      8. accelerator-lowering-fma.f64N/A

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

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

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

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

    if -5.2e-25 < d < 7.20000000000000051e41

    1. Initial program 74.1%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

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

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

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. *-lowering-*.f6483.3

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

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

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

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

        \[\leadsto \frac{b - \color{blue}{a \cdot \frac{d}{c}}}{c} \]
      4. /-lowering-/.f6483.3

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{d}{c}}}{c} \]
    7. Applied egg-rr83.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.3 \cdot 10^{+154}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-25}:\\ \;\;\;\;a \cdot \frac{0 - d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;d \leq 7.2 \cdot 10^{+41}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{0 - d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 78.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \mathbf{if}\;d \leq -15200000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 2.9:\\ \;\;\;\;\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 (/ (fma c (/ b d) (- 0.0 a)) d)))
   (if (<= d -15200000.0) t_0 (if (<= d 2.9) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(c, (b / d), (0.0 - a)) / d;
	double tmp;
	if (d <= -15200000.0) {
		tmp = t_0;
	} else if (d <= 2.9) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(c, Float64(b / d), Float64(0.0 - a)) / d)
	tmp = 0.0
	if (d <= -15200000.0)
		tmp = t_0;
	elseif (d <= 2.9)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / d), $MachinePrecision] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -15200000.0], t$95$0, If[LessEqual[d, 2.9], 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{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -15200000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 2.9:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.52e7 or 2.89999999999999991 < d

    1. Initial program 53.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. 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. /-lowering-/.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{0 - a}\right)}{d} \]
      16. --lowering--.f6482.4

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

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

    if -1.52e7 < d < 2.89999999999999991

    1. Initial program 76.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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

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

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

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. *-lowering-*.f6486.5

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

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

Alternative 10: 78.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(b, \frac{c}{d}, 0 - a\right)}{d}\\ \mathbf{if}\;d \leq -310000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 7.2:\\ \;\;\;\;\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 (/ (fma b (/ c d) (- 0.0 a)) d)))
   (if (<= d -310000.0) t_0 (if (<= d 7.2) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(b, (c / d), (0.0 - a)) / d;
	double tmp;
	if (d <= -310000.0) {
		tmp = t_0;
	} else if (d <= 7.2) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(b, Float64(c / d), Float64(0.0 - a)) / d)
	tmp = 0.0
	if (d <= -310000.0)
		tmp = t_0;
	elseif (d <= 7.2)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * N[(c / d), $MachinePrecision] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -310000.0], t$95$0, If[LessEqual[d, 7.2], 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{\mathsf{fma}\left(b, \frac{c}{d}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -310000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 7.2:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.1e5 or 7.20000000000000018 < d

    1. Initial program 53.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, \color{blue}{0 - a}\right)}{d} \]
      8. --lowering--.f6481.3

        \[\leadsto \frac{\mathsf{fma}\left(b, \frac{c}{d}, \color{blue}{0 - a}\right)}{d} \]
    7. Simplified81.3%

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

    if -3.1e5 < d < 7.20000000000000018

    1. Initial program 76.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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

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

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

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. *-lowering-*.f6486.5

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

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

Alternative 11: 76.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;d \leq -6200000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 42:\\ \;\;\;\;\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 (/ (- (/ (* c b) d) a) d)))
   (if (<= d -6200000.0) t_0 (if (<= d 42.0) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = (((c * b) / d) - a) / d;
	double tmp;
	if (d <= -6200000.0) {
		tmp = t_0;
	} else if (d <= 42.0) {
		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 = (((c * b) / d) - a) / d
    if (d <= (-6200000.0d0)) then
        tmp = t_0
    else if (d <= 42.0d0) 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 = (((c * b) / d) - a) / d;
	double tmp;
	if (d <= -6200000.0) {
		tmp = t_0;
	} else if (d <= 42.0) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (((c * b) / d) - a) / d
	tmp = 0
	if d <= -6200000.0:
		tmp = t_0
	elif d <= 42.0:
		tmp = (b - ((d * a) / c)) / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(Float64(c * b) / d) - a) / d)
	tmp = 0.0
	if (d <= -6200000.0)
		tmp = t_0;
	elseif (d <= 42.0)
		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 = (((c * b) / d) - a) / d;
	tmp = 0.0;
	if (d <= -6200000.0)
		tmp = t_0;
	elseif (d <= 42.0)
		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[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6200000.0], t$95$0, If[LessEqual[d, 42.0], 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{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{if}\;d \leq -6200000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 42:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -6.2e6 or 42 < d

    1. Initial program 53.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(d, \mathsf{neg}\left(\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right), \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      16. *-lowering-*.f6458.9

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
      7. *-lowering-*.f6476.7

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

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

    if -6.2e6 < d < 42

    1. Initial program 76.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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

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

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

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. *-lowering-*.f6486.5

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

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

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

Alternative 12: 65.1% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;c \leq 2.15 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{0 - d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.8999999999999999e106 or 2.1500000000000002e45 < 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}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6477.7

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

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

    if -1.8999999999999999e106 < c < -6.2e-127

    1. Initial program 78.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, \frac{b}{{c}^{2} + {d}^{2}}, 0\right)} \]
      5. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left(c, \frac{b}{\color{blue}{d \cdot d} + {c}^{2}}, 0\right) \]
      8. accelerator-lowering-fma.f64N/A

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)}, 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

    if -6.2e-127 < c < 2.1500000000000002e45

    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 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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6465.6

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

      \[\leadsto \color{blue}{\frac{a}{0 - d}} \]
    6. Step-by-step derivation
      1. neg-sub0N/A

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

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr65.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.9 \cdot 10^{+106}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -6.2 \cdot 10^{-127}:\\ \;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 2.15 \cdot 10^{+45}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 63.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -95000:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 2.05 \cdot 10^{+45}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -95000.0) (/ b c) (if (<= c 2.05e+45) (/ a (- 0.0 d)) (/ b c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -95000.0) {
		tmp = b / c;
	} else if (c <= 2.05e+45) {
		tmp = a / (0.0 - d);
	} else {
		tmp = b / c;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (c <= (-95000.0d0)) then
        tmp = b / c
    else if (c <= 2.05d+45) then
        tmp = a / (0.0d0 - d)
    else
        tmp = b / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -95000.0) {
		tmp = b / c;
	} else if (c <= 2.05e+45) {
		tmp = a / (0.0 - d);
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -95000.0:
		tmp = b / c
	elif c <= 2.05e+45:
		tmp = a / (0.0 - d)
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -95000.0)
		tmp = Float64(b / c);
	elseif (c <= 2.05e+45)
		tmp = Float64(a / Float64(0.0 - d));
	else
		tmp = Float64(b / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (c <= -95000.0)
		tmp = b / c;
	elseif (c <= 2.05e+45)
		tmp = a / (0.0 - d);
	else
		tmp = b / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -95000.0], N[(b / c), $MachinePrecision], If[LessEqual[c, 2.05e+45], N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -95000:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{elif}\;c \leq 2.05 \cdot 10^{+45}:\\
\;\;\;\;\frac{a}{0 - d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -95000 or 2.05000000000000006e45 < c

    1. Initial program 55.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. /-lowering-/.f6474.4

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

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

    if -95000 < c < 2.05000000000000006e45

    1. Initial program 73.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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6460.3

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

      \[\leadsto \color{blue}{\frac{a}{0 - d}} \]
    6. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      2. neg-lowering-neg.f6460.3

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr60.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -95000:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 2.05 \cdot 10^{+45}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 42.6% 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 65.6%

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

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

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

    \[\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 2024196 
(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))))