
(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) (/ (hypot x y) (+ x y)))))
double code(double x, double y) {
return (x - y) / (hypot(x, y) * (hypot(x, y) / (x + y)));
}
public static double code(double x, double y) {
return (x - y) / (Math.hypot(x, y) * (Math.hypot(x, y) / (x + y)));
}
def code(x, y): return (x - y) / (math.hypot(x, y) * (math.hypot(x, y) / (x + y)))
function code(x, y) return Float64(Float64(x - y) / Float64(hypot(x, y) * Float64(hypot(x, y) / Float64(x + y)))) end
function tmp = code(x, y) tmp = (x - y) / (hypot(x, y) * (hypot(x, y) / (x + y))); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision] * N[(N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x + y}}
\end{array}
Initial program 73.0%
associate-/l*73.5%
fma-def73.5%
Simplified73.5%
fma-def73.5%
div-inv73.2%
add-sqr-sqrt73.1%
associate-*l*73.3%
hypot-def73.3%
hypot-def99.7%
Applied egg-rr99.7%
expm1-log1p-u97.5%
expm1-udef97.5%
un-div-inv97.6%
Applied egg-rr97.6%
expm1-def97.6%
expm1-log1p99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))) (if (<= t_0 2.0) t_0 (fma 2.0 (pow (/ x y) 2.0) -1.0))))
double code(double x, double y) {
double t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y));
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} else {
tmp = fma(2.0, pow((x / y), 2.0), -1.0);
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y))) tmp = 0.0 if (t_0 <= 2.0) tmp = t_0; else tmp = fma(2.0, (Float64(x / y) ^ 2.0), -1.0); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], t$95$0, N[(2.0 * N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\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, {\left(\frac{x}{y}\right)}^{2}, -1\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y))) < 2Initial program 100.0%
if 2 < (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y))) Initial program 0.0%
associate-/l*3.1%
fma-def3.1%
Simplified3.1%
fma-def3.1%
add-sqr-sqrt3.1%
*-un-lft-identity3.1%
times-frac3.1%
hypot-def3.1%
hypot-def100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 52.2%
fma-neg52.2%
unpow252.2%
unpow252.2%
times-frac73.6%
unpow273.6%
metadata-eval73.6%
Simplified73.6%
Final simplification92.8%
(FPCore (x y) :precision binary64 (* (- x y) (/ (/ (+ x y) (hypot x y)) (hypot x y))))
double code(double x, double y) {
return (x - y) * (((x + y) / hypot(x, y)) / hypot(x, y));
}
public static double code(double x, double y) {
return (x - y) * (((x + y) / Math.hypot(x, y)) / Math.hypot(x, y));
}
def code(x, y): return (x - y) * (((x + y) / math.hypot(x, y)) / math.hypot(x, y))
function code(x, y) return Float64(Float64(x - y) * Float64(Float64(Float64(x + y) / hypot(x, y)) / hypot(x, y))) end
function tmp = code(x, y) tmp = (x - y) * (((x + y) / hypot(x, y)) / hypot(x, y)); end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] * N[(N[(N[(x + y), $MachinePrecision] / N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - y\right) \cdot \frac{\frac{x + y}{\mathsf{hypot}\left(x, y\right)}}{\mathsf{hypot}\left(x, y\right)}
\end{array}
Initial program 73.0%
associate-*r/73.2%
+-commutative73.2%
fma-def73.2%
Simplified73.2%
fma-udef73.2%
+-commutative73.2%
*-un-lft-identity73.2%
add-sqr-sqrt73.2%
times-frac73.3%
hypot-def73.3%
hypot-def99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-lft-identity99.7%
+-commutative99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y) :precision binary64 (/ (* (+ x y) (/ (- x y) (hypot x y))) (hypot x y)))
double code(double x, double y) {
return ((x + y) * ((x - y) / hypot(x, y))) / hypot(x, y);
}
public static double code(double x, double y) {
return ((x + y) * ((x - y) / Math.hypot(x, y))) / Math.hypot(x, y);
}
def code(x, y): return ((x + y) * ((x - y) / math.hypot(x, y))) / math.hypot(x, y)
function code(x, y) return Float64(Float64(Float64(x + y) * Float64(Float64(x - y) / hypot(x, y))) / hypot(x, y)) end
function tmp = code(x, y) tmp = ((x + y) * ((x - y) / hypot(x, y))) / hypot(x, y); end
code[x_, y_] := N[(N[(N[(x + y), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] / N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\right)}}{\mathsf{hypot}\left(x, y\right)}
\end{array}
Initial program 73.0%
add-sqr-sqrt73.0%
times-frac73.5%
hypot-def73.5%
hypot-def99.9%
Applied egg-rr99.9%
associate-*r/99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))) (if (<= t_0 2.0) t_0 (+ -1.0 (* (/ x y) (/ x y))))))
double code(double x, double y) {
double t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y));
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} else {
tmp = -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 = ((x - y) * (x + y)) / ((x * x) + (y * y))
if (t_0 <= 2.0d0) then
tmp = t_0
else
tmp = (-1.0d0) + ((x / y) * (x / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y));
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} else {
tmp = -1.0 + ((x / y) * (x / y));
}
return tmp;
}
def code(x, y): t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y)) tmp = 0 if t_0 <= 2.0: tmp = t_0 else: tmp = -1.0 + ((x / y) * (x / y)) return tmp
function code(x, y) t_0 = Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y))) tmp = 0.0 if (t_0 <= 2.0) tmp = t_0; else tmp = Float64(-1.0 + Float64(Float64(x / y) * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y) t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y)); tmp = 0.0; if (t_0 <= 2.0) tmp = t_0; else tmp = -1.0 + ((x / y) * (x / y)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], t$95$0, N[(-1.0 + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\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}:\\
\;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y))) < 2Initial program 100.0%
if 2 < (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y))) Initial program 0.0%
Taylor expanded in x around 0 0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in x around 0 52.2%
sub-neg52.2%
unpow252.2%
unpow252.2%
metadata-eval52.2%
Simplified52.2%
times-frac73.4%
Applied egg-rr73.4%
Final simplification92.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ -1.0 (* (/ x y) (/ x y)))))
(if (<= y -1.3e-153)
t_0
(if (<= y 4.2e-179)
(+ (/ y x) (- 1.0 (/ y x)))
(if (<= y 5.1e-123)
t_0
(if (<= y 1.7e-108) 1.0 (* (/ (- x y) y) (/ (+ x y) y))))))))
double code(double x, double y) {
double t_0 = -1.0 + ((x / y) * (x / y));
double tmp;
if (y <= -1.3e-153) {
tmp = t_0;
} else if (y <= 4.2e-179) {
tmp = (y / x) + (1.0 - (y / x));
} else if (y <= 5.1e-123) {
tmp = t_0;
} else if (y <= 1.7e-108) {
tmp = 1.0;
} else {
tmp = ((x - y) / y) * ((x + 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) + ((x / y) * (x / y))
if (y <= (-1.3d-153)) then
tmp = t_0
else if (y <= 4.2d-179) then
tmp = (y / x) + (1.0d0 - (y / x))
else if (y <= 5.1d-123) then
tmp = t_0
else if (y <= 1.7d-108) then
tmp = 1.0d0
else
tmp = ((x - y) / y) * ((x + y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = -1.0 + ((x / y) * (x / y));
double tmp;
if (y <= -1.3e-153) {
tmp = t_0;
} else if (y <= 4.2e-179) {
tmp = (y / x) + (1.0 - (y / x));
} else if (y <= 5.1e-123) {
tmp = t_0;
} else if (y <= 1.7e-108) {
tmp = 1.0;
} else {
tmp = ((x - y) / y) * ((x + y) / y);
}
return tmp;
}
def code(x, y): t_0 = -1.0 + ((x / y) * (x / y)) tmp = 0 if y <= -1.3e-153: tmp = t_0 elif y <= 4.2e-179: tmp = (y / x) + (1.0 - (y / x)) elif y <= 5.1e-123: tmp = t_0 elif y <= 1.7e-108: tmp = 1.0 else: tmp = ((x - y) / y) * ((x + y) / y) return tmp
function code(x, y) t_0 = Float64(-1.0 + Float64(Float64(x / y) * Float64(x / y))) tmp = 0.0 if (y <= -1.3e-153) tmp = t_0; elseif (y <= 4.2e-179) tmp = Float64(Float64(y / x) + Float64(1.0 - Float64(y / x))); elseif (y <= 5.1e-123) tmp = t_0; elseif (y <= 1.7e-108) tmp = 1.0; else tmp = Float64(Float64(Float64(x - y) / y) * Float64(Float64(x + y) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = -1.0 + ((x / y) * (x / y)); tmp = 0.0; if (y <= -1.3e-153) tmp = t_0; elseif (y <= 4.2e-179) tmp = (y / x) + (1.0 - (y / x)); elseif (y <= 5.1e-123) tmp = t_0; elseif (y <= 1.7e-108) tmp = 1.0; else tmp = ((x - y) / y) * ((x + y) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(-1.0 + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.3e-153], t$95$0, If[LessEqual[y, 4.2e-179], N[(N[(y / x), $MachinePrecision] + N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.1e-123], t$95$0, If[LessEqual[y, 1.7e-108], 1.0, N[(N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -1.3 \cdot 10^{-153}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-179}:\\
\;\;\;\;\frac{y}{x} + \left(1 - \frac{y}{x}\right)\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{-123}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-108}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{y} \cdot \frac{x + y}{y}\\
\end{array}
\end{array}
if y < -1.3000000000000001e-153 or 4.1999999999999997e-179 < y < 5.1000000000000001e-123Initial program 71.6%
Taylor expanded in x around 0 61.5%
unpow261.5%
Simplified61.5%
Taylor expanded in x around 0 87.1%
sub-neg87.1%
unpow287.1%
unpow287.1%
metadata-eval87.1%
Simplified87.1%
times-frac89.9%
Applied egg-rr89.9%
if -1.3000000000000001e-153 < y < 4.1999999999999997e-179Initial program 58.6%
associate-*r/59.4%
+-commutative59.4%
fma-def59.4%
Simplified59.4%
Taylor expanded in x around inf 84.3%
mul-1-neg84.3%
unsub-neg84.3%
Simplified84.3%
if 5.1000000000000001e-123 < y < 1.70000000000000001e-108Initial program 100.0%
associate-*r/99.4%
+-commutative99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in x around inf 100.0%
if 1.70000000000000001e-108 < y Initial program 100.0%
Taylor expanded in x around 0 89.5%
unpow289.5%
Simplified89.5%
times-frac89.5%
Applied egg-rr89.5%
Final simplification88.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ -1.0 (* (/ x y) (/ x y)))))
(if (<= y -8.8e-154)
t_0
(if (<= y 2.8e-178)
(+ 1.0 (* -2.0 (* (/ y x) (/ y x))))
(if (<= y 6e-123)
t_0
(if (<= y 1.9e-108) 1.0 (* (/ (- x y) y) (/ (+ x y) y))))))))
double code(double x, double y) {
double t_0 = -1.0 + ((x / y) * (x / y));
double tmp;
if (y <= -8.8e-154) {
tmp = t_0;
} else if (y <= 2.8e-178) {
tmp = 1.0 + (-2.0 * ((y / x) * (y / x)));
} else if (y <= 6e-123) {
tmp = t_0;
} else if (y <= 1.9e-108) {
tmp = 1.0;
} else {
tmp = ((x - y) / y) * ((x + 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) + ((x / y) * (x / y))
if (y <= (-8.8d-154)) then
tmp = t_0
else if (y <= 2.8d-178) then
tmp = 1.0d0 + ((-2.0d0) * ((y / x) * (y / x)))
else if (y <= 6d-123) then
tmp = t_0
else if (y <= 1.9d-108) then
tmp = 1.0d0
else
tmp = ((x - y) / y) * ((x + y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = -1.0 + ((x / y) * (x / y));
double tmp;
if (y <= -8.8e-154) {
tmp = t_0;
} else if (y <= 2.8e-178) {
tmp = 1.0 + (-2.0 * ((y / x) * (y / x)));
} else if (y <= 6e-123) {
tmp = t_0;
} else if (y <= 1.9e-108) {
tmp = 1.0;
} else {
tmp = ((x - y) / y) * ((x + y) / y);
}
return tmp;
}
def code(x, y): t_0 = -1.0 + ((x / y) * (x / y)) tmp = 0 if y <= -8.8e-154: tmp = t_0 elif y <= 2.8e-178: tmp = 1.0 + (-2.0 * ((y / x) * (y / x))) elif y <= 6e-123: tmp = t_0 elif y <= 1.9e-108: tmp = 1.0 else: tmp = ((x - y) / y) * ((x + y) / y) return tmp
function code(x, y) t_0 = Float64(-1.0 + Float64(Float64(x / y) * Float64(x / y))) tmp = 0.0 if (y <= -8.8e-154) tmp = t_0; elseif (y <= 2.8e-178) tmp = Float64(1.0 + Float64(-2.0 * Float64(Float64(y / x) * Float64(y / x)))); elseif (y <= 6e-123) tmp = t_0; elseif (y <= 1.9e-108) tmp = 1.0; else tmp = Float64(Float64(Float64(x - y) / y) * Float64(Float64(x + y) / y)); end return tmp end
function tmp_2 = code(x, y) t_0 = -1.0 + ((x / y) * (x / y)); tmp = 0.0; if (y <= -8.8e-154) tmp = t_0; elseif (y <= 2.8e-178) tmp = 1.0 + (-2.0 * ((y / x) * (y / x))); elseif (y <= 6e-123) tmp = t_0; elseif (y <= 1.9e-108) tmp = 1.0; else tmp = ((x - y) / y) * ((x + y) / y); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(-1.0 + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.8e-154], t$95$0, If[LessEqual[y, 2.8e-178], N[(1.0 + N[(-2.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e-123], t$95$0, If[LessEqual[y, 1.9e-108], 1.0, N[(N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -8.8 \cdot 10^{-154}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-178}:\\
\;\;\;\;1 + -2 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-123}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-108}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{y} \cdot \frac{x + y}{y}\\
\end{array}
\end{array}
if y < -8.80000000000000029e-154 or 2.80000000000000019e-178 < y < 5.99999999999999968e-123Initial program 71.6%
Taylor expanded in x around 0 61.5%
unpow261.5%
Simplified61.5%
Taylor expanded in x around 0 87.1%
sub-neg87.1%
unpow287.1%
unpow287.1%
metadata-eval87.1%
Simplified87.1%
times-frac89.9%
Applied egg-rr89.9%
if -8.80000000000000029e-154 < y < 2.80000000000000019e-178Initial program 58.6%
associate-*r/59.4%
+-commutative59.4%
fma-def59.4%
Simplified59.4%
Taylor expanded in y around 0 58.6%
unpow258.6%
unpow258.6%
Simplified58.6%
times-frac85.6%
Applied egg-rr85.6%
if 5.99999999999999968e-123 < y < 1.89999999999999987e-108Initial program 100.0%
associate-*r/99.4%
+-commutative99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in x around inf 100.0%
if 1.89999999999999987e-108 < y Initial program 100.0%
Taylor expanded in x around 0 89.5%
unpow289.5%
Simplified89.5%
times-frac89.5%
Applied egg-rr89.5%
Final simplification88.9%
(FPCore (x y)
:precision binary64
(if (<= y -1.2e-153)
(/ 1.0 (/ (/ y (+ (/ x y) -1.0)) (+ x y)))
(if (<= y 1.2e-180)
(+ 1.0 (* -2.0 (* (/ y x) (/ y x))))
(if (<= y 7.8e-123)
(+ -1.0 (* (/ x y) (/ x y)))
(if (<= y 2.2e-108) 1.0 (* (/ (- x y) y) (/ (+ x y) y)))))))
double code(double x, double y) {
double tmp;
if (y <= -1.2e-153) {
tmp = 1.0 / ((y / ((x / y) + -1.0)) / (x + y));
} else if (y <= 1.2e-180) {
tmp = 1.0 + (-2.0 * ((y / x) * (y / x)));
} else if (y <= 7.8e-123) {
tmp = -1.0 + ((x / y) * (x / y));
} else if (y <= 2.2e-108) {
tmp = 1.0;
} else {
tmp = ((x - y) / y) * ((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 <= (-1.2d-153)) then
tmp = 1.0d0 / ((y / ((x / y) + (-1.0d0))) / (x + y))
else if (y <= 1.2d-180) then
tmp = 1.0d0 + ((-2.0d0) * ((y / x) * (y / x)))
else if (y <= 7.8d-123) then
tmp = (-1.0d0) + ((x / y) * (x / y))
else if (y <= 2.2d-108) then
tmp = 1.0d0
else
tmp = ((x - y) / y) * ((x + y) / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.2e-153) {
tmp = 1.0 / ((y / ((x / y) + -1.0)) / (x + y));
} else if (y <= 1.2e-180) {
tmp = 1.0 + (-2.0 * ((y / x) * (y / x)));
} else if (y <= 7.8e-123) {
tmp = -1.0 + ((x / y) * (x / y));
} else if (y <= 2.2e-108) {
tmp = 1.0;
} else {
tmp = ((x - y) / y) * ((x + y) / y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.2e-153: tmp = 1.0 / ((y / ((x / y) + -1.0)) / (x + y)) elif y <= 1.2e-180: tmp = 1.0 + (-2.0 * ((y / x) * (y / x))) elif y <= 7.8e-123: tmp = -1.0 + ((x / y) * (x / y)) elif y <= 2.2e-108: tmp = 1.0 else: tmp = ((x - y) / y) * ((x + y) / y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.2e-153) tmp = Float64(1.0 / Float64(Float64(y / Float64(Float64(x / y) + -1.0)) / Float64(x + y))); elseif (y <= 1.2e-180) tmp = Float64(1.0 + Float64(-2.0 * Float64(Float64(y / x) * Float64(y / x)))); elseif (y <= 7.8e-123) tmp = Float64(-1.0 + Float64(Float64(x / y) * Float64(x / y))); elseif (y <= 2.2e-108) tmp = 1.0; else tmp = Float64(Float64(Float64(x - y) / y) * Float64(Float64(x + y) / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.2e-153) tmp = 1.0 / ((y / ((x / y) + -1.0)) / (x + y)); elseif (y <= 1.2e-180) tmp = 1.0 + (-2.0 * ((y / x) * (y / x))); elseif (y <= 7.8e-123) tmp = -1.0 + ((x / y) * (x / y)); elseif (y <= 2.2e-108) tmp = 1.0; else tmp = ((x - y) / y) * ((x + y) / y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.2e-153], N[(1.0 / N[(N[(y / N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.2e-180], N[(1.0 + N[(-2.0 * N[(N[(y / x), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.8e-123], N[(-1.0 + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e-108], 1.0, N[(N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{-153}:\\
\;\;\;\;\frac{1}{\frac{\frac{y}{\frac{x}{y} + -1}}{x + y}}\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-180}:\\
\;\;\;\;1 + -2 \cdot \left(\frac{y}{x} \cdot \frac{y}{x}\right)\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{-123}:\\
\;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-108}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{y} \cdot \frac{x + y}{y}\\
\end{array}
\end{array}
if y < -1.2000000000000001e-153Initial program 71.1%
Taylor expanded in x around 0 62.9%
unpow262.9%
Simplified62.9%
clear-num62.9%
inv-pow62.9%
Applied egg-rr62.9%
unpow-162.9%
unpow262.9%
associate-/r*63.7%
unpow263.7%
Simplified63.7%
expm1-log1p-u61.1%
expm1-udef34.1%
associate-/l*58.9%
div-sub58.9%
pow158.9%
pow158.9%
pow-div58.9%
metadata-eval58.9%
metadata-eval58.9%
Applied egg-rr58.9%
expm1-def86.0%
expm1-log1p91.7%
sub-neg91.7%
metadata-eval91.7%
Simplified91.7%
if -1.2000000000000001e-153 < y < 1.1999999999999999e-180Initial program 58.6%
associate-*r/59.4%
+-commutative59.4%
fma-def59.4%
Simplified59.4%
Taylor expanded in y around 0 58.6%
unpow258.6%
unpow258.6%
Simplified58.6%
times-frac85.6%
Applied egg-rr85.6%
if 1.1999999999999999e-180 < y < 7.79999999999999952e-123Initial program 75.0%
Taylor expanded in x around 0 51.3%
unpow251.3%
Simplified51.3%
Taylor expanded in x around 0 51.3%
sub-neg51.3%
unpow251.3%
unpow251.3%
metadata-eval51.3%
Simplified51.3%
times-frac76.4%
Applied egg-rr76.4%
if 7.79999999999999952e-123 < y < 2.2000000000000001e-108Initial program 100.0%
associate-*r/99.4%
+-commutative99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in x around inf 100.0%
if 2.2000000000000001e-108 < y Initial program 100.0%
Taylor expanded in x around 0 89.5%
unpow289.5%
Simplified89.5%
times-frac89.5%
Applied egg-rr89.5%
Final simplification88.9%
(FPCore (x y)
:precision binary64
(if (or (<= y -1.4e-153)
(not
(or (<= y 1.65e-179) (and (not (<= y 7.8e-123)) (<= y 5.1e-108)))))
(+ -1.0 (* (/ x y) (/ x y)))
1.0))
double code(double x, double y) {
double tmp;
if ((y <= -1.4e-153) || !((y <= 1.65e-179) || (!(y <= 7.8e-123) && (y <= 5.1e-108)))) {
tmp = -1.0 + ((x / y) * (x / 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 <= (-1.4d-153)) .or. (.not. (y <= 1.65d-179) .or. (.not. (y <= 7.8d-123)) .and. (y <= 5.1d-108))) then
tmp = (-1.0d0) + ((x / y) * (x / y))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.4e-153) || !((y <= 1.65e-179) || (!(y <= 7.8e-123) && (y <= 5.1e-108)))) {
tmp = -1.0 + ((x / y) * (x / y));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.4e-153) or not ((y <= 1.65e-179) or (not (y <= 7.8e-123) and (y <= 5.1e-108))): tmp = -1.0 + ((x / y) * (x / y)) else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.4e-153) || !((y <= 1.65e-179) || (!(y <= 7.8e-123) && (y <= 5.1e-108)))) tmp = Float64(-1.0 + Float64(Float64(x / y) * Float64(x / y))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.4e-153) || ~(((y <= 1.65e-179) || (~((y <= 7.8e-123)) && (y <= 5.1e-108))))) tmp = -1.0 + ((x / y) * (x / y)); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.4e-153], N[Not[Or[LessEqual[y, 1.65e-179], And[N[Not[LessEqual[y, 7.8e-123]], $MachinePrecision], LessEqual[y, 5.1e-108]]]], $MachinePrecision]], N[(-1.0 + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-153} \lor \neg \left(y \leq 1.65 \cdot 10^{-179} \lor \neg \left(y \leq 7.8 \cdot 10^{-123}\right) \land y \leq 5.1 \cdot 10^{-108}\right):\\
\;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.4e-153 or 1.6499999999999999e-179 < y < 7.79999999999999952e-123 or 5.1000000000000002e-108 < y Initial program 77.9%
Taylor expanded in x around 0 67.7%
unpow267.7%
Simplified67.7%
Taylor expanded in x around 0 87.6%
sub-neg87.6%
unpow287.6%
unpow287.6%
metadata-eval87.6%
Simplified87.6%
times-frac89.8%
Applied egg-rr89.8%
if -1.4e-153 < y < 1.6499999999999999e-179 or 7.79999999999999952e-123 < y < 5.1000000000000002e-108Initial program 61.3%
associate-*r/62.0%
+-commutative62.0%
fma-def62.0%
Simplified62.0%
Taylor expanded in x around inf 85.2%
Final simplification88.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ -1.0 (* (/ x y) (/ x y)))))
(if (<= y -1.4e-153)
t_0
(if (<= y 7.3e-180)
(+ (/ y x) (- 1.0 (/ y x)))
(if (or (<= y 7.6e-123) (not (<= y 1.7e-108))) t_0 1.0)))))
double code(double x, double y) {
double t_0 = -1.0 + ((x / y) * (x / y));
double tmp;
if (y <= -1.4e-153) {
tmp = t_0;
} else if (y <= 7.3e-180) {
tmp = (y / x) + (1.0 - (y / x));
} else if ((y <= 7.6e-123) || !(y <= 1.7e-108)) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (-1.0d0) + ((x / y) * (x / y))
if (y <= (-1.4d-153)) then
tmp = t_0
else if (y <= 7.3d-180) then
tmp = (y / x) + (1.0d0 - (y / x))
else if ((y <= 7.6d-123) .or. (.not. (y <= 1.7d-108))) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = -1.0 + ((x / y) * (x / y));
double tmp;
if (y <= -1.4e-153) {
tmp = t_0;
} else if (y <= 7.3e-180) {
tmp = (y / x) + (1.0 - (y / x));
} else if ((y <= 7.6e-123) || !(y <= 1.7e-108)) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): t_0 = -1.0 + ((x / y) * (x / y)) tmp = 0 if y <= -1.4e-153: tmp = t_0 elif y <= 7.3e-180: tmp = (y / x) + (1.0 - (y / x)) elif (y <= 7.6e-123) or not (y <= 1.7e-108): tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y) t_0 = Float64(-1.0 + Float64(Float64(x / y) * Float64(x / y))) tmp = 0.0 if (y <= -1.4e-153) tmp = t_0; elseif (y <= 7.3e-180) tmp = Float64(Float64(y / x) + Float64(1.0 - Float64(y / x))); elseif ((y <= 7.6e-123) || !(y <= 1.7e-108)) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) t_0 = -1.0 + ((x / y) * (x / y)); tmp = 0.0; if (y <= -1.4e-153) tmp = t_0; elseif (y <= 7.3e-180) tmp = (y / x) + (1.0 - (y / x)); elseif ((y <= 7.6e-123) || ~((y <= 1.7e-108))) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(-1.0 + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.4e-153], t$95$0, If[LessEqual[y, 7.3e-180], N[(N[(y / x), $MachinePrecision] + N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 7.6e-123], N[Not[LessEqual[y, 1.7e-108]], $MachinePrecision]], t$95$0, 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + \frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -1.4 \cdot 10^{-153}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 7.3 \cdot 10^{-180}:\\
\;\;\;\;\frac{y}{x} + \left(1 - \frac{y}{x}\right)\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{-123} \lor \neg \left(y \leq 1.7 \cdot 10^{-108}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.4e-153 or 7.2999999999999996e-180 < y < 7.59999999999999991e-123 or 1.70000000000000001e-108 < y Initial program 77.9%
Taylor expanded in x around 0 67.7%
unpow267.7%
Simplified67.7%
Taylor expanded in x around 0 87.6%
sub-neg87.6%
unpow287.6%
unpow287.6%
metadata-eval87.6%
Simplified87.6%
times-frac89.8%
Applied egg-rr89.8%
if -1.4e-153 < y < 7.2999999999999996e-180Initial program 58.6%
associate-*r/59.4%
+-commutative59.4%
fma-def59.4%
Simplified59.4%
Taylor expanded in x around inf 84.3%
mul-1-neg84.3%
unsub-neg84.3%
Simplified84.3%
if 7.59999999999999991e-123 < y < 1.70000000000000001e-108Initial program 100.0%
associate-*r/99.4%
+-commutative99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in x around inf 100.0%
Final simplification88.5%
(FPCore (x y)
:precision binary64
(if (<= y -1e-153)
-1.0
(if (<= y 8.5e-179)
1.0
(if (<= y 6e-123) -1.0 (if (<= y 2.8e-108) 1.0 -1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1e-153) {
tmp = -1.0;
} else if (y <= 8.5e-179) {
tmp = 1.0;
} else if (y <= 6e-123) {
tmp = -1.0;
} else if (y <= 2.8e-108) {
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 <= (-1d-153)) then
tmp = -1.0d0
else if (y <= 8.5d-179) then
tmp = 1.0d0
else if (y <= 6d-123) then
tmp = -1.0d0
else if (y <= 2.8d-108) 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 <= -1e-153) {
tmp = -1.0;
} else if (y <= 8.5e-179) {
tmp = 1.0;
} else if (y <= 6e-123) {
tmp = -1.0;
} else if (y <= 2.8e-108) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1e-153: tmp = -1.0 elif y <= 8.5e-179: tmp = 1.0 elif y <= 6e-123: tmp = -1.0 elif y <= 2.8e-108: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1e-153) tmp = -1.0; elseif (y <= 8.5e-179) tmp = 1.0; elseif (y <= 6e-123) tmp = -1.0; elseif (y <= 2.8e-108) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1e-153) tmp = -1.0; elseif (y <= 8.5e-179) tmp = 1.0; elseif (y <= 6e-123) tmp = -1.0; elseif (y <= 2.8e-108) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1e-153], -1.0, If[LessEqual[y, 8.5e-179], 1.0, If[LessEqual[y, 6e-123], -1.0, If[LessEqual[y, 2.8e-108], 1.0, -1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-153}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-179}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-123}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-108}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < -1.00000000000000004e-153 or 8.49999999999999932e-179 < y < 5.99999999999999968e-123 or 2.8e-108 < y Initial program 77.9%
associate-*r/77.8%
+-commutative77.8%
fma-def77.9%
Simplified77.9%
Taylor expanded in x around 0 89.3%
if -1.00000000000000004e-153 < y < 8.49999999999999932e-179 or 5.99999999999999968e-123 < y < 2.8e-108Initial program 61.3%
associate-*r/62.0%
+-commutative62.0%
fma-def62.0%
Simplified62.0%
Taylor expanded in x around inf 85.2%
Final simplification88.1%
(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 73.0%
associate-*r/73.2%
+-commutative73.2%
fma-def73.2%
Simplified73.2%
Taylor expanded in x around 0 67.2%
Final simplification67.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 2023194
(FPCore (x y)
:name "Kahan p9 Example"
:precision binary64
:pre (and (and (< 0.0 x) (< x 1.0)) (< y 1.0))
:herbie-target
(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))))