Complex division, imag part

Percentage Accurate: 60.5% → 86.3%
Time: 10.0s
Alternatives: 11
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 11 alternatives:

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

Initial Program: 60.5% 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: 86.3% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.75 \cdot 10^{-9} \lor \neg \left(b \leq 5.5 \cdot 10^{-32}\right):\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{\frac{b \cdot c}{d} - a}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.75e-9 or 5.50000000000000024e-32 < b

    1. Initial program 55.9%

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

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

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

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

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fmm-def54.3%

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

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

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

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

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

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

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

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

    if -1.75e-9 < b < 5.50000000000000024e-32

    1. Initial program 64.3%

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

      \[\leadsto \frac{\color{blue}{d \cdot \left(\frac{b \cdot c}{d} - a\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. sub-neg64.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.75 \cdot 10^{-9} \lor \neg \left(b \leq 5.5 \cdot 10^{-32}\right):\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 84.6% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 80.3%

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

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

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

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

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

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

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

    if 2.0000000000000001e221 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 15.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 86.1% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.2 \cdot 10^{+110} \lor \neg \left(c \leq 1.9 \cdot 10^{+204}\right):\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.19999999999999992e110 or 1.8999999999999999e204 < c

    1. Initial program 29.3%

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. *-commutative84.8%

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

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

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

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

    if -2.19999999999999992e110 < c < 1.8999999999999999e204

    1. Initial program 70.3%

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

      \[\leadsto \frac{\color{blue}{d \cdot \left(\frac{b \cdot c}{d} - a\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. sub-neg66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 82.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -3.1 \cdot 10^{+122}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -3.3 \cdot 10^{-59}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-68}:\\ \;\;\;\;\frac{\left(b \cdot c\right) \cdot \frac{1}{d} - a}{d}\\ \mathbf{elif}\;c \leq 4.7 \cdot 10^{+101}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* b c) (* d a)) (+ (* c c) (* d d))))
        (t_1 (/ (- b (* d (/ a c))) c)))
   (if (<= c -3.1e+122)
     t_1
     (if (<= c -3.3e-59)
       t_0
       (if (<= c 3.2e-68)
         (/ (- (* (* b c) (/ 1.0 d)) a) d)
         (if (<= c 4.7e+101) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
	double t_1 = (b - (d * (a / c))) / c;
	double tmp;
	if (c <= -3.1e+122) {
		tmp = t_1;
	} else if (c <= -3.3e-59) {
		tmp = t_0;
	} else if (c <= 3.2e-68) {
		tmp = (((b * c) * (1.0 / d)) - a) / d;
	} else if (c <= 4.7e+101) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d))
    t_1 = (b - (d * (a / c))) / c
    if (c <= (-3.1d+122)) then
        tmp = t_1
    else if (c <= (-3.3d-59)) then
        tmp = t_0
    else if (c <= 3.2d-68) then
        tmp = (((b * c) * (1.0d0 / d)) - a) / d
    else if (c <= 4.7d+101) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
	double t_1 = (b - (d * (a / c))) / c;
	double tmp;
	if (c <= -3.1e+122) {
		tmp = t_1;
	} else if (c <= -3.3e-59) {
		tmp = t_0;
	} else if (c <= 3.2e-68) {
		tmp = (((b * c) * (1.0 / d)) - a) / d;
	} else if (c <= 4.7e+101) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d))
	t_1 = (b - (d * (a / c))) / c
	tmp = 0
	if c <= -3.1e+122:
		tmp = t_1
	elif c <= -3.3e-59:
		tmp = t_0
	elif c <= 3.2e-68:
		tmp = (((b * c) * (1.0 / d)) - a) / d
	elif c <= 4.7e+101:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(Float64(b - Float64(d * Float64(a / c))) / c)
	tmp = 0.0
	if (c <= -3.1e+122)
		tmp = t_1;
	elseif (c <= -3.3e-59)
		tmp = t_0;
	elseif (c <= 3.2e-68)
		tmp = Float64(Float64(Float64(Float64(b * c) * Float64(1.0 / d)) - a) / d);
	elseif (c <= 4.7e+101)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
	t_1 = (b - (d * (a / c))) / c;
	tmp = 0.0;
	if (c <= -3.1e+122)
		tmp = t_1;
	elseif (c <= -3.3e-59)
		tmp = t_0;
	elseif (c <= 3.2e-68)
		tmp = (((b * c) * (1.0 / d)) - a) / d;
	elseif (c <= 4.7e+101)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -3.1e+122], t$95$1, If[LessEqual[c, -3.3e-59], t$95$0, If[LessEqual[c, 3.2e-68], N[(N[(N[(N[(b * c), $MachinePrecision] * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.7e+101], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -3.3 \cdot 10^{-59}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 4.7 \cdot 10^{+101}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.09999999999999999e122 or 4.69999999999999971e101 < c

    1. Initial program 34.1%

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

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

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

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

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

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

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

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

    if -3.09999999999999999e122 < c < -3.29999999999999982e-59 or 3.1999999999999999e-68 < c < 4.69999999999999971e101

    1. Initial program 79.7%

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

    if -3.29999999999999982e-59 < c < 3.1999999999999999e-68

    1. Initial program 68.9%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define65.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) \]
      8. associate-/l*69.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) \]
      9. add-sqr-sqrt69.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{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow269.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{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define69.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(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr69.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. Taylor expanded in d around inf 91.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
      2. clear-num91.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.1 \cdot 10^{+122}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -3.3 \cdot 10^{-59}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-68}:\\ \;\;\;\;\frac{\left(b \cdot c\right) \cdot \frac{1}{d} - a}{d}\\ \mathbf{elif}\;c \leq 4.7 \cdot 10^{+101}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 77.7% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.2000000000000002e-37 or 86 < c

    1. Initial program 52.5%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. *-commutative73.8%

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

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

        \[\leadsto \frac{b - \color{blue}{d \cdot \frac{a}{c}}}{c} \]
    7. Applied egg-rr75.4%

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

    if -4.2000000000000002e-37 < c < 86

    1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 77.8% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.15000000000000006e-32 or 61 < c

    1. Initial program 52.5%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. *-commutative73.8%

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

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

        \[\leadsto \frac{b - \color{blue}{d \cdot \frac{a}{c}}}{c} \]
    7. Applied egg-rr75.4%

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

    if -4.15000000000000006e-32 < c < 61

    1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 77.8% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.1999999999999995e-32 or 61 < c

    1. Initial program 52.5%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. *-commutative73.8%

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

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

        \[\leadsto \frac{b - \color{blue}{d \cdot \frac{a}{c}}}{c} \]
    7. Applied egg-rr75.4%

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

    if -5.1999999999999995e-32 < c < 61

    1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 73.6% accurate, 0.8× speedup?

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

    1. Initial program 42.2%

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

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

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

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

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

    if -6.4999999999999998e43 < d < 7.50000000000000033e91

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 63.6% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -6e-49 or 92 < c

    1. Initial program 53.2%

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

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

    if -6e-49 < c < 92

    1. Initial program 68.2%

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

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

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

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

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

Alternative 10: 46.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.9 \cdot 10^{+205} \lor \neg \left(d \leq 1.66 \cdot 10^{+168}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.8999999999999998e205 or 1.6600000000000001e168 < d

    1. Initial program 26.8%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified85.6%

      \[\leadsto \color{blue}{\frac{-a}{d}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt43.6%

        \[\leadsto \frac{\color{blue}{\sqrt{-a} \cdot \sqrt{-a}}}{d} \]
      2. sqrt-unprod41.7%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}}{d} \]
      3. sqr-neg41.7%

        \[\leadsto \frac{\sqrt{\color{blue}{a \cdot a}}}{d} \]
      4. sqrt-unprod14.7%

        \[\leadsto \frac{\color{blue}{\sqrt{a} \cdot \sqrt{a}}}{d} \]
      5. add-sqr-sqrt28.2%

        \[\leadsto \frac{\color{blue}{a}}{d} \]
      6. *-un-lft-identity28.2%

        \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
    7. Applied egg-rr28.2%

      \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
    8. Step-by-step derivation
      1. *-lft-identity28.2%

        \[\leadsto \frac{\color{blue}{a}}{d} \]
    9. Simplified28.2%

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

    if -3.8999999999999998e205 < d < 1.6600000000000001e168

    1. Initial program 68.7%

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

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

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

Alternative 11: 11.4% accurate, 5.0× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-a}{d}} \]
  6. Step-by-step derivation
    1. add-sqr-sqrt20.5%

      \[\leadsto \frac{\color{blue}{\sqrt{-a} \cdot \sqrt{-a}}}{d} \]
    2. sqrt-unprod21.5%

      \[\leadsto \frac{\color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}}{d} \]
    3. sqr-neg21.5%

      \[\leadsto \frac{\sqrt{\color{blue}{a \cdot a}}}{d} \]
    4. sqrt-unprod5.7%

      \[\leadsto \frac{\color{blue}{\sqrt{a} \cdot \sqrt{a}}}{d} \]
    5. add-sqr-sqrt9.6%

      \[\leadsto \frac{\color{blue}{a}}{d} \]
    6. *-un-lft-identity9.6%

      \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
  7. Applied egg-rr9.6%

    \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
  8. Step-by-step derivation
    1. *-lft-identity9.6%

      \[\leadsto \frac{\color{blue}{a}}{d} \]
  9. Simplified9.6%

    \[\leadsto \frac{\color{blue}{a}}{d} \]
  10. Add Preprocessing

Developer Target 1: 99.5% 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 2024160 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (! :herbie-platform default (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))))