Math FPCore C Java Python Julia MATLAB Wolfram TeX \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\]
↓
\[\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)} - \frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot a\right)
\]
(FPCore (a b c d)
:precision binary64
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))) ↓
(FPCore (a b c d)
:precision binary64
(* (/ 1.0 (hypot c d)) (- (* c (/ b (hypot c d))) (* (/ d (hypot c d)) a)))) double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
↓
double code(double a, double b, double c, double d) {
return (1.0 / hypot(c, d)) * ((c * (b / hypot(c, d))) - ((d / hypot(c, d)) * a));
}
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
↓
public static double code(double a, double b, double c, double d) {
return (1.0 / Math.hypot(c, d)) * ((c * (b / Math.hypot(c, d))) - ((d / Math.hypot(c, d)) * a));
}
def code(a, b, c, d):
return ((b * c) - (a * d)) / ((c * c) + (d * d))
↓
def code(a, b, c, d):
return (1.0 / math.hypot(c, d)) * ((c * (b / math.hypot(c, d))) - ((d / math.hypot(c, d)) * a))
function code(a, b, c, d)
return Float64(Float64(Float64(b * c) - Float64(a * 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(c * Float64(b / hypot(c, d))) - Float64(Float64(d / hypot(c, d)) * a)))
end
function tmp = code(a, b, c, d)
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
end
↓
function tmp = code(a, b, c, d)
tmp = (1.0 / hypot(c, d)) * ((c * (b / hypot(c, d))) - ((d / hypot(c, d)) * a));
end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * 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[(c * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
↓
\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)} - \frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot a\right)
Alternatives Alternative 1 Error 9.9 Cost 14288
\[\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := t_0 \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -2.5 \cdot 10^{+121}:\\
\;\;\;\;t_0 \cdot \mathsf{fma}\left(-1, \frac{c}{\frac{d}{b}}, a\right)\\
\mathbf{elif}\;d \leq -8.5 \cdot 10^{-181}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 1.25 \cdot 10^{-84}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{d \cdot a}{c}\right)\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{+63}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\]
Alternative 2 Error 11.5 Cost 13700
\[\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -8.5 \cdot 10^{+121}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \mathsf{fma}\left(-1, \frac{c}{\frac{d}{b}}, a\right)\\
\mathbf{elif}\;d \leq -3.3 \cdot 10^{-143}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 5 \cdot 10^{-69}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{d \cdot a}{c}\right)\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+60}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\]
Alternative 3 Error 11.6 Cost 7568
\[\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := c \cdot \frac{b}{d}\\
\mathbf{if}\;d \leq -8 \cdot 10^{+120}:\\
\;\;\;\;\frac{a - t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-145}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 6.4 \cdot 10^{-63}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{d \cdot a}{c}\right)\\
\mathbf{elif}\;d \leq 9 \cdot 10^{+63}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\]
Alternative 4 Error 11.7 Cost 7172
\[\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -8.5 \cdot 10^{+119}:\\
\;\;\;\;\frac{a - c \cdot \frac{b}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-142}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 6.6 \cdot 10^{-68}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{d \cdot a}{c}\right)\\
\mathbf{elif}\;d \leq 8 \cdot 10^{+60}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\
\end{array}
\]
Alternative 5 Error 11.8 Cost 1488
\[\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{+119}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -1.15 \cdot 10^{-142}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 8 \cdot 10^{-72}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{d \cdot a}{c}\right)\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+62}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 6 Error 15.5 Cost 1100
\[\begin{array}{l}
t_0 := \frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -4.6 \cdot 10^{+162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -3.6 \cdot 10^{-70}:\\
\;\;\;\;\frac{-a}{d + \frac{c}{\frac{d}{c}}}\\
\mathbf{elif}\;d \leq 4.9 \cdot 10^{+57}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{d \cdot a}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 7 Error 17.3 Cost 969
\[\begin{array}{l}
\mathbf{if}\;d \leq -5 \cdot 10^{-70} \lor \neg \left(d \leq 3.1 \cdot 10^{+89}\right):\\
\;\;\;\;\frac{-a}{d + \frac{c}{\frac{d}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{d \cdot a}{c}\right)\\
\end{array}
\]
Alternative 8 Error 17.6 Cost 905
\[\begin{array}{l}
\mathbf{if}\;d \leq -5 \cdot 10^{-70} \lor \neg \left(d \leq 3.1 \cdot 10^{+89}\right):\\
\;\;\;\;\frac{-a}{d + \frac{c}{\frac{d}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\]
Alternative 9 Error 19.6 Cost 841
\[\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{-13} \lor \neg \left(d \leq 1.75 \cdot 10^{+103}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\]
Alternative 10 Error 23.3 Cost 521
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.46 \cdot 10^{-12} \lor \neg \left(d \leq 6 \cdot 10^{+90}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\]
Alternative 11 Error 34.0 Cost 456
\[\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \cdot 10^{+177}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{elif}\;d \leq 6.1 \cdot 10^{+209}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\]
Alternative 12 Error 56.9 Cost 192
\[\frac{a}{d}
\]