Complex division, imag part

Percentage Accurate: 62.4% → 96.3%
Time: 12.3s
Alternatives: 13
Speedup: 1.8×

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.4% 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: 96.3% accurate, 0.0× speedup?

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

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

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Step-by-step derivation
    1. div-sub60.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. add-sqr-sqrt60.7%

      \[\leadsto \frac{b \cdot c}{\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} \]
    3. pow260.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.4% accurate, 0.0× speedup?

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

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

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Step-by-step derivation
    1. div-sub60.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. add-sqr-sqrt60.7%

      \[\leadsto \frac{b \cdot c}{\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} \]
    3. pow260.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 82.6% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\
t_1 := c \cdot c + d \cdot d\\
t_2 := \frac{c \cdot b - d \cdot a}{t_1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_2 \leq -5 \cdot 10^{-292}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{-a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0 or 1.9999999999999998e202 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 25.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub17.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. add-sqr-sqrt17.6%

        \[\leadsto \frac{b \cdot c}{\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} \]
      3. pow217.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -4.99999999999999981e-292

    1. Initial program 99.3%

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

    if -4.99999999999999981e-292 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 0.0

    1. Initial program 62.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\frac{a}{\frac{{c}^{2} + {d}^{2}}{d}}} \]
      3. distribute-neg-frac62.0%

        \[\leadsto \color{blue}{\frac{-a}{\frac{{c}^{2} + {d}^{2}}{d}}} \]
      4. +-commutative62.0%

        \[\leadsto \frac{-a}{\frac{\color{blue}{{d}^{2} + {c}^{2}}}{d}} \]
      5. unpow262.0%

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

        \[\leadsto \frac{-a}{\frac{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}}{d}} \]
    7. Simplified62.0%

      \[\leadsto \color{blue}{\frac{-a}{\frac{\mathsf{fma}\left(d, d, {c}^{2}\right)}{d}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt62.0%

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

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

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

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

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

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

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

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

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

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

    if 0.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.9999999999999998e202

    1. Initial program 99.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq -\infty:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{elif}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq -5 \cdot 10^{-292}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 0:\\ \;\;\;\;\frac{-a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\ \mathbf{elif}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+202}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \end{array} \]

Alternative 4: 83.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{if}\;c \leq -3.3 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.8 \cdot 10^{-158}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{t_0}\\ \mathbf{elif}\;c \leq 2.15 \cdot 10^{-148}:\\ \;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 7.6 \cdot 10^{+27}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{t_0}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (+ (* c c) (* d d))) (t_1 (- (/ b c) (/ a (fma c (/ c d) d)))))
   (if (<= c -3.3e+102)
     t_1
     (if (<= c -1.8e-158)
       (/ (- (* c b) (* d a)) t_0)
       (if (<= c 2.15e-148)
         (- (/ b (* d (/ d c))) (/ a d))
         (if (<= c 7.6e+27) (/ (fma c b (* d (- a))) t_0) t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * c) + (d * d);
	double t_1 = (b / c) - (a / fma(c, (c / d), d));
	double tmp;
	if (c <= -3.3e+102) {
		tmp = t_1;
	} else if (c <= -1.8e-158) {
		tmp = ((c * b) - (d * a)) / t_0;
	} else if (c <= 2.15e-148) {
		tmp = (b / (d * (d / c))) - (a / d);
	} else if (c <= 7.6e+27) {
		tmp = fma(c, b, (d * -a)) / t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(c * c) + Float64(d * d))
	t_1 = Float64(Float64(b / c) - Float64(a / fma(c, Float64(c / d), d)))
	tmp = 0.0
	if (c <= -3.3e+102)
		tmp = t_1;
	elseif (c <= -1.8e-158)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / t_0);
	elseif (c <= 2.15e-148)
		tmp = Float64(Float64(b / Float64(d * Float64(d / c))) - Float64(a / d));
	elseif (c <= 7.6e+27)
		tmp = Float64(fma(c, b, Float64(d * Float64(-a))) / t_0);
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.3e+102], t$95$1, If[LessEqual[c, -1.8e-158], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[c, 2.15e-148], N[(N[(b / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.6e+27], N[(N[(c * b + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.8 \cdot 10^{-158}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{t_0}\\

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

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -3.29999999999999999e102 or 7.60000000000000043e27 < c

    1. Initial program 40.0%

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

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

        \[\leadsto \frac{b \cdot c}{\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} \]
      3. pow240.0%

        \[\leadsto \frac{b \cdot c}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. hypot-def40.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.29999999999999999e102 < c < -1.79999999999999995e-158

    1. Initial program 81.5%

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

    if -1.79999999999999995e-158 < c < 2.1499999999999999e-148

    1. Initial program 68.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
    7. Simplified84.9%

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

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

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

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

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

    if 2.1499999999999999e-148 < c < 7.60000000000000043e27

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.3 \cdot 10^{+102}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{elif}\;c \leq -1.8 \cdot 10^{-158}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.15 \cdot 10^{-148}:\\ \;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 7.6 \cdot 10^{+27}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \end{array} \]

Alternative 5: 83.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{if}\;c \leq -3.3 \cdot 10^{+102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.5 \cdot 10^{-158}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 4 \cdot 10^{-149}:\\ \;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+28}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
        (t_1 (- (/ b c) (/ a (fma c (/ c d) d)))))
   (if (<= c -3.3e+102)
     t_1
     (if (<= c -3.5e-158)
       t_0
       (if (<= c 4e-149)
         (- (/ b (* d (/ d c))) (/ a d))
         (if (<= c 2.1e+28) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = (b / c) - (a / fma(c, (c / d), d));
	double tmp;
	if (c <= -3.3e+102) {
		tmp = t_1;
	} else if (c <= -3.5e-158) {
		tmp = t_0;
	} else if (c <= 4e-149) {
		tmp = (b / (d * (d / c))) - (a / d);
	} else if (c <= 2.1e+28) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(Float64(b / c) - Float64(a / fma(c, Float64(c / d), d)))
	tmp = 0.0
	if (c <= -3.3e+102)
		tmp = t_1;
	elseif (c <= -3.5e-158)
		tmp = t_0;
	elseif (c <= 4e-149)
		tmp = Float64(Float64(b / Float64(d * Float64(d / c))) - Float64(a / d));
	elseif (c <= 2.1e+28)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.3e+102], t$95$1, If[LessEqual[c, -3.5e-158], t$95$0, If[LessEqual[c, 4e-149], N[(N[(b / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e+28], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -3.5 \cdot 10^{-158}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 2.1 \cdot 10^{+28}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.29999999999999999e102 or 2.09999999999999989e28 < c

    1. Initial program 40.0%

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

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

        \[\leadsto \frac{b \cdot c}{\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} \]
      3. pow240.0%

        \[\leadsto \frac{b \cdot c}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. hypot-def40.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.29999999999999999e102 < c < -3.50000000000000012e-158 or 3.99999999999999992e-149 < c < 2.09999999999999989e28

    1. Initial program 84.7%

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

    if -3.50000000000000012e-158 < c < 3.99999999999999992e-149

    1. Initial program 68.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
    7. Simplified84.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.3 \cdot 10^{+102}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{elif}\;c \leq -3.5 \cdot 10^{-158}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 4 \cdot 10^{-149}:\\ \;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+28}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \end{array} \]

Alternative 6: 70.2% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;c \leq -6.4 \cdot 10^{-139}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 3400000000000:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.7999999999999998e-4 or 3.4e12 < c

    1. Initial program 48.9%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/75.0%

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

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

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

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

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

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

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

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

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

    if -2.7999999999999998e-4 < c < -6.3999999999999999e-139 or 3.7e-32 < c < 3.4e12

    1. Initial program 86.8%

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

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

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

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

    if -6.3999999999999999e-139 < c < 3.7e-32

    1. Initial program 73.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -0.00028:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -6.4 \cdot 10^{-139}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.7 \cdot 10^{-32}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 3400000000000:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \end{array} \]

Alternative 7: 79.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -5 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -5.5 \cdot 10^{-158}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{-17}:\\ \;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (/ b c) (* d (/ (/ a c) c)))))
   (if (<= c -5e+102)
     t_0
     (if (<= c -5.5e-158)
       (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
       (if (<= c 1.45e-17) (- (/ b (* d (/ d c))) (/ a d)) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = (b / c) - (d * ((a / c) / c));
	double tmp;
	if (c <= -5e+102) {
		tmp = t_0;
	} else if (c <= -5.5e-158) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (c <= 1.45e-17) {
		tmp = (b / (d * (d / c))) - (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) - (d * ((a / c) / c))
    if (c <= (-5d+102)) then
        tmp = t_0
    else if (c <= (-5.5d-158)) then
        tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
    else if (c <= 1.45d-17) then
        tmp = (b / (d * (d / c))) - (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) - (d * ((a / c) / c));
	double tmp;
	if (c <= -5e+102) {
		tmp = t_0;
	} else if (c <= -5.5e-158) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (c <= 1.45e-17) {
		tmp = (b / (d * (d / c))) - (a / d);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b / c) - (d * ((a / c) / c))
	tmp = 0
	if c <= -5e+102:
		tmp = t_0
	elif c <= -5.5e-158:
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
	elif c <= 1.45e-17:
		tmp = (b / (d * (d / c))) - (a / d)
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c)))
	tmp = 0.0
	if (c <= -5e+102)
		tmp = t_0;
	elseif (c <= -5.5e-158)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 1.45e-17)
		tmp = Float64(Float64(b / Float64(d * Float64(d / c))) - Float64(a / d));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b / c) - (d * ((a / c) / c));
	tmp = 0.0;
	if (c <= -5e+102)
		tmp = t_0;
	elseif (c <= -5.5e-158)
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	elseif (c <= 1.45e-17)
		tmp = (b / (d * (d / c))) - (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[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5e+102], t$95$0, If[LessEqual[c, -5.5e-158], 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, 1.45e-17], N[(N[(b / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5e102 or 1.4500000000000001e-17 < c

    1. Initial program 46.3%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/75.8%

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

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

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

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

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

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

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

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

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

    if -5e102 < c < -5.50000000000000025e-158

    1. Initial program 81.5%

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

    if -5.50000000000000025e-158 < c < 1.4500000000000001e-17

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    6. 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. associate-/l*85.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5 \cdot 10^{+102}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -5.5 \cdot 10^{-158}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{-17}:\\ \;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \end{array} \]

Alternative 8: 69.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.9 \cdot 10^{-87} \lor \neg \left(c \leq 1.18 \cdot 10^{-30}\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.8999999999999999e-87 or 1.18000000000000006e-30 < c

    1. Initial program 55.7%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/70.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{\frac{a}{c}}}{c} \cdot d \]
    8. Simplified73.8%

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

    if -2.8999999999999999e-87 < c < 1.18000000000000006e-30

    1. Initial program 74.9%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified71.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.9 \cdot 10^{-87} \lor \neg \left(c \leq 1.18 \cdot 10^{-30}\right):\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]

Alternative 9: 76.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -0.0215 \lor \neg \left(c \leq 2.4 \cdot 10^{-17}\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -0.021499999999999998 or 2.39999999999999986e-17 < c

    1. Initial program 51.7%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/73.7%

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

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

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

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

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

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

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

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

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

    if -0.021499999999999998 < c < 2.39999999999999986e-17

    1. Initial program 76.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -0.0215 \lor \neg \left(c \leq 2.4 \cdot 10^{-17}\right):\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\ \end{array} \]

Alternative 10: 64.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.65 \cdot 10^{+32} \lor \neg \left(c \leq 2.26 \cdot 10^{-29}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.6500000000000001e32 or 2.25999999999999991e-29 < c

    1. Initial program 51.4%

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

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

    if -1.6500000000000001e32 < c < 2.25999999999999991e-29

    1. Initial program 75.7%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified66.6%

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

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

Alternative 11: 15.2% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.02 \cdot 10^{+68} \lor \neg \left(d \leq 2.2 \cdot 10^{+69}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.02e68 or 2.2000000000000002e69 < d

    1. Initial program 47.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.02e68 < d < 2.2000000000000002e69

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.02 \cdot 10^{+68} \lor \neg \left(d \leq 2.2 \cdot 10^{+69}\right):\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]

Alternative 12: 47.3% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{+152} \lor \neg \left(d \leq 3.5 \cdot 10^{+77}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -8.1999999999999996e152 or 3.5000000000000001e77 < d

    1. Initial program 44.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.1999999999999996e152 < d < 3.5000000000000001e77

    1. Initial program 71.5%

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

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

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

Alternative 13: 9.7% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  11. Final simplification10.6%

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

Developer target: 99.4% 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 2023332 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

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

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