Complex division, imag part

Percentage Accurate: 61.7% → 83.7%
Time: 9.0s
Alternatives: 12
Speedup: 1.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\ t_1 := \mathsf{fma}\left(\frac{c}{t\_0}, b, -\frac{d \cdot a}{t\_0}\right)\\ t_2 := \frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -4.5 \cdot 10^{+121}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;c \leq -1.85 \cdot 10^{-140}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{-94}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+59}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma c c (* d d)))
        (t_1 (fma (/ c t_0) b (- (/ (* d a) t_0))))
        (t_2 (/ (- b (* d (/ a c))) c)))
   (if (<= c -4.5e+121)
     t_2
     (if (<= c -1.85e-140)
       t_1
       (if (<= c 4.4e-94)
         (/ (fma b (/ c d) (- a)) d)
         (if (<= c 5.5e+59) t_1 t_2))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(c, c, (d * d));
	double t_1 = fma((c / t_0), b, -((d * a) / t_0));
	double t_2 = (b - (d * (a / c))) / c;
	double tmp;
	if (c <= -4.5e+121) {
		tmp = t_2;
	} else if (c <= -1.85e-140) {
		tmp = t_1;
	} else if (c <= 4.4e-94) {
		tmp = fma(b, (c / d), -a) / d;
	} else if (c <= 5.5e+59) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(c, c, Float64(d * d))
	t_1 = fma(Float64(c / t_0), b, Float64(-Float64(Float64(d * a) / t_0)))
	t_2 = Float64(Float64(b - Float64(d * Float64(a / c))) / c)
	tmp = 0.0
	if (c <= -4.5e+121)
		tmp = t_2;
	elseif (c <= -1.85e-140)
		tmp = t_1;
	elseif (c <= 4.4e-94)
		tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d);
	elseif (c <= 5.5e+59)
		tmp = t_1;
	else
		tmp = t_2;
	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 / t$95$0), $MachinePrecision] * b + (-N[(N[(d * a), $MachinePrecision] / t$95$0), $MachinePrecision])), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4.5e+121], t$95$2, If[LessEqual[c, -1.85e-140], t$95$1, If[LessEqual[c, 4.4e-94], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 5.5e+59], t$95$1, t$95$2]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.85 \cdot 10^{-140}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;c \leq 5.5 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -4.5000000000000003e121 or 5.4999999999999999e59 < c

    1. Initial program 45.9%

      \[\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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}{c}} \]
    10. Simplified86.0%

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

    if -4.5000000000000003e121 < c < -1.84999999999999989e-140 or 4.40000000000000002e-94 < c < 5.4999999999999999e59

    1. Initial program 83.0%

      \[\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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.84999999999999989e-140 < c < 4.40000000000000002e-94

    1. Initial program 69.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} + \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-lowering-neg.f6491.5

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

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

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

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

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

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

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

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

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

Alternative 2: 82.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\ t_1 := \frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -1.26 \cdot 10^{+119}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -1.32 \cdot 10^{-169}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;c \leq 8.6 \cdot 10^{-109}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{+56}:\\ \;\;\;\;\mathsf{fma}\left(-d, \frac{a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma c c (* d d))) (t_1 (/ (- b (* d (/ a c))) c)))
   (if (<= c -1.26e+119)
     t_1
     (if (<= c -1.32e-169)
       (/ (- (* c b) (* d a)) (+ (* d d) (* c c)))
       (if (<= c 8.6e-109)
         (/ (fma b (/ c d) (- a)) d)
         (if (<= c 1.35e+56) (fma (- d) (/ a t_0) (/ (* c b) t_0)) t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(c, c, (d * d));
	double t_1 = (b - (d * (a / c))) / c;
	double tmp;
	if (c <= -1.26e+119) {
		tmp = t_1;
	} else if (c <= -1.32e-169) {
		tmp = ((c * b) - (d * a)) / ((d * d) + (c * c));
	} else if (c <= 8.6e-109) {
		tmp = fma(b, (c / d), -a) / d;
	} else if (c <= 1.35e+56) {
		tmp = fma(-d, (a / t_0), ((c * b) / t_0));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(c, c, Float64(d * d))
	t_1 = Float64(Float64(b - Float64(d * Float64(a / c))) / c)
	tmp = 0.0
	if (c <= -1.26e+119)
		tmp = t_1;
	elseif (c <= -1.32e-169)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(d * d) + Float64(c * c)));
	elseif (c <= 8.6e-109)
		tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d);
	elseif (c <= 1.35e+56)
		tmp = fma(Float64(-d), Float64(a / t_0), Float64(Float64(c * b) / t_0));
	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[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -1.26e+119], t$95$1, If[LessEqual[c, -1.32e-169], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8.6e-109], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.35e+56], N[((-d) * N[(a / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $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{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -1.26 \cdot 10^{+119}:\\
\;\;\;\;t\_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.26e119 or 1.35000000000000005e56 < c

    1. Initial program 45.9%

      \[\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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}{c}} \]
    10. Simplified86.0%

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

    if -1.26e119 < c < -1.32000000000000001e-169

    1. Initial program 87.6%

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

    if -1.32000000000000001e-169 < c < 8.5999999999999993e-109

    1. Initial program 68.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} + \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-lowering-neg.f6490.7

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

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

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

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

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

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

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

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

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

    if 8.5999999999999993e-109 < c < 1.35000000000000005e56

    1. Initial program 74.8%

      \[\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-lft-neg-inN/A

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

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

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

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

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

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

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

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

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

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

        \[\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-rr78.5%

      \[\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)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification87.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.26 \cdot 10^{+119}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.32 \cdot 10^{-169}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;c \leq 8.6 \cdot 10^{-109}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{+56}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 82.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ t_1 := \frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -3.1 \cdot 10^{+119}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -1.32 \cdot 10^{-169}:\\ \;\;\;\;\frac{t\_0}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{-92}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{+55}:\\ \;\;\;\;\frac{t\_0}{\frac{1}{\frac{1}{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))) (t_1 (/ (- b (* d (/ a c))) c)))
   (if (<= c -3.1e+119)
     t_1
     (if (<= c -1.32e-169)
       (/ t_0 (+ (* d d) (* c c)))
       (if (<= c 1.1e-92)
         (/ (fma b (/ c d) (- a)) d)
         (if (<= c 1.7e+55) (/ t_0 (/ 1.0 (/ 1.0 (fma c c (* d d))))) t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = (b - (d * (a / c))) / c;
	double tmp;
	if (c <= -3.1e+119) {
		tmp = t_1;
	} else if (c <= -1.32e-169) {
		tmp = t_0 / ((d * d) + (c * c));
	} else if (c <= 1.1e-92) {
		tmp = fma(b, (c / d), -a) / d;
	} else if (c <= 1.7e+55) {
		tmp = t_0 / (1.0 / (1.0 / fma(c, c, (d * d))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	t_1 = Float64(Float64(b - Float64(d * Float64(a / c))) / c)
	tmp = 0.0
	if (c <= -3.1e+119)
		tmp = t_1;
	elseif (c <= -1.32e-169)
		tmp = Float64(t_0 / Float64(Float64(d * d) + Float64(c * c)));
	elseif (c <= 1.1e-92)
		tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d);
	elseif (c <= 1.7e+55)
		tmp = Float64(t_0 / Float64(1.0 / Float64(1.0 / fma(c, c, Float64(d * d)))));
	else
		tmp = t_1;
	end
	return 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[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.1e+119], t$95$1, If[LessEqual[c, -1.32e-169], N[(t$95$0 / N[(N[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.1e-92], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.7e+55], N[(t$95$0 / N[(1.0 / N[(1.0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.32 \cdot 10^{-169}:\\
\;\;\;\;\frac{t\_0}{d \cdot d + c \cdot c}\\

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

\mathbf{elif}\;c \leq 1.7 \cdot 10^{+55}:\\
\;\;\;\;\frac{t\_0}{\frac{1}{\frac{1}{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -3.09999999999999995e119 or 1.6999999999999999e55 < c

    1. Initial program 45.9%

      \[\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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}{c}} \]
    10. Simplified86.0%

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

    if -3.09999999999999995e119 < c < -1.32000000000000001e-169

    1. Initial program 87.6%

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

    if -1.32000000000000001e-169 < c < 1.09999999999999994e-92

    1. Initial program 68.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-lowering-neg.f6491.2

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

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

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

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

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

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

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

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

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

    if 1.09999999999999994e-92 < c < 1.6999999999999999e55

    1. Initial program 74.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.1 \cdot 10^{+119}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.32 \cdot 10^{-169}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{-92}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{+55}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\frac{1}{\frac{1}{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 82.7% 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{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -6.8 \cdot 10^{+118}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -1.32 \cdot 10^{-169}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-96}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+59}:\\ \;\;\;\;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 (/ (- b (* d (/ a c))) c)))
   (if (<= c -6.8e+118)
     t_1
     (if (<= c -1.32e-169)
       t_0
       (if (<= c 7.2e-96)
         (/ (fma b (/ c d) (- a)) d)
         (if (<= c 5.5e+59) 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 = (b - (d * (a / c))) / c;
	double tmp;
	if (c <= -6.8e+118) {
		tmp = t_1;
	} else if (c <= -1.32e-169) {
		tmp = t_0;
	} else if (c <= 7.2e-96) {
		tmp = fma(b, (c / d), -a) / d;
	} else if (c <= 5.5e+59) {
		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(Float64(b - Float64(d * Float64(a / c))) / c)
	tmp = 0.0
	if (c <= -6.8e+118)
		tmp = t_1;
	elseif (c <= -1.32e-169)
		tmp = t_0;
	elseif (c <= 7.2e-96)
		tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d);
	elseif (c <= 5.5e+59)
		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[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -6.8e+118], t$95$1, If[LessEqual[c, -1.32e-169], t$95$0, If[LessEqual[c, 7.2e-96], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 5.5e+59], 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{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -6.8 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;c \leq -1.32 \cdot 10^{-169}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 5.5 \cdot 10^{+59}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -6.79999999999999973e118 or 5.4999999999999999e59 < c

    1. Initial program 45.9%

      \[\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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}{c}} \]
    10. Simplified86.0%

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

    if -6.79999999999999973e118 < c < -1.32000000000000001e-169 or 7.20000000000000016e-96 < c < 5.4999999999999999e59

    1. Initial program 83.6%

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

    if -1.32000000000000001e-169 < c < 7.20000000000000016e-96

    1. Initial program 68.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-lowering-neg.f6491.2

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6.8 \cdot 10^{+118}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.32 \cdot 10^{-169}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-96}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+59}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 64.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ \mathbf{if}\;c \leq -0.078:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-247}:\\ \;\;\;\;\frac{t\_0}{d \cdot d}\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;c \leq 1.22 \cdot 10^{+114}:\\ \;\;\;\;\frac{t\_0}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))))
   (if (<= c -0.078)
     (/ b c)
     (if (<= c -2e-247)
       (/ t_0 (* d d))
       (if (<= c 1.6e-5)
         (/ a (- d))
         (if (<= c 1.22e+114) (/ t_0 (* c c)) (/ b c)))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if (c <= -0.078) {
		tmp = b / c;
	} else if (c <= -2e-247) {
		tmp = t_0 / (d * d);
	} else if (c <= 1.6e-5) {
		tmp = a / -d;
	} else if (c <= 1.22e+114) {
		tmp = t_0 / (c * c);
	} else {
		tmp = b / c;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (c * b) - (d * a)
    if (c <= (-0.078d0)) then
        tmp = b / c
    else if (c <= (-2d-247)) then
        tmp = t_0 / (d * d)
    else if (c <= 1.6d-5) then
        tmp = a / -d
    else if (c <= 1.22d+114) then
        tmp = t_0 / (c * c)
    else
        tmp = b / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if (c <= -0.078) {
		tmp = b / c;
	} else if (c <= -2e-247) {
		tmp = t_0 / (d * d);
	} else if (c <= 1.6e-5) {
		tmp = a / -d;
	} else if (c <= 1.22e+114) {
		tmp = t_0 / (c * c);
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	tmp = 0
	if c <= -0.078:
		tmp = b / c
	elif c <= -2e-247:
		tmp = t_0 / (d * d)
	elif c <= 1.6e-5:
		tmp = a / -d
	elif c <= 1.22e+114:
		tmp = t_0 / (c * c)
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	tmp = 0.0
	if (c <= -0.078)
		tmp = Float64(b / c);
	elseif (c <= -2e-247)
		tmp = Float64(t_0 / Float64(d * d));
	elseif (c <= 1.6e-5)
		tmp = Float64(a / Float64(-d));
	elseif (c <= 1.22e+114)
		tmp = Float64(t_0 / Float64(c * c));
	else
		tmp = Float64(b / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	tmp = 0.0;
	if (c <= -0.078)
		tmp = b / c;
	elseif (c <= -2e-247)
		tmp = t_0 / (d * d);
	elseif (c <= 1.6e-5)
		tmp = a / -d;
	elseif (c <= 1.22e+114)
		tmp = t_0 / (c * c);
	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]}, If[LessEqual[c, -0.078], N[(b / c), $MachinePrecision], If[LessEqual[c, -2e-247], N[(t$95$0 / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.6e-5], N[(a / (-d)), $MachinePrecision], If[LessEqual[c, 1.22e+114], N[(t$95$0 / N[(c * c), $MachinePrecision]), $MachinePrecision], N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;c \leq -0.078:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{elif}\;c \leq -2 \cdot 10^{-247}:\\
\;\;\;\;\frac{t\_0}{d \cdot d}\\

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

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

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


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

    1. Initial program 48.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-/.f6474.1

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

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

    if -0.0779999999999999999 < c < -2e-247

    1. Initial program 89.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 \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-*.f6474.7

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

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

    if -2e-247 < c < 1.59999999999999993e-5

    1. Initial program 66.4%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. 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-lowering-neg.f6473.8

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

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

    if 1.59999999999999993e-5 < c < 1.21999999999999999e114

    1. Initial program 87.9%

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

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c}} \]
      2. *-lowering-*.f6480.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -0.078:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-247}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-5}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;c \leq 1.22 \cdot 10^{+114}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 65.3% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;c \leq 0.00047:\\
\;\;\;\;\frac{a}{-d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -7.5999999999999996e122 or 4.3999999999999999e112 < c

    1. Initial program 37.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-/.f6479.1

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

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

    if -7.5999999999999996e122 < c < -2.8999999999999999e-142

    1. Initial program 85.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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.8999999999999999e-142 < c < 4.69999999999999986e-4

    1. Initial program 70.5%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. 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-lowering-neg.f6473.0

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

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

    if 4.69999999999999986e-4 < c < 4.3999999999999999e112

    1. Initial program 87.9%

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

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c}} \]
      2. *-lowering-*.f6480.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.6 \cdot 10^{+122}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -2.9 \cdot 10^{-142}:\\ \;\;\;\;c \cdot \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 0.00047:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{+112}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 78.7% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -0.320000000000000007 or 2.59999999999999987e-30 < c

    1. Initial program 56.4%

      \[\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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}{c}} \]
    10. Simplified81.0%

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

    if -0.320000000000000007 < c < 2.59999999999999987e-30

    1. Initial program 74.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} + \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-lowering-neg.f6483.6

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

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

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

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

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

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

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

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

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

Alternative 8: 72.9% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;d \leq 1.36 \cdot 10^{+66}:\\
\;\;\;\;\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 < -5.80000000000000028e91 or 1.36e66 < d

    1. Initial program 48.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-lowering-neg.f6477.2

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

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

    if -5.80000000000000028e91 < d < 1.36e66

    1. Initial program 74.4%

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

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

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

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

Alternative 9: 72.5% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.4e91 or 1.99999999999999989e66 < d

    1. Initial program 48.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-lowering-neg.f6477.2

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

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

    if -5.4e91 < d < 1.99999999999999989e66

    1. Initial program 74.4%

      \[\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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}{c}} \]
    10. Simplified77.2%

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

Alternative 10: 64.1% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;c \leq 2.2 \cdot 10^{+53}:\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.05000000000000008e122 or 2.19999999999999999e53 < c

    1. Initial program 46.4%

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

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

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

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

    if -1.05000000000000008e122 < c < -1.19999999999999994e-142

    1. Initial program 85.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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.19999999999999994e-142 < c < 2.19999999999999999e53

    1. Initial program 70.8%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    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-lowering-neg.f6470.2

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

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

Alternative 11: 64.4% accurate, 1.5× speedup?

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

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

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

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


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

    1. Initial program 54.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-/.f6474.1

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

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

    if -0.46999999999999997 < c < 2.09999999999999995e45

    1. Initial program 74.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. 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-lowering-neg.f6464.6

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

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

Alternative 12: 42.8% 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 64.5%

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

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

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

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

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

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (< (fabs d) (fabs c))
   (/ (- b (* a (/ d c))) (+ c (* d (/ d c))))
   (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (abs(d) < abs(c)) then
        tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (Math.abs(d) < Math.abs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (abs(d) < abs(c))
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (abs(d) < abs(c))
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024199 
(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))))