Complex division, imag part

Percentage Accurate: 60.9% → 95.8%
Time: 15.4s
Alternatives: 17
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 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: 60.9% accurate, 1.0× speedup?

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

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

Alternative 1: 95.8% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\mathsf{hypot}\left(d, c\right)}\right)\right) \cdot \frac{-1}{\mathsf{hypot}\left(d, c\right)}\right)\right) \]
  12. Add Preprocessing

Alternative 2: 91.6% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq 5.3 \cdot 10^{+125}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, \frac{\frac{d \cdot a}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.02e188

    1. Initial program 31.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.02e188 < d < 5.3000000000000003e125

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.3000000000000003e125 < d

    1. Initial program 34.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.8% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.8% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\ t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_2 := c \cdot c + d \cdot d\\ t_3 := a \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -2.12 \cdot 10^{+133}:\\ \;\;\;\;t\_1 \cdot \left(t\_3 - b\right)\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-130}:\\ \;\;\;\;\frac{c \cdot b + \mathsf{fma}\left(a, -d, \mathsf{fma}\left(a, -d, d \cdot a\right)\right)}{t\_2}\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-29}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{+44}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_2}\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{+88}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot \left(b - t\_3\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ a (- d))))
        (t_1 (/ 1.0 (hypot c d)))
        (t_2 (+ (* c c) (* d d)))
        (t_3 (* a (/ d c))))
   (if (<= c -2.12e+133)
     (* t_1 (- t_3 b))
     (if (<= c -1.7e-130)
       (/ (+ (* c b) (fma a (- d) (fma a (- d) (* d a)))) t_2)
       (if (<= c 3e-29)
         t_0
         (if (<= c 1.75e+44)
           (/ (fma (- d) a (* c b)) t_2)
           (if (<= c 1.55e+88) t_0 (* t_1 (- b t_3)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), (a / -d));
	double t_1 = 1.0 / hypot(c, d);
	double t_2 = (c * c) + (d * d);
	double t_3 = a * (d / c);
	double tmp;
	if (c <= -2.12e+133) {
		tmp = t_1 * (t_3 - b);
	} else if (c <= -1.7e-130) {
		tmp = ((c * b) + fma(a, -d, fma(a, -d, (d * a)))) / t_2;
	} else if (c <= 3e-29) {
		tmp = t_0;
	} else if (c <= 1.75e+44) {
		tmp = fma(-d, a, (c * b)) / t_2;
	} else if (c <= 1.55e+88) {
		tmp = t_0;
	} else {
		tmp = t_1 * (b - t_3);
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a / Float64(-d)))
	t_1 = Float64(1.0 / hypot(c, d))
	t_2 = Float64(Float64(c * c) + Float64(d * d))
	t_3 = Float64(a * Float64(d / c))
	tmp = 0.0
	if (c <= -2.12e+133)
		tmp = Float64(t_1 * Float64(t_3 - b));
	elseif (c <= -1.7e-130)
		tmp = Float64(Float64(Float64(c * b) + fma(a, Float64(-d), fma(a, Float64(-d), Float64(d * a)))) / t_2);
	elseif (c <= 3e-29)
		tmp = t_0;
	elseif (c <= 1.75e+44)
		tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / t_2);
	elseif (c <= 1.55e+88)
		tmp = t_0;
	else
		tmp = Float64(t_1 * Float64(b - t_3));
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a / (-d)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.12e+133], N[(t$95$1 * N[(t$95$3 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.7e-130], N[(N[(N[(c * b), $MachinePrecision] + N[(a * (-d) + N[(a * (-d) + N[(d * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[c, 3e-29], t$95$0, If[LessEqual[c, 1.75e+44], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[c, 1.55e+88], t$95$0, N[(t$95$1 * N[(b - t$95$3), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.7 \cdot 10^{-130}:\\
\;\;\;\;\frac{c \cdot b + \mathsf{fma}\left(a, -d, \mathsf{fma}\left(a, -d, d \cdot a\right)\right)}{t\_2}\\

\mathbf{elif}\;c \leq 3 \cdot 10^{-29}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;c \leq 1.75 \cdot 10^{+44}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_2}\\

\mathbf{elif}\;c \leq 1.55 \cdot 10^{+88}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(b - t\_3\right)\\


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

    1. Initial program 30.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.12e133 < c < -1.70000000000000003e-130

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.70000000000000003e-130 < c < 3.0000000000000003e-29 or 1.75e44 < c < 1.5500000000000001e88

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.0000000000000003e-29 < c < 1.75e44

    1. Initial program 89.5%

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

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

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

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

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

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

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

    if 1.5500000000000001e88 < c

    1. Initial program 37.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.12 \cdot 10^{+133}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a \cdot \frac{d}{c} - b\right)\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-130}:\\ \;\;\;\;\frac{c \cdot b + \mathsf{fma}\left(a, -d, \mathsf{fma}\left(a, -d, d \cdot a\right)\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-29}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{+44}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{+88}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - a \cdot \frac{d}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 88.8% accurate, 0.0× speedup?

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

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

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


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

    1. Initial program 78.0%

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e281 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 15.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 77.1% accurate, 0.1× speedup?

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

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

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

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

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


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

    1. Initial program 30.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.1999999999999996e133 < c < -3.2000000000000001e-141

    1. Initial program 90.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.2000000000000001e-141 < c < 6.00000000000000023e-26

    1. Initial program 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.00000000000000023e-26 < c

    1. Initial program 51.6%

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

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

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

      \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt45.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 77.2% accurate, 0.1× speedup?

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

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

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

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

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


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

    1. Initial program 30.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.2e133 < c < -2.00000000000000008e-134

    1. Initial program 90.6%

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

    if -2.00000000000000008e-134 < c < 3.80000000000000015e-26

    1. Initial program 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.80000000000000015e-26 < c

    1. Initial program 51.6%

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

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

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

      \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt45.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 79.3% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -1.4 \cdot 10^{-128}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{t\_2}\\

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

\mathbf{elif}\;c \leq 2.1 \cdot 10^{+86}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t\_2}\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(b - t\_0\right)\\


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

    1. Initial program 30.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.12e133 < c < -1.3999999999999999e-128

    1. Initial program 90.6%

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

    if -1.3999999999999999e-128 < c < 1.99999999999999989e-29

    1. Initial program 69.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999989e-29 < c < 2.0999999999999999e86

    1. Initial program 73.2%

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

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

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

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

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

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

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

    if 2.0999999999999999e86 < c

    1. Initial program 37.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.12 \cdot 10^{+133}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a \cdot \frac{d}{c} - b\right)\\ \mathbf{elif}\;c \leq -1.4 \cdot 10^{-128}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2 \cdot 10^{-29}:\\ \;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+86}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - a \cdot \frac{d}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 78.3% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -9 \cdot 10^{-137}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 7 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 30.2%

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999984e134 < c < -8.9999999999999994e-137 or 1.2000000000000001e-28 < c < 6.99999999999999954e83

    1. Initial program 84.2%

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

    if -8.9999999999999994e-137 < c < 1.2000000000000001e-28

    1. Initial program 69.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.99999999999999954e83 < c

    1. Initial program 37.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2 \cdot 10^{+134}:\\ \;\;\;\;\frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\ \mathbf{elif}\;c \leq -9 \cdot 10^{-137}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-28}:\\ \;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{+83}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - a \cdot \frac{d}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 79.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_2 := a \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -4.9 \cdot 10^{+135}:\\ \;\;\;\;t\_1 \cdot \left(t\_2 - b\right)\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-129}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-29}:\\ \;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.5 \cdot 10^{+81}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot \left(b - t\_2\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
        (t_1 (/ 1.0 (hypot c d)))
        (t_2 (* a (/ d c))))
   (if (<= c -4.9e+135)
     (* t_1 (- t_2 b))
     (if (<= c -1.7e-129)
       t_0
       (if (<= c 3.1e-29)
         (- (* b (/ c (pow d 2.0))) (/ a d))
         (if (<= c 2.5e+81) t_0 (* t_1 (- b t_2))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = 1.0 / hypot(c, d);
	double t_2 = a * (d / c);
	double tmp;
	if (c <= -4.9e+135) {
		tmp = t_1 * (t_2 - b);
	} else if (c <= -1.7e-129) {
		tmp = t_0;
	} else if (c <= 3.1e-29) {
		tmp = (b * (c / pow(d, 2.0))) - (a / d);
	} else if (c <= 2.5e+81) {
		tmp = t_0;
	} else {
		tmp = t_1 * (b - t_2);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = 1.0 / Math.hypot(c, d);
	double t_2 = a * (d / c);
	double tmp;
	if (c <= -4.9e+135) {
		tmp = t_1 * (t_2 - b);
	} else if (c <= -1.7e-129) {
		tmp = t_0;
	} else if (c <= 3.1e-29) {
		tmp = (b * (c / Math.pow(d, 2.0))) - (a / d);
	} else if (c <= 2.5e+81) {
		tmp = t_0;
	} else {
		tmp = t_1 * (b - t_2);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	t_1 = 1.0 / math.hypot(c, d)
	t_2 = a * (d / c)
	tmp = 0
	if c <= -4.9e+135:
		tmp = t_1 * (t_2 - b)
	elif c <= -1.7e-129:
		tmp = t_0
	elif c <= 3.1e-29:
		tmp = (b * (c / math.pow(d, 2.0))) - (a / d)
	elif c <= 2.5e+81:
		tmp = t_0
	else:
		tmp = t_1 * (b - t_2)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(1.0 / hypot(c, d))
	t_2 = Float64(a * Float64(d / c))
	tmp = 0.0
	if (c <= -4.9e+135)
		tmp = Float64(t_1 * Float64(t_2 - b));
	elseif (c <= -1.7e-129)
		tmp = t_0;
	elseif (c <= 3.1e-29)
		tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d));
	elseif (c <= 2.5e+81)
		tmp = t_0;
	else
		tmp = Float64(t_1 * Float64(b - t_2));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	t_1 = 1.0 / hypot(c, d);
	t_2 = a * (d / c);
	tmp = 0.0;
	if (c <= -4.9e+135)
		tmp = t_1 * (t_2 - b);
	elseif (c <= -1.7e-129)
		tmp = t_0;
	elseif (c <= 3.1e-29)
		tmp = (b * (c / (d ^ 2.0))) - (a / d);
	elseif (c <= 2.5e+81)
		tmp = t_0;
	else
		tmp = t_1 * (b - t_2);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4.9e+135], N[(t$95$1 * N[(t$95$2 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.7e-129], t$95$0, If[LessEqual[c, 3.1e-29], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.5e+81], t$95$0, N[(t$95$1 * N[(b - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.7 \cdot 10^{-129}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 2.5 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(b - t\_2\right)\\


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

    1. Initial program 30.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.9000000000000001e135 < c < -1.70000000000000007e-129 or 3.10000000000000026e-29 < c < 2.4999999999999999e81

    1. Initial program 84.2%

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

    if -1.70000000000000007e-129 < c < 3.10000000000000026e-29

    1. Initial program 69.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.4999999999999999e81 < c

    1. Initial program 37.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.9 \cdot 10^{+135}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a \cdot \frac{d}{c} - b\right)\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-129}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-29}:\\ \;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.5 \cdot 10^{+81}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - a \cdot \frac{d}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 77.2% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\
\mathbf{if}\;c \leq -2.8 \cdot 10^{+135}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;c \leq -1.12 \cdot 10^{-138}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 1.12 \cdot 10^{+86}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.80000000000000002e135 or 1.12e86 < c

    1. Initial program 33.9%

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

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

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

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

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

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

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

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

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

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

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

    if -2.80000000000000002e135 < c < -1.1199999999999999e-138 or 2.1999999999999999e-29 < c < 1.12e86

    1. Initial program 84.2%

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

    if -1.1199999999999999e-138 < c < 2.1999999999999999e-29

    1. Initial program 69.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.8 \cdot 10^{+135}:\\ \;\;\;\;\frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\ \mathbf{elif}\;c \leq -1.12 \cdot 10^{-138}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{-29}:\\ \;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 1.12 \cdot 10^{+86}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 76.2% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\
\mathbf{if}\;c \leq -1.3 \cdot 10^{+134}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;c \leq -6.8 \cdot 10^{-140}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 5.5 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.3000000000000001e134 or 5.50000000000000007e79 < c

    1. Initial program 33.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1.3000000000000001e134 < c < -6.80000000000000017e-140 or 2.8000000000000001e-179 < c < 5.50000000000000007e79

    1. Initial program 81.6%

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

    if -6.80000000000000017e-140 < c < 2.8000000000000001e-179

    1. Initial program 66.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.3 \cdot 10^{+134}:\\ \;\;\;\;\frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\ \mathbf{elif}\;c \leq -6.8 \cdot 10^{-140}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-179}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 64.7% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;c \leq -2.3 \cdot 10^{-84}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 5.2 \cdot 10^{+83}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.4500000000000001e92 or 5.2000000000000002e83 < c

    1. Initial program 38.4%

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

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

    if -2.4500000000000001e92 < c < -2.29999999999999981e-84 or 5.00000000000000019e-26 < c < 5.2000000000000002e83

    1. Initial program 81.1%

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

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

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

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

    if -2.29999999999999981e-84 < c < 5.00000000000000019e-26

    1. Initial program 72.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.45 \cdot 10^{+92}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -2.3 \cdot 10^{-84}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 5 \cdot 10^{-26}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;c \leq 5.2 \cdot 10^{+83}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 67.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\
\mathbf{if}\;c \leq -4.1 \cdot 10^{+89}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;c \leq -8 \cdot 10^{-85}:\\
\;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -4.09999999999999985e89 or 4.20000000000000005e-25 < c

    1. Initial program 47.3%

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

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

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

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

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

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

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

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

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

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

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

    if -4.09999999999999985e89 < c < -7.9999999999999998e-85

    1. Initial program 87.0%

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

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

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

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

    if -7.9999999999999998e-85 < c < 4.20000000000000005e-25

    1. Initial program 72.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.1 \cdot 10^{+89}:\\ \;\;\;\;\frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\ \mathbf{elif}\;c \leq -8 \cdot 10^{-85}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 4.2 \cdot 10^{-25}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - a \cdot \left(\frac{d}{c} \cdot \frac{1}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 62.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.02 \cdot 10^{+61} \lor \neg \left(d \leq 6.8 \cdot 10^{-59}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.01999999999999999e61 or 6.80000000000000035e-59 < d

    1. Initial program 55.1%

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

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

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

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

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

    if -1.01999999999999999e61 < d < 6.80000000000000035e-59

    1. Initial program 71.6%

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

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

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

Alternative 16: 9.9% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 42.4% accurate, 5.0× speedup?

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

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

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

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

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

Developer target: 99.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (< (fabs d) (fabs c))
   (/ (- b (* a (/ d c))) (+ c (* d (/ d c))))
   (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (abs(d) < abs(c)) then
        tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (Math.abs(d) < Math.abs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (abs(d) < abs(c))
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (abs(d) < abs(c))
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

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


\end{array}
\end{array}

Reproduce

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

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

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