Complex division, imag part

Percentage Accurate: 61.5% → 96.6%
Time: 14.6s
Alternatives: 13
Speedup: 1.8×

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 13 alternatives:

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

Initial Program: 61.5% accurate, 1.0× speedup?

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

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

Alternative 1: 96.6% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;d \leq 100:\\ \;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{-a}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{\sqrt{d} \cdot \left(-\frac{a}{\mathsf{hypot}\left(c, d\right)}\right)}{\frac{\mathsf{hypot}\left(c, d\right)}{\sqrt{d}}}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ c (hypot c d))) (t_1 (/ b (hypot c d))))
   (if (<= d 100.0)
     (fma t_0 t_1 (/ (- a) (* (hypot c d) (/ (hypot c d) d))))
     (fma
      t_0
      t_1
      (/ (* (sqrt d) (- (/ a (hypot c d)))) (/ (hypot c d) (sqrt d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = c / hypot(c, d);
	double t_1 = b / hypot(c, d);
	double tmp;
	if (d <= 100.0) {
		tmp = fma(t_0, t_1, (-a / (hypot(c, d) * (hypot(c, d) / d))));
	} else {
		tmp = fma(t_0, t_1, ((sqrt(d) * -(a / hypot(c, d))) / (hypot(c, d) / sqrt(d))));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(c / hypot(c, d))
	t_1 = Float64(b / hypot(c, d))
	tmp = 0.0
	if (d <= 100.0)
		tmp = fma(t_0, t_1, Float64(Float64(-a) / Float64(hypot(c, d) * Float64(hypot(c, d) / d))));
	else
		tmp = fma(t_0, t_1, Float64(Float64(sqrt(d) * Float64(-Float64(a / hypot(c, d)))) / Float64(hypot(c, d) / sqrt(d))));
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 100.0], N[(t$95$0 * t$95$1 + N[((-a) / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] * N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$1 + N[(N[(N[Sqrt[d], $MachinePrecision] * (-N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision])), $MachinePrecision] / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / N[Sqrt[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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


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

    1. Initial program 68.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 100 < d

    1. Initial program 44.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub44.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 100:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{\sqrt{d} \cdot \left(-\frac{a}{\mathsf{hypot}\left(c, d\right)}\right)}{\frac{\mathsf{hypot}\left(c, d\right)}{\sqrt{d}}}\right)\\ \end{array} \]

Alternative 2: 96.2% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 96.0% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 84.5% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.9999999999999998e250

    1. Initial program 79.8%

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def79.8%

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

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

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

    if 1.9999999999999998e250 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 17.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      6. times-frac60.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+250}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 5: 77.5% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -80000000000000:\\
\;\;\;\;\frac{b}{c} - \frac{a \cdot \frac{d}{c}}{c}\\

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

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

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


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

    1. Initial program 50.6%

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

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

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

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

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

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

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

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

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

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

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

    if -8e13 < c < 1.99999999999999988e-278

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      6. times-frac87.3%

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

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

    if 1.99999999999999988e-278 < c < 7.19999999999999955e95

    1. Initial program 81.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{c \cdot \left(b \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\right) - a \cdot \left(d \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\right)} \]
    6. Step-by-step derivation
      1. cancel-sign-sub-inv73.6%

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

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

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

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

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

        \[\leadsto {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2} \cdot \color{blue}{\left(c \cdot b + \left(-a\right) \cdot d\right)} \]
      7. cancel-sign-sub-inv82.9%

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

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

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

    if 7.19999999999999955e95 < c

    1. Initial program 31.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -80000000000000:\\ \;\;\;\;\frac{b}{c} - \frac{a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 2 \cdot 10^{-278}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{+95}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2} \cdot \left(c \cdot b - d \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]

Alternative 6: 77.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -820000000000:\\
\;\;\;\;\frac{b}{c} - \frac{a \cdot \frac{d}{c}}{c}\\

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

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

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


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

    1. Initial program 50.6%

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

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

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

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

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

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

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

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

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

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

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

    if -8.2e11 < c < 2.10000000000000014e-278

    1. Initial program 71.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      6. times-frac87.3%

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

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

    if 2.10000000000000014e-278 < c < 6.49999999999999976e94

    1. Initial program 81.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]

    if 6.49999999999999976e94 < c

    1. Initial program 31.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -820000000000:\\ \;\;\;\;\frac{b}{c} - \frac{a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{-278}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 6.5 \cdot 10^{+94}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]

Alternative 7: 69.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \frac{b}{d \cdot d} - \frac{a}{d}\\ t_1 := \frac{b}{c + \frac{d \cdot d}{c}}\\ \mathbf{if}\;c \leq -2.7 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -8.7 \cdot 10^{-221}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.16 \cdot 10^{-206}:\\ \;\;\;\;-\frac{a}{d}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{+49}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c (/ b (* d d))) (/ a d))) (t_1 (/ b (+ c (/ (* d d) c)))))
   (if (<= c -2.7e-9)
     t_1
     (if (<= c -8.7e-221)
       t_0
       (if (<= c 1.16e-206) (- (/ a d)) (if (<= c 7.2e+49) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * (b / (d * d))) - (a / d);
	double t_1 = b / (c + ((d * d) / c));
	double tmp;
	if (c <= -2.7e-9) {
		tmp = t_1;
	} else if (c <= -8.7e-221) {
		tmp = t_0;
	} else if (c <= 1.16e-206) {
		tmp = -(a / d);
	} else if (c <= 7.2e+49) {
		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 * d))) - (a / d)
    t_1 = b / (c + ((d * d) / c))
    if (c <= (-2.7d-9)) then
        tmp = t_1
    else if (c <= (-8.7d-221)) then
        tmp = t_0
    else if (c <= 1.16d-206) then
        tmp = -(a / d)
    else if (c <= 7.2d+49) 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 * d))) - (a / d);
	double t_1 = b / (c + ((d * d) / c));
	double tmp;
	if (c <= -2.7e-9) {
		tmp = t_1;
	} else if (c <= -8.7e-221) {
		tmp = t_0;
	} else if (c <= 1.16e-206) {
		tmp = -(a / d);
	} else if (c <= 7.2e+49) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * (b / (d * d))) - (a / d)
	t_1 = b / (c + ((d * d) / c))
	tmp = 0
	if c <= -2.7e-9:
		tmp = t_1
	elif c <= -8.7e-221:
		tmp = t_0
	elif c <= 1.16e-206:
		tmp = -(a / d)
	elif c <= 7.2e+49:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * Float64(b / Float64(d * d))) - Float64(a / d))
	t_1 = Float64(b / Float64(c + Float64(Float64(d * d) / c)))
	tmp = 0.0
	if (c <= -2.7e-9)
		tmp = t_1;
	elseif (c <= -8.7e-221)
		tmp = t_0;
	elseif (c <= 1.16e-206)
		tmp = Float64(-Float64(a / d));
	elseif (c <= 7.2e+49)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * (b / (d * d))) - (a / d);
	t_1 = b / (c + ((d * d) / c));
	tmp = 0.0;
	if (c <= -2.7e-9)
		tmp = t_1;
	elseif (c <= -8.7e-221)
		tmp = t_0;
	elseif (c <= 1.16e-206)
		tmp = -(a / d);
	elseif (c <= 7.2e+49)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[(c + N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.7e-9], t$95$1, If[LessEqual[c, -8.7e-221], t$95$0, If[LessEqual[c, 1.16e-206], (-N[(a / d), $MachinePrecision]), If[LessEqual[c, 7.2e+49], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -8.7 \cdot 10^{-221}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 7.2 \cdot 10^{+49}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.7000000000000002e-9 or 7.19999999999999993e49 < c

    1. Initial program 48.8%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
    3. Step-by-step derivation
      1. associate-/l*50.7%

        \[\leadsto \color{blue}{\frac{b}{\frac{{c}^{2} + {d}^{2}}{c}}} \]
      2. unpow250.7%

        \[\leadsto \frac{b}{\frac{\color{blue}{c \cdot c} + {d}^{2}}{c}} \]
      3. unpow250.7%

        \[\leadsto \frac{b}{\frac{c \cdot c + \color{blue}{d \cdot d}}{c}} \]
      4. +-commutative50.7%

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

        \[\leadsto \frac{b}{\frac{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}{c}} \]
    4. Simplified50.6%

      \[\leadsto \color{blue}{\frac{b}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{c}}} \]
    5. Taylor expanded in d around 0 72.2%

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

        \[\leadsto \frac{b}{c + \frac{\color{blue}{d \cdot d}}{c}} \]
    7. Simplified72.2%

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

    if -2.7000000000000002e-9 < c < -8.7000000000000003e-221 or 1.16000000000000004e-206 < c < 7.19999999999999993e49

    1. Initial program 77.2%

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

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

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

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

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

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

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

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

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

    if -8.7000000000000003e-221 < c < 1.16000000000000004e-206

    1. Initial program 70.9%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified83.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.7 \cdot 10^{-9}:\\ \;\;\;\;\frac{b}{c + \frac{d \cdot d}{c}}\\ \mathbf{elif}\;c \leq -8.7 \cdot 10^{-221}:\\ \;\;\;\;c \cdot \frac{b}{d \cdot d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 1.16 \cdot 10^{-206}:\\ \;\;\;\;-\frac{a}{d}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{+49}:\\ \;\;\;\;c \cdot \frac{b}{d \cdot d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c + \frac{d \cdot d}{c}}\\ \end{array} \]

Alternative 8: 72.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.8 \cdot 10^{-9} \lor \neg \left(c \leq 2.55 \cdot 10^{+51}\right):\\
\;\;\;\;\frac{b}{c + \frac{d \cdot d}{c}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.79999999999999982e-9 or 2.55000000000000005e51 < c

    1. Initial program 48.8%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
    3. Step-by-step derivation
      1. associate-/l*50.7%

        \[\leadsto \color{blue}{\frac{b}{\frac{{c}^{2} + {d}^{2}}{c}}} \]
      2. unpow250.7%

        \[\leadsto \frac{b}{\frac{\color{blue}{c \cdot c} + {d}^{2}}{c}} \]
      3. unpow250.7%

        \[\leadsto \frac{b}{\frac{c \cdot c + \color{blue}{d \cdot d}}{c}} \]
      4. +-commutative50.7%

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

        \[\leadsto \frac{b}{\frac{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}{c}} \]
    4. Simplified50.6%

      \[\leadsto \color{blue}{\frac{b}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{c}}} \]
    5. Taylor expanded in d around 0 72.2%

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

        \[\leadsto \frac{b}{c + \frac{\color{blue}{d \cdot d}}{c}} \]
    7. Simplified72.2%

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

    if -5.79999999999999982e-9 < c < 2.55000000000000005e51

    1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      6. times-frac81.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.8 \cdot 10^{-9} \lor \neg \left(c \leq 2.55 \cdot 10^{+51}\right):\\ \;\;\;\;\frac{b}{c + \frac{d \cdot d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 9: 76.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1450000000000 \lor \neg \left(c \leq 2.3 \cdot 10^{+48}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.45e12 or 2.3e48 < c

    1. Initial program 48.0%

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

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

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

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

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

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

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

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

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

    if -1.45e12 < c < 2.3e48

    1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1450000000000 \lor \neg \left(c \leq 2.3 \cdot 10^{+48}\right):\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 10: 76.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -44000000000000:\\
\;\;\;\;\frac{b}{c} - \frac{a \cdot \frac{d}{c}}{c}\\

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

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


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

    1. Initial program 50.6%

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

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

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

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

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

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

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

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

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

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

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

    if -4.4e13 < c < 1.42e47

    1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.42e47 < c

    1. Initial program 44.8%

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{d \cdot a}{\color{blue}{c \cdot c}} \]
      6. times-frac83.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -44000000000000:\\ \;\;\;\;\frac{b}{c} - \frac{a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 1.42 \cdot 10^{+47}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]

Alternative 11: 66.2% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.2 \cdot 10^{-37} \lor \neg \left(c \leq 4.8 \cdot 10^{-73}\right):\\
\;\;\;\;\frac{b}{c + \frac{d \cdot d}{c}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -6.19999999999999987e-37 or 4.80000000000000011e-73 < c

    1. Initial program 53.1%

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

      \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}}} \]
    3. Step-by-step derivation
      1. associate-/l*51.7%

        \[\leadsto \color{blue}{\frac{b}{\frac{{c}^{2} + {d}^{2}}{c}}} \]
      2. unpow251.7%

        \[\leadsto \frac{b}{\frac{\color{blue}{c \cdot c} + {d}^{2}}{c}} \]
      3. unpow251.7%

        \[\leadsto \frac{b}{\frac{c \cdot c + \color{blue}{d \cdot d}}{c}} \]
      4. +-commutative51.7%

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

        \[\leadsto \frac{b}{\frac{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}{c}} \]
    4. Simplified51.6%

      \[\leadsto \color{blue}{\frac{b}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{c}}} \]
    5. Taylor expanded in d around 0 70.1%

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

        \[\leadsto \frac{b}{c + \frac{\color{blue}{d \cdot d}}{c}} \]
    7. Simplified70.1%

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

    if -6.19999999999999987e-37 < c < 4.80000000000000011e-73

    1. Initial program 74.3%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified69.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6.2 \cdot 10^{-37} \lor \neg \left(c \leq 4.8 \cdot 10^{-73}\right):\\ \;\;\;\;\frac{b}{c + \frac{d \cdot d}{c}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{a}{d}\\ \end{array} \]

Alternative 12: 64.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.8 \cdot 10^{-9} \lor \neg \left(c \leq 1.75 \cdot 10^{+52}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.79999999999999984e-9 or 1.75e52 < c

    1. Initial program 48.8%

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

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

    if -2.79999999999999984e-9 < c < 1.75e52

    1. Initial program 74.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.8 \cdot 10^{-9} \lor \neg \left(c \leq 1.75 \cdot 10^{+52}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;-\frac{a}{d}\\ \end{array} \]

Alternative 13: 42.7% 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.0%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Final simplification41.8%

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

Developer target: 99.4% accurate, 0.1× speedup?

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

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

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


\end{array}
\end{array}

Reproduce

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