
(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 13 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}
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (/ (/ (- x y) (hypot x y)) (/ (hypot x y) (+ x y))))
y = abs(y);
double code(double x, double y) {
return ((x - y) / hypot(x, y)) / (hypot(x, y) / (x + y));
}
y = Math.abs(y);
public static double code(double x, double y) {
return ((x - y) / Math.hypot(x, y)) / (Math.hypot(x, y) / (x + y));
}
y = abs(y) def code(x, y): return ((x - y) / math.hypot(x, y)) / (math.hypot(x, y) / (x + y))
y = abs(y) function code(x, y) return Float64(Float64(Float64(x - y) / hypot(x, y)) / Float64(hypot(x, y) / Float64(x + y))) end
y = abs(y) function tmp = code(x, y) tmp = ((x - y) / hypot(x, y)) / (hypot(x, y) / (x + y)); end
NOTE: y should be positive before calling this function code[x_, y_] := N[(N[(N[(x - y), $MachinePrecision] / N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x ^ 2 + y ^ 2], $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\frac{\frac{x - y}{\mathsf{hypot}\left(x, y\right)}}{\frac{\mathsf{hypot}\left(x, y\right)}{x + y}}
\end{array}
Initial program 65.9%
associate-*r/65.9%
+-commutative65.9%
fma-def65.9%
Simplified65.9%
fma-udef65.9%
+-commutative65.9%
*-un-lft-identity65.9%
add-sqr-sqrt65.9%
times-frac66.0%
hypot-def66.1%
hypot-def99.6%
Applied egg-rr99.6%
associate-*l/99.6%
*-lft-identity99.6%
+-commutative99.6%
Simplified99.6%
associate-/l/65.9%
+-commutative65.9%
clear-num66.0%
*-un-lft-identity66.0%
frac-times99.7%
div-inv99.9%
/-rgt-identity99.9%
associate-/r*99.9%
Applied egg-rr99.9%
Final simplification99.9%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (* (- x y) (/ (/ (+ x y) (hypot x y)) (hypot x y))))
y = abs(y);
double code(double x, double y) {
return (x - y) * (((x + y) / hypot(x, y)) / hypot(x, y));
}
y = Math.abs(y);
public static double code(double x, double y) {
return (x - y) * (((x + y) / Math.hypot(x, y)) / Math.hypot(x, y));
}
y = abs(y) def code(x, y): return (x - y) * (((x + y) / math.hypot(x, y)) / math.hypot(x, y))
y = abs(y) function code(x, y) return Float64(Float64(x - y) * Float64(Float64(Float64(x + y) / hypot(x, y)) / hypot(x, y))) end
y = abs(y) function tmp = code(x, y) tmp = (x - y) * (((x + y) / hypot(x, y)) / hypot(x, y)); end
NOTE: y should be positive before calling this function 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}
y = |y|\\
\\
\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 65.9%
associate-*r/65.9%
+-commutative65.9%
fma-def65.9%
Simplified65.9%
fma-udef65.9%
+-commutative65.9%
*-un-lft-identity65.9%
add-sqr-sqrt65.9%
times-frac66.0%
hypot-def66.1%
hypot-def99.6%
Applied egg-rr99.6%
associate-*l/99.6%
*-lft-identity99.6%
+-commutative99.6%
Simplified99.6%
Final simplification99.6%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))
(t_1 (* (/ x y) (/ x y))))
(if (<= t_0 2.0) t_0 (+ t_1 (+ t_1 -1.0)))))y = abs(y);
double code(double x, double y) {
double t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y));
double t_1 = (x / y) * (x / y);
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} else {
tmp = t_1 + (t_1 + -1.0);
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y))
t_1 = (x / y) * (x / y)
if (t_0 <= 2.0d0) then
tmp = t_0
else
tmp = t_1 + (t_1 + (-1.0d0))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y));
double t_1 = (x / y) * (x / y);
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} else {
tmp = t_1 + (t_1 + -1.0);
}
return tmp;
}
y = abs(y) def code(x, y): t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y)) t_1 = (x / y) * (x / y) tmp = 0 if t_0 <= 2.0: tmp = t_0 else: tmp = t_1 + (t_1 + -1.0) return tmp
y = abs(y) function code(x, y) t_0 = Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y))) t_1 = Float64(Float64(x / y) * Float64(x / y)) tmp = 0.0 if (t_0 <= 2.0) tmp = t_0; else tmp = Float64(t_1 + Float64(t_1 + -1.0)); end return tmp end
y = abs(y) function tmp_2 = code(x, y) t_0 = ((x - y) * (x + y)) / ((x * x) + (y * y)); t_1 = (x / y) * (x / y); tmp = 0.0; if (t_0 <= 2.0) tmp = t_0; else tmp = t_1 + (t_1 + -1.0); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
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]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], t$95$0, N[(t$95$1 + N[(t$95$1 + -1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
t_1 := \frac{x}{y} \cdot \frac{x}{y}\\
\mathbf{if}\;t_0 \leq 2:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1 + \left(t_1 + -1\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y))) < 2Initial program 99.8%
if 2 < (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y))) Initial program 0.0%
associate-*r/3.1%
+-commutative3.1%
fma-def3.1%
Simplified3.1%
fma-udef3.1%
+-commutative3.1%
*-un-lft-identity3.1%
add-sqr-sqrt3.1%
times-frac3.1%
hypot-def3.1%
hypot-def99.6%
Applied egg-rr99.6%
associate-*l/99.6%
*-lft-identity99.6%
+-commutative99.6%
Simplified99.6%
associate-/l/3.1%
+-commutative3.1%
clear-num3.1%
*-un-lft-identity3.1%
frac-times99.7%
div-inv99.9%
/-rgt-identity99.9%
associate-/r*99.9%
Applied egg-rr99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
Simplified99.9%
Taylor expanded in y around inf 58.6%
distribute-rgt1-in58.6%
metadata-eval58.6%
mul0-lft58.6%
associate-+r-58.6%
unpow258.6%
unpow258.6%
times-frac58.6%
neg-sub058.6%
+-commutative58.6%
distribute-neg-in58.6%
metadata-eval58.6%
mul-1-neg58.6%
remove-double-neg58.6%
unpow258.6%
unpow258.6%
times-frac80.6%
Simplified80.6%
Final simplification93.3%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (let* ((t_0 (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))) (if (<= t_0 2.0) t_0 (+ (* (/ x y) (/ x y)) -1.0))))
y = abs(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 = ((x / y) * (x / y)) + -1.0;
}
return tmp;
}
NOTE: y should be positive before calling this function
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 = ((x / y) * (x / y)) + (-1.0d0)
end if
code = tmp
end function
y = Math.abs(y);
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 = ((x / y) * (x / y)) + -1.0;
}
return tmp;
}
y = abs(y) 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 = ((x / y) * (x / y)) + -1.0 return tmp
y = abs(y) 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(Float64(Float64(x / y) * Float64(x / y)) + -1.0); end return tmp end
y = abs(y) 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 = ((x / y) * (x / y)) + -1.0; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
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[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\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{x}{y} \cdot \frac{x}{y} + -1\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y))) < 2Initial program 99.8%
if 2 < (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y))) Initial program 0.0%
associate-*r/3.1%
+-commutative3.1%
fma-def3.1%
Simplified3.1%
Taylor expanded in y around inf 3.1%
unpow23.1%
Simplified3.1%
*-un-lft-identity3.1%
times-frac79.8%
Applied egg-rr79.8%
associate-*l/79.8%
*-lft-identity79.8%
Simplified79.8%
Taylor expanded in x around 0 58.6%
sub-neg58.6%
unpow258.6%
unpow258.6%
times-frac80.3%
metadata-eval80.3%
Simplified80.3%
Final simplification93.2%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 2.3e-163)
(- (+ (/ y x) 1.0) (/ y x))
(if (<= y 1.35e-120)
(/ (- x y) y)
(if (<= y 1.25e-111)
(+ 1.0 (* -2.0 (/ (* y y) (* x x))))
(+ -1.0 (/ (* x x) (* y y)))))))y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 2.3e-163) {
tmp = ((y / x) + 1.0) - (y / x);
} else if (y <= 1.35e-120) {
tmp = (x - y) / y;
} else if (y <= 1.25e-111) {
tmp = 1.0 + (-2.0 * ((y * y) / (x * x)));
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.3d-163) then
tmp = ((y / x) + 1.0d0) - (y / x)
else if (y <= 1.35d-120) then
tmp = (x - y) / y
else if (y <= 1.25d-111) then
tmp = 1.0d0 + ((-2.0d0) * ((y * y) / (x * x)))
else
tmp = (-1.0d0) + ((x * x) / (y * y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 2.3e-163) {
tmp = ((y / x) + 1.0) - (y / x);
} else if (y <= 1.35e-120) {
tmp = (x - y) / y;
} else if (y <= 1.25e-111) {
tmp = 1.0 + (-2.0 * ((y * y) / (x * x)));
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 2.3e-163: tmp = ((y / x) + 1.0) - (y / x) elif y <= 1.35e-120: tmp = (x - y) / y elif y <= 1.25e-111: tmp = 1.0 + (-2.0 * ((y * y) / (x * x))) else: tmp = -1.0 + ((x * x) / (y * y)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 2.3e-163) tmp = Float64(Float64(Float64(y / x) + 1.0) - Float64(y / x)); elseif (y <= 1.35e-120) tmp = Float64(Float64(x - y) / y); elseif (y <= 1.25e-111) tmp = Float64(1.0 + Float64(-2.0 * Float64(Float64(y * y) / Float64(x * x)))); else tmp = Float64(-1.0 + Float64(Float64(x * x) / Float64(y * y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.3e-163) tmp = ((y / x) + 1.0) - (y / x); elseif (y <= 1.35e-120) tmp = (x - y) / y; elseif (y <= 1.25e-111) tmp = 1.0 + (-2.0 * ((y * y) / (x * x))); else tmp = -1.0 + ((x * x) / (y * y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 2.3e-163], N[(N[(N[(y / x), $MachinePrecision] + 1.0), $MachinePrecision] - N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e-120], N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.25e-111], N[(1.0 + N[(-2.0 * N[(N[(y * y), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.3 \cdot 10^{-163}:\\
\;\;\;\;\left(\frac{y}{x} + 1\right) - \frac{y}{x}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-120}:\\
\;\;\;\;\frac{x - y}{y}\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-111}:\\
\;\;\;\;1 + -2 \cdot \frac{y \cdot y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if y < 2.2999999999999999e-163Initial program 59.0%
associate-*r/59.2%
+-commutative59.2%
fma-def59.2%
Simplified59.2%
fma-udef59.2%
+-commutative59.2%
*-un-lft-identity59.2%
add-sqr-sqrt59.2%
times-frac59.3%
hypot-def59.3%
hypot-def99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-lft-identity99.7%
+-commutative99.7%
Simplified99.7%
associate-/l/59.2%
+-commutative59.2%
clear-num59.2%
*-un-lft-identity59.2%
frac-times99.7%
div-inv99.9%
/-rgt-identity99.9%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 30.3%
associate-+r+30.3%
+-commutative30.3%
associate-*r/30.3%
neg-mul-130.3%
Simplified30.3%
add-sqr-sqrt29.1%
distribute-frac-neg29.1%
fma-def29.1%
add-sqr-sqrt13.0%
sqrt-unprod28.5%
sqr-neg28.5%
sqrt-unprod15.5%
add-sqr-sqrt28.1%
fma-neg28.1%
add-sqr-sqrt31.1%
add-sqr-sqrt18.5%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod13.0%
add-sqr-sqrt30.3%
Applied egg-rr30.3%
if 2.2999999999999999e-163 < y < 1.3499999999999999e-120Initial program 100.0%
associate-/l*99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 56.8%
if 1.3499999999999999e-120 < y < 1.2500000000000001e-111Initial program 100.0%
associate-*r/98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
Taylor expanded in y around 0 100.0%
unpow2100.0%
unpow2100.0%
Simplified100.0%
if 1.2500000000000001e-111 < y Initial program 99.8%
associate-*r/99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
Taylor expanded in y around inf 85.4%
unpow285.4%
Simplified85.4%
Taylor expanded in x around 0 85.9%
sub-neg85.9%
unpow285.9%
unpow285.9%
metadata-eval85.9%
Simplified85.9%
Final simplification38.2%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 5.5e-163)
(* (- x y) (+ (/ 1.0 x) (/ (/ y x) x)))
(if (<= y 1.4e-120)
(/ (- x y) y)
(if (<= y 1.15e-111)
(+ 1.0 (* -2.0 (/ (* y y) (* x x))))
(+ -1.0 (/ (* x x) (* y y)))))))y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 5.5e-163) {
tmp = (x - y) * ((1.0 / x) + ((y / x) / x));
} else if (y <= 1.4e-120) {
tmp = (x - y) / y;
} else if (y <= 1.15e-111) {
tmp = 1.0 + (-2.0 * ((y * y) / (x * x)));
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 5.5d-163) then
tmp = (x - y) * ((1.0d0 / x) + ((y / x) / x))
else if (y <= 1.4d-120) then
tmp = (x - y) / y
else if (y <= 1.15d-111) then
tmp = 1.0d0 + ((-2.0d0) * ((y * y) / (x * x)))
else
tmp = (-1.0d0) + ((x * x) / (y * y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 5.5e-163) {
tmp = (x - y) * ((1.0 / x) + ((y / x) / x));
} else if (y <= 1.4e-120) {
tmp = (x - y) / y;
} else if (y <= 1.15e-111) {
tmp = 1.0 + (-2.0 * ((y * y) / (x * x)));
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 5.5e-163: tmp = (x - y) * ((1.0 / x) + ((y / x) / x)) elif y <= 1.4e-120: tmp = (x - y) / y elif y <= 1.15e-111: tmp = 1.0 + (-2.0 * ((y * y) / (x * x))) else: tmp = -1.0 + ((x * x) / (y * y)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 5.5e-163) tmp = Float64(Float64(x - y) * Float64(Float64(1.0 / x) + Float64(Float64(y / x) / x))); elseif (y <= 1.4e-120) tmp = Float64(Float64(x - y) / y); elseif (y <= 1.15e-111) tmp = Float64(1.0 + Float64(-2.0 * Float64(Float64(y * y) / Float64(x * x)))); else tmp = Float64(-1.0 + Float64(Float64(x * x) / Float64(y * y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 5.5e-163) tmp = (x - y) * ((1.0 / x) + ((y / x) / x)); elseif (y <= 1.4e-120) tmp = (x - y) / y; elseif (y <= 1.15e-111) tmp = 1.0 + (-2.0 * ((y * y) / (x * x))); else tmp = -1.0 + ((x * x) / (y * y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 5.5e-163], N[(N[(x - y), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] + N[(N[(y / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e-120], N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.15e-111], N[(1.0 + N[(-2.0 * N[(N[(y * y), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-163}:\\
\;\;\;\;\left(x - y\right) \cdot \left(\frac{1}{x} + \frac{\frac{y}{x}}{x}\right)\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-120}:\\
\;\;\;\;\frac{x - y}{y}\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{-111}:\\
\;\;\;\;1 + -2 \cdot \frac{y \cdot y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if y < 5.4999999999999998e-163Initial program 59.0%
associate-*r/59.2%
+-commutative59.2%
fma-def59.2%
Simplified59.2%
fma-udef59.2%
+-commutative59.2%
*-un-lft-identity59.2%
add-sqr-sqrt59.2%
times-frac59.3%
hypot-def59.3%
hypot-def99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-lft-identity99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in y around 0 32.3%
Taylor expanded in y around 0 23.9%
+-commutative23.9%
unpow223.9%
associate-/r*31.7%
Simplified31.7%
if 5.4999999999999998e-163 < y < 1.39999999999999997e-120Initial program 100.0%
associate-/l*99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 56.8%
if 1.39999999999999997e-120 < y < 1.15e-111Initial program 100.0%
associate-*r/98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
Taylor expanded in y around 0 100.0%
unpow2100.0%
unpow2100.0%
Simplified100.0%
if 1.15e-111 < y Initial program 99.8%
associate-*r/99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
Taylor expanded in y around inf 85.4%
unpow285.4%
Simplified85.4%
Taylor expanded in x around 0 85.9%
sub-neg85.9%
unpow285.9%
unpow285.9%
metadata-eval85.9%
Simplified85.9%
Final simplification39.4%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 4.9e-167)
(/ (- x y) (+ (- x y) (* y (/ y x))))
(if (<= y 1.4e-120)
(/ (- x y) y)
(if (<= y 1.15e-111)
(+ 1.0 (* -2.0 (/ (* y y) (* x x))))
(+ -1.0 (/ (* x x) (* y y)))))))y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 4.9e-167) {
tmp = (x - y) / ((x - y) + (y * (y / x)));
} else if (y <= 1.4e-120) {
tmp = (x - y) / y;
} else if (y <= 1.15e-111) {
tmp = 1.0 + (-2.0 * ((y * y) / (x * x)));
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.9d-167) then
tmp = (x - y) / ((x - y) + (y * (y / x)))
else if (y <= 1.4d-120) then
tmp = (x - y) / y
else if (y <= 1.15d-111) then
tmp = 1.0d0 + ((-2.0d0) * ((y * y) / (x * x)))
else
tmp = (-1.0d0) + ((x * x) / (y * y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 4.9e-167) {
tmp = (x - y) / ((x - y) + (y * (y / x)));
} else if (y <= 1.4e-120) {
tmp = (x - y) / y;
} else if (y <= 1.15e-111) {
tmp = 1.0 + (-2.0 * ((y * y) / (x * x)));
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 4.9e-167: tmp = (x - y) / ((x - y) + (y * (y / x))) elif y <= 1.4e-120: tmp = (x - y) / y elif y <= 1.15e-111: tmp = 1.0 + (-2.0 * ((y * y) / (x * x))) else: tmp = -1.0 + ((x * x) / (y * y)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 4.9e-167) tmp = Float64(Float64(x - y) / Float64(Float64(x - y) + Float64(y * Float64(y / x)))); elseif (y <= 1.4e-120) tmp = Float64(Float64(x - y) / y); elseif (y <= 1.15e-111) tmp = Float64(1.0 + Float64(-2.0 * Float64(Float64(y * y) / Float64(x * x)))); else tmp = Float64(-1.0 + Float64(Float64(x * x) / Float64(y * y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.9e-167) tmp = (x - y) / ((x - y) + (y * (y / x))); elseif (y <= 1.4e-120) tmp = (x - y) / y; elseif (y <= 1.15e-111) tmp = 1.0 + (-2.0 * ((y * y) / (x * x))); else tmp = -1.0 + ((x * x) / (y * y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 4.9e-167], N[(N[(x - y), $MachinePrecision] / N[(N[(x - y), $MachinePrecision] + N[(y * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e-120], N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.15e-111], N[(1.0 + N[(-2.0 * N[(N[(y * y), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.9 \cdot 10^{-167}:\\
\;\;\;\;\frac{x - y}{\left(x - y\right) + y \cdot \frac{y}{x}}\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-120}:\\
\;\;\;\;\frac{x - y}{y}\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{-111}:\\
\;\;\;\;1 + -2 \cdot \frac{y \cdot y}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if y < 4.90000000000000003e-167Initial program 59.0%
associate-/l*59.4%
fma-def59.4%
Simplified59.4%
fma-def59.4%
add-sqr-sqrt59.4%
*-un-lft-identity59.4%
times-frac59.4%
hypot-def59.5%
hypot-def99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 30.8%
cancel-sign-sub-inv30.8%
+-commutative30.8%
neg-mul-130.8%
+-commutative30.8%
sub-neg30.8%
unpow230.8%
associate-*r/31.2%
metadata-eval31.2%
unpow231.2%
associate-*r/31.4%
*-lft-identity31.4%
Simplified31.4%
Taylor expanded in x around inf 31.1%
+-commutative31.1%
mul-1-neg31.1%
sub-neg31.1%
Simplified31.1%
if 4.90000000000000003e-167 < y < 1.39999999999999997e-120Initial program 100.0%
associate-/l*99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 56.8%
if 1.39999999999999997e-120 < y < 1.15e-111Initial program 100.0%
associate-*r/98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
Taylor expanded in y around 0 100.0%
unpow2100.0%
unpow2100.0%
Simplified100.0%
if 1.15e-111 < y Initial program 99.8%
associate-*r/99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
Taylor expanded in y around inf 85.4%
unpow285.4%
Simplified85.4%
Taylor expanded in x around 0 85.9%
sub-neg85.9%
unpow285.9%
unpow285.9%
metadata-eval85.9%
Simplified85.9%
Final simplification38.9%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 7.5e-168)
1.0
(if (<= y 5.8e-121)
(/ (- x y) y)
(if (<= y 1.1e-111) 1.0 (+ (* (/ x y) (/ x y)) -1.0)))))y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 7.5e-168) {
tmp = 1.0;
} else if (y <= 5.8e-121) {
tmp = (x - y) / y;
} else if (y <= 1.1e-111) {
tmp = 1.0;
} else {
tmp = ((x / y) * (x / y)) + -1.0;
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 7.5d-168) then
tmp = 1.0d0
else if (y <= 5.8d-121) then
tmp = (x - y) / y
else if (y <= 1.1d-111) then
tmp = 1.0d0
else
tmp = ((x / y) * (x / y)) + (-1.0d0)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 7.5e-168) {
tmp = 1.0;
} else if (y <= 5.8e-121) {
tmp = (x - y) / y;
} else if (y <= 1.1e-111) {
tmp = 1.0;
} else {
tmp = ((x / y) * (x / y)) + -1.0;
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 7.5e-168: tmp = 1.0 elif y <= 5.8e-121: tmp = (x - y) / y elif y <= 1.1e-111: tmp = 1.0 else: tmp = ((x / y) * (x / y)) + -1.0 return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 7.5e-168) tmp = 1.0; elseif (y <= 5.8e-121) tmp = Float64(Float64(x - y) / y); elseif (y <= 1.1e-111) tmp = 1.0; else tmp = Float64(Float64(Float64(x / y) * Float64(x / y)) + -1.0); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 7.5e-168) tmp = 1.0; elseif (y <= 5.8e-121) tmp = (x - y) / y; elseif (y <= 1.1e-111) tmp = 1.0; else tmp = ((x / y) * (x / y)) + -1.0; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 7.5e-168], 1.0, If[LessEqual[y, 5.8e-121], N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.1e-111], 1.0, N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{-168}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{-121}:\\
\;\;\;\;\frac{x - y}{y}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-111}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + -1\\
\end{array}
\end{array}
if y < 7.4999999999999995e-168 or 5.8e-121 < y < 1.1e-111Initial program 59.2%
associate-*r/59.3%
+-commutative59.3%
fma-def59.4%
Simplified59.4%
Taylor expanded in x around inf 30.4%
if 7.4999999999999995e-168 < y < 5.8e-121Initial program 100.0%
associate-/l*99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 56.8%
if 1.1e-111 < y Initial program 99.8%
associate-*r/99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
Taylor expanded in y around inf 85.4%
unpow285.4%
Simplified85.4%
*-un-lft-identity85.4%
times-frac85.5%
Applied egg-rr85.5%
associate-*l/85.5%
*-lft-identity85.5%
Simplified85.5%
Taylor expanded in x around 0 85.9%
sub-neg85.9%
unpow285.9%
unpow285.9%
times-frac85.9%
metadata-eval85.9%
Simplified85.9%
Final simplification38.1%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 1.3e-162)
1.0
(if (<= y 1.38e-120)
(/ (- x y) y)
(if (<= y 1.1e-111) 1.0 (+ -1.0 (/ (* x x) (* y y)))))))y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.3e-162) {
tmp = 1.0;
} else if (y <= 1.38e-120) {
tmp = (x - y) / y;
} else if (y <= 1.1e-111) {
tmp = 1.0;
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.3d-162) then
tmp = 1.0d0
else if (y <= 1.38d-120) then
tmp = (x - y) / y
else if (y <= 1.1d-111) then
tmp = 1.0d0
else
tmp = (-1.0d0) + ((x * x) / (y * y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.3e-162) {
tmp = 1.0;
} else if (y <= 1.38e-120) {
tmp = (x - y) / y;
} else if (y <= 1.1e-111) {
tmp = 1.0;
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.3e-162: tmp = 1.0 elif y <= 1.38e-120: tmp = (x - y) / y elif y <= 1.1e-111: tmp = 1.0 else: tmp = -1.0 + ((x * x) / (y * y)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.3e-162) tmp = 1.0; elseif (y <= 1.38e-120) tmp = Float64(Float64(x - y) / y); elseif (y <= 1.1e-111) tmp = 1.0; else tmp = Float64(-1.0 + Float64(Float64(x * x) / Float64(y * y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.3e-162) tmp = 1.0; elseif (y <= 1.38e-120) tmp = (x - y) / y; elseif (y <= 1.1e-111) tmp = 1.0; else tmp = -1.0 + ((x * x) / (y * y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.3e-162], 1.0, If[LessEqual[y, 1.38e-120], N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.1e-111], 1.0, N[(-1.0 + N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.3 \cdot 10^{-162}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.38 \cdot 10^{-120}:\\
\;\;\;\;\frac{x - y}{y}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-111}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if y < 1.3e-162 or 1.38e-120 < y < 1.1e-111Initial program 59.2%
associate-*r/59.3%
+-commutative59.3%
fma-def59.4%
Simplified59.4%
Taylor expanded in x around inf 30.4%
if 1.3e-162 < y < 1.38e-120Initial program 100.0%
associate-/l*99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 56.8%
if 1.1e-111 < y Initial program 99.8%
associate-*r/99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
Taylor expanded in y around inf 85.4%
unpow285.4%
Simplified85.4%
Taylor expanded in x around 0 85.9%
sub-neg85.9%
unpow285.9%
unpow285.9%
metadata-eval85.9%
Simplified85.9%
Final simplification38.1%
NOTE: y should be positive before calling this function
(FPCore (x y)
:precision binary64
(if (<= y 2.4e-169)
(- (+ (/ y x) 1.0) (/ y x))
(if (<= y 1.4e-120)
(/ (- x y) y)
(if (<= y 1.1e-111) 1.0 (+ -1.0 (/ (* x x) (* y y)))))))y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 2.4e-169) {
tmp = ((y / x) + 1.0) - (y / x);
} else if (y <= 1.4e-120) {
tmp = (x - y) / y;
} else if (y <= 1.1e-111) {
tmp = 1.0;
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 2.4d-169) then
tmp = ((y / x) + 1.0d0) - (y / x)
else if (y <= 1.4d-120) then
tmp = (x - y) / y
else if (y <= 1.1d-111) then
tmp = 1.0d0
else
tmp = (-1.0d0) + ((x * x) / (y * y))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 2.4e-169) {
tmp = ((y / x) + 1.0) - (y / x);
} else if (y <= 1.4e-120) {
tmp = (x - y) / y;
} else if (y <= 1.1e-111) {
tmp = 1.0;
} else {
tmp = -1.0 + ((x * x) / (y * y));
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 2.4e-169: tmp = ((y / x) + 1.0) - (y / x) elif y <= 1.4e-120: tmp = (x - y) / y elif y <= 1.1e-111: tmp = 1.0 else: tmp = -1.0 + ((x * x) / (y * y)) return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 2.4e-169) tmp = Float64(Float64(Float64(y / x) + 1.0) - Float64(y / x)); elseif (y <= 1.4e-120) tmp = Float64(Float64(x - y) / y); elseif (y <= 1.1e-111) tmp = 1.0; else tmp = Float64(-1.0 + Float64(Float64(x * x) / Float64(y * y))); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 2.4e-169) tmp = ((y / x) + 1.0) - (y / x); elseif (y <= 1.4e-120) tmp = (x - y) / y; elseif (y <= 1.1e-111) tmp = 1.0; else tmp = -1.0 + ((x * x) / (y * y)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 2.4e-169], N[(N[(N[(y / x), $MachinePrecision] + 1.0), $MachinePrecision] - N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.4e-120], N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.1e-111], 1.0, N[(-1.0 + N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4 \cdot 10^{-169}:\\
\;\;\;\;\left(\frac{y}{x} + 1\right) - \frac{y}{x}\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-120}:\\
\;\;\;\;\frac{x - y}{y}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-111}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if y < 2.40000000000000011e-169Initial program 59.0%
associate-*r/59.2%
+-commutative59.2%
fma-def59.2%
Simplified59.2%
fma-udef59.2%
+-commutative59.2%
*-un-lft-identity59.2%
add-sqr-sqrt59.2%
times-frac59.3%
hypot-def59.3%
hypot-def99.7%
Applied egg-rr99.7%
associate-*l/99.7%
*-lft-identity99.7%
+-commutative99.7%
Simplified99.7%
associate-/l/59.2%
+-commutative59.2%
clear-num59.2%
*-un-lft-identity59.2%
frac-times99.7%
div-inv99.9%
/-rgt-identity99.9%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 30.3%
associate-+r+30.3%
+-commutative30.3%
associate-*r/30.3%
neg-mul-130.3%
Simplified30.3%
add-sqr-sqrt29.1%
distribute-frac-neg29.1%
fma-def29.1%
add-sqr-sqrt13.0%
sqrt-unprod28.5%
sqr-neg28.5%
sqrt-unprod15.5%
add-sqr-sqrt28.1%
fma-neg28.1%
add-sqr-sqrt31.1%
add-sqr-sqrt18.5%
sqrt-unprod31.4%
sqr-neg31.4%
sqrt-unprod13.0%
add-sqr-sqrt30.3%
Applied egg-rr30.3%
if 2.40000000000000011e-169 < y < 1.39999999999999997e-120Initial program 100.0%
associate-/l*99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 56.8%
if 1.39999999999999997e-120 < y < 1.1e-111Initial program 100.0%
associate-*r/98.4%
+-commutative98.4%
fma-def98.4%
Simplified98.4%
Taylor expanded in x around inf 100.0%
if 1.1e-111 < y Initial program 99.8%
associate-*r/99.3%
+-commutative99.3%
fma-def99.4%
Simplified99.4%
Taylor expanded in y around inf 85.4%
unpow285.4%
Simplified85.4%
Taylor expanded in x around 0 85.9%
sub-neg85.9%
unpow285.9%
unpow285.9%
metadata-eval85.9%
Simplified85.9%
Final simplification38.2%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 4.8e-164) 1.0 (if (<= y 1.4e-120) -1.0 (if (<= y 1.7e-111) 1.0 -1.0))))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 4.8e-164) {
tmp = 1.0;
} else if (y <= 1.4e-120) {
tmp = -1.0;
} else if (y <= 1.7e-111) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.8d-164) then
tmp = 1.0d0
else if (y <= 1.4d-120) then
tmp = -1.0d0
else if (y <= 1.7d-111) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 4.8e-164) {
tmp = 1.0;
} else if (y <= 1.4e-120) {
tmp = -1.0;
} else if (y <= 1.7e-111) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 4.8e-164: tmp = 1.0 elif y <= 1.4e-120: tmp = -1.0 elif y <= 1.7e-111: tmp = 1.0 else: tmp = -1.0 return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 4.8e-164) tmp = 1.0; elseif (y <= 1.4e-120) tmp = -1.0; elseif (y <= 1.7e-111) tmp = 1.0; else tmp = -1.0; end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 4.8e-164) tmp = 1.0; elseif (y <= 1.4e-120) tmp = -1.0; elseif (y <= 1.7e-111) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 4.8e-164], 1.0, If[LessEqual[y, 1.4e-120], -1.0, If[LessEqual[y, 1.7e-111], 1.0, -1.0]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{-164}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-120}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-111}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if y < 4.79999999999999966e-164 or 1.39999999999999997e-120 < y < 1.69999999999999998e-111Initial program 59.2%
associate-*r/59.3%
+-commutative59.3%
fma-def59.4%
Simplified59.4%
Taylor expanded in x around inf 30.4%
if 4.79999999999999966e-164 < y < 1.39999999999999997e-120 or 1.69999999999999998e-111 < y Initial program 99.9%
associate-*r/99.4%
+-commutative99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in x around 0 75.7%
Final simplification37.9%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 (if (<= y 1.45e-162) 1.0 (/ (- x y) y)))
y = abs(y);
double code(double x, double y) {
double tmp;
if (y <= 1.45e-162) {
tmp = 1.0;
} else {
tmp = (x - y) / y;
}
return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.45d-162) then
tmp = 1.0d0
else
tmp = (x - y) / y
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y) {
double tmp;
if (y <= 1.45e-162) {
tmp = 1.0;
} else {
tmp = (x - y) / y;
}
return tmp;
}
y = abs(y) def code(x, y): tmp = 0 if y <= 1.45e-162: tmp = 1.0 else: tmp = (x - y) / y return tmp
y = abs(y) function code(x, y) tmp = 0.0 if (y <= 1.45e-162) tmp = 1.0; else tmp = Float64(Float64(x - y) / y); end return tmp end
y = abs(y) function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.45e-162) tmp = 1.0; else tmp = (x - y) / y; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_] := If[LessEqual[y, 1.45e-162], 1.0, N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.45 \cdot 10^{-162}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{y}\\
\end{array}
\end{array}
if y < 1.4500000000000001e-162Initial program 59.0%
associate-*r/59.2%
+-commutative59.2%
fma-def59.2%
Simplified59.2%
Taylor expanded in x around inf 30.1%
if 1.4500000000000001e-162 < y Initial program 99.9%
associate-/l*99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 74.0%
Final simplification37.5%
NOTE: y should be positive before calling this function (FPCore (x y) :precision binary64 -1.0)
y = abs(y);
double code(double x, double y) {
return -1.0;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
y = Math.abs(y);
public static double code(double x, double y) {
return -1.0;
}
y = abs(y) def code(x, y): return -1.0
y = abs(y) function code(x, y) return -1.0 end
y = abs(y) function tmp = code(x, y) tmp = -1.0; end
NOTE: y should be positive before calling this function code[x_, y_] := -1.0
\begin{array}{l}
y = |y|\\
\\
-1
\end{array}
Initial program 65.9%
associate-*r/65.9%
+-commutative65.9%
fma-def65.9%
Simplified65.9%
Taylor expanded in x around 0 69.9%
Final simplification69.9%
(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 2023240
(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))))