Complex division, imag part

Percentage Accurate: 61.1% → 96.9%
Time: 15.1s
Alternatives: 13
Speedup: 1.8×

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.1% 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: 96.9% 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)}, \frac{\frac{-d}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}\right) \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (fma
  (/ c (hypot c d))
  (/ b (hypot c d))
  (/ (/ (- d) (hypot c d)) (/ (hypot c d) a))))
double code(double a, double b, double c, double d) {
	return fma((c / hypot(c, d)), (b / hypot(c, d)), ((-d / hypot(c, d)) / (hypot(c, d) / a)));
}
function code(a, b, c, d)
	return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(Float64(-d) / hypot(c, d)) / Float64(hypot(c, d) / a)))
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[(N[((-d) / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $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)}, \frac{\frac{-d}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}\right)
\end{array}
Derivation
  1. Initial program 63.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
    6. fma-def62.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)} \]
    7. hypot-def62.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) \]
    8. hypot-def75.1%

      \[\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) \]
    9. associate-/l*79.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.0% 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)}, \frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{-d}{\mathsf{hypot}\left(c, d\right)}\right) \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (fma
  (/ c (hypot c d))
  (/ b (hypot c d))
  (* (/ a (hypot c d)) (/ (- d) (hypot c d)))))
double code(double a, double b, double c, double d) {
	return fma((c / hypot(c, d)), (b / hypot(c, d)), ((a / hypot(c, d)) * (-d / hypot(c, d))));
}
function code(a, b, c, d)
	return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(a / hypot(c, d)) * Float64(Float64(-d) / hypot(c, d))))
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[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[((-d) / N[Sqrt[c ^ 2 + d ^ 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)}, \frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{-d}{\mathsf{hypot}\left(c, d\right)}\right)
\end{array}
Derivation
  1. Initial program 63.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
    6. fma-def62.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)} \]
    7. hypot-def62.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) \]
    8. hypot-def75.1%

      \[\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) \]
    9. associate-/l*79.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 91.0% accurate, 0.0× speedup?

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

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

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


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

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000004e90 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 21.5%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      3. *-un-lft-identity19.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c\right)}}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      4. add-sqr-sqrt19.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}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      5. times-frac19.8%

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

        \[\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)} \]
      7. hypot-def19.9%

        \[\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) \]
      8. hypot-def22.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) \]
      9. associate-/l*29.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 88.9% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ \mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+254}:\\ \;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\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} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))))
   (if (<= (/ t_0 (+ (* c c) (* d d))) 1e+254)
     (/ (/ t_0 (hypot c d)) (hypot c d))
     (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d)))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if ((t_0 / ((c * c) + (d * d))) <= 1e+254) {
		tmp = (t_0 / hypot(c, d)) / hypot(c, d);
	} else {
		tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+254)
		tmp = Float64(Float64(t_0 / hypot(c, d)) / hypot(c, d));
	else
		tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d));
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+254], N[(N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $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]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+254}:\\
\;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999994e253

    1. Initial program 82.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 11.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      6. fma-def16.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)} \]
      7. hypot-def16.3%

        \[\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) \]
      8. hypot-def45.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) \]
      9. associate-/l*58.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 10^{+254}:\\ \;\;\;\;\frac{\frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\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 5: 85.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\ \mathbf{if}\;t_1 \leq 10^{+254}:\\ \;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;\left|\frac{a + c \cdot \frac{b}{d}}{\mathsf{hypot}\left(d, c\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
   (if (<= t_1 1e+254)
     (/ (/ t_0 (hypot c d)) (hypot c d))
     (if (<= t_1 INFINITY)
       (fabs (/ (+ a (* c (/ b d))) (hypot d c)))
       (/ (- b (* d (/ a c))) c)))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = t_0 / ((c * c) + (d * d));
	double tmp;
	if (t_1 <= 1e+254) {
		tmp = (t_0 / hypot(c, d)) / hypot(c, d);
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = fabs(((a + (c * (b / d))) / hypot(d, c)));
	} else {
		tmp = (b - (d * (a / c))) / c;
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = t_0 / ((c * c) + (d * d));
	double tmp;
	if (t_1 <= 1e+254) {
		tmp = (t_0 / Math.hypot(c, d)) / Math.hypot(c, d);
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = Math.abs(((a + (c * (b / d))) / Math.hypot(d, c)));
	} else {
		tmp = (b - (d * (a / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	t_1 = t_0 / ((c * c) + (d * d))
	tmp = 0
	if t_1 <= 1e+254:
		tmp = (t_0 / math.hypot(c, d)) / math.hypot(c, d)
	elif t_1 <= math.inf:
		tmp = math.fabs(((a + (c * (b / d))) / math.hypot(d, c)))
	else:
		tmp = (b - (d * (a / c))) / c
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (t_1 <= 1e+254)
		tmp = Float64(Float64(t_0 / hypot(c, d)) / hypot(c, d));
	elseif (t_1 <= Inf)
		tmp = abs(Float64(Float64(a + Float64(c * Float64(b / d))) / hypot(d, c)));
	else
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	t_1 = t_0 / ((c * c) + (d * d));
	tmp = 0.0;
	if (t_1 <= 1e+254)
		tmp = (t_0 / hypot(c, d)) / hypot(c, d);
	elseif (t_1 <= Inf)
		tmp = abs(((a + (c * (b / d))) / hypot(d, c)));
	else
		tmp = (b - (d * (a / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e+254], N[(N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[Abs[N[(N[(a + N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\left|\frac{a + c \cdot \frac{b}{d}}{\mathsf{hypot}\left(d, c\right)}\right|\\

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


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

    1. Initial program 82.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0

    1. Initial program 35.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{a + c \cdot \frac{b}{d}}{\color{blue}{\sqrt{c \cdot c + d \cdot d}}}\right| \]
      6. unpow261.5%

        \[\leadsto \left|\frac{a + c \cdot \frac{b}{d}}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}}\right| \]
      7. unpow261.5%

        \[\leadsto \left|\frac{a + c \cdot \frac{b}{d}}{\sqrt{{c}^{2} + \color{blue}{{d}^{2}}}}\right| \]
      8. +-commutative61.5%

        \[\leadsto \left|\frac{a + c \cdot \frac{b}{d}}{\sqrt{\color{blue}{{d}^{2} + {c}^{2}}}}\right| \]
      9. unpow261.5%

        \[\leadsto \left|\frac{a + c \cdot \frac{b}{d}}{\sqrt{\color{blue}{d \cdot d} + {c}^{2}}}\right| \]
      10. unpow261.5%

        \[\leadsto \left|\frac{a + c \cdot \frac{b}{d}}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}}\right| \]
      11. hypot-def78.6%

        \[\leadsto \left|\frac{a + c \cdot \frac{b}{d}}{\color{blue}{\mathsf{hypot}\left(d, c\right)}}\right| \]
    11. Simplified78.6%

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

    if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 82.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -1.55 \cdot 10^{+95}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-145}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{+80}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= c -1.55e+95)
     (- (/ b c) (/ (/ a c) (/ c d)))
     (if (<= c -4.2e-100)
       t_0
       (if (<= c 3.1e-145)
         (* (/ 1.0 d) (- (/ (* c b) d) a))
         (if (<= c 3.4e+80)
           t_0
           (* (/ 1.0 (hypot c d)) (- b (/ a (/ c 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 (c <= -1.55e+95) {
		tmp = (b / c) - ((a / c) / (c / d));
	} else if (c <= -4.2e-100) {
		tmp = t_0;
	} else if (c <= 3.1e-145) {
		tmp = (1.0 / d) * (((c * b) / d) - a);
	} else if (c <= 3.4e+80) {
		tmp = t_0;
	} else {
		tmp = (1.0 / hypot(c, d)) * (b - (a / (c / d)));
	}
	return tmp;
}
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 (c <= -1.55e+95) {
		tmp = (b / c) - ((a / c) / (c / d));
	} else if (c <= -4.2e-100) {
		tmp = t_0;
	} else if (c <= 3.1e-145) {
		tmp = (1.0 / d) * (((c * b) / d) - a);
	} else if (c <= 3.4e+80) {
		tmp = t_0;
	} else {
		tmp = (1.0 / Math.hypot(c, d)) * (b - (a / (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -1.55e+95:
		tmp = (b / c) - ((a / c) / (c / d))
	elif c <= -4.2e-100:
		tmp = t_0
	elif c <= 3.1e-145:
		tmp = (1.0 / d) * (((c * b) / d) - a)
	elif c <= 3.4e+80:
		tmp = t_0
	else:
		tmp = (1.0 / math.hypot(c, d)) * (b - (a / (c / 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 (c <= -1.55e+95)
		tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d)));
	elseif (c <= -4.2e-100)
		tmp = t_0;
	elseif (c <= 3.1e-145)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(Float64(c * b) / d) - a));
	elseif (c <= 3.4e+80)
		tmp = t_0;
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b - Float64(a / Float64(c / 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 (c <= -1.55e+95)
		tmp = (b / c) - ((a / c) / (c / d));
	elseif (c <= -4.2e-100)
		tmp = t_0;
	elseif (c <= 3.1e-145)
		tmp = (1.0 / d) * (((c * b) / d) - a);
	elseif (c <= 3.4e+80)
		tmp = t_0;
	else
		tmp = (1.0 / hypot(c, d)) * (b - (a / (c / 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[c, -1.55e+95], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -4.2e-100], t$95$0, If[LessEqual[c, 3.1e-145], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.4e+80], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 3.1 \cdot 10^{-145}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\

\mathbf{elif}\;c \leq 3.4 \cdot 10^{+80}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.5500000000000001e95 < c < -4.20000000000000019e-100 or 3.1e-145 < c < 3.39999999999999992e80

    1. Initial program 86.4%

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

    if -4.20000000000000019e-100 < c < 3.1e-145

    1. Initial program 59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.39999999999999992e80 < c

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.55 \cdot 10^{+95}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-145}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{+80}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 82.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -2.8 \cdot 10^{+91}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}\\ \mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{+80}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= c -2.8e+91)
     (- (/ b c) (/ (/ a c) (/ c d)))
     (if (<= c -4.2e-100)
       t_0
       (if (<= c 2.8e-146)
         (* (/ 1.0 d) (- (/ (* c b) d) a))
         (if (<= c 4.3e+80) t_0 (/ (- b (* d (/ a c))) c)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -2.8e+91) {
		tmp = (b / c) - ((a / c) / (c / d));
	} else if (c <= -4.2e-100) {
		tmp = t_0;
	} else if (c <= 2.8e-146) {
		tmp = (1.0 / d) * (((c * b) / d) - a);
	} else if (c <= 4.3e+80) {
		tmp = t_0;
	} else {
		tmp = (b - (d * (a / 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) :: t_0
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    if (c <= (-2.8d+91)) then
        tmp = (b / c) - ((a / c) / (c / d))
    else if (c <= (-4.2d-100)) then
        tmp = t_0
    else if (c <= 2.8d-146) then
        tmp = (1.0d0 / d) * (((c * b) / d) - a)
    else if (c <= 4.3d+80) then
        tmp = t_0
    else
        tmp = (b - (d * (a / c))) / c
    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 (c <= -2.8e+91) {
		tmp = (b / c) - ((a / c) / (c / d));
	} else if (c <= -4.2e-100) {
		tmp = t_0;
	} else if (c <= 2.8e-146) {
		tmp = (1.0 / d) * (((c * b) / d) - a);
	} else if (c <= 4.3e+80) {
		tmp = t_0;
	} else {
		tmp = (b - (d * (a / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -2.8e+91:
		tmp = (b / c) - ((a / c) / (c / d))
	elif c <= -4.2e-100:
		tmp = t_0
	elif c <= 2.8e-146:
		tmp = (1.0 / d) * (((c * b) / d) - a)
	elif c <= 4.3e+80:
		tmp = t_0
	else:
		tmp = (b - (d * (a / c))) / c
	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 (c <= -2.8e+91)
		tmp = Float64(Float64(b / c) - Float64(Float64(a / c) / Float64(c / d)));
	elseif (c <= -4.2e-100)
		tmp = t_0;
	elseif (c <= 2.8e-146)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(Float64(c * b) / d) - a));
	elseif (c <= 4.3e+80)
		tmp = t_0;
	else
		tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c);
	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 (c <= -2.8e+91)
		tmp = (b / c) - ((a / c) / (c / d));
	elseif (c <= -4.2e-100)
		tmp = t_0;
	elseif (c <= 2.8e-146)
		tmp = (1.0 / d) * (((c * b) / d) - a);
	elseif (c <= 4.3e+80)
		tmp = t_0;
	else
		tmp = (b - (d * (a / c))) / c;
	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[c, -2.8e+91], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -4.2e-100], t$95$0, If[LessEqual[c, 2.8e-146], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.3e+80], t$95$0, N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 2.8 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c \cdot b}{d} - a\right)\\

\mathbf{elif}\;c \leq 4.3 \cdot 10^{+80}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.7999999999999999e91 < c < -4.20000000000000019e-100 or 2.80000000000000003e-146 < c < 4.30000000000000004e80

    1. Initial program 86.4%

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

    if -4.20000000000000019e-100 < c < 2.80000000000000003e-146

    1. Initial program 59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.30000000000000004e80 < c

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 77.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.5 \cdot 10^{+48} \lor \neg \left(c \leq 7.5 \cdot 10^{+79}\right):\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -6.49999999999999972e48 or 7.49999999999999967e79 < c

    1. Initial program 46.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.49999999999999972e48 < c < 7.49999999999999967e79

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 72.3% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.05e47 or 2.4e62 < d

    1. Initial program 50.0%

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

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

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

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

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

    if -1.05e47 < d < 2.4e62

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 63.7% accurate, 1.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.5000000000000001e46 or 4.1e58 < d

    1. Initial program 50.0%

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

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

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

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

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

    if -2.5000000000000001e46 < d < 4.1e58

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

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

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

Alternative 11: 43.8% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.7 \cdot 10^{+259} \lor \neg \left(d \leq 2.25 \cdot 10^{+176}\right):\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.70000000000000015e259 or 2.25000000000000002e176 < d

    1. Initial program 53.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.70000000000000015e259 < d < 2.25000000000000002e176

    1. Initial program 65.3%

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

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

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

Alternative 12: 9.7% accurate, 5.0× speedup?

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

\\
\frac{a}{c}
\end{array}
Derivation
  1. Initial program 63.5%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  9. Final simplification11.2%

    \[\leadsto \frac{a}{c} \]
  10. Add Preprocessing

Alternative 13: 42.2% accurate, 5.0× speedup?

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

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

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

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

    \[\leadsto \frac{b}{c} \]
  5. 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 2024019 
(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))))