Complex division, real part

Percentage Accurate: 61.3% → 82.5%
Time: 11.4s
Alternatives: 15
Speedup: 2.1×

Specification

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

\\
\frac{a \cdot c + b \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 15 alternatives:

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

Initial Program: 61.3% accurate, 1.0× speedup?

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

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

Alternative 1: 82.5% accurate, 0.0× speedup?

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\frac{c}{\mathsf{hypot}\left(c, d\right)}}\right)}^{2} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\


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

    1. Initial program 44.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.10000000000000017e34 < c < -4.99999999999999963e-77

    1. Initial program 84.6%

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

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

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

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

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

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

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

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

    if -4.99999999999999963e-77 < c < 8.99999999999999963e-294

    1. Initial program 61.8%

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{a}{\frac{{d}^{2}}{c}}} \]
    4. Simplified88.5%

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

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

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

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

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

    if 8.99999999999999963e-294 < c < 1.75e65

    1. Initial program 76.8%

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

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

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

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

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

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

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

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

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

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

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

    if 1.75e65 < c

    1. Initial program 43.3%

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

      \[\leadsto \frac{\color{blue}{a \cdot c}}{c \cdot c + d \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative43.3%

        \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    4. Simplified43.3%

      \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt43.3%

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt89.5%

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

        \[\leadsto \color{blue}{{\left(\sqrt{\frac{c}{\mathsf{hypot}\left(c, d\right)}}\right)}^{2}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
    8. Applied egg-rr89.5%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{c}{\mathsf{hypot}\left(c, d\right)}}\right)}^{2}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification90.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\ \;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -5 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-294}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \left(d \cdot \frac{1}{c}\right)}\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{+65}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt{\frac{c}{\mathsf{hypot}\left(c, d\right)}}\right)}^{2} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 2: 82.5% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;c \leq -2.3 \cdot 10^{-74}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.72 \cdot 10^{+59}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 44.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.10000000000000017e34 < c < -2.2999999999999998e-74 or 2.5999999999999998e-293 < c < 1.71999999999999996e59

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

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

    if -2.2999999999999998e-74 < c < 2.5999999999999998e-293

    1. Initial program 61.8%

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{a}{\frac{{d}^{2}}{c}}} \]
    4. Simplified88.5%

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

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

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

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

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

    if 1.71999999999999996e59 < c

    1. Initial program 43.3%

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

      \[\leadsto \frac{\color{blue}{a \cdot c}}{c \cdot c + d \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative43.3%

        \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    4. Simplified43.3%

      \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt43.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\ \;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -2.3 \cdot 10^{-74}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{-293}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \left(d \cdot \frac{1}{c}\right)}\\ \mathbf{elif}\;c \leq 1.72 \cdot 10^{+59}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 3: 82.6% accurate, 0.0× speedup?

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

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

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

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

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

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


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

    1. Initial program 44.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.10000000000000017e34 < c < -5.3e-76

    1. Initial program 84.6%

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

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

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

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

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

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

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

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

    if -5.3e-76 < c < 7.8e-293

    1. Initial program 61.8%

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{a}{\frac{{d}^{2}}{c}}} \]
    4. Simplified88.5%

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

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

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

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

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

    if 7.8e-293 < c < 3.25e69

    1. Initial program 76.8%

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

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

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

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

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

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

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

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

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

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

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

    if 3.25e69 < c

    1. Initial program 43.3%

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

      \[\leadsto \frac{\color{blue}{a \cdot c}}{c \cdot c + d \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative43.3%

        \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    4. Simplified43.3%

      \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt43.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\ \;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -5.3 \cdot 10^{-76}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{-293}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \left(d \cdot \frac{1}{c}\right)}\\ \mathbf{elif}\;c \leq 3.25 \cdot 10^{+69}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 4: 79.1% accurate, 0.1× speedup?

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

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

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

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

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


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

    1. Initial program 44.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.10000000000000017e34 < c < -1.45e-74

    1. Initial program 84.6%

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

    if -1.45e-74 < c < 5.19999999999999996e53

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.19999999999999996e53 < c

    1. Initial program 43.3%

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

      \[\leadsto \frac{\color{blue}{a \cdot c}}{c \cdot c + d \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative43.3%

        \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    4. Simplified43.3%

      \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt43.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\ \;\;\;\;\frac{\left(-a\right) - \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1.45 \cdot 10^{-74}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 5.2 \cdot 10^{+53}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 5: 75.2% accurate, 0.1× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.10000000000000017e34 or 1e108 < c

    1. Initial program 43.6%

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

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

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

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

    if -2.10000000000000017e34 < c < -1.45e-68

    1. Initial program 84.6%

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

    if -1.45e-68 < c < 1e108

    1. Initial program 69.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{\frac{{c}^{2}}{d}}\\ \mathbf{elif}\;c \leq -1.45 \cdot 10^{-68}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 10^{+108}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{\frac{{c}^{2}}{d}}\\ \end{array} \]

Alternative 6: 78.4% accurate, 0.1× speedup?

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

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

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

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

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


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

    1. Initial program 44.0%

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

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

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{b}{\frac{{c}^{2}}{d}}} \]
    4. Simplified74.6%

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

    if -2.10000000000000017e34 < c < -1.6499999999999999e-68

    1. Initial program 84.6%

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

    if -1.6499999999999999e-68 < c < 8.19999999999999992e23

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.19999999999999992e23 < c

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a + \color{blue}{\frac{b}{\frac{c}{d}}}}{\mathsf{hypot}\left(c, d\right)} \]
    8. Simplified84.3%

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

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

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

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

Alternative 7: 80.3% accurate, 0.1× speedup?

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

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

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

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

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


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

    1. Initial program 44.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999989e34 < c < -1.2999999999999999e-68

    1. Initial program 84.6%

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

    if -1.2999999999999999e-68 < c < 3.5e19

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.5e19 < c

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a + \color{blue}{\frac{b}{\frac{c}{d}}}}{\mathsf{hypot}\left(c, d\right)} \]
    8. Simplified84.3%

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

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

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

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

Alternative 8: 75.7% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.75 \cdot 10^{+109}:\\
\;\;\;\;\frac{a}{c}\\

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

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

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


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

    1. Initial program 36.1%

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

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

    if -1.74999999999999992e109 < c < -4.99999999999999963e-77

    1. Initial program 76.7%

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

    if -4.99999999999999963e-77 < c < 1.1500000000000001e106

    1. Initial program 69.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.1500000000000001e106 < c

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.75 \cdot 10^{+109}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -5 \cdot 10^{-77}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{+106}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 9: 75.8% accurate, 0.1× speedup?

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

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

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

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

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


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

    1. Initial program 36.1%

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

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

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

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

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

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

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

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

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

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

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

    if -2.40000000000000012e110 < c < -1.2e-72

    1. Initial program 76.7%

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

    if -1.2e-72 < c < 7.79999999999999957e105

    1. Initial program 69.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.79999999999999957e105 < c

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.4 \cdot 10^{+110}:\\ \;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1.2 \cdot 10^{-72}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{+105}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 10: 75.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.1 \cdot 10^{+108}:\\
\;\;\;\;\frac{a}{c}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -4.0999999999999999e108 or 1.15999999999999995e108 < c

    1. Initial program 39.8%

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

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

    if -4.0999999999999999e108 < c < -4.2e-72

    1. Initial program 76.7%

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

    if -4.2e-72 < c < 1.15999999999999995e108

    1. Initial program 69.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.1 \cdot 10^{+108}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -4.2 \cdot 10^{-72}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.16 \cdot 10^{+108}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]

Alternative 11: 71.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\
\;\;\;\;\frac{a}{c}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.10000000000000017e34 or 2.9499999999999999e109 < c

    1. Initial program 43.6%

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

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

    if -2.10000000000000017e34 < c < -2.09999999999999991e-60

    1. Initial program 84.6%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    4. Simplified66.5%

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

    if -2.09999999999999991e-60 < c < 2.9499999999999999e109

    1. Initial program 69.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.1 \cdot 10^{+34}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -2.1 \cdot 10^{-60}:\\ \;\;\;\;\frac{c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.95 \cdot 10^{+109}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]

Alternative 12: 70.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{-60} \lor \neg \left(c \leq 9.8 \cdot 10^{+107}\right):\\
\;\;\;\;\frac{a}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.09999999999999991e-60 or 9.8000000000000003e107 < c

    1. Initial program 51.9%

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

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

    if -2.09999999999999991e-60 < c < 9.8000000000000003e107

    1. Initial program 69.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.1 \cdot 10^{-60} \lor \neg \left(c \leq 9.8 \cdot 10^{+107}\right):\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\ \end{array} \]

Alternative 13: 60.8% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.6 \cdot 10^{-77}:\\
\;\;\;\;\frac{a}{c}\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -4.59999999999999997e-77 or 4.5000000000000002e53 < c

    1. Initial program 51.8%

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

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

    if -4.59999999999999997e-77 < c < 3.19999999999999985e-161 or 1.11999999999999999e-48 < c < 4.5000000000000002e53

    1. Initial program 68.1%

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

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

    if 3.19999999999999985e-161 < c < 1.11999999999999999e-48

    1. Initial program 80.8%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    4. Simplified55.0%

      \[\leadsto \frac{\color{blue}{c \cdot a}}{c \cdot c + d \cdot d} \]
    5. Taylor expanded in c around 0 55.0%

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

        \[\leadsto \frac{\color{blue}{c \cdot a}}{{d}^{2}} \]
      2. associate-*r/51.4%

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

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

        \[\leadsto \color{blue}{\frac{c \cdot a}{{d}^{2}}} \]
      2. unpow255.0%

        \[\leadsto \frac{c \cdot a}{\color{blue}{d \cdot d}} \]
      3. associate-/r*58.9%

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

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

        \[\leadsto \frac{\color{blue}{\frac{a}{d} \cdot c}}{d} \]
      6. associate-/r/58.8%

        \[\leadsto \frac{\color{blue}{\frac{a}{\frac{d}{c}}}}{d} \]
      7. div-inv58.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.6 \cdot 10^{-77}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-161}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 1.12 \cdot 10^{-48}:\\ \;\;\;\;\frac{\frac{c}{d} \cdot a}{d}\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{+53}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]

Alternative 14: 62.7% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.4 \cdot 10^{-79} \lor \neg \left(c \leq 3.7 \cdot 10^{+55}\right):\\
\;\;\;\;\frac{a}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.3999999999999998e-79 or 3.7000000000000002e55 < c

    1. Initial program 51.8%

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

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

    if -4.3999999999999998e-79 < c < 3.7000000000000002e55

    1. Initial program 70.8%

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

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

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

Alternative 15: 42.6% 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 60.7%

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  3. Final simplification42.7%

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

Developer target: 99.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \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))
   (/ (+ a (* b (/ d c))) (+ c (* d (/ d c))))
   (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (b + (a * (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(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(b + Float64(a * 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 = (a + (b * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (b + (a * (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[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * 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{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023306 
(FPCore (a b c d)
  :name "Complex division, real part"
  :precision binary64

  :herbie-target
  (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))

  (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))