Complex division, imag part

Percentage Accurate: 61.3% → 98.4%
Time: 13.1s
Alternatives: 14
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 14 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.3% 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: 98.4% accurate, 0.0× speedup?

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

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

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

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

      \[\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.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-def65.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. hypot-def79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.4% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 78.9%

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

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

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac78.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-def78.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. hypot-def95.0%

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

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

    if 1.9999999999999999e298 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 14.0%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt14.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-frac14.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-def14.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. hypot-def21.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 82.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -8.5 \cdot 10^{+80}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}\\ \mathbf{elif}\;c \leq -2.05 \cdot 10^{-160}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{-62}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{+18}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= c -8.5e+80)
     (/ b (* (hypot c d) (/ (hypot c d) c)))
     (if (<= c -2.05e-160)
       t_0
       (if (<= c 1.2e-116)
         (* (/ 1.0 d) (- (/ b (/ d c)) a))
         (if (<= c 1.75e-62)
           t_0
           (if (<= c 1.15e+18)
             (* (/ 1.0 d) (- (/ (* c b) d) a))
             (* (/ 1.0 (hypot c d)) (- b (* d (/ a (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 (c <= -8.5e+80) {
		tmp = b / (hypot(c, d) * (hypot(c, d) / c));
	} else if (c <= -2.05e-160) {
		tmp = t_0;
	} else if (c <= 1.2e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 1.75e-62) {
		tmp = t_0;
	} else if (c <= 1.15e+18) {
		tmp = (1.0 / d) * (((c * b) / d) - a);
	} else {
		tmp = (1.0 / hypot(c, d)) * (b - (d * (a / 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 (c <= -8.5e+80) {
		tmp = b / (Math.hypot(c, d) * (Math.hypot(c, d) / c));
	} else if (c <= -2.05e-160) {
		tmp = t_0;
	} else if (c <= 1.2e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 1.75e-62) {
		tmp = t_0;
	} else if (c <= 1.15e+18) {
		tmp = (1.0 / d) * (((c * b) / d) - a);
	} else {
		tmp = (1.0 / Math.hypot(c, d)) * (b - (d * (a / 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 c <= -8.5e+80:
		tmp = b / (math.hypot(c, d) * (math.hypot(c, d) / c))
	elif c <= -2.05e-160:
		tmp = t_0
	elif c <= 1.2e-116:
		tmp = (1.0 / d) * ((b / (d / c)) - a)
	elif c <= 1.75e-62:
		tmp = t_0
	elif c <= 1.15e+18:
		tmp = (1.0 / d) * (((c * b) / d) - a)
	else:
		tmp = (1.0 / math.hypot(c, d)) * (b - (d * (a / 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 (c <= -8.5e+80)
		tmp = Float64(b / Float64(hypot(c, d) * Float64(hypot(c, d) / c)));
	elseif (c <= -2.05e-160)
		tmp = t_0;
	elseif (c <= 1.2e-116)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a));
	elseif (c <= 1.75e-62)
		tmp = t_0;
	elseif (c <= 1.15e+18)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(Float64(c * b) / d) - a));
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b - Float64(d * Float64(a / 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 (c <= -8.5e+80)
		tmp = b / (hypot(c, d) * (hypot(c, d) / c));
	elseif (c <= -2.05e-160)
		tmp = t_0;
	elseif (c <= 1.2e-116)
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	elseif (c <= 1.75e-62)
		tmp = t_0;
	elseif (c <= 1.15e+18)
		tmp = (1.0 / d) * (((c * b) / d) - a);
	else
		tmp = (1.0 / hypot(c, d)) * (b - (d * (a / 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[c, -8.5e+80], N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] * N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.05e-160], t$95$0, If[LessEqual[c, 1.2e-116], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.75e-62], t$95$0, If[LessEqual[c, 1.15e+18], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b - N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -2.05 \cdot 10^{-160}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.75 \cdot 10^{-62}:\\
\;\;\;\;t_0\\

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

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


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

    1. Initial program 45.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{\frac{\color{blue}{{c}^{2} + d \cdot d}}{c}} \]
      3. add-sqr-sqrt48.8%

        \[\leadsto \frac{b}{\frac{\color{blue}{\sqrt{{c}^{2} + d \cdot d} \cdot \sqrt{{c}^{2} + d \cdot d}}}{c}} \]
      4. pow248.8%

        \[\leadsto \frac{b}{\frac{\sqrt{\color{blue}{c \cdot c} + d \cdot d} \cdot \sqrt{{c}^{2} + d \cdot d}}{c}} \]
      5. hypot-udef48.8%

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

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

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

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

        \[\leadsto \frac{b}{\color{blue}{\frac{\mathsf{hypot}\left(c, d\right)}{1} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}} \]
      10. /-rgt-identity92.1%

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

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

    if -8.50000000000000007e80 < c < -2.05000000000000001e-160 or 1.19999999999999996e-116 < c < 1.7500000000000001e-62

    1. Initial program 85.2%

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

    if -2.05000000000000001e-160 < c < 1.19999999999999996e-116

    1. Initial program 74.2%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt74.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-frac74.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-def74.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. hypot-def91.1%

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

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

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

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

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

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

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

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

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

    if 1.7500000000000001e-62 < c < 1.15e18

    1. Initial program 70.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt70.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-frac70.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-def70.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. hypot-def87.0%

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

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

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

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

    if 1.15e18 < c

    1. Initial program 49.4%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt49.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-frac49.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-def49.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. hypot-def63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.5 \cdot 10^{+80}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}\\ \mathbf{elif}\;c \leq -2.05 \cdot 10^{-160}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{-62}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{+18}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)\\ \end{array} \]

Alternative 4: 82.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -2.15 \cdot 10^{+80}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}\\ \mathbf{elif}\;c \leq -2.05 \cdot 10^{-160}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{+18}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{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 (<= c -2.15e+80)
     (/ b (* (hypot c d) (/ (hypot c d) c)))
     (if (<= c -2.05e-160)
       t_0
       (if (<= c 3e-116)
         (* (/ 1.0 d) (- (/ b (/ d c)) a))
         (if (<= c 1.6e-61)
           t_0
           (if (<= c 1.15e+18)
             (* (/ 1.0 d) (- (/ (* c b) d) a))
             (* (/ 1.0 (hypot c d)) (- b (/ a (/ (hypot c d) 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 (c <= -2.15e+80) {
		tmp = b / (hypot(c, d) * (hypot(c, d) / c));
	} else if (c <= -2.05e-160) {
		tmp = t_0;
	} else if (c <= 3e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 1.6e-61) {
		tmp = t_0;
	} else if (c <= 1.15e+18) {
		tmp = (1.0 / d) * (((c * b) / d) - a);
	} else {
		tmp = (1.0 / hypot(c, d)) * (b - (a / (hypot(c, d) / 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 (c <= -2.15e+80) {
		tmp = b / (Math.hypot(c, d) * (Math.hypot(c, d) / c));
	} else if (c <= -2.05e-160) {
		tmp = t_0;
	} else if (c <= 3e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 1.6e-61) {
		tmp = t_0;
	} else if (c <= 1.15e+18) {
		tmp = (1.0 / d) * (((c * b) / d) - a);
	} else {
		tmp = (1.0 / Math.hypot(c, d)) * (b - (a / (Math.hypot(c, d) / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -2.15e+80:
		tmp = b / (math.hypot(c, d) * (math.hypot(c, d) / c))
	elif c <= -2.05e-160:
		tmp = t_0
	elif c <= 3e-116:
		tmp = (1.0 / d) * ((b / (d / c)) - a)
	elif c <= 1.6e-61:
		tmp = t_0
	elif c <= 1.15e+18:
		tmp = (1.0 / d) * (((c * b) / d) - a)
	else:
		tmp = (1.0 / math.hypot(c, d)) * (b - (a / (math.hypot(c, d) / 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 (c <= -2.15e+80)
		tmp = Float64(b / Float64(hypot(c, d) * Float64(hypot(c, d) / c)));
	elseif (c <= -2.05e-160)
		tmp = t_0;
	elseif (c <= 3e-116)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a));
	elseif (c <= 1.6e-61)
		tmp = t_0;
	elseif (c <= 1.15e+18)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(Float64(c * b) / d) - a));
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b - Float64(a / Float64(hypot(c, d) / 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 (c <= -2.15e+80)
		tmp = b / (hypot(c, d) * (hypot(c, d) / c));
	elseif (c <= -2.05e-160)
		tmp = t_0;
	elseif (c <= 3e-116)
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	elseif (c <= 1.6e-61)
		tmp = t_0;
	elseif (c <= 1.15e+18)
		tmp = (1.0 / d) * (((c * b) / d) - a);
	else
		tmp = (1.0 / hypot(c, d)) * (b - (a / (hypot(c, d) / 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[c, -2.15e+80], N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] * N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.05e-160], t$95$0, If[LessEqual[c, 3e-116], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.6e-61], t$95$0, If[LessEqual[c, 1.15e+18], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b - N[(a / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -2.05 \cdot 10^{-160}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.6 \cdot 10^{-61}:\\
\;\;\;\;t_0\\

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

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


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

    1. Initial program 45.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{\frac{\color{blue}{{c}^{2} + d \cdot d}}{c}} \]
      3. add-sqr-sqrt48.8%

        \[\leadsto \frac{b}{\frac{\color{blue}{\sqrt{{c}^{2} + d \cdot d} \cdot \sqrt{{c}^{2} + d \cdot d}}}{c}} \]
      4. pow248.8%

        \[\leadsto \frac{b}{\frac{\sqrt{\color{blue}{c \cdot c} + d \cdot d} \cdot \sqrt{{c}^{2} + d \cdot d}}{c}} \]
      5. hypot-udef48.8%

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

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

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

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

        \[\leadsto \frac{b}{\color{blue}{\frac{\mathsf{hypot}\left(c, d\right)}{1} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}} \]
      10. /-rgt-identity92.1%

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

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

    if -2.15000000000000002e80 < c < -2.05000000000000001e-160 or 3.00000000000000026e-116 < c < 1.6000000000000001e-61

    1. Initial program 85.2%

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

    if -2.05000000000000001e-160 < c < 3.00000000000000026e-116

    1. Initial program 74.2%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt74.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-frac74.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-def74.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. hypot-def91.1%

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

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

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

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

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

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

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

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

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

    if 1.6000000000000001e-61 < c < 1.15e18

    1. Initial program 70.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt70.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-frac70.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-def70.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. hypot-def87.0%

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

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

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

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

    if 1.15e18 < c

    1. Initial program 49.4%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt49.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-frac49.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-def49.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. hypot-def63.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.15 \cdot 10^{+80}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}\\ \mathbf{elif}\;c \leq -2.05 \cdot 10^{-160}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-61}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{+18}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\ \end{array} \]

Alternative 5: 81.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -1 \cdot 10^{+81}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}\\ \mathbf{elif}\;c \leq -1.95 \cdot 10^{-160}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{+117}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{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 (<= c -1e+81)
     (/ b (* (hypot c d) (/ (hypot c d) c)))
     (if (<= c -1.95e-160)
       t_0
       (if (<= c 3e-116)
         (* (/ 1.0 d) (- (/ b (/ d c)) a))
         (if (<= c 4.3e+117)
           t_0
           (* (/ 1.0 (hypot c d)) (- b (/ a (/ 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 (c <= -1e+81) {
		tmp = b / (hypot(c, d) * (hypot(c, d) / c));
	} else if (c <= -1.95e-160) {
		tmp = t_0;
	} else if (c <= 3e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 4.3e+117) {
		tmp = t_0;
	} else {
		tmp = (1.0 / hypot(c, d)) * (b - (a / (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 (c <= -1e+81) {
		tmp = b / (Math.hypot(c, d) * (Math.hypot(c, d) / c));
	} else if (c <= -1.95e-160) {
		tmp = t_0;
	} else if (c <= 3e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 4.3e+117) {
		tmp = t_0;
	} else {
		tmp = (1.0 / Math.hypot(c, d)) * (b - (a / (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -1e+81:
		tmp = b / (math.hypot(c, d) * (math.hypot(c, d) / c))
	elif c <= -1.95e-160:
		tmp = t_0
	elif c <= 3e-116:
		tmp = (1.0 / d) * ((b / (d / c)) - a)
	elif c <= 4.3e+117:
		tmp = t_0
	else:
		tmp = (1.0 / math.hypot(c, d)) * (b - (a / (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 (c <= -1e+81)
		tmp = Float64(b / Float64(hypot(c, d) * Float64(hypot(c, d) / c)));
	elseif (c <= -1.95e-160)
		tmp = t_0;
	elseif (c <= 3e-116)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a));
	elseif (c <= 4.3e+117)
		tmp = t_0;
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b - Float64(a / Float64(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 (c <= -1e+81)
		tmp = b / (hypot(c, d) * (hypot(c, d) / c));
	elseif (c <= -1.95e-160)
		tmp = t_0;
	elseif (c <= 3e-116)
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	elseif (c <= 4.3e+117)
		tmp = t_0;
	else
		tmp = (1.0 / hypot(c, d)) * (b - (a / (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[c, -1e+81], N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] * N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.95e-160], t$95$0, If[LessEqual[c, 3e-116], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.3e+117], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.95 \cdot 10^{-160}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 4.3 \cdot 10^{+117}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 45.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{\frac{\color{blue}{{c}^{2} + d \cdot d}}{c}} \]
      3. add-sqr-sqrt48.8%

        \[\leadsto \frac{b}{\frac{\color{blue}{\sqrt{{c}^{2} + d \cdot d} \cdot \sqrt{{c}^{2} + d \cdot d}}}{c}} \]
      4. pow248.8%

        \[\leadsto \frac{b}{\frac{\sqrt{\color{blue}{c \cdot c} + d \cdot d} \cdot \sqrt{{c}^{2} + d \cdot d}}{c}} \]
      5. hypot-udef48.8%

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

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

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

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

        \[\leadsto \frac{b}{\color{blue}{\frac{\mathsf{hypot}\left(c, d\right)}{1} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}} \]
      10. /-rgt-identity92.1%

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

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

    if -9.99999999999999921e80 < c < -1.94999999999999995e-160 or 3.00000000000000026e-116 < c < 4.29999999999999998e117

    1. Initial program 80.8%

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

    if -1.94999999999999995e-160 < c < 3.00000000000000026e-116

    1. Initial program 74.2%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt74.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-frac74.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-def74.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. hypot-def91.1%

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

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

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

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

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

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

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

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

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

    if 4.29999999999999998e117 < c

    1. Initial program 29.1%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt29.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-frac29.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-def29.1%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1 \cdot 10^{+81}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{c}}\\ \mathbf{elif}\;c \leq -1.95 \cdot 10^{-160}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{+117}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \end{array} \]

Alternative 6: 82.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}\\ \mathbf{if}\;c \leq -7 \cdot 10^{+133}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -2.75 \cdot 10^{-160}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.18 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+120}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{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 (<= c -7e+133)
     (- (/ b c) (* d (/ (/ a c) c)))
     (if (<= c -2.75e-160)
       t_0
       (if (<= c 1.18e-116)
         (* (/ 1.0 d) (- (/ b (/ d c)) a))
         (if (<= c 2.6e+120)
           t_0
           (* (/ 1.0 (hypot c d)) (- b (/ a (/ 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 (c <= -7e+133) {
		tmp = (b / c) - (d * ((a / c) / c));
	} else if (c <= -2.75e-160) {
		tmp = t_0;
	} else if (c <= 1.18e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 2.6e+120) {
		tmp = t_0;
	} else {
		tmp = (1.0 / hypot(c, d)) * (b - (a / (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 (c <= -7e+133) {
		tmp = (b / c) - (d * ((a / c) / c));
	} else if (c <= -2.75e-160) {
		tmp = t_0;
	} else if (c <= 1.18e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 2.6e+120) {
		tmp = t_0;
	} else {
		tmp = (1.0 / Math.hypot(c, d)) * (b - (a / (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -7e+133:
		tmp = (b / c) - (d * ((a / c) / c))
	elif c <= -2.75e-160:
		tmp = t_0
	elif c <= 1.18e-116:
		tmp = (1.0 / d) * ((b / (d / c)) - a)
	elif c <= 2.6e+120:
		tmp = t_0
	else:
		tmp = (1.0 / math.hypot(c, d)) * (b - (a / (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 (c <= -7e+133)
		tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c)));
	elseif (c <= -2.75e-160)
		tmp = t_0;
	elseif (c <= 1.18e-116)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a));
	elseif (c <= 2.6e+120)
		tmp = t_0;
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b - Float64(a / Float64(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 (c <= -7e+133)
		tmp = (b / c) - (d * ((a / c) / c));
	elseif (c <= -2.75e-160)
		tmp = t_0;
	elseif (c <= 1.18e-116)
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	elseif (c <= 2.6e+120)
		tmp = t_0;
	else
		tmp = (1.0 / hypot(c, d)) * (b - (a / (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[c, -7e+133], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2.75e-160], t$95$0, If[LessEqual[c, 1.18e-116], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.6e+120], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -2.75 \cdot 10^{-160}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 2.6 \cdot 10^{+120}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 35.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.9999999999999997e133 < c < -2.75e-160 or 1.1800000000000001e-116 < c < 2.5999999999999999e120

    1. Initial program 80.3%

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

    if -2.75e-160 < c < 1.1800000000000001e-116

    1. Initial program 74.2%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt74.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-frac74.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-def74.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. hypot-def91.1%

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

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

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

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

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

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

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

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

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

    if 2.5999999999999999e120 < c

    1. Initial program 29.1%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt29.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-frac29.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-def29.1%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7 \cdot 10^{+133}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -2.75 \cdot 10^{-160}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.18 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+120}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \end{array} \]

Alternative 7: 81.5% 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}\;c \leq -6.5 \cdot 10^{+133}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -6.2 \cdot 10^{-161}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{+117}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{d \cdot a}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= c -6.5e+133)
     (- (/ b c) (* d (/ (/ a c) c)))
     (if (<= c -6.2e-161)
       t_0
       (if (<= c 3.2e-116)
         (* (/ 1.0 d) (- (/ b (/ d c)) a))
         (if (<= c 4.8e+117) t_0 (- (/ b c) (/ (/ (* d a) c) c))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -6.5e+133) {
		tmp = (b / c) - (d * ((a / c) / c));
	} else if (c <= -6.2e-161) {
		tmp = t_0;
	} else if (c <= 3.2e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 4.8e+117) {
		tmp = t_0;
	} else {
		tmp = (b / c) - (((d * a) / c) / c);
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    if (c <= (-6.5d+133)) then
        tmp = (b / c) - (d * ((a / c) / c))
    else if (c <= (-6.2d-161)) then
        tmp = t_0
    else if (c <= 3.2d-116) then
        tmp = (1.0d0 / d) * ((b / (d / c)) - a)
    else if (c <= 4.8d+117) then
        tmp = t_0
    else
        tmp = (b / c) - (((d * a) / c) / c)
    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 (c <= -6.5e+133) {
		tmp = (b / c) - (d * ((a / c) / c));
	} else if (c <= -6.2e-161) {
		tmp = t_0;
	} else if (c <= 3.2e-116) {
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	} else if (c <= 4.8e+117) {
		tmp = t_0;
	} else {
		tmp = (b / c) - (((d * a) / c) / c);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -6.5e+133:
		tmp = (b / c) - (d * ((a / c) / c))
	elif c <= -6.2e-161:
		tmp = t_0
	elif c <= 3.2e-116:
		tmp = (1.0 / d) * ((b / (d / c)) - a)
	elif c <= 4.8e+117:
		tmp = t_0
	else:
		tmp = (b / c) - (((d * a) / c) / c)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (c <= -6.5e+133)
		tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c)));
	elseif (c <= -6.2e-161)
		tmp = t_0;
	elseif (c <= 3.2e-116)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(b / Float64(d / c)) - a));
	elseif (c <= 4.8e+117)
		tmp = t_0;
	else
		tmp = Float64(Float64(b / c) - Float64(Float64(Float64(d * a) / c) / c));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (c <= -6.5e+133)
		tmp = (b / c) - (d * ((a / c) / c));
	elseif (c <= -6.2e-161)
		tmp = t_0;
	elseif (c <= 3.2e-116)
		tmp = (1.0 / d) * ((b / (d / c)) - a);
	elseif (c <= 4.8e+117)
		tmp = t_0;
	else
		tmp = (b / c) - (((d * a) / c) / c);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -6.5e+133], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -6.2e-161], t$95$0, If[LessEqual[c, 3.2e-116], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.8e+117], t$95$0, N[(N[(b / c), $MachinePrecision] - N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -6.2 \cdot 10^{-161}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 4.8 \cdot 10^{+117}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 35.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.5000000000000004e133 < c < -6.1999999999999997e-161 or 3.20000000000000009e-116 < c < 4.7999999999999998e117

    1. Initial program 80.3%

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

    if -6.1999999999999997e-161 < c < 3.20000000000000009e-116

    1. Initial program 74.2%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt74.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-frac74.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-def74.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. hypot-def91.1%

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

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

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

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

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

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

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

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

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

    if 4.7999999999999998e117 < c

    1. Initial program 29.1%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6.5 \cdot 10^{+133}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -6.2 \cdot 10^{-161}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-116}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{b}{\frac{d}{c}} - a\right)\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{+117}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{d \cdot a}{c}}{c}\\ \end{array} \]

Alternative 8: 71.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.9 \cdot 10^{-14} \lor \neg \left(c \leq 2.7 \cdot 10^{+18}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -3.8999999999999998e-14 or 2.7e18 < c

    1. Initial program 52.8%

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

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

    if -3.8999999999999998e-14 < c < 2.7e18

    1. Initial program 77.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt77.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-frac77.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-def77.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. hypot-def91.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{d} \cdot \left(\color{blue}{\left(c \cdot b\right)} \cdot \frac{1}{d} - a\right) \]
      6. associate-*l*77.1%

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

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

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

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

Alternative 9: 72.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.9 \cdot 10^{-14} \lor \neg \left(c \leq 5.5 \cdot 10^{+18}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -3.8999999999999998e-14 or 5.5e18 < c

    1. Initial program 52.8%

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

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

    if -3.8999999999999998e-14 < c < 5.5e18

    1. Initial program 77.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt77.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-frac77.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-def77.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. hypot-def91.1%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 78.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.62 \cdot 10^{-15} \lor \neg \left(c \leq 1.2 \cdot 10^{+18}\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.62000000000000009e-15 or 1.2e18 < c

    1. Initial program 52.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.62000000000000009e-15 < c < 1.2e18

    1. Initial program 77.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt77.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-frac77.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-def77.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. hypot-def91.1%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 78.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.36 \cdot 10^{-14} \lor \neg \left(c \leq 2.7 \cdot 10^{+18}\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.36e-14 or 2.7e18 < c

    1. Initial program 52.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.36e-14 < c < 2.7e18

    1. Initial program 77.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt77.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-frac77.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-def77.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. hypot-def91.1%

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

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

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

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

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

Alternative 12: 61.6% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.2 \cdot 10^{+66} \lor \neg \left(d \leq 3.6 \cdot 10^{+138}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.2e66 or 3.6000000000000001e138 < d

    1. Initial program 47.5%

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

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

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

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

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

    if -3.2e66 < d < 3.6000000000000001e138

    1. Initial program 73.5%

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

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

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

Alternative 13: 46.1% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2 \cdot 10^{+199} \lor \neg \left(d \leq 8 \cdot 10^{+154}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.00000000000000019e199 or 8.0000000000000003e154 < d

    1. Initial program 47.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt47.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-frac47.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-def47.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. hypot-def67.5%

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

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

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

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

    if -2.00000000000000019e199 < d < 8.0000000000000003e154

    1. Initial program 69.0%

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

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

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

Alternative 14: 10.8% accurate, 5.0× speedup?

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

\\
\frac{a}{d}
\end{array}
Derivation
  1. Initial program 65.5%

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

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

      \[\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.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-def65.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. hypot-def79.7%

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

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

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

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  6. Final simplification11.2%

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

Developer target: 99.5% 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 2023307 
(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))))