Complex division, imag part

Percentage Accurate: 61.0% → 91.5%
Time: 13.1s
Alternatives: 13
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 13 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.0% 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: 91.5% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -4.8 \cdot 10^{+145} \lor \neg \left(d \leq 9.6 \cdot 10^{+125}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\frac{\mathsf{hypot}\left(d, c\right)}{c}}, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot \left(-a\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= d -4.8e+145) (not (<= d 9.6e+125)))
   (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d))
   (fma
    (/ 1.0 (hypot c d))
    (/ b (/ (hypot d c) c))
    (* (/ d (pow (hypot c d) 2.0)) (- a)))))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -4.8e+145) || !(d <= 9.6e+125)) {
		tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
	} else {
		tmp = fma((1.0 / hypot(c, d)), (b / (hypot(d, c) / c)), ((d / pow(hypot(c, d), 2.0)) * -a));
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -4.8e+145) || !(d <= 9.6e+125))
		tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d));
	else
		tmp = fma(Float64(1.0 / hypot(c, d)), Float64(b / Float64(hypot(d, c) / c)), Float64(Float64(d / (hypot(c, d) ^ 2.0)) * Float64(-a)));
	end
	return tmp
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.8e+145], N[Not[LessEqual[d, 9.6e+125]], $MachinePrecision]], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[(N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.8 \cdot 10^{+145} \lor \neg \left(d \leq 9.6 \cdot 10^{+125}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -4.79999999999999984e145 or 9.5999999999999999e125 < d

    1. Initial program 29.8%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt29.8%

        \[\leadsto \frac{c \cdot b}{\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} \]
      4. times-frac30.2%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\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) \]
      10. pow247.9%

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

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

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

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

    if -4.79999999999999984e145 < d < 9.5999999999999999e125

    1. Initial program 71.1%

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

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

        \[\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} \]
      3. add-sqr-sqrt67.8%

        \[\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} \]
      4. times-frac67.9%

        \[\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} \]
      5. fma-neg68.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)} \]
      6. hypot-define68.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) \]
      7. hypot-define73.5%

        \[\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) \]
      8. associate-/l*78.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) \]
      9. add-sqr-sqrt78.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) \]
      10. pow278.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}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define78.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}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr78.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)} \]
    5. Step-by-step derivation
      1. div-inv78.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 90.6% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;d \leq -1.2 \cdot 10^{+135} \lor \neg \left(d \leq 9.2 \cdot 10^{+125}\right):\\ \;\;\;\;\mathsf{fma}\left(t\_1, t\_0, \frac{-a}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t\_1, t\_0, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot \left(-a\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ b (hypot c d))) (t_1 (/ c (hypot c d))))
   (if (or (<= d -1.2e+135) (not (<= d 9.2e+125)))
     (fma t_1 t_0 (/ (- a) d))
     (fma t_1 t_0 (* (/ d (pow (hypot c d) 2.0)) (- a))))))
double code(double a, double b, double c, double d) {
	double t_0 = b / hypot(c, d);
	double t_1 = c / hypot(c, d);
	double tmp;
	if ((d <= -1.2e+135) || !(d <= 9.2e+125)) {
		tmp = fma(t_1, t_0, (-a / d));
	} else {
		tmp = fma(t_1, t_0, ((d / pow(hypot(c, d), 2.0)) * -a));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(b / hypot(c, d))
	t_1 = Float64(c / hypot(c, d))
	tmp = 0.0
	if ((d <= -1.2e+135) || !(d <= 9.2e+125))
		tmp = fma(t_1, t_0, Float64(Float64(-a) / d));
	else
		tmp = fma(t_1, t_0, Float64(Float64(d / (hypot(c, d) ^ 2.0)) * Float64(-a)));
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[d, -1.2e+135], N[Not[LessEqual[d, 9.2e+125]], $MachinePrecision]], N[(t$95$1 * t$95$0 + N[((-a) / d), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * t$95$0 + N[(N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -1.2 \cdot 10^{+135} \lor \neg \left(d \leq 9.2 \cdot 10^{+125}\right):\\
\;\;\;\;\mathsf{fma}\left(t\_1, t\_0, \frac{-a}{d}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, t\_0, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot \left(-a\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.19999999999999999e135 or 9.20000000000000051e125 < d

    1. Initial program 29.7%

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

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

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

        \[\leadsto \frac{c \cdot b}{\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} \]
      4. times-frac30.1%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\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) \]
      10. pow249.4%

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

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

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

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

    if -1.19999999999999999e135 < d < 9.20000000000000051e125

    1. Initial program 72.1%

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

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

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

        \[\leadsto \frac{c \cdot b}{\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} \]
      4. times-frac70.8%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\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) \]
      10. pow289.3%

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

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

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

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

Alternative 3: 82.9% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\ \mathbf{if}\;d \leq -5.2 \cdot 10^{-23}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{-162}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d))))
   (if (<= d -5.2e-23)
     t_0
     (if (<= d 3.3e-162)
       (+ (* (/ (* d a) c) (/ -1.0 c)) (/ b c))
       (if (<= d 1.7e+51)
         (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
         (if (<= d 1.8e+67) (- (/ b c) (* (/ d c) (/ a c))) t_0))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
	double tmp;
	if (d <= -5.2e-23) {
		tmp = t_0;
	} else if (d <= 3.3e-162) {
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	} else if (d <= 1.7e+51) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 1.8e+67) {
		tmp = (b / c) - ((d / c) * (a / c));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d))
	tmp = 0.0
	if (d <= -5.2e-23)
		tmp = t_0;
	elseif (d <= 3.3e-162)
		tmp = Float64(Float64(Float64(Float64(d * a) / c) * Float64(-1.0 / c)) + Float64(b / c));
	elseif (d <= 1.7e+51)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 1.8e+67)
		tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c)));
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.2e-23], t$95$0, If[LessEqual[d, 3.3e-162], N[(N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e+51], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.8e+67], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -5.2e-23 or 1.7999999999999999e67 < d

    1. Initial program 42.2%

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

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

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

        \[\leadsto \frac{c \cdot b}{\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} \]
      4. times-frac41.7%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\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) \]
      10. pow263.7%

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

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

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

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

    if -5.2e-23 < d < 3.30000000000000013e-162

    1. Initial program 72.7%

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

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

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

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

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

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

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

    if 3.30000000000000013e-162 < d < 1.69999999999999992e51

    1. Initial program 82.6%

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

    if 1.69999999999999992e51 < d < 1.7999999999999999e67

    1. Initial program 26.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.2 \cdot 10^{-23}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{-162}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 76.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1.65 \cdot 10^{-22}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{c \cdot b}{-d}, \frac{-a}{d}\right)\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-163}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -1.65e-22)
   (fma (/ 1.0 (hypot c d)) (/ (* c b) (- d)) (/ (- a) d))
   (if (<= d 1.95e-163)
     (+ (* (/ (* d a) c) (/ -1.0 c)) (/ b c))
     (if (<= d 1.7e+51)
       (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
       (if (<= d 1.8e+67)
         (- (/ b c) (* (/ d c) (/ a c)))
         (- (* c (/ b (pow d 2.0))) (/ a d)))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -1.65e-22) {
		tmp = fma((1.0 / hypot(c, d)), ((c * b) / -d), (-a / d));
	} else if (d <= 1.95e-163) {
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	} else if (d <= 1.7e+51) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 1.8e+67) {
		tmp = (b / c) - ((d / c) * (a / c));
	} else {
		tmp = (c * (b / pow(d, 2.0))) - (a / d);
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -1.65e-22)
		tmp = fma(Float64(1.0 / hypot(c, d)), Float64(Float64(c * b) / Float64(-d)), Float64(Float64(-a) / d));
	elseif (d <= 1.95e-163)
		tmp = Float64(Float64(Float64(Float64(d * a) / c) * Float64(-1.0 / c)) + Float64(b / c));
	elseif (d <= 1.7e+51)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 1.8e+67)
		tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c)));
	else
		tmp = Float64(Float64(c * Float64(b / (d ^ 2.0))) - Float64(a / d));
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.65e-22], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(c * b), $MachinePrecision] / (-d)), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.95e-163], N[(N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e+51], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.8e+67], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * N[(b / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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

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


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

    1. Initial program 47.1%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-un-lft-identity47.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} \]
      3. add-sqr-sqrt47.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} \]
      4. times-frac47.1%

        \[\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} \]
      5. fma-neg47.1%

        \[\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)} \]
      6. hypot-define47.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) \]
      7. hypot-define53.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) \]
      8. associate-/l*65.9%

        \[\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) \]
      9. add-sqr-sqrt65.9%

        \[\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) \]
      10. pow265.9%

        \[\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}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define65.9%

        \[\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}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr65.9%

      \[\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)} \]
    5. Step-by-step derivation
      1. div-inv65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.65e-22 < d < 1.9500000000000001e-163

    1. Initial program 72.7%

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

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

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

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

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

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

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

    if 1.9500000000000001e-163 < d < 1.69999999999999992e51

    1. Initial program 82.6%

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

    if 1.69999999999999992e51 < d < 1.7999999999999999e67

    1. Initial program 26.8%

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

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

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

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

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

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

    if 1.7999999999999999e67 < d

    1. Initial program 35.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.65 \cdot 10^{-22}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{c \cdot b}{-d}, \frac{-a}{d}\right)\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-163}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 76.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \mathbf{if}\;d \leq -2.5 \cdot 10^{-22}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{-162}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c (/ b (pow d 2.0))) (/ a d))))
   (if (<= d -2.5e-22)
     t_0
     (if (<= d 3.3e-162)
       (+ (* (/ (* d a) c) (/ -1.0 c)) (/ b c))
       (if (<= d 1.7e+51)
         (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
         (if (<= d 3e+67) (- (/ b c) (* (/ d c) (/ a c))) t_0))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * (b / pow(d, 2.0))) - (a / d);
	double tmp;
	if (d <= -2.5e-22) {
		tmp = t_0;
	} else if (d <= 3.3e-162) {
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	} else if (d <= 1.7e+51) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 3e+67) {
		tmp = (b / c) - ((d / c) * (a / c));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (c * (b / (d ** 2.0d0))) - (a / d)
    if (d <= (-2.5d-22)) then
        tmp = t_0
    else if (d <= 3.3d-162) then
        tmp = (((d * a) / c) * ((-1.0d0) / c)) + (b / c)
    else if (d <= 1.7d+51) then
        tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
    else if (d <= 3d+67) then
        tmp = (b / c) - ((d / c) * (a / c))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * (b / Math.pow(d, 2.0))) - (a / d);
	double tmp;
	if (d <= -2.5e-22) {
		tmp = t_0;
	} else if (d <= 3.3e-162) {
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	} else if (d <= 1.7e+51) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 3e+67) {
		tmp = (b / c) - ((d / c) * (a / c));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * (b / math.pow(d, 2.0))) - (a / d)
	tmp = 0
	if d <= -2.5e-22:
		tmp = t_0
	elif d <= 3.3e-162:
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c)
	elif d <= 1.7e+51:
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
	elif d <= 3e+67:
		tmp = (b / c) - ((d / c) * (a / c))
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * Float64(b / (d ^ 2.0))) - Float64(a / d))
	tmp = 0.0
	if (d <= -2.5e-22)
		tmp = t_0;
	elseif (d <= 3.3e-162)
		tmp = Float64(Float64(Float64(Float64(d * a) / c) * Float64(-1.0 / c)) + Float64(b / c));
	elseif (d <= 1.7e+51)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 3e+67)
		tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * (b / (d ^ 2.0))) - (a / d);
	tmp = 0.0;
	if (d <= -2.5e-22)
		tmp = t_0;
	elseif (d <= 3.3e-162)
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	elseif (d <= 1.7e+51)
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	elseif (d <= 3e+67)
		tmp = (b / c) - ((d / c) * (a / c));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.5e-22], t$95$0, If[LessEqual[d, 3.3e-162], N[(N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e+51], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3e+67], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\
\mathbf{if}\;d \leq -2.5 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.49999999999999977e-22 or 3.0000000000000001e67 < d

    1. Initial program 42.2%

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

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

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

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

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

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

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

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

    if -2.49999999999999977e-22 < d < 3.30000000000000013e-162

    1. Initial program 72.7%

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

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

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

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

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

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

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

    if 3.30000000000000013e-162 < d < 1.69999999999999992e51

    1. Initial program 82.6%

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

    if 1.69999999999999992e51 < d < 3.0000000000000001e67

    1. Initial program 26.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.5 \cdot 10^{-22}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{-162}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 75.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -3.1 \cdot 10^{-22}:\\ \;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{-162}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -3.1e-22)
   (- (* b (/ c (pow d 2.0))) (/ a d))
   (if (<= d 3.3e-162)
     (+ (* (/ (* d a) c) (/ -1.0 c)) (/ b c))
     (if (<= d 1.7e+51)
       (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
       (if (<= d 2.8e+67) (- (/ b c) (* (/ d c) (/ a c))) (/ (- a) d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -3.1e-22) {
		tmp = (b * (c / pow(d, 2.0))) - (a / d);
	} else if (d <= 3.3e-162) {
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	} else if (d <= 1.7e+51) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 2.8e+67) {
		tmp = (b / c) - ((d / c) * (a / c));
	} else {
		tmp = -a / d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (d <= (-3.1d-22)) then
        tmp = (b * (c / (d ** 2.0d0))) - (a / d)
    else if (d <= 3.3d-162) then
        tmp = (((d * a) / c) * ((-1.0d0) / c)) + (b / c)
    else if (d <= 1.7d+51) then
        tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
    else if (d <= 2.8d+67) then
        tmp = (b / c) - ((d / c) * (a / c))
    else
        tmp = -a / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -3.1e-22) {
		tmp = (b * (c / Math.pow(d, 2.0))) - (a / d);
	} else if (d <= 3.3e-162) {
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	} else if (d <= 1.7e+51) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 2.8e+67) {
		tmp = (b / c) - ((d / c) * (a / c));
	} else {
		tmp = -a / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -3.1e-22:
		tmp = (b * (c / math.pow(d, 2.0))) - (a / d)
	elif d <= 3.3e-162:
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c)
	elif d <= 1.7e+51:
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
	elif d <= 2.8e+67:
		tmp = (b / c) - ((d / c) * (a / c))
	else:
		tmp = -a / d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -3.1e-22)
		tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d));
	elseif (d <= 3.3e-162)
		tmp = Float64(Float64(Float64(Float64(d * a) / c) * Float64(-1.0 / c)) + Float64(b / c));
	elseif (d <= 1.7e+51)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 2.8e+67)
		tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c)));
	else
		tmp = Float64(Float64(-a) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (d <= -3.1e-22)
		tmp = (b * (c / (d ^ 2.0))) - (a / d);
	elseif (d <= 3.3e-162)
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	elseif (d <= 1.7e+51)
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	elseif (d <= 2.8e+67)
		tmp = (b / c) - ((d / c) * (a / c));
	else
		tmp = -a / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -3.1e-22], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.3e-162], N[(N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e+51], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e+67], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-a) / d), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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

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


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

    1. Initial program 47.1%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-un-lft-identity47.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} \]
      3. add-sqr-sqrt47.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} \]
      4. times-frac47.1%

        \[\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} \]
      5. fma-neg47.1%

        \[\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)} \]
      6. hypot-define47.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) \]
      7. hypot-define53.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) \]
      8. associate-/l*65.9%

        \[\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) \]
      9. add-sqr-sqrt65.9%

        \[\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) \]
      10. pow265.9%

        \[\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}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define65.9%

        \[\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}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr65.9%

      \[\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)} \]
    5. Step-by-step derivation
      1. div-inv65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.10000000000000013e-22 < d < 3.30000000000000013e-162

    1. Initial program 72.7%

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

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

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

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

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

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

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

    if 3.30000000000000013e-162 < d < 1.69999999999999992e51

    1. Initial program 82.6%

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

    if 1.69999999999999992e51 < d < 2.7999999999999998e67

    1. Initial program 26.8%

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

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

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

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

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

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

    if 2.7999999999999998e67 < d

    1. Initial program 35.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified78.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.1 \cdot 10^{-22}:\\ \;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{-162}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 76.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ t_1 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -3.7 \cdot 10^{+93}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -1.25 \cdot 10^{-23}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 3.25 \cdot 10^{-162}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 2.2 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- a) d)) (t_1 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -3.7e+93)
     t_0
     (if (<= d -1.25e-23)
       t_1
       (if (<= d 3.25e-162)
         (+ (* (/ (* d a) c) (/ -1.0 c)) (/ b c))
         (if (<= d 1.7e+51)
           t_1
           (if (<= d 2.2e+67) (- (/ b c) (* (/ d c) (/ a c))) t_0)))))))
double code(double a, double b, double c, double d) {
	double t_0 = -a / d;
	double t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -3.7e+93) {
		tmp = t_0;
	} else if (d <= -1.25e-23) {
		tmp = t_1;
	} else if (d <= 3.25e-162) {
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	} else if (d <= 1.7e+51) {
		tmp = t_1;
	} else if (d <= 2.2e+67) {
		tmp = (b / c) - ((d / c) * (a / c));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = -a / d
    t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    if (d <= (-3.7d+93)) then
        tmp = t_0
    else if (d <= (-1.25d-23)) then
        tmp = t_1
    else if (d <= 3.25d-162) then
        tmp = (((d * a) / c) * ((-1.0d0) / c)) + (b / c)
    else if (d <= 1.7d+51) then
        tmp = t_1
    else if (d <= 2.2d+67) then
        tmp = (b / c) - ((d / c) * (a / c))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = -a / d;
	double t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -3.7e+93) {
		tmp = t_0;
	} else if (d <= -1.25e-23) {
		tmp = t_1;
	} else if (d <= 3.25e-162) {
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	} else if (d <= 1.7e+51) {
		tmp = t_1;
	} else if (d <= 2.2e+67) {
		tmp = (b / c) - ((d / c) * (a / c));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = -a / d
	t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -3.7e+93:
		tmp = t_0
	elif d <= -1.25e-23:
		tmp = t_1
	elif d <= 3.25e-162:
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c)
	elif d <= 1.7e+51:
		tmp = t_1
	elif d <= 2.2e+67:
		tmp = (b / c) - ((d / c) * (a / c))
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(-a) / d)
	t_1 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -3.7e+93)
		tmp = t_0;
	elseif (d <= -1.25e-23)
		tmp = t_1;
	elseif (d <= 3.25e-162)
		tmp = Float64(Float64(Float64(Float64(d * a) / c) * Float64(-1.0 / c)) + Float64(b / c));
	elseif (d <= 1.7e+51)
		tmp = t_1;
	elseif (d <= 2.2e+67)
		tmp = Float64(Float64(b / c) - Float64(Float64(d / c) * Float64(a / c)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = -a / d;
	t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -3.7e+93)
		tmp = t_0;
	elseif (d <= -1.25e-23)
		tmp = t_1;
	elseif (d <= 3.25e-162)
		tmp = (((d * a) / c) * (-1.0 / c)) + (b / c);
	elseif (d <= 1.7e+51)
		tmp = t_1;
	elseif (d <= 2.2e+67)
		tmp = (b / c) - ((d / c) * (a / c));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.7e+93], t$95$0, If[LessEqual[d, -1.25e-23], t$95$1, If[LessEqual[d, 3.25e-162], N[(N[(N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision] * N[(-1.0 / c), $MachinePrecision]), $MachinePrecision] + N[(b / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e+51], t$95$1, If[LessEqual[d, 2.2e+67], N[(N[(b / c), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -3.7 \cdot 10^{+93}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq -1.25 \cdot 10^{-23}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\
\;\;\;\;t\_1\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.69999999999999987e93 or 2.2e67 < d

    1. Initial program 33.0%

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

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

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

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

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

    if -3.69999999999999987e93 < d < -1.2500000000000001e-23 or 3.24999999999999994e-162 < d < 1.69999999999999992e51

    1. Initial program 80.5%

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

    if -1.2500000000000001e-23 < d < 3.24999999999999994e-162

    1. Initial program 72.7%

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

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

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

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

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

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

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

    if 1.69999999999999992e51 < d < 2.2e67

    1. Initial program 26.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.7 \cdot 10^{+93}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -1.25 \cdot 10^{-23}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.25 \cdot 10^{-162}:\\ \;\;\;\;\frac{d \cdot a}{c} \cdot \frac{-1}{c} + \frac{b}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+51}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.2 \cdot 10^{+67}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 71.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2 \cdot 10^{-21} \lor \neg \left(d \leq 1.1 \cdot 10^{+70}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.99999999999999982e-21 or 1.1e70 < d

    1. Initial program 42.2%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified71.9%

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

    if -1.99999999999999982e-21 < d < 1.1e70

    1. Initial program 74.6%

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

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

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

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

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

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

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

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

Alternative 9: 70.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.1 \cdot 10^{-22} \lor \neg \left(d \leq 1.1 \cdot 10^{+68}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.1e-22 or 1.09999999999999994e68 < d

    1. Initial program 42.2%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified71.9%

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

    if -1.1e-22 < d < 1.09999999999999994e68

    1. Initial program 74.6%

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

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

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

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

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

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

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

Alternative 10: 71.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \cdot 10^{-21} \lor \neg \left(d \leq 2.5 \cdot 10^{+67}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.2000000000000001e-21 or 2.49999999999999988e67 < d

    1. Initial program 42.2%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified71.9%

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

    if -2.2000000000000001e-21 < d < 2.49999999999999988e67

    1. Initial program 74.6%

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

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

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

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

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

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

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

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

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

Alternative 11: 62.9% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.8 \cdot 10^{-22} \lor \neg \left(d \leq 1.8 \cdot 10^{+67}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.8000000000000003e-22 or 1.7999999999999999e67 < d

    1. Initial program 42.2%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified71.9%

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

    if -5.8000000000000003e-22 < d < 1.7999999999999999e67

    1. Initial program 74.6%

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

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

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

Alternative 12: 44.3% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 64.7%

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

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

    if 6.4999999999999997e119 < d

    1. Initial program 33.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 10.9% 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 59.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  6. Final simplification9.8%

    \[\leadsto \frac{a}{d} \]
  7. Add Preprocessing

Developer target: 99.4% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024039 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :herbie-target
  (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))

  (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))