Complex division, imag part

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

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

Initial Program: 61.3% accurate, 1.0× speedup?

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

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

Alternative 1: 87.5% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq -5 \cdot 10^{-109}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_1, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \cdot \left(-a\right)\right)\\

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

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


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

    1. Initial program 40.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.7499999999999999e28 < d < -5.0000000000000002e-109

    1. Initial program 82.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000000002e-109 < d < 2.45000000000000002e-147

    1. Initial program 70.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right) - \frac{a \cdot d}{c}}}{c} \]
      8. neg-mul-195.3%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right)} - \frac{a \cdot d}{c}}{c} \]
      9. mul-1-neg95.3%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      10. remove-double-neg95.3%

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

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

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    6. Taylor expanded in a around 0 95.3%

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

    if 2.45000000000000002e-147 < d

    1. Initial program 47.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.8% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;d \leq -3.5 \cdot 10^{-228}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\

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

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


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

    1. Initial program 36.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.5000000000000003e42 < d < -3.49999999999999975e-228

    1. Initial program 76.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-identity76.9%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt76.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-frac76.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-define76.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. fma-neg76.9%

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

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

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

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

    if -3.49999999999999975e-228 < d < 1.54999999999999992e-151

    1. Initial program 71.5%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right) - \frac{a \cdot d}{c}}}{c} \]
      8. neg-mul-198.0%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right)} - \frac{a \cdot d}{c}}{c} \]
      9. mul-1-neg98.0%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      10. remove-double-neg98.0%

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

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

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    6. Taylor expanded in a around 0 98.0%

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

    if 1.54999999999999992e-151 < d

    1. Initial program 47.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 86.3% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.7 \cdot 10^{+94}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\ \mathbf{elif}\;d \leq -1.66 \cdot 10^{-40} \lor \neg \left(d \leq 1.12 \cdot 10^{-153}\right):\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{d}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -2.7e+94)
   (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d))
   (if (or (<= d -1.66e-40) (not (<= d 1.12e-153)))
     (* (/ (- (/ (* c b) d) a) (hypot d c)) (/ d (hypot d c)))
     (/ (- b (/ (* d a) c)) c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -2.7e+94) {
		tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
	} else if ((d <= -1.66e-40) || !(d <= 1.12e-153)) {
		tmp = ((((c * b) / d) - a) / hypot(d, c)) * (d / hypot(d, c));
	} else {
		tmp = (b - ((d * a) / c)) / c;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -2.7e+94)
		tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d));
	elseif ((d <= -1.66e-40) || !(d <= 1.12e-153))
		tmp = Float64(Float64(Float64(Float64(Float64(c * b) / d) - a) / hypot(d, c)) * Float64(d / hypot(d, c)));
	else
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.7e+94], 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], If[Or[LessEqual[d, -1.66e-40], N[Not[LessEqual[d, 1.12e-153]], $MachinePrecision]], N[(N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.66 \cdot 10^{-40} \lor \neg \left(d \leq 1.12 \cdot 10^{-153}\right):\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{d}{\mathsf{hypot}\left(d, c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.7000000000000001e94

    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. div-sub32.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.7000000000000001e94 < d < -1.6600000000000001e-40 or 1.12000000000000005e-153 < d

    1. Initial program 53.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6600000000000001e-40 < d < 1.12000000000000005e-153

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right) - \frac{a \cdot d}{c}}}{c} \]
      8. neg-mul-193.9%

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      10. remove-double-neg93.9%

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

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

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    6. Taylor expanded in a around 0 93.9%

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

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

Alternative 4: 86.0% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.6600000000000001e-40 or 3.19999999999999979e-147 < d

    1. Initial program 49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6600000000000001e-40 < d < 3.19999999999999979e-147

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right) - \frac{a \cdot d}{c}}}{c} \]
      8. neg-mul-193.9%

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      10. remove-double-neg93.9%

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

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

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    6. Taylor expanded in a around 0 93.9%

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

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

Alternative 5: 76.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.9 \cdot 10^{-8} \lor \neg \left(d \leq 4.6 \cdot 10^{-79}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -4.9000000000000002e-8 or 4.60000000000000023e-79 < d

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      5. associate-/r*75.0%

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-sub74.9%

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

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

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

    if -4.9000000000000002e-8 < d < 4.60000000000000023e-79

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right) - \frac{a \cdot d}{c}}}{c} \]
      8. neg-mul-186.6%

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      10. remove-double-neg86.6%

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

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

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    6. Taylor expanded in a around 0 86.6%

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

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

Alternative 6: 69.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -0.00335 \lor \neg \left(d \leq 5 \cdot 10^{-79}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -0.00335000000000000011 or 4.99999999999999999e-79 < d

    1. Initial program 43.1%

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

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

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

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

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

    if -0.00335000000000000011 < d < 4.99999999999999999e-79

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right) - \frac{a \cdot d}{c}}}{c} \]
      8. neg-mul-186.6%

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      10. remove-double-neg86.6%

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

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

      \[\leadsto \color{blue}{\frac{b - a \cdot \frac{d}{c}}{c}} \]
    6. Taylor expanded in a around 0 86.6%

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

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

Alternative 7: 69.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -0.125 \lor \neg \left(d \leq 5 \cdot 10^{-79}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -0.125 or 4.99999999999999999e-79 < d

    1. Initial program 43.1%

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

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

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

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

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

    if -0.125 < d < 4.99999999999999999e-79

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right) - \frac{a \cdot d}{c}}}{c} \]
      8. neg-mul-186.6%

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      10. remove-double-neg86.6%

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

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

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

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

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

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

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

Alternative 8: 69.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -0.135 \lor \neg \left(d \leq 4.9 \cdot 10^{-80}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -0.13500000000000001 or 4.8999999999999999e-80 < d

    1. Initial program 43.1%

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

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

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

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

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

    if -0.13500000000000001 < d < 4.8999999999999999e-80

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right) - \frac{a \cdot d}{c}}}{c} \]
      8. neg-mul-186.6%

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      10. remove-double-neg86.6%

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

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

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

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

Alternative 9: 63.1% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.4 \cdot 10^{-59} \lor \neg \left(c \leq 3.5 \cdot 10^{-26}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -6.3999999999999998e-59 or 3.49999999999999985e-26 < c

    1. Initial program 47.4%

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

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

    if -6.3999999999999998e-59 < c < 3.49999999999999985e-26

    1. Initial program 70.7%

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

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

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

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

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

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

Alternative 10: 42.4% accurate, 5.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  4. 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 2024083 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))

  (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))