Complex division, imag part

Percentage Accurate: 61.8% → 90.1%
Time: 10.1s
Alternatives: 13
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 13 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.8% 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: 90.1% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.75 \cdot 10^{-133} \lor \neg \left(a \leq 1.4 \cdot 10^{+40}\right):\\ \;\;\;\;\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{-d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= a -1.75e-133) (not (<= a 1.4e+40)))
   (* (/ (- (* c (/ b a)) d) (hypot d c)) (/ a (hypot d c)))
   (fma
    (/ c (hypot c d))
    (/ b (hypot c d))
    (* a (/ (- d) (pow (hypot c d) 2.0))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((a <= -1.75e-133) || !(a <= 1.4e+40)) {
		tmp = (((c * (b / a)) - d) / hypot(d, c)) * (a / hypot(d, c));
	} else {
		tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (a * (-d / pow(hypot(c, d), 2.0))));
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if ((a <= -1.75e-133) || !(a <= 1.4e+40))
		tmp = Float64(Float64(Float64(Float64(c * Float64(b / a)) - d) / hypot(d, c)) * Float64(a / hypot(d, c)));
	else
		tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(Float64(-d) / (hypot(c, d) ^ 2.0))));
	end
	return tmp
end
code[a_, b_, c_, d_] := If[Or[LessEqual[a, -1.75e-133], N[Not[LessEqual[a, 1.4e+40]], $MachinePrecision]], N[(N[(N[(N[(c * N[(b / a), $MachinePrecision]), $MachinePrecision] - d), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[((-d) / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.75 \cdot 10^{-133} \lor \neg \left(a \leq 1.4 \cdot 10^{+40}\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.75000000000000001e-133 or 1.4000000000000001e40 < a

    1. Initial program 54.6%

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

      \[\leadsto \frac{\color{blue}{a \cdot \left(\frac{b \cdot c}{a} - d\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. *-commutative54.6%

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

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

      \[\leadsto \frac{\color{blue}{a \cdot \left(c \cdot \frac{b}{a} - d\right)}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. *-commutative54.0%

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

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

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

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\sqrt{\color{blue}{c \cdot c + d \cdot d}} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      5. hypot-undefine54.0%

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\color{blue}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      6. fma-define54.0%

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot \sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      7. hypot-undefine54.0%

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      8. times-frac93.9%

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

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\color{blue}{\sqrt{c \cdot c + d \cdot d}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      10. pow263.3%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      11. +-commutative63.3%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      12. pow263.3%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      13. hypot-define93.9%

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

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\color{blue}{\sqrt{c \cdot c + d \cdot d}}} \]
      15. pow263.3%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}} \]
      16. +-commutative63.3%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \]
      17. pow263.3%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}} \]
      18. hypot-define93.9%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\color{blue}{\mathsf{hypot}\left(d, c\right)}} \]
    7. Applied egg-rr93.9%

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

    if -1.75000000000000001e-133 < a < 1.4000000000000001e40

    1. Initial program 74.7%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt73.6%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac75.7%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg75.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      6. hypot-define75.7%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define90.2%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*92.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      9. add-sqr-sqrt92.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow292.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define92.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr92.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.75 \cdot 10^{-133} \lor \neg \left(a \leq 1.4 \cdot 10^{+40}\right):\\ \;\;\;\;\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{-d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 89.7% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+240}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0

    1. Initial program 28.9%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-commutative22.4%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt22.4%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac46.1%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg46.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      6. hypot-define46.2%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define46.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*87.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      9. add-sqr-sqrt87.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow287.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define87.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr87.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    5. Taylor expanded in d around inf 71.1%

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

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

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

    if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.0000000000000003e240

    1. Initial program 83.6%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity83.6%

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-define83.7%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}} \]
      5. fma-neg83.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\color{blue}{\mathsf{fma}\left(b, c, -a \cdot d\right)}}{\sqrt{c \cdot c + d \cdot d}} \]
      6. distribute-rgt-neg-in83.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \color{blue}{a \cdot \left(-d\right)}\right)}{\sqrt{c \cdot c + d \cdot d}} \]
      7. hypot-define98.0%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    4. Applied egg-rr98.0%

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

    if 5.0000000000000003e240 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 15.4%

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

      \[\leadsto \frac{\color{blue}{a \cdot \left(\frac{b \cdot c}{a} - d\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. *-commutative15.4%

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

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

      \[\leadsto \frac{\color{blue}{a \cdot \left(c \cdot \frac{b}{a} - d\right)}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. *-commutative15.4%

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

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

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

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\sqrt{\color{blue}{c \cdot c + d \cdot d}} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      5. hypot-undefine15.4%

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\color{blue}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      6. fma-define15.4%

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot \sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      7. hypot-undefine15.4%

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      8. times-frac76.5%

        \[\leadsto \color{blue}{\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}} \]
      9. hypot-undefine26.0%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\color{blue}{\sqrt{c \cdot c + d \cdot d}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      10. pow226.0%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      11. +-commutative26.0%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      12. pow226.0%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      13. hypot-define76.5%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\color{blue}{\mathsf{hypot}\left(d, c\right)}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      14. hypot-undefine26.0%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\color{blue}{\sqrt{c \cdot c + d \cdot d}}} \]
      15. pow226.0%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}} \]
      16. +-commutative26.0%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \]
      17. pow226.0%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}} \]
      18. hypot-define76.5%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\color{blue}{\mathsf{hypot}\left(d, c\right)}} \]
    7. Applied egg-rr76.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d} \leq -\infty:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+240}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 88.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.45 \cdot 10^{-102} \lor \neg \left(a \leq 4.8 \cdot 10^{-108}\right):\\ \;\;\;\;\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\mathsf{hypot}\left(d, c\right)}}{\frac{\mathsf{hypot}\left(d, c\right)}{c}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= a -1.45e-102) (not (<= a 4.8e-108)))
   (* (/ (- (* c (/ b a)) d) (hypot d c)) (/ a (hypot d c)))
   (/ (/ b (hypot d c)) (/ (hypot d c) c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((a <= -1.45e-102) || !(a <= 4.8e-108)) {
		tmp = (((c * (b / a)) - d) / hypot(d, c)) * (a / hypot(d, c));
	} else {
		tmp = (b / hypot(d, c)) / (hypot(d, c) / c);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((a <= -1.45e-102) || !(a <= 4.8e-108)) {
		tmp = (((c * (b / a)) - d) / Math.hypot(d, c)) * (a / Math.hypot(d, c));
	} else {
		tmp = (b / Math.hypot(d, c)) / (Math.hypot(d, c) / c);
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (a <= -1.45e-102) or not (a <= 4.8e-108):
		tmp = (((c * (b / a)) - d) / math.hypot(d, c)) * (a / math.hypot(d, c))
	else:
		tmp = (b / math.hypot(d, c)) / (math.hypot(d, c) / c)
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((a <= -1.45e-102) || !(a <= 4.8e-108))
		tmp = Float64(Float64(Float64(Float64(c * Float64(b / a)) - d) / hypot(d, c)) * Float64(a / hypot(d, c)));
	else
		tmp = Float64(Float64(b / hypot(d, c)) / Float64(hypot(d, c) / c));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((a <= -1.45e-102) || ~((a <= 4.8e-108)))
		tmp = (((c * (b / a)) - d) / hypot(d, c)) * (a / hypot(d, c));
	else
		tmp = (b / hypot(d, c)) / (hypot(d, c) / c);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[a, -1.45e-102], N[Not[LessEqual[a, 4.8e-108]], $MachinePrecision]], N[(N[(N[(N[(c * N[(b / a), $MachinePrecision]), $MachinePrecision] - d), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.45 \cdot 10^{-102} \lor \neg \left(a \leq 4.8 \cdot 10^{-108}\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\mathsf{hypot}\left(d, c\right)}}{\frac{\mathsf{hypot}\left(d, c\right)}{c}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.44999999999999993e-102 or 4.80000000000000034e-108 < a

    1. Initial program 57.1%

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

      \[\leadsto \frac{\color{blue}{a \cdot \left(\frac{b \cdot c}{a} - d\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. *-commutative57.1%

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

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

      \[\leadsto \frac{\color{blue}{a \cdot \left(c \cdot \frac{b}{a} - d\right)}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. *-commutative56.5%

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

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

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

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

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

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot \sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      7. hypot-undefine56.5%

        \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      8. times-frac93.3%

        \[\leadsto \color{blue}{\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}} \]
      9. hypot-undefine64.7%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\color{blue}{\sqrt{c \cdot c + d \cdot d}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      10. pow264.7%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      11. +-commutative64.7%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      12. pow264.7%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      13. hypot-define93.3%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\color{blue}{\mathsf{hypot}\left(d, c\right)}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      14. hypot-undefine64.7%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\color{blue}{\sqrt{c \cdot c + d \cdot d}}} \]
      15. pow264.7%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}} \]
      16. +-commutative64.7%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \]
      17. pow264.7%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}} \]
      18. hypot-define93.3%

        \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\color{blue}{\mathsf{hypot}\left(d, c\right)}} \]
    7. Applied egg-rr93.3%

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

    if -1.44999999999999993e-102 < a < 4.80000000000000034e-108

    1. Initial program 74.7%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
    4. Step-by-step derivation
      1. associate-/l*66.5%

        \[\leadsto \color{blue}{b \cdot \frac{c}{{c}^{2} + {d}^{2}}} \]
      2. +-commutative66.5%

        \[\leadsto b \cdot \frac{c}{\color{blue}{{d}^{2} + {c}^{2}}} \]
      3. unpow266.5%

        \[\leadsto b \cdot \frac{c}{\color{blue}{d \cdot d} + {c}^{2}} \]
      4. fma-undefine66.5%

        \[\leadsto b \cdot \frac{c}{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \]
    5. Simplified66.5%

      \[\leadsto \color{blue}{b \cdot \frac{c}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \]
    6. Step-by-step derivation
      1. associate-*r/68.1%

        \[\leadsto \color{blue}{\frac{b \cdot c}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \]
      2. *-commutative68.1%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{\mathsf{fma}\left(d, d, {c}^{2}\right)} \]
      3. add-sqr-sqrt52.7%

        \[\leadsto \color{blue}{\sqrt{\frac{c \cdot b}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \cdot \sqrt{\frac{c \cdot b}{\mathsf{fma}\left(d, d, {c}^{2}\right)}}} \]
      4. sqrt-div35.0%

        \[\leadsto \color{blue}{\frac{\sqrt{c \cdot b}}{\sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)}}} \cdot \sqrt{\frac{c \cdot b}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \]
      5. fma-undefine35.0%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \cdot \sqrt{\frac{c \cdot b}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \]
      6. +-commutative35.0%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\sqrt{\color{blue}{{c}^{2} + d \cdot d}}} \cdot \sqrt{\frac{c \cdot b}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \]
      7. pow235.0%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\sqrt{\color{blue}{c \cdot c} + d \cdot d}} \cdot \sqrt{\frac{c \cdot b}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \]
      8. hypot-undefine35.0%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \sqrt{\frac{c \cdot b}{\mathsf{fma}\left(d, d, {c}^{2}\right)}} \]
      9. sqrt-div35.0%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{\sqrt{c \cdot b}}{\sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)}}} \]
      10. fma-undefine35.0%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\sqrt{c \cdot b}}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \]
      11. +-commutative35.0%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\sqrt{c \cdot b}}{\sqrt{\color{blue}{{c}^{2} + d \cdot d}}} \]
      12. pow235.0%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\sqrt{c \cdot b}}{\sqrt{\color{blue}{c \cdot c} + d \cdot d}} \]
      13. hypot-undefine40.1%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\sqrt{c \cdot b}}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      14. times-frac35.1%

        \[\leadsto \color{blue}{\frac{\sqrt{c \cdot b} \cdot \sqrt{c \cdot b}}{\mathsf{hypot}\left(c, d\right) \cdot \mathsf{hypot}\left(c, d\right)}} \]
      15. add-sqr-sqrt68.1%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{\mathsf{hypot}\left(c, d\right) \cdot \mathsf{hypot}\left(c, d\right)} \]
      16. frac-times90.2%

        \[\leadsto \color{blue}{\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}} \]
      17. clear-num90.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)} \]
      18. associate-*l/90.3%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} \]
    7. Applied egg-rr90.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.45 \cdot 10^{-102} \lor \neg \left(a \leq 4.8 \cdot 10^{-108}\right):\\ \;\;\;\;\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b}{\mathsf{hypot}\left(d, c\right)}}{\frac{\mathsf{hypot}\left(d, c\right)}{c}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b \cdot \frac{c}{d} - a}{d}\\ t_1 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;d \leq -2.85 \cdot 10^{+23}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-39}:\\ \;\;\;\;\frac{a \cdot d}{d \cdot \left(-d\right) - c \cdot c}\\ \mathbf{elif}\;d \leq -1.32 \cdot 10^{-51}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-76}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-25}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 2.95 \cdot 10^{+36}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* b (/ c d)) a) d)) (t_1 (/ (- (/ (* c b) d) a) d)))
   (if (<= d -2.85e+23)
     t_0
     (if (<= d -1e-39)
       (/ (* a d) (- (* d (- d)) (* c c)))
       (if (<= d -1.32e-51)
         t_1
         (if (<= d 1.35e-76)
           (/ (- b (/ a (/ c d))) c)
           (if (<= d 3e-25)
             t_1
             (if (<= d 2.95e+36) (/ (- b (* a (/ d c))) c) t_0))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((b * (c / d)) - a) / d;
	double t_1 = (((c * b) / d) - a) / d;
	double tmp;
	if (d <= -2.85e+23) {
		tmp = t_0;
	} else if (d <= -1e-39) {
		tmp = (a * d) / ((d * -d) - (c * c));
	} else if (d <= -1.32e-51) {
		tmp = t_1;
	} else if (d <= 1.35e-76) {
		tmp = (b - (a / (c / d))) / c;
	} else if (d <= 3e-25) {
		tmp = t_1;
	} else if (d <= 2.95e+36) {
		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) :: t_1
    real(8) :: tmp
    t_0 = ((b * (c / d)) - a) / d
    t_1 = (((c * b) / d) - a) / d
    if (d <= (-2.85d+23)) then
        tmp = t_0
    else if (d <= (-1d-39)) then
        tmp = (a * d) / ((d * -d) - (c * c))
    else if (d <= (-1.32d-51)) then
        tmp = t_1
    else if (d <= 1.35d-76) then
        tmp = (b - (a / (c / d))) / c
    else if (d <= 3d-25) then
        tmp = t_1
    else if (d <= 2.95d+36) then
        tmp = (b - (a * (d / c))) / c
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((b * (c / d)) - a) / d;
	double t_1 = (((c * b) / d) - a) / d;
	double tmp;
	if (d <= -2.85e+23) {
		tmp = t_0;
	} else if (d <= -1e-39) {
		tmp = (a * d) / ((d * -d) - (c * c));
	} else if (d <= -1.32e-51) {
		tmp = t_1;
	} else if (d <= 1.35e-76) {
		tmp = (b - (a / (c / d))) / c;
	} else if (d <= 3e-25) {
		tmp = t_1;
	} else if (d <= 2.95e+36) {
		tmp = (b - (a * (d / c))) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((b * (c / d)) - a) / d
	t_1 = (((c * b) / d) - a) / d
	tmp = 0
	if d <= -2.85e+23:
		tmp = t_0
	elif d <= -1e-39:
		tmp = (a * d) / ((d * -d) - (c * c))
	elif d <= -1.32e-51:
		tmp = t_1
	elif d <= 1.35e-76:
		tmp = (b - (a / (c / d))) / c
	elif d <= 3e-25:
		tmp = t_1
	elif d <= 2.95e+36:
		tmp = (b - (a * (d / c))) / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d)
	t_1 = Float64(Float64(Float64(Float64(c * b) / d) - a) / d)
	tmp = 0.0
	if (d <= -2.85e+23)
		tmp = t_0;
	elseif (d <= -1e-39)
		tmp = Float64(Float64(a * d) / Float64(Float64(d * Float64(-d)) - Float64(c * c)));
	elseif (d <= -1.32e-51)
		tmp = t_1;
	elseif (d <= 1.35e-76)
		tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c);
	elseif (d <= 3e-25)
		tmp = t_1;
	elseif (d <= 2.95e+36)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((b * (c / d)) - a) / d;
	t_1 = (((c * b) / d) - a) / d;
	tmp = 0.0;
	if (d <= -2.85e+23)
		tmp = t_0;
	elseif (d <= -1e-39)
		tmp = (a * d) / ((d * -d) - (c * c));
	elseif (d <= -1.32e-51)
		tmp = t_1;
	elseif (d <= 1.35e-76)
		tmp = (b - (a / (c / d))) / c;
	elseif (d <= 3e-25)
		tmp = t_1;
	elseif (d <= 2.95e+36)
		tmp = (b - (a * (d / c))) / c;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.85e+23], t$95$0, If[LessEqual[d, -1e-39], N[(N[(a * d), $MachinePrecision] / N[(N[(d * (-d)), $MachinePrecision] - N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.32e-51], t$95$1, If[LessEqual[d, 1.35e-76], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3e-25], t$95$1, If[LessEqual[d, 2.95e+36], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1 \cdot 10^{-39}:\\
\;\;\;\;\frac{a \cdot d}{d \cdot \left(-d\right) - c \cdot c}\\

\mathbf{elif}\;d \leq -1.32 \cdot 10^{-51}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 3 \cdot 10^{-25}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -2.85e23 or 2.95e36 < d

    1. Initial program 44.6%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt44.6%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac47.3%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg47.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      6. hypot-define47.3%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define55.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      9. add-sqr-sqrt68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow268.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr68.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    5. Taylor expanded in d around inf 79.2%

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

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

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

    if -2.85e23 < d < -9.99999999999999929e-40

    1. Initial program 91.5%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(a \cdot d\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. mul-1-neg76.1%

        \[\leadsto \frac{\color{blue}{-a \cdot d}}{c \cdot c + d \cdot d} \]
      2. *-commutative76.1%

        \[\leadsto \frac{-\color{blue}{d \cdot a}}{c \cdot c + d \cdot d} \]
      3. distribute-rgt-neg-in76.1%

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

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

    if -9.99999999999999929e-40 < d < -1.31999999999999998e-51 or 1.35e-76 < d < 2.9999999999999998e-25

    1. Initial program 93.7%

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

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

    if -1.31999999999999998e-51 < d < 1.35e-76

    1. Initial program 73.6%

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

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

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

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

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

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

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{1}{\frac{c}{d}}}}{c} \]
      2. un-div-inv87.1%

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

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

    if 2.9999999999999998e-25 < d < 2.95e36

    1. Initial program 81.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.85 \cdot 10^{+23}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-39}:\\ \;\;\;\;\frac{a \cdot d}{d \cdot \left(-d\right) - c \cdot c}\\ \mathbf{elif}\;d \leq -1.32 \cdot 10^{-51}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-76}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-25}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 2.95 \cdot 10^{+36}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 82.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;d \leq -6.5 \cdot 10^{-91}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 3.4 \cdot 10^{+38}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.0000000000000002e44 or 3.39999999999999996e38 < d

    1. Initial program 44.6%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt44.6%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac47.3%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg47.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      6. hypot-define47.3%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define55.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      9. add-sqr-sqrt68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow268.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr68.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    5. Taylor expanded in d around inf 79.2%

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

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

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

    if -2.0000000000000002e44 < d < -6.5000000000000001e-91 or 8.2000000000000001e-122 < d < 3.39999999999999996e38

    1. Initial program 92.0%

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

    if -6.5000000000000001e-91 < d < 8.2000000000000001e-122

    1. Initial program 67.7%

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

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

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

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

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

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

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{1}{\frac{c}{d}}}}{c} \]
      2. un-div-inv93.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2 \cdot 10^{+44}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -6.5 \cdot 10^{-91}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 8.2 \cdot 10^{-122}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 3.4 \cdot 10^{+38}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 77.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{if}\;d \leq -6.2 \cdot 10^{+25}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-76}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{-24} \lor \neg \left(d \leq 1.26 \cdot 10^{+36}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* b (/ c d)) a) d)))
   (if (<= d -6.2e+25)
     t_0
     (if (<= d 1.35e-76)
       (/ (- b (/ a (/ c d))) c)
       (if (or (<= d 2.8e-24) (not (<= d 1.26e+36)))
         t_0
         (/ (- b (* a (/ d c))) c))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((b * (c / d)) - a) / d;
	double tmp;
	if (d <= -6.2e+25) {
		tmp = t_0;
	} else if (d <= 1.35e-76) {
		tmp = (b - (a / (c / d))) / c;
	} else if ((d <= 2.8e-24) || !(d <= 1.26e+36)) {
		tmp = t_0;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((b * (c / d)) - a) / d
    if (d <= (-6.2d+25)) then
        tmp = t_0
    else if (d <= 1.35d-76) then
        tmp = (b - (a / (c / d))) / c
    else if ((d <= 2.8d-24) .or. (.not. (d <= 1.26d+36))) then
        tmp = t_0
    else
        tmp = (b - (a * (d / c))) / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((b * (c / d)) - a) / d;
	double tmp;
	if (d <= -6.2e+25) {
		tmp = t_0;
	} else if (d <= 1.35e-76) {
		tmp = (b - (a / (c / d))) / c;
	} else if ((d <= 2.8e-24) || !(d <= 1.26e+36)) {
		tmp = t_0;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((b * (c / d)) - a) / d
	tmp = 0
	if d <= -6.2e+25:
		tmp = t_0
	elif d <= 1.35e-76:
		tmp = (b - (a / (c / d))) / c
	elif (d <= 2.8e-24) or not (d <= 1.26e+36):
		tmp = t_0
	else:
		tmp = (b - (a * (d / c))) / c
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d)
	tmp = 0.0
	if (d <= -6.2e+25)
		tmp = t_0;
	elseif (d <= 1.35e-76)
		tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c);
	elseif ((d <= 2.8e-24) || !(d <= 1.26e+36))
		tmp = t_0;
	else
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((b * (c / d)) - a) / d;
	tmp = 0.0;
	if (d <= -6.2e+25)
		tmp = t_0;
	elseif (d <= 1.35e-76)
		tmp = (b - (a / (c / d))) / c;
	elseif ((d <= 2.8e-24) || ~((d <= 1.26e+36)))
		tmp = t_0;
	else
		tmp = (b - (a * (d / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6.2e+25], t$95$0, If[LessEqual[d, 1.35e-76], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[Or[LessEqual[d, 2.8e-24], N[Not[LessEqual[d, 1.26e+36]], $MachinePrecision]], t$95$0, N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;d \leq 2.8 \cdot 10^{-24} \lor \neg \left(d \leq 1.26 \cdot 10^{+36}\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.1999999999999996e25 or 1.35e-76 < d < 2.8000000000000002e-24 or 1.25999999999999994e36 < d

    1. Initial program 49.6%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt49.6%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac52.0%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg52.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      6. hypot-define52.0%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define59.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*71.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      9. add-sqr-sqrt71.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow271.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define71.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr71.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    5. Taylor expanded in d around inf 79.1%

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

        \[\leadsto \frac{\color{blue}{b \cdot \frac{c}{d}} - a}{d} \]
    7. Simplified84.4%

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

    if -6.1999999999999996e25 < d < 1.35e-76

    1. Initial program 76.0%

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

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

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

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

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

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

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{1}{\frac{c}{d}}}}{c} \]
      2. un-div-inv82.9%

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    7. Applied egg-rr82.9%

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

    if 2.8000000000000002e-24 < d < 1.25999999999999994e36

    1. Initial program 81.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.2 \cdot 10^{+25}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-76}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{-24} \lor \neg \left(d \leq 1.26 \cdot 10^{+36}\right):\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 77.5% accurate, 0.5× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -9.49999999999999937e22 or 1.55e36 < d

    1. Initial program 44.6%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt44.6%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac47.3%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg47.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      6. hypot-define47.3%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define55.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      9. add-sqr-sqrt68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow268.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr68.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    5. Taylor expanded in d around inf 79.2%

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

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

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

    if -9.49999999999999937e22 < d < 7.5000000000000006e-77

    1. Initial program 76.0%

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

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

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

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

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

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

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{1}{\frac{c}{d}}}}{c} \]
      2. un-div-inv82.9%

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    7. Applied egg-rr82.9%

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

    if 7.5000000000000006e-77 < d < 7.60000000000000029e-26

    1. Initial program 92.3%

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

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

    if 7.60000000000000029e-26 < d < 1.55e36

    1. Initial program 81.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.5 \cdot 10^{+22}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{-77}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 7.6 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 1.55 \cdot 10^{+36}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 77.4% accurate, 0.5× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.91999999999999993e33 or 1.6999999999999999e36 < d

    1. Initial program 44.6%

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

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

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt44.6%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac47.3%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg47.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      6. hypot-define47.3%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define55.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      9. add-sqr-sqrt68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow268.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define68.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr68.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    5. Taylor expanded in d around inf 79.2%

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

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

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

    if -1.91999999999999993e33 < d < 1.35e-76

    1. Initial program 76.0%

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

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

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

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

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

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

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{1}{\frac{c}{d}}}}{c} \]
      2. un-div-inv82.9%

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    7. Applied egg-rr82.9%

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

    if 1.35e-76 < d < 8.0000000000000003e-26

    1. Initial program 92.3%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-commutative92.3%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt92.3%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. times-frac92.4%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg92.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{c \cdot c + d \cdot d}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      6. hypot-define92.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{c \cdot c + d \cdot d}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      7. hypot-define92.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. associate-/l*99.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      9. add-sqr-sqrt99.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow299.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-define99.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    5. Taylor expanded in d around inf 78.0%

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

    if 8.0000000000000003e-26 < d < 1.6999999999999999e36

    1. Initial program 81.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.92 \cdot 10^{+33}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{-76}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 8 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+36}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 72.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.8 \cdot 10^{+39} \lor \neg \left(d \leq 3.4 \cdot 10^{+36}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.80000000000000001e39 or 3.3999999999999998e36 < d

    1. Initial program 44.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified66.6%

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

    if -2.80000000000000001e39 < d < 3.3999999999999998e36

    1. Initial program 78.0%

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

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

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

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

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

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

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{1}{\frac{c}{d}}}}{c} \]
      2. un-div-inv76.9%

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    7. Applied egg-rr76.9%

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

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

Alternative 10: 72.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.05 \cdot 10^{+31} \lor \neg \left(d \leq 1.75 \cdot 10^{+36}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.04999999999999989e31 or 1.7499999999999999e36 < d

    1. Initial program 44.6%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified66.6%

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

    if -1.04999999999999989e31 < d < 1.7499999999999999e36

    1. Initial program 78.0%

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

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

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

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

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

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

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

Alternative 11: 62.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.2 \cdot 10^{-83} \lor \neg \left(d \leq 1.18 \cdot 10^{-73}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -9.19999999999999959e-83 or 1.17999999999999993e-73 < d

    1. Initial program 58.2%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified58.1%

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

    if -9.19999999999999959e-83 < d < 1.17999999999999993e-73

    1. Initial program 72.0%

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

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

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

Alternative 12: 43.0% 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 63.4%

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

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

Alternative 13: 10.0% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \frac{a}{c} \end{array} \]
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
	return a / 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 = a / c
end function
public static double code(double a, double b, double c, double d) {
	return a / c;
}
def code(a, b, c, d):
	return a / c
function code(a, b, c, d)
	return Float64(a / c)
end
function tmp = code(a, b, c, d)
	tmp = a / c;
end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}

\\
\frac{a}{c}
\end{array}
Derivation
  1. Initial program 63.4%

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

    \[\leadsto \frac{\color{blue}{a \cdot \left(\frac{b \cdot c}{a} - d\right)}}{c \cdot c + d \cdot d} \]
  4. Step-by-step derivation
    1. *-commutative55.6%

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

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

    \[\leadsto \frac{\color{blue}{a \cdot \left(c \cdot \frac{b}{a} - d\right)}}{c \cdot c + d \cdot d} \]
  6. Step-by-step derivation
    1. *-commutative51.8%

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

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

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

      \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\sqrt{\color{blue}{c \cdot c + d \cdot d}} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    5. hypot-undefine51.8%

      \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\color{blue}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    6. fma-define51.8%

      \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot \sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
    7. hypot-undefine51.8%

      \[\leadsto \frac{\left(c \cdot \frac{b}{a} - d\right) \cdot a}{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    8. times-frac77.3%

      \[\leadsto \color{blue}{\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}} \]
    9. hypot-undefine56.7%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\color{blue}{\sqrt{c \cdot c + d \cdot d}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
    10. pow256.7%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
    11. +-commutative56.7%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
    12. pow256.7%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
    13. hypot-define77.3%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\color{blue}{\mathsf{hypot}\left(d, c\right)}} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
    14. hypot-undefine56.7%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\color{blue}{\sqrt{c \cdot c + d \cdot d}}} \]
    15. pow256.7%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{\color{blue}{{c}^{2}} + d \cdot d}} \]
    16. +-commutative56.7%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{\color{blue}{d \cdot d + {c}^{2}}}} \]
    17. pow256.7%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\sqrt{d \cdot d + \color{blue}{c \cdot c}}} \]
    18. hypot-define77.3%

      \[\leadsto \frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\color{blue}{\mathsf{hypot}\left(d, c\right)}} \]
  7. Applied egg-rr77.3%

    \[\leadsto \color{blue}{\frac{c \cdot \frac{b}{a} - d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}} \]
  8. Taylor expanded in c around inf 32.2%

    \[\leadsto \color{blue}{\left(-1 \cdot \frac{d}{c} + \frac{b}{a}\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)} \]
  9. Step-by-step derivation
    1. +-commutative32.2%

      \[\leadsto \color{blue}{\left(\frac{b}{a} + -1 \cdot \frac{d}{c}\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)} \]
    2. mul-1-neg32.2%

      \[\leadsto \left(\frac{b}{a} + \color{blue}{\left(-\frac{d}{c}\right)}\right) \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)} \]
    3. sub-neg32.2%

      \[\leadsto \color{blue}{\left(\frac{b}{a} - \frac{d}{c}\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)} \]
  10. Simplified32.2%

    \[\leadsto \color{blue}{\left(\frac{b}{a} - \frac{d}{c}\right)} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)} \]
  11. Taylor expanded in d around -inf 11.8%

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  12. Add Preprocessing

Developer target: 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 2024103 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (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))))