Complex division, imag part

Percentage Accurate: 62.3% → 87.8%
Time: 14.2s
Alternatives: 14
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 62.3% 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: 87.8% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq -2.35 \cdot 10^{-151}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 1.14 \cdot 10^{+167}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 36.6%

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Step-by-step derivation
      1. *-commutative61.7%

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

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

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

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

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

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

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

    if -3.5000000000000001e137 < d < -2.35000000000000014e-151 or 8.5999999999999999e-214 < d < 1.13999999999999995e167

    1. Initial program 75.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      11. hypot-def94.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) \]
      12. fma-def94.4%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\frac{a \cdot d}{\color{blue}{{\left(\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}\right)}^{2}}}\right) \]
    4. Applied egg-rr94.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 \cdot d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]

    if -2.35000000000000014e-151 < d < 8.5999999999999999e-214

    1. Initial program 73.4%

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      2. *-un-lft-identity73.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.13999999999999995e167 < d

    1. Initial program 12.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      8. hypot-def48.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)}} \]
    4. Applied egg-rr48.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)}} \]
    5. Step-by-step derivation
      1. *-commutative48.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.5 \cdot 10^{+137}:\\ \;\;\;\;\frac{a - \frac{b \cdot c}{d}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -2.35 \cdot 10^{-151}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-a\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \mathbf{elif}\;d \leq 8.6 \cdot 10^{-214}:\\ \;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \mathbf{elif}\;d \leq 1.14 \cdot 10^{+167}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-a\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 85.9% accurate, 0.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{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.00000000000000007e260

    1. Initial program 78.9%

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      2. *-un-lft-identity78.9%

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Step-by-step derivation
      1. *-commutative96.8%

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

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

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

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

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

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

    if 1.00000000000000007e260 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 14.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 85.8% accurate, 0.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{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.00000000000000007e260

    1. Initial program 78.9%

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      2. *-un-lft-identity78.9%

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

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

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

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

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

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

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

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

    1. Initial program 14.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 79.3% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -4.3 \cdot 10^{-151}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\

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

\mathbf{elif}\;d \leq 1.9 \cdot 10^{+166}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

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


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

    1. Initial program 36.6%

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Step-by-step derivation
      1. *-commutative61.7%

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

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

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

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

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

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

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

    if -1.44e119 < d < -4.30000000000000018e-151

    1. Initial program 81.3%

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

    if -4.30000000000000018e-151 < d < 3.30000000000000029e23

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.30000000000000029e23 < d < 1.90000000000000003e166

    1. Initial program 81.0%

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

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

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

    if 1.90000000000000003e166 < d

    1. Initial program 12.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      8. hypot-def48.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)}} \]
    4. Applied egg-rr48.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)}} \]
    5. Step-by-step derivation
      1. *-commutative48.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.44 \cdot 10^{+119}:\\ \;\;\;\;\frac{a - \frac{b \cdot c}{d}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -4.3 \cdot 10^{-151}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{+166}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 80.2% accurate, 0.1× speedup?

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

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

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

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

\mathbf{elif}\;d \leq 1.9 \cdot 10^{+166}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 36.6%

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Step-by-step derivation
      1. *-commutative61.7%

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

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

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

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

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

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

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

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

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

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

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

    if -6.00000000000000002e119 < d < -6.8000000000000005e-151 or 3.30000000000000029e23 < d < 1.90000000000000003e166

    1. Initial program 81.2%

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

    if -6.8000000000000005e-151 < d < 3.30000000000000029e23

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.90000000000000003e166 < d

    1. Initial program 12.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      8. hypot-def48.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)}} \]
    4. Applied egg-rr48.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)}} \]
    5. Step-by-step derivation
      1. *-commutative48.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6 \cdot 10^{+119}:\\ \;\;\;\;\frac{a - \frac{b}{\frac{d}{c}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -6.8 \cdot 10^{-151}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{+166}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 79.4% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -9.5 \cdot 10^{-150}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 1.9 \cdot 10^{+166}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 36.6%

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Step-by-step derivation
      1. *-commutative61.7%

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

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

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

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

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

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

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

    if -3.6500000000000002e118 < d < -9.50000000000000013e-150 or 3.30000000000000029e23 < d < 1.90000000000000003e166

    1. Initial program 81.2%

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

    if -9.50000000000000013e-150 < d < 3.30000000000000029e23

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.90000000000000003e166 < d

    1. Initial program 12.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      8. hypot-def48.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)}} \]
    4. Applied egg-rr48.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)}} \]
    5. Step-by-step derivation
      1. *-commutative48.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.65 \cdot 10^{+118}:\\ \;\;\;\;\frac{a - \frac{b \cdot c}{d}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -9.5 \cdot 10^{-150}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{+166}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 78.4% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -1.85 \cdot 10^{-150}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 2.5 \cdot 10^{+143}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 32.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      8. hypot-def59.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)}} \]
    4. Applied egg-rr59.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)}} \]
    5. Step-by-step derivation
      1. *-commutative59.3%

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

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

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

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

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

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

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

    if -1.65000000000000013e145 < d < -1.85e-150 or 3.30000000000000029e23 < d < 2.50000000000000006e143

    1. Initial program 80.8%

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

    if -1.85e-150 < d < 3.30000000000000029e23

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.50000000000000006e143 < d

    1. Initial program 22.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.65 \cdot 10^{+145}:\\ \;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -1.85 \cdot 10^{-150}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{+143}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 79.7% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -2 \cdot 10^{-150}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 5 \cdot 10^{+141}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 36.6%

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Step-by-step derivation
      1. *-commutative61.7%

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

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

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

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

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

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

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

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

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

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

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

    if -4.1499999999999999e123 < d < -2.00000000000000001e-150 or 2.14999999999999994e24 < d < 5.00000000000000025e141

    1. Initial program 80.4%

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

    if -2.00000000000000001e-150 < d < 2.14999999999999994e24

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000025e141 < d

    1. Initial program 22.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.15 \cdot 10^{+123}:\\ \;\;\;\;\frac{a - \frac{b}{\frac{d}{c}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -2 \cdot 10^{-150}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.15 \cdot 10^{+24}:\\ \;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \mathbf{elif}\;d \leq 5 \cdot 10^{+141}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 78.4% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -9.2 \cdot 10^{-150}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 1.15 \cdot 10^{+149}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 32.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      8. hypot-def59.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)}} \]
    4. Applied egg-rr59.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)}} \]
    5. Step-by-step derivation
      1. *-commutative59.3%

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

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

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

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

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

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

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

    if -2.49999999999999983e145 < d < -9.20000000000000011e-150 or 3.30000000000000029e23 < d < 1.1499999999999999e149

    1. Initial program 81.0%

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

    if -9.20000000000000011e-150 < d < 3.30000000000000029e23

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1499999999999999e149 < d

    1. Initial program 20.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.5 \cdot 10^{+145}:\\ \;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -9.2 \cdot 10^{-150}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \mathbf{elif}\;d \leq 1.15 \cdot 10^{+149}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 78.3% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;d \leq -1.9 \cdot 10^{-150}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;d \leq 1.6 \cdot 10^{+145}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.0500000000000001e145 or 1.60000000000000004e145 < d

    1. Initial program 26.2%

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

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

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

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

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

    if -2.0500000000000001e145 < d < -1.8999999999999999e-150 or 3.30000000000000029e23 < d < 1.60000000000000004e145

    1. Initial program 81.0%

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

    if -1.8999999999999999e-150 < d < 3.30000000000000029e23

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.05 \cdot 10^{+145}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-150}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{+145}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 72.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.5 \cdot 10^{+52} \lor \neg \left(d \leq 9.5 \cdot 10^{+28}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.49999999999999996e52 or 9.49999999999999927e28 < d

    1. Initial program 51.2%

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

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

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

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

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

    if -5.49999999999999996e52 < d < 9.49999999999999927e28

    1. Initial program 71.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      8. hypot-def83.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)}} \]
    4. Applied egg-rr83.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)}} \]
    5. Taylor expanded in c around inf 51.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.5 \cdot 10^{+52} \lor \neg \left(d \leq 9.5 \cdot 10^{+28}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 63.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.35 \cdot 10^{-44} \lor \neg \left(d \leq 6 \cdot 10^{+29}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.35e-44 or 5.9999999999999998e29 < d

    1. Initial program 55.7%

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

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

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

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

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

    if -1.35e-44 < d < 5.9999999999999998e29

    1. Initial program 70.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.35 \cdot 10^{-44} \lor \neg \left(d \leq 6 \cdot 10^{+29}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 10.3% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  9. Final simplification9.8%

    \[\leadsto \frac{a}{c} \]
  10. Add Preprocessing

Alternative 14: 42.4% accurate, 5.0× speedup?

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

\\
\frac{b}{c}
\end{array}
Derivation
  1. Initial program 62.5%

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

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

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

Developer target: 99.2% 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 2024024 
(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))))