Math FPCore C Julia Wolfram TeX \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\]
↓
\[\begin{array}{l}
t_0 := \frac{\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -1.9 \cdot 10^{+100}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c \cdot c}{b}}\\
\mathbf{elif}\;c \leq -1.25 \cdot 10^{-222}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 7.8 \cdot 10^{-144}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 3.05 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
(FPCore (a b c d)
:precision binary64
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))) ↓
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (/ (fma a c (* d b)) (hypot c d)) (hypot c d))))
(if (<= c -1.9e+100)
(+ (/ a c) (/ d (/ (* c c) b)))
(if (<= c -1.25e-222)
t_0
(if (<= c 7.8e-144)
(+ (/ b d) (/ (* c (/ a d)) d))
(if (<= c 3.05e+57) t_0 (+ (/ a c) (* (/ b c) (/ d c))))))))) double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
↓
double code(double a, double b, double c, double d) {
double t_0 = (fma(a, c, (d * b)) / hypot(c, d)) / hypot(c, d);
double tmp;
if (c <= -1.9e+100) {
tmp = (a / c) + (d / ((c * c) / b));
} else if (c <= -1.25e-222) {
tmp = t_0;
} else if (c <= 7.8e-144) {
tmp = (b / d) + ((c * (a / d)) / d);
} else if (c <= 3.05e+57) {
tmp = t_0;
} else {
tmp = (a / c) + ((b / c) * (d / c));
}
return tmp;
}
function code(a, b, c, d)
return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
↓
function code(a, b, c, d)
t_0 = Float64(Float64(fma(a, c, Float64(d * b)) / hypot(c, d)) / hypot(c, d))
tmp = 0.0
if (c <= -1.9e+100)
tmp = Float64(Float64(a / c) + Float64(d / Float64(Float64(c * c) / b)));
elseif (c <= -1.25e-222)
tmp = t_0;
elseif (c <= 7.8e-144)
tmp = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d));
elseif (c <= 3.05e+57)
tmp = t_0;
else
tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c)));
end
return tmp
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]
↓
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.9e+100], N[(N[(a / c), $MachinePrecision] + N[(d / N[(N[(c * c), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.25e-222], t$95$0, If[LessEqual[c, 7.8e-144], N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.05e+57], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
↓
\begin{array}{l}
t_0 := \frac{\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -1.9 \cdot 10^{+100}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c \cdot c}{b}}\\
\mathbf{elif}\;c \leq -1.25 \cdot 10^{-222}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 7.8 \cdot 10^{-144}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 3.05 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
Alternatives Alternative 1 Error 13.4 Cost 14032
\[\begin{array}{l}
\mathbf{if}\;c \leq -3.1 \cdot 10^{+100}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c \cdot c}{b}}\\
\mathbf{elif}\;c \leq -1.4 \cdot 10^{-221}:\\
\;\;\;\;\frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.35 \cdot 10^{-128}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 6.3 \cdot 10^{+56}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 2 Error 19.7 Cost 1628
\[\begin{array}{l}
t_0 := a \cdot \frac{c}{c \cdot c + d \cdot d}\\
t_1 := \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -4.4 \cdot 10^{+68}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -1.75 \cdot 10^{-173}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{-181}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 10^{-156}:\\
\;\;\;\;\frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{-102}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 500000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1900000000000:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 3 Error 20.6 Cost 1628
\[\begin{array}{l}
t_0 := a \cdot \frac{c}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -5.7 \cdot 10^{+57}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c \cdot c}{b}}\\
\mathbf{elif}\;c \leq -1.75 \cdot 10^{-173}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{-181}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{-156}:\\
\;\;\;\;\frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;c \leq 1.48 \cdot 10^{-102}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 1300:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.65 \cdot 10^{+14}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 4 Error 22.3 Cost 1496
\[\begin{array}{l}
t_0 := a \cdot \frac{c}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -8.8 \cdot 10^{+128}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -1.75 \cdot 10^{-173}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{-181}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{-156}:\\
\;\;\;\;\frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;c \leq 7.8 \cdot 10^{-103}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{+107}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 5 Error 13.4 Cost 1488
\[\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -4 \cdot 10^{+99}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c \cdot c}{b}}\\
\mathbf{elif}\;c \leq -1.4 \cdot 10^{-221}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{-129}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 3.05 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 6 Error 18.2 Cost 1232
\[\begin{array}{l}
t_0 := \frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{if}\;c \leq -4.9 \cdot 10^{+42}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c \cdot c}{b}}\\
\mathbf{elif}\;c \leq -8.6 \cdot 10^{-13}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -1.8 \cdot 10^{-173}:\\
\;\;\;\;a \cdot \frac{c}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.95 \cdot 10^{+16}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 7 Error 18.1 Cost 1232
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.95 \cdot 10^{+43}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c \cdot c}{b}}\\
\mathbf{elif}\;c \leq -2.2 \cdot 10^{-11}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;c \leq -1.8 \cdot 10^{-173}:\\
\;\;\;\;a \cdot \frac{c}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.62 \cdot 10^{+15}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 8 Error 16.2 Cost 1232
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.92 \cdot 10^{+43}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c \cdot c}{b}}\\
\mathbf{elif}\;c \leq -3.2 \cdot 10^{-11}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;c \leq -1.15 \cdot 10^{-67}:\\
\;\;\;\;\frac{c}{\frac{c \cdot c + d \cdot d}{a}}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{+14}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 9 Error 23.2 Cost 1108
\[\begin{array}{l}
\mathbf{if}\;c \leq -4.8 \cdot 10^{+41}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq -6 \cdot 10^{-13}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq -1.8 \cdot 10^{-48}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{-181}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 10^{-156}:\\
\;\;\;\;\frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{+17}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 10 Error 22.9 Cost 722
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.4 \cdot 10^{+42} \lor \neg \left(c \leq -1.9 \cdot 10^{-11}\right) \land \left(c \leq -5.5 \cdot 10^{-48} \lor \neg \left(c \leq 2.7 \cdot 10^{+17}\right)\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 11 Error 36.5 Cost 324
\[\begin{array}{l}
\mathbf{if}\;d \leq -6.4 \cdot 10^{+178}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 12 Error 37.0 Cost 192
\[\frac{a}{c}
\]