Complex division, imag part

Percentage Accurate: 62.0% → 85.5%
Time: 12.3s
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: 62.0% 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: 85.5% accurate, 0.0× speedup?

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

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

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


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

    1. Initial program 80.7%

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

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

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

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

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

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

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

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

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

    if 1.99999999999999991e271 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 14.8%

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

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

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

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

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

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

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

Alternative 2: 83.5% accurate, 0.0× speedup?

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

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

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

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

\mathbf{elif}\;d \leq 1.2 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -7.60000000000000046e-22 or 1.2000000000000001e48 < d

    1. Initial program 48.8%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define66.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*72.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-sqrt72.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. pow272.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-define72.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-rr72.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 89.7%

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

    if -7.60000000000000046e-22 < d < -8.0000000000000004e-193

    1. Initial program 88.6%

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

    if -8.0000000000000004e-193 < d < 6.99999999999999995e-125

    1. Initial program 71.5%

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

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

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

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

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

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

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

    if 6.99999999999999995e-125 < d < 1.2000000000000001e48

    1. Initial program 85.6%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, c, -a \cdot d\right)} \cdot \frac{1}{c \cdot c + d \cdot d} \]
      3. distribute-rgt-neg-in85.7%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.6 \cdot 10^{-22}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\ \mathbf{elif}\;d \leq -8 \cdot 10^{-193}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{-125}:\\ \;\;\;\;\frac{b}{c} + \frac{a \cdot d}{c} \cdot \frac{-1}{c}\\ \mathbf{elif}\;d \leq 1.2 \cdot 10^{+48}:\\ \;\;\;\;\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{a}{-d}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ t_1 := \frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -7.3 \cdot 10^{+53}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -1.08 \cdot 10^{-190}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 3.3 \cdot 10^{-105}:\\ \;\;\;\;b \cdot \left(\frac{1}{d} \cdot \frac{c}{d}\right) - \frac{a}{d}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+140}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
        (t_1 (- (/ b c) (* d (/ (/ a c) c)))))
   (if (<= c -7.3e+53)
     t_1
     (if (<= c -1.08e-190)
       t_0
       (if (<= c 3.3e-105)
         (- (* b (* (/ 1.0 d) (/ c d))) (/ a d))
         (if (<= c 5.8e+140) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
	double t_1 = (b / c) - (d * ((a / c) / c));
	double tmp;
	if (c <= -7.3e+53) {
		tmp = t_1;
	} else if (c <= -1.08e-190) {
		tmp = t_0;
	} else if (c <= 3.3e-105) {
		tmp = (b * ((1.0 / d) * (c / d))) - (a / d);
	} else if (c <= 5.8e+140) {
		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) - (a * d)) / ((c * c) + (d * d))
    t_1 = (b / c) - (d * ((a / c) / c))
    if (c <= (-7.3d+53)) then
        tmp = t_1
    else if (c <= (-1.08d-190)) then
        tmp = t_0
    else if (c <= 3.3d-105) then
        tmp = (b * ((1.0d0 / d) * (c / d))) - (a / d)
    else if (c <= 5.8d+140) 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) - (a * d)) / ((c * c) + (d * d));
	double t_1 = (b / c) - (d * ((a / c) / c));
	double tmp;
	if (c <= -7.3e+53) {
		tmp = t_1;
	} else if (c <= -1.08e-190) {
		tmp = t_0;
	} else if (c <= 3.3e-105) {
		tmp = (b * ((1.0 / d) * (c / d))) - (a / d);
	} else if (c <= 5.8e+140) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d))
	t_1 = (b / c) - (d * ((a / c) / c))
	tmp = 0
	if c <= -7.3e+53:
		tmp = t_1
	elif c <= -1.08e-190:
		tmp = t_0
	elif c <= 3.3e-105:
		tmp = (b * ((1.0 / d) * (c / d))) - (a / d)
	elif c <= 5.8e+140:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / c) / c)))
	tmp = 0.0
	if (c <= -7.3e+53)
		tmp = t_1;
	elseif (c <= -1.08e-190)
		tmp = t_0;
	elseif (c <= 3.3e-105)
		tmp = Float64(Float64(b * Float64(Float64(1.0 / d) * Float64(c / d))) - Float64(a / d));
	elseif (c <= 5.8e+140)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
	t_1 = (b / c) - (d * ((a / c) / c));
	tmp = 0.0;
	if (c <= -7.3e+53)
		tmp = t_1;
	elseif (c <= -1.08e-190)
		tmp = t_0;
	elseif (c <= 3.3e-105)
		tmp = (b * ((1.0 / d) * (c / d))) - (a / d);
	elseif (c <= 5.8e+140)
		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[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -7.3e+53], t$95$1, If[LessEqual[c, -1.08e-190], t$95$0, If[LessEqual[c, 3.3e-105], N[(N[(b * N[(N[(1.0 / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.8e+140], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.08 \cdot 10^{-190}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 5.8 \cdot 10^{+140}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -7.30000000000000016e53 or 5.7999999999999998e140 < c

    1. Initial program 39.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.30000000000000016e53 < c < -1.08e-190 or 3.2999999999999999e-105 < c < 5.7999999999999998e140

    1. Initial program 84.5%

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

    if -1.08e-190 < c < 3.2999999999999999e-105

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.3 \cdot 10^{+53}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -1.08 \cdot 10^{-190}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.3 \cdot 10^{-105}:\\ \;\;\;\;b \cdot \left(\frac{1}{d} \cdot \frac{c}{d}\right) - \frac{a}{d}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+140}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 63.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{-d}\\ \mathbf{if}\;c \leq -2.8 \cdot 10^{-82}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{-80}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+51}:\\ \;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2 \cdot 10^{+62}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ a (- d))))
   (if (<= c -2.8e-82)
     (/ b c)
     (if (<= c 2.6e-80)
       t_0
       (if (<= c 5.8e+51)
         (/ (* b c) (+ (* c c) (* d d)))
         (if (<= c 2e+62) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
	double t_0 = a / -d;
	double tmp;
	if (c <= -2.8e-82) {
		tmp = b / c;
	} else if (c <= 2.6e-80) {
		tmp = t_0;
	} else if (c <= 5.8e+51) {
		tmp = (b * c) / ((c * c) + (d * d));
	} else if (c <= 2e+62) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = a / -d
    if (c <= (-2.8d-82)) then
        tmp = b / c
    else if (c <= 2.6d-80) then
        tmp = t_0
    else if (c <= 5.8d+51) then
        tmp = (b * c) / ((c * c) + (d * d))
    else if (c <= 2d+62) then
        tmp = t_0
    else
        tmp = b / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = a / -d;
	double tmp;
	if (c <= -2.8e-82) {
		tmp = b / c;
	} else if (c <= 2.6e-80) {
		tmp = t_0;
	} else if (c <= 5.8e+51) {
		tmp = (b * c) / ((c * c) + (d * d));
	} else if (c <= 2e+62) {
		tmp = t_0;
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = a / -d
	tmp = 0
	if c <= -2.8e-82:
		tmp = b / c
	elif c <= 2.6e-80:
		tmp = t_0
	elif c <= 5.8e+51:
		tmp = (b * c) / ((c * c) + (d * d))
	elif c <= 2e+62:
		tmp = t_0
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	t_0 = Float64(a / Float64(-d))
	tmp = 0.0
	if (c <= -2.8e-82)
		tmp = Float64(b / c);
	elseif (c <= 2.6e-80)
		tmp = t_0;
	elseif (c <= 5.8e+51)
		tmp = Float64(Float64(b * c) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 2e+62)
		tmp = t_0;
	else
		tmp = Float64(b / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = a / -d;
	tmp = 0.0;
	if (c <= -2.8e-82)
		tmp = b / c;
	elseif (c <= 2.6e-80)
		tmp = t_0;
	elseif (c <= 5.8e+51)
		tmp = (b * c) / ((c * c) + (d * d));
	elseif (c <= 2e+62)
		tmp = t_0;
	else
		tmp = b / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[c, -2.8e-82], N[(b / c), $MachinePrecision], If[LessEqual[c, 2.6e-80], t$95$0, If[LessEqual[c, 5.8e+51], N[(N[(b * c), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2e+62], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq 2.6 \cdot 10^{-80}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 2 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.80000000000000024e-82 or 2.00000000000000007e62 < c

    1. Initial program 51.5%

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

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

    if -2.80000000000000024e-82 < c < 2.6000000000000001e-80 or 5.7999999999999997e51 < c < 2.00000000000000007e62

    1. Initial program 77.7%

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

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

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

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

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

    if 2.6000000000000001e-80 < c < 5.7999999999999997e51

    1. Initial program 95.3%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} \]
    5. Simplified57.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.8 \cdot 10^{-82}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{-80}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+51}:\\ \;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2 \cdot 10^{+62}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 76.0% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -0.00339999999999999981 or 2.50000000000000019e-44 < c

    1. Initial program 53.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.00339999999999999981 < c < 2.50000000000000019e-44

    1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 74.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -7.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{b}{c} + \frac{a \cdot d}{c} \cdot \frac{-1}{c}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -7.5e-74

    1. Initial program 58.3%

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

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

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

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

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

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

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

    if -7.5e-74 < c < 6.60000000000000011e-44

    1. Initial program 80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.60000000000000011e-44 < c

    1. Initial program 51.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 68.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.05 \cdot 10^{-105} \lor \neg \left(c \leq 9 \cdot 10^{-44}\right):\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -3.04999999999999992e-105 or 8.9999999999999997e-44 < c

    1. Initial program 57.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.04999999999999992e-105 < c < 8.9999999999999997e-44

    1. Initial program 79.1%

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

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

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

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

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

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

Alternative 8: 69.1% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -7.2 \cdot 10^{-103}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\

\mathbf{elif}\;c \leq 9.5 \cdot 10^{-61}:\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -7.1999999999999996e-103

    1. Initial program 61.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.1999999999999996e-103 < c < 9.49999999999999986e-61

    1. Initial program 78.1%

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

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

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

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

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

    if 9.49999999999999986e-61 < c

    1. Initial program 55.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.2 \cdot 10^{-103}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{-61}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 62.9% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.2 \cdot 10^{-82} \lor \neg \left(c \leq 2.9 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.20000000000000004e-82 or 2.89999999999999991e-9 < c

    1. Initial program 54.9%

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

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

    if -1.20000000000000004e-82 < c < 2.89999999999999991e-9

    1. Initial program 80.2%

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

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

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

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

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

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

Alternative 10: 45.5% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.3 \cdot 10^{+166} \lor \neg \left(d \leq 1.36 \cdot 10^{+167}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.3000000000000002e166 or 1.36e167 < d

    1. Initial program 36.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(a \cdot d\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. mul-1-neg37.2%

        \[\leadsto \frac{\color{blue}{-a \cdot d}}{c \cdot c + d \cdot d} \]
      2. distribute-rgt-neg-out37.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      10. add-sqr-sqrt37.3%

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

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

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

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

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

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

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

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

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

    if -3.3000000000000002e166 < d < 1.36e167

    1. Initial program 75.9%

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

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

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

Alternative 11: 10.9% 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 66.3%

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

    \[\leadsto \frac{\color{blue}{-1 \cdot \left(a \cdot d\right)}}{c \cdot c + d \cdot d} \]
  4. Step-by-step derivation
    1. mul-1-neg43.2%

      \[\leadsto \frac{\color{blue}{-a \cdot d}}{c \cdot c + d \cdot d} \]
    2. distribute-rgt-neg-out43.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\sqrt{d} \cdot \sqrt{d}}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
    10. add-sqr-sqrt16.9%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  9. Final simplification11.4%

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

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

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