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{d}{\mathsf{hypot}\left(c, d\right)} \cdot b + \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)) (+ (* (/ d (hypot c d)) b) (/ 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)) * (((d / hypot(c, d)) * b) + (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)) * (((d / Math.hypot(c, d)) * b) + (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)) * (((d / math.hypot(c, d)) * b) + (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(Float64(d / hypot(c, d)) * b) + 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)) * (((d / hypot(c, d)) * b) + (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[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * b), $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{d}{\mathsf{hypot}\left(c, d\right)} \cdot b + \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}\right)
Alternatives Alternative 1 Error 9.4 Cost 20560
\[\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := t_0 \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -1.3 \cdot 10^{+147}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;c \leq -1.1 \cdot 10^{-191}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{-112}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;c \leq 2.55 \cdot 10^{+71}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot b + a\right)\\
\end{array}
\]
Alternative 2 Error 11.4 Cost 14028
\[\begin{array}{l}
\mathbf{if}\;c \leq -1.12 \cdot 10^{+138}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;c \leq -2.8 \cdot 10^{-125}:\\
\;\;\;\;\frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 9.6 \cdot 10^{-105}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot b + a\right)\\
\end{array}
\]
Alternative 3 Error 12.4 Cost 1488
\[\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -1.12 \cdot 10^{+139}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;c \leq -1.32 \cdot 10^{-123}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 4.1 \cdot 10^{-73}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;c \leq 8.6 \cdot 10^{+127}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{c} \cdot \left(d \cdot \frac{b}{c}\right)\\
\end{array}
\]
Alternative 4 Error 15.7 Cost 1232
\[\begin{array}{l}
t_0 := \frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{if}\;c \leq -1.1 \cdot 10^{+26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 6.8 \cdot 10^{-20}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{elif}\;c \leq 1.55 \cdot 10^{+32}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 9 \cdot 10^{+73}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 5 Error 15.7 Cost 1232
\[\begin{array}{l}
\mathbf{if}\;c \leq -8 \cdot 10^{+28}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\
\mathbf{elif}\;c \leq 3.35 \cdot 10^{-18}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{elif}\;c \leq 1.08 \cdot 10^{+32}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{\frac{c \cdot c}{b}}\\
\mathbf{elif}\;c \leq 1.72 \cdot 10^{+75}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 6 Error 15.1 Cost 1096
\[\begin{array}{l}
\mathbf{if}\;d \leq -43000000:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq 6.8 \cdot 10^{-25}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{c} \cdot \left(d \cdot \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\end{array}
\]
Alternative 7 Error 18.5 Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -9000000 \lor \neg \left(d \leq 1.9 \cdot 10^{-24}\right):\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c + \frac{d \cdot d}{c}}\\
\end{array}
\]
Alternative 8 Error 16.7 Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -430000000 \lor \neg \left(d \leq 2.65 \cdot 10^{-24}\right):\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 9 Error 16.6 Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -2800000 \lor \neg \left(d \leq 1.9 \cdot 10^{-24}\right):\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\end{array}
\]
Alternative 10 Error 15.3 Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -1650000 \lor \neg \left(d \leq 1.55 \cdot 10^{-25}\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 Error 15.3 Cost 968
\[\begin{array}{l}
\mathbf{if}\;d \leq -1250000000:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{-24}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\
\end{array}
\]
Alternative 12 Error 20.2 Cost 840
\[\begin{array}{l}
\mathbf{if}\;d \leq -4 \cdot 10^{+46}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{+28}:\\
\;\;\;\;\frac{a}{c + \frac{d \cdot d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 13 Error 22.7 Cost 456
\[\begin{array}{l}
\mathbf{if}\;d \leq -3900000000:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{-17}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\]
Alternative 14 Error 36.7 Cost 324
\[\begin{array}{l}
\mathbf{if}\;d \leq -2 \cdot 10^{+158}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\]
Alternative 15 Error 37.2 Cost 192
\[\frac{a}{c}
\]