Math FPCore C Java Python Julia MATLAB 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)}\\
t_1 := \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\mathbf{if}\;c \leq -1 \cdot 10^{+34}:\\
\;\;\;\;t_0 \cdot \left(t_1 - a\right)\\
\mathbf{elif}\;c \leq 6 \cdot 10^{+96}:\\
\;\;\;\;t_0 \cdot \left(t_1 + \frac{c \cdot a}{\mathsf{hypot}\left(c, d\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(t_1 + a\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
(let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (/ b (/ (hypot c d) d))))
(if (<= c -1e+34)
(* t_0 (- t_1 a))
(if (<= c 6e+96)
(* t_0 (+ t_1 (/ (* c a) (hypot c d))))
(* t_0 (+ t_1 a)))))) 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);
double t_1 = b / (hypot(c, d) / d);
double tmp;
if (c <= -1e+34) {
tmp = t_0 * (t_1 - a);
} else if (c <= 6e+96) {
tmp = t_0 * (t_1 + ((c * a) / hypot(c, d)));
} else {
tmp = t_0 * (t_1 + a);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
↓
public static double code(double a, double b, double c, double d) {
double t_0 = 1.0 / Math.hypot(c, d);
double t_1 = b / (Math.hypot(c, d) / d);
double tmp;
if (c <= -1e+34) {
tmp = t_0 * (t_1 - a);
} else if (c <= 6e+96) {
tmp = t_0 * (t_1 + ((c * a) / Math.hypot(c, d)));
} else {
tmp = t_0 * (t_1 + a);
}
return tmp;
}
def code(a, b, c, d):
return ((a * c) + (b * d)) / ((c * c) + (d * d))
↓
def code(a, b, c, d):
t_0 = 1.0 / math.hypot(c, d)
t_1 = b / (math.hypot(c, d) / d)
tmp = 0
if c <= -1e+34:
tmp = t_0 * (t_1 - a)
elif c <= 6e+96:
tmp = t_0 * (t_1 + ((c * a) / math.hypot(c, d)))
else:
tmp = t_0 * (t_1 + a)
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(1.0 / hypot(c, d))
t_1 = Float64(b / Float64(hypot(c, d) / d))
tmp = 0.0
if (c <= -1e+34)
tmp = Float64(t_0 * Float64(t_1 - a));
elseif (c <= 6e+96)
tmp = Float64(t_0 * Float64(t_1 + Float64(Float64(c * a) / hypot(c, d))));
else
tmp = Float64(t_0 * Float64(t_1 + a));
end
return tmp
end
function tmp = code(a, b, c, d)
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
↓
function tmp_2 = code(a, b, c, d)
t_0 = 1.0 / hypot(c, d);
t_1 = b / (hypot(c, d) / d);
tmp = 0.0;
if (c <= -1e+34)
tmp = t_0 * (t_1 - a);
elseif (c <= 6e+96)
tmp = t_0 * (t_1 + ((c * a) / hypot(c, d)));
else
tmp = t_0 * (t_1 + a);
end
tmp_2 = 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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1e+34], N[(t$95$0 * N[(t$95$1 - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6e+96], N[(t$95$0 * N[(t$95$1 + N[(N[(c * a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(t$95$1 + a), $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)}\\
t_1 := \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\mathbf{if}\;c \leq -1 \cdot 10^{+34}:\\
\;\;\;\;t_0 \cdot \left(t_1 - a\right)\\
\mathbf{elif}\;c \leq 6 \cdot 10^{+96}:\\
\;\;\;\;t_0 \cdot \left(t_1 + \frac{c \cdot a}{\mathsf{hypot}\left(c, d\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(t_1 + a\right)\\
\end{array}
Alternatives Alternative 1 Error 12.6% Cost 20932
\[\begin{array}{l}
\mathbf{if}\;\frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+268}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} - a\right)\\
\end{array}
\]
Alternative 2 Error 15.39% Cost 20168
\[\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\mathbf{if}\;c \leq -6 \cdot 10^{-41}:\\
\;\;\;\;t_0 \cdot \left(t_1 - a\right)\\
\mathbf{elif}\;c \leq -9.8 \cdot 10^{-113}:\\
\;\;\;\;\mathsf{fma}\left(a, c, d \cdot b\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{elif}\;c \leq 5.3 \cdot 10^{-163}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(t_1 + a\right)\\
\end{array}
\]
Alternative 3 Error 17% Cost 14028
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.8 \cdot 10^{+108}:\\
\;\;\;\;\frac{\left(-a\right) - \frac{d}{\frac{c}{b}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -7.5 \cdot 10^{-113}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;c \leq 3 \cdot 10^{-162}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} + a\right)\\
\end{array}
\]
Alternative 4 Error 15.37% Cost 14028
\[\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\mathbf{if}\;c \leq -2.9 \cdot 10^{-40}:\\
\;\;\;\;t_0 \cdot \left(t_1 - a\right)\\
\mathbf{elif}\;c \leq -1.4 \cdot 10^{-112}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;c \leq 2.15 \cdot 10^{-163}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(t_1 + a\right)\\
\end{array}
\]
Alternative 5 Error 19.55% Cost 7828
\[\begin{array}{l}
t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -6 \cdot 10^{+103}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-133}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{-40}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{+27}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 6.5 \cdot 10^{+67}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\
\end{array}
\]
Alternative 6 Error 19.35% Cost 7828
\[\begin{array}{l}
t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.8 \cdot 10^{+103}:\\
\;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -4.1 \cdot 10^{-134}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{-40}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{+27}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+67}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\
\end{array}
\]
Alternative 7 Error 25.17% Cost 1628
\[\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
t_1 := c \cdot c + d \cdot d\\
t_2 := \frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\mathbf{if}\;c \leq -1.65 \cdot 10^{+19}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq -600:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -1.05 \cdot 10^{-51}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq -1.15 \cdot 10^{-66}:\\
\;\;\;\;\frac{d \cdot b}{t_1}\\
\mathbf{elif}\;c \leq -2.3 \cdot 10^{-75}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -8.8 \cdot 10^{-97}:\\
\;\;\;\;\frac{c \cdot a}{t_1}\\
\mathbf{elif}\;c \leq 6.2 \cdot 10^{-67}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 8 Error 19.78% Cost 1488
\[\begin{array}{l}
t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{if}\;d \leq -4.2 \cdot 10^{+103}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -2.4 \cdot 10^{-134}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{-37}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.06 \cdot 10^{+27}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 6.5 \cdot 10^{+67}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 9 Error 31.41% Cost 1234
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.65 \cdot 10^{+19} \lor \neg \left(c \leq -1.1 \cdot 10^{-66} \lor \neg \left(c \leq -7.4 \cdot 10^{-97}\right) \land c \leq 6.4 \cdot 10^{-62}\right):\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 10 Error 24.59% Cost 1232
\[\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
t_1 := \frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\mathbf{if}\;c \leq -3 \cdot 10^{+19}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -3 \cdot 10^{-75}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq -3.8 \cdot 10^{-99}:\\
\;\;\;\;\frac{c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{-59}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 11 Error 24.62% Cost 969
\[\begin{array}{l}
\mathbf{if}\;c \leq -5.8 \cdot 10^{+19} \lor \neg \left(c \leq 6.2 \cdot 10^{-68}\right):\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\end{array}
\]
Alternative 12 Error 24.47% Cost 969
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.35 \cdot 10^{+19} \lor \neg \left(c \leq 1.3 \cdot 10^{-66}\right):\\
\;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\end{array}
\]
Alternative 13 Error 24.11% Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -4.1 \cdot 10^{+17} \lor \neg \left(d \leq 6.2 \cdot 10^{-40}\right):\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\end{array}
\]
Alternative 14 Error 24.71% Cost 968
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.4 \cdot 10^{+19}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{elif}\;c \leq 6.6 \cdot 10^{-72}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\]
Alternative 15 Error 37.77% Cost 456
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.65 \cdot 10^{+19}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{-69}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 16 Error 59.19% Cost 192
\[\frac{a}{c}
\]