Complex division, imag part

Percentage Accurate: 61.1% → 98.3%
Time: 14.8s
Alternatives: 12
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 12 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.1% 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: 98.3% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \frac{\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (- (* (/ c (hypot c d)) b) (* d (/ a (hypot c d)))) (hypot c d)))
double code(double a, double b, double c, double d) {
	return (((c / hypot(c, d)) * b) - (d * (a / hypot(c, d)))) / hypot(c, d);
}
public static double code(double a, double b, double c, double d) {
	return (((c / Math.hypot(c, d)) * b) - (d * (a / Math.hypot(c, d)))) / Math.hypot(c, d);
}
def code(a, b, c, d):
	return (((c / math.hypot(c, d)) * b) - (d * (a / math.hypot(c, d)))) / math.hypot(c, d)
function code(a, b, c, d)
	return Float64(Float64(Float64(Float64(c / hypot(c, d)) * b) - Float64(d * Float64(a / hypot(c, d)))) / hypot(c, d))
end
function tmp = code(a, b, c, d)
	tmp = (((c / hypot(c, d)) * b) - (d * (a / hypot(c, d)))) / hypot(c, d);
end
code[a_, b_, c_, d_] := N[(N[(N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] - N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}
\end{array}
Derivation
  1. Initial program 63.5%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
    2. sub-neg61.7%

      \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
    3. *-un-lft-identity61.7%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
  5. Step-by-step derivation
    1. fma-neg69.8%

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}} \]
    4. associate-/r/78.1%

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

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

    \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
  7. Step-by-step derivation
    1. *-un-lft-identity78.1%

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)} \]
  8. Applied egg-rr85.6%

    \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)} \]
  9. Step-by-step derivation
    1. associate-*l/85.6%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \color{blue}{\frac{1 \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}} \]
    2. *-lft-identity85.6%

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

    \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \color{blue}{\frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}} \]
  11. Step-by-step derivation
    1. associate-*l/85.7%

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}}{\mathsf{hypot}\left(c, d\right)}} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \]
    2. *-un-lft-identity85.7%

      \[\leadsto \frac{\color{blue}{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}}}{\mathsf{hypot}\left(c, d\right)} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \]
    3. associate-*r/96.6%

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

      \[\leadsto \color{blue}{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}} \]
    5. associate-/r/99.2%

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

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

    \[\leadsto \frac{\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \]
  14. Add Preprocessing

Alternative 2: 88.7% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+254}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\

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


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

    1. Initial program 82.7%

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

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

        \[\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-frac82.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-def82.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. hypot-def97.0%

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

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

    if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 11.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub9.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. sub-neg9.4%

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

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

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

        \[\leadsto \color{blue}{\frac{c}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b}{\sqrt{c \cdot c + d \cdot d}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      6. fma-def16.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)} \]
      7. hypot-def16.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) \]
      8. hypot-def45.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) \]
      9. associate-/l*58.1%

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

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

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

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

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

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

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

Alternative 3: 82.1% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -1.55 \cdot 10^{+95}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{d}{c} \cdot \frac{a}{c}, \frac{b}{c}\right)\\

\mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 3.9 \cdot 10^{-66}:\\
\;\;\;\;t_0\\

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

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


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

    1. Initial program 49.8%

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}}, \frac{b}{c}\right) \]
    5. Simplified84.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, \frac{a}{\frac{{c}^{2}}{d}}, \frac{b}{c}\right)} \]
    6. Step-by-step derivation
      1. clear-num84.9%

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{1}{\frac{\frac{{c}^{2}}{d}}{a}}}, \frac{b}{c}\right) \]
      2. inv-pow84.9%

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

      \[\leadsto \mathsf{fma}\left(-1, \color{blue}{{\left(\frac{\frac{{c}^{2}}{d}}{a}\right)}^{-1}}, \frac{b}{c}\right) \]
    8. Step-by-step derivation
      1. unpow-184.9%

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{1}{\frac{\frac{{c}^{2}}{d}}{a}}}, \frac{b}{c}\right) \]
      2. associate-/l/84.3%

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

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

      \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{1}{\frac{{c}^{2}}{d \cdot a}}}, \frac{b}{c}\right) \]
    10. Step-by-step derivation
      1. clear-num84.3%

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{d}{c} \cdot \frac{a}{c}}, \frac{b}{c}\right) \]
    11. Applied egg-rr94.8%

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

    if -1.5500000000000001e95 < c < -4.20000000000000019e-100 or 3.1e-145 < c < 3.89999999999999983e-66

    1. Initial program 93.2%

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

    if -4.20000000000000019e-100 < c < 3.1e-145

    1. Initial program 59.3%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg76.6%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. associate-/l*76.8%

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
      5. associate-/r/71.0%

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

      \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c - \frac{a}{d}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity71.0%

        \[\leadsto \frac{\color{blue}{1 \cdot b}}{{d}^{2}} \cdot c - \frac{a}{d} \]
      2. unpow271.0%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{d}, \frac{b}{d} \cdot c, -\frac{a}{d}\right)} \]
    9. Applied egg-rr81.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{d}, \frac{b}{d} \cdot c, -\frac{a}{d}\right)} \]
    10. Step-by-step derivation
      1. fma-udef81.6%

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

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

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \left(-\color{blue}{\frac{1}{d} \cdot a}\right) \]
      4. distribute-rgt-neg-in81.3%

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \color{blue}{\frac{1}{d} \cdot \left(-a\right)} \]
      5. distribute-lft-out81.3%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{b}{d} \cdot c + \left(-a\right)\right)} \]
      6. *-commutative81.3%

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

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

    if 3.89999999999999983e-66 < c < 1.2000000000000001e41

    1. Initial program 62.6%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. associate-/l*68.2%

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
      5. associate-/r/68.1%

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

      \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c - \frac{a}{d}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity68.1%

        \[\leadsto \frac{\color{blue}{1 \cdot b}}{{d}^{2}} \cdot c - \frac{a}{d} \]
      2. unpow268.1%

        \[\leadsto \frac{1 \cdot b}{\color{blue}{d \cdot d}} \cdot c - \frac{a}{d} \]
      3. times-frac76.3%

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

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

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

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

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

    if 1.2000000000000001e41 < c

    1. Initial program 43.5%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      3. *-un-lft-identity43.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    5. Step-by-step derivation
      1. fma-neg52.7%

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}} \]
      4. associate-/r/86.8%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \color{blue}{d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    6. Simplified86.8%

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(-1 \cdot b\right)} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
    8. Step-by-step derivation
      1. mul-1-neg28.6%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(-b\right)} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
    9. Simplified28.6%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(-b\right)} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
    10. Step-by-step derivation
      1. associate-*l/28.6%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(-b\right)}{\mathsf{hypot}\left(c, d\right)}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
      2. *-un-lft-identity28.6%

        \[\leadsto \frac{\color{blue}{-b}}{\mathsf{hypot}\left(c, d\right)} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
      3. associate-*r/28.2%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b} \cdot \sqrt{b}} - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \]
      12. add-sqr-sqrt92.5%

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

        \[\leadsto \frac{b - d \cdot \color{blue}{\frac{1}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}}{\mathsf{hypot}\left(c, d\right)} \]
      14. un-div-inv92.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.55 \cdot 10^{+95}:\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{d}{c} \cdot \frac{a}{c}, \frac{b}{c}\right)\\ \mathbf{elif}\;c \leq -4.2 \cdot 10^{-100}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-145}:\\ \;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\ \mathbf{elif}\;c \leq 3.9 \cdot 10^{-66}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{+41}:\\ \;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 87.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ \mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+254}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))))
   (if (<= (/ t_0 (+ (* c c) (* d d))) 1e+254)
     (* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
     (/ (- b (/ d (/ (hypot c d) a))) (hypot c d)))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if ((t_0 / ((c * c) + (d * d))) <= 1e+254) {
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	} else {
		tmp = (b - (d / (hypot(c, d) / a))) / hypot(c, d);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double tmp;
	if ((t_0 / ((c * c) + (d * d))) <= 1e+254) {
		tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
	} else {
		tmp = (b - (d / (Math.hypot(c, d) / a))) / Math.hypot(c, d);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	tmp = 0
	if (t_0 / ((c * c) + (d * d))) <= 1e+254:
		tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d))
	else:
		tmp = (b - (d / (math.hypot(c, d) / a))) / math.hypot(c, d)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+254)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d)));
	else
		tmp = Float64(Float64(b - Float64(d / Float64(hypot(c, d) / a))) / hypot(c, d));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	tmp = 0.0;
	if ((t_0 / ((c * c) + (d * d))) <= 1e+254)
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	else
		tmp = (b - (d / (hypot(c, d) / a))) / hypot(c, d);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+254], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(d / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+254}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\

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


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

    1. Initial program 82.7%

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

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

        \[\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-frac82.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-def82.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. hypot-def97.0%

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

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

    if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 11.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub9.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. sub-neg9.4%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      3. *-un-lft-identity9.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    5. Step-by-step derivation
      1. fma-neg18.6%

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}} \]
      4. associate-/r/57.9%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \color{blue}{d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    6. Simplified57.9%

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(-1 \cdot b\right)} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
    8. Step-by-step derivation
      1. mul-1-neg29.7%

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(-b\right)} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
    10. Step-by-step derivation
      1. associate-*l/29.8%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(-b\right)}{\mathsf{hypot}\left(c, d\right)}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
      2. *-un-lft-identity29.8%

        \[\leadsto \frac{\color{blue}{-b}}{\mathsf{hypot}\left(c, d\right)} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
      3. associate-*r/20.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{b} \cdot \sqrt{b}} - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} \]
      12. add-sqr-sqrt66.4%

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

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

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

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

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

Alternative 5: 88.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := c \cdot b - d \cdot a\\ \mathbf{if}\;\frac{t_1}{c \cdot c + d \cdot d} \leq 10^{+254}:\\ \;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (- (* c b) (* d a))))
   (if (<= (/ t_1 (+ (* c c) (* d d))) 1e+254)
     (* t_0 (/ t_1 (hypot c d)))
     (- (* t_0 (/ c (/ (hypot c d) b))) (/ a d)))))
double code(double a, double b, double c, double d) {
	double t_0 = 1.0 / hypot(c, d);
	double t_1 = (c * b) - (d * a);
	double tmp;
	if ((t_1 / ((c * c) + (d * d))) <= 1e+254) {
		tmp = t_0 * (t_1 / hypot(c, d));
	} else {
		tmp = (t_0 * (c / (hypot(c, d) / b))) - (a / d);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = 1.0 / Math.hypot(c, d);
	double t_1 = (c * b) - (d * a);
	double tmp;
	if ((t_1 / ((c * c) + (d * d))) <= 1e+254) {
		tmp = t_0 * (t_1 / Math.hypot(c, d));
	} else {
		tmp = (t_0 * (c / (Math.hypot(c, d) / b))) - (a / d);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = 1.0 / math.hypot(c, d)
	t_1 = (c * b) - (d * a)
	tmp = 0
	if (t_1 / ((c * c) + (d * d))) <= 1e+254:
		tmp = t_0 * (t_1 / math.hypot(c, d))
	else:
		tmp = (t_0 * (c / (math.hypot(c, d) / b))) - (a / d)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(1.0 / hypot(c, d))
	t_1 = Float64(Float64(c * b) - Float64(d * a))
	tmp = 0.0
	if (Float64(t_1 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+254)
		tmp = Float64(t_0 * Float64(t_1 / hypot(c, d)));
	else
		tmp = Float64(Float64(t_0 * Float64(c / Float64(hypot(c, d) / b))) - Float64(a / d));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = 1.0 / hypot(c, d);
	t_1 = (c * b) - (d * a);
	tmp = 0.0;
	if ((t_1 / ((c * c) + (d * d))) <= 1e+254)
		tmp = t_0 * (t_1 / hypot(c, d));
	else
		tmp = (t_0 * (c / (hypot(c, d) / b))) - (a / d);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+254], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_1}{c \cdot c + d \cdot d} \leq 10^{+254}:\\
\;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\

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


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

    1. Initial program 82.7%

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

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

        \[\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-frac82.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-def82.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. hypot-def97.0%

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

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

    if 9.9999999999999994e253 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 11.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub9.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. sub-neg9.4%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      3. *-un-lft-identity9.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    5. Step-by-step derivation
      1. fma-neg18.6%

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}} \]
      4. associate-/r/57.9%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \color{blue}{d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    6. Simplified57.9%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity57.9%

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)} \]
    9. Step-by-step derivation
      1. associate-*l/81.8%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \color{blue}{\frac{1 \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}} \]
      2. *-lft-identity81.8%

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

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

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

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

Alternative 6: 82.0% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \mathsf{fma}\left(-1, \frac{d}{c} \cdot \frac{a}{c}, \frac{b}{c}\right)\\
\mathbf{if}\;c \leq -4 \cdot 10^{+91}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \leq -5 \cdot 10^{-100}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.45 \cdot 10^{+81}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -4.00000000000000032e91 or 1.45e81 < c

    1. Initial program 40.0%

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}}, \frac{b}{c}\right) \]
    5. Simplified82.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, \frac{a}{\frac{{c}^{2}}{d}}, \frac{b}{c}\right)} \]
    6. Step-by-step derivation
      1. clear-num82.3%

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{1}{\frac{\frac{{c}^{2}}{d}}{a}}}, \frac{b}{c}\right) \]
      2. inv-pow82.3%

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

      \[\leadsto \mathsf{fma}\left(-1, \color{blue}{{\left(\frac{\frac{{c}^{2}}{d}}{a}\right)}^{-1}}, \frac{b}{c}\right) \]
    8. Step-by-step derivation
      1. unpow-182.3%

        \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{1}{\frac{\frac{{c}^{2}}{d}}{a}}}, \frac{b}{c}\right) \]
      2. associate-/l/80.4%

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

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

      \[\leadsto \mathsf{fma}\left(-1, \color{blue}{\frac{1}{\frac{{c}^{2}}{d \cdot a}}}, \frac{b}{c}\right) \]
    10. Step-by-step derivation
      1. clear-num80.9%

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

        \[\leadsto \mathsf{fma}\left(-1, \frac{d \cdot a}{\color{blue}{c \cdot c}}, \frac{b}{c}\right) \]
      3. times-frac91.2%

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

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

    if -4.00000000000000032e91 < c < -5.0000000000000001e-100 or 1.1199999999999999e-142 < c < 1.45e81

    1. Initial program 86.4%

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

    if -5.0000000000000001e-100 < c < 1.1199999999999999e-142

    1. Initial program 59.3%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg76.6%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. associate-/l*76.8%

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
      5. associate-/r/71.0%

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

      \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c - \frac{a}{d}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity71.0%

        \[\leadsto \frac{\color{blue}{1 \cdot b}}{{d}^{2}} \cdot c - \frac{a}{d} \]
      2. unpow271.0%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{d}, \frac{b}{d} \cdot c, -\frac{a}{d}\right)} \]
    9. Applied egg-rr81.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{d}, \frac{b}{d} \cdot c, -\frac{a}{d}\right)} \]
    10. Step-by-step derivation
      1. fma-udef81.6%

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

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

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \left(-\color{blue}{\frac{1}{d} \cdot a}\right) \]
      4. distribute-rgt-neg-in81.3%

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \color{blue}{\frac{1}{d} \cdot \left(-a\right)} \]
      5. distribute-lft-out81.3%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{b}{d} \cdot c + \left(-a\right)\right)} \]
      6. *-commutative81.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4 \cdot 10^{+91}:\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{d}{c} \cdot \frac{a}{c}, \frac{b}{c}\right)\\ \mathbf{elif}\;c \leq -5 \cdot 10^{-100}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.12 \cdot 10^{-142}:\\ \;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{+81}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{d}{c} \cdot \frac{a}{c}, \frac{b}{c}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 79.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}\\ \mathbf{if}\;c \leq -5.5 \cdot 10^{+88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\ \mathbf{elif}\;c \leq 3.5 \cdot 10^{+80}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
        (t_1 (- (/ b c) (/ d (/ (pow c 2.0) a)))))
   (if (<= c -5.5e+88)
     t_1
     (if (<= c -6e-100)
       t_0
       (if (<= c 7.2e-146)
         (* (/ 1.0 d) (- (* c (/ b d)) a))
         (if (<= c 3.5e+80) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = (b / c) - (d / (pow(c, 2.0) / a));
	double tmp;
	if (c <= -5.5e+88) {
		tmp = t_1;
	} else if (c <= -6e-100) {
		tmp = t_0;
	} else if (c <= 7.2e-146) {
		tmp = (1.0 / d) * ((c * (b / d)) - a);
	} else if (c <= 3.5e+80) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    t_1 = (b / c) - (d / ((c ** 2.0d0) / a))
    if (c <= (-5.5d+88)) then
        tmp = t_1
    else if (c <= (-6d-100)) then
        tmp = t_0
    else if (c <= 7.2d-146) then
        tmp = (1.0d0 / d) * ((c * (b / d)) - a)
    else if (c <= 3.5d+80) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = (b / c) - (d / (Math.pow(c, 2.0) / a));
	double tmp;
	if (c <= -5.5e+88) {
		tmp = t_1;
	} else if (c <= -6e-100) {
		tmp = t_0;
	} else if (c <= 7.2e-146) {
		tmp = (1.0 / d) * ((c * (b / d)) - a);
	} else if (c <= 3.5e+80) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	t_1 = (b / c) - (d / (math.pow(c, 2.0) / a))
	tmp = 0
	if c <= -5.5e+88:
		tmp = t_1
	elif c <= -6e-100:
		tmp = t_0
	elif c <= 7.2e-146:
		tmp = (1.0 / d) * ((c * (b / d)) - a)
	elif c <= 3.5e+80:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(Float64(b / c) - Float64(d / Float64((c ^ 2.0) / a)))
	tmp = 0.0
	if (c <= -5.5e+88)
		tmp = t_1;
	elseif (c <= -6e-100)
		tmp = t_0;
	elseif (c <= 7.2e-146)
		tmp = Float64(Float64(1.0 / d) * Float64(Float64(c * Float64(b / d)) - a));
	elseif (c <= 3.5e+80)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	t_1 = (b / c) - (d / ((c ^ 2.0) / a));
	tmp = 0.0;
	if (c <= -5.5e+88)
		tmp = t_1;
	elseif (c <= -6e-100)
		tmp = t_0;
	elseif (c <= 7.2e-146)
		tmp = (1.0 / d) * ((c * (b / d)) - a);
	elseif (c <= 3.5e+80)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(d / N[(N[Power[c, 2.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5.5e+88], t$95$1, If[LessEqual[c, -6e-100], t$95$0, If[LessEqual[c, 7.2e-146], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.5e+80], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -6 \cdot 10^{-100}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 3.5 \cdot 10^{+80}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.5e88 or 3.49999999999999994e80 < c

    1. Initial program 40.0%

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

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

        \[\leadsto \color{blue}{\frac{b}{c} + -1 \cdot \frac{a \cdot d}{{c}^{2}}} \]
      2. mul-1-neg80.9%

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

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

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{d \cdot a}}{{c}^{2}} \]
      5. associate-/l*83.9%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{d}{\frac{{c}^{2}}{a}}} \]
    5. Simplified83.9%

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

    if -5.5e88 < c < -6.0000000000000001e-100 or 7.19999999999999957e-146 < c < 3.49999999999999994e80

    1. Initial program 86.4%

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

    if -6.0000000000000001e-100 < c < 7.19999999999999957e-146

    1. Initial program 59.3%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg76.6%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. associate-/l*76.8%

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
      5. associate-/r/71.0%

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

      \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c - \frac{a}{d}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity71.0%

        \[\leadsto \frac{\color{blue}{1 \cdot b}}{{d}^{2}} \cdot c - \frac{a}{d} \]
      2. unpow271.0%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{d}, \frac{b}{d} \cdot c, -\frac{a}{d}\right)} \]
    9. Applied egg-rr81.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{d}, \frac{b}{d} \cdot c, -\frac{a}{d}\right)} \]
    10. Step-by-step derivation
      1. fma-udef81.6%

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

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

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \left(-\color{blue}{\frac{1}{d} \cdot a}\right) \]
      4. distribute-rgt-neg-in81.3%

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \color{blue}{\frac{1}{d} \cdot \left(-a\right)} \]
      5. distribute-lft-out81.3%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{b}{d} \cdot c + \left(-a\right)\right)} \]
      6. *-commutative81.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.5 \cdot 10^{+88}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-100}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\ \mathbf{elif}\;c \leq 3.5 \cdot 10^{+80}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 77.7% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;c \leq -7.5 \cdot 10^{-100}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 3 \cdot 10^{+81}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.00000000000000004e93 or 2.99999999999999997e81 < c

    1. Initial program 40.0%

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

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

    if -1.00000000000000004e93 < c < -7.50000000000000015e-100 or 7.5000000000000003e-143 < c < 2.99999999999999997e81

    1. Initial program 86.4%

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

    if -7.50000000000000015e-100 < c < 7.5000000000000003e-143

    1. Initial program 59.3%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg76.6%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. associate-/l*76.8%

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
      5. associate-/r/71.0%

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

      \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c - \frac{a}{d}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity71.0%

        \[\leadsto \frac{\color{blue}{1 \cdot b}}{{d}^{2}} \cdot c - \frac{a}{d} \]
      2. unpow271.0%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{d}, \frac{b}{d} \cdot c, -\frac{a}{d}\right)} \]
    9. Applied egg-rr81.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{d}, \frac{b}{d} \cdot c, -\frac{a}{d}\right)} \]
    10. Step-by-step derivation
      1. fma-udef81.6%

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

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

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \left(-\color{blue}{\frac{1}{d} \cdot a}\right) \]
      4. distribute-rgt-neg-in81.3%

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \color{blue}{\frac{1}{d} \cdot \left(-a\right)} \]
      5. distribute-lft-out81.3%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{b}{d} \cdot c + \left(-a\right)\right)} \]
      6. *-commutative81.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1 \cdot 10^{+93}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -7.5 \cdot 10^{-100}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7.5 \cdot 10^{-143}:\\ \;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\ \mathbf{elif}\;c \leq 3 \cdot 10^{+81}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 71.5% accurate, 0.6× speedup?

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

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

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

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

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


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

    1. Initial program 40.0%

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

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

    if -8.1999999999999998e86 < c < -5.99999999999999999e-79

    1. Initial program 92.9%

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

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

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

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

    if -5.99999999999999999e-79 < c < 4.50000000000000007e80

    1. Initial program 67.5%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg72.6%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. associate-/l*72.7%

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
      5. associate-/r/69.0%

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

      \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c - \frac{a}{d}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity69.0%

        \[\leadsto \frac{\color{blue}{1 \cdot b}}{{d}^{2}} \cdot c - \frac{a}{d} \]
      2. unpow269.0%

        \[\leadsto \frac{1 \cdot b}{\color{blue}{d \cdot d}} \cdot c - \frac{a}{d} \]
      3. times-frac72.6%

        \[\leadsto \color{blue}{\left(\frac{1}{d} \cdot \frac{b}{d}\right)} \cdot c - \frac{a}{d} \]
    7. Applied egg-rr72.6%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{d}, \frac{b}{d} \cdot c, -\frac{a}{d}\right)} \]
    10. Step-by-step derivation
      1. fma-udef77.1%

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

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

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \left(-\color{blue}{\frac{1}{d} \cdot a}\right) \]
      4. distribute-rgt-neg-in76.9%

        \[\leadsto \frac{1}{d} \cdot \left(\frac{b}{d} \cdot c\right) + \color{blue}{\frac{1}{d} \cdot \left(-a\right)} \]
      5. distribute-lft-out76.9%

        \[\leadsto \color{blue}{\frac{1}{d} \cdot \left(\frac{b}{d} \cdot c + \left(-a\right)\right)} \]
      6. *-commutative76.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.2 \cdot 10^{+86}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-79}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{+80}:\\ \;\;\;\;\frac{1}{d} \cdot \left(c \cdot \frac{b}{d} - a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 70.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.9 \cdot 10^{-21} \lor \neg \left(d \leq 1.45 \cdot 10^{-34}\right):\\
\;\;\;\;c \cdot \frac{\frac{b}{d}}{d} - \frac{a}{d}\\

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


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

    1. Initial program 57.4%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg73.7%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. associate-/l*75.3%

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
      5. associate-/r/76.0%

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

      \[\leadsto \color{blue}{\frac{b}{{d}^{2}} \cdot c - \frac{a}{d}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity76.0%

        \[\leadsto \frac{\color{blue}{1 \cdot b}}{{d}^{2}} \cdot c - \frac{a}{d} \]
      2. unpow276.0%

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

        \[\leadsto \color{blue}{\left(\frac{1}{d} \cdot \frac{b}{d}\right)} \cdot c - \frac{a}{d} \]
    7. Applied egg-rr78.7%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{b}{d}}{d}} \cdot c - \frac{a}{d} \]
      2. *-lft-identity78.7%

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

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

    if -5.9000000000000003e-21 < d < 1.4500000000000001e-34

    1. Initial program 70.7%

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

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

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

Alternative 11: 63.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.2 \cdot 10^{+45} \lor \neg \left(d \leq 3.9 \cdot 10^{+58}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.20000000000000014e45 or 3.9000000000000001e58 < d

    1. Initial program 50.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified77.0%

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

    if -5.20000000000000014e45 < d < 3.9000000000000001e58

    1. Initial program 72.7%

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

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

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

Alternative 12: 42.2% 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.5%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  4. Final simplification43.6%

    \[\leadsto \frac{b}{c} \]
  5. Add Preprocessing

Developer target: 99.4% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024019 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :herbie-target
  (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))))