Complex division, imag part

Percentage Accurate: 61.4% → 88.4%
Time: 12.6s
Alternatives: 10
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 10 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.4% 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: 88.4% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;c \leq -1.3 \cdot 10^{-131}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;c \leq 4.1 \cdot 10^{+102}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - t\_0\\


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

    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 79.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\frac{\color{blue}{c \cdot c}}{d}} \]
      3. add-sqr-sqrt27.0%

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

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

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

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{\sqrt{d}}} \cdot \frac{a}{\sqrt{\frac{c \cdot c}{d}}} \]
      7. add-sqr-sqrt27.0%

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{\color{blue}{c}}{\sqrt{d}}} \cdot \frac{a}{\sqrt{\frac{c \cdot c}{d}}} \]
      8. sqrt-div27.0%

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

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{c}{\sqrt{d}}} \cdot \frac{a}{\frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{\sqrt{d}}} \]
      10. add-sqr-sqrt31.8%

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

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

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

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

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot \sqrt{d}}{\frac{c}{\sqrt{d}}}} \]
    10. Step-by-step derivation
      1. expm1-log1p-u31.8%

        \[\leadsto \frac{b}{c} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{a}{c} \cdot \sqrt{d}}{\frac{c}{\sqrt{d}}}\right)\right)} \]
      2. expm1-udef27.0%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\frac{a}{c} \cdot \sqrt{d}}{\frac{c}{\sqrt{d}}}\right)} - 1\right)} \]
      3. associate-/l*27.0%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{a}{c}}{\frac{\frac{c}{\sqrt{d}}}{\sqrt{d}}}}\right)} - 1\right) \]
      4. div-inv27.0%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{a}{c} \cdot \frac{1}{\frac{\frac{c}{\sqrt{d}}}{\sqrt{d}}}}\right)} - 1\right) \]
      5. associate-/r*27.0%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{1}{\color{blue}{\frac{c}{\sqrt{d} \cdot \sqrt{d}}}}\right)} - 1\right) \]
      6. add-sqr-sqrt80.2%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{1}{\frac{c}{\color{blue}{d}}}\right)} - 1\right) \]
      7. clear-num80.2%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \color{blue}{\frac{d}{c}}\right)} - 1\right) \]
    11. Applied egg-rr80.2%

      \[\leadsto \frac{b}{c} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{d}{c}\right)} - 1\right)} \]
    12. Step-by-step derivation
      1. expm1-def90.2%

        \[\leadsto \frac{b}{c} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{d}{c}\right)\right)} \]
      2. expm1-log1p90.2%

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

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

    if -1.25000000000000001e154 < c < -1.29999999999999998e-131 or 2.80000000000000011e-255 < c < 4.1e102

    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. div-sub75.2%

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

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

        \[\leadsto \color{blue}{\frac{b}{\frac{c \cdot c + d \cdot d}{c}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      4. fma-def77.4%

        \[\leadsto \frac{b}{\frac{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}{c}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      5. add-sqr-sqrt77.4%

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

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

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

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

        \[\leadsto \frac{b}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{c}} + \left(-\frac{a \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      10. add-sqr-sqrt77.4%

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

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

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

        \[\leadsto \frac{b}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{c}} + \left(-\frac{a \cdot d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr77.4%

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

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

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

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

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

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

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

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

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

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

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

    if -1.29999999999999998e-131 < c < 2.80000000000000011e-255

    1. Initial program 53.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.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1e102 < c

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{c}} + \left(-\frac{a \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      10. add-sqr-sqrt43.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot c - \frac{a}{\color{blue}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}} \]
    10. Taylor expanded in c around inf 90.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.25 \cdot 10^{+154}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1.3 \cdot 10^{-131}:\\ \;\;\;\;c \cdot \frac{b}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-255}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 4.1 \cdot 10^{+102}:\\ \;\;\;\;c \cdot \frac{b}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 79.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1 \cdot 10^{+85}:\\ \;\;\;\;\frac{c}{d \cdot \frac{d}{b}} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{-21}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{elif}\;d \leq 2.25 \cdot 10^{+52}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 7.3 \cdot 10^{+92}:\\ \;\;\;\;\frac{b}{c} + \frac{-1}{\frac{c}{d} \cdot \frac{c}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -1e+85)
   (- (/ c (* d (/ d b))) (/ a d))
   (if (<= d 1.6e-21)
     (- (/ b c) (/ a (fma c (/ c d) d)))
     (if (<= d 2.25e+52)
       (/ (- (* c b) (* a d)) (+ (* c c) (* d d)))
       (if (<= d 7.3e+92)
         (+ (/ b c) (/ -1.0 (* (/ c d) (/ c a))))
         (/ (- (* c (/ b d)) a) d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -1e+85) {
		tmp = (c / (d * (d / b))) - (a / d);
	} else if (d <= 1.6e-21) {
		tmp = (b / c) - (a / fma(c, (c / d), d));
	} else if (d <= 2.25e+52) {
		tmp = ((c * b) - (a * d)) / ((c * c) + (d * d));
	} else if (d <= 7.3e+92) {
		tmp = (b / c) + (-1.0 / ((c / d) * (c / a)));
	} else {
		tmp = ((c * (b / d)) - a) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -1e+85)
		tmp = Float64(Float64(c / Float64(d * Float64(d / b))) - Float64(a / d));
	elseif (d <= 1.6e-21)
		tmp = Float64(Float64(b / c) - Float64(a / fma(c, Float64(c / d), d)));
	elseif (d <= 2.25e+52)
		tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 7.3e+92)
		tmp = Float64(Float64(b / c) + Float64(-1.0 / Float64(Float64(c / d) * Float64(c / a))));
	else
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[d, -1e+85], N[(N[(c / N[(d * N[(d / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.6e-21], N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.25e+52], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.3e+92], N[(N[(b / c), $MachinePrecision] + N[(-1.0 / N[(N[(c / d), $MachinePrecision] * N[(c / a), $MachinePrecision]), $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 -1 \cdot 10^{+85}:\\
\;\;\;\;\frac{c}{d \cdot \frac{d}{b}} - \frac{a}{d}\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -1e85

    1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e85 < d < 1.6000000000000001e-21

    1. Initial program 71.2%

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

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

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

        \[\leadsto \color{blue}{\frac{b}{\frac{c \cdot c + d \cdot d}{c}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      4. fma-def69.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot c - \frac{a}{\color{blue}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}} \]
    10. Taylor expanded in c around inf 87.0%

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

    if 1.6000000000000001e-21 < d < 2.25e52

    1. Initial program 82.1%

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

    if 2.25e52 < d < 7.30000000000000049e92

    1. Initial program 36.0%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
    5. Simplified65.9%

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{\sqrt{d}}} \cdot \frac{a}{\sqrt{\frac{c \cdot c}{d}}} \]
      7. add-sqr-sqrt49.9%

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{\color{blue}{c}}{\sqrt{d}}} \cdot \frac{a}{\sqrt{\frac{c \cdot c}{d}}} \]
      8. sqrt-div50.0%

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

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{c}{\sqrt{d}}} \cdot \frac{a}{\frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{\sqrt{d}}} \]
      10. add-sqr-sqrt81.3%

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{1}{\frac{\frac{c}{\sqrt{d}}}{\frac{a}{c} \cdot \sqrt{d}}}} \]
      2. inv-pow81.6%

        \[\leadsto \frac{b}{c} - \color{blue}{{\left(\frac{\frac{c}{\sqrt{d}}}{\frac{a}{c} \cdot \sqrt{d}}\right)}^{-1}} \]
      3. *-un-lft-identity81.6%

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

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

        \[\leadsto \frac{b}{c} - {\left(\color{blue}{\frac{c}{a}} \cdot \frac{\frac{c}{\sqrt{d}}}{\sqrt{d}}\right)}^{-1} \]
      6. associate-/r*81.3%

        \[\leadsto \frac{b}{c} - {\left(\frac{c}{a} \cdot \color{blue}{\frac{c}{\sqrt{d} \cdot \sqrt{d}}}\right)}^{-1} \]
      7. add-sqr-sqrt81.6%

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

      \[\leadsto \frac{b}{c} - \color{blue}{{\left(\frac{c}{a} \cdot \frac{c}{d}\right)}^{-1}} \]
    12. Step-by-step derivation
      1. unpow-181.6%

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

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

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

    if 7.30000000000000049e92 < d

    1. Initial program 40.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{b}{d} \cdot c - a}{d}} \]
    11. Applied egg-rr96.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1 \cdot 10^{+85}:\\ \;\;\;\;\frac{c}{d \cdot \frac{d}{b}} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 1.6 \cdot 10^{-21}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{elif}\;d \leq 2.25 \cdot 10^{+52}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 7.3 \cdot 10^{+92}:\\ \;\;\;\;\frac{b}{c} + \frac{-1}{\frac{c}{d} \cdot \frac{c}{a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 79.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1.06 \cdot 10^{+73}:\\ \;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{elif}\;d \leq -1.52 \cdot 10^{-86}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.5:\\ \;\;\;\;\frac{b}{c} + \frac{a}{\frac{c}{d}} \cdot \frac{-1}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -1.06e+73)
   (/ (- a) (fma c (/ c d) d))
   (if (<= d -1.52e-86)
     (/ (- (* c b) (* a d)) (+ (* c c) (* d d)))
     (if (<= d 1.5)
       (+ (/ b c) (* (/ a (/ c d)) (/ -1.0 c)))
       (/ (- (* c (/ b d)) a) d)))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -1.06e+73) {
		tmp = -a / fma(c, (c / d), d);
	} else if (d <= -1.52e-86) {
		tmp = ((c * b) - (a * d)) / ((c * c) + (d * d));
	} else if (d <= 1.5) {
		tmp = (b / c) + ((a / (c / d)) * (-1.0 / c));
	} else {
		tmp = ((c * (b / d)) - a) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -1.06e+73)
		tmp = Float64(Float64(-a) / fma(c, Float64(c / d), d));
	elseif (d <= -1.52e-86)
		tmp = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 1.5)
		tmp = Float64(Float64(b / c) + Float64(Float64(a / Float64(c / d)) * Float64(-1.0 / c)));
	else
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.06e+73], N[((-a) / N[(c * N[(c / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.52e-86], N[(N[(N[(c * b), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.5], N[(N[(b / c), $MachinePrecision] + N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / c), $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 -1.06 \cdot 10^{+73}:\\
\;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\

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

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

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


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

    1. Initial program 41.1%

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

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

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

        \[\leadsto \color{blue}{\frac{b}{\frac{c \cdot c + d \cdot d}{c}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      4. fma-def41.4%

        \[\leadsto \frac{b}{\frac{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}{c}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      5. add-sqr-sqrt41.4%

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

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

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

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

        \[\leadsto \frac{b}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{c}} + \left(-\frac{a \cdot d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      10. add-sqr-sqrt41.4%

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

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

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

        \[\leadsto \frac{b}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{c}} + \left(-\frac{a \cdot d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr41.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot c - \frac{a}{\color{blue}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}} \]
    10. Taylor expanded in c around inf 51.6%

      \[\leadsto \color{blue}{\frac{b}{c}} - \frac{a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)} \]
    11. Taylor expanded in b around 0 76.2%

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d + \frac{{c}^{2}}{d}}} \]
    12. Step-by-step derivation
      1. associate-*r/76.2%

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

        \[\leadsto \frac{\color{blue}{-a}}{d + \frac{{c}^{2}}{d}} \]
      3. +-commutative76.2%

        \[\leadsto \frac{-a}{\color{blue}{\frac{{c}^{2}}{d} + d}} \]
      4. *-lft-identity76.2%

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

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

        \[\leadsto \frac{-a}{\color{blue}{\frac{c}{1} \cdot \frac{c}{d}} + d} \]
      7. /-rgt-identity82.5%

        \[\leadsto \frac{-a}{\color{blue}{c} \cdot \frac{c}{d} + d} \]
      8. fma-udef82.5%

        \[\leadsto \frac{-a}{\color{blue}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}} \]
    13. Simplified82.5%

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

    if -1.0600000000000001e73 < d < -1.52e-86

    1. Initial program 77.2%

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

    if -1.52e-86 < d < 1.5

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.5 < d

    1. Initial program 49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.06 \cdot 10^{+73}:\\ \;\;\;\;\frac{-a}{\mathsf{fma}\left(c, \frac{c}{d}, d\right)}\\ \mathbf{elif}\;d \leq -1.52 \cdot 10^{-86}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.5:\\ \;\;\;\;\frac{b}{c} + \frac{a}{\frac{c}{d}} \cdot \frac{-1}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.3% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{b}{d}}{d}} \cdot c - \frac{a}{d} \]
    10. Step-by-step derivation
      1. *-commutative78.0%

        \[\leadsto \color{blue}{c \cdot \frac{\frac{b}{d}}{d}} - \frac{a}{d} \]
      2. clear-num78.0%

        \[\leadsto c \cdot \color{blue}{\frac{1}{\frac{d}{\frac{b}{d}}}} - \frac{a}{d} \]
      3. un-div-inv78.0%

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

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

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

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

    if -7.9999999999999997e35 < d < 0.0179999999999999986

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0179999999999999986 < d

    1. Initial program 49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8 \cdot 10^{+35}:\\ \;\;\;\;\frac{c}{d \cdot \frac{d}{b}} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 0.018:\\ \;\;\;\;\frac{b}{c} + \frac{a}{\frac{c}{d}} \cdot \frac{-1}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 76.3% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.50000000000000009e34 < d < 0.170000000000000012

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\frac{\color{blue}{c \cdot c}}{d}} \]
      3. add-sqr-sqrt37.2%

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

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

        \[\leadsto \frac{b}{c} - \frac{1}{\color{blue}{\frac{\sqrt{c \cdot c}}{\sqrt{d}}}} \cdot \frac{a}{\sqrt{\frac{c \cdot c}{d}}} \]
      6. sqrt-prod19.7%

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{\sqrt{d}}} \cdot \frac{a}{\sqrt{\frac{c \cdot c}{d}}} \]
      7. add-sqr-sqrt35.3%

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

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

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{c}{\sqrt{d}}} \cdot \frac{a}{\frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{\sqrt{d}}} \]
      10. add-sqr-sqrt42.1%

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

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

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

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

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot \sqrt{d}}{\frac{c}{\sqrt{d}}}} \]
    10. Step-by-step derivation
      1. expm1-log1p-u35.7%

        \[\leadsto \frac{b}{c} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{a}{c} \cdot \sqrt{d}}{\frac{c}{\sqrt{d}}}\right)\right)} \]
      2. expm1-udef32.1%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\frac{a}{c} \cdot \sqrt{d}}{\frac{c}{\sqrt{d}}}\right)} - 1\right)} \]
      3. associate-/l*32.1%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{a}{c}}{\frac{\frac{c}{\sqrt{d}}}{\sqrt{d}}}}\right)} - 1\right) \]
      4. div-inv32.1%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{a}{c} \cdot \frac{1}{\frac{\frac{c}{\sqrt{d}}}{\sqrt{d}}}}\right)} - 1\right) \]
      5. associate-/r*32.1%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{1}{\color{blue}{\frac{c}{\sqrt{d} \cdot \sqrt{d}}}}\right)} - 1\right) \]
      6. add-sqr-sqrt69.7%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{1}{\frac{c}{\color{blue}{d}}}\right)} - 1\right) \]
      7. clear-num69.7%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \color{blue}{\frac{d}{c}}\right)} - 1\right) \]
    11. Applied egg-rr69.7%

      \[\leadsto \frac{b}{c} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{d}{c}\right)} - 1\right)} \]
    12. Step-by-step derivation
      1. expm1-def75.4%

        \[\leadsto \frac{b}{c} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{d}{c}\right)\right)} \]
      2. expm1-log1p85.1%

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

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

    if 0.170000000000000012 < d

    1. Initial program 49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.5 \cdot 10^{+34}:\\ \;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 0.17:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 76.3% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{b}{d}}{d}} \cdot c - \frac{a}{d} \]
    10. Step-by-step derivation
      1. *-commutative78.0%

        \[\leadsto \color{blue}{c \cdot \frac{\frac{b}{d}}{d}} - \frac{a}{d} \]
      2. clear-num78.0%

        \[\leadsto c \cdot \color{blue}{\frac{1}{\frac{d}{\frac{b}{d}}}} - \frac{a}{d} \]
      3. un-div-inv78.0%

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

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

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

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

    if -1.99999999999999989e34 < d < 0.23499999999999999

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{1 \cdot a}{\frac{\color{blue}{c \cdot c}}{d}} \]
      3. add-sqr-sqrt37.2%

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

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

        \[\leadsto \frac{b}{c} - \frac{1}{\color{blue}{\frac{\sqrt{c \cdot c}}{\sqrt{d}}}} \cdot \frac{a}{\sqrt{\frac{c \cdot c}{d}}} \]
      6. sqrt-prod19.7%

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{\sqrt{d}}} \cdot \frac{a}{\sqrt{\frac{c \cdot c}{d}}} \]
      7. add-sqr-sqrt35.3%

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

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

        \[\leadsto \frac{b}{c} - \frac{1}{\frac{c}{\sqrt{d}}} \cdot \frac{a}{\frac{\color{blue}{\sqrt{c} \cdot \sqrt{c}}}{\sqrt{d}}} \]
      10. add-sqr-sqrt42.1%

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

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

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

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

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot \sqrt{d}}{\frac{c}{\sqrt{d}}}} \]
    10. Step-by-step derivation
      1. expm1-log1p-u35.7%

        \[\leadsto \frac{b}{c} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{a}{c} \cdot \sqrt{d}}{\frac{c}{\sqrt{d}}}\right)\right)} \]
      2. expm1-udef32.1%

        \[\leadsto \frac{b}{c} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\frac{a}{c} \cdot \sqrt{d}}{\frac{c}{\sqrt{d}}}\right)} - 1\right)} \]
      3. associate-/l*32.1%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{a}{c}}{\frac{\frac{c}{\sqrt{d}}}{\sqrt{d}}}}\right)} - 1\right) \]
      4. div-inv32.1%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{a}{c} \cdot \frac{1}{\frac{\frac{c}{\sqrt{d}}}{\sqrt{d}}}}\right)} - 1\right) \]
      5. associate-/r*32.1%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{1}{\color{blue}{\frac{c}{\sqrt{d} \cdot \sqrt{d}}}}\right)} - 1\right) \]
      6. add-sqr-sqrt69.7%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{1}{\frac{c}{\color{blue}{d}}}\right)} - 1\right) \]
      7. clear-num69.7%

        \[\leadsto \frac{b}{c} - \left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \color{blue}{\frac{d}{c}}\right)} - 1\right) \]
    11. Applied egg-rr69.7%

      \[\leadsto \frac{b}{c} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{d}{c}\right)} - 1\right)} \]
    12. Step-by-step derivation
      1. expm1-def75.4%

        \[\leadsto \frac{b}{c} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a}{c} \cdot \frac{d}{c}\right)\right)} \]
      2. expm1-log1p85.1%

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

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

    if 0.23499999999999999 < d

    1. Initial program 49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2 \cdot 10^{+34}:\\ \;\;\;\;\frac{c}{d \cdot \frac{d}{b}} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 0.235:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 70.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.35 \cdot 10^{+20} \lor \neg \left(d \leq 1.56 \cdot 10^{-44}\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.35e20 or 1.56e-44 < d

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.35e20 < d < 1.56e-44

    1. Initial program 70.8%

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

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

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

Alternative 8: 69.3% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.8e35 < d < 9.99999999999999953e-45

    1. Initial program 70.7%

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

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

    if 9.99999999999999953e-45 < d

    1. Initial program 51.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.8 \cdot 10^{+35}:\\ \;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 10^{-44}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 63.5% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.70000000000000015e66 or 2.09999999999999987e-46 < d

    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 0 77.1%

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified77.1%

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

    if -1.70000000000000015e66 < d < 2.09999999999999987e-46

    1. Initial program 71.9%

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

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

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

Alternative 10: 42.3% accurate, 5.0× speedup?

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

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

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

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

    \[\leadsto \frac{b}{c} \]
  5. Add Preprocessing

Developer target: 99.2% 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 2024041 
(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))))