Complex division, imag part

Percentage Accurate: 61.7% → 85.2%
Time: 10.9s
Alternatives: 12
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 61.7% accurate, 1.0× speedup?

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

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

Alternative 1: 85.2% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 76.0%

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

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

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

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

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

    1. Initial program 9.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{c \cdot \frac{b}{d} - a}{d}} \]
    6. Step-by-step derivation
      1. clear-num57.8%

        \[\leadsto \frac{c \cdot \color{blue}{\frac{1}{\frac{d}{b}}} - a}{d} \]
      2. un-div-inv57.9%

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

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

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

Alternative 2: 85.8% accurate, 0.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.4000000000000001e106

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. *-commutative80.2%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{c}{\frac{d}{b}}} - a}{d} \]
    7. Applied egg-rr83.4%

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

    if -2.4000000000000001e106 < d < 5.50000000000000021e97

    1. Initial program 72.9%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-define72.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-define85.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)}} \]
    4. Applied egg-rr85.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)}} \]
    5. Taylor expanded in b around inf 82.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.50000000000000021e97 < d

    1. Initial program 37.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. *-commutative78.0%

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

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

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

Alternative 3: 82.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -2.2 \cdot 10^{+36}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -8.5 \cdot 10^{-116}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{-117}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{+55}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(d \cdot \frac{a}{c} - b\right) \cdot \frac{-1}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d)))))
   (if (<= c -2.2e+36)
     (/ (- b (* a (/ d c))) c)
     (if (<= c -8.5e-116)
       t_0
       (if (<= c 8.2e-117)
         (/ (- (* b (/ c d)) a) d)
         (if (<= c 9.5e+55) t_0 (* (- (* d (/ a c)) b) (/ -1.0 c))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -2.2e+36) {
		tmp = (b - (a * (d / c))) / c;
	} else if (c <= -8.5e-116) {
		tmp = t_0;
	} else if (c <= 8.2e-117) {
		tmp = ((b * (c / d)) - a) / d;
	} else if (c <= 9.5e+55) {
		tmp = t_0;
	} else {
		tmp = ((d * (a / c)) - b) * (-1.0 / 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 = ((b * c) - (a * d)) / ((c * c) + (d * d))
    if (c <= (-2.2d+36)) then
        tmp = (b - (a * (d / c))) / c
    else if (c <= (-8.5d-116)) then
        tmp = t_0
    else if (c <= 8.2d-117) then
        tmp = ((b * (c / d)) - a) / d
    else if (c <= 9.5d+55) then
        tmp = t_0
    else
        tmp = ((d * (a / c)) - b) * ((-1.0d0) / c)
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -2.2e+36) {
		tmp = (b - (a * (d / c))) / c;
	} else if (c <= -8.5e-116) {
		tmp = t_0;
	} else if (c <= 8.2e-117) {
		tmp = ((b * (c / d)) - a) / d;
	} else if (c <= 9.5e+55) {
		tmp = t_0;
	} else {
		tmp = ((d * (a / c)) - b) * (-1.0 / c);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -2.2e+36:
		tmp = (b - (a * (d / c))) / c
	elif c <= -8.5e-116:
		tmp = t_0
	elif c <= 8.2e-117:
		tmp = ((b * (c / d)) - a) / d
	elif c <= 9.5e+55:
		tmp = t_0
	else:
		tmp = ((d * (a / c)) - b) * (-1.0 / c)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (c <= -2.2e+36)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (c <= -8.5e-116)
		tmp = t_0;
	elseif (c <= 8.2e-117)
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d);
	elseif (c <= 9.5e+55)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(d * Float64(a / c)) - b) * Float64(-1.0 / c));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (c <= -2.2e+36)
		tmp = (b - (a * (d / c))) / c;
	elseif (c <= -8.5e-116)
		tmp = t_0;
	elseif (c <= 8.2e-117)
		tmp = ((b * (c / d)) - a) / d;
	elseif (c <= 9.5e+55)
		tmp = t_0;
	else
		tmp = ((d * (a / c)) - b) * (-1.0 / c);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.2e+36], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, -8.5e-116], t$95$0, If[LessEqual[c, 8.2e-117], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 9.5e+55], t$95$0, N[(N[(N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -8.5 \cdot 10^{-116}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 9.5 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 49.5%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt49.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-frac49.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-define49.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-define72.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)}} \]
    4. Applied egg-rr72.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)}} \]
    5. Taylor expanded in b around inf 62.1%

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

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

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

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

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

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

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

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

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

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

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

    if -2.2e36 < c < -8.4999999999999995e-116 or 8.20000000000000063e-117 < c < 9.49999999999999989e55

    1. Initial program 81.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing

    if -8.4999999999999995e-116 < c < 8.20000000000000063e-117

    1. Initial program 67.3%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. *-commutative90.0%

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

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

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

        \[\leadsto \frac{c \cdot \color{blue}{\frac{1}{\frac{d}{b}}} - a}{d} \]
      2. un-div-inv87.5%

        \[\leadsto \frac{\color{blue}{\frac{c}{\frac{d}{b}}} - a}{d} \]
    7. Applied egg-rr87.5%

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

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

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

    if 9.49999999999999989e55 < c

    1. Initial program 30.6%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. *-commutative74.9%

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

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

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

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

        \[\leadsto \left(-\color{blue}{\left(b + \left(-\frac{d \cdot a}{c}\right)\right)}\right) \cdot \frac{1}{-c} \]
      4. distribute-neg-in74.7%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.2 \cdot 10^{+36}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -8.5 \cdot 10^{-116}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{-117}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{+55}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\left(d \cdot \frac{a}{c} - b\right) \cdot \frac{-1}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.0% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.49999999999999985e-31

    1. Initial program 59.4%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt59.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-frac59.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-define59.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-define76.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)}} \]
    4. Applied egg-rr76.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)}} \]
    5. Taylor expanded in b around inf 67.8%

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

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

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

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

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

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

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

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

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

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

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

    if -3.49999999999999985e-31 < c < 2.80000000000000015e87

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot \color{blue}{\frac{1}{\frac{d}{b}}} - a}{d} \]
      2. un-div-inv76.5%

        \[\leadsto \frac{\color{blue}{\frac{c}{\frac{d}{b}}} - a}{d} \]
    7. Applied egg-rr76.5%

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

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

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

    if 2.80000000000000015e87 < c

    1. Initial program 32.9%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. mul-1-neg79.0%

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. *-commutative79.0%

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

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

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

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

        \[\leadsto \left(-\color{blue}{\left(b + \left(-\frac{d \cdot a}{c}\right)\right)}\right) \cdot \frac{1}{-c} \]
      4. distribute-neg-in78.7%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.5 \cdot 10^{-31}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{+87}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\left(d \cdot \frac{a}{c} - b\right) \cdot \frac{-1}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 76.9% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.8999999999999998e-27

    1. Initial program 59.4%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt59.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-frac59.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-define59.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-define76.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)}} \]
    4. Applied egg-rr76.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)}} \]
    5. Taylor expanded in b around inf 67.8%

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

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

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

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

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

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

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

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

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

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

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

    if -5.8999999999999998e-27 < c < 3.4000000000000002e87

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot \color{blue}{\frac{1}{\frac{d}{b}}} - a}{d} \]
      2. un-div-inv76.5%

        \[\leadsto \frac{\color{blue}{\frac{c}{\frac{d}{b}}} - a}{d} \]
    7. Applied egg-rr76.5%

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

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

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

    if 3.4000000000000002e87 < c

    1. Initial program 32.9%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. mul-1-neg79.0%

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. *-commutative79.0%

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

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    6. Step-by-step derivation
      1. div-inv78.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.9 \cdot 10^{-27}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{+87}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \left(d \cdot \frac{-1}{c}\right)}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 77.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.15 \cdot 10^{-33} \lor \neg \left(c \leq 1.18 \cdot 10^{+86}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.14999999999999993e-33 or 1.18e86 < c

    1. Initial program 48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.14999999999999993e-33 < c < 1.18e86

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot \color{blue}{\frac{1}{\frac{d}{b}}} - a}{d} \]
      2. un-div-inv76.5%

        \[\leadsto \frac{\color{blue}{\frac{c}{\frac{d}{b}}} - a}{d} \]
    7. Applied egg-rr76.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.15 \cdot 10^{-33} \lor \neg \left(c \leq 1.18 \cdot 10^{+86}\right):\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 77.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.7 \cdot 10^{-20} \lor \neg \left(d \leq 2.3 \cdot 10^{-50}\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 -2.7e-20) (not (<= d 2.3e-50)))
   (/ (- (* c (/ b d)) a) d)
   (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -2.7e-20) || !(d <= 2.3e-50)) {
		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 <= (-2.7d-20)) .or. (.not. (d <= 2.3d-50))) 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 <= -2.7e-20) || !(d <= 2.3e-50)) {
		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 <= -2.7e-20) or not (d <= 2.3e-50):
		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 <= -2.7e-20) || !(d <= 2.3e-50))
		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 <= -2.7e-20) || ~((d <= 2.3e-50)))
		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, -2.7e-20], N[Not[LessEqual[d, 2.3e-50]], $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 -2.7 \cdot 10^{-20} \lor \neg \left(d \leq 2.3 \cdot 10^{-50}\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 < -2.7e-20 or 2.3000000000000002e-50 < d

    1. Initial program 49.7%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. *-commutative73.0%

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

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

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

    if -2.7e-20 < d < 2.3000000000000002e-50

    1. Initial program 72.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. 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.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-define72.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-define88.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.7 \cdot 10^{-20} \lor \neg \left(d \leq 2.3 \cdot 10^{-50}\right):\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 70.4% accurate, 0.8× speedup?

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

    1. Initial program 49.7%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified65.0%

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

    if -3.00000000000000029e-20 < d < 1.4499999999999999e-53

    1. Initial program 72.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. 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.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-define72.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-define88.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3 \cdot 10^{-20} \lor \neg \left(d \leq 1.45 \cdot 10^{-53}\right):\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 63.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.9 \cdot 10^{-32} \lor \neg \left(c \leq 7 \cdot 10^{+45}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.90000000000000004e-32 or 7.00000000000000046e45 < c

    1. Initial program 48.0%

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

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

    if -1.90000000000000004e-32 < c < 7.00000000000000046e45

    1. Initial program 72.5%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified62.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.9 \cdot 10^{-32} \lor \neg \left(c \leq 7 \cdot 10^{+45}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{-d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 15.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.7 \cdot 10^{+124} \lor \neg \left(d \leq 6 \cdot 10^{+107}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.70000000000000021e124 or 6.00000000000000046e107 < d

    1. Initial program 32.1%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt32.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-frac32.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-define32.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-define55.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)}} \]
    4. Applied egg-rr55.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)}} \]
    5. Taylor expanded in c around 0 52.5%

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

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

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

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

    if -5.70000000000000021e124 < d < 6.00000000000000046e107

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.7 \cdot 10^{+124} \lor \neg \left(d \leq 6 \cdot 10^{+107}\right):\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 43.9% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 3.2000000000000002e210

    1. Initial program 63.3%

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

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

    if 3.2000000000000002e210 < d

    1. Initial program 36.4%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-define36.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-define44.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)}} \]
    4. Applied egg-rr44.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)}} \]
    5. Taylor expanded in c around 0 86.6%

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

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

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

      \[\leadsto \color{blue}{\frac{a}{d}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 9.7% 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. Add Preprocessing
  3. 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-define61.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-define76.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)}} \]
  4. Applied egg-rr76.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)}} \]
  5. Taylor expanded in c around 0 30.4%

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  9. Add Preprocessing

Developer Target 1: 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 2024149 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (! :herbie-platform default (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))))