Math FPCore C Java Python Julia MATLAB Wolfram TeX \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\]
↓
\[\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} + \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}\right)
\]
(FPCore (a b c d)
:precision binary64
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))) ↓
(FPCore (a b c d)
:precision binary64
(* (/ 1.0 (hypot c d)) (+ (/ b (/ (hypot c d) d)) (/ a (/ (hypot c d) 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) {
return (1.0 / hypot(c, d)) * ((b / (hypot(c, d) / d)) + (a / (hypot(c, d) / c)));
}
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) {
return (1.0 / Math.hypot(c, d)) * ((b / (Math.hypot(c, d) / d)) + (a / (Math.hypot(c, d) / c)));
}
def code(a, b, c, d):
return ((a * c) + (b * d)) / ((c * c) + (d * d))
↓
def code(a, b, c, d):
return (1.0 / math.hypot(c, d)) * ((b / (math.hypot(c, d) / d)) + (a / (math.hypot(c, d) / c)))
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)
return Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(b / Float64(hypot(c, d) / d)) + Float64(a / Float64(hypot(c, d) / c))))
end
function tmp = code(a, b, c, d)
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
↓
function tmp = code(a, b, c, d)
tmp = (1.0 / hypot(c, d)) * ((b / (hypot(c, d) / d)) + (a / (hypot(c, d) / c)));
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_] := N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] + N[(a / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
↓
\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} + \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}\right)
Alternatives Alternative 1 Accuracy 88.8% Cost 22089
\[\begin{array}{l}
t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{+259}\right):\\
\;\;\;\;t_1 \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} + a\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\]
Alternative 2 Accuracy 77.8% Cost 1224
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.1 \cdot 10^{+116}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;d \leq -1.4 \cdot 10^{-48}:\\
\;\;\;\;\frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 206000000:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d}{\frac{c}{b}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\end{array}
\]
Alternative 3 Accuracy 70.3% Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -6 \cdot 10^{+33} \lor \neg \left(d \leq 64000000000\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\end{array}
\]
Alternative 4 Accuracy 70.0% Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.8 \cdot 10^{+32} \lor \neg \left(d \leq 18000000000\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d}{\frac{c}{b}}}{c}\\
\end{array}
\]
Alternative 5 Accuracy 76.3% Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \cdot 10^{+19} \lor \neg \left(d \leq 72\right):\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d}{\frac{c}{b}}}{c}\\
\end{array}
\]
Alternative 6 Accuracy 75.8% Cost 968
\[\begin{array}{l}
\mathbf{if}\;d \leq -2.15 \cdot 10^{+19}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{elif}\;d \leq 185:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d}{\frac{c}{b}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\end{array}
\]
Alternative 7 Accuracy 63.4% Cost 844
\[\begin{array}{l}
\mathbf{if}\;c \leq -8.6 \cdot 10^{+19}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 1.05 \cdot 10^{-6}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 2.3 \cdot 10^{+34}:\\
\;\;\;\;\frac{a}{d} \cdot \frac{c}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 8 Accuracy 64.0% Cost 456
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.5 \cdot 10^{+19}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 4.05 \cdot 10^{+34}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 9 Accuracy 41.8% Cost 192
\[\frac{a}{c}
\]