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 Accuracy 88.9% Cost 15816
\[\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := c \cdot c + d \cdot d\\
t_3 := \frac{t_0}{t_2}\\
\mathbf{if}\;t_3 \leq -2 \cdot 10^{+240}:\\
\;\;\;\;\frac{c}{\frac{t_2}{b}} - \frac{a}{\frac{t_2}{d}}\\
\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+274}:\\
\;\;\;\;t_1 \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b - \frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot a\right)\\
\end{array}
\]
Alternative 2 Accuracy 83.5% Cost 14028
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -1.16 \cdot 10^{+107}:\\
\;\;\;\;t_1 \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;c \leq -2.05 \cdot 10^{-153}:\\
\;\;\;\;\frac{c}{\frac{t_0}{b}} - \frac{a}{\frac{t_0}{d}}\\
\mathbf{elif}\;c \leq 1.42 \cdot 10^{-83}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b - \frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot a\right)\\
\end{array}
\]
Alternative 3 Accuracy 79.9% Cost 7500
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;d \leq -5 \cdot 10^{+156}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -2.2 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{\frac{t_0}{b}} - \frac{a}{\frac{t_0}{d}}\\
\mathbf{elif}\;d \leq 56000000:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{\frac{a}{\frac{c}{d}}}{c}, \frac{b}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\]
Alternative 4 Accuracy 79.6% Cost 1736
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;d \leq -3 \cdot 10^{+151}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -1.6 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{\frac{t_0}{b}} - \frac{a}{\frac{t_0}{d}}\\
\mathbf{elif}\;d \leq 3100:\\
\;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\]
Alternative 5 Accuracy 78.7% Cost 1224
\[\begin{array}{l}
t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -1.55 \cdot 10^{+69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -2.9 \cdot 10^{-142}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 30500:\\
\;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 6 Accuracy 69.2% Cost 841
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.32 \cdot 10^{-36} \lor \neg \left(d \leq 16000000000\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\
\end{array}
\]
Alternative 7 Accuracy 75.6% Cost 841
\[\begin{array}{l}
\mathbf{if}\;d \leq -5 \cdot 10^{-37} \lor \neg \left(d \leq 15000\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\
\end{array}
\]
Alternative 8 Accuracy 63.4% Cost 521
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.95 \cdot 10^{-38} \lor \neg \left(d \leq 1.7 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\]
Alternative 9 Accuracy 14.0% Cost 456
\[\begin{array}{l}
\mathbf{if}\;d \leq -8.5 \cdot 10^{+60}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{elif}\;d \leq 4.7 \cdot 10^{+37}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\]
Alternative 10 Accuracy 45.5% Cost 456
\[\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{+116}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{elif}\;d \leq 5.4 \cdot 10^{+164}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\]
Alternative 11 Accuracy 8.3% Cost 192
\[\frac{a}{c}
\]