Complex division, imag part

Percentage Accurate: 61.5% → 82.2%
Time: 9.1s
Alternatives: 7
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 7 alternatives:

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

Initial Program: 61.5% accurate, 1.0× speedup?

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

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

Alternative 1: 82.2% accurate, 0.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -6.40000000000000013e96 or 1.35e82 < d

    1. Initial program 32.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.40000000000000013e96 < d < -8.1999999999999994e-161

    1. Initial program 86.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.1999999999999994e-161 < d < 8.49999999999999953e-115

    1. Initial program 68.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.49999999999999953e-115 < d < 1.35e82

    1. Initial program 79.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.4 \cdot 10^{+96}:\\ \;\;\;\;\frac{\frac{b}{d} \cdot c - a}{d}\\ \mathbf{elif}\;d \leq -8.2 \cdot 10^{-161}:\\ \;\;\;\;a \cdot \left(b \cdot \frac{\frac{c}{a}}{c \cdot c + d \cdot d} - \frac{d}{c \cdot c + d \cdot d}\right)\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-115}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{+82}:\\ \;\;\;\;\frac{1}{c \cdot c + d \cdot d} \cdot \left(b \cdot c - d \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{d} \cdot c - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 83.5% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := b \cdot c - d \cdot a\\
t_1 := c \cdot c + d \cdot d\\
t_2 := \frac{\frac{b}{d} \cdot c - a}{d}\\
\mathbf{if}\;d \leq -2.5 \cdot 10^{+47}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;d \leq -7.6 \cdot 10^{-161}:\\
\;\;\;\;\frac{t\_0}{t\_1}\\

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

\mathbf{elif}\;d \leq 4 \cdot 10^{+80}:\\
\;\;\;\;\frac{1}{t\_1} \cdot t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.50000000000000011e47 or 4e80 < d

    1. Initial program 35.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} + \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-*.f6481.2%

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

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

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

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

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

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

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

    if -2.50000000000000011e47 < d < -7.6000000000000003e-161

    1. Initial program 89.9%

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

    if -7.6000000000000003e-161 < d < 5.50000000000000025e-117

    1. Initial program 68.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.50000000000000025e-117 < d < 4e80

    1. Initial program 79.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.5 \cdot 10^{+47}:\\ \;\;\;\;\frac{\frac{b}{d} \cdot c - a}{d}\\ \mathbf{elif}\;d \leq -7.6 \cdot 10^{-161}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-117}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 4 \cdot 10^{+80}:\\ \;\;\;\;\frac{1}{c \cdot c + d \cdot d} \cdot \left(b \cdot c - d \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{d} \cdot c - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 83.5% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;d \leq -8.2 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 4 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.30000000000000003e47 or 4e80 < d

    1. Initial program 35.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} + \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-*.f6481.2%

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

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

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

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

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

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

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

    if -6.30000000000000003e47 < d < -8.1999999999999994e-161 or 5.50000000000000025e-117 < d < 4e80

    1. Initial program 85.3%

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

    if -8.1999999999999994e-161 < d < 5.50000000000000025e-117

    1. Initial program 68.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.3 \cdot 10^{+47}:\\ \;\;\;\;\frac{\frac{b}{d} \cdot c - a}{d}\\ \mathbf{elif}\;d \leq -8.2 \cdot 10^{-161}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-117}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 4 \cdot 10^{+80}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{d} \cdot c - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 75.6% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 55.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.4999999999999996e-73 < c < 4.8e17

    1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.8e17 < c

    1. Initial program 61.8%

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

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

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

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

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

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

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

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

      \[\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. clear-numN/A

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

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

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

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

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

Alternative 5: 72.7% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.4000000000000001e-26 or 1.41999999999999998e79 < d

    1. Initial program 43.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-/.f6473.7%

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

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

    if -2.4000000000000001e-26 < d < 1.41999999999999998e79

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 62.4% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.20000000000000011e-125 or 7200 < d

    1. Initial program 54.9%

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

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

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

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

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

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

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

    if -5.20000000000000011e-125 < d < 7200

    1. Initial program 71.6%

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

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

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

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

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

Alternative 7: 42.8% accurate, 5.0× speedup?

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

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

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

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

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

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

Developer Target 1: 99.6% 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 2024155 
(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))))