Math FPCore C Julia Wolfram TeX \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\]
↓
\[\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := x \cdot x - t_0\\
t_2 := \mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\
\mathbf{if}\;x \leq -1.6 \cdot 10^{+101}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq -1.12 \cdot 10^{-94}:\\
\;\;\;\;\frac{t_1}{\mathsf{fma}\left(y \cdot 4, y, x \cdot x\right)}\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-79}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x \cdot \frac{x}{y}}{y}, -1\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+31}:\\
\;\;\;\;\frac{t_1}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
(FPCore (x y)
:precision binary64
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y)))) ↓
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (* y 4.0)))
(t_1 (- (* x x) t_0))
(t_2 (fma (* (/ y x) (/ y x)) -8.0 1.0)))
(if (<= x -1.6e+101)
t_2
(if (<= x -1.12e-94)
(/ t_1 (fma (* y 4.0) y (* x x)))
(if (<= x 1.2e-79)
(fma 0.5 (/ (* x (/ x y)) y) -1.0)
(if (<= x 8e+31) (/ t_1 (+ (* x x) t_0)) t_2)))))) double code(double x, double y) {
return ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y));
}
↓
double code(double x, double y) {
double t_0 = y * (y * 4.0);
double t_1 = (x * x) - t_0;
double t_2 = fma(((y / x) * (y / x)), -8.0, 1.0);
double tmp;
if (x <= -1.6e+101) {
tmp = t_2;
} else if (x <= -1.12e-94) {
tmp = t_1 / fma((y * 4.0), y, (x * x));
} else if (x <= 1.2e-79) {
tmp = fma(0.5, ((x * (x / y)) / y), -1.0);
} else if (x <= 8e+31) {
tmp = t_1 / ((x * x) + t_0);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y)
return Float64(Float64(Float64(x * x) - Float64(Float64(y * 4.0) * y)) / Float64(Float64(x * x) + Float64(Float64(y * 4.0) * y)))
end
↓
function code(x, y)
t_0 = Float64(y * Float64(y * 4.0))
t_1 = Float64(Float64(x * x) - t_0)
t_2 = fma(Float64(Float64(y / x) * Float64(y / x)), -8.0, 1.0)
tmp = 0.0
if (x <= -1.6e+101)
tmp = t_2;
elseif (x <= -1.12e-94)
tmp = Float64(t_1 / fma(Float64(y * 4.0), y, Float64(x * x)));
elseif (x <= 1.2e-79)
tmp = fma(0.5, Float64(Float64(x * Float64(x / y)) / y), -1.0);
elseif (x <= 8e+31)
tmp = Float64(t_1 / Float64(Float64(x * x) + t_0));
else
tmp = t_2;
end
return tmp
end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[x_, y_] := Block[{t$95$0 = N[(y * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] * -8.0 + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.6e+101], t$95$2, If[LessEqual[x, -1.12e-94], N[(t$95$1 / N[(N[(y * 4.0), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.2e-79], N[(0.5 * N[(N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[x, 8e+31], N[(t$95$1 / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
↓
\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := x \cdot x - t_0\\
t_2 := \mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\
\mathbf{if}\;x \leq -1.6 \cdot 10^{+101}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq -1.12 \cdot 10^{-94}:\\
\;\;\;\;\frac{t_1}{\mathsf{fma}\left(y \cdot 4, y, x \cdot x\right)}\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-79}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x \cdot \frac{x}{y}}{y}, -1\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+31}:\\
\;\;\;\;\frac{t_1}{x \cdot x + t_0}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
Alternatives Alternative 1 Error 12.5 Cost 7504
\[\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\
t_2 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{+101}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.9 \cdot 10^{-106}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-79}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x \cdot \frac{x}{y}}{y}, -1\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+31}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 2 Error 12.7 Cost 7372
\[\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{+101}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-112}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{-80}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{x \cdot \frac{x}{y}}{y}, -1\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+31}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
Alternative 3 Error 12.9 Cost 1744
\[\begin{array}{l}
t_0 := y \cdot \left(y \cdot 4\right)\\
t_1 := \frac{x \cdot x - t_0}{x \cdot x + t_0}\\
\mathbf{if}\;x \leq -2.2 \cdot 10^{+101}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq -1.36 \cdot 10^{-95}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 10^{-79}:\\
\;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y \cdot 4}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+31}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
Alternative 4 Error 18.3 Cost 1232
\[\begin{array}{l}
t_0 := -1 + \frac{x}{y} \cdot \frac{x}{y \cdot 4}\\
\mathbf{if}\;y \leq -2 \cdot 10^{-65}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-138}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-23}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{+68}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 5 Error 18.5 Cost 592
\[\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-65}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-138}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10^{-24}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{+68}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\]
Alternative 6 Error 31.5 Cost 64
\[-1
\]