Complex division, real part

Percentage Accurate: 61.9% → 91.5%
Time: 9.7s
Alternatives: 11
Speedup: 1.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 11 alternatives:

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

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{t\_0}}{t\_0}\\ t_2 := \mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, t\_1\right)\\ \mathbf{if}\;d \leq -1.05 \cdot 10^{+124}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\ \mathbf{elif}\;d \leq -5.05 \cdot 10^{-144}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{-205}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 7.2 \cdot 10^{+106}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, t\_1\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (sqrt (hypot c d)))
        (t_1 (/ (/ (/ c (/ (hypot c d) a)) t_0) t_0))
        (t_2 (fma b (/ d (pow (hypot c d) 2.0)) t_1)))
   (if (<= d -1.05e+124)
     (fma b (/ 1.0 d) (* c (/ (/ a (hypot c d)) (hypot c d))))
     (if (<= d -5.05e-144)
       t_2
       (if (<= d 9.2e-205)
         (/ (+ a (/ (* d b) c)) c)
         (if (<= d 7.2e+106) t_2 (fma b (/ 1.0 d) t_1)))))))
double code(double a, double b, double c, double d) {
	double t_0 = sqrt(hypot(c, d));
	double t_1 = ((c / (hypot(c, d) / a)) / t_0) / t_0;
	double t_2 = fma(b, (d / pow(hypot(c, d), 2.0)), t_1);
	double tmp;
	if (d <= -1.05e+124) {
		tmp = fma(b, (1.0 / d), (c * ((a / hypot(c, d)) / hypot(c, d))));
	} else if (d <= -5.05e-144) {
		tmp = t_2;
	} else if (d <= 9.2e-205) {
		tmp = (a + ((d * b) / c)) / c;
	} else if (d <= 7.2e+106) {
		tmp = t_2;
	} else {
		tmp = fma(b, (1.0 / d), t_1);
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = sqrt(hypot(c, d))
	t_1 = Float64(Float64(Float64(c / Float64(hypot(c, d) / a)) / t_0) / t_0)
	t_2 = fma(b, Float64(d / (hypot(c, d) ^ 2.0)), t_1)
	tmp = 0.0
	if (d <= -1.05e+124)
		tmp = fma(b, Float64(1.0 / d), Float64(c * Float64(Float64(a / hypot(c, d)) / hypot(c, d))));
	elseif (d <= -5.05e-144)
		tmp = t_2;
	elseif (d <= 9.2e-205)
		tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c);
	elseif (d <= 7.2e+106)
		tmp = t_2;
	else
		tmp = fma(b, Float64(1.0 / d), t_1);
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[Sqrt[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[d, -1.05e+124], N[(b * N[(1.0 / d), $MachinePrecision] + N[(c * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.05e-144], t$95$2, If[LessEqual[d, 9.2e-205], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.2e+106], t$95$2, N[(b * N[(1.0 / d), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{t\_0}}{t\_0}\\
t_2 := \mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, t\_1\right)\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\

\mathbf{elif}\;d \leq -5.05 \cdot 10^{-144}:\\
\;\;\;\;t\_2\\

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

\mathbf{elif}\;d \leq 7.2 \cdot 10^{+106}:\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, t\_1\right)\\


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

    1. Initial program 41.9%

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{d}{{c}^{2} + {d}^{2}}} + \frac{a \cdot c}{{c}^{2} + {d}^{2}} \]
      3. fma-define42.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.05000000000000006e124 < d < -5.0499999999999999e-144 or 9.1999999999999997e-205 < d < 7.2000000000000002e106

    1. Initial program 72.9%

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{d}{{c}^{2} + {d}^{2}}} + \frac{a \cdot c}{{c}^{2} + {d}^{2}} \]
      3. fma-define75.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.0499999999999999e-144 < d < 9.1999999999999997e-205

    1. Initial program 66.3%

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

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

    if 7.2000000000000002e106 < d

    1. Initial program 29.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, \color{blue}{\frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}\right) \]
    12. Taylor expanded in d around inf 95.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.05 \cdot 10^{+124}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\ \mathbf{elif}\;d \leq -5.05 \cdot 10^{-144}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, \frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}\right)\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{-205}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 7.2 \cdot 10^{+106}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, \frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, \frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 88.1% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\ t_2 := \mathsf{fma}\left(b, \frac{1}{d}, \frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{t\_0}}{t\_0}\right)\\ \mathbf{if}\;d \leq -2 \cdot 10^{+150}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;d \leq -3.2 \cdot 10^{-83}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{-88}:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{+106}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (sqrt (hypot c d)))
        (t_1
         (fma
          b
          (/ d (pow (hypot c d) 2.0))
          (* c (/ (/ a (hypot c d)) (hypot c d)))))
        (t_2 (fma b (/ 1.0 d) (/ (/ (/ c (/ (hypot c d) a)) t_0) t_0))))
   (if (<= d -2e+150)
     t_2
     (if (<= d -3.2e-83)
       t_1
       (if (<= d 1.45e-88)
         (/ (+ a (* b (/ d c))) c)
         (if (<= d 1.9e+106) t_1 t_2))))))
double code(double a, double b, double c, double d) {
	double t_0 = sqrt(hypot(c, d));
	double t_1 = fma(b, (d / pow(hypot(c, d), 2.0)), (c * ((a / hypot(c, d)) / hypot(c, d))));
	double t_2 = fma(b, (1.0 / d), (((c / (hypot(c, d) / a)) / t_0) / t_0));
	double tmp;
	if (d <= -2e+150) {
		tmp = t_2;
	} else if (d <= -3.2e-83) {
		tmp = t_1;
	} else if (d <= 1.45e-88) {
		tmp = (a + (b * (d / c))) / c;
	} else if (d <= 1.9e+106) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = sqrt(hypot(c, d))
	t_1 = fma(b, Float64(d / (hypot(c, d) ^ 2.0)), Float64(c * Float64(Float64(a / hypot(c, d)) / hypot(c, d))))
	t_2 = fma(b, Float64(1.0 / d), Float64(Float64(Float64(c / Float64(hypot(c, d) / a)) / t_0) / t_0))
	tmp = 0.0
	if (d <= -2e+150)
		tmp = t_2;
	elseif (d <= -3.2e-83)
		tmp = t_1;
	elseif (d <= 1.45e-88)
		tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c);
	elseif (d <= 1.9e+106)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[Sqrt[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(c * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(1.0 / d), $MachinePrecision] + N[(N[(N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2e+150], t$95$2, If[LessEqual[d, -3.2e-83], t$95$1, If[LessEqual[d, 1.45e-88], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.9e+106], t$95$1, t$95$2]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -3.2 \cdot 10^{-83}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 1.9 \cdot 10^{+106}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.99999999999999996e150 or 1.8999999999999999e106 < d

    1. Initial program 32.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, \color{blue}{\frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}\right) \]
    12. Taylor expanded in d around inf 95.8%

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

    if -1.99999999999999996e150 < d < -3.2000000000000001e-83 or 1.4500000000000001e-88 < d < 1.8999999999999999e106

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.2000000000000001e-83 < d < 1.4500000000000001e-88

    1. Initial program 66.8%

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

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

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

      \[\leadsto \color{blue}{\frac{a + b \cdot \frac{d}{c}}{c}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 86.9% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, t\_0\right)\\ \mathbf{if}\;d \leq -6.9 \cdot 10^{+149}:\\ \;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, t\_0\right)\\ \mathbf{elif}\;d \leq -3 \cdot 10^{-85}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 6.6 \cdot 10^{-88}:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 2.9 \cdot 10^{+155}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (* c (/ (/ a (hypot c d)) (hypot c d))))
        (t_1 (fma b (/ d (pow (hypot c d) 2.0)) t_0)))
   (if (<= d -6.9e+149)
     (fma b (/ 1.0 d) t_0)
     (if (<= d -3e-85)
       t_1
       (if (<= d 6.6e-88)
         (/ (+ a (* b (/ d c))) c)
         (if (<= d 2.9e+155) t_1 (/ (+ b (* c (/ a d))) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = c * ((a / hypot(c, d)) / hypot(c, d));
	double t_1 = fma(b, (d / pow(hypot(c, d), 2.0)), t_0);
	double tmp;
	if (d <= -6.9e+149) {
		tmp = fma(b, (1.0 / d), t_0);
	} else if (d <= -3e-85) {
		tmp = t_1;
	} else if (d <= 6.6e-88) {
		tmp = (a + (b * (d / c))) / c;
	} else if (d <= 2.9e+155) {
		tmp = t_1;
	} else {
		tmp = (b + (c * (a / d))) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(c * Float64(Float64(a / hypot(c, d)) / hypot(c, d)))
	t_1 = fma(b, Float64(d / (hypot(c, d) ^ 2.0)), t_0)
	tmp = 0.0
	if (d <= -6.9e+149)
		tmp = fma(b, Float64(1.0 / d), t_0);
	elseif (d <= -3e-85)
		tmp = t_1;
	elseif (d <= 6.6e-88)
		tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c);
	elseif (d <= 2.9e+155)
		tmp = t_1;
	else
		tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[d, -6.9e+149], N[(b * N[(1.0 / d), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[d, -3e-85], t$95$1, If[LessEqual[d, 6.6e-88], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.9e+155], t$95$1, N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -3 \cdot 10^{-85}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 2.9 \cdot 10^{+155}:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 35.9%

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{d}{{c}^{2} + {d}^{2}}} + \frac{a \cdot c}{{c}^{2} + {d}^{2}} \]
      3. fma-define36.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.9000000000000004e149 < d < -3.00000000000000022e-85 or 6.59999999999999987e-88 < d < 2.8999999999999999e155

    1. Initial program 74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.00000000000000022e-85 < d < 6.59999999999999987e-88

    1. Initial program 66.8%

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

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

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

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

    if 2.8999999999999999e155 < d

    1. Initial program 22.6%

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

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

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

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

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

      \[\leadsto \frac{b + \color{blue}{c \cdot \frac{a}{d}}}{d} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 4: 81.7% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, \frac{1}{d}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\
t_1 := {\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}\\
\mathbf{if}\;d \leq -1.02 \cdot 10^{-69}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 2.3 \cdot 10^{+106}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{d}{t\_1}, c \cdot \frac{a}{t\_1}\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.02000000000000005e-69 or 2.3000000000000002e106 < d

    1. Initial program 49.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.02000000000000005e-69 < d < 6.19999999999999995e-87

    1. Initial program 66.8%

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

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

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

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

    if 6.19999999999999995e-87 < d < 2.3000000000000002e106

    1. Initial program 71.2%

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{d}{{c}^{2} + {d}^{2}}} + \frac{a \cdot c}{{c}^{2} + {d}^{2}} \]
      3. fma-define76.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, c \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 79.9% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.1 \cdot 10^{-69} \lor \neg \left(d \leq 1.05 \cdot 10^{-17}\right):\\
\;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.1e-69 or 1.04999999999999996e-17 < d

    1. Initial program 52.8%

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{d}{{c}^{2} + {d}^{2}}} + \frac{a \cdot c}{{c}^{2} + {d}^{2}} \]
      3. fma-define55.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.1e-69 < d < 1.04999999999999996e-17

    1. Initial program 67.7%

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

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

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

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

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

Alternative 6: 82.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -1.25 \cdot 10^{+66}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \mathbf{elif}\;d \leq -1.5 \cdot 10^{-89}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.65 \cdot 10^{-87}:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.5 \cdot 10^{+103}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (+ (* d b) (* c a)) (+ (* c c) (* d d)))))
   (if (<= d -1.25e+66)
     (/ (+ b (* c (/ a d))) d)
     (if (<= d -1.5e-89)
       t_0
       (if (<= d 1.65e-87)
         (/ (+ a (* b (/ d c))) c)
         (if (<= d 3.5e+103) t_0 (/ (+ b (* a (/ c d))) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -1.25e+66) {
		tmp = (b + (c * (a / d))) / d;
	} else if (d <= -1.5e-89) {
		tmp = t_0;
	} else if (d <= 1.65e-87) {
		tmp = (a + (b * (d / c))) / c;
	} else if (d <= 3.5e+103) {
		tmp = t_0;
	} else {
		tmp = (b + (a * (c / d))) / d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d))
    if (d <= (-1.25d+66)) then
        tmp = (b + (c * (a / d))) / d
    else if (d <= (-1.5d-89)) then
        tmp = t_0
    else if (d <= 1.65d-87) then
        tmp = (a + (b * (d / c))) / c
    else if (d <= 3.5d+103) then
        tmp = t_0
    else
        tmp = (b + (a * (c / d))) / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -1.25e+66) {
		tmp = (b + (c * (a / d))) / d;
	} else if (d <= -1.5e-89) {
		tmp = t_0;
	} else if (d <= 1.65e-87) {
		tmp = (a + (b * (d / c))) / c;
	} else if (d <= 3.5e+103) {
		tmp = t_0;
	} else {
		tmp = (b + (a * (c / d))) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -1.25e+66:
		tmp = (b + (c * (a / d))) / d
	elif d <= -1.5e-89:
		tmp = t_0
	elif d <= 1.65e-87:
		tmp = (a + (b * (d / c))) / c
	elif d <= 3.5e+103:
		tmp = t_0
	else:
		tmp = (b + (a * (c / d))) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -1.25e+66)
		tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d);
	elseif (d <= -1.5e-89)
		tmp = t_0;
	elseif (d <= 1.65e-87)
		tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c);
	elseif (d <= 3.5e+103)
		tmp = t_0;
	else
		tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -1.25e+66)
		tmp = (b + (c * (a / d))) / d;
	elseif (d <= -1.5e-89)
		tmp = t_0;
	elseif (d <= 1.65e-87)
		tmp = (a + (b * (d / c))) / c;
	elseif (d <= 3.5e+103)
		tmp = t_0;
	else
		tmp = (b + (a * (c / d))) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.25e+66], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.5e-89], t$95$0, If[LessEqual[d, 1.65e-87], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.5e+103], t$95$0, N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.5 \cdot 10^{-89}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 3.5 \cdot 10^{+103}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 49.5%

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

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

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

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

        \[\leadsto \frac{b + \color{blue}{c \cdot \frac{a}{d}}}{d} \]
    7. Applied egg-rr91.7%

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

    if -1.24999999999999998e66 < d < -1.5e-89 or 1.65e-87 < d < 3.5e103

    1. Initial program 76.5%

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

    if -1.5e-89 < d < 1.65e-87

    1. Initial program 66.8%

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

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

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

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

    if 3.5e103 < d

    1. Initial program 29.9%

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

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

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

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

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

        \[\leadsto \frac{b + \color{blue}{a \cdot \frac{c}{d}}}{d} \]
    8. Simplified86.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.25 \cdot 10^{+66}:\\ \;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\ \mathbf{elif}\;d \leq -1.5 \cdot 10^{-89}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.65 \cdot 10^{-87}:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.5 \cdot 10^{+103}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 78.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -29500000 \lor \neg \left(d \leq 1.7 \cdot 10^{-16}\right):\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.95e7 or 1.7e-16 < d

    1. Initial program 49.3%

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

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

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

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

        \[\leadsto \frac{b + \color{blue}{c \cdot \frac{a}{d}}}{d} \]
    7. Applied egg-rr81.4%

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

    if -2.95e7 < d < 1.7e-16

    1. Initial program 69.8%

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

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

        \[\leadsto \frac{a + \color{blue}{b \cdot \frac{d}{c}}}{c} \]
    5. Simplified88.7%

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

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

Alternative 8: 78.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -12800000 \lor \neg \left(d \leq 3.9 \cdot 10^{-16}\right):\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.28e7 or 3.89999999999999977e-16 < d

    1. Initial program 49.3%

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

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

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

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

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

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

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

    if -1.28e7 < d < 3.89999999999999977e-16

    1. Initial program 69.8%

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

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

        \[\leadsto \frac{a + \color{blue}{b \cdot \frac{d}{c}}}{c} \]
    5. Simplified88.7%

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

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

Alternative 9: 72.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.6 \cdot 10^{+48} \lor \neg \left(d \leq 3.1 \cdot 10^{+125}\right):\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.6000000000000001e48 or 3.1e125 < d

    1. Initial program 42.1%

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

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

    if -1.6000000000000001e48 < d < 3.1e125

    1. Initial program 69.7%

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

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

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

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

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

Alternative 10: 62.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -45000 \lor \neg \left(d \leq 3.1 \cdot 10^{+125}\right):\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -45000 or 3.1e125 < d

    1. Initial program 45.0%

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

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

    if -45000 < d < 3.1e125

    1. Initial program 69.0%

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

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

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

Alternative 11: 42.9% accurate, 5.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  4. Add Preprocessing

Developer Target 1: 99.2% 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 2024131 
(FPCore (a b c d)
  :name "Complex division, real part"
  :precision binary64

  :alt
  (! :herbie-platform default (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))))