Complex division, imag part

Percentage Accurate: 61.7% → 91.7%
Time: 8.7s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 61.7% accurate, 1.0× speedup?

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

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

Alternative 1: 91.7% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq -2.8 \cdot 10^{-136}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 7.2 \cdot 10^{+149}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 29.9%

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

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

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

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

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

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

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

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

    if -1.6499999999999999e159 < d < -2.8000000000000001e-136 or 1.7500000000000001e-165 < d < 7.1999999999999999e149

    1. Initial program 72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.8000000000000001e-136 < d < 1.7500000000000001e-165

    1. Initial program 62.3%

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

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

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

      \[\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 50.4%

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

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

    if 7.1999999999999999e149 < d

    1. Initial program 41.0%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt41.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-frac41.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-def41.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-def64.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-rr64.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 92.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.65 \cdot 10^{+159}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -2.8 \cdot 10^{-136}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-165}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{d \cdot a}{c} - b\right)\\ \mathbf{elif}\;d \leq 7.2 \cdot 10^{+149}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\ \end{array} \]

Alternative 2: 85.4% accurate, 0.1× speedup?

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

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

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


\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))) < 2e303

    1. Initial program 81.1%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt81.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-frac81.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-def81.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-def97.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-rr97.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)}} \]

    if 2e303 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 7.5%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      5. times-frac57.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+303}:\\ \;\;\;\;\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{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 3: 78.7% accurate, 0.1× speedup?

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

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

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

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

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


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

    1. Initial program 38.8%

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

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

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

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

      \[\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 85.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.8e76 < c < -9.5000000000000004e-66

    1. Initial program 94.8%

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

    if -9.5000000000000004e-66 < c < 1.8500000000000001e55

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

    if 1.8500000000000001e55 < c

    1. Initial program 51.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.8 \cdot 10^{+76}:\\ \;\;\;\;\frac{d \cdot \frac{a}{c} - b}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -9.5 \cdot 10^{-66}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{+55}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 4: 78.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -3.9 \cdot 10^{+121}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -1.66 \cdot 10^{-65}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{+53}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (/ b c) (* (/ a c) (/ d c)))))
   (if (<= c -3.9e+121)
     t_0
     (if (<= c -1.66e-65)
       (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
       (if (<= c 6.8e+53) (- (* (/ c d) (/ b d)) (/ a d)) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = (b / c) - ((a / c) * (d / c));
	double tmp;
	if (c <= -3.9e+121) {
		tmp = t_0;
	} else if (c <= -1.66e-65) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (c <= 6.8e+53) {
		tmp = ((c / d) * (b / d)) - (a / d);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (b / c) - ((a / c) * (d / c))
    if (c <= (-3.9d+121)) then
        tmp = t_0
    else if (c <= (-1.66d-65)) then
        tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
    else if (c <= 6.8d+53) then
        tmp = ((c / d) * (b / d)) - (a / d)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (b / c) - ((a / c) * (d / c));
	double tmp;
	if (c <= -3.9e+121) {
		tmp = t_0;
	} else if (c <= -1.66e-65) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (c <= 6.8e+53) {
		tmp = ((c / d) * (b / d)) - (a / d);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b / c) - ((a / c) * (d / c))
	tmp = 0
	if c <= -3.9e+121:
		tmp = t_0
	elif c <= -1.66e-65:
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
	elif c <= 6.8e+53:
		tmp = ((c / d) * (b / d)) - (a / d)
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c)))
	tmp = 0.0
	if (c <= -3.9e+121)
		tmp = t_0;
	elseif (c <= -1.66e-65)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 6.8e+53)
		tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b / c) - ((a / c) * (d / c));
	tmp = 0.0;
	if (c <= -3.9e+121)
		tmp = t_0;
	elseif (c <= -1.66e-65)
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	elseif (c <= 6.8e+53)
		tmp = ((c / d) * (b / d)) - (a / d);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.9e+121], t$95$0, If[LessEqual[c, -1.66e-65], 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.8e+53], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.89999999999999984e121 or 6.79999999999999995e53 < c

    1. Initial program 45.0%

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

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

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

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

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

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

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

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

    if -3.89999999999999984e121 < c < -1.6599999999999999e-65

    1. Initial program 92.2%

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

    if -1.6599999999999999e-65 < c < 6.79999999999999995e53

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.9 \cdot 10^{+121}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1.66 \cdot 10^{-65}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{+53}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 5: 75.7% accurate, 0.9× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -6.80000000000000022e75 or 3.89999999999999976e53 < c

    1. Initial program 46.6%

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

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

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

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

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

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

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

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

    if -6.80000000000000022e75 < c < -1.70000000000000006e-64

    1. Initial program 94.8%

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

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

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac95.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-def95.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-def95.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-rr95.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. Taylor expanded in b around inf 85.5%

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

        \[\leadsto \color{blue}{\frac{c}{\frac{{d}^{2} + {c}^{2}}{b}}} \]
      2. unpow285.7%

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

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

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

    if -1.70000000000000006e-64 < c < 3.89999999999999976e53

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6.8 \cdot 10^{+75}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-64}:\\ \;\;\;\;\frac{c}{\frac{c \cdot c + d \cdot d}{b}}\\ \mathbf{elif}\;c \leq 3.9 \cdot 10^{+53}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 6: 71.3% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.5000000000000003e41 or 4.7999999999999998e55 < c

    1. Initial program 48.8%

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

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

    if -5.5000000000000003e41 < c < 4.7999999999999998e55

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

Alternative 7: 75.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.1 \cdot 10^{-60} \lor \neg \left(c \leq 2.25 \cdot 10^{+54}\right):\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.0999999999999999e-60 or 2.24999999999999992e54 < c

    1. Initial program 54.4%

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{c} \cdot \frac{d}{c}} \]
    4. Simplified82.6%

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

    if -1.0999999999999999e-60 < c < 2.24999999999999992e54

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

Alternative 8: 62.7% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;c \leq 9.2 \cdot 10^{-150}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 5.8 \cdot 10^{+55}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -7.80000000000000065e-61 or 5.7999999999999997e55 < c

    1. Initial program 54.4%

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

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

    if -7.80000000000000065e-61 < c < 9.20000000000000011e-150 or 1.0000000000000001e-123 < c < 5.7999999999999997e55

    1. Initial program 65.2%

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

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

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

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

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

    if 9.20000000000000011e-150 < c < 1.0000000000000001e-123

    1. Initial program 89.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{c}{1} \cdot \frac{b}{d \cdot d + c \cdot c}} \]
      3. pow142.6%

        \[\leadsto \frac{c}{1} \cdot \frac{b}{\color{blue}{{\left(d \cdot d + c \cdot c\right)}^{1}}} \]
      4. metadata-eval42.6%

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d}} \]
    9. Simplified70.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.8 \cdot 10^{-61}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 9.2 \cdot 10^{-150}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 10^{-123}:\\ \;\;\;\;\frac{c \cdot b}{d \cdot d}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+55}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 9: 62.8% accurate, 1.1× speedup?

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

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

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

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

\mathbf{elif}\;c \leq 2.2 \cdot 10^{+54}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -9.3999999999999993e-61 or 2.1999999999999999e54 < c

    1. Initial program 54.4%

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

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

    if -9.3999999999999993e-61 < c < 1.9500000000000001e-150 or 1.02e-123 < c < 2.1999999999999999e54

    1. Initial program 65.2%

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

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

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

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

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

    if 1.9500000000000001e-150 < c < 1.02e-123

    1. Initial program 89.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{c \cdot b}{d \cdot d + c \cdot c}} \]
    5. Taylor expanded in c around 0 70.7%

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d}} \]
      2. times-frac52.1%

        \[\leadsto \color{blue}{\frac{c}{d} \cdot \frac{b}{d}} \]
    7. Simplified52.1%

      \[\leadsto \color{blue}{\frac{c}{d} \cdot \frac{b}{d}} \]
    8. Step-by-step derivation
      1. associate-*r/70.7%

        \[\leadsto \color{blue}{\frac{\frac{c}{d} \cdot b}{d}} \]
    9. Applied egg-rr70.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9.4 \cdot 10^{-61}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 1.95 \cdot 10^{-150}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 1.02 \cdot 10^{-123}:\\ \;\;\;\;\frac{\frac{c}{d} \cdot b}{d}\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{+54}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 10: 63.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.95 \cdot 10^{-61} \lor \neg \left(c \leq 2.3 \cdot 10^{+53}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.94999999999999986e-61 or 2.3000000000000002e53 < c

    1. Initial program 54.4%

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

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

    if -2.94999999999999986e-61 < c < 2.3000000000000002e53

    1. Initial program 67.2%

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

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

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

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

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

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

Alternative 11: 9.5% accurate, 5.0× speedup?

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
    2. add-sqr-sqrt60.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-frac60.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-def60.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-def73.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-rr73.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. Taylor expanded in c around -inf 31.0%

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  6. Final simplification8.9%

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

Alternative 12: 43.2% accurate, 5.0× speedup?

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

\\
\frac{b}{c}
\end{array}
Derivation
  1. Initial program 60.4%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Final simplification45.4%

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

Developer target: 99.3% 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 2023240 
(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))))