Complex division, imag part

Percentage Accurate: 62.2% → 97.4%
Time: 15.7s
Alternatives: 13
Speedup: 0.7×

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 13 alternatives:

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

Initial Program: 62.2% accurate, 1.0× speedup?

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

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

Alternative 1: 97.4% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{hypot}\left(d, c\right)}\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a \cdot \frac{d}{\mathsf{hypot}\left(d, c\right)}}{t\_0} \cdot \frac{-1}{t\_0}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 61.5%

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. div-sub59.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. *-commutative59.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-sqrt59.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-frac62.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-neg62.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-define62.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-define78.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*81.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-sqrt81.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. pow281.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-define81.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-rr81.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. associate-*r/78.5%

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

      \[\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 \mathsf{hypot}\left(c, d\right)}}\right) \]
    3. associate-/r*86.7%

      \[\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) \]
    4. *-commutative86.7%

      \[\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) \]
    5. hypot-undefine78.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}{\sqrt{c \cdot c + d \cdot d}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
    6. pow278.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}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
    7. +-commutative78.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}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
    8. pow278.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}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
    9. hypot-define86.7%

      \[\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) \]
    10. hypot-undefine78.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}{\sqrt{c \cdot c + d \cdot d}}}\right) \]
    11. pow278.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)}}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}}\right) \]
    12. +-commutative78.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)}}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}}\right) \]
    13. pow278.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)}}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}}\right) \]
    14. hypot-define86.7%

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

    \[\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) \]
  7. Step-by-step derivation
    1. *-un-lft-identity86.7%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 92.1% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq 2.26 \cdot 10^{+105}:\\
\;\;\;\;\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}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, \frac{a}{t\_2} \cdot \frac{-1}{t\_2}\right)\\


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

    1. Initial program 26.7%

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

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac26.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-neg26.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-define26.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-define33.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*40.5%

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

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

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

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

      \[\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 b around 0 26.9%

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(a \cdot d\right)}{{c}^{2} + {d}^{2}}} \]
      2. *-commutative26.9%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(d \cdot a\right)}}{{c}^{2} + {d}^{2}} \]
      3. rem-square-sqrt26.9%

        \[\leadsto \frac{-1 \cdot \left(d \cdot a\right)}{\color{blue}{\sqrt{{c}^{2} + {d}^{2}} \cdot \sqrt{{c}^{2} + {d}^{2}}}} \]
      4. +-commutative26.9%

        \[\leadsto \frac{-1 \cdot \left(d \cdot a\right)}{\sqrt{\color{blue}{{d}^{2} + {c}^{2}}} \cdot \sqrt{{c}^{2} + {d}^{2}}} \]
      5. unpow226.9%

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

        \[\leadsto \frac{-1 \cdot \left(d \cdot a\right)}{\sqrt{d \cdot d + \color{blue}{c \cdot c}} \cdot \sqrt{{c}^{2} + {d}^{2}}} \]
      7. hypot-undefine26.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{d \cdot a}{{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}} \]
      15. distribute-frac-neg226.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d \cdot a}{-\color{blue}{\left(c \cdot c + d \cdot d\right)}} \]
      7. distribute-frac-neg226.9%

        \[\leadsto \color{blue}{-\frac{d \cdot a}{c \cdot c + d \cdot d}} \]
      8. +-commutative26.9%

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

        \[\leadsto -\frac{d \cdot a}{\color{blue}{\sqrt{d \cdot d + c \cdot c} \cdot \sqrt{d \cdot d + c \cdot c}}} \]
      10. hypot-undefine26.9%

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

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

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

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

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

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

    if -3.19999999999999989e119 < d < 2.2600000000000001e105

    1. Initial program 72.5%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*92.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-sqrt92.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. pow292.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-define92.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-rr92.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. Step-by-step derivation
      1. associate-*r/90.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}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}}\right) \]
      2. unpow290.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 \mathsf{hypot}\left(c, d\right)}}\right) \]
      3. associate-/r*95.3%

        \[\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) \]
      4. *-commutative95.3%

        \[\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) \]
      5. hypot-undefine91.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) \]
      6. pow291.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}{{c}^{2}} + d \cdot d}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      7. +-commutative91.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}^{2}}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      8. pow291.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{d \cdot d + \color{blue}{c \cdot c}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      9. hypot-define95.3%

        \[\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) \]
      10. hypot-undefine91.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) \]
      11. pow291.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}{{c}^{2}} + d \cdot d}}\right) \]
      12. +-commutative91.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}^{2}}}}\right) \]
      13. pow291.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{d \cdot d + \color{blue}{c \cdot c}}}\right) \]
      14. hypot-define95.3%

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

      \[\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 2.2600000000000001e105 < d

    1. Initial program 37.5%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub37.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. *-commutative37.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-sqrt37.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-frac40.5%

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

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

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

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

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

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

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

      \[\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. associate-*r/57.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 \cdot d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}}\right) \]
      2. unpow257.3%

        \[\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 \mathsf{hypot}\left(c, d\right)}}\right) \]
      3. associate-/r*72.5%

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

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

        \[\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) \]
      6. pow257.3%

        \[\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}{{c}^{2}} + d \cdot d}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      7. +-commutative57.3%

        \[\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}^{2}}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      8. pow257.3%

        \[\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{d \cdot d + \color{blue}{c \cdot c}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      9. hypot-define72.5%

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

        \[\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) \]
      11. pow257.3%

        \[\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}{{c}^{2}} + d \cdot d}}\right) \]
      12. +-commutative57.3%

        \[\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}^{2}}}}\right) \]
      13. pow257.3%

        \[\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{d \cdot d + \color{blue}{c \cdot c}}}\right) \]
      14. hypot-define72.5%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.2 \cdot 10^{+119}:\\ \;\;\;\;\frac{d \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{elif}\;d \leq 2.26 \cdot 10^{+105}:\\ \;\;\;\;\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}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{\sqrt{\mathsf{hypot}\left(d, c\right)}} \cdot \frac{-1}{\sqrt{\mathsf{hypot}\left(d, c\right)}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 91.2% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq 1.15 \cdot 10^{+173}:\\
\;\;\;\;\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}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot \frac{1}{d}, \frac{b}{d}, \frac{a}{-d}\right)\\


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

    1. Initial program 26.7%

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

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac26.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-neg26.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-define26.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-define33.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*40.5%

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

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

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

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

      \[\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 b around 0 26.9%

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(a \cdot d\right)}{{c}^{2} + {d}^{2}}} \]
      2. *-commutative26.9%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(d \cdot a\right)}}{{c}^{2} + {d}^{2}} \]
      3. rem-square-sqrt26.9%

        \[\leadsto \frac{-1 \cdot \left(d \cdot a\right)}{\color{blue}{\sqrt{{c}^{2} + {d}^{2}} \cdot \sqrt{{c}^{2} + {d}^{2}}}} \]
      4. +-commutative26.9%

        \[\leadsto \frac{-1 \cdot \left(d \cdot a\right)}{\sqrt{\color{blue}{{d}^{2} + {c}^{2}}} \cdot \sqrt{{c}^{2} + {d}^{2}}} \]
      5. unpow226.9%

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

        \[\leadsto \frac{-1 \cdot \left(d \cdot a\right)}{\sqrt{d \cdot d + \color{blue}{c \cdot c}} \cdot \sqrt{{c}^{2} + {d}^{2}}} \]
      7. hypot-undefine26.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{d \cdot a}{{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}} \]
      15. distribute-frac-neg226.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d \cdot a}{-\color{blue}{\left(c \cdot c + d \cdot d\right)}} \]
      7. distribute-frac-neg226.9%

        \[\leadsto \color{blue}{-\frac{d \cdot a}{c \cdot c + d \cdot d}} \]
      8. +-commutative26.9%

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

        \[\leadsto -\frac{d \cdot a}{\color{blue}{\sqrt{d \cdot d + c \cdot c} \cdot \sqrt{d \cdot d + c \cdot c}}} \]
      10. hypot-undefine26.9%

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

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

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

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

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

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

    if -1.54999999999999993e118 < d < 1.14999999999999997e173

    1. Initial program 71.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub68.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. *-commutative68.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-sqrt68.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-frac72.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-neg72.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-define72.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-define90.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*91.9%

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

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

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

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

      \[\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. associate-*r/90.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 \cdot d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}}\right) \]
      2. unpow290.3%

        \[\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 \mathsf{hypot}\left(c, d\right)}}\right) \]
      3. associate-/r*95.0%

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

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

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

        \[\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}{{c}^{2}} + d \cdot d}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      7. +-commutative90.4%

        \[\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}^{2}}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      8. pow290.4%

        \[\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{d \cdot d + \color{blue}{c \cdot c}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      9. hypot-define95.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}{\mathsf{hypot}\left(d, c\right)}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
      10. hypot-undefine90.4%

        \[\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) \]
      11. pow290.4%

        \[\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}{{c}^{2}} + d \cdot d}}\right) \]
      12. +-commutative90.4%

        \[\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}^{2}}}}\right) \]
      13. pow290.4%

        \[\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{d \cdot d + \color{blue}{c \cdot c}}}\right) \]
      14. hypot-define95.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}{\mathsf{hypot}\left(d, c\right)}}\right) \]
    6. Applied egg-rr95.0%

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

    if 1.14999999999999997e173 < d

    1. Initial program 34.7%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto c \cdot \color{blue}{\left(\frac{1}{d} \cdot \frac{b}{d}\right)} - \frac{a}{d} \]
    8. Step-by-step derivation
      1. associate-*r*96.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.55 \cdot 10^{+118}:\\ \;\;\;\;\frac{d \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{elif}\;d \leq 1.15 \cdot 10^{+173}:\\ \;\;\;\;\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}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot \frac{1}{d}, \frac{b}{d}, \frac{a}{-d}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 88.7% accurate, 0.0× speedup?

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

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

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

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


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

    1. Initial program 27.5%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub27.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. *-commutative27.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-sqrt27.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-frac27.6%

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define33.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*38.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-sqrt38.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. pow238.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-define38.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-rr38.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. Taylor expanded in b around 0 27.6%

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

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

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(d \cdot a\right)}}{{c}^{2} + {d}^{2}} \]
      3. rem-square-sqrt27.6%

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

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

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

        \[\leadsto \frac{-1 \cdot \left(d \cdot a\right)}{\sqrt{d \cdot d + \color{blue}{c \cdot c}} \cdot \sqrt{{c}^{2} + {d}^{2}}} \]
      7. hypot-undefine27.6%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{d \cdot a}{{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}} \]
      15. distribute-frac-neg227.6%

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

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

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

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

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

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

        \[\leadsto \frac{d \cdot a}{-\sqrt{d \cdot d + c \cdot c} \cdot \color{blue}{\sqrt{d \cdot d + c \cdot c}}} \]
      5. add-sqr-sqrt27.6%

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

        \[\leadsto \frac{d \cdot a}{-\color{blue}{\left(c \cdot c + d \cdot d\right)}} \]
      7. distribute-frac-neg227.6%

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

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

        \[\leadsto -\frac{d \cdot a}{\color{blue}{\sqrt{d \cdot d + c \cdot c} \cdot \sqrt{d \cdot d + c \cdot c}}} \]
      10. hypot-undefine27.6%

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

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

        \[\leadsto -\color{blue}{\frac{\frac{d \cdot a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}} \]
      13. distribute-neg-frac249.9%

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

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

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

    if -1.75e121 < d < 9.0000000000000003e141

    1. Initial program 71.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub68.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. *-commutative68.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-sqrt68.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-frac72.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-neg72.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-define72.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-define90.2%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*92.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-sqrt92.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. pow292.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-define92.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-rr92.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)} \]

    if 9.0000000000000003e141 < d

    1. Initial program 38.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto c \cdot \color{blue}{\left(\frac{1}{d} \cdot \frac{b}{d}\right)} - \frac{a}{d} \]
    8. Step-by-step derivation
      1. associate-*r*94.7%

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

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

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

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

Alternative 5: 85.6% 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 \infty:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{b \cdot \frac{c}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= (/ (- (* c b) (* d a)) (+ (* c c) (* d d))) INFINITY)
   (* (/ 1.0 (hypot c d)) (/ (fma b c (* d (- a))) (hypot c d)))
   (/ (* b (/ c (hypot d c))) (hypot d c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((((c * b) - (d * a)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
		tmp = (1.0 / hypot(c, d)) * (fma(b, c, (d * -a)) / hypot(c, d));
	} else {
		tmp = (b * (c / hypot(d, c))) / hypot(d, c);
	}
	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))) <= Inf)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(d * Float64(-a))) / hypot(c, d)));
	else
		tmp = Float64(Float64(b * Float64(c / hypot(d, c))) / hypot(d, c));
	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], Infinity], 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[(b * N[(c / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{b \cdot \frac{c}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\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))) < +inf.0

    1. Initial program 77.1%

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

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

        \[\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-frac77.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-define77.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-neg77.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-in77.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-define94.0%

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

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

    1. Initial program 0.0%

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

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

        \[\leadsto \color{blue}{b \cdot \frac{c}{{c}^{2} + {d}^{2}}} \]
      2. +-commutative4.2%

        \[\leadsto b \cdot \frac{c}{\color{blue}{{d}^{2} + {c}^{2}}} \]
      3. unpow24.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{c \cdot b} \cdot \sqrt{c \cdot b}}{\mathsf{hypot}\left(c, d\right) \cdot \mathsf{hypot}\left(c, d\right)}} \]
      15. add-sqr-sqrt1.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq \infty:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{b \cdot \frac{c}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 78.7% accurate, 0.1× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.1000000000000002e37 or 5.4e26 < c

    1. Initial program 47.6%

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

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

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

        \[\leadsto b \cdot \frac{c}{\color{blue}{{d}^{2} + {c}^{2}}} \]
      3. unpow249.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{c \cdot b} \cdot \sqrt{c \cdot b}}{\mathsf{hypot}\left(c, d\right) \cdot \mathsf{hypot}\left(c, d\right)}} \]
      15. add-sqr-sqrt44.2%

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

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

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

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

    if -3.1000000000000002e37 < c < -8.3999999999999994e-126

    1. Initial program 82.6%

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

    if -8.3999999999999994e-126 < c < 5.4e26

    1. Initial program 72.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 76.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b}{c} - a \cdot \frac{d}{{c}^{2}}\\ \mathbf{if}\;c \leq -5 \cdot 10^{+69}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq -8 \cdot 10^{-126}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{+46}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \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 (pow c 2.0))))))
   (if (<= c -5e+69)
     t_0
     (if (<= c -8e-126)
       (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
       (if (<= c 5.4e+46) (- (/ (/ (* c b) d) d) (/ a d)) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = (b / c) - (a * (d / pow(c, 2.0)));
	double tmp;
	if (c <= -5e+69) {
		tmp = t_0;
	} else if (c <= -8e-126) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (c <= 5.4e+46) {
		tmp = (((c * b) / d) / d) - (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 ** 2.0d0)))
    if (c <= (-5d+69)) then
        tmp = t_0
    else if (c <= (-8d-126)) then
        tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
    else if (c <= 5.4d+46) then
        tmp = (((c * b) / d) / d) - (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 / Math.pow(c, 2.0)));
	double tmp;
	if (c <= -5e+69) {
		tmp = t_0;
	} else if (c <= -8e-126) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (c <= 5.4e+46) {
		tmp = (((c * b) / d) / d) - (a / d);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b / c) - (a * (d / math.pow(c, 2.0)))
	tmp = 0
	if c <= -5e+69:
		tmp = t_0
	elif c <= -8e-126:
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
	elif c <= 5.4e+46:
		tmp = (((c * b) / d) / d) - (a / d)
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b / c) - Float64(a * Float64(d / (c ^ 2.0))))
	tmp = 0.0
	if (c <= -5e+69)
		tmp = t_0;
	elseif (c <= -8e-126)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 5.4e+46)
		tmp = Float64(Float64(Float64(Float64(c * b) / d) / d) - Float64(a / d));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b / c) - (a * (d / (c ^ 2.0)));
	tmp = 0.0;
	if (c <= -5e+69)
		tmp = t_0;
	elseif (c <= -8e-126)
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	elseif (c <= 5.4e+46)
		tmp = (((c * b) / d) / d) - (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[(d / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5e+69], t$95$0, If[LessEqual[c, -8e-126], 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, 5.4e+46], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.00000000000000036e69 or 5.4000000000000003e46 < c

    1. Initial program 46.1%

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

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

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

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

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

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

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

    if -5.00000000000000036e69 < c < -7.9999999999999996e-126

    1. Initial program 78.4%

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

    if -7.9999999999999996e-126 < c < 5.4000000000000003e46

    1. Initial program 73.2%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5 \cdot 10^{+69}:\\ \;\;\;\;\frac{b}{c} - a \cdot \frac{d}{{c}^{2}}\\ \mathbf{elif}\;c \leq -8 \cdot 10^{-126}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{+46}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - a \cdot \frac{d}{{c}^{2}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 70.0% accurate, 0.5× speedup?

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

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

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

\mathbf{elif}\;c \leq -1.2 \cdot 10^{-98} \lor \neg \left(c \leq 1.25 \cdot 10^{+44}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.3999999999999999e65 or -2.7499999999999998e-9 < c < -1.20000000000000002e-98 or 1.2499999999999999e44 < c

    1. Initial program 50.3%

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

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

    if -3.3999999999999999e65 < c < -2.7499999999999998e-9

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto c \cdot \color{blue}{\left(\frac{1}{d} \cdot \frac{b}{d}\right)} - \frac{a}{d} \]
    8. Step-by-step derivation
      1. associate-*l/63.8%

        \[\leadsto c \cdot \color{blue}{\frac{1 \cdot \frac{b}{d}}{d}} - \frac{a}{d} \]
      2. *-un-lft-identity63.8%

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

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

    if -1.20000000000000002e-98 < c < 1.2499999999999999e44

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.4 \cdot 10^{+65}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -2.75 \cdot 10^{-9}:\\ \;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq -1.2 \cdot 10^{-98} \lor \neg \left(c \leq 1.25 \cdot 10^{+44}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 71.3% accurate, 0.5× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -4.6e65 or 7.7999999999999999e45 < c

    1. Initial program 46.1%

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

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

    if -4.6e65 < c < -1.08000000000000001e-7

    1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto c \cdot \color{blue}{\left(\frac{1}{d} \cdot \frac{b}{d}\right)} - \frac{a}{d} \]
    8. Step-by-step derivation
      1. associate-*l/63.8%

        \[\leadsto c \cdot \color{blue}{\frac{1 \cdot \frac{b}{d}}{d}} - \frac{a}{d} \]
      2. *-un-lft-identity63.8%

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

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

    if -1.08000000000000001e-7 < c < -1.04999999999999996e-98

    1. Initial program 80.9%

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

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

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

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

    if -1.04999999999999996e-98 < c < 7.7999999999999999e45

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.6 \cdot 10^{+65}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -1.08 \cdot 10^{-7}:\\ \;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq -1.05 \cdot 10^{-98}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{+45}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 75.5% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.2499999999999998e106 or 7.8000000000000005e47 < c

    1. Initial program 43.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.1%

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

    if -2.2499999999999998e106 < c < -1.90000000000000001e-127

    1. Initial program 78.5%

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

    if -1.90000000000000001e-127 < c < 7.8000000000000005e47

    1. Initial program 73.2%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.25 \cdot 10^{+106}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-127}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{+47}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d}}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 62.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.6 \cdot 10^{+46} \lor \neg \left(c \leq -7.5 \cdot 10^{-5}\right) \land \left(c \leq -1.2 \cdot 10^{-98} \lor \neg \left(c \leq 1.25 \cdot 10^{+44}\right)\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.60000000000000013e46 or -7.49999999999999934e-5 < c < -1.20000000000000002e-98 or 1.2499999999999999e44 < c

    1. Initial program 51.4%

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

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

    if -2.60000000000000013e46 < c < -7.49999999999999934e-5 or -1.20000000000000002e-98 < c < 1.2499999999999999e44

    1. Initial program 73.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.6 \cdot 10^{+46} \lor \neg \left(c \leq -7.5 \cdot 10^{-5}\right) \land \left(c \leq -1.2 \cdot 10^{-98} \lor \neg \left(c \leq 1.25 \cdot 10^{+44}\right)\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{-d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 69.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.1 \cdot 10^{+68} \lor \neg \left(c \leq 2.6 \cdot 10^{+47}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.10000000000000001e68 or 2.60000000000000003e47 < c

    1. Initial program 46.1%

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

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

    if -2.10000000000000001e68 < c < 2.60000000000000003e47

    1. Initial program 74.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto c \cdot \color{blue}{\left(\frac{1}{d} \cdot \frac{b}{d}\right)} - \frac{a}{d} \]
    8. Step-by-step derivation
      1. associate-*l/73.1%

        \[\leadsto c \cdot \color{blue}{\frac{1 \cdot \frac{b}{d}}{d}} - \frac{a}{d} \]
      2. *-un-lft-identity73.1%

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

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

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

Alternative 13: 43.8% 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 61.5%

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

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

    \[\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 2024053 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (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))))