Complex division, real part

Percentage Accurate: 61.8% → 80.8%
Time: 10.9s
Alternatives: 8
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((a * c) + (b * 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 = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a \cdot c + b \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 8 alternatives:

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

Initial Program: 61.8% accurate, 1.0× speedup?

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

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

Alternative 1: 80.8% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\frac{d}{c \cdot \frac{a}{d} + b}}\\
t_1 := \sqrt[3]{\mathsf{fma}\left(a, c, d \cdot b\right)}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 1.02 \cdot 10^{+57}:\\
\;\;\;\;\frac{{t\_1}^{2}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_1}{\mathsf{hypot}\left(c, d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -7.49999999999999993e25 or 1.02e57 < d

    1. Initial program 53.2%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around inf 80.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{d}{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}}} \]
    12. Step-by-step derivation
      1. fma-undefine83.9%

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

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

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

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{c \cdot \frac{a}{d}} + b}} \]
    13. Applied egg-rr85.3%

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

    if -7.49999999999999993e25 < d < 1.45e-74

    1. Initial program 69.4%

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

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

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

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

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

        \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
    7. Simplified91.6%

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

    if 1.45e-74 < d < 1.02e57

    1. Initial program 80.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-cube-cbrt79.6%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{+25}:\\ \;\;\;\;\frac{1}{\frac{d}{c \cdot \frac{a}{d} + b}}\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{-74}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 1.02 \cdot 10^{+57}:\\ \;\;\;\;\frac{{\left(\sqrt[3]{\mathsf{fma}\left(a, c, d \cdot b\right)}\right)}^{2}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\sqrt[3]{\mathsf{fma}\left(a, c, d \cdot b\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{d}{c \cdot \frac{a}{d} + b}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 80.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\frac{d}{c \cdot \frac{a}{d} + b}}\\ \mathbf{if}\;d \leq -2.7 \cdot 10^{+29}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{-76}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 4.7 \cdot 10^{+55}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ 1.0 (/ d (+ (* c (/ a d)) b)))))
   (if (<= d -2.7e+29)
     t_0
     (if (<= d 1.5e-76)
       (/ (+ a (/ (* d b) c)) c)
       (if (<= d 4.7e+55) (/ (fma a c (* d b)) (fma c c (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = 1.0 / (d / ((c * (a / d)) + b));
	double tmp;
	if (d <= -2.7e+29) {
		tmp = t_0;
	} else if (d <= 1.5e-76) {
		tmp = (a + ((d * b) / c)) / c;
	} else if (d <= 4.7e+55) {
		tmp = fma(a, c, (d * b)) / fma(c, c, (d * d));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(1.0 / Float64(d / Float64(Float64(c * Float64(a / d)) + b)))
	tmp = 0.0
	if (d <= -2.7e+29)
		tmp = t_0;
	elseif (d <= 1.5e-76)
		tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c);
	elseif (d <= 4.7e+55)
		tmp = Float64(fma(a, c, Float64(d * b)) / fma(c, c, Float64(d * d)));
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[(d / N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.7e+29], t$95$0, If[LessEqual[d, 1.5e-76], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4.7e+55], N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;d \leq 4.7 \cdot 10^{+55}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.7e29 or 4.7000000000000001e55 < d

    1. Initial program 53.2%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around inf 80.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{d}{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}}} \]
    12. Step-by-step derivation
      1. fma-undefine83.9%

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

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

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

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{c \cdot \frac{a}{d}} + b}} \]
    13. Applied egg-rr85.3%

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

    if -2.7e29 < d < 1.50000000000000012e-76

    1. Initial program 69.4%

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

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

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

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

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

        \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
    7. Simplified91.6%

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

    if 1.50000000000000012e-76 < d < 4.7000000000000001e55

    1. Initial program 80.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
  3. Recombined 3 regimes into one program.
  4. Final simplification87.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.7 \cdot 10^{+29}:\\ \;\;\;\;\frac{1}{\frac{d}{c \cdot \frac{a}{d} + b}}\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{-76}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 4.7 \cdot 10^{+55}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{d}{c \cdot \frac{a}{d} + b}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.0% accurate, 0.5× speedup?

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

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

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

\mathbf{elif}\;d \leq 2.15 \cdot 10^{+58}:\\
\;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.4999999999999997e28 or 2.14999999999999996e58 < d

    1. Initial program 53.2%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around inf 80.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{d}{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}}} \]
    12. Step-by-step derivation
      1. fma-undefine83.9%

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

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

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

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{c \cdot \frac{a}{d}} + b}} \]
    13. Applied egg-rr85.3%

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

    if -4.4999999999999997e28 < d < 4.69999999999999996e-71

    1. Initial program 69.4%

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

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

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

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

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

        \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
    7. Simplified91.6%

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

    if 4.69999999999999996e-71 < d < 2.14999999999999996e58

    1. Initial program 80.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.5 \cdot 10^{+28}:\\ \;\;\;\;\frac{1}{\frac{d}{c \cdot \frac{a}{d} + b}}\\ \mathbf{elif}\;d \leq 4.7 \cdot 10^{-71}:\\ \;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\ \mathbf{elif}\;d \leq 2.15 \cdot 10^{+58}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{d}{c \cdot \frac{a}{d} + b}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 77.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.05 \cdot 10^{+28} \lor \neg \left(d \leq 1.3 \cdot 10^{-53}\right):\\
\;\;\;\;\frac{1}{\frac{d}{c \cdot \frac{a}{d} + b}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.04999999999999995e28 or 1.29999999999999998e-53 < d

    1. Initial program 58.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around inf 78.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{d}{\mathsf{fma}\left(a, \frac{c}{d}, b\right)}}} \]
    11. Simplified81.2%

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

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

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

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

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{c \cdot \frac{a}{d}} + b}} \]
    13. Applied egg-rr82.3%

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

    if -1.04999999999999995e28 < d < 1.29999999999999998e-53

    1. Initial program 69.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 90.3%

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

        \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
    7. Simplified90.3%

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

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

Alternative 5: 77.5% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7.3999999999999998e28 or 1.00000000000000003e-53 < d

    1. Initial program 58.6%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in d around inf 78.2%

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

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

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

    if -7.3999999999999998e28 < d < 1.00000000000000003e-53

    1. Initial program 69.0%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 90.3%

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

        \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
    7. Simplified90.3%

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

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

Alternative 6: 72.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.6 \cdot 10^{+28} \lor \neg \left(d \leq 3.1 \cdot 10^{+35}\right):\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.6e28 or 3.09999999999999987e35 < d

    1. Initial program 54.4%

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

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

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

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

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

    if -1.6e28 < d < 3.09999999999999987e35

    1. Initial program 71.1%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 82.3%

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

        \[\leadsto \frac{a + \frac{\color{blue}{d \cdot b}}{c}}{c} \]
    7. Simplified82.3%

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

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

Alternative 7: 63.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -4 \cdot 10^{+16} \lor \neg \left(d \leq 1.25 \cdot 10^{-53}\right):\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -4e16 or 1.25e-53 < d

    1. Initial program 59.1%

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

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

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

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

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

    if -4e16 < d < 1.25e-53

    1. Initial program 68.5%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in c around inf 68.7%

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

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

Alternative 8: 42.2% accurate, 5.0× speedup?

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

\\
\frac{a}{c}
\end{array}
Derivation
  1. Initial program 63.3%

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in c around inf 39.9%

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

Developer Target 1: 99.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \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))
   (/ (+ a (* b (/ d c))) (+ c (* d (/ d c))))
   (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (b + (a * (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(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(b + Float64(a * 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 = (a + (b * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (b + (a * (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[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * 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{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024145 
(FPCore (a b c d)
  :name "Complex division, real part"
  :precision binary64

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

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