Complex division, imag part

Percentage Accurate: 60.8% → 91.3%
Time: 8.6s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 60.8% accurate, 1.0× speedup?

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

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

Alternative 1: 91.3% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq -6 \cdot 10^{-133}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 2.3 \cdot 10^{+149}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 39.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt39.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-frac39.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-def39.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-def63.5%

        \[\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)}} \]
    3. Applied egg-rr63.5%

      \[\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)}} \]
    4. Step-by-step derivation
      1. associate-*l/63.5%

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

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

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

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

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

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

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

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

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

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

    if -1.35000000000000003e154 < d < -6.00000000000000038e-133 or 3.70000000000000004e-178 < d < 2.2999999999999998e149

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

        \[\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) \]
      10. pow295.2%

        \[\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) \]
      11. hypot-def95.2%

        \[\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) \]
    3. Applied egg-rr95.2%

      \[\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)} \]

    if -6.00000000000000038e-133 < d < 3.70000000000000004e-178

    1. Initial program 64.9%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{a}{\frac{c}{\frac{d}{c}}}} \]
    5. Step-by-step derivation
      1. clear-num92.3%

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

        \[\leadsto \frac{b}{c} - \color{blue}{{\left(\frac{\frac{c}{\frac{d}{c}}}{a}\right)}^{-1}} \]
      3. associate-/r/92.3%

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

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

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

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{1}{\frac{\frac{c}{d}}{\frac{a}{c}}}} \]
    9. Step-by-step derivation
      1. inv-pow93.3%

        \[\leadsto \frac{b}{c} - \color{blue}{{\left(\frac{\frac{c}{d}}{\frac{a}{c}}\right)}^{-1}} \]
      2. associate-/r/94.8%

        \[\leadsto \frac{b}{c} - {\color{blue}{\left(\frac{\frac{c}{d}}{a} \cdot c\right)}}^{-1} \]
      3. unpow-prod-down94.8%

        \[\leadsto \frac{b}{c} - \color{blue}{{\left(\frac{\frac{c}{d}}{a}\right)}^{-1} \cdot {c}^{-1}} \]
      4. inv-pow94.8%

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{{\left(\frac{\frac{c}{d}}{a}\right)}^{-1} \cdot 1}{c}} \]
      2. *-rgt-identity94.8%

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{{\left(\frac{\frac{c}{d}}{a}\right)}^{-1}}}{c} \]
      3. unpow-194.8%

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{\frac{1}{\frac{\frac{c}{d}}{a}}}}{c} \]
      4. associate-/l/95.4%

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

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

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

    if 2.2999999999999998e149 < d

    1. Initial program 28.5%

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

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

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

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

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

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

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

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

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

        \[\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) \]
      10. pow238.6%

        \[\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) \]
      11. hypot-def38.6%

        \[\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) \]
    3. Applied egg-rr38.6%

      \[\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)} \]
    4. Taylor expanded in c around 0 82.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{a - b \cdot \frac{c}{d}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -6 \cdot 10^{-133}:\\ \;\;\;\;\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)\\ \mathbf{elif}\;d \leq 3.7 \cdot 10^{-178}:\\ \;\;\;\;\frac{b}{c} + \frac{\frac{-1}{\frac{c}{d \cdot a}}}{c}\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{+149}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 2: 85.7% accurate, 0.1× speedup?

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

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

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


\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))) < 1.99999999999999997e307

    1. Initial program 77.7%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt77.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-frac77.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-def77.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-def95.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)}} \]
    3. Applied egg-rr95.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)}} \]
    4. Step-by-step derivation
      1. associate-*l/96.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-identity96.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. *-commutative96.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. *-commutative96.1%

        \[\leadsto \frac{\frac{c \cdot b - \color{blue}{d \cdot a}}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \]
    5. Applied egg-rr96.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 1.99999999999999997e307 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 6.1%

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

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

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

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

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

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

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

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

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

        \[\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) \]
      10. pow248.0%

        \[\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) \]
      11. hypot-def48.0%

        \[\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) \]
    3. Applied egg-rr48.0%

      \[\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)} \]
    4. Taylor expanded in c around inf 41.5%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 82.6% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -9.5 \cdot 10^{-64}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.75 \cdot 10^{+46}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 34.5%

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

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

        \[\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-def34.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-def63.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)}} \]
    3. Applied egg-rr63.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)}} \]
    4. Step-by-step derivation
      1. associate-*l/63.6%

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

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

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

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

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

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

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

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

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

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

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

    if -4.2000000000000004e63 < c < -9.50000000000000043e-64 or 8.1999999999999999e-113 < c < 1.74999999999999992e46

    1. Initial program 84.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]

    if -9.50000000000000043e-64 < c < 8.1999999999999999e-113

    1. Initial program 71.7%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt71.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-frac71.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-def71.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-def83.5%

        \[\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)}} \]
    3. Applied egg-rr83.5%

      \[\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)}} \]
    4. Taylor expanded in d around -inf 55.2%

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

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

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

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

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

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

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

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

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

    if 1.74999999999999992e46 < c

    1. Initial program 43.7%

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

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

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

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

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

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

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

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

        \[\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) \]
      10. pow274.8%

        \[\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) \]
      11. hypot-def74.8%

        \[\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) \]
    3. Applied egg-rr74.8%

      \[\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)} \]
    4. Taylor expanded in c around inf 74.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.2 \cdot 10^{+63}:\\ \;\;\;\;\frac{\frac{a}{\frac{c}{d}} - b}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -9.5 \cdot 10^{-64}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{-113}:\\ \;\;\;\;\left(a - b \cdot \frac{c}{d}\right) \cdot \frac{-1}{d}\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{+46}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 4: 82.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -9.6 \cdot 10^{+62}:\\ \;\;\;\;\frac{b}{c} + \frac{-1}{\frac{\frac{c}{d}}{\frac{a}{c}}}\\ \mathbf{elif}\;c \leq -7 \cdot 10^{-64}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.65 \cdot 10^{-106}:\\ \;\;\;\;\left(a - b \cdot \frac{c}{d}\right) \cdot \frac{-1}{d}\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{+46}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* b c) (* d a)) (+ (* c c) (* d d)))))
   (if (<= c -9.6e+62)
     (+ (/ b c) (/ -1.0 (/ (/ c d) (/ a c))))
     (if (<= c -7e-64)
       t_0
       (if (<= c 1.65e-106)
         (* (- a (* b (/ c d))) (/ -1.0 d))
         (if (<= c 1.75e+46) t_0 (- (/ b c) (* (/ a c) (/ d c)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -9.6e+62) {
		tmp = (b / c) + (-1.0 / ((c / d) / (a / c)));
	} else if (c <= -7e-64) {
		tmp = t_0;
	} else if (c <= 1.65e-106) {
		tmp = (a - (b * (c / d))) * (-1.0 / d);
	} else if (c <= 1.75e+46) {
		tmp = t_0;
	} else {
		tmp = (b / c) - ((a / c) * (d / 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 = ((b * c) - (d * a)) / ((c * c) + (d * d))
    if (c <= (-9.6d+62)) then
        tmp = (b / c) + ((-1.0d0) / ((c / d) / (a / c)))
    else if (c <= (-7d-64)) then
        tmp = t_0
    else if (c <= 1.65d-106) then
        tmp = (a - (b * (c / d))) * ((-1.0d0) / d)
    else if (c <= 1.75d+46) then
        tmp = t_0
    else
        tmp = (b / c) - ((a / c) * (d / c))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -9.6e+62) {
		tmp = (b / c) + (-1.0 / ((c / d) / (a / c)));
	} else if (c <= -7e-64) {
		tmp = t_0;
	} else if (c <= 1.65e-106) {
		tmp = (a - (b * (c / d))) * (-1.0 / d);
	} else if (c <= 1.75e+46) {
		tmp = t_0;
	} else {
		tmp = (b / c) - ((a / c) * (d / c));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -9.6e+62:
		tmp = (b / c) + (-1.0 / ((c / d) / (a / c)))
	elif c <= -7e-64:
		tmp = t_0
	elif c <= 1.65e-106:
		tmp = (a - (b * (c / d))) * (-1.0 / d)
	elif c <= 1.75e+46:
		tmp = t_0
	else:
		tmp = (b / c) - ((a / c) * (d / c))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (c <= -9.6e+62)
		tmp = Float64(Float64(b / c) + Float64(-1.0 / Float64(Float64(c / d) / Float64(a / c))));
	elseif (c <= -7e-64)
		tmp = t_0;
	elseif (c <= 1.65e-106)
		tmp = Float64(Float64(a - Float64(b * Float64(c / d))) * Float64(-1.0 / d));
	elseif (c <= 1.75e+46)
		tmp = t_0;
	else
		tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (c <= -9.6e+62)
		tmp = (b / c) + (-1.0 / ((c / d) / (a / c)));
	elseif (c <= -7e-64)
		tmp = t_0;
	elseif (c <= 1.65e-106)
		tmp = (a - (b * (c / d))) * (-1.0 / d);
	elseif (c <= 1.75e+46)
		tmp = t_0;
	else
		tmp = (b / c) - ((a / c) * (d / c));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9.6e+62], N[(N[(b / c), $MachinePrecision] + N[(-1.0 / N[(N[(c / d), $MachinePrecision] / N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -7e-64], t$95$0, If[LessEqual[c, 1.65e-106], N[(N[(a - N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.75e+46], t$95$0, N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -7 \cdot 10^{-64}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.75 \cdot 10^{+46}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 34.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{{\left(\frac{\frac{c}{\frac{d}{c}}}{a}\right)}^{-1}} \]
      3. associate-/r/81.0%

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

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

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

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

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

    if -9.6e62 < c < -7.0000000000000006e-64 or 1.65000000000000008e-106 < c < 1.74999999999999992e46

    1. Initial program 84.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]

    if -7.0000000000000006e-64 < c < 1.65000000000000008e-106

    1. Initial program 71.7%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt71.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-frac71.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-def71.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-def83.5%

        \[\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)}} \]
    3. Applied egg-rr83.5%

      \[\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)}} \]
    4. Taylor expanded in d around -inf 55.2%

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

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

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

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

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

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

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

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

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

    if 1.74999999999999992e46 < c

    1. Initial program 43.7%

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

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

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

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

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

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

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

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

        \[\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) \]
      10. pow274.8%

        \[\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) \]
      11. hypot-def74.8%

        \[\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) \]
    3. Applied egg-rr74.8%

      \[\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)} \]
    4. Taylor expanded in c around inf 74.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9.6 \cdot 10^{+62}:\\ \;\;\;\;\frac{b}{c} + \frac{-1}{\frac{\frac{c}{d}}{\frac{a}{c}}}\\ \mathbf{elif}\;c \leq -7 \cdot 10^{-64}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.65 \cdot 10^{-106}:\\ \;\;\;\;\left(a - b \cdot \frac{c}{d}\right) \cdot \frac{-1}{d}\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{+46}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternative 5: 73.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.65 \cdot 10^{-18} \lor \neg \left(c \leq 1.2 \cdot 10^{+69}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.6500000000000001e-18 or 1.2000000000000001e69 < c

    1. Initial program 49.1%

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

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

    if -1.6500000000000001e-18 < c < 1.2000000000000001e69

    1. Initial program 74.0%

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

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

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

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

        \[\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.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)}} \]
    3. Applied egg-rr84.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)}} \]
    4. Taylor expanded in d around -inf 49.1%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.65 \cdot 10^{-18} \lor \neg \left(c \leq 1.2 \cdot 10^{+69}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\left(a - b \cdot \frac{c}{d}\right) \cdot \frac{-1}{d}\\ \end{array} \]

Alternative 6: 78.8% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -3.99999999999999978e-20 or 1.32e17 < c

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
      11. hypot-def80.7%

        \[\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) \]
    3. Applied egg-rr80.7%

      \[\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)} \]
    4. Taylor expanded in c around inf 74.3%

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

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

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

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

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

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

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

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

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

    if -3.99999999999999978e-20 < c < 1.32e17

    1. Initial program 74.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt74.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-frac74.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-def74.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-def85.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)}} \]
    3. Applied egg-rr85.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)}} \]
    4. Taylor expanded in d around -inf 50.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4 \cdot 10^{-20} \lor \neg \left(c \leq 1.32 \cdot 10^{+17}\right):\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{else}:\\ \;\;\;\;\left(a - b \cdot \frac{c}{d}\right) \cdot \frac{-1}{d}\\ \end{array} \]

Alternative 7: 64.2% accurate, 1.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.1e15 or 7.9999999999999998e-19 < d

    1. Initial program 59.8%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified67.2%

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

    if -2.1e15 < d < 7.9999999999999998e-19

    1. Initial program 67.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.1 \cdot 10^{+15} \lor \neg \left(d \leq 8 \cdot 10^{-19}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 8: 46.0% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.5 \cdot 10^{+158}:\\
\;\;\;\;\frac{a}{d}\\

\mathbf{elif}\;d \leq 9 \cdot 10^{+89}:\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -9.49999999999999913e158 or 9e89 < d

    1. Initial program 43.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt43.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-frac43.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-def43.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-def67.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)}} \]
    3. Applied egg-rr67.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)}} \]
    4. Taylor expanded in d around -inf 52.3%

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

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

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

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

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

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

    if -9.49999999999999913e158 < d < 9e89

    1. Initial program 71.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.5 \cdot 10^{+158}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{elif}\;d \leq 9 \cdot 10^{+89}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{d}\\ \end{array} \]

Alternative 9: 11.1% accurate, 5.0× speedup?

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

\\
\frac{a}{d}
\end{array}
Derivation
  1. Initial program 63.1%

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

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

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

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

      \[\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)}} \]
  3. Applied egg-rr78.5%

    \[\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)}} \]
  4. Taylor expanded in d around -inf 32.5%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  8. Final simplification12.2%

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

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 2023271 
(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))))