Complex division, imag part

Percentage Accurate: 61.7% → 84.9%
Time: 15.4s
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: 61.7% 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: 84.9% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq -1.65 \cdot 10^{-93}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;d \leq 3.35 \cdot 10^{+134}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \mathsf{fma}\left(-1, a, t_2\right)\\


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

    1. Initial program 41.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.09999999999999991e202 < d < -1.6500000000000001e-93 or 1.8e-99 < d < 3.3499999999999998e134

    1. Initial program 75.3%

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

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

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

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

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

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

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

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

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

    if -1.6500000000000001e-93 < d < 1.8e-99

    1. Initial program 58.1%

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

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

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

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

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

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

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

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

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

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

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

    if 3.3499999999999998e134 < d

    1. Initial program 36.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.1 \cdot 10^{+202}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\ \mathbf{elif}\;d \leq -1.65 \cdot 10^{-93}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{-99}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 3.35 \cdot 10^{+134}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \mathsf{fma}\left(-1, a, \frac{b}{\frac{d}{c}}\right)\\ \end{array} \]

Alternative 2: 82.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_2 := \frac{b}{\frac{d}{c}}\\ \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;t_1 \cdot \left(a - t_2\right)\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-93}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-86}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{+134}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \mathsf{fma}\left(-1, a, t_2\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
        (t_1 (/ 1.0 (hypot c d)))
        (t_2 (/ b (/ d c))))
   (if (<= d -1.6e+159)
     (* t_1 (- a t_2))
     (if (<= d -1.9e-93)
       t_0
       (if (<= d 8.5e-86)
         (* (/ -1.0 c) (- (/ (* d a) c) b))
         (if (<= d 3.8e+134) t_0 (* t_1 (fma -1.0 a t_2))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = 1.0 / hypot(c, d);
	double t_2 = b / (d / c);
	double tmp;
	if (d <= -1.6e+159) {
		tmp = t_1 * (a - t_2);
	} else if (d <= -1.9e-93) {
		tmp = t_0;
	} else if (d <= 8.5e-86) {
		tmp = (-1.0 / c) * (((d * a) / c) - b);
	} else if (d <= 3.8e+134) {
		tmp = t_0;
	} else {
		tmp = t_1 * fma(-1.0, a, t_2);
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(1.0 / hypot(c, d))
	t_2 = Float64(b / Float64(d / c))
	tmp = 0.0
	if (d <= -1.6e+159)
		tmp = Float64(t_1 * Float64(a - t_2));
	elseif (d <= -1.9e-93)
		tmp = t_0;
	elseif (d <= 8.5e-86)
		tmp = Float64(Float64(-1.0 / c) * Float64(Float64(Float64(d * a) / c) - b));
	elseif (d <= 3.8e+134)
		tmp = t_0;
	else
		tmp = Float64(t_1 * fma(-1.0, a, t_2));
	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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.6e+159], N[(t$95$1 * N[(a - t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.9e-93], t$95$0, If[LessEqual[d, 8.5e-86], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.8e+134], t$95$0, N[(t$95$1 * N[(-1.0 * a + t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.9 \cdot 10^{-93}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 3.8 \cdot 10^{+134}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \mathsf{fma}\left(-1, a, t_2\right)\\


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

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999992e159 < d < -1.8999999999999999e-93 or 8.499999999999999e-86 < d < 3.79999999999999998e134

    1. Initial program 78.3%

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

    if -1.8999999999999999e-93 < d < 8.499999999999999e-86

    1. Initial program 58.0%

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

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

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

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

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

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

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

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

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

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

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

    if 3.79999999999999998e134 < d

    1. Initial program 36.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\ \mathbf{elif}\;d \leq -1.9 \cdot 10^{-93}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-86}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{+134}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \mathsf{fma}\left(-1, a, \frac{b}{\frac{d}{c}}\right)\\ \end{array} \]

Alternative 3: 81.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\ \mathbf{elif}\;d \leq -4.5 \cdot 10^{-92}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.85 \cdot 10^{-91}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 1.02 \cdot 10^{+130}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}}{-\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -1.6e+159)
     (* (/ 1.0 (hypot c d)) (- a (/ b (/ d c))))
     (if (<= d -4.5e-92)
       t_0
       (if (<= d 1.85e-91)
         (* (/ -1.0 c) (- (/ (* d a) c) b))
         (if (<= d 1.02e+130)
           t_0
           (/ (* a (/ d (hypot c d))) (- (hypot c d)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -1.6e+159) {
		tmp = (1.0 / hypot(c, d)) * (a - (b / (d / c)));
	} else if (d <= -4.5e-92) {
		tmp = t_0;
	} else if (d <= 1.85e-91) {
		tmp = (-1.0 / c) * (((d * a) / c) - b);
	} else if (d <= 1.02e+130) {
		tmp = t_0;
	} else {
		tmp = (a * (d / hypot(c, d))) / -hypot(c, d);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -1.6e+159) {
		tmp = (1.0 / Math.hypot(c, d)) * (a - (b / (d / c)));
	} else if (d <= -4.5e-92) {
		tmp = t_0;
	} else if (d <= 1.85e-91) {
		tmp = (-1.0 / c) * (((d * a) / c) - b);
	} else if (d <= 1.02e+130) {
		tmp = t_0;
	} else {
		tmp = (a * (d / Math.hypot(c, d))) / -Math.hypot(c, d);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -1.6e+159:
		tmp = (1.0 / math.hypot(c, d)) * (a - (b / (d / c)))
	elif d <= -4.5e-92:
		tmp = t_0
	elif d <= 1.85e-91:
		tmp = (-1.0 / c) * (((d * a) / c) - b)
	elif d <= 1.02e+130:
		tmp = t_0
	else:
		tmp = (a * (d / math.hypot(c, d))) / -math.hypot(c, d)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -1.6e+159)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a - Float64(b / Float64(d / c))));
	elseif (d <= -4.5e-92)
		tmp = t_0;
	elseif (d <= 1.85e-91)
		tmp = Float64(Float64(-1.0 / c) * Float64(Float64(Float64(d * a) / c) - b));
	elseif (d <= 1.02e+130)
		tmp = t_0;
	else
		tmp = Float64(Float64(a * Float64(d / hypot(c, d))) / Float64(-hypot(c, d)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -1.6e+159)
		tmp = (1.0 / hypot(c, d)) * (a - (b / (d / c)));
	elseif (d <= -4.5e-92)
		tmp = t_0;
	elseif (d <= 1.85e-91)
		tmp = (-1.0 / c) * (((d * a) / c) - b);
	elseif (d <= 1.02e+130)
		tmp = t_0;
	else
		tmp = (a * (d / hypot(c, d))) / -hypot(c, d);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.6e+159], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a - N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.5e-92], t$95$0, If[LessEqual[d, 1.85e-91], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.02e+130], t$95$0, N[(N[(a * N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -4.5 \cdot 10^{-92}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 1.02 \cdot 10^{+130}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999992e159 < d < -4.5e-92 or 1.8500000000000001e-91 < d < 1.01999999999999999e130

    1. Initial program 78.6%

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

    if -4.5e-92 < d < 1.8500000000000001e-91

    1. Initial program 58.0%

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

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

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

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

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

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

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

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

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

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

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

    if 1.01999999999999999e130 < d

    1. Initial program 38.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a \cdot \color{blue}{\left(-1 \cdot d\right)}}{{c}^{2} + {d}^{2}} \]
      5. associate-*r/45.1%

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

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

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

        \[\leadsto a \cdot \frac{\color{blue}{-1 \cdot d}}{{c}^{2} + {d}^{2}} \]
      2. add-sqr-sqrt45.1%

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

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

        \[\leadsto a \cdot \frac{-1 \cdot d}{\sqrt{c \cdot c + \color{blue}{d \cdot d}} \cdot \sqrt{{c}^{2} + {d}^{2}}} \]
      5. hypot-udef45.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\ \mathbf{elif}\;d \leq -4.5 \cdot 10^{-92}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.85 \cdot 10^{-91}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 1.02 \cdot 10^{+130}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}}{-\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 4: 81.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;t_1 \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\ \mathbf{elif}\;d \leq -6.8 \cdot 10^{-92}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 4.8 \cdot 10^{-89}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 6.8 \cdot 10^{+60}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(\frac{c \cdot b}{d} - a\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
        (t_1 (/ 1.0 (hypot c d))))
   (if (<= d -1.6e+159)
     (* t_1 (- a (/ b (/ d c))))
     (if (<= d -6.8e-92)
       t_0
       (if (<= d 4.8e-89)
         (* (/ -1.0 c) (- (/ (* d a) c) b))
         (if (<= d 6.8e+60) t_0 (* t_1 (- (/ (* c b) d) a))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = 1.0 / hypot(c, d);
	double tmp;
	if (d <= -1.6e+159) {
		tmp = t_1 * (a - (b / (d / c)));
	} else if (d <= -6.8e-92) {
		tmp = t_0;
	} else if (d <= 4.8e-89) {
		tmp = (-1.0 / c) * (((d * a) / c) - b);
	} else if (d <= 6.8e+60) {
		tmp = t_0;
	} else {
		tmp = t_1 * (((c * b) / d) - a);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = 1.0 / Math.hypot(c, d);
	double tmp;
	if (d <= -1.6e+159) {
		tmp = t_1 * (a - (b / (d / c)));
	} else if (d <= -6.8e-92) {
		tmp = t_0;
	} else if (d <= 4.8e-89) {
		tmp = (-1.0 / c) * (((d * a) / c) - b);
	} else if (d <= 6.8e+60) {
		tmp = t_0;
	} else {
		tmp = t_1 * (((c * b) / d) - a);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	t_1 = 1.0 / math.hypot(c, d)
	tmp = 0
	if d <= -1.6e+159:
		tmp = t_1 * (a - (b / (d / c)))
	elif d <= -6.8e-92:
		tmp = t_0
	elif d <= 4.8e-89:
		tmp = (-1.0 / c) * (((d * a) / c) - b)
	elif d <= 6.8e+60:
		tmp = t_0
	else:
		tmp = t_1 * (((c * b) / d) - a)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(1.0 / hypot(c, d))
	tmp = 0.0
	if (d <= -1.6e+159)
		tmp = Float64(t_1 * Float64(a - Float64(b / Float64(d / c))));
	elseif (d <= -6.8e-92)
		tmp = t_0;
	elseif (d <= 4.8e-89)
		tmp = Float64(Float64(-1.0 / c) * Float64(Float64(Float64(d * a) / c) - b));
	elseif (d <= 6.8e+60)
		tmp = t_0;
	else
		tmp = Float64(t_1 * Float64(Float64(Float64(c * b) / d) - a));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	t_1 = 1.0 / hypot(c, d);
	tmp = 0.0;
	if (d <= -1.6e+159)
		tmp = t_1 * (a - (b / (d / c)));
	elseif (d <= -6.8e-92)
		tmp = t_0;
	elseif (d <= 4.8e-89)
		tmp = (-1.0 / c) * (((d * a) / c) - b);
	elseif (d <= 6.8e+60)
		tmp = t_0;
	else
		tmp = t_1 * (((c * b) / d) - a);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.6e+159], N[(t$95$1 * N[(a - N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6.8e-92], t$95$0, If[LessEqual[d, 4.8e-89], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.8e+60], t$95$0, N[(t$95$1 * N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -6.8 \cdot 10^{-92}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 6.8 \cdot 10^{+60}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999992e159 < d < -6.8000000000000005e-92 or 4.80000000000000032e-89 < d < 6.7999999999999999e60

    1. Initial program 80.2%

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

    if -6.8000000000000005e-92 < d < 4.80000000000000032e-89

    1. Initial program 58.0%

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

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

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

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

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

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

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

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

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

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

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

    if 6.7999999999999999e60 < d

    1. Initial program 48.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\ \mathbf{elif}\;d \leq -6.8 \cdot 10^{-92}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 4.8 \cdot 10^{-89}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 6.8 \cdot 10^{+60}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{c \cdot b}{d} - a\right)\\ \end{array} \]

Alternative 5: 81.3% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq -2.15 \cdot 10^{-92}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 8 \cdot 10^{+68}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999992e159 < d < -2.15000000000000007e-92 or 1.85000000000000016e-80 < d < 7.99999999999999962e68

    1. Initial program 79.3%

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

    if -2.15000000000000007e-92 < d < 1.85000000000000016e-80

    1. Initial program 58.0%

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

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

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

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

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

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

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

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

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

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

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

    if 7.99999999999999962e68 < d

    1. Initial program 49.1%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\ \mathbf{elif}\;d \leq -2.15 \cdot 10^{-92}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.85 \cdot 10^{-80}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 8 \cdot 10^{+68}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{c \cdot b}{d} - a\right) \cdot \frac{1}{d}\\ \end{array} \]

Alternative 6: 80.1% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq -4.3 \cdot 10^{-93}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 7 \cdot 10^{+68}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 43.3%

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

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

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

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

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

    if -1.59999999999999992e159 < d < -4.29999999999999963e-93 or 7.19999999999999961e-90 < d < 6.99999999999999955e68

    1. Initial program 79.3%

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

    if -4.29999999999999963e-93 < d < 7.19999999999999961e-90

    1. Initial program 58.0%

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

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

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

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

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

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

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

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

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

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

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

    if 6.99999999999999955e68 < d

    1. Initial program 49.1%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -4.3 \cdot 10^{-93}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 7.2 \cdot 10^{-90}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+68}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{c \cdot b}{d} - a\right) \cdot \frac{1}{d}\\ \end{array} \]

Alternative 7: 64.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := \frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -3.1 \cdot 10^{-19}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;d \leq 2.2 \cdot 10^{-11}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq 0.215:\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.59999999999999992e159 or 0.214999999999999997 < d

    1. Initial program 50.2%

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

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

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

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

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

    if -1.59999999999999992e159 < d < -3.0999999999999999e-19 or 3.40000000000000021e-84 < d < 2.2000000000000002e-11

    1. Initial program 83.2%

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

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

        \[\leadsto \frac{\color{blue}{-a \cdot d}}{c \cdot c + d \cdot d} \]
      2. distribute-rgt-neg-out68.5%

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

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

    if -3.0999999999999999e-19 < d < 3.40000000000000021e-84 or 2.2000000000000002e-11 < d < 0.214999999999999997

    1. Initial program 61.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -3.1 \cdot 10^{-19}:\\ \;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{-84}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 2.2 \cdot 10^{-11}:\\ \;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 0.215:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]

Alternative 8: 72.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -9.5 \cdot 10^{-18}:\\
\;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.59999999999999992e159 or 1.5e61 < d

    1. Initial program 47.1%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified75.7%

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

    if -1.59999999999999992e159 < d < -9.5000000000000003e-18

    1. Initial program 81.1%

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

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

        \[\leadsto \frac{\color{blue}{-a \cdot d}}{c \cdot c + d \cdot d} \]
      2. distribute-rgt-neg-out67.3%

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

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

    if -9.5000000000000003e-18 < d < 1.5e61

    1. Initial program 64.6%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -9.5 \cdot 10^{-18}:\\ \;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{+61}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]

Alternative 9: 75.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.95 \cdot 10^{-23} \lor \neg \left(d \leq 14500000000000\right):\\
\;\;\;\;\left(\frac{c \cdot b}{d} - a\right) \cdot \frac{1}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.95e-23 or 1.45e13 < d

    1. Initial program 58.8%

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

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

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

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

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

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

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

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

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

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

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

    if -1.95e-23 < d < 1.45e13

    1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 63.4% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.68 \cdot 10^{-25} \lor \neg \left(d \leq 0.105\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.68000000000000006e-25 or 0.104999999999999996 < d

    1. Initial program 59.4%

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

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

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

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

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

    if -1.68000000000000006e-25 < d < 0.104999999999999996

    1. Initial program 63.8%

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

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

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

Alternative 11: 46.5% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.2 \cdot 10^{+140} \lor \neg \left(d \leq 2.3 \cdot 10^{+196}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.2000000000000002e140 or 2.2999999999999998e196 < d

    1. Initial program 45.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.2000000000000002e140 < d < 2.2999999999999998e196

    1. Initial program 66.1%

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

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

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

Alternative 12: 12.3% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq 2.1 \cdot 10^{+83}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d) :precision binary64 (if (<= c 2.1e+83) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= 2.1e+83) {
		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 (c <= 2.1d+83) 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 (c <= 2.1e+83) {
		tmp = a / d;
	} else {
		tmp = a / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= 2.1e+83:
		tmp = a / d
	else:
		tmp = a / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= 2.1e+83)
		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 (c <= 2.1e+83)
		tmp = a / d;
	else
		tmp = a / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, 2.1e+83], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 2.10000000000000002e83

    1. Initial program 65.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.10000000000000002e83 < c

    1. Initial program 44.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq 2.1 \cdot 10^{+83}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]

Alternative 13: 9.5% 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 61.4%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  8. Final simplification8.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 2023301 
(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))))