Complex division, imag part

Percentage Accurate: 62.0% → 96.3%
Time: 13.0s
Alternatives: 11
Speedup: 0.6×

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 11 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: 62.0% 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: 96.3% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.4 \cdot 10^{+235}:\\
\;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.40000000000000013e235

    1. Initial program 32.7%

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

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

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg74.6%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg74.6%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. associate-/l*76.3%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/76.3%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{{c}^{2}} \cdot d} \]
    6. Step-by-step derivation
      1. *-un-lft-identity76.3%

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{1 \cdot a}}{{c}^{2}} \cdot d \]
      2. pow276.3%

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\color{blue}{c \cdot c}} \cdot d \]
      3. times-frac85.3%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    7. Applied egg-rr85.3%

      \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    8. Step-by-step derivation
      1. associate-*l/85.4%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{1 \cdot \frac{a}{c}}{c}} \cdot d \]
      2. *-lft-identity85.4%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{c}} \cdot d \]
    10. Step-by-step derivation
      1. associate-*l/99.9%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    12. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{\frac{c}{d}}} \]
    13. Simplified99.9%

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

    if -1.40000000000000013e235 < c

    1. Initial program 57.7%

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

        \[\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-neg55.0%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      3. *-commutative55.0%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      4. add-sqr-sqrt55.0%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      5. times-frac60.3%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      6. fma-def60.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      7. hypot-def60.3%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{\frac{a}{\frac{c \cdot c + d \cdot d}{d}}}\right) \]
      10. add-sqr-sqrt77.7%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}{d}}\right) \]
      11. pow277.7%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}{d}}\right) \]
      12. hypot-def77.7%

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

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

      \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\color{blue}{d + \frac{{c}^{2}}{d}}}\right) \]
    6. Step-by-step derivation
      1. +-commutative93.2%

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

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

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

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

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

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

Alternative 2: 89.3% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - a \cdot d\\ t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+237}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* a d))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+237)))
     (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d))
     (* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (a * d);
	double t_1 = t_0 / ((c * c) + (d * d));
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+237)) {
		tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
	} else {
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(a * d))
	t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+237))
		tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d));
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d)));
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+237]], $MachinePrecision]], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot b - a \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+237}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0 or 5.0000000000000002e237 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 19.1%

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

        \[\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-neg12.1%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      3. *-commutative12.1%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      4. add-sqr-sqrt12.1%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      5. times-frac27.1%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      6. fma-def27.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      7. hypot-def27.1%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{\frac{a}{\frac{c \cdot c + d \cdot d}{d}}}\right) \]
      10. add-sqr-sqrt61.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}{d}}\right) \]
      11. pow261.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}{d}}\right) \]
      12. hypot-def61.4%

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

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

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

    if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.0000000000000002e237

    1. Initial program 75.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity75.1%

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def75.2%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def99.1%

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

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

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

Alternative 3: 85.4% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 4.0000000000000003e302

    1. Initial program 71.5%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity71.5%

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

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac71.5%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def71.5%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def94.6%

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

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

    if 4.0000000000000003e302 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 11.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2}} + \frac{b}{c}} \]
    4. Step-by-step derivation
      1. fma-def41.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1, \frac{a \cdot d}{{c}^{2}}, \frac{b}{c}\right)} \]
      2. associate-/l*44.3%

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{a}{{c}^{2}} \cdot d}, \frac{b}{c}\right) \]
      2. associate-*l/41.6%

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

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

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

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

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

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

Alternative 4: 77.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -8 \cdot 10^{+81}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{elif}\;c \leq -4.8 \cdot 10^{-156}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{-218}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 0.28:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* a d)) (+ (* c c) (* d d)))))
   (if (<= c -8e+81)
     (- (/ b c) (/ (/ a c) (/ c d)))
     (if (<= c -4.8e-156)
       t_0
       (if (<= c 2.2e-218)
         (/ (- a) d)
         (if (<= c 0.28) t_0 (* (/ c (hypot c d)) (/ b (hypot c d)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -8e+81) {
		tmp = (b / c) - ((a / c) / (c / d));
	} else if (c <= -4.8e-156) {
		tmp = t_0;
	} else if (c <= 2.2e-218) {
		tmp = -a / d;
	} else if (c <= 0.28) {
		tmp = t_0;
	} else {
		tmp = (c / hypot(c, d)) * (b / hypot(c, d));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -8e+81) {
		tmp = (b / c) - ((a / c) / (c / d));
	} else if (c <= -4.8e-156) {
		tmp = t_0;
	} else if (c <= 2.2e-218) {
		tmp = -a / d;
	} else if (c <= 0.28) {
		tmp = t_0;
	} else {
		tmp = (c / Math.hypot(c, d)) * (b / Math.hypot(c, d));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -8e+81:
		tmp = (b / c) - ((a / c) / (c / d))
	elif c <= -4.8e-156:
		tmp = t_0
	elif c <= 2.2e-218:
		tmp = -a / d
	elif c <= 0.28:
		tmp = t_0
	else:
		tmp = (c / math.hypot(c, d)) * (b / math.hypot(c, d))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (c <= -8e+81)
		tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d)));
	elseif (c <= -4.8e-156)
		tmp = t_0;
	elseif (c <= 2.2e-218)
		tmp = Float64(Float64(-a) / d);
	elseif (c <= 0.28)
		tmp = t_0;
	else
		tmp = Float64(Float64(c / hypot(c, d)) * Float64(b / hypot(c, d)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (c <= -8e+81)
		tmp = (b / c) - ((a / c) / (c / d));
	elseif (c <= -4.8e-156)
		tmp = t_0;
	elseif (c <= 2.2e-218)
		tmp = -a / d;
	elseif (c <= 0.28)
		tmp = t_0;
	else
		tmp = (c / hypot(c, d)) * (b / hypot(c, d));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8e+81], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -4.8e-156], t$95$0, If[LessEqual[c, 2.2e-218], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 0.28], t$95$0, N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -4.8 \cdot 10^{-156}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 0.28:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -7.99999999999999937e81

    1. Initial program 32.6%

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

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

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg70.3%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg70.3%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. associate-/l*69.7%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/71.2%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{{c}^{2}} \cdot d} \]
    6. Step-by-step derivation
      1. *-un-lft-identity71.2%

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{1 \cdot a}}{{c}^{2}} \cdot d \]
      2. pow271.2%

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\color{blue}{c \cdot c}} \cdot d \]
      3. times-frac79.6%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    7. Applied egg-rr79.6%

      \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    8. Step-by-step derivation
      1. associate-*l/79.6%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{1 \cdot \frac{a}{c}}{c}} \cdot d \]
      2. *-lft-identity79.6%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{c}} \cdot d \]
    10. Step-by-step derivation
      1. associate-*l/84.9%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    12. Step-by-step derivation
      1. associate-/l*85.0%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{\frac{c}{d}}} \]
    13. Simplified85.0%

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

    if -7.99999999999999937e81 < c < -4.8e-156 or 2.20000000000000007e-218 < c < 0.28000000000000003

    1. Initial program 81.2%

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

    if -4.8e-156 < c < 2.20000000000000007e-218

    1. Initial program 64.2%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-188.1%

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

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

    if 0.28000000000000003 < c

    1. Initial program 29.4%

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

        \[\leadsto \frac{\color{blue}{\frac{\left(b \cdot c\right) \cdot \left(b \cdot c\right) - \left(a \cdot d\right) \cdot \left(a \cdot d\right)}{b \cdot c + a \cdot d}}}{c \cdot c + d \cdot d} \]
      2. clear-num18.4%

        \[\leadsto \frac{\color{blue}{\frac{1}{\frac{b \cdot c + a \cdot d}{\left(b \cdot c\right) \cdot \left(b \cdot c\right) - \left(a \cdot d\right) \cdot \left(a \cdot d\right)}}}}{c \cdot c + d \cdot d} \]
      3. fma-def18.4%

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

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

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

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\frac{1}{b \cdot c}}}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. associate-/r*30.0%

        \[\leadsto \frac{\frac{1}{\color{blue}{\frac{\frac{1}{b}}{c}}}}{c \cdot c + d \cdot d} \]
    7. Simplified30.0%

      \[\leadsto \frac{\frac{1}{\color{blue}{\frac{\frac{1}{b}}{c}}}}{c \cdot c + d \cdot d} \]
    8. Step-by-step derivation
      1. associate-/r/30.0%

        \[\leadsto \frac{\color{blue}{\frac{1}{\frac{1}{b}} \cdot c}}{c \cdot c + d \cdot d} \]
      2. inv-pow30.0%

        \[\leadsto \frac{\frac{1}{\color{blue}{{b}^{-1}}} \cdot c}{c \cdot c + d \cdot d} \]
      3. pow-flip30.0%

        \[\leadsto \frac{\color{blue}{{b}^{\left(--1\right)}} \cdot c}{c \cdot c + d \cdot d} \]
      4. metadata-eval30.0%

        \[\leadsto \frac{{b}^{\color{blue}{1}} \cdot c}{c \cdot c + d \cdot d} \]
      5. pow130.0%

        \[\leadsto \frac{\color{blue}{b} \cdot c}{c \cdot c + d \cdot d} \]
      6. add-sqr-sqrt30.0%

        \[\leadsto \frac{b \cdot c}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      7. hypot-udef30.0%

        \[\leadsto \frac{b \cdot c}{\color{blue}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{c \cdot c + d \cdot d}} \]
      8. hypot-udef30.0%

        \[\leadsto \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      9. times-frac77.6%

        \[\leadsto \color{blue}{\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}} \]
    9. Applied egg-rr77.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8 \cdot 10^{+81}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{elif}\;c \leq -4.8 \cdot 10^{-156}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{-218}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 0.28:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 78.1% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -8 \cdot 10^{-158}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 4.3 \cdot 10^{+21}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.9e78

    1. Initial program 32.6%

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

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

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg70.3%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg70.3%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. associate-/l*69.7%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/71.2%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{{c}^{2}} \cdot d} \]
    6. Step-by-step derivation
      1. *-un-lft-identity71.2%

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{1 \cdot a}}{{c}^{2}} \cdot d \]
      2. pow271.2%

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\color{blue}{c \cdot c}} \cdot d \]
      3. times-frac79.6%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    7. Applied egg-rr79.6%

      \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    8. Step-by-step derivation
      1. associate-*l/79.6%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{1 \cdot \frac{a}{c}}{c}} \cdot d \]
      2. *-lft-identity79.6%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{c}} \cdot d \]
    10. Step-by-step derivation
      1. associate-*l/84.9%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    12. Step-by-step derivation
      1. associate-/l*85.0%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{\frac{c}{d}}} \]
    13. Simplified85.0%

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

    if -1.9e78 < c < -8.00000000000000052e-158 or 3.9e-218 < c < 4.3e21

    1. Initial program 80.6%

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

    if -8.00000000000000052e-158 < c < 3.9e-218

    1. Initial program 64.2%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-188.1%

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

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

    if 4.3e21 < c

    1. Initial program 28.6%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1, \frac{a \cdot d}{{c}^{2}}, \frac{b}{c}\right)} \]
      2. associate-/l*62.5%

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{a}{{c}^{2}} \cdot d}, \frac{b}{c}\right) \]
      2. associate-*l/62.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.9 \cdot 10^{+78}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{elif}\;c \leq -8 \cdot 10^{-158}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.9 \cdot 10^{-218}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{+21}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{a}{c} \cdot \frac{d}{c}, \frac{b}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 78.1% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;c \leq -4.3 \cdot 10^{-160}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 4.3 \cdot 10^{+21}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -6.80000000000000014e78 or 4.3e21 < c

    1. Initial program 30.7%

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

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

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg66.3%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg66.3%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. associate-/l*66.2%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/67.9%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{{c}^{2}} \cdot d} \]
    6. Step-by-step derivation
      1. *-un-lft-identity67.9%

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{1 \cdot a}}{{c}^{2}} \cdot d \]
      2. pow267.9%

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\color{blue}{c \cdot c}} \cdot d \]
      3. times-frac75.6%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    7. Applied egg-rr75.6%

      \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    8. Step-by-step derivation
      1. associate-*l/75.6%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{1 \cdot \frac{a}{c}}{c}} \cdot d \]
      2. *-lft-identity75.6%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{c}} \cdot d \]
    10. Step-by-step derivation
      1. associate-*l/79.2%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    12. Step-by-step derivation
      1. associate-/l*79.3%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{\frac{c}{d}}} \]
    13. Simplified79.3%

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

    if -6.80000000000000014e78 < c < -4.30000000000000014e-160 or 6.49999999999999983e-218 < c < 4.3e21

    1. Initial program 80.6%

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

    if -4.30000000000000014e-160 < c < 6.49999999999999983e-218

    1. Initial program 64.2%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-188.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6.8 \cdot 10^{+78}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{elif}\;c \leq -4.3 \cdot 10^{-160}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 6.5 \cdot 10^{-218}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{+21}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 68.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1.8 \cdot 10^{-33} \lor \neg \left(c \leq 2.3 \cdot 10^{-92}\right) \land \left(c \leq 1.55 \cdot 10^{-44} \lor \neg \left(c \leq 4.4 \cdot 10^{+21}\right)\right):\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= c -1.8e-33)
         (and (not (<= c 2.3e-92)) (or (<= c 1.55e-44) (not (<= c 4.4e+21)))))
   (- (/ b c) (* d (/ (/ a c) c)))
   (/ (- a) d)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((c <= -1.8e-33) || (!(c <= 2.3e-92) && ((c <= 1.55e-44) || !(c <= 4.4e+21)))) {
		tmp = (b / c) - (d * ((a / c) / c));
	} else {
		tmp = -a / d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((c <= (-1.8d-33)) .or. (.not. (c <= 2.3d-92)) .and. (c <= 1.55d-44) .or. (.not. (c <= 4.4d+21))) then
        tmp = (b / c) - (d * ((a / c) / c))
    else
        tmp = -a / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((c <= -1.8e-33) || (!(c <= 2.3e-92) && ((c <= 1.55e-44) || !(c <= 4.4e+21)))) {
		tmp = (b / c) - (d * ((a / c) / c));
	} else {
		tmp = -a / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (c <= -1.8e-33) or (not (c <= 2.3e-92) and ((c <= 1.55e-44) or not (c <= 4.4e+21))):
		tmp = (b / c) - (d * ((a / c) / c))
	else:
		tmp = -a / d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((c <= -1.8e-33) || (!(c <= 2.3e-92) && ((c <= 1.55e-44) || !(c <= 4.4e+21))))
		tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c)));
	else
		tmp = Float64(Float64(-a) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((c <= -1.8e-33) || (~((c <= 2.3e-92)) && ((c <= 1.55e-44) || ~((c <= 4.4e+21)))))
		tmp = (b / c) - (d * ((a / c) / c));
	else
		tmp = -a / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.8e-33], And[N[Not[LessEqual[c, 2.3e-92]], $MachinePrecision], Or[LessEqual[c, 1.55e-44], N[Not[LessEqual[c, 4.4e+21]], $MachinePrecision]]]], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.8 \cdot 10^{-33} \lor \neg \left(c \leq 2.3 \cdot 10^{-92}\right) \land \left(c \leq 1.55 \cdot 10^{-44} \lor \neg \left(c \leq 4.4 \cdot 10^{+21}\right)\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\

\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.80000000000000017e-33 or 2.30000000000000016e-92 < c < 1.54999999999999992e-44 or 4.4e21 < c

    1. Initial program 44.5%

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

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

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg66.9%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg66.9%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. associate-/l*66.9%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/68.1%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{{c}^{2}} \cdot d} \]
    6. Step-by-step derivation
      1. *-un-lft-identity68.1%

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{1 \cdot a}}{{c}^{2}} \cdot d \]
      2. pow268.1%

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\color{blue}{c \cdot c}} \cdot d \]
      3. times-frac73.9%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    7. Applied egg-rr73.9%

      \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    8. Step-by-step derivation
      1. associate-*l/73.9%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{1 \cdot \frac{a}{c}}{c}} \cdot d \]
      2. *-lft-identity73.9%

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

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

    if -1.80000000000000017e-33 < c < 2.30000000000000016e-92 or 1.54999999999999992e-44 < c < 4.4e21

    1. Initial program 70.9%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-174.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.8 \cdot 10^{-33} \lor \neg \left(c \leq 2.3 \cdot 10^{-92}\right) \land \left(c \leq 1.55 \cdot 10^{-44} \lor \neg \left(c \leq 4.4 \cdot 10^{+21}\right)\right):\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 69.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1.85 \cdot 10^{-38} \lor \neg \left(c \leq 2.3 \cdot 10^{-92} \lor \neg \left(c \leq 2.15 \cdot 10^{-42}\right) \land c \leq 1.15 \cdot 10^{+22}\right):\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= c -1.85e-38)
         (not (or (<= c 2.3e-92) (and (not (<= c 2.15e-42)) (<= c 1.15e+22)))))
   (- (/ b c) (/ (/ a c) (/ c d)))
   (/ (- a) d)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((c <= -1.85e-38) || !((c <= 2.3e-92) || (!(c <= 2.15e-42) && (c <= 1.15e+22)))) {
		tmp = (b / c) - ((a / c) / (c / d));
	} else {
		tmp = -a / d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((c <= (-1.85d-38)) .or. (.not. (c <= 2.3d-92) .or. (.not. (c <= 2.15d-42)) .and. (c <= 1.15d+22))) then
        tmp = (b / c) - ((a / c) / (c / d))
    else
        tmp = -a / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((c <= -1.85e-38) || !((c <= 2.3e-92) || (!(c <= 2.15e-42) && (c <= 1.15e+22)))) {
		tmp = (b / c) - ((a / c) / (c / d));
	} else {
		tmp = -a / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (c <= -1.85e-38) or not ((c <= 2.3e-92) or (not (c <= 2.15e-42) and (c <= 1.15e+22))):
		tmp = (b / c) - ((a / c) / (c / d))
	else:
		tmp = -a / d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((c <= -1.85e-38) || !((c <= 2.3e-92) || (!(c <= 2.15e-42) && (c <= 1.15e+22))))
		tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d)));
	else
		tmp = Float64(Float64(-a) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((c <= -1.85e-38) || ~(((c <= 2.3e-92) || (~((c <= 2.15e-42)) && (c <= 1.15e+22)))))
		tmp = (b / c) - ((a / c) / (c / d));
	else
		tmp = -a / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.85e-38], N[Not[Or[LessEqual[c, 2.3e-92], And[N[Not[LessEqual[c, 2.15e-42]], $MachinePrecision], LessEqual[c, 1.15e+22]]]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.85 \cdot 10^{-38} \lor \neg \left(c \leq 2.3 \cdot 10^{-92} \lor \neg \left(c \leq 2.15 \cdot 10^{-42}\right) \land c \leq 1.15 \cdot 10^{+22}\right):\\
\;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.85e-38 or 2.30000000000000016e-92 < c < 2.1500000000000001e-42 or 1.1500000000000001e22 < c

    1. Initial program 44.5%

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

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

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg66.9%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg66.9%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. associate-/l*66.9%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/68.1%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{{c}^{2}} \cdot d} \]
    6. Step-by-step derivation
      1. *-un-lft-identity68.1%

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{1 \cdot a}}{{c}^{2}} \cdot d \]
      2. pow268.1%

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\color{blue}{c \cdot c}} \cdot d \]
      3. times-frac73.9%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    7. Applied egg-rr73.9%

      \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    8. Step-by-step derivation
      1. associate-*l/73.9%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{1 \cdot \frac{a}{c}}{c}} \cdot d \]
      2. *-lft-identity73.9%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{c}} \cdot d \]
    10. Step-by-step derivation
      1. associate-*l/76.5%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    12. Step-by-step derivation
      1. associate-/l*76.6%

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

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

    if -1.85e-38 < c < 2.30000000000000016e-92 or 2.1500000000000001e-42 < c < 1.1500000000000001e22

    1. Initial program 70.9%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-174.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.85 \cdot 10^{-38} \lor \neg \left(c \leq 2.3 \cdot 10^{-92} \lor \neg \left(c \leq 2.15 \cdot 10^{-42}\right) \land c \leq 1.15 \cdot 10^{+22}\right):\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 68.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := \frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\
\mathbf{if}\;c \leq -1.85 \cdot 10^{-34}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \leq 5.7 \cdot 10^{-95}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 10^{-44}:\\
\;\;\;\;\frac{b}{c} + d \cdot \left(\frac{a}{c} \cdot \frac{-1}{c}\right)\\

\mathbf{elif}\;c \leq 4.4 \cdot 10^{+21}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.84999999999999994e-34 or 4.4e21 < c

    1. Initial program 41.3%

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

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

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg65.3%

        \[\leadsto \frac{b}{c} + \color{blue}{\left(-\frac{a \cdot d}{{c}^{2}}\right)} \]
      3. unsub-neg65.3%

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. associate-/l*65.2%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/66.5%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{{c}^{2}} \cdot d} \]
    6. Step-by-step derivation
      1. *-un-lft-identity66.5%

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

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\color{blue}{c \cdot c}} \cdot d \]
      3. times-frac72.7%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    8. Step-by-step derivation
      1. associate-*l/72.7%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{1 \cdot \frac{a}{c}}{c}} \cdot d \]
      2. *-lft-identity72.7%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{c}} \cdot d \]
    10. Step-by-step derivation
      1. associate-*l/75.5%

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    12. Step-by-step derivation
      1. associate-/l*75.6%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{\frac{c}{d}}} \]
    13. Simplified75.6%

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

    if -1.84999999999999994e-34 < c < 5.7e-95 or 9.99999999999999953e-45 < c < 4.4e21

    1. Initial program 70.9%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-174.5%

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

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

    if 5.7e-95 < c < 9.99999999999999953e-45

    1. Initial program 89.5%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}} \]
      4. associate-/l*90.0%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/90.1%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{{c}^{2}} \cdot d} \]
    6. Step-by-step derivation
      1. *-un-lft-identity90.1%

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{1 \cdot a}}{{c}^{2}} \cdot d \]
      2. pow290.1%

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\color{blue}{c \cdot c}} \cdot d \]
      3. times-frac90.3%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(\frac{1}{c} \cdot \frac{a}{c}\right)} \cdot d \]
    7. Applied egg-rr90.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.85 \cdot 10^{-34}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{elif}\;c \leq 5.7 \cdot 10^{-95}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 10^{-44}:\\ \;\;\;\;\frac{b}{c} + d \cdot \left(\frac{a}{c} \cdot \frac{-1}{c}\right)\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{+21}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 63.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -5.2 \cdot 10^{-35} \lor \neg \left(c \leq 2.2 \cdot 10^{-92}\right) \land \left(c \leq 9.8 \cdot 10^{-45} \lor \neg \left(c \leq 4.4 \cdot 10^{+21}\right)\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= c -5.2e-35)
         (and (not (<= c 2.2e-92)) (or (<= c 9.8e-45) (not (<= c 4.4e+21)))))
   (/ b c)
   (/ (- a) d)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((c <= -5.2e-35) || (!(c <= 2.2e-92) && ((c <= 9.8e-45) || !(c <= 4.4e+21)))) {
		tmp = b / c;
	} else {
		tmp = -a / d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((c <= (-5.2d-35)) .or. (.not. (c <= 2.2d-92)) .and. (c <= 9.8d-45) .or. (.not. (c <= 4.4d+21))) then
        tmp = b / c
    else
        tmp = -a / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((c <= -5.2e-35) || (!(c <= 2.2e-92) && ((c <= 9.8e-45) || !(c <= 4.4e+21)))) {
		tmp = b / c;
	} else {
		tmp = -a / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (c <= -5.2e-35) or (not (c <= 2.2e-92) and ((c <= 9.8e-45) or not (c <= 4.4e+21))):
		tmp = b / c
	else:
		tmp = -a / d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((c <= -5.2e-35) || (!(c <= 2.2e-92) && ((c <= 9.8e-45) || !(c <= 4.4e+21))))
		tmp = Float64(b / c);
	else
		tmp = Float64(Float64(-a) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((c <= -5.2e-35) || (~((c <= 2.2e-92)) && ((c <= 9.8e-45) || ~((c <= 4.4e+21)))))
		tmp = b / c;
	else
		tmp = -a / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.2e-35], And[N[Not[LessEqual[c, 2.2e-92]], $MachinePrecision], Or[LessEqual[c, 9.8e-45], N[Not[LessEqual[c, 4.4e+21]], $MachinePrecision]]]], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.2 \cdot 10^{-35} \lor \neg \left(c \leq 2.2 \cdot 10^{-92}\right) \land \left(c \leq 9.8 \cdot 10^{-45} \lor \neg \left(c \leq 4.4 \cdot 10^{+21}\right)\right):\\
\;\;\;\;\frac{b}{c}\\

\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.20000000000000009e-35 or 2.19999999999999987e-92 < c < 9.7999999999999996e-45 or 4.4e21 < c

    1. Initial program 44.5%

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

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

    if -5.20000000000000009e-35 < c < 2.19999999999999987e-92 or 9.7999999999999996e-45 < c < 4.4e21

    1. Initial program 70.9%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-174.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.2 \cdot 10^{-35} \lor \neg \left(c \leq 2.2 \cdot 10^{-92}\right) \land \left(c \leq 9.8 \cdot 10^{-45} \lor \neg \left(c \leq 4.4 \cdot 10^{+21}\right)\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 43.2% accurate, 5.0× 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 55.7%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  4. Final simplification42.6%

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

Developer target: 99.3% accurate, 0.1× 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 2024020 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :herbie-target
  (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))))