Complex division, imag part

Percentage Accurate: 61.5% → 97.8%
Time: 15.9s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 61.5% accurate, 1.0× speedup?

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

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

Alternative 1: 97.8% 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{\frac{-d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\mathsf{hypot}\left(c, d\right)}\right) \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (fma
  (/ c (hypot c d))
  (/ b (hypot c d))
  (/ (/ (- d) (/ (hypot c d) a)) (hypot c d))))
double code(double a, double b, double c, double d) {
	return fma((c / hypot(c, d)), (b / hypot(c, d)), ((-d / (hypot(c, d) / a)) / hypot(c, d)));
}
function code(a, b, c, d)
	return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(Float64(-d) / Float64(hypot(c, d) / a)) / hypot(c, d)))
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[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 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{\frac{-d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\mathsf{hypot}\left(c, d\right)}\right)
\end{array}
Derivation
  1. Initial program 60.9%

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

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

      \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
    3. add-sqr-sqrt57.7%

      \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
    4. times-frac60.8%

      \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
    5. fma-neg60.8%

      \[\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)} \]
    6. hypot-def60.8%

      \[\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) \]
    7. hypot-def73.0%

      \[\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) \]
    8. associate-/l*78.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) \]
    9. add-sqr-sqrt78.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) \]
    10. pow278.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) \]
    11. hypot-def78.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-rr78.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. unpow278.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. add-sqr-sqrt38.4%

      \[\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}{\sqrt{d} \cdot \sqrt{d}}}}\right) \]
    3. hypot-udef38.4%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{\color{blue}{-d}}}\right) \]
    12. associate-/l*51.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 \cdot \left(-d\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}}\right) \]
    13. *-un-lft-identity51.0%

      \[\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 \left(a \cdot \left(-d\right)\right)}}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right) \]
    14. fma-udef51.0%

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

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

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

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

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

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

    \[\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{d \cdot a}{\mathsf{hypot}\left(c, d\right)}}\right) \]
  6. Step-by-step derivation
    1. associate-*l/84.5%

      \[\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{d \cdot a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}}\right) \]
    2. *-lft-identity84.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{d \cdot a}{\mathsf{hypot}\left(c, d\right)}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
    3. associate-/l*98.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{d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
  7. Simplified98.0%

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

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

Alternative 2: 92.4% 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)\\ \mathbf{if}\;d \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.4 \cdot 10^{-163}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-196}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{elif}\;d \leq 5 \cdot 10^{+123}:\\ \;\;\;\;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)))))
   (if (<= d -1.35e+154)
     (/ (- (* c (/ b d)) a) d)
     (if (<= d -1.4e-163)
       t_2
       (if (<= d 3e-196)
         (- (/ b c) (* (/ d c) (/ a c)))
         (if (<= d 5e+123) 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 tmp;
	if (d <= -1.35e+154) {
		tmp = ((c * (b / d)) - a) / d;
	} else if (d <= -1.4e-163) {
		tmp = t_2;
	} else if (d <= 3e-196) {
		tmp = (b / c) - ((d / c) * (a / c));
	} else if (d <= 5e+123) {
		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)))
	tmp = 0.0
	if (d <= -1.35e+154)
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	elseif (d <= -1.4e-163)
		tmp = t_2;
	elseif (d <= 3e-196)
		tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c)));
	elseif (d <= 5e+123)
		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]}, If[LessEqual[d, -1.35e+154], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.4e-163], t$95$2, If[LessEqual[d, 3e-196], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5e+123], 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)\\
\mathbf{if}\;d \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\

\mathbf{elif}\;d \leq -1.4 \cdot 10^{-163}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;d \leq 5 \cdot 10^{+123}:\\
\;\;\;\;t_2\\

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


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

    1. Initial program 25.0%

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

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

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

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg25.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)} \]
      6. hypot-def25.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) \]
      7. hypot-def31.2%

        \[\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) \]
      8. associate-/l*35.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) \]
      9. add-sqr-sqrt35.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) \]
      10. pow235.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) \]
      11. hypot-def35.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-rr35.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 84.4%

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

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

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

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

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

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

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

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

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

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

    if -1.35000000000000003e154 < d < -1.4e-163 or 3e-196 < d < 4.99999999999999974e123

    1. Initial program 71.5%

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac72.9%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg72.9%

        \[\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)} \]
      6. hypot-def72.9%

        \[\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) \]
      7. hypot-def83.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) \]
      8. associate-/l*92.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) \]
      9. add-sqr-sqrt92.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) \]
      10. pow292.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) \]
      11. hypot-def92.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-rr92.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)} \]

    if -1.4e-163 < d < 3e-196

    1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

    if 4.99999999999999974e123 < d

    1. Initial program 47.3%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-commutative47.3%

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

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

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg47.2%

        \[\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)} \]
      6. hypot-def47.2%

        \[\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) \]
      7. hypot-def52.3%

        \[\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) \]
      8. associate-/l*56.2%

        \[\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) \]
      9. add-sqr-sqrt56.2%

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

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

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

      \[\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 100.0%

      \[\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 4 regimes into one program.
  4. Final simplification94.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.4 \cdot 10^{-163}:\\ \;\;\;\;\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}\;d \leq 3 \cdot 10^{-196}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{elif}\;d \leq 5 \cdot 10^{+123}:\\ \;\;\;\;\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: 90.0% accurate, 0.0× speedup?

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

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

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


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

    1. Initial program 26.3%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt16.9%

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

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg26.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)} \]
      6. hypot-def26.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) \]
      7. hypot-def48.5%

        \[\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) \]
      8. associate-/l*65.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) \]
      9. add-sqr-sqrt65.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) \]
      10. pow265.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) \]
      11. hypot-def65.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-rr65.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 73.5%

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

    if -1.99999999999999988e237 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.00000000000000005e301

    1. Initial program 79.0%

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

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

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

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

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

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

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

Alternative 4: 85.1% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -8.2 \cdot 10^{-229}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 7 \cdot 10^{+189}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 38.8%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt38.8%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac38.8%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg38.8%

        \[\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)} \]
      6. hypot-def38.8%

        \[\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) \]
      7. hypot-def42.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) \]
      8. associate-/l*59.2%

        \[\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) \]
      9. add-sqr-sqrt59.2%

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

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

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

      \[\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 85.7%

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

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

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

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

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

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

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

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

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

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

    if -2.20000000000000012e75 < d < -8.1999999999999999e-229 or 9.6000000000000005e-125 < d < 6.99999999999999991e189

    1. Initial program 71.6%

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

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

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac71.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-def71.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-def84.3%

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

      \[\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 -8.1999999999999999e-229 < d < 9.6000000000000005e-125

    1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

    if 6.99999999999999991e189 < d

    1. Initial program 45.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub45.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. *-commutative45.4%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt45.4%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac45.4%

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

        \[\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)} \]
      6. hypot-def45.4%

        \[\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) \]
      7. hypot-def45.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) \]
      8. associate-/l*47.1%

        \[\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) \]
      9. add-sqr-sqrt47.1%

        \[\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) \]
      10. pow247.1%

        \[\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) \]
      11. hypot-def47.1%

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

      \[\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 85.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.2 \cdot 10^{+75}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -8.2 \cdot 10^{-229}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq 9.6 \cdot 10^{-125}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+189}:\\ \;\;\;\;\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{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 5: 85.0% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -9 \cdot 10^{-229}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{t_0}}\\

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

\mathbf{elif}\;d \leq 7 \cdot 10^{+189}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\

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


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

    1. Initial program 38.8%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt38.8%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac38.8%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg38.8%

        \[\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)} \]
      6. hypot-def38.8%

        \[\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) \]
      7. hypot-def42.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) \]
      8. associate-/l*59.2%

        \[\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) \]
      9. add-sqr-sqrt59.2%

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

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

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

      \[\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 85.7%

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

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

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

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

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

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

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

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

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

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

    if -4.0000000000000002e76 < d < -9.0000000000000004e-229

    1. Initial program 71.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot 1}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{b \cdot c - a \cdot d}}} \]
      3. metadata-eval83.6%

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

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

    if -9.0000000000000004e-229 < d < 6.20000000000000026e-125

    1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

    if 6.20000000000000026e-125 < d < 6.99999999999999991e189

    1. Initial program 72.3%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def72.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-def85.0%

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

      \[\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 6.99999999999999991e189 < d

    1. Initial program 45.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub45.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. *-commutative45.4%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt45.4%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac45.4%

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

        \[\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)} \]
      6. hypot-def45.4%

        \[\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) \]
      7. hypot-def45.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) \]
      8. associate-/l*47.1%

        \[\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) \]
      9. add-sqr-sqrt47.1%

        \[\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) \]
      10. pow247.1%

        \[\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) \]
      11. hypot-def47.1%

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

      \[\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 85.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4 \cdot 10^{+76}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -9 \cdot 10^{-229}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c \cdot b - d \cdot a}}\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-125}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+189}:\\ \;\;\;\;\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{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 6: 76.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-88}:\\ \;\;\;\;\frac{c}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{b}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq -5.5 \cdot 10^{-198}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.35 \cdot 10^{-78}:\\ \;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -9e+23)
   (* (/ 1.0 (hypot c d)) (- (/ a (/ c d)) b))
   (if (<= c -1.7e-88)
     (- (/ c (/ (pow (hypot c d) 2.0) b)) (/ a d))
     (if (<= c -5.5e-198)
       (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
       (if (<= c 3.35e-78)
         (- (* (/ b d) (/ c d)) (/ a d))
         (- (/ b c) (* (/ d c) (/ a c))))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -9e+23) {
		tmp = (1.0 / hypot(c, d)) * ((a / (c / d)) - b);
	} else if (c <= -1.7e-88) {
		tmp = (c / (pow(hypot(c, d), 2.0) / b)) - (a / d);
	} else if (c <= -5.5e-198) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (c <= 3.35e-78) {
		tmp = ((b / d) * (c / d)) - (a / d);
	} else {
		tmp = (b / c) - ((d / c) * (a / c));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -9e+23) {
		tmp = (1.0 / Math.hypot(c, d)) * ((a / (c / d)) - b);
	} else if (c <= -1.7e-88) {
		tmp = (c / (Math.pow(Math.hypot(c, d), 2.0) / b)) - (a / d);
	} else if (c <= -5.5e-198) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (c <= 3.35e-78) {
		tmp = ((b / d) * (c / d)) - (a / d);
	} else {
		tmp = (b / c) - ((d / c) * (a / c));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -9e+23:
		tmp = (1.0 / math.hypot(c, d)) * ((a / (c / d)) - b)
	elif c <= -1.7e-88:
		tmp = (c / (math.pow(math.hypot(c, d), 2.0) / b)) - (a / d)
	elif c <= -5.5e-198:
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
	elif c <= 3.35e-78:
		tmp = ((b / d) * (c / d)) - (a / d)
	else:
		tmp = (b / c) - ((d / c) * (a / c))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -9e+23)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(a / Float64(c / d)) - b));
	elseif (c <= -1.7e-88)
		tmp = Float64(Float64(c / Float64((hypot(c, d) ^ 2.0) / b)) - Float64(a / d));
	elseif (c <= -5.5e-198)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 3.35e-78)
		tmp = Float64(Float64(Float64(b / d) * Float64(c / d)) - Float64(a / d));
	else
		tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (c <= -9e+23)
		tmp = (1.0 / hypot(c, d)) * ((a / (c / d)) - b);
	elseif (c <= -1.7e-88)
		tmp = (c / ((hypot(c, d) ^ 2.0) / b)) - (a / d);
	elseif (c <= -5.5e-198)
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	elseif (c <= 3.35e-78)
		tmp = ((b / d) * (c / d)) - (a / d);
	else
		tmp = (b / c) - ((d / c) * (a / c));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -9e+23], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.7e-88], N[(N[(c / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5.5e-198], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.35e-78], N[(N[(N[(b / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.7 \cdot 10^{-88}:\\
\;\;\;\;\frac{c}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{b}} - \frac{a}{d}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if c < -8.99999999999999958e23

    1. Initial program 48.7%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(-1 \cdot b + \frac{a \cdot d}{c}\right)} \]
    5. Step-by-step derivation
      1. neg-mul-171.7%

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

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

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

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

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

    if -8.99999999999999958e23 < c < -1.69999999999999987e-88

    1. Initial program 63.7%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt63.7%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac64.0%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg64.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)} \]
      6. hypot-def64.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) \]
      7. hypot-def64.0%

        \[\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) \]
      8. associate-/l*71.8%

        \[\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) \]
      9. add-sqr-sqrt71.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) \]
      10. pow271.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) \]
      11. hypot-def71.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-rr71.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 93.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) \]
    5. Step-by-step derivation
      1. fma-udef93.6%

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

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

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

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

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

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

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

    if -1.69999999999999987e-88 < c < -5.5000000000000001e-198

    1. Initial program 89.1%

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

    if -5.5000000000000001e-198 < c < 3.34999999999999997e-78

    1. Initial program 63.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub53.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. *-commutative53.2%

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

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

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg52.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)} \]
      6. hypot-def52.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) \]
      7. hypot-def55.3%

        \[\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) \]
      8. associate-/l*64.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) \]
      9. add-sqr-sqrt64.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) \]
      10. pow264.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) \]
      11. hypot-def64.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-rr64.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 89.1%

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

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

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

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

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

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

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

    if 3.34999999999999997e-78 < c

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-88}:\\ \;\;\;\;\frac{c}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{b}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq -5.5 \cdot 10^{-198}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.35 \cdot 10^{-78}:\\ \;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]

Alternative 7: 77.0% accurate, 0.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.1e21

    1. Initial program 48.7%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(-1 \cdot b + \frac{a \cdot d}{c}\right)} \]
    5. Step-by-step derivation
      1. neg-mul-171.7%

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

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

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

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

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

    if -1.1e21 < c < 5.5999999999999998e-81

    1. Initial program 68.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub62.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. *-commutative62.2%

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac62.6%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg62.6%

        \[\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)} \]
      6. hypot-def62.6%

        \[\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) \]
      7. hypot-def64.3%

        \[\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) \]
      8. associate-/l*71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.5999999999999998e-81 < c

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 76.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.3 \cdot 10^{+22} \lor \neg \left(c \leq 5.6 \cdot 10^{-81}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{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 < -1.3e22 or 5.5999999999999998e-81 < c

    1. Initial program 53.4%

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

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

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

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

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

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

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

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

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

    if -1.3e22 < c < 5.5999999999999998e-81

    1. Initial program 68.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub62.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. *-commutative62.2%

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac62.6%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg62.6%

        \[\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)} \]
      6. hypot-def62.6%

        \[\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) \]
      7. hypot-def64.3%

        \[\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) \]
      8. associate-/l*71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 72.8% accurate, 1.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -9.6000000000000003e24 or 3.9999999999999999e-19 < c

    1. Initial program 51.2%

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

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

    if -9.6000000000000003e24 < c < 3.9999999999999999e-19

    1. Initial program 69.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub63.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. *-commutative63.4%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt63.4%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac63.8%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg63.8%

        \[\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)} \]
      6. hypot-def63.8%

        \[\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) \]
      7. hypot-def65.3%

        \[\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) \]
      8. associate-/l*72.5%

        \[\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) \]
      9. add-sqr-sqrt72.5%

        \[\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) \]
      10. pow272.5%

        \[\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) \]
      11. hypot-def72.5%

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

      \[\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 79.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9.6 \cdot 10^{+24}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 4 \cdot 10^{-19}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 10: 63.5% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.7e24 or 3.6000000000000002e-78 < c

    1. Initial program 53.0%

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

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

    if -2.7e24 < c < 3.6000000000000002e-78

    1. Initial program 69.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.7 \cdot 10^{+24}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-78}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 11: 46.6% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.4 \cdot 10^{+158}:\\
\;\;\;\;\frac{a}{d}\\

\mathbf{elif}\;d \leq 9 \cdot 10^{+189}:\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.3999999999999999e158 or 8.99999999999999947e189 < d

    1. Initial program 35.6%

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

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

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

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

        \[\leadsto \frac{\color{blue}{b \cdot c + \left(\left(-a \cdot d\right) + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}}{c \cdot c + d \cdot d} \]
      5. distribute-rgt-neg-in35.6%

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

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

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

        \[\leadsto \frac{b \cdot c + \mathsf{fma}\left(a, -d, \color{blue}{\left(-d\right) \cdot a + a \cdot d}\right)}{c \cdot c + d \cdot d} \]
      9. distribute-lft-neg-in35.6%

        \[\leadsto \frac{b \cdot c + \mathsf{fma}\left(a, -d, \color{blue}{\left(-d \cdot a\right)} + a \cdot d\right)}{c \cdot c + d \cdot d} \]
      10. *-commutative35.6%

        \[\leadsto \frac{b \cdot c + \mathsf{fma}\left(a, -d, \left(-\color{blue}{a \cdot d}\right) + a \cdot d\right)}{c \cdot c + d \cdot d} \]
      11. distribute-rgt-neg-in35.6%

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

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

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

      \[\leadsto \color{blue}{\frac{-2 \cdot \left(a \cdot d\right) + a \cdot d}{{d}^{2}}} \]
    5. Step-by-step derivation
      1. distribute-lft1-in35.6%

        \[\leadsto \frac{\color{blue}{\left(-2 + 1\right) \cdot \left(a \cdot d\right)}}{{d}^{2}} \]
      2. metadata-eval35.6%

        \[\leadsto \frac{\color{blue}{-1} \cdot \left(a \cdot d\right)}{{d}^{2}} \]
      3. *-commutative35.6%

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

        \[\leadsto \frac{\color{blue}{-d \cdot a}}{{d}^{2}} \]
      5. distribute-rgt-neg-in35.6%

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

        \[\leadsto \frac{d \cdot \left(-a\right)}{\color{blue}{d \cdot d}} \]
    6. Simplified35.6%

      \[\leadsto \color{blue}{\frac{d \cdot \left(-a\right)}{d \cdot d}} \]
    7. Step-by-step derivation
      1. times-frac93.8%

        \[\leadsto \color{blue}{\frac{d}{d} \cdot \frac{-a}{d}} \]
      2. distribute-neg-frac93.8%

        \[\leadsto \frac{d}{d} \cdot \color{blue}{\left(-\frac{a}{d}\right)} \]
      3. *-inverses93.8%

        \[\leadsto \color{blue}{1} \cdot \left(-\frac{a}{d}\right) \]
      4. *-un-lft-identity93.8%

        \[\leadsto \color{blue}{-\frac{a}{d}} \]
      5. add-sqr-sqrt67.9%

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

        \[\leadsto \color{blue}{\sqrt{\left(-\frac{a}{d}\right) \cdot \left(-\frac{a}{d}\right)}} \]
      7. sqr-neg59.5%

        \[\leadsto \sqrt{\color{blue}{\frac{a}{d} \cdot \frac{a}{d}}} \]
      8. sqrt-unprod35.3%

        \[\leadsto \color{blue}{\sqrt{\frac{a}{d}} \cdot \sqrt{\frac{a}{d}}} \]
      9. add-sqr-sqrt36.4%

        \[\leadsto \color{blue}{\frac{a}{d}} \]
      10. clear-num36.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{d}{a}}} \]
      11. inv-pow36.4%

        \[\leadsto \color{blue}{{\left(\frac{d}{a}\right)}^{-1}} \]
    8. Applied egg-rr36.4%

      \[\leadsto \color{blue}{{\left(\frac{d}{a}\right)}^{-1}} \]
    9. Step-by-step derivation
      1. unpow-136.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{d}{a}}} \]
    10. Simplified36.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{d}{a}}} \]
    11. Taylor expanded in d around 0 36.4%

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

    if -3.3999999999999999e158 < d < 8.99999999999999947e189

    1. Initial program 67.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.4 \cdot 10^{+158}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{elif}\;d \leq 9 \cdot 10^{+189}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{d}\\ \end{array} \]

Alternative 12: 10.8% accurate, 5.0× speedup?

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

\\
\frac{a}{d}
\end{array}
Derivation
  1. Initial program 60.9%

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

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

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

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

      \[\leadsto \frac{\color{blue}{b \cdot c + \left(\left(-a \cdot d\right) + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}}{c \cdot c + d \cdot d} \]
    5. distribute-rgt-neg-in60.7%

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

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

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

      \[\leadsto \frac{b \cdot c + \mathsf{fma}\left(a, -d, \color{blue}{\left(-d\right) \cdot a + a \cdot d}\right)}{c \cdot c + d \cdot d} \]
    9. distribute-lft-neg-in60.7%

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

      \[\leadsto \frac{b \cdot c + \mathsf{fma}\left(a, -d, \left(-\color{blue}{a \cdot d}\right) + a \cdot d\right)}{c \cdot c + d \cdot d} \]
    11. distribute-rgt-neg-in60.7%

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

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

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

    \[\leadsto \color{blue}{\frac{-2 \cdot \left(a \cdot d\right) + a \cdot d}{{d}^{2}}} \]
  5. Step-by-step derivation
    1. distribute-lft1-in28.3%

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

      \[\leadsto \frac{\color{blue}{-1} \cdot \left(a \cdot d\right)}{{d}^{2}} \]
    3. *-commutative28.3%

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

      \[\leadsto \frac{\color{blue}{-d \cdot a}}{{d}^{2}} \]
    5. distribute-rgt-neg-in28.3%

      \[\leadsto \frac{\color{blue}{d \cdot \left(-a\right)}}{{d}^{2}} \]
    6. unpow228.3%

      \[\leadsto \frac{d \cdot \left(-a\right)}{\color{blue}{d \cdot d}} \]
  6. Simplified28.3%

    \[\leadsto \color{blue}{\frac{d \cdot \left(-a\right)}{d \cdot d}} \]
  7. Step-by-step derivation
    1. times-frac45.2%

      \[\leadsto \color{blue}{\frac{d}{d} \cdot \frac{-a}{d}} \]
    2. distribute-neg-frac45.2%

      \[\leadsto \frac{d}{d} \cdot \color{blue}{\left(-\frac{a}{d}\right)} \]
    3. *-inverses45.2%

      \[\leadsto \color{blue}{1} \cdot \left(-\frac{a}{d}\right) \]
    4. *-un-lft-identity45.2%

      \[\leadsto \color{blue}{-\frac{a}{d}} \]
    5. add-sqr-sqrt26.9%

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

      \[\leadsto \color{blue}{\sqrt{\left(-\frac{a}{d}\right) \cdot \left(-\frac{a}{d}\right)}} \]
    7. sqr-neg23.5%

      \[\leadsto \sqrt{\color{blue}{\frac{a}{d} \cdot \frac{a}{d}}} \]
    8. sqrt-unprod9.2%

      \[\leadsto \color{blue}{\sqrt{\frac{a}{d}} \cdot \sqrt{\frac{a}{d}}} \]
    9. add-sqr-sqrt10.3%

      \[\leadsto \color{blue}{\frac{a}{d}} \]
    10. clear-num10.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{d}{a}}} \]
    11. inv-pow10.3%

      \[\leadsto \color{blue}{{\left(\frac{d}{a}\right)}^{-1}} \]
  8. Applied egg-rr10.3%

    \[\leadsto \color{blue}{{\left(\frac{d}{a}\right)}^{-1}} \]
  9. Step-by-step derivation
    1. unpow-110.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{d}{a}}} \]
  10. Simplified10.3%

    \[\leadsto \color{blue}{\frac{1}{\frac{d}{a}}} \]
  11. Taylor expanded in d around 0 10.3%

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  12. Final simplification10.3%

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

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