Complex division, imag part

Percentage Accurate: 61.8% → 91.0%
Time: 9.7s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 61.8% accurate, 1.0× speedup?

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

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

Alternative 1: 91.0% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.4 \cdot 10^{+129} \lor \neg \left(d \leq 4.2 \cdot 10^{+136}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(d, c\right)}, c \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}, \frac{a}{-d}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.3999999999999999e129 or 4.1999999999999998e136 < d

    1. Initial program 28.1%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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. pow237.8%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-define37.8%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-rr37.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(d, c\right)}, c \cdot \frac{b}{\color{blue}{\mathsf{hypot}\left(d, c\right)}}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right) \]
      17. distribute-rgt-neg-in43.5%

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

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

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

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

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

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

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

    if -2.3999999999999999e129 < d < 4.1999999999999998e136

    1. Initial program 69.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub68.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. *-commutative68.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-sqrt68.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-frac72.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-neg72.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-define72.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-define89.3%

        \[\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*91.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-sqrt91.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. pow291.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-define91.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-rr91.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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.3%

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

Alternative 2: 88.8% accurate, 0.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\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)}\\


\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))) < -inf.0 or 1.99999999999999981e215 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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. pow225.9%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-define25.9%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-rr25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(d, c\right)}, c \cdot \frac{b}{\color{blue}{\mathsf{hypot}\left(d, c\right)}}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right) \]
      17. distribute-rgt-neg-in57.2%

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

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

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

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

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

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

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

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

    1. Initial program 78.6%

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

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

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

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

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

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

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

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

      \[\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)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq -\infty \lor \neg \left(\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+215}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(d, c\right)}, c \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}, \frac{-a}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\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)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.9% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.05 \cdot 10^{+136}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -7.3 \cdot 10^{-78}:\\ \;\;\;\;\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.9 \cdot 10^{+49}:\\ \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -2.05e+136)
   (/ (- (* b (/ c d)) a) d)
   (if (<= d -7.3e-78)
     (* (/ 1.0 (hypot c d)) (/ (fma b c (* d (- a))) (hypot c d)))
     (if (<= d 1.9e+49) (/ (- b (* (/ d c) a)) c) (/ (- (* c (/ b d)) a) d)))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -2.05e+136) {
		tmp = ((b * (c / d)) - a) / d;
	} else if (d <= -7.3e-78) {
		tmp = (1.0 / hypot(c, d)) * (fma(b, c, (d * -a)) / hypot(c, d));
	} else if (d <= 1.9e+49) {
		tmp = (b - ((d / c) * a)) / c;
	} else {
		tmp = ((c * (b / d)) - a) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -2.05e+136)
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d);
	elseif (d <= -7.3e-78)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(d * Float64(-a))) / hypot(c, d)));
	elseif (d <= 1.9e+49)
		tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c);
	else
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.05e+136], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -7.3e-78], 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.9e+49], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -7.3 \cdot 10^{-78}:\\
\;\;\;\;\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.9 \cdot 10^{+49}:\\
\;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\

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


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

    1. Initial program 25.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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. pow235.9%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-define35.9%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-rr35.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(d, c\right)}, c \cdot \frac{b}{\color{blue}{\mathsf{hypot}\left(d, c\right)}}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right) \]
      17. distribute-rgt-neg-in41.7%

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

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

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

      \[\leadsto \color{blue}{\frac{-1 \cdot a + \frac{b \cdot c}{d}}{d}} \]
    8. Step-by-step derivation
      1. associate-*r/97.7%

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

        \[\leadsto \frac{\color{blue}{b \cdot \frac{c}{d} + -1 \cdot a}}{d} \]
      3. associate-*r/86.6%

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} + -1 \cdot a}{d} \]
      4. neg-mul-186.6%

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

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

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

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

    if -2.0499999999999999e136 < d < -7.29999999999999981e-78

    1. Initial program 67.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-identity67.0%

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

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

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

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

      \[\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 -7.29999999999999981e-78 < d < 1.8999999999999999e49

    1. Initial program 68.9%

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

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

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

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

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

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

    if 1.8999999999999999e49 < d

    1. Initial program 45.5%

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

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

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

        \[\leadsto -\frac{\color{blue}{-1 \cdot \frac{b \cdot c}{d} + a}}{d} \]
      3. remove-double-neg77.8%

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

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

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} - \color{blue}{-1 \cdot a}}{d} \]
      6. distribute-neg-frac277.8%

        \[\leadsto \color{blue}{\frac{-1 \cdot \frac{b \cdot c}{d} - -1 \cdot a}{-d}} \]
      7. cancel-sign-sub-inv77.8%

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

        \[\leadsto \frac{-1 \cdot \frac{b \cdot c}{d} + \color{blue}{1} \cdot a}{-d} \]
      9. *-lft-identity77.8%

        \[\leadsto \frac{-1 \cdot \frac{b \cdot c}{d} + \color{blue}{a}}{-d} \]
      10. +-commutative77.8%

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

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

        \[\leadsto \frac{\color{blue}{a - \frac{b \cdot c}{d}}}{-d} \]
      13. *-commutative77.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.05 \cdot 10^{+136}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -7.3 \cdot 10^{-78}:\\ \;\;\;\;\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.9 \cdot 10^{+49}:\\ \;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.8 \cdot 10^{+20} \lor \neg \left(d \leq 3 \cdot 10^{+49}\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.8e20 or 3.0000000000000002e49 < d

    1. Initial program 40.5%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-un-lft-identity40.5%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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. pow252.4%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-define52.4%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-rr52.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(d, c\right)}, c \cdot \frac{b}{\color{blue}{\mathsf{hypot}\left(d, c\right)}}, -a \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right) \]
      17. distribute-rgt-neg-in59.5%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{b \cdot \frac{c}{d} + -1 \cdot a}}{d} \]
      3. associate-*r/80.0%

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} + -1 \cdot a}{d} \]
      4. neg-mul-180.0%

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

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

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

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

    if -1.8e20 < d < 3.0000000000000002e49

    1. Initial program 69.8%

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

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

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

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

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

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

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

Alternative 5: 72.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.15 \cdot 10^{+23} \lor \neg \left(d \leq 5.8 \cdot 10^{+57}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.1499999999999999e23 or 5.8000000000000003e57 < d

    1. Initial program 40.3%

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

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

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

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

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

    if -2.1499999999999999e23 < d < 5.8000000000000003e57

    1. Initial program 69.6%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. 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 simplification80.7%

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

Alternative 6: 77.5% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 36.5%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-un-lft-identity36.5%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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. pow252.0%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-define52.0%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\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-rr52.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-1 \cdot a + \frac{b \cdot c}{d}}{d}} \]
    8. Step-by-step derivation
      1. associate-*r/89.1%

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

        \[\leadsto \frac{\color{blue}{b \cdot \frac{c}{d} + -1 \cdot a}}{d} \]
      3. associate-*r/81.6%

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} + -1 \cdot a}{d} \]
      4. neg-mul-181.6%

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

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

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

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

    if -6.8e16 < d < 1.8999999999999999e49

    1. Initial program 69.8%

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

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

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

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

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

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

    if 1.8999999999999999e49 < d

    1. Initial program 45.5%

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

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

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

        \[\leadsto -\frac{\color{blue}{-1 \cdot \frac{b \cdot c}{d} + a}}{d} \]
      3. remove-double-neg77.8%

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

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

        \[\leadsto -\frac{-1 \cdot \frac{b \cdot c}{d} - \color{blue}{-1 \cdot a}}{d} \]
      6. distribute-neg-frac277.8%

        \[\leadsto \color{blue}{\frac{-1 \cdot \frac{b \cdot c}{d} - -1 \cdot a}{-d}} \]
      7. cancel-sign-sub-inv77.8%

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

        \[\leadsto \frac{-1 \cdot \frac{b \cdot c}{d} + \color{blue}{1} \cdot a}{-d} \]
      9. *-lft-identity77.8%

        \[\leadsto \frac{-1 \cdot \frac{b \cdot c}{d} + \color{blue}{a}}{-d} \]
      10. +-commutative77.8%

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

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

        \[\leadsto \frac{\color{blue}{a - \frac{b \cdot c}{d}}}{-d} \]
      13. *-commutative77.8%

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

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

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

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

Alternative 7: 63.3% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.35 \cdot 10^{+14} \lor \neg \left(d \leq 2.5 \cdot 10^{+49}\right):\\
\;\;\;\;\frac{a}{-d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.35e14 or 2.5000000000000002e49 < d

    1. Initial program 40.5%

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

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

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

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

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

    if -2.35e14 < d < 2.5000000000000002e49

    1. Initial program 69.8%

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

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

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

Alternative 8: 43.1% 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 56.5%

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

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

Alternative 9: 10.1% 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 56.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-identity56.5%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{c \cdot c + d \cdot d} \]
    2. add-sqr-sqrt56.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-frac56.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-define56.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. fma-neg56.5%

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

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

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

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

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

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

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

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

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

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

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

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

  :alt
  (! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))

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