Complex division, imag part

Percentage Accurate: 61.6% → 82.9%
Time: 9.1s
Alternatives: 11
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 11 alternatives:

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

Initial Program: 61.6% accurate, 1.0× speedup?

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

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

Alternative 1: 82.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := b \cdot c - d \cdot a\\ \mathbf{if}\;d \leq -1.3 \cdot 10^{+77}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \mathbf{elif}\;d \leq -1.52 \cdot 10^{-111}:\\ \;\;\;\;\frac{1}{\frac{t\_0}{t\_1}}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+66}:\\ \;\;\;\;\frac{t\_1}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c, \frac{\frac{b}{d}}{d}, 0 - \frac{a}{d}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (+ (* c c) (* d d))) (t_1 (- (* b c) (* d a))))
   (if (<= d -1.3e+77)
     (/ (- (/ b (/ d c)) a) d)
     (if (<= d -1.52e-111)
       (/ 1.0 (/ t_0 t_1))
       (if (<= d 1.8e-121)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 2.7e+66)
           (/ t_1 t_0)
           (fma c (/ (/ b d) d) (- 0.0 (/ a d)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * c) + (d * d);
	double t_1 = (b * c) - (d * a);
	double tmp;
	if (d <= -1.3e+77) {
		tmp = ((b / (d / c)) - a) / d;
	} else if (d <= -1.52e-111) {
		tmp = 1.0 / (t_0 / t_1);
	} else if (d <= 1.8e-121) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 2.7e+66) {
		tmp = t_1 / t_0;
	} else {
		tmp = fma(c, ((b / d) / d), (0.0 - (a / d)));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(c * c) + Float64(d * d))
	t_1 = Float64(Float64(b * c) - Float64(d * a))
	tmp = 0.0
	if (d <= -1.3e+77)
		tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d);
	elseif (d <= -1.52e-111)
		tmp = Float64(1.0 / Float64(t_0 / t_1));
	elseif (d <= 1.8e-121)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 2.7e+66)
		tmp = Float64(t_1 / t_0);
	else
		tmp = fma(c, Float64(Float64(b / d) / d), Float64(0.0 - Float64(a / d)));
	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[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.3e+77], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.52e-111], N[(1.0 / N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.8e-121], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.7e+66], N[(t$95$1 / t$95$0), $MachinePrecision], N[(c * N[(N[(b / d), $MachinePrecision] / d), $MachinePrecision] + N[(0.0 - N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.52 \cdot 10^{-111}:\\
\;\;\;\;\frac{1}{\frac{t\_0}{t\_1}}\\

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

\mathbf{elif}\;d \leq 2.7 \cdot 10^{+66}:\\
\;\;\;\;\frac{t\_1}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{\frac{b}{d}}{d}, 0 - \frac{a}{d}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -1.3000000000000001e77

    1. Initial program 44.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} + \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-*.f6484.1%

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(b \cdot \frac{1}{\frac{d}{c}}\right), a\right), d\right) \]
      4. un-div-invN/A

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

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

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

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

    if -1.3000000000000001e77 < d < -1.51999999999999998e-111

    1. Initial program 93.9%

      \[\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-*.f6494.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-rr94.1%

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

    if -1.51999999999999998e-111 < d < 1.79999999999999992e-121

    1. Initial program 61.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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

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

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

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

    if 1.79999999999999992e-121 < d < 2.7e66

    1. Initial program 74.6%

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

    if 2.7e66 < d

    1. Initial program 39.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-*.f6475.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma.f64}\left(c, \mathsf{/.f64}\left(\mathsf{/.f64}\left(b, d\right), d\right), \mathsf{neg.f64}\left(\left(\frac{a}{d}\right)\right)\right) \]
      9. /-lowering-/.f6483.4%

        \[\leadsto \mathsf{fma.f64}\left(c, \mathsf{/.f64}\left(\mathsf{/.f64}\left(b, d\right), d\right), \mathsf{neg.f64}\left(\mathsf{/.f64}\left(a, d\right)\right)\right) \]
    7. Applied egg-rr83.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.3 \cdot 10^{+77}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \mathbf{elif}\;d \leq -1.52 \cdot 10^{-111}:\\ \;\;\;\;\frac{1}{\frac{c \cdot c + d \cdot d}{b \cdot c - d \cdot a}}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+66}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c, \frac{\frac{b}{d}}{d}, 0 - \frac{a}{d}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 83.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := b \cdot c - d \cdot a\\ \mathbf{if}\;d \leq -2.2 \cdot 10^{+77}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \mathbf{elif}\;d \leq -1.42 \cdot 10^{-111}:\\ \;\;\;\;\frac{1}{\frac{t\_0}{t\_1}}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 2.1 \cdot 10^{+67}:\\ \;\;\;\;\frac{t\_1}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (+ (* c c) (* d d))) (t_1 (- (* b c) (* d a))))
   (if (<= d -2.2e+77)
     (/ (- (/ b (/ d c)) a) d)
     (if (<= d -1.42e-111)
       (/ 1.0 (/ t_0 t_1))
       (if (<= d 2.7e-121)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 2.1e+67) (/ t_1 t_0) (/ (- (* b (/ c d)) a) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * c) + (d * d);
	double t_1 = (b * c) - (d * a);
	double tmp;
	if (d <= -2.2e+77) {
		tmp = ((b / (d / c)) - a) / d;
	} else if (d <= -1.42e-111) {
		tmp = 1.0 / (t_0 / t_1);
	} else if (d <= 2.7e-121) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 2.1e+67) {
		tmp = t_1 / t_0;
	} 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (c * c) + (d * d)
    t_1 = (b * c) - (d * a)
    if (d <= (-2.2d+77)) then
        tmp = ((b / (d / c)) - a) / d
    else if (d <= (-1.42d-111)) then
        tmp = 1.0d0 / (t_0 / t_1)
    else if (d <= 2.7d-121) then
        tmp = (b - ((d * a) / c)) / c
    else if (d <= 2.1d+67) then
        tmp = t_1 / t_0
    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 t_0 = (c * c) + (d * d);
	double t_1 = (b * c) - (d * a);
	double tmp;
	if (d <= -2.2e+77) {
		tmp = ((b / (d / c)) - a) / d;
	} else if (d <= -1.42e-111) {
		tmp = 1.0 / (t_0 / t_1);
	} else if (d <= 2.7e-121) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 2.1e+67) {
		tmp = t_1 / t_0;
	} else {
		tmp = ((b * (c / d)) - a) / d;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * c) + (d * d)
	t_1 = (b * c) - (d * a)
	tmp = 0
	if d <= -2.2e+77:
		tmp = ((b / (d / c)) - a) / d
	elif d <= -1.42e-111:
		tmp = 1.0 / (t_0 / t_1)
	elif d <= 2.7e-121:
		tmp = (b - ((d * a) / c)) / c
	elif d <= 2.1e+67:
		tmp = t_1 / t_0
	else:
		tmp = ((b * (c / d)) - a) / d
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * c) + Float64(d * d))
	t_1 = Float64(Float64(b * c) - Float64(d * a))
	tmp = 0.0
	if (d <= -2.2e+77)
		tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / d);
	elseif (d <= -1.42e-111)
		tmp = Float64(1.0 / Float64(t_0 / t_1));
	elseif (d <= 2.7e-121)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 2.1e+67)
		tmp = Float64(t_1 / t_0);
	else
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * c) + (d * d);
	t_1 = (b * c) - (d * a);
	tmp = 0.0;
	if (d <= -2.2e+77)
		tmp = ((b / (d / c)) - a) / d;
	elseif (d <= -1.42e-111)
		tmp = 1.0 / (t_0 / t_1);
	elseif (d <= 2.7e-121)
		tmp = (b - ((d * a) / c)) / c;
	elseif (d <= 2.1e+67)
		tmp = t_1 / t_0;
	else
		tmp = ((b * (c / d)) - a) / d;
	end
	tmp_2 = 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[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.2e+77], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.42e-111], N[(1.0 / N[(t$95$0 / t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e-121], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.1e+67], N[(t$95$1 / t$95$0), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.42 \cdot 10^{-111}:\\
\;\;\;\;\frac{1}{\frac{t\_0}{t\_1}}\\

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

\mathbf{elif}\;d \leq 2.1 \cdot 10^{+67}:\\
\;\;\;\;\frac{t\_1}{t\_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -2.2e77

    1. Initial program 44.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} + \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-*.f6484.1%

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(b \cdot \frac{1}{\frac{d}{c}}\right), a\right), d\right) \]
      4. un-div-invN/A

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

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

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

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

    if -2.2e77 < d < -1.41999999999999991e-111

    1. Initial program 93.9%

      \[\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-*.f6494.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-rr94.1%

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

    if -1.41999999999999991e-111 < d < 2.7000000000000002e-121

    1. Initial program 61.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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

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

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

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

    if 2.7000000000000002e-121 < d < 2.1000000000000001e67

    1. Initial program 74.6%

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

    if 2.1000000000000001e67 < d

    1. Initial program 39.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-*.f6475.4%

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

      \[\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-/.f6482.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.2 \cdot 10^{+77}:\\ \;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{d}\\ \mathbf{elif}\;d \leq -1.42 \cdot 10^{-111}:\\ \;\;\;\;\frac{1}{\frac{c \cdot c + d \cdot d}{b \cdot c - d \cdot a}}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 2.1 \cdot 10^{+67}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 82.8% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;d \leq -3.2 \cdot 10^{-111}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 1.5 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.0000000000000001e114 or 1.5000000000000001e64 < d

    1. Initial program 39.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 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-*.f6480.4%

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

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

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

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

    if -6.0000000000000001e114 < d < -3.1999999999999998e-111 or 1.45e-121 < d < 1.5000000000000001e64

    1. Initial program 82.1%

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

    if -3.1999999999999998e-111 < d < 1.45e-121

    1. Initial program 61.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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6 \cdot 10^{+114}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -3.2 \cdot 10^{-111}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{-121}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{+64}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 76.1% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 40.0%

      \[\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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

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

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

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

    if -1.01999999999999996e86 < c < 5.4000000000000002e36

    1. Initial program 72.2%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(b \cdot \frac{1}{\frac{d}{c}}\right), a\right), d\right) \]
      4. un-div-invN/A

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

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

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

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

    if 5.4000000000000002e36 < c

    1. Initial program 50.4%

      \[\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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(a \cdot \frac{d}{c}\right)\right), c\right) \]
      4. remove-double-divN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(a \cdot \frac{1}{\frac{1}{\frac{d}{c}}}\right)\right), c\right) \]
      5. un-div-invN/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{/.f64}\left(a, \left(\frac{1}{\frac{d}{c}}\right)\right)\right), c\right) \]
      7. clear-numN/A

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

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

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

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

Alternative 5: 76.2% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 40.0%

      \[\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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

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

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

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

    if -1e86 < c < 3.5999999999999997e36

    1. Initial program 72.2%

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

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

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

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

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

    if 3.5999999999999997e36 < c

    1. Initial program 50.4%

      \[\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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(a \cdot \frac{d}{c}\right)\right), c\right) \]
      4. remove-double-divN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \left(a \cdot \frac{1}{\frac{1}{\frac{d}{c}}}\right)\right), c\right) \]
      5. un-div-invN/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(b, \mathsf{/.f64}\left(a, \left(\frac{1}{\frac{d}{c}}\right)\right)\right), c\right) \]
      7. clear-numN/A

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

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

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

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

Alternative 6: 73.2% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -8.80000000000000034e23 or 9.8000000000000001e82 < d

    1. Initial program 48.9%

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

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

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

    if -8.80000000000000034e23 < d < 9.8000000000000001e82

    1. Initial program 69.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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8.8 \cdot 10^{+23}:\\ \;\;\;\;0 - \frac{a}{d}\\ \mathbf{elif}\;d \leq 9.8 \cdot 10^{+82}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;0 - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 73.3% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.46e22 or 2.45e82 < d

    1. Initial program 48.9%

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

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

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

    if -1.46e22 < d < 2.45e82

    1. Initial program 69.1%

      \[\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-*.f6469.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-rr69.1%

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 63.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.6 \cdot 10^{+31}:\\
\;\;\;\;\frac{1}{\frac{c}{b}}\\

\mathbf{elif}\;c \leq 1.45 \cdot 10^{+43}:\\
\;\;\;\;0 - \frac{a}{d}\\

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


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

    1. Initial program 44.6%

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

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

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    6. Step-by-step derivation
      1. clear-numN/A

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

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{c}{b}\right)}\right) \]
      3. /-lowering-/.f6474.4%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(c, \color{blue}{b}\right)\right) \]
    7. Applied egg-rr74.4%

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

    if -5.60000000000000034e31 < c < 1.4500000000000001e43

    1. Initial program 72.1%

      \[\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-/.f6459.0%

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

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

    if 1.4500000000000001e43 < c

    1. Initial program 50.5%

      \[\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-/.f6465.4%

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

      \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 63.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.42 \cdot 10^{+32}:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{elif}\;c \leq 1.35 \cdot 10^{+42}:\\
\;\;\;\;0 - \frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.41999999999999992e32 or 1.35e42 < c

    1. Initial program 47.3%

      \[\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-/.f6469.9%

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

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

    if -1.41999999999999992e32 < c < 1.35e42

    1. Initial program 72.1%

      \[\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-/.f6459.0%

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

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

Alternative 10: 63.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.6 \cdot 10^{+31}:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{elif}\;c \leq 1.1 \cdot 10^{+31}:\\
\;\;\;\;a \cdot \frac{-1}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.60000000000000034e31 or 1.10000000000000005e31 < c

    1. Initial program 47.4%

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

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

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

    if -5.60000000000000034e31 < c < 1.10000000000000005e31

    1. Initial program 72.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. Simplified66.7%

      \[\leadsto \color{blue}{a \cdot \left(\frac{\frac{c \cdot b}{a}}{c \cdot c + d \cdot d} - \frac{d}{c \cdot c + d \cdot d}\right)} \]
    6. Taylor expanded in c around 0

      \[\leadsto \mathsf{*.f64}\left(a, \color{blue}{\left(\frac{-1}{d}\right)}\right) \]
    7. Step-by-step derivation
      1. /-lowering-/.f6458.9%

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{/.f64}\left(-1, \color{blue}{d}\right)\right) \]
    8. Simplified58.9%

      \[\leadsto a \cdot \color{blue}{\frac{-1}{d}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 43.5% 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 61.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-/.f6442.5%

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

    \[\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 2024139 
(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))))