Math FPCore C Julia Wolfram TeX \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{b \cdot d + a \cdot c}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+264}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\]
(FPCore (a b c d)
:precision binary64
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))) ↓
(FPCore (a b c d)
:precision binary64
(if (<= (/ (+ (* b d) (* a c)) (+ (* c c) (* d d))) 5e+264)
(* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d)))
(* (/ c (hypot c d)) (/ a (hypot c d))))) 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 tmp;
if ((((b * d) + (a * c)) / ((c * c) + (d * d))) <= 5e+264) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
}
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)
tmp = 0.0
if (Float64(Float64(Float64(b * d) + Float64(a * c)) / Float64(Float64(c * c) + Float64(d * d))) <= 5e+264)
tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d)));
else
tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d)));
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_] := If[LessEqual[N[(N[(N[(b * d), $MachinePrecision] + N[(a * c), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+264], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
↓
\begin{array}{l}
\mathbf{if}\;\frac{b \cdot d + a \cdot c}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+264}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
Alternatives Alternative 1 Error 12.8 Cost 13904
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;c \leq -7.6 \cdot 10^{+69}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq -2.45 \cdot 10^{-139}:\\
\;\;\;\;\frac{b \cdot d + a \cdot c}{t_0}\\
\mathbf{elif}\;c \leq 7.6 \cdot 10^{-143}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{+90}:\\
\;\;\;\;\frac{\mathsf{fma}\left(d, b, a \cdot c\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\]
Alternative 2 Error 12.9 Cost 13904
\[\begin{array}{l}
\mathbf{if}\;c \leq -4.2 \cdot 10^{+69}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq -1.22 \cdot 10^{-139}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;c \leq 5 \cdot 10^{-144}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 9.2 \cdot 10^{+93}:\\
\;\;\;\;\frac{\mathsf{fma}\left(d, b, a \cdot c\right)}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\]
Alternative 3 Error 12.5 Cost 7760
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;c \leq -6.7 \cdot 10^{+69}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq -1.4 \cdot 10^{-138}:\\
\;\;\;\;\frac{b \cdot d + a \cdot c}{t_0}\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{-141}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 1.26 \cdot 10^{+144}:\\
\;\;\;\;\frac{\mathsf{fma}\left(d, b, a \cdot c\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\end{array}
\]
Alternative 4 Error 12.6 Cost 1488
\[\begin{array}{l}
t_0 := \frac{b \cdot d + a \cdot c}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -8.5 \cdot 10^{+69}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq -5 \cdot 10^{-139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 6.4 \cdot 10^{-142}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 1.16 \cdot 10^{+144}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\end{array}
\]
Alternative 5 Error 16.8 Cost 1364
\[\begin{array}{l}
t_0 := \frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
t_1 := d \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -57:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{-50}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.3 \cdot 10^{+27}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + t_1\right)\\
\mathbf{elif}\;c \leq 3.1 \cdot 10^{+78}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.5 \cdot 10^{+151}:\\
\;\;\;\;a \cdot \frac{c}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{t_1}{c}\\
\end{array}
\]
Alternative 6 Error 16.6 Cost 1364
\[\begin{array}{l}
t_0 := d \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -7300000000:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{-50}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{+27}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + t_0\right)\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{+78}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{+151}:\\
\;\;\;\;a \cdot \frac{c}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{t_0}{c}\\
\end{array}
\]
Alternative 7 Error 16.6 Cost 1364
\[\begin{array}{l}
t_0 := d \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -420000:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq 3.5 \cdot 10^{-52}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{+26}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + t_0\right)\\
\mathbf{elif}\;c \leq 6 \cdot 10^{+78}:\\
\;\;\;\;\frac{b}{d} + \frac{1}{\frac{d}{c} \cdot \frac{d}{a}}\\
\mathbf{elif}\;c \leq 2.5 \cdot 10^{+151}:\\
\;\;\;\;a \cdot \frac{c}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{t_0}{c}\\
\end{array}
\]
Alternative 8 Error 21.7 Cost 1232
\[\begin{array}{l}
t_0 := \frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{if}\;c \leq -1.95 \cdot 10^{-70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-234}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{-151}:\\
\;\;\;\;\frac{a \cdot c}{d \cdot d}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{-50}:\\
\;\;\;\;b \cdot \frac{d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 9 Error 21.7 Cost 1232
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.85 \cdot 10^{-70}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-234}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{-151}:\\
\;\;\;\;\frac{a \cdot c}{d \cdot d}\\
\mathbf{elif}\;c \leq 6 \cdot 10^{-50}:\\
\;\;\;\;b \cdot \frac{d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\end{array}
\]
Alternative 10 Error 21.7 Cost 1232
\[\begin{array}{l}
\mathbf{if}\;c \leq -7.4 \cdot 10^{-71}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-234}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{-151}:\\
\;\;\;\;\frac{a \cdot c}{d \cdot d}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{-50}:\\
\;\;\;\;b \cdot \frac{d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\end{array}
\]
Alternative 11 Error 19.1 Cost 968
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.55 \cdot 10^{+33}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 8.5 \cdot 10^{+64}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 12 Error 23.9 Cost 844
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.8 \cdot 10^{+26}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -1.8 \cdot 10^{-147}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;d \leq -7.6 \cdot 10^{-193}:\\
\;\;\;\;b \cdot \frac{d}{c \cdot c}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{+25}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 13 Error 23.9 Cost 844
\[\begin{array}{l}
\mathbf{if}\;d \leq -3.9 \cdot 10^{+27}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -1.8 \cdot 10^{-147}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;d \leq -7.6 \cdot 10^{-193}:\\
\;\;\;\;\frac{b}{\frac{c}{\frac{d}{c}}}\\
\mathbf{elif}\;d \leq 2.35 \cdot 10^{+25}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 14 Error 23.8 Cost 844
\[\begin{array}{l}
\mathbf{if}\;d \leq -7.5 \cdot 10^{+27}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -1.8 \cdot 10^{-147}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;d \leq -7.6 \cdot 10^{-193}:\\
\;\;\;\;\frac{b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{+25}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 15 Error 22.9 Cost 456
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.65 \cdot 10^{+28}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{+25}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 16 Error 37.9 Cost 192
\[\frac{a}{c}
\]