Complex division, imag part

Percentage Accurate: 61.3% → 82.3%
Time: 9.4s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 61.3% accurate, 1.0× speedup?

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

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

Alternative 1: 82.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -2.55 \cdot 10^{+54}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -4.5 \cdot 10^{-113}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-38}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{+90}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{\frac{c \cdot \frac{b}{d} - a}{d}}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -2.55e+54)
     (- (* (/ c d) (/ b d)) (/ a d))
     (if (<= d -4.5e-113)
       t_0
       (if (<= d 6.2e-38)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 6.5e+90) t_0 (/ 1.0 (/ 1.0 (/ (- (* c (/ b d)) a) d)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -2.55e+54) {
		tmp = ((c / d) * (b / d)) - (a / d);
	} else if (d <= -4.5e-113) {
		tmp = t_0;
	} else if (d <= 6.2e-38) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 6.5e+90) {
		tmp = t_0;
	} else {
		tmp = 1.0 / (1.0 / (((c * (b / d)) - a) / d));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    if (d <= (-2.55d+54)) then
        tmp = ((c / d) * (b / d)) - (a / d)
    else if (d <= (-4.5d-113)) then
        tmp = t_0
    else if (d <= 6.2d-38) then
        tmp = (b - ((d * a) / c)) / c
    else if (d <= 6.5d+90) then
        tmp = t_0
    else
        tmp = 1.0d0 / (1.0d0 / (((c * (b / 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 * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -2.55e+54) {
		tmp = ((c / d) * (b / d)) - (a / d);
	} else if (d <= -4.5e-113) {
		tmp = t_0;
	} else if (d <= 6.2e-38) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 6.5e+90) {
		tmp = t_0;
	} else {
		tmp = 1.0 / (1.0 / (((c * (b / d)) - a) / d));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -2.55e+54:
		tmp = ((c / d) * (b / d)) - (a / d)
	elif d <= -4.5e-113:
		tmp = t_0
	elif d <= 6.2e-38:
		tmp = (b - ((d * a) / c)) / c
	elif d <= 6.5e+90:
		tmp = t_0
	else:
		tmp = 1.0 / (1.0 / (((c * (b / d)) - a) / d))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -2.55e+54)
		tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d));
	elseif (d <= -4.5e-113)
		tmp = t_0;
	elseif (d <= 6.2e-38)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 6.5e+90)
		tmp = t_0;
	else
		tmp = Float64(1.0 / Float64(1.0 / Float64(Float64(Float64(c * Float64(b / d)) - a) / d)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (d <= -2.55e+54)
		tmp = ((c / d) * (b / d)) - (a / d);
	elseif (d <= -4.5e-113)
		tmp = t_0;
	elseif (d <= 6.2e-38)
		tmp = (b - ((d * a) / c)) / c;
	elseif (d <= 6.5e+90)
		tmp = t_0;
	else
		tmp = 1.0 / (1.0 / (((c * (b / d)) - a) / d));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.55e+54], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.5e-113], t$95$0, If[LessEqual[d, 6.2e-38], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 6.5e+90], t$95$0, N[(1.0 / N[(1.0 / N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -4.5 \cdot 10^{-113}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 6.5 \cdot 10^{+90}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.55000000000000005e54

    1. Initial program 36.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    6. 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. --lowering--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.55000000000000005e54 < d < -4.5000000000000001e-113 or 6.19999999999999966e-38 < d < 6.5000000000000001e90

    1. Initial program 82.0%

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

    if -4.5000000000000001e-113 < d < 6.19999999999999966e-38

    1. Initial program 60.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-*.f6491.6%

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

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

    if 6.5000000000000001e90 < d

    1. Initial program 39.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    6. 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. --lowering--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{c \cdot \left(\frac{\frac{1}{d}}{d} \cdot b\right)} - \frac{a}{d} \]
    10. Step-by-step derivation
      1. flip--N/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \left(\frac{c \cdot \left(\frac{1}{d} \cdot b\right)}{d} - \frac{\color{blue}{a}}{d}\right)\right)\right) \]
      9. sub-divN/A

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot \left(\frac{1}{d} \cdot b\right) - a\right), \color{blue}{d}\right)\right)\right) \]
    11. Applied egg-rr87.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.55 \cdot 10^{+54}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -4.5 \cdot 10^{-113}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{-38}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{+90}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{\frac{c \cdot \frac{b}{d} - a}{d}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 77.2% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -8.99999999999999924e-50

    1. Initial program 50.1%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    6. 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. --lowering--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.99999999999999924e-50 < d < 6.5999999999999997e-25

    1. Initial program 63.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-*.f6488.3%

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

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

    if 6.5999999999999997e-25 < d

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    6. 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. --lowering--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{c \cdot \left(\frac{\frac{1}{d}}{d} \cdot b\right)} - \frac{a}{d} \]
    10. Step-by-step derivation
      1. flip--N/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \left(\frac{c \cdot \left(\frac{1}{d} \cdot b\right)}{d} - \frac{\color{blue}{a}}{d}\right)\right)\right) \]
      9. sub-divN/A

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(c \cdot \left(\frac{1}{d} \cdot b\right) - a\right), \color{blue}{d}\right)\right)\right) \]
    11. Applied egg-rr78.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9 \cdot 10^{-50}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 6.6 \cdot 10^{-25}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{\frac{c \cdot \frac{b}{d} - a}{d}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{if}\;d \leq -9 \cdot 10^{-50}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 8 \cdot 10^{-23}:\\ \;\;\;\;\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 (- (* (/ c d) (/ b d)) (/ a d))))
   (if (<= d -9e-50) t_0 (if (<= d 8e-23) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c / d) * (b / d)) - (a / d);
	double tmp;
	if (d <= -9e-50) {
		tmp = t_0;
	} else if (d <= 8e-23) {
		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 = ((c / d) * (b / d)) - (a / d)
    if (d <= (-9d-50)) then
        tmp = t_0
    else if (d <= 8d-23) 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 = ((c / d) * (b / d)) - (a / d);
	double tmp;
	if (d <= -9e-50) {
		tmp = t_0;
	} else if (d <= 8e-23) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c / d) * (b / d)) - (a / d)
	tmp = 0
	if d <= -9e-50:
		tmp = t_0
	elif d <= 8e-23:
		tmp = (b - ((d * a) / c)) / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d))
	tmp = 0.0
	if (d <= -9e-50)
		tmp = t_0;
	elseif (d <= 8e-23)
		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 = ((c / d) * (b / d)) - (a / d);
	tmp = 0.0;
	if (d <= -9e-50)
		tmp = t_0;
	elseif (d <= 8e-23)
		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[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9e-50], t$95$0, If[LessEqual[d, 8e-23], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq 8 \cdot 10^{-23}:\\
\;\;\;\;\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.99999999999999924e-50 or 7.99999999999999968e-23 < d

    1. Initial program 52.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    6. 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. --lowering--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.99999999999999924e-50 < d < 7.99999999999999968e-23

    1. Initial program 63.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-*.f6488.3%

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

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

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

Alternative 4: 76.3% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -7.4999999999999998e-49

    1. Initial program 50.1%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    6. 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. --lowering--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.4999999999999998e-49 < d < 5.99999999999999991e-24

    1. Initial program 63.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-*.f6488.3%

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

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

    if 5.99999999999999991e-24 < d

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{-49}:\\ \;\;\;\;\frac{\frac{c}{d} \cdot b - a}{d}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{-24}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 77.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{c}{d} \cdot b - a}{d}\\ \mathbf{if}\;d \leq -8.5 \cdot 10^{-50}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 6 \cdot 10^{-24}:\\ \;\;\;\;\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 (/ (- (* (/ c d) b) a) d)))
   (if (<= d -8.5e-50) t_0 (if (<= d 6e-24) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = (((c / d) * b) - a) / d;
	double tmp;
	if (d <= -8.5e-50) {
		tmp = t_0;
	} else if (d <= 6e-24) {
		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 = (((c / d) * b) - a) / d
    if (d <= (-8.5d-50)) then
        tmp = t_0
    else if (d <= 6d-24) 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 = (((c / d) * b) - a) / d;
	double tmp;
	if (d <= -8.5e-50) {
		tmp = t_0;
	} else if (d <= 6e-24) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (((c / d) * b) - a) / d
	tmp = 0
	if d <= -8.5e-50:
		tmp = t_0
	elif d <= 6e-24:
		tmp = (b - ((d * a) / c)) / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(Float64(c / d) * b) - a) / d)
	tmp = 0.0
	if (d <= -8.5e-50)
		tmp = t_0;
	elseif (d <= 6e-24)
		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 = (((c / d) * b) - a) / d;
	tmp = 0.0;
	if (d <= -8.5e-50)
		tmp = t_0;
	elseif (d <= 6e-24)
		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[(N[(N[(N[(c / d), $MachinePrecision] * b), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -8.5e-50], t$95$0, If[LessEqual[d, 6e-24], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq 6 \cdot 10^{-24}:\\
\;\;\;\;\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.50000000000000012e-50 or 5.99999999999999991e-24 < d

    1. Initial program 52.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    6. 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. --lowering--.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.50000000000000012e-50 < d < 5.99999999999999991e-24

    1. Initial program 63.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-*.f6488.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8.5 \cdot 10^{-50}:\\ \;\;\;\;\frac{\frac{c}{d} \cdot b - a}{d}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{-24}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c}{d} \cdot b - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 71.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0 - \frac{a}{d}\\ \mathbf{if}\;d \leq -7 \cdot 10^{-20}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-22}:\\ \;\;\;\;\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 -7e-20) t_0 (if (<= d 1.4e-22) (/ (- 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 <= -7e-20) {
		tmp = t_0;
	} else if (d <= 1.4e-22) {
		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 <= (-7d-20)) then
        tmp = t_0
    else if (d <= 1.4d-22) 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 <= -7e-20) {
		tmp = t_0;
	} else if (d <= 1.4e-22) {
		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 <= -7e-20:
		tmp = t_0
	elif d <= 1.4e-22:
		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 <= -7e-20)
		tmp = t_0;
	elseif (d <= 1.4e-22)
		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 <= -7e-20)
		tmp = t_0;
	elseif (d <= 1.4e-22)
		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, -7e-20], t$95$0, If[LessEqual[d, 1.4e-22], 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 -7 \cdot 10^{-20}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 1.4 \cdot 10^{-22}:\\
\;\;\;\;\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 < -7.00000000000000007e-20 or 1.39999999999999997e-22 < d

    1. Initial program 50.7%

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

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

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

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

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

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

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

    if -7.00000000000000007e-20 < d < 1.39999999999999997e-22

    1. Initial program 63.9%

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

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

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

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

Alternative 7: 71.4% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7.00000000000000007e-20 or 2.42000000000000005e-23 < d

    1. Initial program 50.7%

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

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

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

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

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

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

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

    if -7.00000000000000007e-20 < d < 2.42000000000000005e-23

    1. Initial program 63.9%

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

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

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

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

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

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

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

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

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

Alternative 8: 70.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0 - \frac{a}{d}\\ \mathbf{if}\;d \leq -7 \cdot 10^{-20}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-24}:\\ \;\;\;\;\frac{b - d \cdot \frac{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 -7e-20) t_0 (if (<= d 4.5e-24) (/ (- 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 <= -7e-20) {
		tmp = t_0;
	} else if (d <= 4.5e-24) {
		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 <= (-7d-20)) then
        tmp = t_0
    else if (d <= 4.5d-24) 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 <= -7e-20) {
		tmp = t_0;
	} else if (d <= 4.5e-24) {
		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 <= -7e-20:
		tmp = t_0
	elif d <= 4.5e-24:
		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 <= -7e-20)
		tmp = t_0;
	elseif (d <= 4.5e-24)
		tmp = Float64(Float64(b - Float64(d * Float64(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 <= -7e-20)
		tmp = t_0;
	elseif (d <= 4.5e-24)
		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, -7e-20], t$95$0, If[LessEqual[d, 4.5e-24], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7.00000000000000007e-20 or 4.4999999999999997e-24 < d

    1. Initial program 50.7%

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

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

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

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

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

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

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

    if -7.00000000000000007e-20 < d < 4.4999999999999997e-24

    1. Initial program 63.9%

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

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

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

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

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

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

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

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

Alternative 9: 62.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0 - \frac{a}{d}\\ \mathbf{if}\;d \leq -6.8 \cdot 10^{-49}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-71}:\\ \;\;\;\;\frac{b}{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 -6.8e-49) t_0 (if (<= d 8.5e-71) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = 0.0 - (a / d);
	double tmp;
	if (d <= -6.8e-49) {
		tmp = t_0;
	} else if (d <= 8.5e-71) {
		tmp = b / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.0d0 - (a / d)
    if (d <= (-6.8d-49)) then
        tmp = t_0
    else if (d <= 8.5d-71) then
        tmp = b / c
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = 0.0 - (a / d);
	double tmp;
	if (d <= -6.8e-49) {
		tmp = t_0;
	} else if (d <= 8.5e-71) {
		tmp = b / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = 0.0 - (a / d)
	tmp = 0
	if d <= -6.8e-49:
		tmp = t_0
	elif d <= 8.5e-71:
		tmp = b / 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 <= -6.8e-49)
		tmp = t_0;
	elseif (d <= 8.5e-71)
		tmp = Float64(b / 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 <= -6.8e-49)
		tmp = t_0;
	elseif (d <= 8.5e-71)
		tmp = b / 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, -6.8e-49], t$95$0, If[LessEqual[d, 8.5e-71], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq 8.5 \cdot 10^{-71}:\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -6.8000000000000001e-49 or 8.49999999999999988e-71 < d

    1. Initial program 54.8%

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

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

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

    if -6.8000000000000001e-49 < d < 8.49999999999999988e-71

    1. Initial program 61.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-/.f6468.5%

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

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

Alternative 10: 42.6% 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 57.7%

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

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

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  6. Add Preprocessing

Developer Target 1: 99.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (< (fabs d) (fabs c))
   (/ (- b (* a (/ d c))) (+ c (* d (/ d c))))
   (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (abs(d) < abs(c)) then
        tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (Math.abs(d) < Math.abs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (abs(d) < abs(c))
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (abs(d) < abs(c))
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024156 
(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))))