Complex division, imag part

Percentage Accurate: 61.3% → 87.1%
Time: 10.0s
Alternatives: 12
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

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

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

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

\mathbf{elif}\;d \leq -3.4 \cdot 10^{-134}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a \cdot \left(-d\right)}{t\_1}\right)\\

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

\mathbf{elif}\;d \leq 7.2 \cdot 10^{+153}:\\
\;\;\;\;t\_0 \cdot \left(b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}\right) - \frac{d \cdot a}{t\_1}\\

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


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

    1. Initial program 40.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def40.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out40.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/80.4%

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

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

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

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

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

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

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

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

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

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

    if -1.4e72 < d < -3.39999999999999977e-134

    1. Initial program 81.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def81.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out81.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative86.6%

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

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

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

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

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

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

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

    if -3.39999999999999977e-134 < d < 5.2e-42

    1. Initial program 73.5%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    3. Simplified73.5%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 94.6%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in94.6%

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

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

    if 5.2e-42 < d < 7.2000000000000001e153

    1. Initial program 75.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out75.1%

        \[\leadsto \frac{\mathsf{fma}\left(b, c, \color{blue}{-a \cdot d}\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      2. fmm-def75.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.2000000000000001e153 < d

    1. Initial program 35.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def35.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 89.6%

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

        \[\leadsto \color{blue}{-\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
      2. distribute-neg-frac289.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.4 \cdot 10^{+72}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \mathbf{elif}\;d \leq -3.4 \cdot 10^{-134}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a \cdot \left(-d\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{-42}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 7.2 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}\right) - \frac{d \cdot a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 87.4% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq -3.1 \cdot 10^{-134}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 5.8 \cdot 10^{+153}:\\
\;\;\;\;t\_0\\

\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.24999999999999998e72

    1. Initial program 40.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def40.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out40.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/80.4%

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

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

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

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

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

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

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

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

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

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

    if -1.24999999999999998e72 < d < -3.10000000000000006e-134 or 5.2e-42 < d < 5.80000000000000004e153

    1. Initial program 77.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out77.6%

        \[\leadsto \frac{\mathsf{fma}\left(b, c, \color{blue}{-a \cdot d}\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      2. fmm-def77.5%

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      3. fma-undefine77.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.10000000000000006e-134 < d < 5.2e-42

    1. Initial program 73.5%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    3. Simplified73.5%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 94.6%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in94.6%

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

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

    if 5.80000000000000004e153 < d

    1. Initial program 35.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def35.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 89.6%

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

        \[\leadsto \color{blue}{-\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
      2. distribute-neg-frac289.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.25 \cdot 10^{+72}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \mathbf{elif}\;d \leq -3.1 \cdot 10^{-134}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}\right) - \frac{d \cdot a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{-42}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 5.8 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}\right) - \frac{d \cdot a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.7% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;d \leq 6.8 \cdot 10^{+14}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{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 < -2.09999999999999989e71

    1. Initial program 40.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def40.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out40.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/80.4%

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

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

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

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

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

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

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

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

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

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

    if -2.09999999999999989e71 < d < -8.0000000000000007e-130

    1. Initial program 81.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def81.4%

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

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

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

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

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

    if -8.0000000000000007e-130 < d < 6.8e14

    1. Initial program 71.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def71.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 89.0%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in89.0%

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

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

    if 6.8e14 < d

    1. Initial program 55.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 86.0%

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

        \[\leadsto \color{blue}{-\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
      2. distribute-neg-frac286.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.1 \cdot 10^{+71}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \mathbf{elif}\;d \leq -8 \cdot 10^{-130}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 6.8 \cdot 10^{+14}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 80.6% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq 2.4 \cdot 10^{+20}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{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 < -7.4e71

    1. Initial program 40.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def40.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out40.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/80.4%

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

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

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

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

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

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

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

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

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

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

    if -7.4e71 < d < -1.2200000000000001e-132

    1. Initial program 81.3%

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

    if -1.2200000000000001e-132 < d < 2.4e20

    1. Initial program 71.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def71.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 89.0%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in89.0%

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

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

    if 2.4e20 < d

    1. Initial program 55.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 86.0%

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

        \[\leadsto \color{blue}{-\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
      2. distribute-neg-frac286.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.4 \cdot 10^{+71}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \mathbf{elif}\;d \leq -1.22 \cdot 10^{-132}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{+20}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 75.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.5 \cdot 10^{+114} \lor \neg \left(d \leq 6.2 \cdot 10^{+19}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -4.5000000000000001e114 or 6.2e19 < d

    1. Initial program 50.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def50.0%

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    3. Simplified50.0%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out50.0%

        \[\leadsto \frac{\mathsf{fma}\left(b, c, \color{blue}{-a \cdot d}\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      2. fmm-def50.0%

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      3. fma-undefine50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/88.5%

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

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

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

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

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

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

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

    if -4.5000000000000001e114 < d < 6.2e19

    1. Initial program 71.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def71.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out71.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      9. fmm-def64.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-\color{blue}{d \cdot a}}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right) \]
      6. distribute-rgt-neg-in83.5%

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

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

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

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

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

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

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

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

Alternative 6: 72.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.1 \cdot 10^{+62} \lor \neg \left(d \leq 1.6 \cdot 10^{+25}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.10000000000000014e62 or 1.6e25 < d

    1. Initial program 49.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def49.3%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around 0 74.5%

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified74.5%

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

    if -3.10000000000000014e62 < d < 1.6e25

    1. Initial program 73.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def73.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out73.8%

        \[\leadsto \frac{\mathsf{fma}\left(b, c, \color{blue}{-a \cdot d}\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      2. fmm-def73.8%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      9. fmm-def66.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 77.1% accurate, 0.8× speedup?

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

\mathbf{elif}\;d \leq 5.5 \cdot 10^{+16}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{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 < -2.7000000000000002e61

    1. Initial program 41.5%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    3. Simplified41.5%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out41.5%

        \[\leadsto \frac{\mathsf{fma}\left(b, c, \color{blue}{-a \cdot d}\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      2. fmm-def41.5%

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      3. fma-undefine41.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/80.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b}{\frac{d}{c}}} - a}{d} \]
    13. Applied egg-rr80.8%

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

    if -2.7000000000000002e61 < d < 5.5e16

    1. Initial program 73.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def73.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 83.8%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in83.8%

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

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

    if 5.5e16 < d

    1. Initial program 55.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 86.0%

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

        \[\leadsto \color{blue}{-\frac{a + -1 \cdot \frac{b \cdot c}{d}}{d}} \]
      2. distribute-neg-frac286.0%

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

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

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

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

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

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

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

Alternative 8: 76.9% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 41.5%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    3. Simplified41.5%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out41.5%

        \[\leadsto \frac{\mathsf{fma}\left(b, c, \color{blue}{-a \cdot d}\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      2. fmm-def41.5%

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      3. fma-undefine41.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/80.8%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b}{\frac{d}{c}}} - a}{d} \]
    13. Applied egg-rr80.8%

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

    if -2.7000000000000002e61 < d < 4.3e14

    1. Initial program 73.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def73.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 83.8%

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

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

        \[\leadsto \frac{b + \frac{\color{blue}{-a \cdot d}}{c}}{c} \]
      3. distribute-rgt-neg-in83.8%

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

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

    if 4.3e14 < d

    1. Initial program 55.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out55.5%

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

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      3. fma-undefine55.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative63.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/90.3%

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

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

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

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

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

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

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

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

Alternative 9: 75.9% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 42.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def42.0%

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    3. Simplified42.0%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out42.0%

        \[\leadsto \frac{\mathsf{fma}\left(b, c, \color{blue}{-a \cdot d}\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      2. fmm-def42.0%

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      3. fma-undefine42.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative53.6%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-\color{blue}{d \cdot a}}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right) \]
      6. distribute-rgt-neg-in54.5%

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/85.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b \cdot \frac{c}{d} - a}{d}} \]
    12. Step-by-step derivation
      1. clear-num85.9%

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

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

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

    if -6.0000000000000001e114 < d < 1.9e15

    1. Initial program 71.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def71.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out71.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      9. fmm-def64.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-\color{blue}{d \cdot a}}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right) \]
      6. distribute-rgt-neg-in83.5%

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

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

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

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

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

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

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

    if 1.9e15 < d

    1. Initial program 55.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-rgt-neg-out55.5%

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

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      3. fma-undefine55.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    7. Step-by-step derivation
      1. *-commutative63.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} + -1 \cdot a}{d} \]
      3. associate-*r/90.3%

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

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

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

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

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

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

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

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

Alternative 10: 63.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.25 \cdot 10^{-63} \lor \neg \left(d \leq 2.35 \cdot 10^{+20}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.25e-63 or 2.35e20 < d

    1. Initial program 53.5%

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    3. Simplified53.5%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around 0 68.0%

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified68.0%

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

    if -2.25e-63 < d < 2.35e20

    1. Initial program 73.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 70.4%

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

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

Alternative 11: 45.2% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.85 \cdot 10^{+212} \lor \neg \left(d \leq 7 \cdot 10^{+75}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.8499999999999998e212 or 6.9999999999999997e75 < d

    1. Initial program 47.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def47.3%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around 0 78.0%

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified78.0%

      \[\leadsto \color{blue}{\frac{-a}{d}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt37.7%

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

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}}{d} \]
      3. sqr-neg48.1%

        \[\leadsto \frac{\sqrt{\color{blue}{a \cdot a}}}{d} \]
      4. sqrt-unprod17.7%

        \[\leadsto \frac{\color{blue}{\sqrt{a} \cdot \sqrt{a}}}{d} \]
      5. add-sqr-sqrt34.5%

        \[\leadsto \frac{\color{blue}{a}}{d} \]
      6. *-un-lft-identity34.5%

        \[\leadsto \color{blue}{1 \cdot \frac{a}{d}} \]
    9. Applied egg-rr34.5%

      \[\leadsto \color{blue}{1 \cdot \frac{a}{d}} \]
    10. Step-by-step derivation
      1. *-lft-identity34.5%

        \[\leadsto \color{blue}{\frac{a}{d}} \]
    11. Simplified34.5%

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

    if -1.8499999999999998e212 < d < 6.9999999999999997e75

    1. Initial program 68.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fmm-def69.0%

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    3. Simplified69.0%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 53.8%

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

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

Alternative 12: 10.6% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \frac{a}{d} \end{array} \]
(FPCore (a b c d) :precision binary64 (/ a d))
double code(double a, double b, double c, double d) {
	return a / 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 = a / d
end function
public static double code(double a, double b, double c, double d) {
	return a / d;
}
def code(a, b, c, d):
	return a / d
function code(a, b, c, d)
	return Float64(a / d)
end
function tmp = code(a, b, c, d)
	tmp = a / d;
end
code[a_, b_, c_, d_] := N[(a / d), $MachinePrecision]
\begin{array}{l}

\\
\frac{a}{d}
\end{array}
Derivation
  1. Initial program 62.4%

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Step-by-step derivation
    1. fmm-def62.4%

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

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in c around 0 43.1%

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

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

      \[\leadsto \frac{\color{blue}{-a}}{d} \]
  7. Simplified43.1%

    \[\leadsto \color{blue}{\frac{-a}{d}} \]
  8. Step-by-step derivation
    1. add-sqr-sqrt18.9%

      \[\leadsto \frac{\color{blue}{\sqrt{-a} \cdot \sqrt{-a}}}{d} \]
    2. sqrt-unprod22.9%

      \[\leadsto \frac{\color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}}{d} \]
    3. sqr-neg22.9%

      \[\leadsto \frac{\sqrt{\color{blue}{a \cdot a}}}{d} \]
    4. sqrt-unprod7.3%

      \[\leadsto \frac{\color{blue}{\sqrt{a} \cdot \sqrt{a}}}{d} \]
    5. add-sqr-sqrt13.6%

      \[\leadsto \frac{\color{blue}{a}}{d} \]
    6. *-un-lft-identity13.6%

      \[\leadsto \color{blue}{1 \cdot \frac{a}{d}} \]
  9. Applied egg-rr13.6%

    \[\leadsto \color{blue}{1 \cdot \frac{a}{d}} \]
  10. Step-by-step derivation
    1. *-lft-identity13.6%

      \[\leadsto \color{blue}{\frac{a}{d}} \]
  11. Simplified13.6%

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  12. Add Preprocessing

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

  :alt
  (! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))

  (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))