Complex division, imag part

Percentage Accurate: 61.3% → 90.2%
Time: 10.8s
Alternatives: 11
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 61.3% 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: 90.2% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.9 \cdot 10^{-72} \lor \neg \left(d \leq 3.4 \cdot 10^{-121}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{d}{\mathsf{hypot}\left(d, c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.89999999999999998e-72 or 3.40000000000000001e-121 < d

    1. Initial program 55.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around inf 55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.89999999999999998e-72 < d < 3.40000000000000001e-121

    1. Initial program 68.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 93.6%

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

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

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

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

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

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

Alternative 2: 80.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{c}{\frac{d}{b}} - a}{d}\\ \mathbf{if}\;d \leq -1.9 \cdot 10^{+23}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 5 \cdot 10^{-80}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 2.75 \cdot 10^{+65}:\\ \;\;\;\;\frac{d \cdot \left(b \cdot \frac{c}{d} - a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (/ c (/ d b)) a) d)))
   (if (<= d -1.9e+23)
     t_0
     (if (<= d 5e-80)
       (/ (- b (/ (* d a) c)) c)
       (if (<= d 2.75e+65)
         (/ (* d (- (* b (/ c d)) a)) (fma d d (* c c)))
         t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c / (d / b)) - a) / d;
	double tmp;
	if (d <= -1.9e+23) {
		tmp = t_0;
	} else if (d <= 5e-80) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 2.75e+65) {
		tmp = (d * ((b * (c / d)) - a)) / fma(d, d, (c * c));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c / Float64(d / b)) - a) / d)
	tmp = 0.0
	if (d <= -1.9e+23)
		tmp = t_0;
	elseif (d <= 5e-80)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 2.75e+65)
		tmp = Float64(Float64(d * Float64(Float64(b * Float64(c / d)) - a)) / fma(d, d, Float64(c * c)));
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.9e+23], t$95$0, If[LessEqual[d, 5e-80], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.75e+65], N[(N[(d * N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{if}\;d \leq -1.9 \cdot 10^{+23}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 2.75 \cdot 10^{+65}:\\
\;\;\;\;\frac{d \cdot \left(b \cdot \frac{c}{d} - a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.89999999999999987e23 or 2.7499999999999998e65 < d

    1. Initial program 43.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 79.2%

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

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

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

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

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

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

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

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

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

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

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

    if -1.89999999999999987e23 < d < 5e-80

    1. Initial program 72.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 89.2%

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

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

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

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

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

    if 5e-80 < d < 2.7499999999999998e65

    1. Initial program 86.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around inf 86.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.9 \cdot 10^{+23}:\\ \;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\ \mathbf{elif}\;d \leq 5 \cdot 10^{-80}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 2.75 \cdot 10^{+65}:\\ \;\;\;\;\frac{d \cdot \left(b \cdot \frac{c}{d} - a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.3% accurate, 0.5× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.6e22 or 3.5000000000000001e65 < d

    1. Initial program 43.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 79.2%

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

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

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

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

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

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

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

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

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

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

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

    if -2.6e22 < d < 4.8000000000000003e-65

    1. Initial program 72.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 89.2%

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

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

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

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

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

    if 4.8000000000000003e-65 < d < 3.5000000000000001e65

    1. Initial program 86.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.6 \cdot 10^{+22}:\\ \;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\ \mathbf{elif}\;d \leq 4.8 \cdot 10^{-65}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 3.5 \cdot 10^{+65}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.2 \cdot 10^{+19} \lor \neg \left(d \leq 9.5 \cdot 10^{-59}\right):\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -9.2e19 or 9.4999999999999994e-59 < d

    1. Initial program 50.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 76.2%

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

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

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

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

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

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

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

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

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

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

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

    if -9.2e19 < d < 9.4999999999999994e-59

    1. Initial program 72.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 89.3%

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

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

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

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

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

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

Alternative 5: 77.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+21} \lor \neg \left(d \leq 1.3 \cdot 10^{-58}\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -9e21 or 1.30000000000000003e-58 < d

    1. Initial program 50.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 76.2%

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

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

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

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

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

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

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

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

    if -9e21 < d < 1.30000000000000003e-58

    1. Initial program 72.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 89.3%

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

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

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

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

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

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

Alternative 6: 77.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.55 \cdot 10^{+23} \lor \neg \left(d \leq 7.6 \cdot 10^{-59}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.54999999999999985e23 or 7.59999999999999966e-59 < d

    1. Initial program 50.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around -inf 76.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{a - c \cdot \frac{b}{d}}{-d}} \]
    8. Taylor expanded in d around inf 76.2%

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

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

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

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

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

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

    if -1.54999999999999985e23 < d < 7.59999999999999966e-59

    1. Initial program 72.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 89.3%

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

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

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

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

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

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

Alternative 7: 71.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.3 \cdot 10^{+21} \lor \neg \left(d \leq 1.8 \cdot 10^{-26}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.3e21 or 1.8000000000000001e-26 < d

    1. Initial program 49.7%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified67.0%

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

    if -1.3e21 < d < 1.8000000000000001e-26

    1. Initial program 72.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 88.0%

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

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

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

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

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

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

Alternative 8: 71.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.2 \cdot 10^{+20} \lor \neg \left(d \leq 1.75 \cdot 10^{-26}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -4.2e20 or 1.74999999999999992e-26 < d

    1. Initial program 49.7%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified67.0%

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

    if -4.2e20 < d < 1.74999999999999992e-26

    1. Initial program 72.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around -inf 88.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\mathsf{fma}\left(-1, b, \frac{a \cdot d}{c}\right) \cdot \frac{1}{c}} \]
      21. distribute-lft-neg-out87.8%

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

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

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

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

Alternative 9: 62.9% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.4 \cdot 10^{-16} \lor \neg \left(d \leq 5.4 \cdot 10^{-31}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -8.4000000000000004e-16 or 5.40000000000000027e-31 < d

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Simplified65.6%

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

    if -8.4000000000000004e-16 < d < 5.40000000000000027e-31

    1. Initial program 71.8%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 72.2%

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

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

Alternative 10: 46.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.5 \cdot 10^{+190} \lor \neg \left(d \leq 2.35 \cdot 10^{+169}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -6.5000000000000001e190 or 2.3499999999999999e169 < d

    1. Initial program 31.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-a}{d}} \]
    8. Step-by-step derivation
      1. neg-sub081.5%

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

        \[\leadsto \frac{\color{blue}{0 + \left(-a\right)}}{d} \]
      3. add-sqr-sqrt50.3%

        \[\leadsto \frac{0 + \color{blue}{\sqrt{-a} \cdot \sqrt{-a}}}{d} \]
      4. sqrt-unprod51.8%

        \[\leadsto \frac{0 + \color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}}{d} \]
      5. sqr-neg51.8%

        \[\leadsto \frac{0 + \sqrt{\color{blue}{a \cdot a}}}{d} \]
      6. sqrt-unprod16.2%

        \[\leadsto \frac{0 + \color{blue}{\sqrt{a} \cdot \sqrt{a}}}{d} \]
      7. add-sqr-sqrt32.3%

        \[\leadsto \frac{0 + \color{blue}{a}}{d} \]
    9. Applied egg-rr32.3%

      \[\leadsto \frac{\color{blue}{0 + a}}{d} \]
    10. Step-by-step derivation
      1. +-lft-identity32.3%

        \[\leadsto \frac{\color{blue}{a}}{d} \]
    11. Simplified32.3%

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

    if -6.5000000000000001e190 < d < 2.3499999999999999e169

    1. Initial program 68.8%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 52.9%

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

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

Alternative 11: 10.5% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-a}}{d} \]
  7. Simplified41.8%

    \[\leadsto \color{blue}{\frac{-a}{d}} \]
  8. Step-by-step derivation
    1. neg-sub041.8%

      \[\leadsto \frac{\color{blue}{0 - a}}{d} \]
    2. sub-neg41.8%

      \[\leadsto \frac{\color{blue}{0 + \left(-a\right)}}{d} \]
    3. add-sqr-sqrt20.8%

      \[\leadsto \frac{0 + \color{blue}{\sqrt{-a} \cdot \sqrt{-a}}}{d} \]
    4. sqrt-unprod22.6%

      \[\leadsto \frac{0 + \color{blue}{\sqrt{\left(-a\right) \cdot \left(-a\right)}}}{d} \]
    5. sqr-neg22.6%

      \[\leadsto \frac{0 + \sqrt{\color{blue}{a \cdot a}}}{d} \]
    6. sqrt-unprod6.0%

      \[\leadsto \frac{0 + \color{blue}{\sqrt{a} \cdot \sqrt{a}}}{d} \]
    7. add-sqr-sqrt11.4%

      \[\leadsto \frac{0 + \color{blue}{a}}{d} \]
  9. Applied egg-rr11.4%

    \[\leadsto \frac{\color{blue}{0 + a}}{d} \]
  10. Step-by-step derivation
    1. +-lft-identity11.4%

      \[\leadsto \frac{\color{blue}{a}}{d} \]
  11. Simplified11.4%

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

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

  :alt
  (! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))

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