Math FPCore C Julia Wolfram TeX \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\]
↓
\[\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}\right)
\]
(FPCore (a b c d)
:precision binary64
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))) ↓
(FPCore (a b c d)
:precision binary64
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(* (/ d (hypot d c)) (/ (- a) (hypot d c))))) 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 fma((c / hypot(c, d)), (b / hypot(c, d)), ((d / hypot(d, c)) * (-a / hypot(d, c))));
}
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 fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(d / hypot(d, c)) * Float64(Float64(-a) / hypot(d, c))))
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[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[((-a) / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
↓
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{-a}{\mathsf{hypot}\left(d, c\right)}\right)
Alternatives Alternative 1 Error 6.2 Cost 33288
\[\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -4.1 \cdot 10^{+117}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{-a}{d}\right)\\
\mathbf{elif}\;d \leq 8.4 \cdot 10^{+43}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{d \cdot \left(-a\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{-a}{\mathsf{hypot}\left(d, c\right)}\right)\\
\end{array}
\]
Alternative 2 Error 7.5 Cost 20996
\[\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+250}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\
\end{array}
\]
Alternative 3 Error 9.1 Cost 14408
\[\begin{array}{l}
\mathbf{if}\;d \leq -6.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 8 \cdot 10^{+128}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)} - d \cdot \frac{a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{d}, \frac{c}{d}, \frac{-a}{d}\right)\\
\end{array}
\]
Alternative 4 Error 11.0 Cost 14288
\[\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -7 \cdot 10^{+113}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -4.1 \cdot 10^{-112}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{-166}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{\frac{c \cdot c}{d}}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+73}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{d}, \frac{c}{d}, \frac{-a}{d}\right)\\
\end{array}
\]
Alternative 5 Error 14.5 Cost 7436
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := d \cdot \frac{a}{t_0}\\
\mathbf{if}\;d \leq -4.25 \cdot 10^{+43}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 9.6 \cdot 10^{-136}:\\
\;\;\;\;\frac{b}{c} - t_1\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+73}:\\
\;\;\;\;\frac{c \cdot b}{t_0} - t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{d}, \frac{c}{d}, \frac{-a}{d}\right)\\
\end{array}
\]
Alternative 6 Error 14.6 Cost 1868
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := d \cdot \frac{a}{t_0}\\
t_2 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -1.42 \cdot 10^{+44}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq 9.6 \cdot 10^{-136}:\\
\;\;\;\;\frac{b}{c} - t_1\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+73}:\\
\;\;\;\;\frac{c \cdot b}{t_0} - t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 7 Error 17.4 Cost 1496
\[\begin{array}{l}
t_0 := \frac{b}{c} - d \cdot \frac{a}{c \cdot c}\\
t_1 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -1.8 \cdot 10^{+36}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -7.2 \cdot 10^{-17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.25 \cdot 10^{-50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 8.4 \cdot 10^{-44}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.26 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;d \leq 9.8 \cdot 10^{-14}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\]
Alternative 8 Error 16.8 Cost 1496
\[\begin{array}{l}
t_0 := \frac{b}{c} - \frac{a}{\frac{c \cdot c}{d}}\\
t_1 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -9.6 \cdot 10^{+40}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -1.22 \cdot 10^{-17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -4.1 \cdot 10^{-50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{-42}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{-13}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{a}{c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\]
Alternative 9 Error 16.8 Cost 1496
\[\begin{array}{l}
t_0 := \frac{b}{c} - \frac{a}{\frac{c \cdot c}{d}}\\
t_1 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -4 \cdot 10^{+37}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -6.5 \cdot 10^{-17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.65 \cdot 10^{-50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 1.96 \cdot 10^{-42}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 9.5 \cdot 10^{-27}:\\
\;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{a}{c \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\]
Alternative 10 Error 15.8 Cost 1488
\[\begin{array}{l}
t_0 := \frac{b}{c} - d \cdot \frac{a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.45 \cdot 10^{+44}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 1.96 \cdot 10^{-42}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 7.6 \cdot 10^{-27}:\\
\;\;\;\;\frac{b}{d \cdot \frac{d}{c}} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 1.1 \cdot 10^{-13}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\]
Alternative 11 Error 14.5 Cost 1356
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -7.2 \cdot 10^{+39}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 8.2 \cdot 10^{-134}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{a}{t_0}\\
\mathbf{elif}\;d \leq 9 \cdot 10^{+72}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 12 Error 19.0 Cost 1104
\[\begin{array}{l}
t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -5.4 \cdot 10^{+39}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 4.9 \cdot 10^{-45}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 1.26 \cdot 10^{-26}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 13 Error 19.0 Cost 1104
\[\begin{array}{l}
t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -1.8 \cdot 10^{+37}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{-44}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 7.6 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;d \leq 1.06 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 14 Error 19.2 Cost 1104
\[\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{+40}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq 3.6 \cdot 10^{-43}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 10^{-26}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;d \leq 9.8 \cdot 10^{-14}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\]
Alternative 15 Error 19.7 Cost 840
\[\begin{array}{l}
\mathbf{if}\;c \leq -2.25 \cdot 10^{+121}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.05 \cdot 10^{+88}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\]
Alternative 16 Error 22.8 Cost 520
\[\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -1 \cdot 10^{+36}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1150000:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 17 Error 37.7 Cost 192
\[\frac{b}{c}
\]