
(FPCore (x y) :precision binary64 (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))
double code(double x, double y) {
return ((x - y) * (x + y)) / ((x * x) + (y * y));
}
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
public static double code(double x, double y) {
return ((x - y) * (x + y)) / ((x * x) + (y * y));
}
def code(x, y): return ((x - y) * (x + y)) / ((x * x) + (y * y))
function code(x, y) return Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y))) end
function tmp = code(x, y) tmp = ((x - y) * (x + y)) / ((x * x) + (y * y)); 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]
\begin{array}{l}
\\
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))
double code(double x, double y) {
return ((x - y) * (x + y)) / ((x * x) + (y * y));
}
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
public static double code(double x, double y) {
return ((x - y) * (x + y)) / ((x * x) + (y * y));
}
def code(x, y): return ((x - y) * (x + y)) / ((x * x) + (y * y))
function code(x, y) return Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y))) end
function tmp = code(x, y) tmp = ((x - y) * (x + y)) / ((x * x) + (y * y)); 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]
\begin{array}{l}
\\
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\end{array}
(FPCore (x y) :precision binary64 (* (/ (- x y) (hypot x y)) (/ (+ x y) (hypot x y))))
double code(double x, double y) {
return ((x - y) / hypot(x, y)) * ((x + y) / hypot(x, y));
}
public static double code(double x, double y) {
return ((x - y) / Math.hypot(x, y)) * ((x + y) / Math.hypot(x, y));
}
def code(x, y): return ((x - y) / math.hypot(x, y)) * ((x + y) / math.hypot(x, y))
function code(x, y) return Float64(Float64(Float64(x - y) / hypot(x, y)) * Float64(Float64(x + y) / hypot(x, y))) end
function tmp = code(x, y) tmp = ((x - y) / hypot(x, y)) * ((x + y) / hypot(x, y)); end
code[x_, y_] := N[(N[(N[(x - y), $MachinePrecision] / N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] / N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(x, y\right)}
\end{array}
Initial program 65.6%
fma-define65.6%
add-sqr-sqrt65.6%
times-frac65.6%
fma-define65.6%
hypot-define65.6%
fma-define65.6%
hypot-define99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y 9e-205)
(- 1.0 (/ (* 2.0 (* y (/ y x))) x))
(if (<= y 2.25e-175)
(fma 2.0 (/ (/ x y) (/ y x)) -1.0)
(if (<= y 1e-22) (/ (* (- x y) (+ x y)) (fma x x (pow y 2.0))) -1.0))))
double code(double x, double y) {
double tmp;
if (y <= 9e-205) {
tmp = 1.0 - ((2.0 * (y * (y / x))) / x);
} else if (y <= 2.25e-175) {
tmp = fma(2.0, ((x / y) / (y / x)), -1.0);
} else if (y <= 1e-22) {
tmp = ((x - y) * (x + y)) / fma(x, x, pow(y, 2.0));
} else {
tmp = -1.0;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= 9e-205) tmp = Float64(1.0 - Float64(Float64(2.0 * Float64(y * Float64(y / x))) / x)); elseif (y <= 2.25e-175) tmp = fma(2.0, Float64(Float64(x / y) / Float64(y / x)), -1.0); elseif (y <= 1e-22) tmp = Float64(Float64(Float64(x - y) * Float64(x + y)) / fma(x, x, (y ^ 2.0))); else tmp = -1.0; end return tmp end
code[x_, y_] := If[LessEqual[y, 9e-205], N[(1.0 - N[(N[(2.0 * N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.25e-175], N[(2.0 * N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, 1e-22], N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(x * x + N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-205}:\\
\;\;\;\;1 - \frac{2 \cdot \left(y \cdot \frac{y}{x}\right)}{x}\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{-175}:\\
\;\;\;\;\mathsf{fma}\left(2, \frac{\frac{x}{y}}{\frac{y}{x}}, -1\right)\\
\mathbf{elif}\;y \leq 10^{-22}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{\mathsf{fma}\left(x, x, {y}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 8.99999999999999912e-205Initial program 58.4%
associate-/l*58.3%
fma-define58.3%
Simplified58.3%
Taylor expanded in x around -inf 35.8%
Simplified36.3%
Taylor expanded in y around 0 36.3%
unpow236.3%
associate-/l*36.9%
Applied egg-rr36.9%
if 8.99999999999999912e-205 < y < 2.24999999999999999e-175Initial program 14.3%
fma-define14.3%
add-sqr-sqrt14.3%
times-frac17.0%
fma-define17.0%
hypot-define17.0%
fma-define17.0%
hypot-define99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 0.4%
fma-neg0.4%
unpow20.4%
unpow20.4%
times-frac86.3%
unpow286.3%
metadata-eval86.3%
Simplified86.3%
unpow286.3%
clear-num86.3%
un-div-inv86.3%
Applied egg-rr86.3%
if 2.24999999999999999e-175 < y < 1e-22Initial program 97.7%
fma-define97.8%
pow297.8%
Applied egg-rr97.8%
if 1e-22 < y Initial program 100.0%
associate-/l*99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in x around 0 100.0%
Final simplification51.2%
(FPCore (x y)
:precision binary64
(if (<= y 9e-205)
(- 1.0 (/ (* 2.0 (* y (/ y x))) x))
(if (<= y 6.8e-176)
(fma 2.0 (/ (/ x y) (/ y x)) -1.0)
(if (<= y 3.1e-19) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) -1.0))))
double code(double x, double y) {
double tmp;
if (y <= 9e-205) {
tmp = 1.0 - ((2.0 * (y * (y / x))) / x);
} else if (y <= 6.8e-176) {
tmp = fma(2.0, ((x / y) / (y / x)), -1.0);
} else if (y <= 3.1e-19) {
tmp = ((x - y) * (x + y)) / ((x * x) + (y * y));
} else {
tmp = -1.0;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (y <= 9e-205) tmp = Float64(1.0 - Float64(Float64(2.0 * Float64(y * Float64(y / x))) / x)); elseif (y <= 6.8e-176) tmp = fma(2.0, Float64(Float64(x / y) / Float64(y / x)), -1.0); elseif (y <= 3.1e-19) tmp = Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y))); else tmp = -1.0; end return tmp end
code[x_, y_] := If[LessEqual[y, 9e-205], N[(1.0 - N[(N[(2.0 * N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.8e-176], N[(2.0 * N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[y, 3.1e-19], N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-205}:\\
\;\;\;\;1 - \frac{2 \cdot \left(y \cdot \frac{y}{x}\right)}{x}\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{-176}:\\
\;\;\;\;\mathsf{fma}\left(2, \frac{\frac{x}{y}}{\frac{y}{x}}, -1\right)\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{-19}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 8.99999999999999912e-205Initial program 58.4%
associate-/l*58.3%
fma-define58.3%
Simplified58.3%
Taylor expanded in x around -inf 35.8%
Simplified36.3%
Taylor expanded in y around 0 36.3%
unpow236.3%
associate-/l*36.9%
Applied egg-rr36.9%
if 8.99999999999999912e-205 < y < 6.7999999999999994e-176Initial program 14.3%
fma-define14.3%
add-sqr-sqrt14.3%
times-frac17.0%
fma-define17.0%
hypot-define17.0%
fma-define17.0%
hypot-define99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 0.4%
fma-neg0.4%
unpow20.4%
unpow20.4%
times-frac86.3%
unpow286.3%
metadata-eval86.3%
Simplified86.3%
unpow286.3%
clear-num86.3%
un-div-inv86.3%
Applied egg-rr86.3%
if 6.7999999999999994e-176 < y < 3.0999999999999999e-19Initial program 97.7%
if 3.0999999999999999e-19 < y Initial program 100.0%
associate-/l*99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in x around 0 100.0%
Final simplification51.2%
(FPCore (x y)
:precision binary64
(if (<= y 9e-205)
(- 1.0 (/ (* 2.0 (* y (/ y x))) x))
(if (<= y 5.4e-175)
(/ (- x y) (+ y (* x (+ (/ x y) -1.0))))
(if (<= y 2e-19) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) -1.0))))
double code(double x, double y) {
double tmp;
if (y <= 9e-205) {
tmp = 1.0 - ((2.0 * (y * (y / x))) / x);
} else if (y <= 5.4e-175) {
tmp = (x - y) / (y + (x * ((x / y) + -1.0)));
} else if (y <= 2e-19) {
tmp = ((x - y) * (x + y)) / ((x * x) + (y * y));
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 9d-205) then
tmp = 1.0d0 - ((2.0d0 * (y * (y / x))) / x)
else if (y <= 5.4d-175) then
tmp = (x - y) / (y + (x * ((x / y) + (-1.0d0))))
else if (y <= 2d-19) then
tmp = ((x - y) * (x + y)) / ((x * x) + (y * y))
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 9e-205) {
tmp = 1.0 - ((2.0 * (y * (y / x))) / x);
} else if (y <= 5.4e-175) {
tmp = (x - y) / (y + (x * ((x / y) + -1.0)));
} else if (y <= 2e-19) {
tmp = ((x - y) * (x + y)) / ((x * x) + (y * y));
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 9e-205: tmp = 1.0 - ((2.0 * (y * (y / x))) / x) elif y <= 5.4e-175: tmp = (x - y) / (y + (x * ((x / y) + -1.0))) elif y <= 2e-19: tmp = ((x - y) * (x + y)) / ((x * x) + (y * y)) else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 9e-205) tmp = Float64(1.0 - Float64(Float64(2.0 * Float64(y * Float64(y / x))) / x)); elseif (y <= 5.4e-175) tmp = Float64(Float64(x - y) / Float64(y + Float64(x * Float64(Float64(x / y) + -1.0)))); elseif (y <= 2e-19) tmp = Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y))); else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 9e-205) tmp = 1.0 - ((2.0 * (y * (y / x))) / x); elseif (y <= 5.4e-175) tmp = (x - y) / (y + (x * ((x / y) + -1.0))); elseif (y <= 2e-19) tmp = ((x - y) * (x + y)) / ((x * x) + (y * y)); else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 9e-205], N[(1.0 - N[(N[(2.0 * N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.4e-175], N[(N[(x - y), $MachinePrecision] / N[(y + N[(x * N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2e-19], N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-205}:\\
\;\;\;\;1 - \frac{2 \cdot \left(y \cdot \frac{y}{x}\right)}{x}\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{-175}:\\
\;\;\;\;\frac{x - y}{y + x \cdot \left(\frac{x}{y} + -1\right)}\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 8.99999999999999912e-205Initial program 58.4%
associate-/l*58.3%
fma-define58.3%
Simplified58.3%
Taylor expanded in x around -inf 35.8%
Simplified36.3%
Taylor expanded in y around 0 36.3%
unpow236.3%
associate-/l*36.9%
Applied egg-rr36.9%
if 8.99999999999999912e-205 < y < 5.39999999999999998e-175Initial program 14.3%
associate-/l*17.0%
fma-define17.0%
Simplified17.0%
Taylor expanded in y around inf 83.5%
Taylor expanded in y around 0 83.5%
clear-num83.5%
un-div-inv84.0%
div-inv84.0%
clear-num84.0%
Applied egg-rr84.0%
Taylor expanded in x around 0 84.2%
if 5.39999999999999998e-175 < y < 2e-19Initial program 97.7%
if 2e-19 < y Initial program 100.0%
associate-/l*99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in x around 0 100.0%
Final simplification51.1%
(FPCore (x y) :precision binary64 (if (or (<= y 8.5e-205) (and (not (<= y 9e-175)) (<= y 4.5e-168))) (- 1.0 (/ (* 2.0 (* y (/ y x))) x)) (/ (- x y) (+ y (* x (+ (/ x y) -1.0))))))
double code(double x, double y) {
double tmp;
if ((y <= 8.5e-205) || (!(y <= 9e-175) && (y <= 4.5e-168))) {
tmp = 1.0 - ((2.0 * (y * (y / x))) / x);
} else {
tmp = (x - y) / (y + (x * ((x / y) + -1.0)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= 8.5d-205) .or. (.not. (y <= 9d-175)) .and. (y <= 4.5d-168)) then
tmp = 1.0d0 - ((2.0d0 * (y * (y / x))) / x)
else
tmp = (x - y) / (y + (x * ((x / y) + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= 8.5e-205) || (!(y <= 9e-175) && (y <= 4.5e-168))) {
tmp = 1.0 - ((2.0 * (y * (y / x))) / x);
} else {
tmp = (x - y) / (y + (x * ((x / y) + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= 8.5e-205) or (not (y <= 9e-175) and (y <= 4.5e-168)): tmp = 1.0 - ((2.0 * (y * (y / x))) / x) else: tmp = (x - y) / (y + (x * ((x / y) + -1.0))) return tmp
function code(x, y) tmp = 0.0 if ((y <= 8.5e-205) || (!(y <= 9e-175) && (y <= 4.5e-168))) tmp = Float64(1.0 - Float64(Float64(2.0 * Float64(y * Float64(y / x))) / x)); else tmp = Float64(Float64(x - y) / Float64(y + Float64(x * Float64(Float64(x / y) + -1.0)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 8.5e-205) || (~((y <= 9e-175)) && (y <= 4.5e-168))) tmp = 1.0 - ((2.0 * (y * (y / x))) / x); else tmp = (x - y) / (y + (x * ((x / y) + -1.0))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 8.5e-205], And[N[Not[LessEqual[y, 9e-175]], $MachinePrecision], LessEqual[y, 4.5e-168]]], N[(1.0 - N[(N[(2.0 * N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(y + N[(x * N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.5 \cdot 10^{-205} \lor \neg \left(y \leq 9 \cdot 10^{-175}\right) \land y \leq 4.5 \cdot 10^{-168}:\\
\;\;\;\;1 - \frac{2 \cdot \left(y \cdot \frac{y}{x}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{y + x \cdot \left(\frac{x}{y} + -1\right)}\\
\end{array}
\end{array}
if y < 8.5000000000000005e-205 or 8.99999999999999996e-175 < y < 4.5000000000000001e-168Initial program 58.6%
associate-/l*58.4%
fma-define58.4%
Simplified58.4%
Taylor expanded in x around -inf 36.2%
Simplified36.8%
Taylor expanded in y around 0 36.8%
unpow236.8%
associate-/l*37.4%
Applied egg-rr37.4%
if 8.5000000000000005e-205 < y < 8.99999999999999996e-175 or 4.5000000000000001e-168 < y Initial program 89.6%
associate-/l*88.9%
fma-define88.9%
Simplified88.9%
Taylor expanded in y around inf 71.8%
Taylor expanded in y around 0 71.8%
clear-num71.8%
un-div-inv71.9%
div-inv71.9%
clear-num71.9%
Applied egg-rr71.9%
Taylor expanded in x around 0 72.3%
Final simplification45.4%
(FPCore (x y)
:precision binary64
(if (<= y 9e-205)
1.0
(if (or (<= y 1.5e-174) (not (<= y 4.4e-168)))
(* (- x y) (/ (+ 1.0 (/ x y)) y))
1.0)))
double code(double x, double y) {
double tmp;
if (y <= 9e-205) {
tmp = 1.0;
} else if ((y <= 1.5e-174) || !(y <= 4.4e-168)) {
tmp = (x - y) * ((1.0 + (x / y)) / y);
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 9d-205) then
tmp = 1.0d0
else if ((y <= 1.5d-174) .or. (.not. (y <= 4.4d-168))) then
tmp = (x - y) * ((1.0d0 + (x / y)) / y)
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 9e-205) {
tmp = 1.0;
} else if ((y <= 1.5e-174) || !(y <= 4.4e-168)) {
tmp = (x - y) * ((1.0 + (x / y)) / y);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 9e-205: tmp = 1.0 elif (y <= 1.5e-174) or not (y <= 4.4e-168): tmp = (x - y) * ((1.0 + (x / y)) / y) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 9e-205) tmp = 1.0; elseif ((y <= 1.5e-174) || !(y <= 4.4e-168)) tmp = Float64(Float64(x - y) * Float64(Float64(1.0 + Float64(x / y)) / y)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 9e-205) tmp = 1.0; elseif ((y <= 1.5e-174) || ~((y <= 4.4e-168))) tmp = (x - y) * ((1.0 + (x / y)) / y); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 9e-205], 1.0, If[Or[LessEqual[y, 1.5e-174], N[Not[LessEqual[y, 4.4e-168]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-205}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-174} \lor \neg \left(y \leq 4.4 \cdot 10^{-168}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{1 + \frac{x}{y}}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < 8.99999999999999912e-205 or 1.50000000000000011e-174 < y < 4.3999999999999996e-168Initial program 58.6%
associate-/l*58.4%
fma-define58.4%
Simplified58.4%
Taylor expanded in x around inf 35.5%
if 8.99999999999999912e-205 < y < 1.50000000000000011e-174 or 4.3999999999999996e-168 < y Initial program 89.6%
associate-/l*88.9%
fma-define88.9%
Simplified88.9%
Taylor expanded in y around inf 71.8%
Final simplification43.7%
(FPCore (x y) :precision binary64 (if (or (<= y 9e-205) (and (not (<= y 8.8e-176)) (<= y 5.2e-168))) (* (- x y) (/ (+ 1.0 (/ y x)) x)) (* (- x y) (/ (+ 1.0 (/ x y)) y))))
double code(double x, double y) {
double tmp;
if ((y <= 9e-205) || (!(y <= 8.8e-176) && (y <= 5.2e-168))) {
tmp = (x - y) * ((1.0 + (y / x)) / x);
} else {
tmp = (x - y) * ((1.0 + (x / y)) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= 9d-205) .or. (.not. (y <= 8.8d-176)) .and. (y <= 5.2d-168)) then
tmp = (x - y) * ((1.0d0 + (y / x)) / x)
else
tmp = (x - y) * ((1.0d0 + (x / y)) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= 9e-205) || (!(y <= 8.8e-176) && (y <= 5.2e-168))) {
tmp = (x - y) * ((1.0 + (y / x)) / x);
} else {
tmp = (x - y) * ((1.0 + (x / y)) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= 9e-205) or (not (y <= 8.8e-176) and (y <= 5.2e-168)): tmp = (x - y) * ((1.0 + (y / x)) / x) else: tmp = (x - y) * ((1.0 + (x / y)) / y) return tmp
function code(x, y) tmp = 0.0 if ((y <= 9e-205) || (!(y <= 8.8e-176) && (y <= 5.2e-168))) tmp = Float64(Float64(x - y) * Float64(Float64(1.0 + Float64(y / x)) / x)); else tmp = Float64(Float64(x - y) * Float64(Float64(1.0 + Float64(x / y)) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 9e-205) || (~((y <= 8.8e-176)) && (y <= 5.2e-168))) tmp = (x - y) * ((1.0 + (y / x)) / x); else tmp = (x - y) * ((1.0 + (x / y)) / y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 9e-205], And[N[Not[LessEqual[y, 8.8e-176]], $MachinePrecision], LessEqual[y, 5.2e-168]]], N[(N[(x - y), $MachinePrecision] * N[(N[(1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-205} \lor \neg \left(y \leq 8.8 \cdot 10^{-176}\right) \land y \leq 5.2 \cdot 10^{-168}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{1 + \frac{y}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{1 + \frac{x}{y}}{y}\\
\end{array}
\end{array}
if y < 8.99999999999999912e-205 or 8.7999999999999994e-176 < y < 5.2000000000000002e-168Initial program 58.6%
associate-/l*58.4%
fma-define58.4%
Simplified58.4%
Taylor expanded in x around inf 37.1%
if 8.99999999999999912e-205 < y < 8.7999999999999994e-176 or 5.2000000000000002e-168 < y Initial program 89.6%
associate-/l*88.9%
fma-define88.9%
Simplified88.9%
Taylor expanded in y around inf 71.8%
Final simplification44.9%
(FPCore (x y) :precision binary64 (if (or (<= y 9e-205) (and (not (<= y 7.2e-175)) (<= y 4.8e-168))) (- 1.0 (/ (* 2.0 (* y (/ y x))) x)) (/ (- x y) (* y (/ y (+ x y))))))
double code(double x, double y) {
double tmp;
if ((y <= 9e-205) || (!(y <= 7.2e-175) && (y <= 4.8e-168))) {
tmp = 1.0 - ((2.0 * (y * (y / x))) / x);
} else {
tmp = (x - y) / (y * (y / (x + y)));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= 9d-205) .or. (.not. (y <= 7.2d-175)) .and. (y <= 4.8d-168)) then
tmp = 1.0d0 - ((2.0d0 * (y * (y / x))) / x)
else
tmp = (x - y) / (y * (y / (x + y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= 9e-205) || (!(y <= 7.2e-175) && (y <= 4.8e-168))) {
tmp = 1.0 - ((2.0 * (y * (y / x))) / x);
} else {
tmp = (x - y) / (y * (y / (x + y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= 9e-205) or (not (y <= 7.2e-175) and (y <= 4.8e-168)): tmp = 1.0 - ((2.0 * (y * (y / x))) / x) else: tmp = (x - y) / (y * (y / (x + y))) return tmp
function code(x, y) tmp = 0.0 if ((y <= 9e-205) || (!(y <= 7.2e-175) && (y <= 4.8e-168))) tmp = Float64(1.0 - Float64(Float64(2.0 * Float64(y * Float64(y / x))) / x)); else tmp = Float64(Float64(x - y) / Float64(y * Float64(y / Float64(x + y)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= 9e-205) || (~((y <= 7.2e-175)) && (y <= 4.8e-168))) tmp = 1.0 - ((2.0 * (y * (y / x))) / x); else tmp = (x - y) / (y * (y / (x + y))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, 9e-205], And[N[Not[LessEqual[y, 7.2e-175]], $MachinePrecision], LessEqual[y, 4.8e-168]]], N[(1.0 - N[(N[(2.0 * N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / N[(y * N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-205} \lor \neg \left(y \leq 7.2 \cdot 10^{-175}\right) \land y \leq 4.8 \cdot 10^{-168}:\\
\;\;\;\;1 - \frac{2 \cdot \left(y \cdot \frac{y}{x}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{y \cdot \frac{y}{x + y}}\\
\end{array}
\end{array}
if y < 8.99999999999999912e-205 or 7.2e-175 < y < 4.7999999999999999e-168Initial program 58.6%
associate-/l*58.4%
fma-define58.4%
Simplified58.4%
Taylor expanded in x around -inf 36.2%
Simplified36.8%
Taylor expanded in y around 0 36.8%
unpow236.8%
associate-/l*37.4%
Applied egg-rr37.4%
if 8.99999999999999912e-205 < y < 7.2e-175 or 4.7999999999999999e-168 < y Initial program 89.6%
associate-/l*88.9%
fma-define88.9%
Simplified88.9%
Taylor expanded in y around inf 71.8%
Taylor expanded in y around 0 71.8%
clear-num71.8%
un-div-inv71.9%
div-inv71.9%
clear-num71.9%
Applied egg-rr71.9%
Final simplification45.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- x y) (/ (+ 1.0 (/ y x)) x))))
(if (<= y 9e-205)
t_0
(if (<= y 8.8e-176)
(* (- x y) (/ (+ 1.0 (/ x y)) y))
(if (<= y 4.4e-168) t_0 (* (- x y) (/ (/ (+ x y) y) y)))))))
double code(double x, double y) {
double t_0 = (x - y) * ((1.0 + (y / x)) / x);
double tmp;
if (y <= 9e-205) {
tmp = t_0;
} else if (y <= 8.8e-176) {
tmp = (x - y) * ((1.0 + (x / y)) / y);
} else if (y <= 4.4e-168) {
tmp = t_0;
} else {
tmp = (x - y) * (((x + y) / y) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (x - y) * ((1.0d0 + (y / x)) / x)
if (y <= 9d-205) then
tmp = t_0
else if (y <= 8.8d-176) then
tmp = (x - y) * ((1.0d0 + (x / y)) / y)
else if (y <= 4.4d-168) then
tmp = t_0
else
tmp = (x - y) * (((x + y) / y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x - y) * ((1.0 + (y / x)) / x);
double tmp;
if (y <= 9e-205) {
tmp = t_0;
} else if (y <= 8.8e-176) {
tmp = (x - y) * ((1.0 + (x / y)) / y);
} else if (y <= 4.4e-168) {
tmp = t_0;
} else {
tmp = (x - y) * (((x + y) / y) / y);
}
return tmp;
}
def code(x, y): t_0 = (x - y) * ((1.0 + (y / x)) / x) tmp = 0 if y <= 9e-205: tmp = t_0 elif y <= 8.8e-176: tmp = (x - y) * ((1.0 + (x / y)) / y) elif y <= 4.4e-168: tmp = t_0 else: tmp = (x - y) * (((x + y) / y) / y) return tmp
function code(x, y) t_0 = Float64(Float64(x - y) * Float64(Float64(1.0 + Float64(y / x)) / x)) tmp = 0.0 if (y <= 9e-205) tmp = t_0; elseif (y <= 8.8e-176) tmp = Float64(Float64(x - y) * Float64(Float64(1.0 + Float64(x / y)) / y)); elseif (y <= 4.4e-168) tmp = t_0; else tmp = Float64(Float64(x - y) * Float64(Float64(Float64(x + y) / y) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = (x - y) * ((1.0 + (y / x)) / x); tmp = 0.0; if (y <= 9e-205) tmp = t_0; elseif (y <= 8.8e-176) tmp = (x - y) * ((1.0 + (x / y)) / y); elseif (y <= 4.4e-168) tmp = t_0; else tmp = (x - y) * (((x + y) / y) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] * N[(N[(1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 9e-205], t$95$0, If[LessEqual[y, 8.8e-176], N[(N[(x - y), $MachinePrecision] * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.4e-168], t$95$0, N[(N[(x - y), $MachinePrecision] * N[(N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - y\right) \cdot \frac{1 + \frac{y}{x}}{x}\\
\mathbf{if}\;y \leq 9 \cdot 10^{-205}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{-176}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{1 + \frac{x}{y}}{y}\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-168}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{\frac{x + y}{y}}{y}\\
\end{array}
\end{array}
if y < 8.99999999999999912e-205 or 8.7999999999999994e-176 < y < 4.3999999999999996e-168Initial program 58.6%
associate-/l*58.4%
fma-define58.4%
Simplified58.4%
Taylor expanded in x around inf 37.1%
if 8.99999999999999912e-205 < y < 8.7999999999999994e-176Initial program 14.3%
associate-/l*17.0%
fma-define17.0%
Simplified17.0%
Taylor expanded in y around inf 83.5%
if 4.3999999999999996e-168 < y Initial program 99.9%
associate-/l*98.8%
fma-define98.8%
Simplified98.8%
Taylor expanded in y around inf 70.2%
Taylor expanded in y around 0 70.2%
Final simplification44.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* 2.0 (* y (/ y x))) x))))
(if (<= y 9e-205)
t_0
(if (<= y 8.2e-176)
(* (- x y) (/ (+ 1.0 (/ x y)) y))
(if (<= y 4.7e-168) t_0 (* (- x y) (/ (/ (+ x y) y) y)))))))
double code(double x, double y) {
double t_0 = 1.0 - ((2.0 * (y * (y / x))) / x);
double tmp;
if (y <= 9e-205) {
tmp = t_0;
} else if (y <= 8.2e-176) {
tmp = (x - y) * ((1.0 + (x / y)) / y);
} else if (y <= 4.7e-168) {
tmp = t_0;
} else {
tmp = (x - y) * (((x + y) / y) / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((2.0d0 * (y * (y / x))) / x)
if (y <= 9d-205) then
tmp = t_0
else if (y <= 8.2d-176) then
tmp = (x - y) * ((1.0d0 + (x / y)) / y)
else if (y <= 4.7d-168) then
tmp = t_0
else
tmp = (x - y) * (((x + y) / y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - ((2.0 * (y * (y / x))) / x);
double tmp;
if (y <= 9e-205) {
tmp = t_0;
} else if (y <= 8.2e-176) {
tmp = (x - y) * ((1.0 + (x / y)) / y);
} else if (y <= 4.7e-168) {
tmp = t_0;
} else {
tmp = (x - y) * (((x + y) / y) / y);
}
return tmp;
}
def code(x, y): t_0 = 1.0 - ((2.0 * (y * (y / x))) / x) tmp = 0 if y <= 9e-205: tmp = t_0 elif y <= 8.2e-176: tmp = (x - y) * ((1.0 + (x / y)) / y) elif y <= 4.7e-168: tmp = t_0 else: tmp = (x - y) * (((x + y) / y) / y) return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(Float64(2.0 * Float64(y * Float64(y / x))) / x)) tmp = 0.0 if (y <= 9e-205) tmp = t_0; elseif (y <= 8.2e-176) tmp = Float64(Float64(x - y) * Float64(Float64(1.0 + Float64(x / y)) / y)); elseif (y <= 4.7e-168) tmp = t_0; else tmp = Float64(Float64(x - y) * Float64(Float64(Float64(x + y) / y) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - ((2.0 * (y * (y / x))) / x); tmp = 0.0; if (y <= 9e-205) tmp = t_0; elseif (y <= 8.2e-176) tmp = (x - y) * ((1.0 + (x / y)) / y); elseif (y <= 4.7e-168) tmp = t_0; else tmp = (x - y) * (((x + y) / y) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(N[(2.0 * N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 9e-205], t$95$0, If[LessEqual[y, 8.2e-176], N[(N[(x - y), $MachinePrecision] * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.7e-168], t$95$0, N[(N[(x - y), $MachinePrecision] * N[(N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{2 \cdot \left(y \cdot \frac{y}{x}\right)}{x}\\
\mathbf{if}\;y \leq 9 \cdot 10^{-205}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{-176}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{1 + \frac{x}{y}}{y}\\
\mathbf{elif}\;y \leq 4.7 \cdot 10^{-168}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{\frac{x + y}{y}}{y}\\
\end{array}
\end{array}
if y < 8.99999999999999912e-205 or 8.2000000000000005e-176 < y < 4.70000000000000026e-168Initial program 58.6%
associate-/l*58.4%
fma-define58.4%
Simplified58.4%
Taylor expanded in x around -inf 36.2%
Simplified36.8%
Taylor expanded in y around 0 36.8%
unpow236.8%
associate-/l*37.4%
Applied egg-rr37.4%
if 8.99999999999999912e-205 < y < 8.2000000000000005e-176Initial program 14.3%
associate-/l*17.0%
fma-define17.0%
Simplified17.0%
Taylor expanded in y around inf 83.5%
if 4.70000000000000026e-168 < y Initial program 99.9%
associate-/l*98.8%
fma-define98.8%
Simplified98.8%
Taylor expanded in y around inf 70.2%
Taylor expanded in y around 0 70.2%
Final simplification45.2%
(FPCore (x y) :precision binary64 (if (<= y 9e-205) 1.0 (if (<= y 1e-175) -1.0 (if (<= y 4.4e-168) 1.0 -1.0))))
double code(double x, double y) {
double tmp;
if (y <= 9e-205) {
tmp = 1.0;
} else if (y <= 1e-175) {
tmp = -1.0;
} else if (y <= 4.4e-168) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 9d-205) then
tmp = 1.0d0
else if (y <= 1d-175) then
tmp = -1.0d0
else if (y <= 4.4d-168) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 9e-205) {
tmp = 1.0;
} else if (y <= 1e-175) {
tmp = -1.0;
} else if (y <= 4.4e-168) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 9e-205: tmp = 1.0 elif y <= 1e-175: tmp = -1.0 elif y <= 4.4e-168: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= 9e-205) tmp = 1.0; elseif (y <= 1e-175) tmp = -1.0; elseif (y <= 4.4e-168) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 9e-205) tmp = 1.0; elseif (y <= 1e-175) tmp = -1.0; elseif (y <= 4.4e-168) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 9e-205], 1.0, If[LessEqual[y, 1e-175], -1.0, If[LessEqual[y, 4.4e-168], 1.0, -1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9 \cdot 10^{-205}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10^{-175}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{-168}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 8.99999999999999912e-205 or 1e-175 < y < 4.3999999999999996e-168Initial program 58.6%
associate-/l*58.4%
fma-define58.4%
Simplified58.4%
Taylor expanded in x around inf 35.5%
if 8.99999999999999912e-205 < y < 1e-175 or 4.3999999999999996e-168 < y Initial program 89.6%
associate-/l*88.9%
fma-define88.9%
Simplified88.9%
Taylor expanded in x around 0 70.2%
Final simplification43.4%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 65.6%
associate-/l*65.4%
fma-define65.4%
Simplified65.4%
Taylor expanded in x around 0 66.2%
Final simplification66.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fabs (/ x y))))
(if (and (< 0.5 t_0) (< t_0 2.0))
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y)))
(- 1.0 (/ 2.0 (+ 1.0 (* (/ x y) (/ x y))))))))
double code(double x, double y) {
double t_0 = fabs((x / y));
double tmp;
if ((0.5 < t_0) && (t_0 < 2.0)) {
tmp = ((x - y) * (x + y)) / ((x * x) + (y * y));
} else {
tmp = 1.0 - (2.0 / (1.0 + ((x / y) * (x / y))));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = abs((x / y))
if ((0.5d0 < t_0) .and. (t_0 < 2.0d0)) then
tmp = ((x - y) * (x + y)) / ((x * x) + (y * y))
else
tmp = 1.0d0 - (2.0d0 / (1.0d0 + ((x / y) * (x / y))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.abs((x / y));
double tmp;
if ((0.5 < t_0) && (t_0 < 2.0)) {
tmp = ((x - y) * (x + y)) / ((x * x) + (y * y));
} else {
tmp = 1.0 - (2.0 / (1.0 + ((x / y) * (x / y))));
}
return tmp;
}
def code(x, y): t_0 = math.fabs((x / y)) tmp = 0 if (0.5 < t_0) and (t_0 < 2.0): tmp = ((x - y) * (x + y)) / ((x * x) + (y * y)) else: tmp = 1.0 - (2.0 / (1.0 + ((x / y) * (x / y)))) return tmp
function code(x, y) t_0 = abs(Float64(x / y)) tmp = 0.0 if ((0.5 < t_0) && (t_0 < 2.0)) tmp = Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y))); else tmp = Float64(1.0 - Float64(2.0 / Float64(1.0 + Float64(Float64(x / y) * Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y) t_0 = abs((x / y)); tmp = 0.0; if ((0.5 < t_0) && (t_0 < 2.0)) tmp = ((x - y) * (x + y)) / ((x * x) + (y * y)); else tmp = 1.0 - (2.0 / (1.0 + ((x / y) * (x / y)))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[And[Less[0.5, t$95$0], Less[t$95$0, 2.0]], N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(2.0 / N[(1.0 + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;0.5 < t\_0 \land t\_0 < 2:\\
\;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{2}{1 + \frac{x}{y} \cdot \frac{x}{y}}\\
\end{array}
\end{array}
herbie shell --seed 2024055
(FPCore (x y)
:name "Kahan p9 Example"
:precision binary64
:pre (and (and (< 0.0 x) (< x 1.0)) (< y 1.0))
:alt
(if (and (< 0.5 (fabs (/ x y))) (< (fabs (/ x y)) 2.0)) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1.0 (/ 2.0 (+ 1.0 (* (/ x y) (/ x y))))))
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))