Complex division, imag part

Percentage Accurate: 61.2% → 95.6%
Time: 10.6s
Alternatives: 9
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 9 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.2% 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: 95.6% accurate, 0.0× speedup?

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

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

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

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

      \[\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-sqrt58.4%

      \[\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-frac61.5%

      \[\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-neg61.5%

      \[\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-define61.5%

      \[\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-define78.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*81.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-sqrt81.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. pow281.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-define81.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-rr81.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. Step-by-step derivation
    1. *-un-lft-identity81.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 89.6% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq -1 \cdot 10^{-134}:\\
\;\;\;\;t\_2\\

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

\mathbf{elif}\;d \leq 2.6 \cdot 10^{+147}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.9999999999999998e131 or 2.5999999999999999e147 < d

    1. Initial program 31.5%

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

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

        \[\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-sqrt31.5%

        \[\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-frac31.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-neg31.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-define31.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-define49.6%

        \[\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*53.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-sqrt53.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. pow253.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-define53.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-rr53.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 93.9%

      \[\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 -6.9999999999999998e131 < d < -1.00000000000000004e-134 or 460 < d < 2.5999999999999999e147

    1. Initial program 72.4%

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

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

        \[\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-sqrt72.4%

        \[\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-frac77.0%

        \[\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-neg77.0%

        \[\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-define77.0%

        \[\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-define88.5%

        \[\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*93.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-sqrt93.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. pow293.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-define93.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-rr93.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)} \]

    if -1.00000000000000004e-134 < d < 460

    1. Initial program 66.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7 \cdot 10^{+131}:\\ \;\;\;\;\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 -1 \cdot 10^{-134}:\\ \;\;\;\;\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)\\ \mathbf{elif}\;d \leq 460:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{+147}:\\ \;\;\;\;\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)\\ \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 3: 83.7% 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 -4.6 \cdot 10^{+102}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -3.15 \cdot 10^{-50}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 35000000000:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{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 -4.6e+102)
     t_0
     (if (<= d -3.15e-50)
       (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
       (if (<= d 35000000000.0) (/ (- b (* a (/ d c))) 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 <= -4.6e+102) {
		tmp = t_0;
	} else if (d <= -3.15e-50) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 35000000000.0) {
		tmp = (b - (a * (d / c))) / 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(a / Float64(-d)))
	tmp = 0.0
	if (d <= -4.6e+102)
		tmp = t_0;
	elseif (d <= -3.15e-50)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 35000000000.0)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / 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, -4.6e+102], t$95$0, If[LessEqual[d, -3.15e-50], 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, 35000000000.0], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $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 -4.6 \cdot 10^{+102}:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.5999999999999998e102 or 3.5e10 < d

    1. Initial program 44.9%

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

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

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

        \[\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-frac46.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-neg46.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-define46.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-define61.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*70.0%

        \[\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-sqrt70.0%

        \[\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. pow270.0%

        \[\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-define70.0%

        \[\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-rr70.0%

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

      \[\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.5999999999999998e102 < d < -3.15000000000000011e-50

    1. Initial program 83.0%

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

    if -3.15000000000000011e-50 < d < 3.5e10

    1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.6 \cdot 10^{+102}:\\ \;\;\;\;\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.15 \cdot 10^{-50}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 35000000000:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{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: 81.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -1.7 \cdot 10^{+106}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -2.4 \cdot 10^{-45}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 460:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.5 \cdot 10^{+75}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -1.7e+106)
     (/ (- (* c (/ b d)) a) d)
     (if (<= d -2.4e-45)
       t_0
       (if (<= d 460.0)
         (/ (- b (* a (/ d c))) c)
         (if (<= d 3.5e+75) t_0 (/ (- (* b (/ c d)) a) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -1.7e+106) {
		tmp = ((c * (b / d)) - a) / d;
	} else if (d <= -2.4e-45) {
		tmp = t_0;
	} else if (d <= 460.0) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= 3.5e+75) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    if (d <= (-1.7d+106)) then
        tmp = ((c * (b / d)) - a) / d
    else if (d <= (-2.4d-45)) then
        tmp = t_0
    else if (d <= 460.0d0) then
        tmp = (b - (a * (d / c))) / c
    else if (d <= 3.5d+75) then
        tmp = t_0
    else
        tmp = ((b * (c / d)) - a) / d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -1.7e+106) {
		tmp = ((c * (b / d)) - a) / d;
	} else if (d <= -2.4e-45) {
		tmp = t_0;
	} else if (d <= 460.0) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= 3.5e+75) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -1.7e+106:
		tmp = ((c * (b / d)) - a) / d
	elif d <= -2.4e-45:
		tmp = t_0
	elif d <= 460.0:
		tmp = (b - (a * (d / c))) / c
	elif d <= 3.5e+75:
		tmp = t_0
	else:
		tmp = ((b * (c / d)) - a) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -1.7e+106)
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	elseif (d <= -2.4e-45)
		tmp = t_0;
	elseif (d <= 460.0)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (d <= 3.5e+75)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -1.7e+106)
		tmp = ((c * (b / d)) - a) / d;
	elseif (d <= -2.4e-45)
		tmp = t_0;
	elseif (d <= 460.0)
		tmp = (b - (a * (d / c))) / c;
	elseif (d <= 3.5e+75)
		tmp = t_0;
	else
		tmp = ((b * (c / d)) - a) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.7e+106], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -2.4e-45], t$95$0, If[LessEqual[d, 460.0], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.5e+75], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -2.4 \cdot 10^{-45}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 3.5 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

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

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

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

    if -1.69999999999999997e106 < d < -2.3999999999999999e-45 or 460 < d < 3.4999999999999998e75

    1. Initial program 86.2%

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

    if -2.3999999999999999e-45 < d < 460

    1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.4999999999999998e75 < d

    1. Initial program 38.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub38.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. *-commutative38.1%

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

        \[\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-frac40.4%

        \[\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-neg40.4%

        \[\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-define40.4%

        \[\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-define51.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.2%

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

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

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

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

      \[\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 c around 0 70.1%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.7 \cdot 10^{+106}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -2.4 \cdot 10^{-45}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 460:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.5 \cdot 10^{+75}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 65.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.6 \cdot 10^{-51} \lor \neg \left(c \leq 1.22 \cdot 10^{-210}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.6e-51 or 1.22e-210 < c

    1. Initial program 55.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      9. remove-double-neg75.9%

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

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

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

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

    if -2.6e-51 < c < 1.22e-210

    1. Initial program 69.9%

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

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

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

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

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

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

Alternative 6: 76.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.2 \cdot 10^{-51} \lor \neg \left(c \leq 8.5 \cdot 10^{-47}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -6.1999999999999995e-51 or 8.4999999999999999e-47 < c

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.1999999999999995e-51 < c < 8.4999999999999999e-47

    1. Initial program 68.5%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub64.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. *-commutative64.1%

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

        \[\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-frac63.3%

        \[\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-neg63.3%

        \[\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-define63.4%

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

        \[\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*75.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-sqrt75.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. pow275.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-define75.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-rr75.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)} \]
    5. Taylor expanded in c around 0 77.3%

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

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

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

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

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

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

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

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

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

Alternative 7: 62.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.1 \cdot 10^{-51} \lor \neg \left(c \leq 4.2 \cdot 10^{-47}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.09999999999999973e-51 or 4.2000000000000001e-47 < c

    1. Initial program 54.5%

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

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

    if -4.09999999999999973e-51 < c < 4.2000000000000001e-47

    1. Initial program 68.5%

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

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

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

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

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

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

Alternative 8: 45.5% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.8000000000000003e116 or 6.9999999999999998e153 < d

    1. Initial program 32.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{d}{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{a}\right)}\right)}^{-1} \]
    7. Applied egg-rr39.3%

      \[\leadsto \color{blue}{{\left(\frac{d}{\mathsf{fma}\left(c, \frac{b}{d}, a\right)}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-139.3%

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

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

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

    if -5.8000000000000003e116 < d < 6.9999999999999998e153

    1. Initial program 69.3%

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

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

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

Alternative 9: 11.1% 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 60.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\frac{d}{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{a}\right)}\right)}^{-1} \]
  7. Applied egg-rr16.3%

    \[\leadsto \color{blue}{{\left(\frac{d}{\mathsf{fma}\left(c, \frac{b}{d}, a\right)}\right)}^{-1}} \]
  8. Step-by-step derivation
    1. unpow-116.3%

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

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

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  11. Final simplification10.0%

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

Developer target: 99.3% 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 2024096 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (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))))