Complex division, imag part

Percentage Accurate: 60.9% → 99.0%
Time: 9.9s
Alternatives: 14
Speedup: 1.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 60.9% 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: 99.0% accurate, 0.0× speedup?

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
    2. add-sqr-sqrt61.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-frac61.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-def61.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-def75.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-rr75.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. Step-by-step derivation
    1. div-sub75.8%

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

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

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

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

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

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

Alternative 2: 87.6% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 77.4%

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

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

    if 1.99999999999999997e307 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 10.1%

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

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

        \[\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-rr13.9%

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

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

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

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

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

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

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

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

Alternative 3: 83.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -2.4 \cdot 10^{+83}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.15 \cdot 10^{-151}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-144}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -2.4e+83)
   (/ (- b (* d (/ a c))) c)
   (if (<= c -1.15e-151)
     (/ (fma c b (* d (- a))) (+ (* c c) (* d d)))
     (if (<= c 1.6e-144)
       (/ (- (/ (* c b) d) a) d)
       (* (/ 1.0 (hypot c d)) (- b (/ a (/ (hypot c d) d))))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -2.4e+83) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= -1.15e-151) {
		tmp = fma(c, b, (d * -a)) / ((c * c) + (d * d));
	} else if (c <= 1.6e-144) {
		tmp = (((c * b) / d) - a) / d;
	} else {
		tmp = (1.0 / hypot(c, d)) * (b - (a / (hypot(c, d) / d)));
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -2.4e+83)
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	elseif (c <= -1.15e-151)
		tmp = Float64(fma(c, b, Float64(d * Float64(-a))) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 1.6e-144)
		tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d);
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b - Float64(a / Float64(hypot(c, d) / d))));
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.4e+83], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -1.15e-151], N[(N[(c * b + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.6e-144], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b - N[(a / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


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

    1. Initial program 44.7%

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

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

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

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

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

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

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

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

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

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

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

    if -2.39999999999999991e83 < c < -1.14999999999999998e-151

    1. Initial program 81.6%

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

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

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

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

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

    if -1.14999999999999998e-151 < c < 1.59999999999999986e-144

    1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{c \cdot \frac{b}{d} - a}{d}} \]
    9. Step-by-step derivation
      1. *-lft-identity87.4%

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

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

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

    if 1.59999999999999986e-144 < c

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.4 \cdot 10^{+83}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.15 \cdot 10^{-151}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-144}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\ \end{array} \]

Alternative 4: 82.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot c + d \cdot d\\ \mathbf{if}\;c \leq -2.2 \cdot 10^{+83}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -7.6 \cdot 10^{-152}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{t_0}\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-55}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+92}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{t_0}\\ \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 c) (* d d))))
   (if (<= c -2.2e+83)
     (/ (- b (* d (/ a c))) c)
     (if (<= c -7.6e-152)
       (/ (fma c b (* d (- a))) t_0)
       (if (<= c 1.6e-55)
         (/ (- (/ (* c b) d) a) d)
         (if (<= c 2.6e+92)
           (/ (- (* c b) (* d a)) t_0)
           (- (/ b c) (* (/ a c) (/ d c)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * c) + (d * d);
	double tmp;
	if (c <= -2.2e+83) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= -7.6e-152) {
		tmp = fma(c, b, (d * -a)) / t_0;
	} else if (c <= 1.6e-55) {
		tmp = (((c * b) / d) - a) / d;
	} else if (c <= 2.6e+92) {
		tmp = ((c * b) - (d * a)) / t_0;
	} else {
		tmp = (b / c) - ((a / c) * (d / c));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(c * c) + Float64(d * d))
	tmp = 0.0
	if (c <= -2.2e+83)
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	elseif (c <= -7.6e-152)
		tmp = Float64(fma(c, b, Float64(d * Float64(-a))) / t_0);
	elseif (c <= 1.6e-55)
		tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d);
	elseif (c <= 2.6e+92)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / t_0);
	else
		tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c)));
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.2e+83], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -7.6e-152], N[(N[(c * b + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[c, 1.6e-55], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 2.6e+92], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / t$95$0), $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 c + d \cdot d\\
\mathbf{if}\;c \leq -2.2 \cdot 10^{+83}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

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

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

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

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


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

    1. Initial program 44.7%

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

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

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

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

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

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

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

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

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

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

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

    if -2.19999999999999999e83 < c < -7.60000000000000024e-152

    1. Initial program 81.6%

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

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

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

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

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

    if -7.60000000000000024e-152 < c < 1.6000000000000001e-55

    1. Initial program 63.9%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{c \cdot \frac{b}{d} - a}{d}} \]
    9. Step-by-step derivation
      1. *-lft-identity87.8%

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

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

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

    if 1.6000000000000001e-55 < c < 2.5999999999999999e92

    1. Initial program 80.4%

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

    if 2.5999999999999999e92 < c

    1. Initial program 35.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.2 \cdot 10^{+83}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -7.6 \cdot 10^{-152}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{-55}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+92}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 5: 82.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -2.45 \cdot 10^{+83}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.32 \cdot 10^{-152}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.65 \cdot 10^{-55}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{+80}:\\ \;\;\;\;t_0\\ \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)) (+ (* c c) (* d d)))))
   (if (<= c -2.45e+83)
     (/ (- b (* d (/ a c))) c)
     (if (<= c -1.32e-152)
       t_0
       (if (<= c 1.65e-55)
         (/ (- (/ (* c b) d) a) d)
         (if (<= c 8.2e+80) t_0 (- (/ b c) (* (/ a c) (/ d c)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -2.45e+83) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= -1.32e-152) {
		tmp = t_0;
	} else if (c <= 1.65e-55) {
		tmp = (((c * b) / d) - a) / d;
	} else if (c <= 8.2e+80) {
		tmp = t_0;
	} else {
		tmp = (b / c) - ((a / c) * (d / c));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    if (c <= (-2.45d+83)) then
        tmp = (b - (d * (a / c))) / c
    else if (c <= (-1.32d-152)) then
        tmp = t_0
    else if (c <= 1.65d-55) then
        tmp = (((c * b) / d) - a) / d
    else if (c <= 8.2d+80) then
        tmp = t_0
    else
        tmp = (b / c) - ((a / c) * (d / c))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -2.45e+83) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= -1.32e-152) {
		tmp = t_0;
	} else if (c <= 1.65e-55) {
		tmp = (((c * b) / d) - a) / d;
	} else if (c <= 8.2e+80) {
		tmp = t_0;
	} else {
		tmp = (b / c) - ((a / c) * (d / c));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -2.45e+83:
		tmp = (b - (d * (a / c))) / c
	elif c <= -1.32e-152:
		tmp = t_0
	elif c <= 1.65e-55:
		tmp = (((c * b) / d) - a) / d
	elif c <= 8.2e+80:
		tmp = t_0
	else:
		tmp = (b / c) - ((a / c) * (d / c))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (c <= -2.45e+83)
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	elseif (c <= -1.32e-152)
		tmp = t_0;
	elseif (c <= 1.65e-55)
		tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d);
	elseif (c <= 8.2e+80)
		tmp = t_0;
	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)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (c <= -2.45e+83)
		tmp = (b - (d * (a / c))) / c;
	elseif (c <= -1.32e-152)
		tmp = t_0;
	elseif (c <= 1.65e-55)
		tmp = (((c * b) / d) - a) / d;
	elseif (c <= 8.2e+80)
		tmp = t_0;
	else
		tmp = (b / c) - ((a / c) * (d / c));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.45e+83], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -1.32e-152], t$95$0, If[LessEqual[c, 1.65e-55], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 8.2e+80], t$95$0, N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.32 \cdot 10^{-152}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 8.2 \cdot 10^{+80}:\\
\;\;\;\;t_0\\

\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 < -2.44999999999999989e83

    1. Initial program 44.7%

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

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

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

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

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

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

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

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

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

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

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

    if -2.44999999999999989e83 < c < -1.31999999999999995e-152 or 1.65e-55 < c < 8.20000000000000003e80

    1. Initial program 81.1%

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

    if -1.31999999999999995e-152 < c < 1.65e-55

    1. Initial program 63.9%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{c \cdot \frac{b}{d} - a}{d}} \]
    9. Step-by-step derivation
      1. *-lft-identity87.8%

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

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

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

    if 8.20000000000000003e80 < c

    1. Initial program 35.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.45 \cdot 10^{+83}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.32 \cdot 10^{-152}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.65 \cdot 10^{-55}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{+80}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 6: 77.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -4.3 \cdot 10^{+80}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.1 \cdot 10^{-21}:\\ \;\;\;\;\frac{c}{\frac{c \cdot c + d \cdot d}{b}}\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{+44}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - 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.3e+80)
   (/ (- b (* d (/ a c))) c)
   (if (<= c -1.1e-21)
     (/ c (/ (+ (* c c) (* d d)) b))
     (if (<= c 2.7e+44)
       (/ (- (/ (* c 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.3e+80) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= -1.1e-21) {
		tmp = c / (((c * c) + (d * d)) / b);
	} else if (c <= 2.7e+44) {
		tmp = (((c * b) / d) - a) / d;
	} else {
		tmp = (b / c) - ((a / c) * (d / 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.3d+80)) then
        tmp = (b - (d * (a / c))) / c
    else if (c <= (-1.1d-21)) then
        tmp = c / (((c * c) + (d * d)) / b)
    else if (c <= 2.7d+44) then
        tmp = (((c * b) / d) - a) / d
    else
        tmp = (b / c) - ((a / c) * (d / c))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -4.3e+80) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= -1.1e-21) {
		tmp = c / (((c * c) + (d * d)) / b);
	} else if (c <= 2.7e+44) {
		tmp = (((c * 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.3e+80:
		tmp = (b - (d * (a / c))) / c
	elif c <= -1.1e-21:
		tmp = c / (((c * c) + (d * d)) / b)
	elif c <= 2.7e+44:
		tmp = (((c * 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.3e+80)
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	elseif (c <= -1.1e-21)
		tmp = Float64(c / Float64(Float64(Float64(c * c) + Float64(d * d)) / b));
	elseif (c <= 2.7e+44)
		tmp = Float64(Float64(Float64(Float64(c * b) / d) - 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.3e+80)
		tmp = (b - (d * (a / c))) / c;
	elseif (c <= -1.1e-21)
		tmp = c / (((c * c) + (d * d)) / b);
	elseif (c <= 2.7e+44)
		tmp = (((c * 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.3e+80], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -1.1e-21], N[(c / N[(N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.7e+44], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $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.3 \cdot 10^{+80}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

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

\mathbf{elif}\;c \leq 2.7 \cdot 10^{+44}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - 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.30000000000000004e80

    1. Initial program 45.9%

      \[\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-frac88.6%

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

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

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

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

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

    if -4.30000000000000004e80 < c < -1.1e-21

    1. Initial program 83.9%

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

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

        \[\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-def83.9%

        \[\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-def84.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-rr84.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 81.2%

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

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

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

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

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

    if -1.1e-21 < c < 2.7e44

    1. Initial program 69.1%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{c \cdot \frac{b}{d} - a}{d}} \]
    9. Step-by-step derivation
      1. *-lft-identity77.7%

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

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

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

    if 2.7e44 < c

    1. Initial program 44.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.3 \cdot 10^{+80}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.1 \cdot 10^{-21}:\\ \;\;\;\;\frac{c}{\frac{c \cdot c + d \cdot d}{b}}\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{+44}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 7: 77.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1 \cdot 10^{+52}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{+44}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - 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 -1e+52)
   (/ (- b (* d (/ a c))) c)
   (if (<= c 3.1e+44)
     (/ (- (/ (* c b) d) a) d)
     (- (/ b c) (* (/ a c) (/ d c))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -1e+52) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= 3.1e+44) {
		tmp = (((c * b) / d) - a) / d;
	} else {
		tmp = (b / c) - ((a / c) * (d / 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 <= (-1d+52)) then
        tmp = (b - (d * (a / c))) / c
    else if (c <= 3.1d+44) then
        tmp = (((c * b) / d) - a) / d
    else
        tmp = (b / c) - ((a / c) * (d / c))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -1e+52) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= 3.1e+44) {
		tmp = (((c * b) / d) - a) / d;
	} else {
		tmp = (b / c) - ((a / c) * (d / c));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -1e+52:
		tmp = (b - (d * (a / c))) / c
	elif c <= 3.1e+44:
		tmp = (((c * 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 <= -1e+52)
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	elseif (c <= 3.1e+44)
		tmp = Float64(Float64(Float64(Float64(c * b) / d) - 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 <= -1e+52)
		tmp = (b - (d * (a / c))) / c;
	elseif (c <= 3.1e+44)
		tmp = (((c * 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, -1e+52], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 3.1e+44], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $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 -1 \cdot 10^{+52}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

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

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


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

    1. Initial program 50.2%

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

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

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

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

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

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

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

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

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

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

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

    if -9.9999999999999999e51 < c < 3.09999999999999996e44

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{c \cdot \frac{b}{d} - a}{d}} \]
    9. Step-by-step derivation
      1. *-lft-identity74.4%

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

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

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

    if 3.09999999999999996e44 < c

    1. Initial program 44.5%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1 \cdot 10^{+52}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{+44}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 8: 73.1% accurate, 1.1× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.3e9 or 1.05e32 < d

    1. Initial program 46.3%

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

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

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

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

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

    if -1.3e9 < d < 1.05e32

    1. Initial program 72.7%

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

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

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

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

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

        \[\leadsto \frac{b}{c} + \left(-1\right) \cdot \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      4. cancel-sign-sub-inv71.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1300000000 \lor \neg \left(d \leq 1.05 \cdot 10^{+32}\right):\\ \;\;\;\;-\frac{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}\;d \leq -3.7 \cdot 10^{-73} \lor \neg \left(d \leq 3.6 \cdot 10^{+30}\right):\\ \;\;\;\;\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 (or (<= d -3.7e-73) (not (<= d 3.6e+30)))
   (/ (- (* c (/ b d)) a) d)
   (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -3.7e-73) || !(d <= 3.6e+30)) {
		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 ((d <= (-3.7d-73)) .or. (.not. (d <= 3.6d+30))) 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 ((d <= -3.7e-73) || !(d <= 3.6e+30)) {
		tmp = ((c * (b / d)) - a) / d;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -3.7e-73) or not (d <= 3.6e+30):
		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 ((d <= -3.7e-73) || !(d <= 3.6e+30))
		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 ((d <= -3.7e-73) || ~((d <= 3.6e+30)))
		tmp = ((c * (b / d)) - a) / d;
	else
		tmp = (b - (a * (d / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.7e-73], N[Not[LessEqual[d, 3.6e+30]], $MachinePrecision]], 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}\;d \leq -3.7 \cdot 10^{-73} \lor \neg \left(d \leq 3.6 \cdot 10^{+30}\right):\\
\;\;\;\;\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 2 regimes
  2. if d < -3.7000000000000001e-73 or 3.6000000000000002e30 < d

    1. Initial program 53.6%

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

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

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

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

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

        \[\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} \]
    6. Applied egg-rr75.7%

      \[\leadsto \color{blue}{\frac{c \cdot \frac{b}{d}}{d}} - \frac{a}{d} \]
    7. Step-by-step derivation
      1. sub-div75.7%

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

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

    if -3.7000000000000001e-73 < d < 3.6000000000000002e30

    1. Initial program 69.2%

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

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

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

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

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

        \[\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-rr82.9%

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

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

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

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

        \[\leadsto \frac{b}{c} + \left(-1\right) \cdot \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      4. cancel-sign-sub-inv77.3%

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a \cdot d}{c}}{c}} \]
      7. div-sub84.1%

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

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

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

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

Alternative 10: 77.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -3.45 \cdot 10^{+52}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{+44}:\\ \;\;\;\;\frac{\frac{c \cdot 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.45e+52)
   (/ (- b (* d (/ a c))) c)
   (if (<= c 2.7e+44) (/ (- (/ (* 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.45e+52) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= 2.7e+44) {
		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.45d+52)) then
        tmp = (b - (d * (a / c))) / c
    else if (c <= 2.7d+44) 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.45e+52) {
		tmp = (b - (d * (a / c))) / c;
	} else if (c <= 2.7e+44) {
		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.45e+52:
		tmp = (b - (d * (a / c))) / c
	elif c <= 2.7e+44:
		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.45e+52)
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	elseif (c <= 2.7e+44)
		tmp = Float64(Float64(Float64(Float64(c * 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.45e+52)
		tmp = (b - (d * (a / c))) / c;
	elseif (c <= 2.7e+44)
		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.45e+52], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 2.7e+44], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $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.45 \cdot 10^{+52}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

\mathbf{elif}\;c \leq 2.7 \cdot 10^{+44}:\\
\;\;\;\;\frac{\frac{c \cdot 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.44999999999999998e52

    1. Initial program 50.2%

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

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

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

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

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

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

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

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

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

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

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

    if -3.44999999999999998e52 < c < 2.7e44

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{c \cdot \frac{b}{d} - a}{d}} \]
    9. Step-by-step derivation
      1. *-lft-identity74.4%

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

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

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

    if 2.7e44 < c

    1. Initial program 44.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} + \left(-1\right) \cdot \frac{a \cdot d}{\color{blue}{c \cdot c}} \]
      4. cancel-sign-sub-inv75.5%

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a \cdot d}{c}}{c}} \]
      7. div-sub77.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.45 \cdot 10^{+52}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{+44}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]

Alternative 11: 63.0% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -9.5 \cdot 10^{-21} \lor \neg \left(c \leq 2.5 \cdot 10^{+48}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -9.4999999999999994e-21 or 2.49999999999999987e48 < c

    1. Initial program 52.5%

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

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

    if -9.4999999999999994e-21 < c < 2.49999999999999987e48

    1. Initial program 69.0%

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

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

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

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

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

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

Alternative 12: 14.7% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.2 \cdot 10^{+58}:\\
\;\;\;\;\frac{a}{d}\\

\mathbf{elif}\;d \leq 1.9 \cdot 10^{+145}:\\
\;\;\;\;\frac{a}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.19999999999999976e58 or 1.90000000000000006e145 < d

    1. Initial program 36.8%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt36.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-frac36.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-def36.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-def59.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-rr59.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 0 46.1%

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

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

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

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

    if -5.19999999999999976e58 < d < 1.90000000000000006e145

    1. Initial program 71.9%

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

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

        \[\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-def71.9%

        \[\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-def83.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.2 \cdot 10^{+58}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{+145}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{d}\\ \end{array} \]

Alternative 13: 46.4% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.5 \cdot 10^{+188}:\\
\;\;\;\;\frac{a}{d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.50000000000000013e188 or 2.05000000000000002e245 < d

    1. Initial program 44.6%

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

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

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

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

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

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

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

    if -5.50000000000000013e188 < d < 2.05000000000000002e245

    1. Initial program 63.4%

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

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

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

Alternative 14: 9.2% accurate, 5.0× speedup?

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
    2. add-sqr-sqrt61.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-frac61.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-def61.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-def75.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-rr75.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 0 27.8%

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  8. Final simplification9.5%

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

Developer target: 99.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (< (fabs d) (fabs c))
   (/ (- b (* a (/ d c))) (+ c (* d (/ d c))))
   (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (abs(d) < abs(c)) then
        tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (Math.abs(d) < Math.abs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (abs(d) < abs(c))
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (abs(d) < abs(c))
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023216 
(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))))