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{d}{\frac{c}{b}}\\
\mathbf{if}\;c \leq -6.8 \cdot 10^{+104}:\\
\;\;\;\;\frac{a}{c} + \frac{t_1}{c}\\
\mathbf{elif}\;c \leq 2.15 \cdot 10^{+192}:\\
\;\;\;\;t_0 \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} + \frac{c \cdot a}{\mathsf{hypot}\left(c, d\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(a + t_1\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 (/ d (/ c b))))
(if (<= c -6.8e+104)
(+ (/ a c) (/ t_1 c))
(if (<= c 2.15e+192)
(* t_0 (+ (/ b (/ (hypot c d) d)) (/ (* c a) (hypot c d))))
(* t_0 (+ a t_1)))))) 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 = d / (c / b);
double tmp;
if (c <= -6.8e+104) {
tmp = (a / c) + (t_1 / c);
} else if (c <= 2.15e+192) {
tmp = t_0 * ((b / (hypot(c, d) / d)) + ((c * a) / hypot(c, d)));
} else {
tmp = t_0 * (a + t_1);
}
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 = d / (c / b);
double tmp;
if (c <= -6.8e+104) {
tmp = (a / c) + (t_1 / c);
} else if (c <= 2.15e+192) {
tmp = t_0 * ((b / (Math.hypot(c, d) / d)) + ((c * a) / Math.hypot(c, d)));
} else {
tmp = t_0 * (a + t_1);
}
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 = d / (c / b)
tmp = 0
if c <= -6.8e+104:
tmp = (a / c) + (t_1 / c)
elif c <= 2.15e+192:
tmp = t_0 * ((b / (math.hypot(c, d) / d)) + ((c * a) / math.hypot(c, d)))
else:
tmp = t_0 * (a + t_1)
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(d / Float64(c / b))
tmp = 0.0
if (c <= -6.8e+104)
tmp = Float64(Float64(a / c) + Float64(t_1 / c));
elseif (c <= 2.15e+192)
tmp = Float64(t_0 * Float64(Float64(b / Float64(hypot(c, d) / d)) + Float64(Float64(c * a) / hypot(c, d))));
else
tmp = Float64(t_0 * Float64(a + t_1));
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 = d / (c / b);
tmp = 0.0;
if (c <= -6.8e+104)
tmp = (a / c) + (t_1 / c);
elseif (c <= 2.15e+192)
tmp = t_0 * ((b / (hypot(c, d) / d)) + ((c * a) / hypot(c, d)));
else
tmp = t_0 * (a + t_1);
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[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -6.8e+104], N[(N[(a / c), $MachinePrecision] + N[(t$95$1 / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.15e+192], N[(t$95$0 * N[(N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] + N[(N[(c * a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(a + t$95$1), $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{d}{\frac{c}{b}}\\
\mathbf{if}\;c \leq -6.8 \cdot 10^{+104}:\\
\;\;\;\;\frac{a}{c} + \frac{t_1}{c}\\
\mathbf{elif}\;c \leq 2.15 \cdot 10^{+192}:\\
\;\;\;\;t_0 \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} + \frac{c \cdot a}{\mathsf{hypot}\left(c, d\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(a + t_1\right)\\
\end{array}
Alternatives Alternative 1 Error 9.5 Cost 21060
\[\begin{array}{l}
t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;\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{elif}\;t_0 \leq \infty:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{c}{\frac{d}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\end{array}
\]
Alternative 2 Error 11.7 Cost 7696
\[\begin{array}{l}
t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.5 \cdot 10^{+147}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;d \leq -1.2 \cdot 10^{-148}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.9 \cdot 10^{-108}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + b \cdot \frac{d}{c}\right)\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{+85}:\\
\;\;\;\;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 Error 11.6 Cost 7696
\[\begin{array}{l}
t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
t_1 := b + \frac{c}{\frac{d}{a}}\\
\mathbf{if}\;d \leq -4.5 \cdot 10^{+68}:\\
\;\;\;\;t_1 \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.6 \cdot 10^{-153}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 4.5 \cdot 10^{-108}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + b \cdot \frac{d}{c}\right)\\
\mathbf{elif}\;d \leq 6 \cdot 10^{+95}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t_1\\
\end{array}
\]
Alternative 4 Error 11.8 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{a}{d} \cdot \frac{c}{d}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{+146}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -1.5 \cdot 10^{-153}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{-108}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + b \cdot \frac{d}{c}\right)\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{+95}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 5 Error 18.5 Cost 969
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.9 \cdot 10^{-33} \lor \neg \left(c \leq 1.35 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{1}{c} \cdot \left(a + b \cdot \frac{d}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 6 Error 15.1 Cost 969
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.25 \cdot 10^{+39} \lor \neg \left(c \leq 24000\right):\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b + \frac{c}{\frac{d}{a}}\right) \cdot \frac{1}{d}\\
\end{array}
\]
Alternative 7 Error 15.0 Cost 969
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.3 \cdot 10^{+39} \lor \neg \left(c \leq 450\right):\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d}{\frac{c}{b}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\left(b + \frac{c}{\frac{d}{a}}\right) \cdot \frac{1}{d}\\
\end{array}
\]
Alternative 8 Error 15.2 Cost 969
\[\begin{array}{l}
\mathbf{if}\;c \leq -8 \cdot 10^{+38} \lor \neg \left(c \leq 7200\right):\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d}{\frac{c}{b}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\end{array}
\]
Alternative 9 Error 18.4 Cost 968
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{-31}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{-27}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + b \cdot \frac{d}{c}\right)\\
\end{array}
\]
Alternative 10 Error 22.7 Cost 456
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.3 \cdot 10^{+22}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 3.8:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 11 Error 37.5 Cost 324
\[\begin{array}{l}
\mathbf{if}\;d \leq 9.5 \cdot 10^{+138}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\]
Alternative 12 Error 37.6 Cost 192
\[\frac{a}{c}
\]