Complex division, imag part

Percentage Accurate: 61.7% → 82.5%
Time: 10.4s
Alternatives: 10
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 10 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.7% 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: 82.5% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -2.3 \cdot 10^{-131}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if c < -3e52

    1. Initial program 45.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3e52 < c < -2.30000000000000022e-131

    1. Initial program 84.5%

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

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

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

    if -2.30000000000000022e-131 < c < 3.89999999999999994e-91

    1. Initial program 68.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0 - \frac{a}{d}\right) + \frac{\color{blue}{\frac{1}{d} \cdot \left(c \cdot b\right)}}{d} \]
      8. associate--r-93.0%

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

        \[\leadsto 0 - \color{blue}{\frac{a - \frac{1}{d} \cdot \left(c \cdot b\right)}{d}} \]
      10. neg-sub093.0%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot \frac{c}{d} - a}{d}} \]
    11. Taylor expanded in b around 0 93.0%

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

    if 3.89999999999999994e-91 < c < 9.9999999999999994e38

    1. Initial program 89.1%

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

    if 9.9999999999999994e38 < c

    1. Initial program 35.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b - a \cdot \color{blue}{{\left(\frac{c}{d}\right)}^{-1}}}{c} \]
    8. Step-by-step derivation
      1. unpow-178.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3 \cdot 10^{+52}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -2.3 \cdot 10^{-131}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 3.9 \cdot 10^{-91}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 10^{+39}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{-1}{\frac{c}{d}}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 82.5% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;c \leq -2.5 \cdot 10^{-131}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 10^{+39}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.65e50

    1. Initial program 45.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.65e50 < c < -2.5000000000000002e-131 or 3.40000000000000027e-91 < c < 9.9999999999999994e38

    1. Initial program 86.6%

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

    if -2.5000000000000002e-131 < c < 3.40000000000000027e-91

    1. Initial program 68.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0 - \frac{a}{d}\right) + \frac{\color{blue}{\frac{1}{d} \cdot \left(c \cdot b\right)}}{d} \]
      8. associate--r-93.0%

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

        \[\leadsto 0 - \color{blue}{\frac{a - \frac{1}{d} \cdot \left(c \cdot b\right)}{d}} \]
      10. neg-sub093.0%

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

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

      \[\leadsto \color{blue}{\frac{b \cdot \frac{c}{d} - a}{d}} \]
    11. Taylor expanded in b around 0 93.0%

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

    if 9.9999999999999994e38 < c

    1. Initial program 35.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b - a \cdot \color{blue}{{\left(\frac{c}{d}\right)}^{-1}}}{c} \]
    8. Step-by-step derivation
      1. unpow-178.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.65 \cdot 10^{+50}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -2.5 \cdot 10^{-131}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-91}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 10^{+39}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{-1}{\frac{c}{d}}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.5% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 56.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.59999999999999981e-15 < c < 1.02e-57

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0 - \frac{a}{d}\right) + \frac{\color{blue}{\frac{1}{d} \cdot \left(c \cdot b\right)}}{d} \]
      8. associate--r-87.5%

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

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

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

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

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

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

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

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

    if 1.02e-57 < c

    1. Initial program 47.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{1}{\frac{c}{d}}}}{c} \]
      2. inv-pow73.4%

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

      \[\leadsto \frac{b - a \cdot \color{blue}{{\left(\frac{c}{d}\right)}^{-1}}}{c} \]
    8. Step-by-step derivation
      1. unpow-173.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.6 \cdot 10^{-15}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 1.02 \cdot 10^{-57}:\\ \;\;\;\;\frac{\frac{1}{\frac{d}{c \cdot b}} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{-1}{\frac{c}{d}}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.5% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 56.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2e-14 < c < 1.02e-57

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0 - \frac{a}{d}\right) + \frac{\color{blue}{\frac{1}{d} \cdot \left(c \cdot b\right)}}{d} \]
      8. associate--r-87.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{b \cdot \frac{c}{d} - a}{d}} \]
    11. Taylor expanded in b around 0 87.6%

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

    if 1.02e-57 < c

    1. Initial program 47.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{1}{\frac{c}{d}}}}{c} \]
      2. inv-pow73.4%

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

      \[\leadsto \frac{b - a \cdot \color{blue}{{\left(\frac{c}{d}\right)}^{-1}}}{c} \]
    8. Step-by-step derivation
      1. unpow-173.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2 \cdot 10^{-14}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 1.02 \cdot 10^{-57}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{-1}{\frac{c}{d}}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 77.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.75 \cdot 10^{-14} \lor \neg \left(c \leq 4.5 \cdot 10^{-58}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.74999999999999996e-14 or 4.5000000000000003e-58 < c

    1. Initial program 51.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.74999999999999996e-14 < c < 4.5000000000000003e-58

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0 - \frac{a}{d}\right) + \frac{\color{blue}{\frac{1}{d} \cdot \left(c \cdot b\right)}}{d} \]
      8. associate--r-87.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{b \cdot \frac{c}{d} - a}{d}} \]
    11. Taylor expanded in b around 0 87.6%

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

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

Alternative 6: 77.4% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.10000000000000036e-15 or 9.99999999999999955e-58 < c

    1. Initial program 51.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.10000000000000036e-15 < c < 9.99999999999999955e-58

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(0 - \frac{a}{d}\right) + \frac{\color{blue}{\frac{1}{d} \cdot \left(c \cdot b\right)}}{d} \]
      8. associate--r-87.5%

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

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

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

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

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

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

Alternative 7: 69.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.05 \cdot 10^{-14} \lor \neg \left(c \leq 4.9 \cdot 10^{-107}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.0500000000000001e-14 or 4.8999999999999998e-107 < c

    1. Initial program 54.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0500000000000001e-14 < c < 4.8999999999999998e-107

    1. Initial program 70.3%

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

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

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

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

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

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

Alternative 8: 63.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{-14} \lor \neg \left(c \leq 6.5 \cdot 10^{-91}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.6999999999999999e-14 or 6.5000000000000001e-91 < c

    1. Initial program 54.0%

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

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

    if -2.6999999999999999e-14 < c < 6.5000000000000001e-91

    1. Initial program 70.0%

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

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

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

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

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

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

Alternative 9: 47.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.2 \cdot 10^{+186} \lor \neg \left(d \leq 3.6 \cdot 10^{+135}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7.2000000000000003e186 or 3.5999999999999998e135 < d

    1. Initial program 34.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
      7. *-un-lft-identity32.4%

        \[\leadsto \frac{1 \cdot a}{\color{blue}{1 \cdot d}} \]
      8. times-frac32.4%

        \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{a}{d}} \]
      9. metadata-eval32.4%

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

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

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

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

    if -7.2000000000000003e186 < d < 3.5999999999999998e135

    1. Initial program 69.8%

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

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

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

Alternative 10: 11.0% 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 61.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot a}}{d} \]
    7. *-un-lft-identity11.8%

      \[\leadsto \frac{1 \cdot a}{\color{blue}{1 \cdot d}} \]
    8. times-frac11.8%

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{a}{d}} \]
    9. metadata-eval11.8%

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

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

      \[\leadsto \color{blue}{\frac{a}{d}} \]
  9. Simplified11.8%

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

Developer Target 1: 99.3% 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 2024118 
(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))))