Complex division, imag part

Percentage Accurate: 60.6% → 85.5%
Time: 8.5s
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: 60.6% 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: 85.5% accurate, 0.1× speedup?

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

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

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


\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))) < 1e280

    1. Initial program 72.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt72.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-frac72.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-def72.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-def97.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-rr97.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. Step-by-step derivation
      1. associate-*r/97.1%

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

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

    if 1e280 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 13.2%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.4% accurate, 0.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{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))) < +inf.0

    1. Initial program 70.7%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. 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 +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 0.0%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt0.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-frac0.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-def0.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-def2.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-rr2.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. associate-*r/2.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{\frac{c}{d}}}{c}} \]
      8. associate-/l*35.5%

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

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{a \cdot \frac{d}{c}}}{c} \]
      10. div-sub51.3%

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

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

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

Alternative 3: 78.9% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.7 \cdot 10^{+35}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\

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

\mathbf{elif}\;c \leq 18000000000:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\

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

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


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

    1. Initial program 45.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.70000000000000033e35 < c < 1.50000000000000009e-60

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{c}{d} \cdot b}{d}} - \frac{a}{d} \]
      2. sub-div86.9%

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

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

    if 1.50000000000000009e-60 < c < 1.8e10

    1. Initial program 84.8%

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

    if 1.8e10 < c < 2.0500000000000002e29

    1. Initial program 48.4%

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

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

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

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

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

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

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

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

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

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

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

    if 2.0500000000000002e29 < c

    1. Initial program 41.6%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def67.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-rr67.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. associate-*r/67.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.7 \cdot 10^{+35}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\ \mathbf{elif}\;c \leq 1.5 \cdot 10^{-60}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 18000000000:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.05 \cdot 10^{+29}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 4: 78.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -4 \cdot 10^{+35}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{-61}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 660000000:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+29}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -4e+35)
   (- (/ b c) (/ d (* c (/ c a))))
   (if (<= c 2.6e-61)
     (/ (- (* b (/ c d)) a) d)
     (if (<= c 660000000.0)
       (/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
       (if (<= c 2.6e+29)
         (/ (- (* c (/ b d)) a) d)
         (/ (- b (* a (/ d c))) c))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -4e+35) {
		tmp = (b / c) - (d / (c * (c / a)));
	} else if (c <= 2.6e-61) {
		tmp = ((b * (c / d)) - a) / d;
	} else if (c <= 660000000.0) {
		tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
	} else if (c <= 2.6e+29) {
		tmp = ((c * (b / d)) - a) / d;
	} else {
		tmp = (b - (a * (d / 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) :: tmp
    if (c <= (-4d+35)) then
        tmp = (b / c) - (d / (c * (c / a)))
    else if (c <= 2.6d-61) then
        tmp = ((b * (c / d)) - a) / d
    else if (c <= 660000000.0d0) then
        tmp = ((b * c) - (a * d)) / ((c * c) + (d * d))
    else if (c <= 2.6d+29) then
        tmp = ((c * (b / d)) - a) / d
    else
        tmp = (b - (a * (d / c))) / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -4e+35) {
		tmp = (b / c) - (d / (c * (c / a)));
	} else if (c <= 2.6e-61) {
		tmp = ((b * (c / d)) - a) / d;
	} else if (c <= 660000000.0) {
		tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
	} else if (c <= 2.6e+29) {
		tmp = ((c * (b / d)) - a) / d;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -4e+35:
		tmp = (b / c) - (d / (c * (c / a)))
	elif c <= 2.6e-61:
		tmp = ((b * (c / d)) - a) / d
	elif c <= 660000000.0:
		tmp = ((b * c) - (a * d)) / ((c * c) + (d * d))
	elif c <= 2.6e+29:
		tmp = ((c * (b / d)) - a) / d
	else:
		tmp = (b - (a * (d / c))) / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -4e+35)
		tmp = Float64(Float64(b / c) - Float64(d / Float64(c * Float64(c / a))));
	elseif (c <= 2.6e-61)
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d);
	elseif (c <= 660000000.0)
		tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 2.6e+29)
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	else
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (c <= -4e+35)
		tmp = (b / c) - (d / (c * (c / a)));
	elseif (c <= 2.6e-61)
		tmp = ((b * (c / d)) - a) / d;
	elseif (c <= 660000000.0)
		tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
	elseif (c <= 2.6e+29)
		tmp = ((c * (b / d)) - a) / d;
	else
		tmp = (b - (a * (d / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -4e+35], N[(N[(b / c), $MachinePrecision] - N[(d / N[(c * N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.6e-61], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 660000000.0], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.6e+29], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4 \cdot 10^{+35}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\

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

\mathbf{elif}\;c \leq 660000000:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\

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

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


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

    1. Initial program 45.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9999999999999999e35 < c < 2.6000000000000001e-61

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{c}{d} \cdot b}{d}} - \frac{a}{d} \]
      2. sub-div86.9%

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

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

    if 2.6000000000000001e-61 < c < 6.6e8

    1. Initial program 84.8%

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

    if 6.6e8 < c < 2.6e29

    1. Initial program 48.4%

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

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

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

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

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

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

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

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

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

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

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

    if 2.6e29 < c

    1. Initial program 41.6%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def67.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-rr67.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. associate-*r/67.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{\frac{c}{d}}}{c}} \]
      8. associate-/l*81.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4 \cdot 10^{+35}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{-61}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 660000000:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+29}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]

Alternative 5: 69.4% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -3.9e15 or 4.2000000000000002e26 < c

    1. Initial program 43.8%

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def66.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-rr66.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. Step-by-step derivation
      1. associate-*r/66.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{\frac{c}{d}}}{c}} \]
      8. associate-/l*75.9%

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

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{a \cdot \frac{d}{c}}}{c} \]
      10. div-sub80.5%

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

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

    if -3.9e15 < c < 4.2000000000000002e26

    1. Initial program 66.8%

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

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

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

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

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

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

Alternative 6: 69.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -17000000000000:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

\mathbf{elif}\;c \leq 3.2 \cdot 10^{+29}:\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.7e13

    1. Initial program 45.3%

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

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

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

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

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

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

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

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

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

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

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

    if -1.7e13 < c < 3.19999999999999987e29

    1. Initial program 66.8%

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

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

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

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

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

    if 3.19999999999999987e29 < c

    1. Initial program 41.6%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def67.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-rr67.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. associate-*r/67.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{\frac{c}{d}}}{c}} \]
      8. associate-/l*81.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -17000000000000:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{+29}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]

Alternative 7: 77.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.2 \cdot 10^{+35}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.19999999999999983e35

    1. Initial program 45.2%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
      2. sub-div83.2%

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

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

    if -3.19999999999999983e35 < c < 2.9999999999999999e29

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

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

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

    if 2.9999999999999999e29 < c

    1. Initial program 41.6%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def67.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-rr67.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. associate-*r/67.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{\frac{c}{d}}}{c}} \]
      8. associate-/l*81.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.2 \cdot 10^{+35}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq 3 \cdot 10^{+29}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]

Alternative 8: 78.3% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.62 \cdot 10^{+35}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.62e35

    1. Initial program 45.2%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
      2. sub-div83.2%

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

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

    if -1.62e35 < c < 2.64999999999999984e26

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{c}{d} \cdot b}{d}} - \frac{a}{d} \]
      2. sub-div83.2%

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

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

    if 2.64999999999999984e26 < c

    1. Initial program 41.6%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def67.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-rr67.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. associate-*r/67.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{\frac{c}{d}}}{c}} \]
      8. associate-/l*81.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.62 \cdot 10^{+35}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq 2.65 \cdot 10^{+26}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]

Alternative 9: 77.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.05 \cdot 10^{+35}:\\
\;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.0499999999999999e35

    1. Initial program 45.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0499999999999999e35 < c < 6.39999999999999973e29

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{c}{d} \cdot b}{d}} - \frac{a}{d} \]
      2. sub-div83.2%

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

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

    if 6.39999999999999973e29 < c

    1. Initial program 41.6%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. hypot-def67.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-rr67.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. associate-*r/67.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{\frac{c}{d}}}{c}} \]
      8. associate-/l*81.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.05 \cdot 10^{+35}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c \cdot \frac{c}{a}}\\ \mathbf{elif}\;c \leq 6.4 \cdot 10^{+29}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]

Alternative 10: 64.0% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;c \leq 1.5 \cdot 10^{+29}:\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.5999999999999996e35 or 1.5e29 < c

    1. Initial program 43.6%

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

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

    if -4.5999999999999996e35 < c < 1.5e29

    1. Initial program 65.9%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified68.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.6 \cdot 10^{+35}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 1.5 \cdot 10^{+29}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 11: 9.4% 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 57.7%

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
    5. hypot-def78.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-rr78.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 inf 27.0%

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  6. Final simplification7.5%

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

Alternative 12: 41.7% 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 57.7%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Final simplification34.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 2023199 
(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))))