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{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+74}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -1.5 \cdot 10^{-202}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{-222}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;c \leq 10^{+95}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{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 (* (/ 1.0 (hypot c d)) (/ (fma a c (* d b)) (hypot c d)))))
(if (<= c -2.1e+74)
(* (/ c (hypot c d)) (/ a (hypot c d)))
(if (<= c -1.5e-202)
t_0
(if (<= c 4.4e-222)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= c 1e+95) t_0 (+ (/ a c) (* (/ d c) (/ b 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 = (1.0 / hypot(c, d)) * (fma(a, c, (d * b)) / hypot(c, d));
double tmp;
if (c <= -2.1e+74) {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
} else if (c <= -1.5e-202) {
tmp = t_0;
} else if (c <= 4.4e-222) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (c <= 1e+95) {
tmp = t_0;
} else {
tmp = (a / c) + ((d / c) * (b / 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(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(d * b)) / hypot(c, d)))
tmp = 0.0
if (c <= -2.1e+74)
tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d)));
elseif (c <= -1.5e-202)
tmp = t_0;
elseif (c <= 4.4e-222)
tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d)));
elseif (c <= 1e+95)
tmp = t_0;
else
tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / 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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.1e+74], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.5e-202], t$95$0, If[LessEqual[c, 4.4e-222], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1e+95], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
↓
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -2.1 \cdot 10^{+74}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -1.5 \cdot 10^{-202}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{-222}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;c \leq 10^{+95}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
Alternatives Alternative 1 Accuracy 78.1% Cost 17489
\[\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+269}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;t_0 \leq -4 \cdot 10^{-281} \lor \neg \left(t_0 \leq 0\right) \land t_0 \leq 10^{+303}:\\
\;\;\;\;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 Accuracy 82.1% Cost 7696
\[\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -6.6 \cdot 10^{+66}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq -2.7 \cdot 10^{-152}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.85 \cdot 10^{-142}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{+91}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\
\end{array}
\]
Alternative 3 Accuracy 81.9% Cost 1488
\[\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -3.1 \cdot 10^{+66}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-152}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.52 \cdot 10^{-142}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;d \leq 4.1 \cdot 10^{+89}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 4 Accuracy 76.1% Cost 1232
\[\begin{array}{l}
t_0 := \frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -3600000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.2 \cdot 10^{-62}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;d \leq 4.15 \cdot 10^{-17}:\\
\;\;\;\;\frac{d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{-5}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 5 Accuracy 74.3% Cost 1228
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.02 \cdot 10^{+21}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;c \leq 2.25 \cdot 10^{-77}:\\
\;\;\;\;\frac{b}{d} + \frac{1}{\frac{d}{c \cdot \frac{a}{d}}}\\
\mathbf{elif}\;c \leq 2.2 \cdot 10^{+94}:\\
\;\;\;\;\frac{c}{\frac{c}{\frac{a}{c}} + \frac{d}{\frac{a}{d}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\]
Alternative 6 Accuracy 73.6% Cost 1100
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.55 \cdot 10^{+20}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;c \leq 2.3 \cdot 10^{-77}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;c \leq 9 \cdot 10^{+93}:\\
\;\;\;\;\frac{c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\]
Alternative 7 Accuracy 69.3% Cost 977
\[\begin{array}{l}
\mathbf{if}\;d \leq -2.5 \cdot 10^{+56}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 0.000125:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq 3.9 \cdot 10^{+157} \lor \neg \left(d \leq 2 \cdot 10^{+199}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{\frac{a}{d}}{d}\\
\end{array}
\]
Alternative 8 Accuracy 69.3% Cost 977
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.25 \cdot 10^{+57}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 3.9 \cdot 10^{-5}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{+157} \lor \neg \left(d \leq 9.4 \cdot 10^{+198}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{\frac{a}{d}}{d}\\
\end{array}
\]
Alternative 9 Accuracy 63.5% Cost 976
\[\begin{array}{l}
\mathbf{if}\;d \leq -2.1 \cdot 10^{+57}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 1.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;d \leq 4.5 \cdot 10^{+156}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{+198}:\\
\;\;\;\;c \cdot \frac{\frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 10 Accuracy 76.2% Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -26000000000 \lor \neg \left(d \leq 6 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\end{array}
\]
Alternative 11 Accuracy 63.8% Cost 456
\[\begin{array}{l}
\mathbf{if}\;c \leq -6 \cdot 10^{+24}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 2.3 \cdot 10^{-77}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 12 Accuracy 42.4% Cost 324
\[\begin{array}{l}
\mathbf{if}\;d \leq 3.05 \cdot 10^{+172}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\]
Alternative 13 Accuracy 41.3% Cost 192
\[\frac{a}{c}
\]