Complex division, imag part

Percentage Accurate: 61.7% → 97.6%
Time: 14.3s
Alternatives: 14
Speedup: 1.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 61.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: 97.6% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-\frac{a}{\mathsf{hypot}\left(d, c\right)}\right)}{\mathsf{hypot}\left(d, c\right)}\right) \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (fma
  (/ c (hypot c d))
  (/ b (hypot c d))
  (/ (* d (- (/ a (hypot d c)))) (hypot d c))))
double code(double a, double b, double c, double d) {
	return fma((c / hypot(c, d)), (b / hypot(c, d)), ((d * -(a / hypot(d, c))) / hypot(d, c)));
}
function code(a, b, c, d)
	return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(d * Float64(-Float64(a / hypot(d, c)))) / hypot(d, c)))
end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(d * (-N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision])), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-\frac{a}{\mathsf{hypot}\left(d, c\right)}\right)}{\mathsf{hypot}\left(d, c\right)}\right)
\end{array}
Derivation
  1. Initial program 58.8%

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Step-by-step derivation
    1. div-sub56.4%

      \[\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-neg56.4%

      \[\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. *-commutative56.4%

      \[\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-sqrt56.4%

      \[\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-frac59.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-def59.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-def59.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-def69.1%

      \[\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*73.9%

      \[\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-sqrt73.9%

      \[\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. pow273.9%

      \[\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-def73.9%

      \[\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) \]
  3. Applied egg-rr73.9%

    \[\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)} \]
  4. Step-by-step derivation
    1. unpow273.9%

      \[\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}{\mathsf{hypot}\left(c, d\right) \cdot \mathsf{hypot}\left(c, d\right)}}{d}}\right) \]
    2. *-un-lft-identity73.9%

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

      \[\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{\mathsf{hypot}\left(c, d\right)}{1} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}}\right) \]
  5. Applied egg-rr94.4%

    \[\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{\mathsf{hypot}\left(c, d\right)}{1} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}}\right) \]
  6. Step-by-step derivation
    1. /-rgt-identity94.4%

      \[\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{hypot}\left(c, d\right)} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}\right) \]
    2. *-un-lft-identity94.4%

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{\frac{1 \cdot \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}}{\mathsf{hypot}\left(c, d\right)}}\right) \]
    2. *-lft-identity97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 89.6% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := \mathsf{fma}\left(t_0, t_1, \frac{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\
t_3 := c \cdot b - d \cdot a\\
t_4 := \frac{t_3}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_4 \leq -4 \cdot 10^{+291}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_4 \leq 2 \cdot 10^{+142}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_3}{\mathsf{hypot}\left(c, d\right)}\\

\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;t_2\\

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


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

    1. Initial program 58.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub45.5%

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

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

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

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

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

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

        \[\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-def69.9%

        \[\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*94.0%

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

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

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

        \[\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) \]
    3. Applied egg-rr94.0%

      \[\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)} \]

    if -3.9999999999999998e291 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.0000000000000001e142

    1. Initial program 79.5%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt79.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-frac79.6%

        \[\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-def79.6%

        \[\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.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)}} \]
    3. Applied egg-rr99.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 +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 0.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub0.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-neg0.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. *-commutative0.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-sqrt0.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-frac1.0%

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

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

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

        \[\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*34.0%

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

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

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

        \[\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) \]
    3. Applied egg-rr34.0%

      \[\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)} \]
    4. Taylor expanded in c around 0 75.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq -4 \cdot 10^{+291}:\\ \;\;\;\;\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)\\ \mathbf{elif}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+142}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq \infty:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\ \end{array} \]

Alternative 3: 89.7% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := c \cdot b - d \cdot a\\ t_2 := \frac{t_1}{c \cdot c + d \cdot d}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_0 \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{d}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{a}}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+252}:\\ \;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ 1.0 (hypot c d)))
        (t_1 (- (* c b) (* d a)))
        (t_2 (/ t_1 (+ (* c c) (* d d)))))
   (if (<= t_2 (- INFINITY))
     (- (* t_0 (/ c (/ (hypot c d) b))) (/ d (/ (pow (hypot c d) 2.0) a)))
     (if (<= t_2 2e+252)
       (* t_0 (/ t_1 (hypot c d)))
       (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d))))))
double code(double a, double b, double c, double d) {
	double t_0 = 1.0 / hypot(c, d);
	double t_1 = (c * b) - (d * a);
	double t_2 = t_1 / ((c * c) + (d * d));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = (t_0 * (c / (hypot(c, d) / b))) - (d / (pow(hypot(c, d), 2.0) / a));
	} else if (t_2 <= 2e+252) {
		tmp = t_0 * (t_1 / hypot(c, d));
	} else {
		tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(1.0 / hypot(c, d))
	t_1 = Float64(Float64(c * b) - Float64(d * a))
	t_2 = Float64(t_1 / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(Float64(t_0 * Float64(c / Float64(hypot(c, d) / b))) - Float64(d / Float64((hypot(c, d) ^ 2.0) / a)));
	elseif (t_2 <= 2e+252)
		tmp = Float64(t_0 * Float64(t_1 / hypot(c, d)));
	else
		tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d));
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(t$95$0 * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+252], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $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) / d), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+252}:\\
\;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\

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


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

    1. Initial program 45.5%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub16.5%

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

        \[\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. *-un-lft-identity16.5%

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

        \[\leadsto \frac{1 \cdot \left(b \cdot c\right)}{\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-frac16.5%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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. pow266.0%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-def66.0%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 81.0%

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

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

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

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

        \[\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.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)}} \]
    3. Applied egg-rr99.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 2.0000000000000002e252 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 12.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub10.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-neg10.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. *-commutative10.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-sqrt10.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-frac18.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-def18.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-def18.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-def37.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*51.9%

        \[\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-sqrt51.9%

        \[\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. pow251.9%

        \[\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-def51.9%

        \[\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) \]
    3. Applied egg-rr51.9%

      \[\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)} \]
    4. Taylor expanded in c around 0 76.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}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq -\infty:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{d}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{a}}\\ \mathbf{elif}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+252}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\ \end{array} \]

Alternative 4: 88.9% accurate, 0.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{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))) < 2.0000000000000002e252

    1. Initial program 78.2%

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

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

        \[\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-frac78.3%

        \[\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-def78.3%

        \[\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-def95.9%

        \[\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)}} \]
    3. Applied egg-rr95.9%

      \[\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 2.0000000000000002e252 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 12.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub10.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-neg10.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. *-commutative10.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-sqrt10.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-frac18.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-def18.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-def18.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-def37.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*51.9%

        \[\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-sqrt51.9%

        \[\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. pow251.9%

        \[\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-def51.9%

        \[\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) \]
    3. Applied egg-rr51.9%

      \[\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)} \]
    4. Taylor expanded in c around 0 76.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}}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.0%

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

Alternative 5: 85.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ \mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+252}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))))
   (if (<= (/ t_0 (+ (* c c) (* d d))) 2e+252)
     (* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
     (/ (- (* c (/ b d)) a) d))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if ((t_0 / ((c * c) + (d * d))) <= 2e+252) {
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	} else {
		tmp = ((c * (b / d)) - a) / d;
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if ((t_0 / ((c * c) + (d * d))) <= 2e+252) {
		tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
	} else {
		tmp = ((c * (b / d)) - a) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	tmp = 0
	if (t_0 / ((c * c) + (d * d))) <= 2e+252:
		tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d))
	else:
		tmp = ((c * (b / d)) - a) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 2e+252)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d)));
	else
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	tmp = 0.0;
	if ((t_0 / ((c * c) + (d * d))) <= 2e+252)
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	else
		tmp = ((c * (b / d)) - a) / d;
	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[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+252], 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[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\


\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))) < 2.0000000000000002e252

    1. Initial program 78.2%

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

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

        \[\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-frac78.3%

        \[\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-def78.3%

        \[\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-def95.9%

        \[\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)}} \]
    3. Applied egg-rr95.9%

      \[\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 2.0000000000000002e252 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 12.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c}{d}} - \frac{a}{d} \]
      2. sub-div65.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+252}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]

Alternative 6: 79.2% accurate, 0.1× speedup?

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

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

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

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

\mathbf{elif}\;d \leq 1.2 \cdot 10^{+54}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{t_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -4.70000000000000007e88

    1. Initial program 30.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{d} \cdot b}{d}} \cdot c - \frac{a}{d} \]
    8. Simplified82.6%

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

    if -4.70000000000000007e88 < d < -6e-95

    1. Initial program 87.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. sub-neg87.4%

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

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

        \[\leadsto \frac{\left(-\color{blue}{d \cdot a}\right) + b \cdot c}{c \cdot c + d \cdot d} \]
      4. distribute-lft-neg-in87.4%

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

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

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

    if -6e-95 < d < 1.80000000000000003e-137

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

    if 1.80000000000000003e-137 < d < 1.19999999999999999e54

    1. Initial program 89.0%

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

    if 1.19999999999999999e54 < d

    1. Initial program 35.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c} - \frac{a}{d} \]
    4. Simplified80.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c}{d}} - \frac{a}{d} \]
      2. sub-div88.0%

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c - a}{d}} \]
    10. Applied egg-rr88.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.7 \cdot 10^{+88}:\\ \;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -6 \cdot 10^{-95}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{-137}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{a}{{c}^{2}}\\ \mathbf{elif}\;d \leq 1.2 \cdot 10^{+54}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]

Alternative 7: 80.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -6.1 \cdot 10^{+88}:\\ \;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -6.8 \cdot 10^{-96}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{-130}:\\ \;\;\;\;\frac{b}{c} - a \cdot \frac{d}{{c}^{2}}\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{+54}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -6.1e+88)
     (- (* c (/ (* b (/ 1.0 d)) d)) (/ a d))
     (if (<= d -6.8e-96)
       t_0
       (if (<= d 1.5e-130)
         (- (/ b c) (* a (/ d (pow c 2.0))))
         (if (<= d 1.45e+54) t_0 (/ (- (* c (/ b d)) a) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -6.1e+88) {
		tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
	} else if (d <= -6.8e-96) {
		tmp = t_0;
	} else if (d <= 1.5e-130) {
		tmp = (b / c) - (a * (d / pow(c, 2.0)));
	} else if (d <= 1.45e+54) {
		tmp = t_0;
	} else {
		tmp = ((c * (b / d)) - a) / d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    if (d <= (-6.1d+88)) then
        tmp = (c * ((b * (1.0d0 / d)) / d)) - (a / d)
    else if (d <= (-6.8d-96)) then
        tmp = t_0
    else if (d <= 1.5d-130) then
        tmp = (b / c) - (a * (d / (c ** 2.0d0)))
    else if (d <= 1.45d+54) then
        tmp = t_0
    else
        tmp = ((c * (b / d)) - a) / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -6.1e+88) {
		tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
	} else if (d <= -6.8e-96) {
		tmp = t_0;
	} else if (d <= 1.5e-130) {
		tmp = (b / c) - (a * (d / Math.pow(c, 2.0)));
	} else if (d <= 1.45e+54) {
		tmp = t_0;
	} else {
		tmp = ((c * (b / d)) - a) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -6.1e+88:
		tmp = (c * ((b * (1.0 / d)) / d)) - (a / d)
	elif d <= -6.8e-96:
		tmp = t_0
	elif d <= 1.5e-130:
		tmp = (b / c) - (a * (d / math.pow(c, 2.0)))
	elif d <= 1.45e+54:
		tmp = t_0
	else:
		tmp = ((c * (b / d)) - a) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -6.1e+88)
		tmp = Float64(Float64(c * Float64(Float64(b * Float64(1.0 / d)) / d)) - Float64(a / d));
	elseif (d <= -6.8e-96)
		tmp = t_0;
	elseif (d <= 1.5e-130)
		tmp = Float64(Float64(b / c) - Float64(a * Float64(d / (c ^ 2.0))));
	elseif (d <= 1.45e+54)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -6.1e+88)
		tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
	elseif (d <= -6.8e-96)
		tmp = t_0;
	elseif (d <= 1.5e-130)
		tmp = (b / c) - (a * (d / (c ^ 2.0)));
	elseif (d <= 1.45e+54)
		tmp = t_0;
	else
		tmp = ((c * (b / d)) - a) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.1e+88], N[(N[(c * N[(N[(b * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6.8e-96], t$95$0, If[LessEqual[d, 1.5e-130], N[(N[(b / c), $MachinePrecision] - N[(a * N[(d / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.45e+54], t$95$0, N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -6.8 \cdot 10^{-96}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 1.45 \cdot 10^{+54}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -6.0999999999999998e88

    1. Initial program 30.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{d} \cdot b}{d}} \cdot c - \frac{a}{d} \]
    8. Simplified82.6%

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

    if -6.0999999999999998e88 < d < -6.8000000000000002e-96 or 1.49999999999999993e-130 < d < 1.4499999999999999e54

    1. Initial program 88.2%

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

    if -6.8000000000000002e-96 < d < 1.49999999999999993e-130

    1. Initial program 67.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub58.5%

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

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

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

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

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

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

        \[\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-def88.6%

        \[\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*87.6%

        \[\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-sqrt87.6%

        \[\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. pow287.6%

        \[\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-def87.6%

        \[\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) \]
    3. Applied egg-rr87.6%

      \[\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)} \]
    4. Step-by-step derivation
      1. unpow287.6%

        \[\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}{\mathsf{hypot}\left(c, d\right) \cdot \mathsf{hypot}\left(c, d\right)}}{d}}\right) \]
      2. *-un-lft-identity87.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{\mathsf{hypot}\left(c, d\right) \cdot \mathsf{hypot}\left(c, d\right)}{\color{blue}{1 \cdot d}}}\right) \]
      3. times-frac93.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}{\frac{\mathsf{hypot}\left(c, d\right)}{1} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}}\right) \]
    5. Applied egg-rr93.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}{\frac{\mathsf{hypot}\left(c, d\right)}{1} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}}\right) \]
    6. Step-by-step derivation
      1. /-rgt-identity93.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{hypot}\left(c, d\right)} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}\right) \]
      2. *-un-lft-identity93.1%

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{\frac{1 \cdot \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}}{\mathsf{hypot}\left(c, d\right)}}\right) \]
      2. *-lft-identity95.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} + \left(-\frac{\color{blue}{d \cdot a}}{{c}^{2}}\right) \]
      4. associate-*l/84.8%

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{d}{{c}^{2}} \cdot a} \]
      6. *-commutative84.8%

        \[\leadsto \frac{b}{c} - \color{blue}{a \cdot \frac{d}{{c}^{2}}} \]
    12. Simplified84.8%

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

    if 1.4499999999999999e54 < d

    1. Initial program 35.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c} - \frac{a}{d} \]
    4. Simplified80.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c}{d}} - \frac{a}{d} \]
      2. sub-div88.0%

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c - a}{d}} \]
    10. Applied egg-rr88.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.1 \cdot 10^{+88}:\\ \;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -6.8 \cdot 10^{-96}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{-130}:\\ \;\;\;\;\frac{b}{c} - a \cdot \frac{d}{{c}^{2}}\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{+54}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]

Alternative 8: 79.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -1.45 \cdot 10^{+89}:\\ \;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -2.8 \cdot 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-138}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{a}{{c}^{2}}\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{+54}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -1.45e+89)
     (- (* c (/ (* b (/ 1.0 d)) d)) (/ a d))
     (if (<= d -2.8e-105)
       t_0
       (if (<= d 3.8e-138)
         (- (/ b c) (* d (/ a (pow c 2.0))))
         (if (<= d 1.45e+54) t_0 (/ (- (* c (/ b d)) a) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -1.45e+89) {
		tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
	} else if (d <= -2.8e-105) {
		tmp = t_0;
	} else if (d <= 3.8e-138) {
		tmp = (b / c) - (d * (a / pow(c, 2.0)));
	} else if (d <= 1.45e+54) {
		tmp = t_0;
	} else {
		tmp = ((c * (b / d)) - a) / d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    if (d <= (-1.45d+89)) then
        tmp = (c * ((b * (1.0d0 / d)) / d)) - (a / d)
    else if (d <= (-2.8d-105)) then
        tmp = t_0
    else if (d <= 3.8d-138) then
        tmp = (b / c) - (d * (a / (c ** 2.0d0)))
    else if (d <= 1.45d+54) then
        tmp = t_0
    else
        tmp = ((c * (b / d)) - a) / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -1.45e+89) {
		tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
	} else if (d <= -2.8e-105) {
		tmp = t_0;
	} else if (d <= 3.8e-138) {
		tmp = (b / c) - (d * (a / Math.pow(c, 2.0)));
	} else if (d <= 1.45e+54) {
		tmp = t_0;
	} else {
		tmp = ((c * (b / d)) - a) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -1.45e+89:
		tmp = (c * ((b * (1.0 / d)) / d)) - (a / d)
	elif d <= -2.8e-105:
		tmp = t_0
	elif d <= 3.8e-138:
		tmp = (b / c) - (d * (a / math.pow(c, 2.0)))
	elif d <= 1.45e+54:
		tmp = t_0
	else:
		tmp = ((c * (b / d)) - a) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -1.45e+89)
		tmp = Float64(Float64(c * Float64(Float64(b * Float64(1.0 / d)) / d)) - Float64(a / d));
	elseif (d <= -2.8e-105)
		tmp = t_0;
	elseif (d <= 3.8e-138)
		tmp = Float64(Float64(b / c) - Float64(d * Float64(a / (c ^ 2.0))));
	elseif (d <= 1.45e+54)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -1.45e+89)
		tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
	elseif (d <= -2.8e-105)
		tmp = t_0;
	elseif (d <= 3.8e-138)
		tmp = (b / c) - (d * (a / (c ^ 2.0)));
	elseif (d <= 1.45e+54)
		tmp = t_0;
	else
		tmp = ((c * (b / d)) - a) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.45e+89], N[(N[(c * N[(N[(b * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.8e-105], t$95$0, If[LessEqual[d, 3.8e-138], N[(N[(b / c), $MachinePrecision] - N[(d * N[(a / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.45e+54], t$95$0, N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -2.8 \cdot 10^{-105}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 1.45 \cdot 10^{+54}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.45000000000000013e89

    1. Initial program 30.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{d} \cdot b}{d}} \cdot c - \frac{a}{d} \]
    8. Simplified82.6%

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

    if -1.45000000000000013e89 < d < -2.8e-105 or 3.8000000000000002e-138 < d < 1.4499999999999999e54

    1. Initial program 88.2%

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

    if -2.8e-105 < d < 3.8000000000000002e-138

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

    if 1.4499999999999999e54 < d

    1. Initial program 35.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c} - \frac{a}{d} \]
    4. Simplified80.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c}{d}} - \frac{a}{d} \]
      2. sub-div88.0%

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c - a}{d}} \]
    10. Applied egg-rr88.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.45 \cdot 10^{+89}:\\ \;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -2.8 \cdot 10^{-105}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-138}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{a}{{c}^{2}}\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{+54}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]

Alternative 9: 78.0% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq -1 \cdot 10^{-92}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 6.1 \cdot 10^{+53}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.6000000000000002e88

    1. Initial program 30.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{d} \cdot b}{d}} \cdot c - \frac{a}{d} \]
    8. Simplified82.6%

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

    if -3.6000000000000002e88 < d < -9.99999999999999988e-93 or 2.6999999999999999e-170 < d < 6.1000000000000002e53

    1. Initial program 87.8%

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

    if -9.99999999999999988e-93 < d < 2.6999999999999999e-170

    1. Initial program 65.9%

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

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

    if 6.1000000000000002e53 < d

    1. Initial program 35.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c} - \frac{a}{d} \]
    4. Simplified80.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c}{d}} - \frac{a}{d} \]
      2. sub-div88.0%

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c - a}{d}} \]
    10. Applied egg-rr88.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.6 \cdot 10^{+88}:\\ \;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-92}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{-170}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 6.1 \cdot 10^{+53}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]

Alternative 10: 71.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.45 \cdot 10^{+23} \lor \neg \left(c \leq 4.7 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{b}{c}\\

\mathbf{else}:\\
\;\;\;\;b \cdot \frac{\frac{c}{d}}{d} - \frac{a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.45000000000000006e23 or 4.7e14 < c

    1. Initial program 51.6%

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

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

    if -1.45000000000000006e23 < c < 4.7e14

    1. Initial program 64.5%

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

        \[\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-neg60.2%

        \[\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. *-commutative60.2%

        \[\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-sqrt60.2%

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

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

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

        \[\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-def59.9%

        \[\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*66.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-sqrt66.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. pow266.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-def66.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) \]
    3. Applied egg-rr66.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)} \]
    4. Taylor expanded in c around 0 82.6%

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. *-commutative82.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{c}{d}}}{d} \cdot b - \frac{a}{d} \]
    10. Simplified84.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.45 \cdot 10^{+23} \lor \neg \left(c \leq 4.7 \cdot 10^{+14}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{\frac{c}{d}}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 11: 72.2% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -8.5 \cdot 10^{+22} \lor \neg \left(c \leq 2.8 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{b}{c}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -8.49999999999999979e22 or 2.8e14 < c

    1. Initial program 51.6%

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

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

    if -8.49999999999999979e22 < c < 2.8e14

    1. Initial program 64.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c}{d}} - \frac{a}{d} \]
      2. sub-div83.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.5 \cdot 10^{+22} \lor \neg \left(c \leq 2.8 \cdot 10^{+14}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]

Alternative 12: 63.3% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1.5 \cdot 10^{-63} \lor \neg \left(d \leq 1.05 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= d -1.5e-63) (not (<= d 1.05e-11))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -1.5e-63) || !(d <= 1.05e-11)) {
		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 ((d <= (-1.5d-63)) .or. (.not. (d <= 1.05d-11))) 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 ((d <= -1.5e-63) || !(d <= 1.05e-11)) {
		tmp = -a / d;
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -1.5e-63) or not (d <= 1.05e-11):
		tmp = -a / d
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -1.5e-63) || !(d <= 1.05e-11))
		tmp = Float64(Float64(-a) / d);
	else
		tmp = Float64(b / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((d <= -1.5e-63) || ~((d <= 1.05e-11)))
		tmp = -a / d;
	else
		tmp = b / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.5e-63], N[Not[LessEqual[d, 1.05e-11]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.5 \cdot 10^{-63} \lor \neg \left(d \leq 1.05 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.4999999999999999e-63 or 1.0499999999999999e-11 < d

    1. Initial program 48.8%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified68.3%

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

    if -1.4999999999999999e-63 < d < 1.0499999999999999e-11

    1. Initial program 74.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.5 \cdot 10^{-63} \lor \neg \left(d \leq 1.05 \cdot 10^{-11}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 13: 9.9% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \frac{a}{c} \end{array} \]
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
	return a / 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 = a / c
end function
public static double code(double a, double b, double c, double d) {
	return a / c;
}
def code(a, b, c, d):
	return a / c
function code(a, b, c, d)
	return Float64(a / c)
end
function tmp = code(a, b, c, d)
	tmp = a / c;
end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}

\\
\frac{a}{c}
\end{array}
Derivation
  1. Initial program 58.8%

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

    \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2} + {d}^{2}}} \]
  3. Step-by-step derivation
    1. associate-*r/38.1%

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

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

      \[\leadsto \frac{\color{blue}{\left(-a\right)} \cdot d}{{c}^{2} + {d}^{2}} \]
    4. *-commutative38.1%

      \[\leadsto \frac{\color{blue}{d \cdot \left(-a\right)}}{{c}^{2} + {d}^{2}} \]
    5. associate-/l*40.2%

      \[\leadsto \color{blue}{\frac{d}{\frac{{c}^{2} + {d}^{2}}{-a}}} \]
    6. +-commutative40.2%

      \[\leadsto \frac{d}{\frac{\color{blue}{{d}^{2} + {c}^{2}}}{-a}} \]
    7. unpow240.2%

      \[\leadsto \frac{d}{\frac{\color{blue}{d \cdot d} + {c}^{2}}{-a}} \]
    8. fma-udef40.2%

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

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

      \[\leadsto \frac{d}{\frac{\color{blue}{d \cdot d + {c}^{2}}}{-a}} \]
    2. +-commutative40.2%

      \[\leadsto \frac{d}{\frac{\color{blue}{{c}^{2} + d \cdot d}}{-a}} \]
    3. add-sqr-sqrt40.2%

      \[\leadsto \frac{d}{\frac{\color{blue}{\sqrt{{c}^{2} + d \cdot d} \cdot \sqrt{{c}^{2} + d \cdot d}}}{-a}} \]
    4. pow240.2%

      \[\leadsto \frac{d}{\frac{\sqrt{\color{blue}{c \cdot c} + d \cdot d} \cdot \sqrt{{c}^{2} + d \cdot d}}{-a}} \]
    5. hypot-udef40.2%

      \[\leadsto \frac{d}{\frac{\color{blue}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{{c}^{2} + d \cdot d}}{-a}} \]
    6. pow240.2%

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

      \[\leadsto \frac{d}{\frac{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}}{-a}} \]
    8. neg-mul-140.2%

      \[\leadsto \frac{d}{\frac{\mathsf{hypot}\left(c, d\right) \cdot \mathsf{hypot}\left(c, d\right)}{\color{blue}{-1 \cdot a}}} \]
    9. times-frac49.2%

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

    \[\leadsto \frac{d}{\color{blue}{\frac{\mathsf{hypot}\left(c, d\right)}{-1} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{a}}} \]
  7. Taylor expanded in d around -inf 29.0%

    \[\leadsto \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{-1} \cdot \color{blue}{\left(-1 \cdot \frac{d}{a}\right)}} \]
  8. Step-by-step derivation
    1. associate-*r/29.0%

      \[\leadsto \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{-1} \cdot \color{blue}{\frac{-1 \cdot d}{a}}} \]
    2. neg-mul-129.0%

      \[\leadsto \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{-1} \cdot \frac{\color{blue}{-d}}{a}} \]
  9. Simplified29.0%

    \[\leadsto \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{-1} \cdot \color{blue}{\frac{-d}{a}}} \]
  10. Taylor expanded in d around 0 10.5%

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  11. Final simplification10.5%

    \[\leadsto \frac{a}{c} \]

Alternative 14: 42.5% 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 58.8%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Final simplification36.1%

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

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 2023315 
(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))))