Complex division, imag part

Percentage Accurate: 61.5% → 98.3%
Time: 13.7s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 61.5% accurate, 1.0× speedup?

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

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

Alternative 1: 98.3% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

    \[\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)}} \]
  5. Step-by-step derivation
    1. div-sub77.6%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 89.0% 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 5 \cdot 10^{+280}:\\ \;\;\;\;\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))) 5e+280)
     (* (/ 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))) <= 5e+280) {
		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))) <= 5e+280)
		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], 5e+280], 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 5 \cdot 10^{+280}:\\
\;\;\;\;\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))) < 5.0000000000000002e280

    1. Initial program 76.2%

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

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

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

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

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

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

      \[\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 5.0000000000000002e280 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 13.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+280}:\\ \;\;\;\;\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: 87.0% 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 4 \cdot 10^{+263}:\\ \;\;\;\;t\_0 \cdot \frac{t\_1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - a\right)\\ \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))) 4e+263)
     (* t_0 (/ t_1 (hypot c d)))
     (* t_0 (- (* (/ c (hypot c d)) b) a)))))
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))) <= 4e+263) {
		tmp = t_0 * (t_1 / hypot(c, d));
	} else {
		tmp = t_0 * (((c / hypot(c, d)) * b) - a);
	}
	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))) <= 4e+263) {
		tmp = t_0 * (t_1 / Math.hypot(c, d));
	} else {
		tmp = t_0 * (((c / Math.hypot(c, d)) * b) - a);
	}
	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))) <= 4e+263:
		tmp = t_0 * (t_1 / math.hypot(c, d))
	else:
		tmp = t_0 * (((c / math.hypot(c, d)) * b) - a)
	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))) <= 4e+263)
		tmp = Float64(t_0 * Float64(t_1 / hypot(c, d)));
	else
		tmp = Float64(t_0 * Float64(Float64(Float64(c / hypot(c, d)) * b) - a));
	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))) <= 4e+263)
		tmp = t_0 * (t_1 / hypot(c, d));
	else
		tmp = t_0 * (((c / hypot(c, d)) * b) - a);
	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], 4e+263], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] - a), $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 4 \cdot 10^{+263}:\\
\;\;\;\;t\_0 \cdot \frac{t\_1}{\mathsf{hypot}\left(c, d\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - a\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))) < 4.00000000000000006e263

    1. Initial program 76.1%

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

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

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

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

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

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

      \[\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 4.00000000000000006e263 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 14.9%

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

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

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

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

        \[\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-def21.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-rr21.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)}} \]
    5. Step-by-step derivation
      1. div-sub21.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - \color{blue}{a}\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 4 \cdot 10^{+263}:\\ \;\;\;\;\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 \left(\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - a\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 84.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;d \leq -3.45 \cdot 10^{+130}:\\ \;\;\;\;t\_0 \cdot \left(a - \frac{b}{\frac{d}{c}}\right)\\ \mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{-90}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot b - a\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ 1.0 (hypot c d))))
   (if (<= d -3.45e+130)
     (* t_0 (- a (/ b (/ d c))))
     (if (<= d -2.5e-165)
       (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
       (if (<= d 2.8e-90)
         (* (/ -1.0 c) (- (/ a (/ c d)) b))
         (* t_0 (- (* (/ c (hypot c d)) b) a)))))))
double code(double a, double b, double c, double d) {
	double t_0 = 1.0 / hypot(c, d);
	double tmp;
	if (d <= -3.45e+130) {
		tmp = t_0 * (a - (b / (d / c)));
	} else if (d <= -2.5e-165) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 2.8e-90) {
		tmp = (-1.0 / c) * ((a / (c / d)) - b);
	} else {
		tmp = t_0 * (((c / hypot(c, d)) * b) - a);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = 1.0 / Math.hypot(c, d);
	double tmp;
	if (d <= -3.45e+130) {
		tmp = t_0 * (a - (b / (d / c)));
	} else if (d <= -2.5e-165) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 2.8e-90) {
		tmp = (-1.0 / c) * ((a / (c / d)) - b);
	} else {
		tmp = t_0 * (((c / Math.hypot(c, d)) * b) - a);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = 1.0 / math.hypot(c, d)
	tmp = 0
	if d <= -3.45e+130:
		tmp = t_0 * (a - (b / (d / c)))
	elif d <= -2.5e-165:
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
	elif d <= 2.8e-90:
		tmp = (-1.0 / c) * ((a / (c / d)) - b)
	else:
		tmp = t_0 * (((c / math.hypot(c, d)) * b) - a)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(1.0 / hypot(c, d))
	tmp = 0.0
	if (d <= -3.45e+130)
		tmp = Float64(t_0 * Float64(a - Float64(b / Float64(d / c))));
	elseif (d <= -2.5e-165)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 2.8e-90)
		tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b));
	else
		tmp = Float64(t_0 * Float64(Float64(Float64(c / hypot(c, d)) * b) - a));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = 1.0 / hypot(c, d);
	tmp = 0.0;
	if (d <= -3.45e+130)
		tmp = t_0 * (a - (b / (d / c)));
	elseif (d <= -2.5e-165)
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	elseif (d <= 2.8e-90)
		tmp = (-1.0 / c) * ((a / (c / d)) - b);
	else
		tmp = t_0 * (((c / hypot(c, d)) * b) - a);
	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]}, If[LessEqual[d, -3.45e+130], N[(t$95$0 * N[(a - N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.5e-165], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e-90], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * b), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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


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

    1. Initial program 32.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-identity32.7%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt32.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-frac32.8%

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

        \[\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-def58.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-rr58.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)}} \]
    5. Taylor expanded in d around -inf 83.6%

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

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

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

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

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

    if -3.4500000000000001e130 < d < -2.4999999999999999e-165

    1. Initial program 81.7%

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

    if -2.4999999999999999e-165 < d < 2.7999999999999999e-90

    1. Initial program 73.4%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around -inf 55.2%

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

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

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

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

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

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

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

    if 2.7999999999999999e-90 < d

    1. Initial program 45.0%

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

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

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

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

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

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

      \[\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)}} \]
    5. Step-by-step derivation
      1. div-sub67.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \frac{b}{\frac{d}{c}}\\ \mathbf{if}\;d \leq -4.8 \cdot 10^{+130}:\\ \;\;\;\;t\_0 \cdot \left(a - t\_1\right)\\ \mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{+22}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(t\_1 - a\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (/ b (/ d c))))
   (if (<= d -4.8e+130)
     (* t_0 (- a t_1))
     (if (<= d -2.5e-165)
       (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
       (if (<= d 9.2e+22)
         (* (/ -1.0 c) (- (/ a (/ c d)) b))
         (* t_0 (- t_1 a)))))))
double code(double a, double b, double c, double d) {
	double t_0 = 1.0 / hypot(c, d);
	double t_1 = b / (d / c);
	double tmp;
	if (d <= -4.8e+130) {
		tmp = t_0 * (a - t_1);
	} else if (d <= -2.5e-165) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 9.2e+22) {
		tmp = (-1.0 / c) * ((a / (c / d)) - b);
	} else {
		tmp = t_0 * (t_1 - a);
	}
	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 = b / (d / c);
	double tmp;
	if (d <= -4.8e+130) {
		tmp = t_0 * (a - t_1);
	} else if (d <= -2.5e-165) {
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 9.2e+22) {
		tmp = (-1.0 / c) * ((a / (c / d)) - b);
	} else {
		tmp = t_0 * (t_1 - a);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = 1.0 / math.hypot(c, d)
	t_1 = b / (d / c)
	tmp = 0
	if d <= -4.8e+130:
		tmp = t_0 * (a - t_1)
	elif d <= -2.5e-165:
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d))
	elif d <= 9.2e+22:
		tmp = (-1.0 / c) * ((a / (c / d)) - b)
	else:
		tmp = t_0 * (t_1 - a)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(1.0 / hypot(c, d))
	t_1 = Float64(b / Float64(d / c))
	tmp = 0.0
	if (d <= -4.8e+130)
		tmp = Float64(t_0 * Float64(a - t_1));
	elseif (d <= -2.5e-165)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 9.2e+22)
		tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b));
	else
		tmp = Float64(t_0 * Float64(t_1 - a));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = 1.0 / hypot(c, d);
	t_1 = b / (d / c);
	tmp = 0.0;
	if (d <= -4.8e+130)
		tmp = t_0 * (a - t_1);
	elseif (d <= -2.5e-165)
		tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
	elseif (d <= 9.2e+22)
		tmp = (-1.0 / c) * ((a / (c / d)) - b);
	else
		tmp = t_0 * (t_1 - a);
	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[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.8e+130], N[(t$95$0 * N[(a - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.5e-165], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.2e+22], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(t$95$1 - a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 - a\right)\\


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

    1. Initial program 32.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-identity32.7%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt32.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-frac32.8%

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

        \[\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-def58.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-rr58.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)}} \]
    5. Taylor expanded in d around -inf 83.6%

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

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

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

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

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

    if -4.80000000000000048e130 < d < -2.4999999999999999e-165

    1. Initial program 81.7%

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

    if -2.4999999999999999e-165 < d < 9.2000000000000008e22

    1. Initial program 71.4%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around -inf 53.2%

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

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

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

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

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

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

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

    if 9.2000000000000008e22 < d

    1. Initial program 40.9%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around 0 71.3%

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

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

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

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

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

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

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

Alternative 6: 77.8% accurate, 0.1× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.4000000000000001e130 or 2.4000000000000001e24 < d

    1. Initial program 37.4%

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

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

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

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

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

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

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

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

    if -3.4000000000000001e130 < d < -2.4999999999999999e-165

    1. Initial program 81.7%

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

    if -2.4999999999999999e-165 < d < 2.4000000000000001e24

    1. Initial program 71.4%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around -inf 53.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.4 \cdot 10^{+130}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{+24}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 79.0% accurate, 0.1× speedup?

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

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

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

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

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


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

    1. Initial program 32.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-identity32.7%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt32.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-frac32.8%

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

        \[\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-def58.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-rr58.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)}} \]
    5. Taylor expanded in d around -inf 83.6%

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

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

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

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

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

    if -7.5000000000000003e130 < d < -2.4999999999999999e-165

    1. Initial program 81.7%

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

    if -2.4999999999999999e-165 < d < 1.6e23

    1. Initial program 71.4%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around -inf 53.2%

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

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

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

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

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

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

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

    if 1.6e23 < d

    1. Initial program 40.9%

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

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

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

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

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

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

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

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

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

Alternative 8: 76.3% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+130}:\\
\;\;\;\;\frac{-a}{d}\\

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

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

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


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

    1. Initial program 32.7%

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

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

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

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

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

    if -9.00000000000000078e130 < d < -2.4999999999999999e-165

    1. Initial program 81.7%

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

    if -2.4999999999999999e-165 < d < 2.20000000000000002e24

    1. Initial program 71.4%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around -inf 53.2%

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

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

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

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

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

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

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

    if 2.20000000000000002e24 < d

    1. Initial program 40.9%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around 0 66.3%

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

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{\mathsf{hypot}\left(c, d\right)} \]
      3. neg-sub066.4%

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

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

      \[\leadsto \color{blue}{\frac{0}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{\mathsf{hypot}\left(c, d\right)}} \]
    10. Step-by-step derivation
      1. div066.4%

        \[\leadsto \color{blue}{0} - \frac{a}{\mathsf{hypot}\left(c, d\right)} \]
      2. neg-sub066.4%

        \[\leadsto \color{blue}{-\frac{a}{\mathsf{hypot}\left(c, d\right)}} \]
      3. distribute-frac-neg66.4%

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

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

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

Alternative 9: 70.2% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{if}\;c \leq -5.7 \cdot 10^{-68}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 2.9 \cdot 10^{+18}:\\
\;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.7000000000000002e-68 or 2.9e18 < c

    1. Initial program 49.9%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around -inf 51.7%

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

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

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

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

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

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

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

    if -5.7000000000000002e-68 < c < 3.49999999999999985e-26

    1. Initial program 71.1%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified71.4%

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

    if 3.49999999999999985e-26 < c < 2.9e18

    1. Initial program 99.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.7 \cdot 10^{-68}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\ \mathbf{elif}\;c \leq 3.5 \cdot 10^{-26}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 2.9 \cdot 10^{+18}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 76.0% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.28e131 or 1.05e25 < d

    1. Initial program 37.4%

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

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

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

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

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

    if -1.28e131 < d < -2.4999999999999999e-165

    1. Initial program 81.7%

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

    if -2.4999999999999999e-165 < d < 1.05e25

    1. Initial program 71.4%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around -inf 53.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.28 \cdot 10^{+131}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -2.5 \cdot 10^{-165}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{+25}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 72.9% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -9.9999999999999993e44 or 9.5000000000000001e24 < d

    1. Initial program 44.3%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified65.3%

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

    if -9.9999999999999993e44 < d < 9.5000000000000001e24

    1. Initial program 74.9%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around -inf 48.6%

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

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

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

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

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

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

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

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

Alternative 12: 64.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2 \cdot 10^{+45} \lor \neg \left(c \leq 4.2 \cdot 10^{-28}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.9999999999999999e45 or 4.20000000000000013e-28 < c

    1. Initial program 48.6%

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

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

    if -1.9999999999999999e45 < c < 4.20000000000000013e-28

    1. Initial program 71.1%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    5. Simplified65.4%

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

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

Alternative 13: 15.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.5 \cdot 10^{+48} \lor \neg \left(d \leq 4.5 \cdot 10^{+112}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7.5000000000000006e48 or 4.4999999999999999e112 < d

    1. Initial program 39.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-identity39.7%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt39.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-frac39.8%

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around 0 36.6%

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

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

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

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

    if -7.5000000000000006e48 < d < 4.4999999999999999e112

    1. Initial program 74.5%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around -inf 45.5%

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

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{a \cdot d}{c} + \color{blue}{\left(-b\right)}\right) \]
      3. unsub-neg45.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{+48} \lor \neg \left(d \leq 4.5 \cdot 10^{+112}\right):\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 44.2% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -9 \cdot 10^{+131}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d) :precision binary64 (if (<= d -9e+131) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -9e+131) {
		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 <= (-9d+131)) 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 <= -9e+131) {
		tmp = a / d;
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -9e+131:
		tmp = a / d
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -9e+131)
		tmp = 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 <= -9e+131)
		tmp = a / d;
	else
		tmp = b / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -9e+131], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+131}:\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -9.00000000000000039e131

    1. Initial program 33.4%

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in c around 0 22.5%

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

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

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

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

    if -9.00000000000000039e131 < d

    1. Initial program 66.0%

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

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

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

Alternative 15: 9.7% accurate, 5.0× speedup?

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

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

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

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

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

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

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

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

    \[\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)}} \]
  5. Taylor expanded in c around -inf 33.1%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  9. Final simplification9.4%

    \[\leadsto \frac{a}{c} \]
  10. Add Preprocessing

Developer target: 99.3% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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