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}\;d \leq -3.4 \cdot 10^{+103}:\\
\;\;\;\;\left(b + \frac{c}{\frac{d}{a}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.02 \cdot 10^{-196}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.15 \cdot 10^{-181}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{c}{\frac{d}{c}}}\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+89}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\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 (<= d -3.4e+103)
(* (+ b (/ c (/ d a))) (/ -1.0 (hypot c d)))
(if (<= d -1.02e-196)
t_0
(if (<= d 2.15e-181)
(+ (/ a c) (/ b (/ c (/ d c))))
(if (<= d 7e+89) t_0 (+ (/ b d) (/ (* c (/ a d)) 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 t_0 = (fma(a, c, (d * b)) / hypot(c, d)) / hypot(c, d);
double tmp;
if (d <= -3.4e+103) {
tmp = (b + (c / (d / a))) * (-1.0 / hypot(c, d));
} else if (d <= -1.02e-196) {
tmp = t_0;
} else if (d <= 2.15e-181) {
tmp = (a / c) + (b / (c / (d / c)));
} else if (d <= 7e+89) {
tmp = t_0;
} else {
tmp = (b / d) + ((c * (a / d)) / 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)
t_0 = Float64(Float64(fma(a, c, Float64(d * b)) / hypot(c, d)) / hypot(c, d))
tmp = 0.0
if (d <= -3.4e+103)
tmp = Float64(Float64(b + Float64(c / Float64(d / a))) * Float64(-1.0 / hypot(c, d)));
elseif (d <= -1.02e-196)
tmp = t_0;
elseif (d <= 2.15e-181)
tmp = Float64(Float64(a / c) + Float64(b / Float64(c / Float64(d / c))));
elseif (d <= 7e+89)
tmp = t_0;
else
tmp = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / 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_] := 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[d, -3.4e+103], N[(N[(b + N[(c / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.02e-196], t$95$0, If[LessEqual[d, 2.15e-181], N[(N[(a / c), $MachinePrecision] + N[(b / N[(c / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7e+89], t$95$0, N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $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}\;d \leq -3.4 \cdot 10^{+103}:\\
\;\;\;\;\left(b + \frac{c}{\frac{d}{a}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.02 \cdot 10^{-196}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.15 \cdot 10^{-181}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{c}{\frac{d}{c}}}\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+89}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\end{array}
Alternatives Alternative 1 Error 21.02% Cost 14300
\[\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -2.9 \cdot 10^{+94}:\\
\;\;\;\;\left(b + \frac{c}{\frac{d}{a}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -5.3 \cdot 10^{-82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.1 \cdot 10^{-161}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d \cdot b}{c}}{c}\\
\mathbf{elif}\;d \leq 1.16 \cdot 10^{-97}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{-34}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;\frac{\frac{c}{\frac{\mathsf{hypot}\left(d, c\right)}{a}}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;d \leq 3.7 \cdot 10^{+102}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\end{array}
\]
Alternative 2 Error 21% Cost 7300
\[\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.75 \cdot 10^{+98}:\\
\;\;\;\;\left(b + \frac{c}{\frac{d}{a}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -9.2 \cdot 10^{-82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.1 \cdot 10^{-161}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d \cdot b}{c}}{c}\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{-98}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{+67}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\end{array}
\]
Alternative 3 Error 21.24% Cost 1488
\[\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{+118}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;d \leq -7.2 \cdot 10^{-82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.1 \cdot 10^{-161}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d \cdot b}{c}}{c}\\
\mathbf{elif}\;d \leq 1.06 \cdot 10^{-97}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.1 \cdot 10^{+67}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\end{array}
\]
Alternative 4 Error 30.52% Cost 1232
\[\begin{array}{l}
t_0 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
t_1 := \frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{if}\;d \leq -2.8 \cdot 10^{+162}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -2.4 \cdot 10^{+72}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -2.8 \cdot 10^{+19}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 4.3 \cdot 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 5 Error 30.98% Cost 1232
\[\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{if}\;d \leq -2.8 \cdot 10^{+162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -3.8 \cdot 10^{+72}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -4.5 \cdot 10^{+28}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 4.8 \cdot 10^{+62}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{c}{\frac{d}{c}}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 6 Error 28.59% Cost 1232
\[\begin{array}{l}
t_0 := \frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{if}\;d \leq -2.8 \cdot 10^{+162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -3.5 \cdot 10^{+72}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -1.65 \cdot 10^{+28}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 1.15 \cdot 10^{+61}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{c}{\frac{d}{c}}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 7 Error 28.55% Cost 1232
\[\begin{array}{l}
\mathbf{if}\;d \leq -2.8 \cdot 10^{+162}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;d \leq -8.2 \cdot 10^{+71}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -2.9 \cdot 10^{+28}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{+61}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{c}{\frac{d}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\end{array}
\]
Alternative 8 Error 28.24% Cost 1232
\[\begin{array}{l}
\mathbf{if}\;d \leq -2.8 \cdot 10^{+162}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;d \leq -2.8 \cdot 10^{+72}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq -4.2 \cdot 10^{+24}:\\
\;\;\;\;\frac{d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 1.22 \cdot 10^{+61}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{c}{\frac{d}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\end{array}
\]
Alternative 9 Error 29.33% Cost 969
\[\begin{array}{l}
\mathbf{if}\;c \leq -7.8 \cdot 10^{+93} \lor \neg \left(c \leq 1.9 \cdot 10^{+23}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\end{array}
\]
Alternative 10 Error 39.31% Cost 722
\[\begin{array}{l}
\mathbf{if}\;d \leq -2.8 \cdot 10^{+162} \lor \neg \left(d \leq -2.2 \cdot 10^{+72}\right) \land \left(d \leq -8.6 \cdot 10^{+19} \lor \neg \left(d \leq 1.7 \cdot 10^{+77}\right)\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 11 Error 58.76% Cost 192
\[\frac{a}{c}
\]