Complex division, imag part

Percentage Accurate: 61.1% → 95.9%
Time: 10.7s
Alternatives: 12
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 91.5% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq -2.55 \cdot 10^{-128}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 1.4 \cdot 10^{+150}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.35000000000000003e154 or 1.40000000000000005e150 < d

    1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      10. hypot-define47.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) \]
      11. associate-/l*48.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.35000000000000003e154 < d < -2.5500000000000002e-128 or 4.50000000000000023e-162 < d < 1.40000000000000005e150

    1. Initial program 74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.5500000000000002e-128 < d < 4.50000000000000023e-162

    1. Initial program 73.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      10. remove-double-neg97.3%

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

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

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

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

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    7. Applied egg-rr97.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{d}, a \cdot \frac{\frac{d}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)\\ \mathbf{elif}\;d \leq -2.55 \cdot 10^{-128}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{-d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-162}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{+150}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{-d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{d}, a \cdot \frac{\frac{d}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 83.1% accurate, 0.0× speedup?

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

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

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

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

\mathbf{elif}\;d \leq 2.25 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 39.6%

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

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

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

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

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

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

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

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

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

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

    if -5.3999999999999999e81 < d < -3.10000000000000011e-32 or 5.8e-120 < d < 2.24999999999999991e49

    1. Initial program 83.8%

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

    if -3.10000000000000011e-32 < d < 5.8e-120

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.24999999999999991e49 < d

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      10. hypot-define60.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) \]
      11. associate-/l*67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.4 \cdot 10^{+81}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -3.1 \cdot 10^{-32}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 5.8 \cdot 10^{-120}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 2.25 \cdot 10^{+49}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{d}, a \cdot \frac{\frac{d}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 82.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ \mathbf{if}\;d \leq -5.2 \cdot 10^{+81}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -4 \cdot 10^{-32}:\\ \;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{+118}:\\ \;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))))
   (if (<= d -5.2e+81)
     (/ (- (* b (/ c d)) a) d)
     (if (<= d -4e-32)
       (/ t_0 (+ (* c c) (* d d)))
       (if (<= d 3.6e-121)
         (/ (- b (/ a (/ c d))) c)
         (if (<= d 5.2e+118)
           (/ t_0 (fma c c (* d d)))
           (/ (- (/ b (/ d c)) a) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if (d <= -5.2e+81) {
		tmp = ((b * (c / d)) - a) / d;
	} else if (d <= -4e-32) {
		tmp = t_0 / ((c * c) + (d * d));
	} else if (d <= 3.6e-121) {
		tmp = (b - (a / (c / d))) / c;
	} else if (d <= 5.2e+118) {
		tmp = t_0 / fma(c, c, (d * d));
	} else {
		tmp = ((b / (d / c)) - a) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	tmp = 0.0
	if (d <= -5.2e+81)
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d);
	elseif (d <= -4e-32)
		tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 3.6e-121)
		tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c);
	elseif (d <= 5.2e+118)
		tmp = Float64(t_0 / fma(c, c, Float64(d * d)));
	else
		tmp = Float64(Float64(Float64(b / Float64(d / c)) - 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[d, -5.2e+81], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -4e-32], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.6e-121], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 5.2e+118], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -4 \cdot 10^{-32}:\\
\;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\

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

\mathbf{elif}\;d \leq 5.2 \cdot 10^{+118}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

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


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

    1. Initial program 39.6%

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

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

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

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

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

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

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

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

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

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

    if -5.19999999999999984e81 < d < -4.00000000000000022e-32

    1. Initial program 86.2%

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

    if -4.00000000000000022e-32 < d < 3.59999999999999984e-121

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.59999999999999984e-121 < d < 5.20000000000000032e118

    1. Initial program 83.5%

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

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

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

    if 5.20000000000000032e118 < d

    1. Initial program 37.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b}{\frac{d}{c}}} - a}{d} \]
    7. Applied egg-rr86.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.2 \cdot 10^{+81}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -4 \cdot 10^{-32}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{+118}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 82.3% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;d \leq -2.8 \cdot 10^{-32}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 1.55 \cdot 10^{+117}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 39.6%

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

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

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

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

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

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

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

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

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

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

    if -2.59999999999999992e81 < d < -2.7999999999999999e-32 or 3.20000000000000017e-127 < d < 1.54999999999999988e117

    1. Initial program 84.3%

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

    if -2.7999999999999999e-32 < d < 3.20000000000000017e-127

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.54999999999999988e117 < d

    1. Initial program 37.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b}{\frac{d}{c}}} - a}{d} \]
    7. Applied egg-rr86.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.6 \cdot 10^{+81}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -2.8 \cdot 10^{-32}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{-127}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 1.55 \cdot 10^{+117}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 78.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -45000000000 \lor \neg \left(d \leq 8 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -4.5e10 or 7.99999999999999964e-6 < d

    1. Initial program 55.0%

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

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

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

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

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

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

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

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

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

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

    if -4.5e10 < d < 7.99999999999999964e-6

    1. Initial program 74.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 73.0% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.59999999999999993e112 or 6.40000000000000004e42 < d

    1. Initial program 47.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified66.4%

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

    if -1.59999999999999993e112 < d < 6.40000000000000004e42

    1. Initial program 75.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 73.0% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.5e112 or 5.79999999999999977e41 < d

    1. Initial program 47.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified66.4%

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

    if -2.5e112 < d < 5.79999999999999977e41

    1. Initial program 75.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 78.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -28000000000:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\

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

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


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

    1. Initial program 53.6%

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

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

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

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

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

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

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

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

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

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

    if -2.8e10 < d < 4.0999999999999999e-12

    1. Initial program 74.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0999999999999999e-12 < d

    1. Initial program 56.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{b}{\frac{d}{c}}} - a}{d} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 62.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.5 \cdot 10^{+94} \lor \neg \left(d \leq 1.15 \cdot 10^{-41}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -8.50000000000000054e94 or 1.15000000000000005e-41 < d

    1. Initial program 52.0%

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

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

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

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

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

    if -8.50000000000000054e94 < d < 1.15000000000000005e-41

    1. Initial program 74.5%

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

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

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

Alternative 11: 45.7% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.49999999999999987e212 or 1.6000000000000001e93 < d

    1. Initial program 46.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{b}{\frac{d}{c}}} - a}{d} \]
    8. Step-by-step derivation
      1. div-inv85.1%

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

        \[\leadsto \color{blue}{\log \left(e^{\frac{b}{\frac{d}{c}} - a}\right)} \cdot \frac{1}{d} \]
      3. add-log-exp85.1%

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

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

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

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

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

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

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

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

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

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

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

    if -3.49999999999999987e212 < d < 1.6000000000000001e93

    1. Initial program 71.0%

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

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

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

Alternative 12: 10.8% 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 64.8%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{b}{\frac{d}{c}}} - a}{d} \]
  8. Step-by-step derivation
    1. div-inv52.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  11. 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 2024097 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

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

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