Math FPCore C Java Python Julia MATLAB Wolfram TeX \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\]
↓
\[\frac{a \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)} - \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{-\mathsf{hypot}\left(c, d\right)}
\]
(FPCore (a b c d)
:precision binary64
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))) ↓
(FPCore (a b c d)
:precision binary64
(/ (- (* a (/ d (hypot c d))) (/ b (/ (hypot c d) c))) (- (hypot c d)))) 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 ((a * (d / hypot(c, d))) - (b / (hypot(c, d) / c))) / -hypot(c, d);
}
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 ((a * (d / Math.hypot(c, d))) - (b / (Math.hypot(c, d) / c))) / -Math.hypot(c, d);
}
def code(a, b, c, d):
return ((b * c) - (a * d)) / ((c * c) + (d * d))
↓
def code(a, b, c, d):
return ((a * (d / math.hypot(c, d))) - (b / (math.hypot(c, d) / c))) / -math.hypot(c, d)
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(Float64(a * Float64(d / hypot(c, d))) - Float64(b / Float64(hypot(c, d) / c))) / Float64(-hypot(c, d)))
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 = ((a * (d / hypot(c, d))) - (b / (hypot(c, d) / c))) / -hypot(c, d);
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[(N[(a * N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])), $MachinePrecision]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
↓
\frac{a \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)} - \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{-\mathsf{hypot}\left(c, d\right)}
Alternatives Alternative 1 Accuracy 87.3% Cost 14788
\[\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := c \cdot b - a \cdot d\\
\mathbf{if}\;\frac{t_1}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+244}:\\
\;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(b - \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\
\end{array}
\]
Alternative 2 Accuracy 83.3% Cost 13896
\[\begin{array}{l}
\mathbf{if}\;c \leq -2 \cdot 10^{-173}:\\
\;\;\;\;\left(b + a \cdot \frac{d}{\mathsf{hypot}\left(c, d\right)}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq 4.2 \cdot 10^{-141}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\
\end{array}
\]
Alternative 3 Accuracy 83.3% Cost 13896
\[\begin{array}{l}
t_0 := \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\mathbf{if}\;c \leq -2 \cdot 10^{-173}:\\
\;\;\;\;\left(b + t_0\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq 3.4 \cdot 10^{-142}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - t_0\right)\\
\end{array}
\]
Alternative 4 Accuracy 81.7% Cost 2000
\[\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := b \cdot \frac{c}{t_0} - \frac{a \cdot d}{t_0}\\
t_2 := \frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{if}\;d \leq -2.1 \cdot 10^{+152}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq -1.75 \cdot 10^{-91}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 3.2 \cdot 10^{-99}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;d \leq 1.66 \cdot 10^{+97}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 5 Accuracy 81.1% Cost 1488
\[\begin{array}{l}
t_0 := \frac{c \cdot b - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{if}\;d \leq -1.2 \cdot 10^{+152}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -1.7 \cdot 10^{-90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{-96}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;d \leq 3 \cdot 10^{+97}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 6 Accuracy 75.5% Cost 1032
\[\begin{array}{l}
t_0 := \frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\mathbf{if}\;d \leq -1.25 \cdot 10^{+152}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -5.8 \cdot 10^{-11}:\\
\;\;\;\;\frac{-a}{\frac{c \cdot c + d \cdot d}{d}}\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{+58}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 7 Accuracy 76.1% Cost 968
\[\begin{array}{l}
\mathbf{if}\;c \leq -270000:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{-42}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\end{array}
\]
Alternative 8 Accuracy 69.7% Cost 841
\[\begin{array}{l}
\mathbf{if}\;c \leq -6.6 \cdot 10^{-14} \lor \neg \left(c \leq 4 \cdot 10^{-42}\right):\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\]
Alternative 9 Accuracy 75.5% Cost 841
\[\begin{array}{l}
\mathbf{if}\;c \leq -0.015 \lor \neg \left(c \leq 4.5 \cdot 10^{-42}\right):\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{d}\\
\end{array}
\]
Alternative 10 Accuracy 76.2% Cost 841
\[\begin{array}{l}
\mathbf{if}\;c \leq -400000000 \lor \neg \left(c \leq 3.5 \cdot 10^{-42}\right):\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\end{array}
\]
Alternative 11 Accuracy 63.3% Cost 520
\[\begin{array}{l}
\mathbf{if}\;c \leq -4100000000:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{-22}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\]
Alternative 12 Accuracy 40.9% Cost 192
\[\frac{b}{c}
\]