Complex division, imag part

Percentage Accurate: 61.5% → 83.3%
Time: 8.5s
Alternatives: 8
Speedup: 1.0×

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 8 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 83.3% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{a}{d \cdot \left(0 - d\right) - c \cdot c}\\
\mathbf{if}\;c \leq -9 \cdot 10^{+81}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\

\mathbf{elif}\;c \leq -1.65 \cdot 10^{-161}:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{t\_0}\\

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

\mathbf{elif}\;c \leq 1.02 \cdot 10^{+99}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{b}{t\_0}, d \cdot t\_1\right) + \mathsf{fma}\left(t\_1, d, d \cdot \frac{a}{t\_0}\right)\\

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


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

    1. Initial program 36.5%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot c + d \cdot d\right), \color{blue}{\left(b \cdot c - a \cdot d\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(c \cdot c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b \cdot c} - a \cdot d\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b} \cdot c - a \cdot d\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \left(b \cdot \color{blue}{c} - a \cdot d\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\left(b \cdot c\right), \color{blue}{\left(a \cdot d\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \left(\color{blue}{a} \cdot d\right)\right)\right)\right) \]
      9. *-lowering-*.f6436.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{d}\right)\right)\right)\right) \]
    4. Applied egg-rr36.5%

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

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

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

        \[\leadsto \frac{b}{c} + \left(\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2}}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot d}{{c}^{2}}} \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{b}{c}\right), \color{blue}{\left(\frac{a \cdot d}{{c}^{2}}\right)}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{\color{blue}{a \cdot d}}{{c}^{2}}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(a \cdot \color{blue}{\frac{d}{{c}^{2}}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{d}{{c}^{2}}\right)}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \color{blue}{\left({c}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \left(c \cdot \color{blue}{c}\right)\right)\right)\right) \]
      10. *-lowering-*.f6471.9%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
    7. Simplified71.9%

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{a \cdot d}{\color{blue}{c \cdot c}}\right)\right) \]
      2. times-fracN/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{a}{c} \cdot \color{blue}{\frac{d}{c}}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(\left(\frac{a}{c}\right), \color{blue}{\left(\frac{d}{c}\right)}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(a, c\right), \left(\frac{\color{blue}{d}}{c}\right)\right)\right) \]
      5. /-lowering-/.f6479.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(a, c\right), \mathsf{/.f64}\left(d, \color{blue}{c}\right)\right)\right) \]
    9. Applied egg-rr79.6%

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

    if -9.00000000000000034e81 < c < -1.6499999999999999e-161

    1. Initial program 81.2%

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

    if -1.6499999999999999e-161 < c < 3.7999999999999997e-99

    1. Initial program 79.6%

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

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

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

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \left(\mathsf{neg}\left(\frac{a}{d}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} - \color{blue}{\frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{d \cdot d} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \frac{\color{blue}{a}}{d} \]
      6. div-subN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{b \cdot c}{d} - a\right), \color{blue}{d}\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(b \cdot c\right), d\right), a\right), d\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(c \cdot b\right), d\right), a\right), d\right) \]
      11. *-lowering-*.f6495.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(c, b\right), d\right), a\right), d\right) \]
    5. Simplified95.0%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(b \cdot \frac{c}{d}\right), a\right), d\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \left(\frac{c}{d}\right)\right), a\right), d\right) \]
      4. /-lowering-/.f6496.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \mathsf{/.f64}\left(c, d\right)\right), a\right), d\right) \]
    7. Applied egg-rr96.3%

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

    if 3.7999999999999997e-99 < c < 1.01999999999999998e99

    1. Initial program 85.4%

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

        \[\leadsto \frac{b \cdot c}{c \cdot c + d \cdot d} - \color{blue}{\frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-commutativeN/A

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

        \[\leadsto c \cdot \frac{b}{c \cdot c + d \cdot d} - \frac{\color{blue}{a \cdot d}}{c \cdot c + d \cdot d} \]
      4. *-commutativeN/A

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

        \[\leadsto c \cdot \frac{b}{c \cdot c + d \cdot d} - d \cdot \color{blue}{\frac{a}{c \cdot c + d \cdot d}} \]
      6. prod-diffN/A

        \[\leadsto \mathsf{fma}\left(c, \frac{b}{c \cdot c + d \cdot d}, \mathsf{neg}\left(\frac{a}{c \cdot c + d \cdot d} \cdot d\right)\right) + \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\frac{a}{c \cdot c + d \cdot d}\right), d, \frac{a}{c \cdot c + d \cdot d} \cdot d\right)} \]
      7. +-lowering-+.f64N/A

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

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

    if 1.01999999999999998e99 < c

    1. Initial program 45.0%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot c + d \cdot d\right), \color{blue}{\left(b \cdot c - a \cdot d\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(c \cdot c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b \cdot c} - a \cdot d\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b} \cdot c - a \cdot d\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \left(b \cdot \color{blue}{c} - a \cdot d\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\left(b \cdot c\right), \color{blue}{\left(a \cdot d\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \left(\color{blue}{a} \cdot d\right)\right)\right)\right) \]
      9. *-lowering-*.f6443.6%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{d}\right)\right)\right)\right) \]
    4. Applied egg-rr43.6%

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

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

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

        \[\leadsto \frac{b}{c} + \left(\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2}}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot d}{{c}^{2}}} \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{b}{c}\right), \color{blue}{\left(\frac{a \cdot d}{{c}^{2}}\right)}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{\color{blue}{a \cdot d}}{{c}^{2}}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(a \cdot \color{blue}{\frac{d}{{c}^{2}}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{d}{{c}^{2}}\right)}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \color{blue}{\left({c}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \left(c \cdot \color{blue}{c}\right)\right)\right)\right) \]
      10. *-lowering-*.f6481.9%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
    7. Simplified81.9%

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

        \[\leadsto \frac{b}{c} - \frac{d}{c \cdot c} \cdot \color{blue}{a} \]
      2. associate-/r*N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c}}{c} \cdot a \]
      3. associate-*l/N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c} \cdot a}{\color{blue}{c}} \]
      4. sub-divN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot a}{\color{blue}{c}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(b - \frac{d}{c} \cdot a\right), \color{blue}{c}\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(\frac{d}{c} \cdot a\right)\right), c\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\left(\frac{d}{c}\right), a\right)\right), c\right) \]
      8. /-lowering-/.f6486.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\mathsf{/.f64}\left(d, c\right), a\right)\right), c\right) \]
    9. Applied egg-rr86.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{+81}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1.65 \cdot 10^{-161}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.8 \cdot 10^{-99}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 1.02 \cdot 10^{+99}:\\ \;\;\;\;\mathsf{fma}\left(c, \frac{b}{c \cdot c + d \cdot d}, d \cdot \frac{a}{d \cdot \left(0 - d\right) - c \cdot c}\right) + \mathsf{fma}\left(\frac{a}{d \cdot \left(0 - d\right) - c \cdot c}, d, d \cdot \frac{a}{c \cdot c + d \cdot d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 82.5% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;c \leq -1.95 \cdot 10^{-162}:\\
\;\;\;\;\frac{c \cdot b - a \cdot d}{t\_0}\\

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

\mathbf{elif}\;c \leq 7.5 \cdot 10^{+79}:\\
\;\;\;\;a \cdot \left(b \cdot \frac{\frac{c}{a}}{t\_0} - \frac{d}{t\_0}\right)\\

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


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

    1. Initial program 36.5%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot c + d \cdot d\right), \color{blue}{\left(b \cdot c - a \cdot d\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(c \cdot c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b \cdot c} - a \cdot d\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b} \cdot c - a \cdot d\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \left(b \cdot \color{blue}{c} - a \cdot d\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\left(b \cdot c\right), \color{blue}{\left(a \cdot d\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \left(\color{blue}{a} \cdot d\right)\right)\right)\right) \]
      9. *-lowering-*.f6436.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{d}\right)\right)\right)\right) \]
    4. Applied egg-rr36.5%

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

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

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

        \[\leadsto \frac{b}{c} + \left(\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2}}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot d}{{c}^{2}}} \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{b}{c}\right), \color{blue}{\left(\frac{a \cdot d}{{c}^{2}}\right)}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{\color{blue}{a \cdot d}}{{c}^{2}}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(a \cdot \color{blue}{\frac{d}{{c}^{2}}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{d}{{c}^{2}}\right)}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \color{blue}{\left({c}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \left(c \cdot \color{blue}{c}\right)\right)\right)\right) \]
      10. *-lowering-*.f6471.9%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
    7. Simplified71.9%

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{a \cdot d}{\color{blue}{c \cdot c}}\right)\right) \]
      2. times-fracN/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{a}{c} \cdot \color{blue}{\frac{d}{c}}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(\left(\frac{a}{c}\right), \color{blue}{\left(\frac{d}{c}\right)}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(a, c\right), \left(\frac{\color{blue}{d}}{c}\right)\right)\right) \]
      5. /-lowering-/.f6479.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(a, c\right), \mathsf{/.f64}\left(d, \color{blue}{c}\right)\right)\right) \]
    9. Applied egg-rr79.6%

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

    if -8.4999999999999995e82 < c < -1.95e-162

    1. Initial program 81.2%

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

    if -1.95e-162 < c < 2.4e-99

    1. Initial program 79.6%

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

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

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

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \left(\mathsf{neg}\left(\frac{a}{d}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} - \color{blue}{\frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{d \cdot d} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \frac{\color{blue}{a}}{d} \]
      6. div-subN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{b \cdot c}{d} - a\right), \color{blue}{d}\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(b \cdot c\right), d\right), a\right), d\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(c \cdot b\right), d\right), a\right), d\right) \]
      11. *-lowering-*.f6495.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(c, b\right), d\right), a\right), d\right) \]
    5. Simplified95.0%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(b \cdot \frac{c}{d}\right), a\right), d\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \left(\frac{c}{d}\right)\right), a\right), d\right) \]
      4. /-lowering-/.f6496.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \mathsf{/.f64}\left(c, d\right)\right), a\right), d\right) \]
    7. Applied egg-rr96.3%

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

    if 2.4e-99 < c < 7.49999999999999967e79

    1. Initial program 84.4%

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

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

        \[\leadsto a \cdot \left(\left(\mathsf{neg}\left(\frac{d}{{c}^{2} + {d}^{2}}\right)\right) + \frac{\color{blue}{b \cdot c}}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right) \]
      2. neg-sub0N/A

        \[\leadsto a \cdot \left(\left(0 - \frac{d}{{c}^{2} + {d}^{2}}\right) + \frac{\color{blue}{b \cdot c}}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right) \]
      3. associate-+l-N/A

        \[\leadsto a \cdot \left(0 - \color{blue}{\left(\frac{d}{{c}^{2} + {d}^{2}} - \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)}\right) \]
      4. unsub-negN/A

        \[\leadsto a \cdot \left(0 - \left(\frac{d}{{c}^{2} + {d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)}\right)\right)}\right)\right) \]
      5. mul-1-negN/A

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

        \[\leadsto a \cdot \left(0 - \left(-1 \cdot \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)} + \color{blue}{\frac{d}{{c}^{2} + {d}^{2}}}\right)\right) \]
      7. neg-sub0N/A

        \[\leadsto a \cdot \left(\mathsf{neg}\left(\left(-1 \cdot \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)} + \frac{d}{{c}^{2} + {d}^{2}}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \color{blue}{\left(\mathsf{neg}\left(\left(-1 \cdot \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)} + \frac{d}{{c}^{2} + {d}^{2}}\right)\right)\right)}\right) \]
      9. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(a, \left(0 - \color{blue}{\left(-1 \cdot \frac{b \cdot c}{a \cdot \left({c}^{2} + {d}^{2}\right)} + \frac{d}{{c}^{2} + {d}^{2}}\right)}\right)\right) \]
    5. Simplified92.0%

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

    if 7.49999999999999967e79 < c

    1. Initial program 48.0%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot c + d \cdot d\right), \color{blue}{\left(b \cdot c - a \cdot d\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(c \cdot c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b \cdot c} - a \cdot d\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b} \cdot c - a \cdot d\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \left(b \cdot \color{blue}{c} - a \cdot d\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\left(b \cdot c\right), \color{blue}{\left(a \cdot d\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \left(\color{blue}{a} \cdot d\right)\right)\right)\right) \]
      9. *-lowering-*.f6446.7%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{d}\right)\right)\right)\right) \]
    4. Applied egg-rr46.7%

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

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

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

        \[\leadsto \frac{b}{c} + \left(\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2}}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot d}{{c}^{2}}} \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{b}{c}\right), \color{blue}{\left(\frac{a \cdot d}{{c}^{2}}\right)}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{\color{blue}{a \cdot d}}{{c}^{2}}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(a \cdot \color{blue}{\frac{d}{{c}^{2}}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{d}{{c}^{2}}\right)}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \color{blue}{\left({c}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \left(c \cdot \color{blue}{c}\right)\right)\right)\right) \]
      10. *-lowering-*.f6481.1%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
    7. Simplified81.1%

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

        \[\leadsto \frac{b}{c} - \frac{d}{c \cdot c} \cdot \color{blue}{a} \]
      2. associate-/r*N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c}}{c} \cdot a \]
      3. associate-*l/N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c} \cdot a}{\color{blue}{c}} \]
      4. sub-divN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot a}{\color{blue}{c}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(b - \frac{d}{c} \cdot a\right), \color{blue}{c}\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(\frac{d}{c} \cdot a\right)\right), c\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\left(\frac{d}{c}\right), a\right)\right), c\right) \]
      8. /-lowering-/.f6485.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\mathsf{/.f64}\left(d, c\right), a\right)\right), c\right) \]
    9. Applied egg-rr85.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.5 \cdot 10^{+82}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1.95 \cdot 10^{-162}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{-99}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 7.5 \cdot 10^{+79}:\\ \;\;\;\;a \cdot \left(b \cdot \frac{\frac{c}{a}}{c \cdot c + d \cdot d} - \frac{d}{c \cdot c + d \cdot d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 83.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -1 \cdot 10^{+82}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1.65 \cdot 10^{-161}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-99}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{+129}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* a d)) (+ (* c c) (* d d)))))
   (if (<= c -1e+82)
     (- (/ b c) (* (/ a c) (/ d c)))
     (if (<= c -1.65e-161)
       t_0
       (if (<= c 1.3e-99)
         (/ (- (* b (/ c d)) a) d)
         (if (<= c 6.2e+129) t_0 (/ (- b (* a (/ d c))) c)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -1e+82) {
		tmp = (b / c) - ((a / c) * (d / c));
	} else if (c <= -1.65e-161) {
		tmp = t_0;
	} else if (c <= 1.3e-99) {
		tmp = ((b * (c / d)) - a) / d;
	} else if (c <= 6.2e+129) {
		tmp = t_0;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d))
    if (c <= (-1d+82)) then
        tmp = (b / c) - ((a / c) * (d / c))
    else if (c <= (-1.65d-161)) then
        tmp = t_0
    else if (c <= 1.3d-99) then
        tmp = ((b * (c / d)) - a) / d
    else if (c <= 6.2d+129) then
        tmp = t_0
    else
        tmp = (b - (a * (d / c))) / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -1e+82) {
		tmp = (b / c) - ((a / c) * (d / c));
	} else if (c <= -1.65e-161) {
		tmp = t_0;
	} else if (c <= 1.3e-99) {
		tmp = ((b * (c / d)) - a) / d;
	} else if (c <= 6.2e+129) {
		tmp = t_0;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -1e+82:
		tmp = (b / c) - ((a / c) * (d / c))
	elif c <= -1.65e-161:
		tmp = t_0
	elif c <= 1.3e-99:
		tmp = ((b * (c / d)) - a) / d
	elif c <= 6.2e+129:
		tmp = t_0
	else:
		tmp = (b - (a * (d / c))) / c
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (c <= -1e+82)
		tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c)));
	elseif (c <= -1.65e-161)
		tmp = t_0;
	elseif (c <= 1.3e-99)
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d);
	elseif (c <= 6.2e+129)
		tmp = t_0;
	else
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (a * d)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (c <= -1e+82)
		tmp = (b / c) - ((a / c) * (d / c));
	elseif (c <= -1.65e-161)
		tmp = t_0;
	elseif (c <= 1.3e-99)
		tmp = ((b * (c / d)) - a) / d;
	elseif (c <= 6.2e+129)
		tmp = t_0;
	else
		tmp = (b - (a * (d / c))) / 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[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1e+82], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.65e-161], t$95$0, If[LessEqual[c, 1.3e-99], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6.2e+129], t$95$0, N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.65 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 6.2 \cdot 10^{+129}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 36.5%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot c + d \cdot d\right), \color{blue}{\left(b \cdot c - a \cdot d\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(c \cdot c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b \cdot c} - a \cdot d\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b} \cdot c - a \cdot d\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \left(b \cdot \color{blue}{c} - a \cdot d\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\left(b \cdot c\right), \color{blue}{\left(a \cdot d\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \left(\color{blue}{a} \cdot d\right)\right)\right)\right) \]
      9. *-lowering-*.f6436.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{d}\right)\right)\right)\right) \]
    4. Applied egg-rr36.5%

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

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

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

        \[\leadsto \frac{b}{c} + \left(\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2}}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot d}{{c}^{2}}} \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{b}{c}\right), \color{blue}{\left(\frac{a \cdot d}{{c}^{2}}\right)}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{\color{blue}{a \cdot d}}{{c}^{2}}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(a \cdot \color{blue}{\frac{d}{{c}^{2}}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{d}{{c}^{2}}\right)}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \color{blue}{\left({c}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \left(c \cdot \color{blue}{c}\right)\right)\right)\right) \]
      10. *-lowering-*.f6471.9%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
    7. Simplified71.9%

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{a \cdot d}{\color{blue}{c \cdot c}}\right)\right) \]
      2. times-fracN/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{a}{c} \cdot \color{blue}{\frac{d}{c}}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(\left(\frac{a}{c}\right), \color{blue}{\left(\frac{d}{c}\right)}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(a, c\right), \left(\frac{\color{blue}{d}}{c}\right)\right)\right) \]
      5. /-lowering-/.f6479.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(a, c\right), \mathsf{/.f64}\left(d, \color{blue}{c}\right)\right)\right) \]
    9. Applied egg-rr79.6%

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

    if -9.9999999999999996e81 < c < -1.6499999999999999e-161 or 1.30000000000000003e-99 < c < 6.1999999999999999e129

    1. Initial program 82.1%

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

    if -1.6499999999999999e-161 < c < 1.30000000000000003e-99

    1. Initial program 79.6%

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

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

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

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \left(\mathsf{neg}\left(\frac{a}{d}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} - \color{blue}{\frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{d \cdot d} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \frac{\color{blue}{a}}{d} \]
      6. div-subN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{b \cdot c}{d} - a\right), \color{blue}{d}\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(b \cdot c\right), d\right), a\right), d\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(c \cdot b\right), d\right), a\right), d\right) \]
      11. *-lowering-*.f6495.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(c, b\right), d\right), a\right), d\right) \]
    5. Simplified95.0%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(b \cdot \frac{c}{d}\right), a\right), d\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \left(\frac{c}{d}\right)\right), a\right), d\right) \]
      4. /-lowering-/.f6496.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \mathsf{/.f64}\left(c, d\right)\right), a\right), d\right) \]
    7. Applied egg-rr96.3%

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

    if 6.1999999999999999e129 < c

    1. Initial program 39.2%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot c + d \cdot d\right), \color{blue}{\left(b \cdot c - a \cdot d\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(c \cdot c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b \cdot c} - a \cdot d\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b} \cdot c - a \cdot d\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \left(b \cdot \color{blue}{c} - a \cdot d\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\left(b \cdot c\right), \color{blue}{\left(a \cdot d\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \left(\color{blue}{a} \cdot d\right)\right)\right)\right) \]
      9. *-lowering-*.f6439.2%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{d}\right)\right)\right)\right) \]
    4. Applied egg-rr39.2%

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

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

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

        \[\leadsto \frac{b}{c} + \left(\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2}}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot d}{{c}^{2}}} \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{b}{c}\right), \color{blue}{\left(\frac{a \cdot d}{{c}^{2}}\right)}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{\color{blue}{a \cdot d}}{{c}^{2}}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(a \cdot \color{blue}{\frac{d}{{c}^{2}}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{d}{{c}^{2}}\right)}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \color{blue}{\left({c}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \left(c \cdot \color{blue}{c}\right)\right)\right)\right) \]
      10. *-lowering-*.f6485.6%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
    7. Simplified85.6%

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

        \[\leadsto \frac{b}{c} - \frac{d}{c \cdot c} \cdot \color{blue}{a} \]
      2. associate-/r*N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c}}{c} \cdot a \]
      3. associate-*l/N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c} \cdot a}{\color{blue}{c}} \]
      4. sub-divN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot a}{\color{blue}{c}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(b - \frac{d}{c} \cdot a\right), \color{blue}{c}\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(\frac{d}{c} \cdot a\right)\right), c\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\left(\frac{d}{c}\right), a\right)\right), c\right) \]
      8. /-lowering-/.f6490.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\mathsf{/.f64}\left(d, c\right), a\right)\right), c\right) \]
    9. Applied egg-rr90.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1 \cdot 10^{+82}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1.65 \cdot 10^{-161}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-99}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{+129}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 78.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -6.2 \cdot 10^{-29}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{-8}:\\ \;\;\;\;\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 (<= d -6.2e-29)
   (/ (- (* c (/ b d)) a) d)
   (if (<= d 3.1e-8) (/ (- b (* a (/ d c))) c) (/ (- (* b (/ c d)) a) d))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -6.2e-29) {
		tmp = ((c * (b / d)) - a) / d;
	} else if (d <= 3.1e-8) {
		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 (d <= (-6.2d-29)) then
        tmp = ((c * (b / d)) - a) / d
    else if (d <= 3.1d-8) 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 (d <= -6.2e-29) {
		tmp = ((c * (b / d)) - a) / d;
	} else if (d <= 3.1e-8) {
		tmp = (b - (a * (d / c))) / c;
	} else {
		tmp = ((b * (c / d)) - a) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -6.2e-29:
		tmp = ((c * (b / d)) - a) / d
	elif d <= 3.1e-8:
		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 (d <= -6.2e-29)
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	elseif (d <= 3.1e-8)
		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 (d <= -6.2e-29)
		tmp = ((c * (b / d)) - a) / d;
	elseif (d <= 3.1e-8)
		tmp = (b - (a * (d / c))) / c;
	else
		tmp = ((b * (c / d)) - a) / d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -6.2e-29], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 3.1e-8], 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}\;d \leq -6.2 \cdot 10^{-29}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\

\mathbf{elif}\;d \leq 3.1 \cdot 10^{-8}:\\
\;\;\;\;\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 3 regimes
  2. if d < -6.20000000000000052e-29

    1. Initial program 66.6%

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

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

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

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \left(\mathsf{neg}\left(\frac{a}{d}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} - \color{blue}{\frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{d \cdot d} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \frac{\color{blue}{a}}{d} \]
      6. div-subN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{b \cdot c}{d} - a\right), \color{blue}{d}\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(b \cdot c\right), d\right), a\right), d\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(c \cdot b\right), d\right), a\right), d\right) \]
      11. *-lowering-*.f6477.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(c, b\right), d\right), a\right), d\right) \]
    5. Simplified77.0%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(c \cdot \frac{b}{d}\right), a\right), d\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b}{d} \cdot c\right), a\right), d\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(\frac{b}{d}\right), c\right), a\right), d\right) \]
      4. /-lowering-/.f6478.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(b, d\right), c\right), a\right), d\right) \]
    7. Applied egg-rr78.3%

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

    if -6.20000000000000052e-29 < d < 3.1e-8

    1. Initial program 73.8%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot c + d \cdot d\right), \color{blue}{\left(b \cdot c - a \cdot d\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(c \cdot c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b \cdot c} - a \cdot d\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b} \cdot c - a \cdot d\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \left(b \cdot \color{blue}{c} - a \cdot d\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\left(b \cdot c\right), \color{blue}{\left(a \cdot d\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \left(\color{blue}{a} \cdot d\right)\right)\right)\right) \]
      9. *-lowering-*.f6473.1%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{d}\right)\right)\right)\right) \]
    4. Applied egg-rr73.1%

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

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

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

        \[\leadsto \frac{b}{c} + \left(\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2}}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot d}{{c}^{2}}} \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{b}{c}\right), \color{blue}{\left(\frac{a \cdot d}{{c}^{2}}\right)}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{\color{blue}{a \cdot d}}{{c}^{2}}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(a \cdot \color{blue}{\frac{d}{{c}^{2}}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{d}{{c}^{2}}\right)}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \color{blue}{\left({c}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \left(c \cdot \color{blue}{c}\right)\right)\right)\right) \]
      10. *-lowering-*.f6478.1%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
    7. Simplified78.1%

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

        \[\leadsto \frac{b}{c} - \frac{d}{c \cdot c} \cdot \color{blue}{a} \]
      2. associate-/r*N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c}}{c} \cdot a \]
      3. associate-*l/N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c} \cdot a}{\color{blue}{c}} \]
      4. sub-divN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot a}{\color{blue}{c}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(b - \frac{d}{c} \cdot a\right), \color{blue}{c}\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(\frac{d}{c} \cdot a\right)\right), c\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\left(\frac{d}{c}\right), a\right)\right), c\right) \]
      8. /-lowering-/.f6484.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\mathsf{/.f64}\left(d, c\right), a\right)\right), c\right) \]
    9. Applied egg-rr84.4%

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

    if 3.1e-8 < d

    1. Initial program 57.7%

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

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

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

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \left(\mathsf{neg}\left(\frac{a}{d}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} - \color{blue}{\frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{d \cdot d} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \frac{\color{blue}{a}}{d} \]
      6. div-subN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{b \cdot c}{d} - a\right), \color{blue}{d}\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(b \cdot c\right), d\right), a\right), d\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(c \cdot b\right), d\right), a\right), d\right) \]
      11. *-lowering-*.f6477.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(c, b\right), d\right), a\right), d\right) \]
    5. Simplified77.7%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(b \cdot \frac{c}{d}\right), a\right), d\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \left(\frac{c}{d}\right)\right), a\right), d\right) \]
      4. /-lowering-/.f6481.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \mathsf{/.f64}\left(c, d\right)\right), a\right), d\right) \]
    7. Applied egg-rr81.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.2 \cdot 10^{-29}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{-8}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 78.4% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.6000000000000001e-26 or 1.04e-8 < d

    1. Initial program 62.7%

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

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

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

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \left(\mathsf{neg}\left(\frac{a}{d}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} - \color{blue}{\frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{d \cdot d} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \frac{\frac{b \cdot c}{d}}{d} - \frac{\color{blue}{a}}{d} \]
      6. div-subN/A

        \[\leadsto \frac{\frac{b \cdot c}{d} - a}{\color{blue}{d}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{b \cdot c}{d} - a\right), \color{blue}{d}\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(b \cdot c\right), d\right), a\right), d\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(c \cdot b\right), d\right), a\right), d\right) \]
      11. *-lowering-*.f6477.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(c, b\right), d\right), a\right), d\right) \]
    5. Simplified77.3%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{b \cdot c}{d}\right), a\right), d\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(b \cdot \frac{c}{d}\right), a\right), d\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \left(\frac{c}{d}\right)\right), a\right), d\right) \]
      4. /-lowering-/.f6479.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, \mathsf{/.f64}\left(c, d\right)\right), a\right), d\right) \]
    7. Applied egg-rr79.5%

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

    if -2.6000000000000001e-26 < d < 1.04e-8

    1. Initial program 73.8%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot c + d \cdot d\right), \color{blue}{\left(b \cdot c - a \cdot d\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(c \cdot c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b \cdot c} - a \cdot d\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b} \cdot c - a \cdot d\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \left(b \cdot \color{blue}{c} - a \cdot d\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\left(b \cdot c\right), \color{blue}{\left(a \cdot d\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \left(\color{blue}{a} \cdot d\right)\right)\right)\right) \]
      9. *-lowering-*.f6473.1%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{d}\right)\right)\right)\right) \]
    4. Applied egg-rr73.1%

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

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

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

        \[\leadsto \frac{b}{c} + \left(\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2}}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot d}{{c}^{2}}} \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{b}{c}\right), \color{blue}{\left(\frac{a \cdot d}{{c}^{2}}\right)}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{\color{blue}{a \cdot d}}{{c}^{2}}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(a \cdot \color{blue}{\frac{d}{{c}^{2}}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{d}{{c}^{2}}\right)}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \color{blue}{\left({c}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \left(c \cdot \color{blue}{c}\right)\right)\right)\right) \]
      10. *-lowering-*.f6478.1%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
    7. Simplified78.1%

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

        \[\leadsto \frac{b}{c} - \frac{d}{c \cdot c} \cdot \color{blue}{a} \]
      2. associate-/r*N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c}}{c} \cdot a \]
      3. associate-*l/N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c} \cdot a}{\color{blue}{c}} \]
      4. sub-divN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot a}{\color{blue}{c}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(b - \frac{d}{c} \cdot a\right), \color{blue}{c}\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(\frac{d}{c} \cdot a\right)\right), c\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\left(\frac{d}{c}\right), a\right)\right), c\right) \]
      8. /-lowering-/.f6484.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\mathsf{/.f64}\left(d, c\right), a\right)\right), c\right) \]
    9. Applied egg-rr84.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.6 \cdot 10^{-26}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq 1.04 \cdot 10^{-8}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 72.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{0 - d}\\ \mathbf{if}\;d \leq -4.2 \cdot 10^{-34}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 10000:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ a (- 0.0 d))))
   (if (<= d -4.2e-34) t_0 (if (<= d 10000.0) (/ (- b (* a (/ d c))) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = a / (0.0 - d);
	double tmp;
	if (d <= -4.2e-34) {
		tmp = t_0;
	} else if (d <= 10000.0) {
		tmp = (b - (a * (d / c))) / c;
	} 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 = a / (0.0d0 - d)
    if (d <= (-4.2d-34)) then
        tmp = t_0
    else if (d <= 10000.0d0) then
        tmp = (b - (a * (d / c))) / c
    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 = a / (0.0 - d);
	double tmp;
	if (d <= -4.2e-34) {
		tmp = t_0;
	} else if (d <= 10000.0) {
		tmp = (b - (a * (d / c))) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = a / (0.0 - d)
	tmp = 0
	if d <= -4.2e-34:
		tmp = t_0
	elif d <= 10000.0:
		tmp = (b - (a * (d / c))) / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(a / Float64(0.0 - d))
	tmp = 0.0
	if (d <= -4.2e-34)
		tmp = t_0;
	elseif (d <= 10000.0)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = a / (0.0 - d);
	tmp = 0.0;
	if (d <= -4.2e-34)
		tmp = t_0;
	elseif (d <= 10000.0)
		tmp = (b - (a * (d / c))) / c;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / N[(0.0 - d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.2e-34], t$95$0, If[LessEqual[d, 10000.0], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{a}{0 - d}\\
\mathbf{if}\;d \leq -4.2 \cdot 10^{-34}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 10000:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -4.2000000000000002e-34 or 1e4 < d

    1. Initial program 62.3%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{a}{d}\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{\frac{a}{d}} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(\frac{a}{d}\right)}\right) \]
      4. /-lowering-/.f6468.8%

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(a, \color{blue}{d}\right)\right) \]
    5. Simplified68.8%

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

    if -4.2000000000000002e-34 < d < 1e4

    1. Initial program 74.5%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}\right)}\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot c + d \cdot d\right), \color{blue}{\left(b \cdot c - a \cdot d\right)}\right)\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(c \cdot c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b \cdot c} - a \cdot d\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \left(d \cdot d\right)\right), \left(\color{blue}{b} \cdot c - a \cdot d\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \left(b \cdot \color{blue}{c} - a \cdot d\right)\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\left(b \cdot c\right), \color{blue}{\left(a \cdot d\right)}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \left(\color{blue}{a} \cdot d\right)\right)\right)\right) \]
      9. *-lowering-*.f6473.8%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(c, c\right), \mathsf{*.f64}\left(d, d\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{d}\right)\right)\right)\right) \]
    4. Applied egg-rr73.8%

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

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

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

        \[\leadsto \frac{b}{c} + \left(\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2}}\right)\right) \]
      3. unsub-negN/A

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a \cdot d}{{c}^{2}}} \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{b}{c}\right), \color{blue}{\left(\frac{a \cdot d}{{c}^{2}}\right)}\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(\frac{\color{blue}{a \cdot d}}{{c}^{2}}\right)\right) \]
      6. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \left(a \cdot \color{blue}{\frac{d}{{c}^{2}}}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{d}{{c}^{2}}\right)}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \color{blue}{\left({c}^{2}\right)}\right)\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \left(c \cdot \color{blue}{c}\right)\right)\right)\right) \]
      10. *-lowering-*.f6477.9%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(b, c\right), \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(d, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
    7. Simplified77.9%

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

        \[\leadsto \frac{b}{c} - \frac{d}{c \cdot c} \cdot \color{blue}{a} \]
      2. associate-/r*N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c}}{c} \cdot a \]
      3. associate-*l/N/A

        \[\leadsto \frac{b}{c} - \frac{\frac{d}{c} \cdot a}{\color{blue}{c}} \]
      4. sub-divN/A

        \[\leadsto \frac{b - \frac{d}{c} \cdot a}{\color{blue}{c}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(b - \frac{d}{c} \cdot a\right), \color{blue}{c}\right) \]
      6. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(\frac{d}{c} \cdot a\right)\right), c\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\left(\frac{d}{c}\right), a\right)\right), c\right) \]
      8. /-lowering-/.f6484.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{*.f64}\left(\mathsf{/.f64}\left(d, c\right), a\right)\right), c\right) \]
    9. Applied egg-rr84.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.2 \cdot 10^{-34}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{elif}\;d \leq 10000:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{0 - d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 64.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{a}{0 - d}\\
\mathbf{if}\;d \leq -2.25 \cdot 10^{-29}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 3.6:\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.2499999999999999e-29 or 3.60000000000000009 < d

    1. Initial program 62.4%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\frac{a}{d}\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{\frac{a}{d}} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(\frac{a}{d}\right)}\right) \]
      4. /-lowering-/.f6469.1%

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(a, \color{blue}{d}\right)\right) \]
    5. Simplified69.1%

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

    if -2.2499999999999999e-29 < d < 3.60000000000000009

    1. Initial program 74.1%

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

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6467.2%

        \[\leadsto \mathsf{/.f64}\left(b, \color{blue}{c}\right) \]
    5. Simplified67.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.25 \cdot 10^{-29}:\\ \;\;\;\;\frac{a}{0 - d}\\ \mathbf{elif}\;d \leq 3.6:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{0 - d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 42.7% accurate, 5.0× speedup?

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

\\
\frac{b}{c}
\end{array}
Derivation
  1. Initial program 67.8%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f6441.1%

      \[\leadsto \mathsf{/.f64}\left(b, \color{blue}{c}\right) \]
  5. Simplified41.1%

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  6. 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 2024161 
(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))))