Complex division, imag part

Percentage Accurate: 62.4% → 95.5%
Time: 14.1s
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: 62.4% 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: 95.5% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
  6. Taylor expanded in b around 0 60.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b \cdot c}{\mathsf{fma}\left(d, d, {c}^{2}\right)} - \frac{a}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)} \cdot \sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)}}}{d}} \]
    2. *-un-lft-identity62.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.8% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\mathsf{hypot}\left(d, c\right)}{d}\\
\mathbf{if}\;c \leq -2 \cdot 10^{+138} \lor \neg \left(c \leq 7 \cdot 10^{+60}\right):\\
\;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{hypot}\left(d, c\right) \cdot t_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.0000000000000001e138 or 7.0000000000000004e60 < c

    1. Initial program 30.4%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, -a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      5. distribute-rgt-neg-in30.4%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 30.4%

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d} + {c}^{2}} - \frac{a \cdot d}{{c}^{2} + {d}^{2}} \]
      6. fma-udef30.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e138 < c < 7.0000000000000004e60

    1. Initial program 78.6%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 75.0%

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d} + {c}^{2}} - \frac{a \cdot d}{{c}^{2} + {d}^{2}} \]
      6. fma-udef75.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 87.4% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.25 \cdot 10^{+137} \lor \neg \left(c \leq 5.8 \cdot 10^{+60}\right):\\
\;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.25e137 or 5.79999999999999999e60 < c

    1. Initial program 30.4%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, -a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      5. distribute-rgt-neg-in30.4%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 30.4%

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d} + {c}^{2}} - \frac{a \cdot d}{{c}^{2} + {d}^{2}} \]
      6. fma-udef30.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.25e137 < c < 5.79999999999999999e60

    1. Initial program 78.6%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 75.0%

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d} + {c}^{2}} - \frac{a \cdot d}{{c}^{2} + {d}^{2}} \]
      6. fma-udef75.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 87.9% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\
\mathbf{if}\;c \leq -9 \cdot 10^{+88} \lor \neg \left(c \leq 1.9 \cdot 10^{+60}\right):\\
\;\;\;\;\frac{b}{c} - t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -9e88 or 1.90000000000000005e60 < c

    1. Initial program 35.5%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, -a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      5. distribute-rgt-neg-in35.5%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 35.5%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\mathsf{fma}\left(d, d, {c}^{2}\right)} - \frac{a}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)} \cdot \sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)}}}{d}} \]
      2. *-un-lft-identity34.0%

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

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

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

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

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

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

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

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

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

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

    if -9e88 < c < 1.90000000000000005e60

    1. Initial program 79.7%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 75.8%

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d} + {c}^{2}} - \frac{a \cdot d}{{c}^{2} + {d}^{2}} \]
      6. fma-udef75.8%

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

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\mathsf{fma}\left(d, d, {c}^{2}\right)} - \frac{a}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)} \cdot \sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)}}}{d}} \]
      2. *-un-lft-identity80.5%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 80.5% accurate, 0.0× speedup?

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

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

\mathbf{elif}\;c \leq -2.6 \cdot 10^{-79}:\\
\;\;\;\;\frac{c \cdot b}{t_0} - \frac{a}{\frac{t_0}{d}}\\

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

\mathbf{elif}\;c \leq 2700000000000:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -7.2e92 or 2.7e12 < c

    1. Initial program 37.3%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, -a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      5. distribute-rgt-neg-in37.3%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 37.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\mathsf{fma}\left(d, d, {c}^{2}\right)} - \frac{a}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)} \cdot \sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)}}}{d}} \]
      2. *-un-lft-identity36.0%

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

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

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

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

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

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

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

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

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

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

    if -7.2e92 < c < -2.59999999999999994e-79

    1. Initial program 83.6%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.59999999999999994e-79 < c < 1.19999999999999996e-239

    1. Initial program 78.0%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, -a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      5. distribute-rgt-neg-in78.0%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 74.7%

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d} + {c}^{2}} - \frac{a \cdot d}{{c}^{2} + {d}^{2}} \]
      6. fma-udef74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
    13. Simplified90.8%

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

    if 1.19999999999999996e-239 < c < 2.7e12

    1. Initial program 83.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
  3. Recombined 4 regimes into one program.
  4. Final simplification85.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.2 \cdot 10^{+92}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{-79}:\\ \;\;\;\;\frac{c \cdot b}{\mathsf{fma}\left(d, d, {c}^{2}\right)} - \frac{a}{\frac{\mathsf{fma}\left(d, d, {c}^{2}\right)}{d}}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-239}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2700000000000:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 79.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{b}{c} - \frac{a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\ t_2 := \frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{if}\;c \leq -2.6 \cdot 10^{+86}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.4 \cdot 10^{-79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{-236}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-49}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 6000000000:\\ \;\;\;\;t_2\\ \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) (/ a (* (hypot d c) (/ (hypot d c) d)))))
        (t_2 (- (/ b (/ (pow d 2.0) c)) (/ a d))))
   (if (<= c -2.6e+86)
     t_1
     (if (<= c -3.4e-79)
       t_0
       (if (<= c 1.4e-236)
         t_2
         (if (<= c 1.35e-49) t_0 (if (<= c 6000000000.0) t_2 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) - (a / (hypot(d, c) * (hypot(d, c) / d)));
	double t_2 = (b / (pow(d, 2.0) / c)) - (a / d);
	double tmp;
	if (c <= -2.6e+86) {
		tmp = t_1;
	} else if (c <= -3.4e-79) {
		tmp = t_0;
	} else if (c <= 1.4e-236) {
		tmp = t_2;
	} else if (c <= 1.35e-49) {
		tmp = t_0;
	} else if (c <= 6000000000.0) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
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) - (a / (Math.hypot(d, c) * (Math.hypot(d, c) / d)));
	double t_2 = (b / (Math.pow(d, 2.0) / c)) - (a / d);
	double tmp;
	if (c <= -2.6e+86) {
		tmp = t_1;
	} else if (c <= -3.4e-79) {
		tmp = t_0;
	} else if (c <= 1.4e-236) {
		tmp = t_2;
	} else if (c <= 1.35e-49) {
		tmp = t_0;
	} else if (c <= 6000000000.0) {
		tmp = t_2;
	} 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) - (a / (math.hypot(d, c) * (math.hypot(d, c) / d)))
	t_2 = (b / (math.pow(d, 2.0) / c)) - (a / d)
	tmp = 0
	if c <= -2.6e+86:
		tmp = t_1
	elif c <= -3.4e-79:
		tmp = t_0
	elif c <= 1.4e-236:
		tmp = t_2
	elif c <= 1.35e-49:
		tmp = t_0
	elif c <= 6000000000.0:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(Float64(b / c) - Float64(a / Float64(hypot(d, c) * Float64(hypot(d, c) / d))))
	t_2 = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d))
	tmp = 0.0
	if (c <= -2.6e+86)
		tmp = t_1;
	elseif (c <= -3.4e-79)
		tmp = t_0;
	elseif (c <= 1.4e-236)
		tmp = t_2;
	elseif (c <= 1.35e-49)
		tmp = t_0;
	elseif (c <= 6000000000.0)
		tmp = t_2;
	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) - (a / (hypot(d, c) * (hypot(d, c) / d)));
	t_2 = (b / ((d ^ 2.0) / c)) - (a / d);
	tmp = 0.0;
	if (c <= -2.6e+86)
		tmp = t_1;
	elseif (c <= -3.4e-79)
		tmp = t_0;
	elseif (c <= 1.4e-236)
		tmp = t_2;
	elseif (c <= 1.35e-49)
		tmp = t_0;
	elseif (c <= 6000000000.0)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] * N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.6e+86], t$95$1, If[LessEqual[c, -3.4e-79], t$95$0, If[LessEqual[c, 1.4e-236], t$95$2, If[LessEqual[c, 1.35e-49], t$95$0, If[LessEqual[c, 6000000000.0], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -3.4 \cdot 10^{-79}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 1.4 \cdot 10^{-236}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;c \leq 1.35 \cdot 10^{-49}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 6000000000:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.5999999999999998e86 or 6e9 < c

    1. Initial program 37.3%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, -a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      5. distribute-rgt-neg-in37.3%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 37.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\mathsf{fma}\left(d, d, {c}^{2}\right)} - \frac{a}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)} \cdot \sqrt{\mathsf{fma}\left(d, d, {c}^{2}\right)}}}{d}} \]
      2. *-un-lft-identity36.0%

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

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

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

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

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

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

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

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

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

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

    if -2.5999999999999998e86 < c < -3.39999999999999976e-79 or 1.39999999999999993e-236 < c < 1.35e-49

    1. Initial program 84.7%

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

    if -3.39999999999999976e-79 < c < 1.39999999999999993e-236 or 1.35e-49 < c < 6e9

    1. Initial program 77.0%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, -a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      5. distribute-rgt-neg-in77.0%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 74.0%

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d} + {c}^{2}} - \frac{a \cdot d}{{c}^{2} + {d}^{2}} \]
      6. fma-udef74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.6 \cdot 10^{+86}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\ \mathbf{elif}\;c \leq -3.4 \cdot 10^{-79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{-236}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-49}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 6000000000:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\mathsf{hypot}\left(d, c\right) \cdot \frac{\mathsf{hypot}\left(d, c\right)}{d}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 75.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -7 \cdot 10^{+142}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.9 \cdot 10^{-307}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+73}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\frac{{c}^{2}}{d}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= c -7e+142)
     (/ b c)
     (if (<= c -6e-79)
       t_0
       (if (<= c 1.9e-307)
         (- (* c (/ b (pow d 2.0))) (/ a d))
         (if (<= c 2.1e+73) t_0 (- (/ b c) (/ a (/ (pow c 2.0) d)))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -7e+142) {
		tmp = b / c;
	} else if (c <= -6e-79) {
		tmp = t_0;
	} else if (c <= 1.9e-307) {
		tmp = (c * (b / pow(d, 2.0))) - (a / d);
	} else if (c <= 2.1e+73) {
		tmp = t_0;
	} else {
		tmp = (b / c) - (a / (pow(c, 2.0) / 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) :: t_0
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    if (c <= (-7d+142)) then
        tmp = b / c
    else if (c <= (-6d-79)) then
        tmp = t_0
    else if (c <= 1.9d-307) then
        tmp = (c * (b / (d ** 2.0d0))) - (a / d)
    else if (c <= 2.1d+73) then
        tmp = t_0
    else
        tmp = (b / c) - (a / ((c ** 2.0d0) / d))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -7e+142) {
		tmp = b / c;
	} else if (c <= -6e-79) {
		tmp = t_0;
	} else if (c <= 1.9e-307) {
		tmp = (c * (b / Math.pow(d, 2.0))) - (a / d);
	} else if (c <= 2.1e+73) {
		tmp = t_0;
	} else {
		tmp = (b / c) - (a / (Math.pow(c, 2.0) / d));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -7e+142:
		tmp = b / c
	elif c <= -6e-79:
		tmp = t_0
	elif c <= 1.9e-307:
		tmp = (c * (b / math.pow(d, 2.0))) - (a / d)
	elif c <= 2.1e+73:
		tmp = t_0
	else:
		tmp = (b / c) - (a / (math.pow(c, 2.0) / d))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (c <= -7e+142)
		tmp = Float64(b / c);
	elseif (c <= -6e-79)
		tmp = t_0;
	elseif (c <= 1.9e-307)
		tmp = Float64(Float64(c * Float64(b / (d ^ 2.0))) - Float64(a / d));
	elseif (c <= 2.1e+73)
		tmp = t_0;
	else
		tmp = Float64(Float64(b / c) - Float64(a / Float64((c ^ 2.0) / d)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	tmp = 0.0;
	if (c <= -7e+142)
		tmp = b / c;
	elseif (c <= -6e-79)
		tmp = t_0;
	elseif (c <= 1.9e-307)
		tmp = (c * (b / (d ^ 2.0))) - (a / d);
	elseif (c <= 2.1e+73)
		tmp = t_0;
	else
		tmp = (b / c) - (a / ((c ^ 2.0) / d));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -7e+142], N[(b / c), $MachinePrecision], If[LessEqual[c, -6e-79], t$95$0, If[LessEqual[c, 1.9e-307], N[(N[(c * N[(b / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e+73], t$95$0, N[(N[(b / c), $MachinePrecision] - N[(a / N[(N[Power[c, 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;c \leq 2.1 \cdot 10^{+73}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -6.99999999999999995e142

    1. Initial program 27.1%

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

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

    if -6.99999999999999995e142 < c < -5.99999999999999999e-79 or 1.89999999999999993e-307 < c < 2.1000000000000001e73

    1. Initial program 80.0%

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

    if -5.99999999999999999e-79 < c < 1.89999999999999993e-307

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

    if 2.1000000000000001e73 < c

    1. Initial program 30.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7 \cdot 10^{+142}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.9 \cdot 10^{-307}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+73}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{\frac{{c}^{2}}{d}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 76.2% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -3 \cdot 10^{-79}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 9.5 \cdot 10^{-308}:\\
\;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\

\mathbf{elif}\;c \leq 3.1 \cdot 10^{+68}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.4999999999999997e94 or 3.0999999999999998e68 < c

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b \cdot c - a \cdot d}{\sqrt[3]{\color{blue}{{c}^{6}}}} \]
    6. Step-by-step derivation
      1. pow1/321.1%

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{{c}^{\left(6 \cdot 0.3333333333333333\right)}}} \]
      3. metadata-eval34.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b}{\frac{{c}^{2}}{c}} - \frac{d}{\frac{{c}^{2}}{a}}} \]
    8. Taylor expanded in c around 0 78.0%

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

    if -5.4999999999999997e94 < c < -3e-79 or 9.49999999999999963e-308 < c < 3.0999999999999998e68

    1. Initial program 81.8%

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

    if -3e-79 < c < 9.49999999999999963e-308

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.5 \cdot 10^{+94}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}\\ \mathbf{elif}\;c \leq -3 \cdot 10^{-79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{-308}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{+68}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 77.5% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -9.5 \cdot 10^{-79}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 3.2 \cdot 10^{-241}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\

\mathbf{elif}\;c \leq 9 \cdot 10^{+70}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.90000000000000012e89 or 8.9999999999999999e70 < c

    1. Initial program 34.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b \cdot c - a \cdot d}{\sqrt[3]{\color{blue}{{c}^{6}}}} \]
    6. Step-by-step derivation
      1. pow1/321.1%

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{{c}^{\left(6 \cdot 0.3333333333333333\right)}}} \]
      3. metadata-eval34.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{b}{\frac{{c}^{2}}{c}} - \frac{d}{\frac{{c}^{2}}{a}}} \]
    8. Taylor expanded in c around 0 78.0%

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

    if -1.90000000000000012e89 < c < -9.4999999999999997e-79 or 3.2e-241 < c < 8.9999999999999999e70

    1. Initial program 81.2%

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

    if -9.4999999999999997e-79 < c < 3.2e-241

    1. Initial program 78.0%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, -a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      5. distribute-rgt-neg-in78.0%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, b, a \cdot \left(-d\right)\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in b around 0 74.7%

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

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

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

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

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

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d} + {c}^{2}} - \frac{a \cdot d}{{c}^{2} + {d}^{2}} \]
      6. fma-udef74.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
    13. Simplified90.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.9 \cdot 10^{+89}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}\\ \mathbf{elif}\;c \leq -9.5 \cdot 10^{-79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-241}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{+70}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 75.5% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -2.6 \cdot 10^{-79}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 6.8 \cdot 10^{+132}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -5.2000000000000002e138 or 6.80000000000000051e132 < c

    1. Initial program 25.3%

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

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

    if -5.2000000000000002e138 < c < -2.59999999999999994e-79 or 1.7500000000000001e-307 < c < 6.80000000000000051e132

    1. Initial program 80.0%

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

    if -2.59999999999999994e-79 < c < 1.7500000000000001e-307

    1. Initial program 76.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.2 \cdot 10^{+138}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{-79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{-307}:\\ \;\;\;\;c \cdot \frac{b}{{d}^{2}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{+132}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 73.3% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;c \leq -2.6 \cdot 10^{-79}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.1 \cdot 10^{+132}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -4.80000000000000016e139 or 1.09999999999999994e132 < c

    1. Initial program 25.3%

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

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

    if -4.80000000000000016e139 < c < -2.59999999999999994e-79 or -1.75e-218 < c < 1.09999999999999994e132

    1. Initial program 80.2%

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

    if -2.59999999999999994e-79 < c < -1.75e-218

    1. Initial program 72.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.8 \cdot 10^{+139}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{-79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq -1.75 \cdot 10^{-218}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{+132}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 64.0% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;c \leq 180000:\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.6999999999999999e50 or 1.8e5 < c

    1. Initial program 39.8%

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

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

    if -1.6999999999999999e50 < c < -9.20000000000000047e-79

    1. Initial program 89.8%

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

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

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\sqrt[3]{{\color{blue}{\left(\mathsf{fma}\left(c, c, d \cdot d\right)\right)}}^{3}}} \]
      4. add-sqr-sqrt64.7%

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

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

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

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

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

      \[\leadsto \frac{b \cdot c - a \cdot d}{\sqrt[3]{\color{blue}{{c}^{6}}}} \]
    6. Step-by-step derivation
      1. pow1/346.0%

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{{c}^{\left(6 \cdot 0.3333333333333333\right)}}} \]
      3. metadata-eval62.3%

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c}} \]
    7. Applied egg-rr62.3%

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

    if -9.20000000000000047e-79 < c < 1.8e5

    1. Initial program 80.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.7 \cdot 10^{+50}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -9.2 \cdot 10^{-79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c}\\ \mathbf{elif}\;c \leq 180000:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 64.5% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.7 \cdot 10^{-6} \lor \neg \left(c \leq 13000\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -3.7000000000000002e-6 or 13000 < c

    1. Initial program 45.5%

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

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

    if -3.7000000000000002e-6 < c < 13000

    1. Initial program 80.9%

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

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

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

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

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

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

Alternative 14: 42.5% 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 62.9%

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

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

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

Developer target: 99.2% 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 2024021 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

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

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