Complex division, imag part

Percentage Accurate: 61.8% → 85.5%
Time: 12.6s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 61.8% accurate, 1.0× speedup?

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

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

Alternative 1: 85.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot c - a \cdot d\\ \mathbf{if}\;\frac{t\_0}{c \cdot c + d \cdot d} \leq \infty:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* b c) (* a d))))
   (if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
     (* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
     (- (/ b c) (/ (* d (/ a c)) c)))))
double code(double a, double b, double c, double d) {
	double t_0 = (b * c) - (a * d);
	double tmp;
	if ((t_0 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	} else {
		tmp = (b / c) - ((d * (a / c)) / c);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (b * c) - (a * d);
	double tmp;
	if ((t_0 / ((c * c) + (d * d))) <= Double.POSITIVE_INFINITY) {
		tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
	} else {
		tmp = (b / c) - ((d * (a / c)) / c);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b * c) - (a * d)
	tmp = 0
	if (t_0 / ((c * c) + (d * d))) <= math.inf:
		tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d))
	else:
		tmp = (b / c) - ((d * (a / c)) / c)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b * c) - Float64(a * d))
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= Inf)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d)));
	else
		tmp = Float64(Float64(b / c) - Float64(Float64(d * Float64(a / c)) / c));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b * c) - (a * d);
	tmp = 0.0;
	if ((t_0 / ((c * c) + (d * d))) <= Inf)
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	else
		tmp = (b / c) - ((d * (a / c)) / c);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], 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[(b / c), $MachinePrecision] - N[(N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{c}}{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))) < +inf.0

    1. Initial program 76.8%

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.5% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -4.6 \cdot 10^{-234}:\\
\;\;\;\;\frac{t\_0 + 2 \cdot \mathsf{fma}\left(a, -d, a \cdot d\right)}{c \cdot c + d \cdot d}\\

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

\mathbf{elif}\;c \leq 7.6 \cdot 10^{+114}:\\
\;\;\;\;t\_0 \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -2.4999999999999998e44 or 7.6000000000000001e114 < c

    1. Initial program 48.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-identity48.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.4999999999999998e44 < c < -4.59999999999999981e-234

    1. Initial program 87.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\color{blue}{\left(\left(-d\right) \cdot a + a \cdot d\right)} + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}{c \cdot c + d \cdot d} \]
      10. distribute-lft-neg-in87.9%

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\left(\color{blue}{\left(-d \cdot a\right)} + a \cdot d\right) + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}{c \cdot c + d \cdot d} \]
      11. *-commutative87.9%

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

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

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\color{blue}{\mathsf{fma}\left(a, -d, a \cdot d\right)} + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}{c \cdot c + d \cdot d} \]
      14. *-commutative87.9%

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

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\mathsf{fma}\left(a, -d, a \cdot d\right) + \color{blue}{\left(\left(-d\right) \cdot a + a \cdot d\right)}\right)}{c \cdot c + d \cdot d} \]
      16. distribute-lft-neg-in87.9%

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\mathsf{fma}\left(a, -d, a \cdot d\right) + \left(\color{blue}{\left(-d \cdot a\right)} + a \cdot d\right)\right)}{c \cdot c + d \cdot d} \]
      17. *-commutative87.9%

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

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

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

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

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

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

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

    if -4.59999999999999981e-234 < c < 5.79999999999999995e-140

    1. Initial program 71.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{d}{1} \cdot \frac{d}{c}} \cdot b} - \frac{a}{d} \]
      3. /-rgt-identity95.6%

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

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

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

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

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

    if 5.79999999999999995e-140 < c < 7.6000000000000001e114

    1. Initial program 77.9%

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

        \[\leadsto \color{blue}{\frac{1}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. associate-/r/77.8%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} - 1\right)} \cdot \left(b \cdot c - a \cdot d\right) \]
      3. pow-flip38.2%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{\left(-2\right)}}\right)} - 1\right) \cdot \left(b \cdot c - a \cdot d\right) \]
      4. metadata-eval38.2%

        \[\leadsto \left(e^{\mathsf{log1p}\left({\left(\mathsf{hypot}\left(c, d\right)\right)}^{\color{blue}{-2}}\right)} - 1\right) \cdot \left(b \cdot c - a \cdot d\right) \]
    6. Applied egg-rr38.2%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\right)} - 1\right)} \cdot \left(b \cdot c - a \cdot d\right) \]
    7. Step-by-step derivation
      1. expm1-def76.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\right)\right)} \cdot \left(b \cdot c - a \cdot d\right) \]
      2. expm1-log1p78.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.5 \cdot 10^{+44}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -4.6 \cdot 10^{-234}:\\ \;\;\;\;\frac{\left(b \cdot c - a \cdot d\right) + 2 \cdot \mathsf{fma}\left(a, -d, a \cdot d\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{-140}:\\ \;\;\;\;b \cdot \frac{\frac{c}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 7.6 \cdot 10^{+114}:\\ \;\;\;\;\left(b \cdot c - a \cdot d\right) \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot c - a \cdot d\\ t_1 := \frac{b}{c} - \frac{d \cdot \frac{a}{c}}{c}\\ t_2 := c \cdot c + d \cdot d\\ \mathbf{if}\;c \leq -2.1 \cdot 10^{+44}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -8.2 \cdot 10^{-234}:\\ \;\;\;\;\frac{t\_0 + 2 \cdot \mathsf{fma}\left(a, -d, a \cdot d\right)}{t\_2}\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{d} \cdot \frac{b}{\frac{d}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 3.3 \cdot 10^{+115}:\\ \;\;\;\;\frac{t\_0}{t\_2}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* b c) (* a d)))
        (t_1 (- (/ b c) (/ (* d (/ a c)) c)))
        (t_2 (+ (* c c) (* d d))))
   (if (<= c -2.1e+44)
     t_1
     (if (<= c -8.2e-234)
       (/ (+ t_0 (* 2.0 (fma a (- d) (* a d)))) t_2)
       (if (<= c 2.4e-77)
         (- (* (/ 1.0 d) (/ b (/ d c))) (/ a d))
         (if (<= c 3.3e+115) (/ t_0 t_2) t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = (b * c) - (a * d);
	double t_1 = (b / c) - ((d * (a / c)) / c);
	double t_2 = (c * c) + (d * d);
	double tmp;
	if (c <= -2.1e+44) {
		tmp = t_1;
	} else if (c <= -8.2e-234) {
		tmp = (t_0 + (2.0 * fma(a, -d, (a * d)))) / t_2;
	} else if (c <= 2.4e-77) {
		tmp = ((1.0 / d) * (b / (d / c))) - (a / d);
	} else if (c <= 3.3e+115) {
		tmp = t_0 / t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(b * c) - Float64(a * d))
	t_1 = Float64(Float64(b / c) - Float64(Float64(d * Float64(a / c)) / c))
	t_2 = Float64(Float64(c * c) + Float64(d * d))
	tmp = 0.0
	if (c <= -2.1e+44)
		tmp = t_1;
	elseif (c <= -8.2e-234)
		tmp = Float64(Float64(t_0 + Float64(2.0 * fma(a, Float64(-d), Float64(a * d)))) / t_2);
	elseif (c <= 2.4e-77)
		tmp = Float64(Float64(Float64(1.0 / d) * Float64(b / Float64(d / c))) - Float64(a / d));
	elseif (c <= 3.3e+115)
		tmp = Float64(t_0 / t_2);
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.1e+44], t$95$1, If[LessEqual[c, -8.2e-234], N[(N[(t$95$0 + N[(2.0 * N[(a * (-d) + N[(a * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[c, 2.4e-77], N[(N[(N[(1.0 / d), $MachinePrecision] * N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.3e+115], N[(t$95$0 / t$95$2), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -8.2 \cdot 10^{-234}:\\
\;\;\;\;\frac{t\_0 + 2 \cdot \mathsf{fma}\left(a, -d, a \cdot d\right)}{t\_2}\\

\mathbf{elif}\;c \leq 2.4 \cdot 10^{-77}:\\
\;\;\;\;\frac{1}{d} \cdot \frac{b}{\frac{d}{c}} - \frac{a}{d}\\

\mathbf{elif}\;c \leq 3.3 \cdot 10^{+115}:\\
\;\;\;\;\frac{t\_0}{t\_2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -2.09999999999999987e44 or 3.30000000000000005e115 < c

    1. Initial program 48.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-identity48.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.09999999999999987e44 < c < -8.20000000000000021e-234

    1. Initial program 87.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\color{blue}{\left(\left(-d\right) \cdot a + a \cdot d\right)} + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}{c \cdot c + d \cdot d} \]
      10. distribute-lft-neg-in87.9%

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\left(\color{blue}{\left(-d \cdot a\right)} + a \cdot d\right) + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}{c \cdot c + d \cdot d} \]
      11. *-commutative87.9%

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

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

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\color{blue}{\mathsf{fma}\left(a, -d, a \cdot d\right)} + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}{c \cdot c + d \cdot d} \]
      14. *-commutative87.9%

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

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\mathsf{fma}\left(a, -d, a \cdot d\right) + \color{blue}{\left(\left(-d\right) \cdot a + a \cdot d\right)}\right)}{c \cdot c + d \cdot d} \]
      16. distribute-lft-neg-in87.9%

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\mathsf{fma}\left(a, -d, a \cdot d\right) + \left(\color{blue}{\left(-d \cdot a\right)} + a \cdot d\right)\right)}{c \cdot c + d \cdot d} \]
      17. *-commutative87.9%

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

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

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

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

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

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

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

    if -8.20000000000000021e-234 < c < 2.3999999999999999e-77

    1. Initial program 72.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b}{\color{blue}{\frac{d}{1} \cdot \frac{d}{c}}} - \frac{a}{d} \]
    8. Step-by-step derivation
      1. /-rgt-identity90.9%

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

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

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

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

    if 2.3999999999999999e-77 < c < 3.30000000000000005e115

    1. Initial program 77.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
  3. Recombined 4 regimes into one program.
  4. Final simplification86.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.1 \cdot 10^{+44}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -8.2 \cdot 10^{-234}:\\ \;\;\;\;\frac{\left(b \cdot c - a \cdot d\right) + 2 \cdot \mathsf{fma}\left(a, -d, a \cdot d\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{d} \cdot \frac{b}{\frac{d}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 3.3 \cdot 10^{+115}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.4% 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} - \frac{d \cdot \frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -2.1 \cdot 10^{+44}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \leq -8.2 \cdot 10^{-234}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 2.5 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{d} \cdot \frac{b}{\frac{d}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 8.7 \cdot 10^{+114}:\\ \;\;\;\;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 -2.1e+44)
     t_1
     (if (<= c -8.2e-234)
       t_0
       (if (<= c 2.5e-77)
         (- (* (/ 1.0 d) (/ b (/ d c))) (/ a d))
         (if (<= c 8.7e+114) 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 <= -2.1e+44) {
		tmp = t_1;
	} else if (c <= -8.2e-234) {
		tmp = t_0;
	} else if (c <= 2.5e-77) {
		tmp = ((1.0 / d) * (b / (d / c))) - (a / d);
	} else if (c <= 8.7e+114) {
		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 <= (-2.1d+44)) then
        tmp = t_1
    else if (c <= (-8.2d-234)) then
        tmp = t_0
    else if (c <= 2.5d-77) then
        tmp = ((1.0d0 / d) * (b / (d / c))) - (a / d)
    else if (c <= 8.7d+114) 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 <= -2.1e+44) {
		tmp = t_1;
	} else if (c <= -8.2e-234) {
		tmp = t_0;
	} else if (c <= 2.5e-77) {
		tmp = ((1.0 / d) * (b / (d / c))) - (a / d);
	} else if (c <= 8.7e+114) {
		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 <= -2.1e+44:
		tmp = t_1
	elif c <= -8.2e-234:
		tmp = t_0
	elif c <= 2.5e-77:
		tmp = ((1.0 / d) * (b / (d / c))) - (a / d)
	elif c <= 8.7e+114:
		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(Float64(d * Float64(a / c)) / c))
	tmp = 0.0
	if (c <= -2.1e+44)
		tmp = t_1;
	elseif (c <= -8.2e-234)
		tmp = t_0;
	elseif (c <= 2.5e-77)
		tmp = Float64(Float64(Float64(1.0 / d) * Float64(b / Float64(d / c))) - Float64(a / d));
	elseif (c <= 8.7e+114)
		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 <= -2.1e+44)
		tmp = t_1;
	elseif (c <= -8.2e-234)
		tmp = t_0;
	elseif (c <= 2.5e-77)
		tmp = ((1.0 / d) * (b / (d / c))) - (a / d);
	elseif (c <= 8.7e+114)
		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[(N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.1e+44], t$95$1, If[LessEqual[c, -8.2e-234], t$95$0, If[LessEqual[c, 2.5e-77], N[(N[(N[(1.0 / d), $MachinePrecision] * N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8.7e+114], 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} - \frac{d \cdot \frac{a}{c}}{c}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+44}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;c \leq -8.2 \cdot 10^{-234}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;c \leq 2.5 \cdot 10^{-77}:\\
\;\;\;\;\frac{1}{d} \cdot \frac{b}{\frac{d}{c}} - \frac{a}{d}\\

\mathbf{elif}\;c \leq 8.7 \cdot 10^{+114}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.09999999999999987e44 or 8.7000000000000001e114 < c

    1. Initial program 48.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-identity48.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.09999999999999987e44 < c < -8.20000000000000021e-234 or 2.49999999999999982e-77 < c < 8.7000000000000001e114

    1. Initial program 83.7%

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

    if -8.20000000000000021e-234 < c < 2.49999999999999982e-77

    1. Initial program 72.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b}{\color{blue}{\frac{d}{1} \cdot \frac{d}{c}}} - \frac{a}{d} \]
    8. Step-by-step derivation
      1. /-rgt-identity90.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.1 \cdot 10^{+44}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{c}}{c}\\ \mathbf{elif}\;c \leq -8.2 \cdot 10^{-234}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.5 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{d} \cdot \frac{b}{\frac{d}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 8.7 \cdot 10^{+114}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 76.8% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.49999999999999972e48 < c < 7.2e-72

    1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 71.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.05 \cdot 10^{+51} \lor \neg \left(c \leq 1.1 \cdot 10^{+62}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.0500000000000001e51 or 1.10000000000000007e62 < c

    1. Initial program 52.0%

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

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

    if -1.0500000000000001e51 < c < 1.10000000000000007e62

    1. Initial program 77.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b}{\color{blue}{\frac{d}{1} \cdot \frac{d}{c}}} - \frac{a}{d} \]
    8. Step-by-step derivation
      1. /-rgt-identity76.0%

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

        \[\leadsto \frac{\color{blue}{1 \cdot b}}{d \cdot \frac{d}{c}} - \frac{a}{d} \]
      3. *-commutative76.0%

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

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

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

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

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

Alternative 7: 71.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.5 \cdot 10^{+51} \lor \neg \left(c \leq 2.3 \cdot 10^{+63}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.5e51 or 2.29999999999999993e63 < c

    1. Initial program 52.0%

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

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

    if -4.5e51 < c < 2.29999999999999993e63

    1. Initial program 77.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{d}{1} \cdot \frac{d}{c}} \cdot b} - \frac{a}{d} \]
      3. /-rgt-identity76.0%

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

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

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

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

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

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

Alternative 8: 73.9% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -8.00000000000000035e48 or 5.4e-72 < c

    1. Initial program 57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.00000000000000035e48 < c < 5.4e-72

    1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 76.0% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.49999999999999972e48 < c < 1.2e-72

    1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 64.1% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -0.0132 \lor \neg \left(c \leq 2 \cdot 10^{+46}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -0.0132 or 2e46 < c

    1. Initial program 54.2%

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

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

    if -0.0132 < c < 2e46

    1. Initial program 78.0%

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

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

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

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

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

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

Alternative 11: 15.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.8 \cdot 10^{+129} \lor \neg \left(d \leq 7.8 \cdot 10^{+105}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.80000000000000005e129 or 7.79999999999999957e105 < d

    1. Initial program 43.6%

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

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

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

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

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

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

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

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

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

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

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

    if -3.80000000000000005e129 < d < 7.79999999999999957e105

    1. Initial program 77.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-identity77.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 47.4% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.69999999999999977e166 or 5.1999999999999998e144 < d

    1. Initial program 40.5%

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

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

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

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

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

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

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

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

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

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

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

    if -5.69999999999999977e166 < d < 5.1999999999999998e144

    1. Initial program 75.1%

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

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

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

Alternative 13: 9.3% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  9. Final simplification10.1%

    \[\leadsto \frac{a}{c} \]
  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 2024040 
(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))))