\[\left(0 < x \land x < 1\right) \land y < 1\]
Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{-67}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -2.35 \cdot 10^{-156} \lor \neg \left(y \leq 1.55 \cdot 10^{-162}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{x + y}{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
\]
(FPCore (x y) :precision binary64 (/ (* (- x y) (+ x y)) (+ (* x x) (* y y)))) ↓
(FPCore (x y)
:precision binary64
(if (<= y -4.7e-67)
-1.0
(if (or (<= y -2.35e-156) (not (<= y 1.55e-162)))
(* (- x y) (/ (+ x y) (+ (* x x) (* y y))))
(+ 1.0 (* -2.0 (* (/ y x) (/ y x))))))) double code(double x, double y) {
return ((x - y) * (x + y)) / ((x * x) + (y * y));
}
↓
double code(double x, double y) {
double tmp;
if (y <= -4.7e-67) {
tmp = -1.0;
} else if ((y <= -2.35e-156) || !(y <= 1.55e-162)) {
tmp = (x - y) * ((x + y) / ((x * x) + (y * y)));
} else {
tmp = 1.0 + (-2.0 * ((y / x) * (y / x)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x - y) * (x + y)) / ((x * x) + (y * y))
end function
↓
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-4.7d-67)) then
tmp = -1.0d0
else if ((y <= (-2.35d-156)) .or. (.not. (y <= 1.55d-162))) then
tmp = (x - y) * ((x + y) / ((x * x) + (y * y)))
else
tmp = 1.0d0 + ((-2.0d0) * ((y / x) * (y / x)))
end if
code = tmp
end function
public static double code(double x, double y) {
return ((x - y) * (x + y)) / ((x * x) + (y * y));
}
↓
public static double code(double x, double y) {
double tmp;
if (y <= -4.7e-67) {
tmp = -1.0;
} else if ((y <= -2.35e-156) || !(y <= 1.55e-162)) {
tmp = (x - y) * ((x + y) / ((x * x) + (y * y)));
} else {
tmp = 1.0 + (-2.0 * ((y / x) * (y / x)));
}
return tmp;
}
def code(x, y):
return ((x - y) * (x + y)) / ((x * x) + (y * y))
↓
def code(x, y):
tmp = 0
if y <= -4.7e-67:
tmp = -1.0
elif (y <= -2.35e-156) or not (y <= 1.55e-162):
tmp = (x - y) * ((x + y) / ((x * x) + (y * y)))
else:
tmp = 1.0 + (-2.0 * ((y / x) * (y / x)))
return tmp
function code(x, y)
return Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y)))
end
↓
function code(x, y)
tmp = 0.0
if (y <= -4.7e-67)
tmp = -1.0;
elseif ((y <= -2.35e-156) || !(y <= 1.55e-162))
tmp = Float64(Float64(x - y) * Float64(Float64(x + y) / Float64(Float64(x * x) + Float64(y * y))));
else
tmp = Float64(1.0 + Float64(-2.0 * Float64(Float64(y / x) * Float64(y / x))));
end
return tmp
end
function tmp = code(x, y)
tmp = ((x - y) * (x + y)) / ((x * x) + (y * y));
end
↓
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= -4.7e-67)
tmp = -1.0;
elseif ((y <= -2.35e-156) || ~((y <= 1.55e-162)))
tmp = (x - y) * ((x + y) / ((x * x) + (y * y)));
else
tmp = 1.0 + (-2.0 * ((y / x) * (y / x)));
end
tmp_2 = tmp;
end
code[x_, y_] := N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[x_, y_] := If[LessEqual[y, -4.7e-67], -1.0, If[Or[LessEqual[y, -2.35e-156], N[Not[LessEqual[y, 1.55e-162]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-2.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
↓
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{-67}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -2.35 \cdot 10^{-156} \lor \neg \left(y \leq 1.55 \cdot 10^{-162}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{x + y}{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
Alternatives Alternative 1 Accuracy 91.6% Cost 1357
\[\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{-67}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -2.35 \cdot 10^{-156} \lor \neg \left(y \leq 1.55 \cdot 10^{-162}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{x + y}{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
\]
Alternative 2 Accuracy 92.8% Cost 8004
\[\begin{array}{l}
t_0 := \frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{if}\;t_0 \leq 2:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\
\end{array}
\]
Alternative 3 Accuracy 92.6% Cost 1988
\[\begin{array}{l}
t_0 := \frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{if}\;t_0 \leq 2:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \frac{x + y}{y}}{y}\\
\end{array}
\]
Alternative 4 Accuracy 80.9% Cost 1371
\[\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-136} \lor \neg \left(y \leq -8.5 \cdot 10^{-169}\right) \land \left(y \leq -5.4 \cdot 10^{-233} \lor \neg \left(y \leq 6 \cdot 10^{-171}\right) \land \left(y \leq 2.9 \cdot 10^{-142} \lor \neg \left(y \leq 1.82 \cdot 10^{-121}\right)\right)\right):\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + -1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
Alternative 5 Accuracy 80.9% Cost 1370
\[\begin{array}{l}
t_0 := \frac{x}{y} \cdot \frac{x}{y} + -1\\
\mathbf{if}\;y \leq -6.6 \cdot 10^{-136}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-167}:\\
\;\;\;\;1 - \frac{y \cdot y}{x \cdot x}\\
\mathbf{elif}\;\neg \left(y \leq -5.4 \cdot 10^{-233}\right) \land \left(y \leq 7.2 \cdot 10^{-171} \lor \neg \left(y \leq 2.1 \cdot 10^{-143}\right) \land y \leq 1.85 \cdot 10^{-120}\right):\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
Alternative 6 Accuracy 83.7% Cost 969
\[\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{-136} \lor \neg \left(y \leq 1.2 \cdot 10^{-121}\right):\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + -1\\
\mathbf{else}:\\
\;\;\;\;1 + -2 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\end{array}
\]
Alternative 7 Accuracy 83.7% Cost 968
\[\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{-135}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + -1\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-121}:\\
\;\;\;\;1 + -2 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{y \cdot y}\\
\end{array}
\]
Alternative 8 Accuracy 83.7% Cost 968
\[\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-136}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + -1\\
\mathbf{elif}\;y \leq 4.7 \cdot 10^{-120}:\\
\;\;\;\;1 + -2 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \frac{x + y}{y}}{y}\\
\end{array}
\]
Alternative 9 Accuracy 82.7% Cost 328
\[\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{-136}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-121}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\]
Alternative 10 Accuracy 66.7% Cost 64
\[-1
\]