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.9 \cdot 10^{+125}:\\
\;\;\;\;\left(a + \frac{d}{\frac{c}{b}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq 10^{+94}:\\
\;\;\;\;t_0 \cdot \left(t_1 + \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 (/ b (/ (hypot c d) d))))
(if (<= c -1.9e+125)
(* (+ a (/ d (/ c b))) (/ -1.0 (hypot c d)))
(if (<= c 1e+94)
(* t_0 (+ t_1 (/ (* 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 = b / (hypot(c, d) / d);
double tmp;
if (c <= -1.9e+125) {
tmp = (a + (d / (c / b))) * (-1.0 / hypot(c, d));
} else if (c <= 1e+94) {
tmp = t_0 * (t_1 + ((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 = b / (Math.hypot(c, d) / d);
double tmp;
if (c <= -1.9e+125) {
tmp = (a + (d / (c / b))) * (-1.0 / Math.hypot(c, d));
} else if (c <= 1e+94) {
tmp = t_0 * (t_1 + ((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 = b / (math.hypot(c, d) / d)
tmp = 0
if c <= -1.9e+125:
tmp = (a + (d / (c / b))) * (-1.0 / math.hypot(c, d))
elif c <= 1e+94:
tmp = t_0 * (t_1 + ((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(b / Float64(hypot(c, d) / d))
tmp = 0.0
if (c <= -1.9e+125)
tmp = Float64(Float64(a + Float64(d / Float64(c / b))) * Float64(-1.0 / hypot(c, d)));
elseif (c <= 1e+94)
tmp = Float64(t_0 * Float64(t_1 + 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 = b / (hypot(c, d) / d);
tmp = 0.0;
if (c <= -1.9e+125)
tmp = (a + (d / (c / b))) * (-1.0 / hypot(c, d));
elseif (c <= 1e+94)
tmp = t_0 * (t_1 + ((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[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.9e+125], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1e+94], 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[(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{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\mathbf{if}\;c \leq -1.9 \cdot 10^{+125}:\\
\;\;\;\;\left(a + \frac{d}{\frac{c}{b}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq 10^{+94}:\\
\;\;\;\;t_0 \cdot \left(t_1 + \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 Accuracy 88.0% Cost 21960
\[\begin{array}{l}
t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\
t_1 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+261}:\\
\;\;\;\;\frac{d}{\frac{t_0}{b}} + a \cdot \frac{c}{t_0}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+245}:\\
\;\;\;\;\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(a + \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\
\end{array}
\]
Alternative 2 Accuracy 85.1% Cost 14028
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;c \leq -1.36 \cdot 10^{+138}:\\
\;\;\;\;\left(a + \frac{d}{\frac{c}{b}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -3.9 \cdot 10^{-154}:\\
\;\;\;\;b \cdot \frac{d}{t_0} + a \cdot \frac{c}{t_0}\\
\mathbf{elif}\;c \leq 8 \cdot 10^{-59}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\
\end{array}
\]
Alternative 3 Accuracy 84.2% Cost 7300
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := b \cdot \frac{d}{t_0} + a \cdot \frac{c}{t_0}\\
\mathbf{if}\;c \leq -1.3 \cdot 10^{+138}:\\
\;\;\;\;\left(a + \frac{d}{\frac{c}{b}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -3.7 \cdot 10^{-154}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 8.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{+145}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 4 Accuracy 77.1% Cost 2148
\[\begin{array}{l}
t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
t_1 := \frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{if}\;d \leq -72000000000000:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-48}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;d \leq -5.4 \cdot 10^{-59}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;d \leq -4.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;d \leq -2.7 \cdot 10^{-147}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.26 \cdot 10^{-129}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 25000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.25 \cdot 10^{+55}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 3.7 \cdot 10^{+118}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{c}{d}}{\frac{d}{a}}\\
\end{array}
\]
Alternative 5 Accuracy 84.1% Cost 2000
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := b \cdot \frac{d}{t_0} + a \cdot \frac{c}{t_0}\\
t_2 := \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\mathbf{if}\;c \leq -5.5 \cdot 10^{+135}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq -1.32 \cdot 10^{-155}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 8.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 1.7 \cdot 10^{+145}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 6 Accuracy 68.6% Cost 1232
\[\begin{array}{l}
t_0 := \frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{if}\;d \leq -2.65 \cdot 10^{+14}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 2.05 \cdot 10^{-71}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 18000000:\\
\;\;\;\;b \cdot \frac{d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 6.2 \cdot 10^{+60}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 7 Accuracy 74.7% Cost 1232
\[\begin{array}{l}
t_0 := \frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{if}\;c \leq -2 \cdot 10^{-12}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq 3.1 \cdot 10^{+33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.2 \cdot 10^{+61}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 1.9 \cdot 10^{+95}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 8 Accuracy 74.7% Cost 1232
\[\begin{array}{l}
\mathbf{if}\;c \leq -9.5 \cdot 10^{-13}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq 4.2 \cdot 10^{+33}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;c \leq 5.1 \cdot 10^{+61}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{+94}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 9 Accuracy 74.9% Cost 1232
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.5 \cdot 10^{-15}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq 6.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 5.5 \cdot 10^{+61}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{+94}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 10 Accuracy 75.0% Cost 1232
\[\begin{array}{l}
\mathbf{if}\;c \leq -3.9 \cdot 10^{-12}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq 4.8 \cdot 10^{+33}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 3.2 \cdot 10^{+60}:\\
\;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 10^{+94}:\\
\;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 11 Accuracy 69.9% Cost 968
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.8 \cdot 10^{-13}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq 6.2 \cdot 10^{+32}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 12 Accuracy 64.1% Cost 456
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.85 \cdot 10^{-13}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 4.4 \cdot 10^{+34}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 13 Accuracy 42.0% Cost 192
\[\frac{a}{c}
\]