Complex division, imag part

Percentage Accurate: 61.0% → 96.6%
Time: 12.0s
Alternatives: 14
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 14 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.0% 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: 96.6% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
    11. associate-/l*79.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) \]
    12. fma-define79.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}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
    13. add-sqr-sqrt79.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{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\right) \]
    14. pow279.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{\mathsf{fma}\left(c, c, d \cdot d\right)}\right)}^{2}}}\right) \]
  4. Applied egg-rr79.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)} \]
  5. Step-by-step derivation
    1. *-un-lft-identity79.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 91.1% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.2 \cdot 10^{+24} \lor \neg \left(a \leq 1.5 \cdot 10^{-93}\right):\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(d, c\right)}{c \cdot \frac{b}{a} - d}} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -3.1999999999999997e24 or 1.5000000000000001e-93 < a

    1. Initial program 56.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.1999999999999997e24 < a < 1.5000000000000001e-93

    1. Initial program 73.1%

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
      11. associate-/l*90.9%

        \[\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) \]
      12. fma-define90.9%

        \[\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}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt90.9%

        \[\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{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\right) \]
      14. pow290.9%

        \[\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{\mathsf{fma}\left(c, c, d \cdot d\right)}\right)}^{2}}}\right) \]
    4. Applied egg-rr90.9%

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

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

Alternative 3: 81.7% accurate, 0.1× speedup?

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

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

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

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

\mathbf{elif}\;c \leq 4.6 \cdot 10^{+106}:\\
\;\;\;\;\left(c \cdot \frac{b}{a} - d\right) \cdot \frac{\frac{a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -4.00000000000000019e57 or 4.6000000000000004e106 < c

    1. Initial program 42.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000019e57 < c < -5.40000000000000005e-117

    1. Initial program 88.9%

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

    if -5.40000000000000005e-117 < c < 1.25e-28

    1. Initial program 73.9%

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
      11. associate-/l*69.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) \]
      12. fma-define69.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}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt69.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{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\right) \]
      14. pow269.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{\mathsf{fma}\left(c, c, d \cdot d\right)}\right)}^{2}}}\right) \]
    4. Applied egg-rr69.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 92.9%

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

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

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

    if 1.25e-28 < c < 4.6000000000000004e106

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4 \cdot 10^{+57}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -5.4 \cdot 10^{-117}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.25 \cdot 10^{-28}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 4.6 \cdot 10^{+106}:\\ \;\;\;\;\left(c \cdot \frac{b}{a} - d\right) \cdot \frac{\frac{a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 80.8% accurate, 0.1× speedup?

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

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

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

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

\mathbf{elif}\;c \leq 7.5 \cdot 10^{+102}:\\
\;\;\;\;\left(c \cdot \frac{b}{a} - d\right) \cdot \left(a \cdot {\left(\mathsf{hypot}\left(d, c\right)\right)}^{-2}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -4.5999999999999998e57 or 7.5e102 < c

    1. Initial program 42.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.5999999999999998e57 < c < -4.1999999999999998e-116

    1. Initial program 88.9%

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

    if -4.1999999999999998e-116 < c < 8.9999999999999996e-28

    1. Initial program 73.9%

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
      11. associate-/l*69.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) \]
      12. fma-define69.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}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt69.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{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\right) \]
      14. pow269.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{\mathsf{fma}\left(c, c, d \cdot d\right)}\right)}^{2}}}\right) \]
    4. Applied egg-rr69.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 92.9%

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

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

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

    if 8.9999999999999996e-28 < c < 7.5e102

    1. Initial program 76.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.6 \cdot 10^{+57}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -4.2 \cdot 10^{-116}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-28}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 7.5 \cdot 10^{+102}:\\ \;\;\;\;\left(c \cdot \frac{b}{a} - d\right) \cdot \left(a \cdot {\left(\mathsf{hypot}\left(d, c\right)\right)}^{-2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 89.5% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.1 \cdot 10^{-76} \lor \neg \left(a \leq 2.65 \cdot 10^{-123}\right):\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(d, c\right)}{c \cdot \frac{b}{a} - d}} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -3.0999999999999997e-76 or 2.64999999999999985e-123 < a

    1. Initial program 55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.0999999999999997e-76 < a < 2.64999999999999985e-123

    1. Initial program 80.2%

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

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

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

      \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt54.5%

        \[\leadsto \color{blue}{\sqrt{\frac{c \cdot b}{c \cdot c + d \cdot d}} \cdot \sqrt{\frac{c \cdot b}{c \cdot c + d \cdot d}}} \]
      2. sqrt-div40.0%

        \[\leadsto \color{blue}{\frac{\sqrt{c \cdot b}}{\sqrt{c \cdot c + d \cdot d}}} \cdot \sqrt{\frac{c \cdot b}{c \cdot c + d \cdot d}} \]
      3. +-commutative40.0%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 84.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -8200000000:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+77}:\\ \;\;\;\;\frac{a}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{\frac{c \cdot b}{a} - d}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -8200000000.0)
   (* (/ c (hypot d c)) (/ b (hypot d c)))
   (if (<= c 2.6e+77)
     (* (/ a (hypot d c)) (/ (- (/ (* c b) a) d) (hypot d c)))
     (/ (- b (* a (/ d c))) c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -8200000000.0) {
		tmp = (c / hypot(d, c)) * (b / hypot(d, c));
	} else if (c <= 2.6e+77) {
		tmp = (a / hypot(d, c)) * ((((c * b) / a) - d) / hypot(d, c));
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -8200000000.0) {
		tmp = (c / Math.hypot(d, c)) * (b / Math.hypot(d, c));
	} else if (c <= 2.6e+77) {
		tmp = (a / Math.hypot(d, c)) * ((((c * b) / a) - d) / Math.hypot(d, c));
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -8200000000.0:
		tmp = (c / math.hypot(d, c)) * (b / math.hypot(d, c))
	elif c <= 2.6e+77:
		tmp = (a / math.hypot(d, c)) * ((((c * b) / a) - d) / math.hypot(d, c))
	else:
		tmp = (b - (a * (d / c))) / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -8200000000.0)
		tmp = Float64(Float64(c / hypot(d, c)) * Float64(b / hypot(d, c)));
	elseif (c <= 2.6e+77)
		tmp = Float64(Float64(a / hypot(d, c)) * Float64(Float64(Float64(Float64(c * b) / a) - d) / hypot(d, c)));
	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 (c <= -8200000000.0)
		tmp = (c / hypot(d, c)) * (b / hypot(d, c));
	elseif (c <= 2.6e+77)
		tmp = (a / hypot(d, c)) * ((((c * b) / a) - d) / hypot(d, c));
	else
		tmp = (b - (a * (d / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -8200000000.0], N[(N[(c / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.6e+77], N[(N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(c * b), $MachinePrecision] / a), $MachinePrecision] - d), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -8200000000:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\

\mathbf{elif}\;c \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{\frac{c \cdot b}{a} - d}{\mathsf{hypot}\left(d, c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -8.2e9

    1. Initial program 49.7%

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

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

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

      \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt34.3%

        \[\leadsto \color{blue}{\sqrt{\frac{c \cdot b}{c \cdot c + d \cdot d}} \cdot \sqrt{\frac{c \cdot b}{c \cdot c + d \cdot d}}} \]
      2. sqrt-div24.6%

        \[\leadsto \color{blue}{\frac{\sqrt{c \cdot b}}{\sqrt{c \cdot c + d \cdot d}}} \cdot \sqrt{\frac{c \cdot b}{c \cdot c + d \cdot d}} \]
      3. +-commutative24.6%

        \[\leadsto \frac{\sqrt{c \cdot b}}{\sqrt{\color{blue}{d \cdot d + c \cdot c}}} \cdot \sqrt{\frac{c \cdot b}{c \cdot c + d \cdot d}} \]
      4. hypot-undefine24.6%

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

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

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

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

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

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

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

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

    if -8.2e9 < c < 2.6000000000000002e77

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.6000000000000002e77 < c

    1. Initial program 48.5%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. unsub-neg80.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      14. remove-double-neg80.2%

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

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

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

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

Alternative 7: 83.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{if}\;d \leq -6.2 \cdot 10^{+119}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -1.8 \cdot 10^{-159}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 9.4 \cdot 10^{-150}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+147}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (fma c c (* d d)))))
   (if (<= d -6.2e+119)
     (/ (fma c (/ b d) (- a)) d)
     (if (<= d -1.8e-159)
       t_0
       (if (<= d 9.4e-150)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 6e+147) t_0 (/ (- (* b (/ c d)) a) d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / fma(c, c, (d * d));
	double tmp;
	if (d <= -6.2e+119) {
		tmp = fma(c, (b / d), -a) / d;
	} else if (d <= -1.8e-159) {
		tmp = t_0;
	} else if (d <= 9.4e-150) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 6e+147) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / d;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(c, c, Float64(d * d)))
	tmp = 0.0
	if (d <= -6.2e+119)
		tmp = Float64(fma(c, Float64(b / d), Float64(-a)) / d);
	elseif (d <= -1.8e-159)
		tmp = t_0;
	elseif (d <= 9.4e-150)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 6e+147)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / 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[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.2e+119], N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.8e-159], t$95$0, If[LessEqual[d, 9.4e-150], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 6e+147], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.8 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 6 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.1999999999999999e119 < d < -1.80000000000000011e-159 or 9.3999999999999998e-150 < d < 5.99999999999999987e147

    1. Initial program 83.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fma-define83.9%

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

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

    if -1.80000000000000011e-159 < d < 9.3999999999999998e-150

    1. Initial program 57.5%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. unsub-neg96.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      12. remove-double-neg96.4%

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

        \[\leadsto \frac{b + \color{blue}{\frac{-1 \cdot \left(a \cdot d\right)}{c}}}{c} \]
      14. associate-*r*96.4%

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

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

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

    if 5.99999999999999987e147 < d

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.2 \cdot 10^{+119}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -1.8 \cdot 10^{-159}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;d \leq 9.4 \cdot 10^{-150}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+147}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 83.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -5.8 \cdot 10^{+119}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -1.3 \cdot 10^{-158}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-147}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+147}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -5.8e+119)
     (/ (fma c (/ b d) (- a)) d)
     (if (<= d -1.3e-158)
       t_0
       (if (<= d 1.05e-147)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 6e+147) t_0 (/ (- (* b (/ c d)) a) 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 (d <= -5.8e+119) {
		tmp = fma(c, (b / d), -a) / d;
	} else if (d <= -1.3e-158) {
		tmp = t_0;
	} else if (d <= 1.05e-147) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 6e+147) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / 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 (d <= -5.8e+119)
		tmp = Float64(fma(c, Float64(b / d), Float64(-a)) / d);
	elseif (d <= -1.3e-158)
		tmp = t_0;
	elseif (d <= 1.05e-147)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 6e+147)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d);
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.8e+119], N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.3e-158], t$95$0, If[LessEqual[d, 1.05e-147], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 6e+147], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.3 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 6 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.80000000000000014e119 < d < -1.3e-158 or 1.05e-147 < d < 5.99999999999999987e147

    1. Initial program 83.9%

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

    if -1.3e-158 < d < 1.05e-147

    1. Initial program 57.5%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. unsub-neg96.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      12. remove-double-neg96.4%

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

        \[\leadsto \frac{b + \color{blue}{\frac{-1 \cdot \left(a \cdot d\right)}{c}}}{c} \]
      14. associate-*r*96.4%

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

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

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

    if 5.99999999999999987e147 < d

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.8 \cdot 10^{+119}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -1.3 \cdot 10^{-158}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-147}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+147}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 83.1% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;d \leq -1.45 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 6.8 \cdot 10^{+149}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.1999999999999999e119 or 6.7999999999999997e149 < d

    1. Initial program 34.0%

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

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

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

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

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

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

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

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

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

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

    if -6.1999999999999999e119 < d < -1.44999999999999995e-159 or 1.75e-149 < d < 6.7999999999999997e149

    1. Initial program 83.9%

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

    if -1.44999999999999995e-159 < d < 1.75e-149

    1. Initial program 57.5%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. unsub-neg96.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      12. remove-double-neg96.4%

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

        \[\leadsto \frac{b + \color{blue}{\frac{-1 \cdot \left(a \cdot d\right)}{c}}}{c} \]
      14. associate-*r*96.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.2 \cdot 10^{+119}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.45 \cdot 10^{-159}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-149}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 6.8 \cdot 10^{+149}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 72.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -8.1 \cdot 10^{+132} \lor \neg \left(d \leq -5.5 \cdot 10^{+107}\right) \land \left(d \leq -8.6 \cdot 10^{+18} \lor \neg \left(d \leq 9.8 \cdot 10^{-17}\right)\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 -8.1e+132)
         (and (not (<= d -5.5e+107))
              (or (<= d -8.6e+18) (not (<= d 9.8e-17)))))
   (/ a (- d))
   (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -8.1e+132) || (!(d <= -5.5e+107) && ((d <= -8.6e+18) || !(d <= 9.8e-17)))) {
		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 <= (-8.1d+132)) .or. (.not. (d <= (-5.5d+107))) .and. (d <= (-8.6d+18)) .or. (.not. (d <= 9.8d-17))) 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 <= -8.1e+132) || (!(d <= -5.5e+107) && ((d <= -8.6e+18) || !(d <= 9.8e-17)))) {
		tmp = a / -d;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -8.1e+132) or (not (d <= -5.5e+107) and ((d <= -8.6e+18) or not (d <= 9.8e-17))):
		tmp = a / -d
	else:
		tmp = (b - (a * (d / c))) / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -8.1e+132) || (!(d <= -5.5e+107) && ((d <= -8.6e+18) || !(d <= 9.8e-17))))
		tmp = Float64(a / Float64(-d));
	else
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((d <= -8.1e+132) || (~((d <= -5.5e+107)) && ((d <= -8.6e+18) || ~((d <= 9.8e-17)))))
		tmp = a / -d;
	else
		tmp = (b - (a * (d / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.1e+132], And[N[Not[LessEqual[d, -5.5e+107]], $MachinePrecision], Or[LessEqual[d, -8.6e+18], N[Not[LessEqual[d, 9.8e-17]], $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 -8.1 \cdot 10^{+132} \lor \neg \left(d \leq -5.5 \cdot 10^{+107}\right) \land \left(d \leq -8.6 \cdot 10^{+18} \lor \neg \left(d \leq 9.8 \cdot 10^{-17}\right)\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 < -8.09999999999999988e132 or -5.5000000000000003e107 < d < -8.6e18 or 9.80000000000000024e-17 < d

    1. Initial program 56.8%

      \[\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}} \]

    if -8.09999999999999988e132 < d < -5.5000000000000003e107 or -8.6e18 < d < 9.80000000000000024e-17

    1. Initial program 71.1%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. unsub-neg80.0%

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

        \[\leadsto \frac{b + \color{blue}{-1 \cdot \frac{a \cdot d}{c}}}{c} \]
      5. remove-double-neg80.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8.1 \cdot 10^{+132} \lor \neg \left(d \leq -5.5 \cdot 10^{+107}\right) \land \left(d \leq -8.6 \cdot 10^{+18} \lor \neg \left(d \leq 9.8 \cdot 10^{-17}\right)\right):\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 76.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -8.5 \cdot 10^{-84} \lor \neg \left(c \leq 28000000\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -8.4999999999999994e-84 or 2.8e7 < c

    1. Initial program 56.7%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. unsub-neg73.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      14. remove-double-neg73.2%

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

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

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

    if -8.4999999999999994e-84 < c < 2.8e7

    1. Initial program 75.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 76.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -8.5 \cdot 10^{-84} \lor \neg \left(c \leq 48000000000000\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -8.4999999999999994e-84 or 4.8e13 < c

    1. Initial program 56.7%

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

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

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

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      3. unsub-neg73.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) - \frac{a \cdot d}{c}}{c} \]
      14. remove-double-neg73.2%

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

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

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

    if -8.4999999999999994e-84 < c < 4.8e13

    1. Initial program 75.4%

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

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

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

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

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

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

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

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

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

        \[\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) \]
      11. associate-/l*71.4%

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

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

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

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

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

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

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

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

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

Alternative 13: 64.3% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -0.000225 \lor \neg \left(c \leq 6.6 \cdot 10^{+47}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.2499999999999999e-4 or 6.5999999999999998e47 < c

    1. Initial program 51.1%

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

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

    if -2.2499999999999999e-4 < c < 6.5999999999999998e47

    1. Initial program 76.4%

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

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

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

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

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

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

Alternative 14: 43.3% 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 64.5%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  4. Final simplification40.5%

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

Developer target: 99.4% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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