def test_clambdify():
x = Symbol('x')
y = Symbol('y')
z = Symbol('z')
f1 = sqrt(x*y)
pf1 = lambdify((x, y), f1, 'math')
cf1 = clambdify((x, y), f1)
for i in xrange(10):
if cf1(i, 10 - i) != pf1(i, 10 - i):
raise ValueError("Values should be equal")
f2 = (x - y) / z * pi
pf2 = lambdify((x, y, z), f2, 'math')
cf2 = clambdify((x, y, z), f2)
if round(pf2(1, 2, 3), 14) != round(cf2(1, 2, 3), 14):
raise ValueError("Values should be equal")
# FIXME: slight difference in precision
python类pi()的实例源码
def __init__(self, n):
self.degree = 2
self.dim = n
n2 = fr(n, 2) if n % 2 == 0 else fr(n-1, 2)
pts = [[
[sqrt(fr(2, n+2)) * cos(2*k*i*pi / (n+1)) for i in range(n+1)],
[sqrt(fr(2, n+2)) * sin(2*k*i*pi / (n+1)) for i in range(n+1)],
] for k in range(1, n2+1)]
if n % 2 == 1:
sqrt3pm = numpy.full(n+1, 1/sqrt(n+2))
sqrt3pm[1::2] *= -1
pts.append(sqrt3pm)
pts = numpy.vstack(pts).T
data = [(fr(1, n+1), pts)]
self.points, self.weights = untangle(data)
self.weights *= volume_unit_ball(n)
return
def test_pow_E():
assert 2**(y/log(2)) == S.Exp1**y
assert 2**(y/log(2)/3) == S.Exp1**(y/3)
assert 3**(1/log(-3)) != S.Exp1
assert (3 + 2*I)**(1/(log(-3 - 2*I) + I*pi)) == S.Exp1
assert (4 + 2*I)**(1/(log(-4 - 2*I) + I*pi)) == S.Exp1
assert (3 + 2*I)**(1/(log(-3 - 2*I, 3)/2 + I*pi/log(3)/2)) == 9
assert (3 + 2*I)**(1/(log(3 + 2*I, 3)/2)) == 9
# every time tests are run they will affirm with a different random
# value that this identity holds
while 1:
b = x._random()
r, i = b.as_real_imag()
if i:
break
assert test_numerically(b**(1/(log(-b) + sign(i)*I*pi).n()), S.Exp1)
def equation(self, type='cosine'):
"""
Returns equation of the wave.
Examples
========
>>> from sympy import symbols
>>> from sympy.physics.optics import TWave
>>> A, phi, f = symbols('A, phi, f')
>>> w = TWave(A, f, phi)
>>> w.equation('cosine')
A*cos(2*pi*f*t + phi)
"""
if not isinstance(type, str):
raise TypeError("type can only be a string.")
if type == 'cosine':
return self._amplitude*cos(self.angular_velocity*Symbol('t') + self._phase)
def test_twave():
A1, phi1, A2, phi2, f = symbols('A1, phi1, A2, phi2, f')
c = Symbol('c') # Speed of light in vacuum
n = Symbol('n') # Refractive index
t = Symbol('t') # Time
w1 = TWave(A1, f, phi1)
w2 = TWave(A2, f, phi2)
assert w1.amplitude == A1
assert w1.frequency == f
assert w1.phase == phi1
assert w1.wavelength == c/(f*n)
assert w1.time_period == 1/f
w3 = w1 + w2
assert w3.amplitude == sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2)
assert w3.frequency == f
assert w3.wavelength == c/(f*n)
assert w3.time_period == 1/f
assert w3.angular_velocity == 2*pi*f
assert w3.equation() == sqrt(A1**2 + 2*A1*A2*cos(phi1 - phi2) + A2**2)*cos(2*pi*f*t + phi1 + phi2)
def test_p():
assert Px.hilbert_space == L2(Interval(S.NegativeInfinity, S.Infinity))
assert qapply(Px*PxKet(px)) == px*PxKet(px)
assert PxKet(px).dual_class() == PxBra
assert PxBra(x).dual_class() == PxKet
assert (Dagger(PxKet(py))*PxKet(px)).doit() == DiracDelta(px - py)
assert (XBra(x)*PxKet(px)).doit() == \
exp(I*x*px/hbar)/sqrt(2*pi*hbar)
assert represent(PxKet(px)) == DiracDelta(px - px_1)
rep_x = represent(PxOp(), basis=XOp)
assert rep_x == -hbar*I*DiracDelta(x_1 - x_2)*DifferentialOperator(x_1)
assert rep_x == represent(PxOp(), basis=XOp())
assert rep_x == represent(PxOp(), basis=XKet)
assert rep_x == represent(PxOp(), basis=XKet())
assert represent(PxOp()*XKet(), basis=XKet) == \
-hbar*I*DiracDelta(x - x_2)*DifferentialOperator(x)
assert represent(XBra("y")*PxOp()*XKet(), basis=XKet) == \
-hbar*I*DiracDelta(x - y)*DifferentialOperator(x)
def test_quantum_fourier():
assert QFT(0, 3).decompose() == \
SwapGate(0, 2)*HadamardGate(0)*CGate((0,), PhaseGate(1)) * \
HadamardGate(1)*CGate((0,), TGate(2))*CGate((1,), PhaseGate(2)) * \
HadamardGate(2)
assert IQFT(0, 3).decompose() == \
HadamardGate(2)*CGate((1,), RkGate(2, -2))*CGate((0,), RkGate(2, -3)) * \
HadamardGate(1)*CGate((0,), RkGate(1, -2))*HadamardGate(0)*SwapGate(0, 2)
assert represent(QFT(0, 3), nqubits=3) == \
Matrix([[exp(2*pi*I/8)**(i*j % 8)/sqrt(8) for i in range(8)] for j in range(8)])
assert QFT(0, 4).decompose() # non-trivial decomposition
assert qapply(QFT(0, 3).decompose()*Qubit(0, 0, 0)).expand() == qapply(
HadamardGate(0)*HadamardGate(1)*HadamardGate(2)*Qubit(0, 0, 0)
).expand()
def test_dot_different_frames():
assert dot(N.x, A.x) == cos(q1)
assert dot(N.x, A.y) == -sin(q1)
assert dot(N.x, A.z) == 0
assert dot(N.y, A.x) == sin(q1)
assert dot(N.y, A.y) == cos(q1)
assert dot(N.y, A.z) == 0
assert dot(N.z, A.x) == 0
assert dot(N.z, A.y) == 0
assert dot(N.z, A.z) == 1
assert dot(N.x, A.x + A.y) == sqrt(2)*cos(q1 + pi/4) == dot(A.x + A.y, N.x)
assert dot(A.x, C.x) == cos(q3)
assert dot(A.x, C.y) == 0
assert dot(A.x, C.z) == sin(q3)
assert dot(A.y, C.x) == sin(q2)*sin(q3)
assert dot(A.y, C.y) == cos(q2)
assert dot(A.y, C.z) == -sin(q2)*cos(q3)
assert dot(A.z, C.x) == -cos(q2)*sin(q3)
assert dot(A.z, C.y) == sin(q2)
assert dot(A.z, C.z) == cos(q2)*cos(q3)
def test_vector_simplify():
x, y, z, k, n, m, w, f, s, A = symbols('x, y, z, k, n, m, w, f, s, A')
N = ReferenceFrame('N')
test1 = (1 / x + 1 / y) * N.x
assert (test1 & N.x) != (x + y) / (x * y)
test1 = test1.simplify()
assert (test1 & N.x) == (x + y) / (x * y)
test2 = (A**2 * s**4 / (4 * pi * k * m**3)) * N.x
test2 = test2.simplify()
assert (test2 & N.x) == (A**2 * s**4 / (4 * pi * k * m**3))
test3 = ((4 + 4 * x - 2 * (2 + 2 * x)) / (2 + 2 * x)) * N.x
test3 = test3.simplify()
assert (test3 & N.x) == 0
test4 = ((-4 * x * y**2 - 2 * y**3 - 2 * x**2 * y) / (x + y)**2) * N.x
test4 = test4.simplify()
assert (test4 & N.x) == -2 * y
def test_dyadic_simplify():
x, y, z, k, n, m, w, f, s, A = symbols('x, y, z, k, n, m, w, f, s, A')
N = ReferenceFrame('N')
dy = N.x | N.x
test1 = (1 / x + 1 / y) * dy
assert (N.x & test1 & N.x) != (x + y) / (x * y)
test1 = test1.simplify()
assert (N.x & test1 & N.x) == (x + y) / (x * y)
test2 = (A**2 * s**4 / (4 * pi * k * m**3)) * dy
test2 = test2.simplify()
assert (N.x & test2 & N.x) == (A**2 * s**4 / (4 * pi * k * m**3))
test3 = ((4 + 4 * x - 2 * (2 + 2 * x)) / (2 + 2 * x)) * dy
test3 = test3.simplify()
assert (N.x & test3 & N.x) == 0
test4 = ((-4 * x * y**2 - 2 * y**3 - 2 * x**2 * y) / (x + y)**2) * dy
test4 = test4.simplify()
assert (N.x & test4 & N.x) == -2 * y
def test_Znm():
# http://en.wikipedia.org/wiki/Solid_harmonics#List_of_lowest_functions
th, ph = Symbol("theta", real=True), Symbol("phi", real=True)
from sympy.abc import n,m
assert Znm(0, 0, th, ph) == Ynm(0, 0, th, ph)
assert Znm(1, -1, th, ph) == (-sqrt(2)*I*(Ynm(1, 1, th, ph)
- exp(-2*I*ph)*Ynm(1, 1, th, ph))/2)
assert Znm(1, 0, th, ph) == Ynm(1, 0, th, ph)
assert Znm(1, 1, th, ph) == (sqrt(2)*(Ynm(1, 1, th, ph)
+ exp(-2*I*ph)*Ynm(1, 1, th, ph))/2)
assert Znm(0, 0, th, ph).expand(func=True) == 1/(2*sqrt(pi))
assert Znm(1, -1, th, ph).expand(func=True) == (sqrt(3)*I*sqrt(-cos(th)**2 + 1)*exp(I*ph)/(4*sqrt(pi))
- sqrt(3)*I*sqrt(-cos(th)**2 + 1)*exp(-I*ph)/(4*sqrt(pi)))
assert Znm(1, 0, th, ph).expand(func=True) == sqrt(3)*cos(th)/(2*sqrt(pi))
assert Znm(1, 1, th, ph).expand(func=True) == (-sqrt(3)*sqrt(-cos(th)**2 + 1)*exp(I*ph)/(4*sqrt(pi))
- sqrt(3)*sqrt(-cos(th)**2 + 1)*exp(-I*ph)/(4*sqrt(pi)))
assert Znm(2, -1, th, ph).expand(func=True) == (sqrt(15)*I*sqrt(-cos(th)**2 + 1)*exp(I*ph)*cos(th)/(4*sqrt(pi))
- sqrt(15)*I*sqrt(-cos(th)**2 + 1)*exp(-I*ph)*cos(th)/(4*sqrt(pi)))
assert Znm(2, 0, th, ph).expand(func=True) == 3*sqrt(5)*cos(th)**2/(4*sqrt(pi)) - sqrt(5)/(4*sqrt(pi))
assert Znm(2, 1, th, ph).expand(func=True) == (-sqrt(15)*sqrt(-cos(th)**2 + 1)*exp(I*ph)*cos(th)/(4*sqrt(pi))
- sqrt(15)*sqrt(-cos(th)**2 + 1)*exp(-I*ph)*cos(th)/(4*sqrt(pi)))
def compute_stencil(order, n, x_value, h_value, x0=0.):
"""
computes a stencil of Order order
"""
h,x = symbols('h x')
xs = [x+h*cos(i*pi/n) for i in range(n,-1,-1)]
cs = finite_diff_weights(order, xs, x0)[order][n]
cs = [simplify(c) for c in cs]
cs = [simplify(expr.subs(h, h_value)) for expr in cs]
xs = [simplify(expr.subs(h, h_value)) for expr in xs]
cs = [simplify(expr.subs(x, x_value)) for expr in cs]
xs = [simplify(expr.subs(x, x_value)) for expr in xs]
return xs, cs
##############################################
def test_Mul_is_rational():
x = Symbol('x')
n = Symbol('n', integer=True)
m = Symbol('m', integer=True, nonzero=True)
assert (n/m).is_rational is True
assert (x/pi).is_rational is None
assert (x/n).is_rational is None
assert (m/pi).is_rational is False
r = Symbol('r', rational=True)
assert (pi*r).is_rational is None
# issue 8008
z = Symbol('z', zero=True)
i = Symbol('i', imaginary=True)
assert (z*i).is_rational is None
bi = Symbol('i', imaginary=True, finite=True)
assert (z*bi).is_zero is True
def test_issue_8247_8354():
from sympy import tan
z = sqrt(1 + sqrt(3)) + sqrt(3 + 3*sqrt(3)) - sqrt(10 + 6*sqrt(3))
assert z.is_positive is False # it's 0
z = S('''-2**(1/3)*(3*sqrt(93) + 29)**2 - 4*(3*sqrt(93) + 29)**(4/3) +
12*sqrt(93)*(3*sqrt(93) + 29)**(1/3) + 116*(3*sqrt(93) + 29)**(1/3) +
174*2**(1/3)*sqrt(93) + 1678*2**(1/3)''')
assert z.is_positive is False # it's 0
z = 2*(-3*tan(19*pi/90) + sqrt(3))*cos(11*pi/90)*cos(19*pi/90) - \
sqrt(3)*(-3 + 4*cos(19*pi/90)**2)
assert z.is_positive is not True # it's zero and it shouldn't hang
z = S('''9*(3*sqrt(93) + 29)**(2/3)*((3*sqrt(93) +
29)**(1/3)*(-2**(2/3)*(3*sqrt(93) + 29)**(1/3) - 2) - 2*2**(1/3))**3 +
72*(3*sqrt(93) + 29)**(2/3)*(81*sqrt(93) + 783) + (162*sqrt(93) +
1566)*((3*sqrt(93) + 29)**(1/3)*(-2**(2/3)*(3*sqrt(93) + 29)**(1/3) -
2) - 2*2**(1/3))**2''')
assert z.is_positive is False # it's 0 (and a single _mexpand isn't enough)
def test_p():
assert Px.hilbert_space == L2(Interval(S.NegativeInfinity, S.Infinity))
assert qapply(Px*PxKet(px)) == px*PxKet(px)
assert PxKet(px).dual_class() == PxBra
assert PxBra(x).dual_class() == PxKet
assert (Dagger(PxKet(py))*PxKet(px)).doit() == DiracDelta(px - py)
assert (XBra(x)*PxKet(px)).doit() == \
exp(I*x*px/hbar)/sqrt(2*pi*hbar)
assert represent(PxKet(px)) == DiracDelta(px - px_1)
rep_x = represent(PxOp(), basis=XOp)
assert rep_x == -hbar*I*DiracDelta(x_1 - x_2)*DifferentialOperator(x_1)
assert rep_x == represent(PxOp(), basis=XOp())
assert rep_x == represent(PxOp(), basis=XKet)
assert rep_x == represent(PxOp(), basis=XKet())
assert represent(PxOp()*XKet(), basis=XKet) == \
-hbar*I*DiracDelta(x - x_2)*DifferentialOperator(x)
assert represent(XBra("y")*PxOp()*XKet(), basis=XKet) == \
-hbar*I*DiracDelta(x - y)*DifferentialOperator(x)
def test_quantum_fourier():
assert QFT(0, 3).decompose() == \
SwapGate(0, 2)*HadamardGate(0)*CGate((0,), PhaseGate(1)) * \
HadamardGate(1)*CGate((0,), TGate(2))*CGate((1,), PhaseGate(2)) * \
HadamardGate(2)
assert IQFT(0, 3).decompose() == \
HadamardGate(2)*CGate((1,), RkGate(2, -2))*CGate((0,), RkGate(2, -3)) * \
HadamardGate(1)*CGate((0,), RkGate(1, -2))*HadamardGate(0)*SwapGate(0, 2)
assert represent(QFT(0, 3), nqubits=3) == \
Matrix([[exp(2*pi*I/8)**(i*j % 8)/sqrt(8) for i in range(8)] for j in range(8)])
assert QFT(0, 4).decompose() # non-trivial decomposition
assert qapply(QFT(0, 3).decompose()*Qubit(0, 0, 0)).expand() == qapply(
HadamardGate(0)*HadamardGate(1)*HadamardGate(2)*Qubit(0, 0, 0)
).expand()
def test_dot_rota_grad_SH():
theta, phi = symbols("theta phi")
assert dot_rot_grad_Ynm(1, 1, 1, 1, 1, 0) != \
sqrt(30)*Ynm(2, 2, 1, 0)/(10*sqrt(pi))
assert dot_rot_grad_Ynm(1, 1, 1, 1, 1, 0).doit() == \
sqrt(30)*Ynm(2, 2, 1, 0)/(10*sqrt(pi))
assert dot_rot_grad_Ynm(1, 5, 1, 1, 1, 2) != \
0
assert dot_rot_grad_Ynm(1, 5, 1, 1, 1, 2).doit() == \
0
assert dot_rot_grad_Ynm(3, 3, 3, 3, theta, phi).doit() == \
15*sqrt(3003)*Ynm(6, 6, theta, phi)/(143*sqrt(pi))
assert dot_rot_grad_Ynm(3, 3, 1, 1, theta, phi).doit() == \
sqrt(3)*Ynm(4, 4, theta, phi)/sqrt(pi)
assert dot_rot_grad_Ynm(3, 2, 2, 0, theta, phi).doit() == \
3*sqrt(55)*Ynm(5, 2, theta, phi)/(11*sqrt(pi))
assert dot_rot_grad_Ynm(3, 2, 3, 2, theta, phi).doit() == \
-sqrt(70)*Ynm(4, 4, theta, phi)/(11*sqrt(pi)) + \
45*sqrt(182)*Ynm(6, 4, theta, phi)/(143*sqrt(pi))
def test_vector_simplify():
x, y, z, k, n, m, w, f, s, A = symbols('x, y, z, k, n, m, w, f, s, A')
N = ReferenceFrame('N')
test1 = (1 / x + 1 / y) * N.x
assert (test1 & N.x) != (x + y) / (x * y)
test1 = test1.simplify()
assert (test1 & N.x) == (x + y) / (x * y)
test2 = (A**2 * s**4 / (4 * pi * k * m**3)) * N.x
test2 = test2.simplify()
assert (test2 & N.x) == (A**2 * s**4 / (4 * pi * k * m**3))
test3 = ((4 + 4 * x - 2 * (2 + 2 * x)) / (2 + 2 * x)) * N.x
test3 = test3.simplify()
assert (test3 & N.x) == 0
test4 = ((-4 * x * y**2 - 2 * y**3 - 2 * x**2 * y) / (x + y)**2) * N.x
test4 = test4.simplify()
assert (test4 & N.x) == -2 * y
def test_dyadic_simplify():
x, y, z, k, n, m, w, f, s, A = symbols('x, y, z, k, n, m, w, f, s, A')
N = ReferenceFrame('N')
dy = N.x | N.x
test1 = (1 / x + 1 / y) * dy
assert (N.x & test1 & N.x) != (x + y) / (x * y)
test1 = test1.simplify()
assert (N.x & test1 & N.x) == (x + y) / (x * y)
test2 = (A**2 * s**4 / (4 * pi * k * m**3)) * dy
test2 = test2.simplify()
assert (N.x & test2 & N.x) == (A**2 * s**4 / (4 * pi * k * m**3))
test3 = ((4 + 4 * x - 2 * (2 + 2 * x)) / (2 + 2 * x)) * dy
test3 = test3.simplify()
assert (N.x & test3 & N.x) == 0
test4 = ((-4 * x * y**2 - 2 * y**3 - 2 * x**2 * y) / (x + y)**2) * dy
test4 = test4.simplify()
assert (N.x & test4 & N.x) == -2 * y
def fcts(self):
j = sympy.Matrix([
r**2 * z,
r * z**2
])
# Create an isotropic sigma vector
Sig = sympy.Matrix([
[420/(sympy.pi)*(r*z)**2, 0],
[0, 420/(sympy.pi)*(r*z)**2],
])
return j, Sig
def sol(self):
# Do the inner product! - we are in cyl coordinates!
j, Sig = self.fcts()
jTSj = j.T*Sig*j
# we are integrating in cyl coordinates
ans = sympy.integrate(sympy.integrate(sympy.integrate(r * jTSj,
(r, 0, 1)),
(t, 0, 2*sympy.pi)),
(z, 0, 1))[0] # The `[0]` is to make it an int.
return ans
def fcts(self):
j = sympy.Matrix([
r**2 * z,
r * z**2
])
# Create an isotropic sigma vector
Sig = sympy.Matrix([
[120/(sympy.pi)*(r*z)**2, 0],
[0, 420/(sympy.pi)*(r*z)**2],
])
return j, Sig
def fcts(self):
h = sympy.Matrix([r**2 * z])
# Create an isotropic sigma vector
Sig = sympy.Matrix([200/(sympy.pi)*(r*z)**2])
return h, Sig
def sol(self):
h, Sig = self.fcts()
# Do the inner product! - we are in cyl coordinates!
hTSh = h.T*Sig*h
ans = sympy.integrate(sympy.integrate(sympy.integrate(r * hTSh,
(r, 0, 1)),
(t, 0, 2*sympy.pi)),
(z, 0, 1))[0] # The `[0]` is to make it an int.
return ans
def __init__(self, n, index):
self.dim = n
if index == 2:
self.degree = 2
r = sqrt(3) / 6
data = [
(1.0, numpy.array([numpy.full(n, 2*r)])),
(+r, _s(n, -1, r)),
(-r, _s(n, +1, r)),
]
else:
assert index == 3
self.degree = 3
n2 = n // 2 if n % 2 == 0 else (n-1)//2
i_range = range(1, 2*n+1)
pts = [[
[sqrt(fr(2, 3)) * cos((2*k-1)*i*pi / n) for i in i_range],
[sqrt(fr(2, 3)) * sin((2*k-1)*i*pi / n) for i in i_range],
] for k in range(1, n2+1)]
if n % 2 == 1:
sqrt3pm = numpy.full(2*n, 1/sqrt(3))
sqrt3pm[1::2] *= -1
pts.append(sqrt3pm)
pts = numpy.vstack(pts).T
data = [(fr(1, 2*n), pts)]
self.points, self.weights = untangle(data)
reference_volume = 2**n
self.weights *= reference_volume
return
def __init__(self, key):
self.degree, data = _gen[key]()
self.points, self.weights = untangle(data)
self.weights *= sqrt(pi)**3
return
def __init__(self, n, index):
self.dim = n
if index == 'I':
self.degree = 2
data = [
(fr(1, n+1), sqrt(fr(1, 2)) * _nsimplex(n))
]
elif index == 'II':
self.degree = 3
nu = sqrt(fr(n, 2))
data = [
(fr(1, 2*n), fsd(n, (nu, 1)))
]
elif index == 'III':
self.degree = 3
nu = sqrt(fr(1, 2))
data = [
(fr(1, 2**n), pm(n, nu))
]
else:
assert index == 'IV'
self.degree = 5
nu = sqrt(fr(n+2, 2))
xi = sqrt(fr(n+2, 4))
A = fr(2, n+2)
B = fr(4-n, 2 * (n+2)**2)
C = fr(1, (n+2)**2)
data = [
(A, numpy.full((1, n), 0)),
(B, fsd(n, (nu, 1))),
(C, fsd(n, (xi, 2))),
]
self.points, self.weights = untangle(data)
self.weights *= sqrt(pi)**n
return
def __init__(self, n):
self.name = 'Dobrodeev'
self.degree = 7
self.dim = n
A = fr(1, 8)
B = fr(5-n, 4)
C = fr((6 - n) * (1 - n**2) + 36, 4*(n + 3))
D = fr(81, (n + 3) * (n + 6)**2)
E = fr(45*n**2 + 324*n + 216, n**2 + 12*n + 36) \
- fr(n * (n**2 - 12*n + 65), 6)
r = sqrt(fr(3, n+6))
data = [
(A, fsd(n, (r, 3))),
(B, fsd(n, (r, 2))),
(C, fsd(n, (r, 1))),
(D, fsd(n, (1, 1))),
(E, z(n)),
]
self.points, self.weights = untangle(data)
self.weights /= (
fr(n, 2) * gamma(fr(n, 2)) / sqrt(pi)**n
* fr(27 * (n+2) * (n+4), (n+6)**2)
)
return
def __init__(self, n, key):
self.dim = n
self.degree, data = _gen[key](n)
self.points, self.weights = untangle(data)
self.weights *= 2 * sqrt(pi)**n * gamma(n) / gamma(fr(n, 2))
return
def __init__(self, n):
self.weights = numpy.full(n, 2*sympy.pi/n)
self.points = numpy.column_stack([
[sympy.cos(sympy.pi * sympy.Rational(2*k, n)) for k in range(n)],
[sympy.sin(sympy.pi * sympy.Rational(2*k, n)) for k in range(n)],
])
self.degree = n - 1
return