本文整理匯總了Python中sympy.sin方法的典型用法代碼示例。如果您正苦於以下問題:Python sympy.sin方法的具體用法?Python sympy.sin怎麽用?Python sympy.sin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sympy
的用法示例。
在下文中一共展示了sympy.sin方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_equations
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def get_equations(self):
"""
:return: Functions to calculate A, B and f given state x and input u
"""
f = sp.zeros(3, 1)
x = sp.Matrix(sp.symbols('x y theta', real=True))
u = sp.Matrix(sp.symbols('v w', real=True))
f[0, 0] = u[0, 0] * sp.cos(x[2, 0])
f[1, 0] = u[0, 0] * sp.sin(x[2, 0])
f[2, 0] = u[1, 0]
f = sp.simplify(f)
A = sp.simplify(f.jacobian(x))
B = sp.simplify(f.jacobian(u))
f_func = sp.lambdify((x, u), f, 'numpy')
A_func = sp.lambdify((x, u), A, 'numpy')
B_func = sp.lambdify((x, u), B, 'numpy')
return f_func, A_func, B_func
示例2: get_equations
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def get_equations(self):
"""
:return: Functions to calculate A, B and f given state x and input u
"""
f = sp.zeros(6, 1)
x = sp.Matrix(sp.symbols('rx ry vx vy t w', real=True))
u = sp.Matrix(sp.symbols('gimbal T', real=True))
f[0, 0] = x[2, 0]
f[1, 0] = x[3, 0]
f[2, 0] = 1 / self.m * sp.sin(x[4, 0] + u[0, 0]) * u[1, 0]
f[3, 0] = 1 / self.m * (sp.cos(x[4, 0] + u[0, 0]) * u[1, 0] - self.m * self.g)
f[4, 0] = x[5, 0]
f[5, 0] = 1 / self.I * (-sp.sin(u[0, 0]) * u[1, 0] * self.r_T)
f = sp.simplify(f)
A = sp.simplify(f.jacobian(x))
B = sp.simplify(f.jacobian(u))
f_func = sp.lambdify((x, u), f, 'numpy')
A_func = sp.lambdify((x, u), A, 'numpy')
B_func = sp.lambdify((x, u), B, 'numpy')
return f_func, A_func, B_func
示例3: derivatives_in_spherical_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def derivatives_in_spherical_coordinates():
Print_Function()
X = (r,th,phi) = symbols('r theta phi')
curv = [[r*cos(phi)*sin(th),r*sin(phi)*sin(th),r*cos(th)],[1,r,r*sin(th)]]
(er,eth,ephi,grad) = MV.setup('e_r e_theta e_phi',metric='[1,1,1]',coords=X,curv=curv)
f = MV('f','scalar',fct=True)
A = MV('A','vector',fct=True)
B = MV('B','grade2',fct=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-MV.I*(grad^A))
print('grad^B =',grad^B)
return
示例4: derivatives_in_spherical_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def derivatives_in_spherical_coordinates():
X = (r,th,phi) = symbols('r theta phi')
curv = [[r*cos(phi)*sin(th),r*sin(phi)*sin(th),r*cos(th)],[1,r,r*sin(th)]]
(er,eth,ephi,grad) = MV.setup('e_r e_theta e_phi',metric='[1,1,1]',coords=X,curv=curv)
f = MV('f','scalar',fct=True)
A = MV('A','vector',fct=True)
B = MV('B','grade2',fct=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-MV.I*(grad^A))
print('grad^B =',grad^B)
return
示例5: derivatives_in_spherical_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def derivatives_in_spherical_coordinates():
Print_Function()
X = (r,th,phi) = symbols('r theta phi')
curv = [[r*cos(phi)*sin(th),r*sin(phi)*sin(th),r*cos(th)],[1,r,r*sin(th)]]
(er,eth,ephi,grad) = MV.setup('e_r e_theta e_phi',metric='[1,1,1]',coords=X,curv=curv)
f = MV('f','scalar',fct=True)
A = MV('A','vector',fct=True)
B = MV('B','grade2',fct=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',(-MV.I*(grad^A)).simplify())
print('grad^B =',grad^B)
示例6: derivatives_in_paraboloidal_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def derivatives_in_paraboloidal_coordinates():
#Print_Function()
coords = (u,v,phi) = symbols('u v phi', real=True)
(par3d,er,eth,ephi) = Ga.build('e_u e_v e_phi',X=[u*v*cos(phi),u*v*sin(phi),(u**2-v**2)/2],coords=coords,norm=True)
grad = par3d.grad
f = par3d.mv('f','scalar',f=True)
A = par3d.mv('A','vector',f=True)
B = par3d.mv('B','bivector',f=True)
print('#Derivatives in Paraboloidal Coordinates')
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
(-par3d.i*(grad^A)).Fmt(3,'grad\\times A = -I*(grad^A)')
print('grad^B =',grad^B)
return
示例7: derivatives_in_elliptic_cylindrical_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def derivatives_in_elliptic_cylindrical_coordinates():
#Print_Function()
a = symbols('a', real=True)
coords = (u,v,z) = symbols('u v z', real=True)
(elip3d,er,eth,ephi) = Ga.build('e_u e_v e_z',X=[a*cosh(u)*cos(v),a*sinh(u)*sin(v),z],coords=coords,norm=True)
grad = elip3d.grad
f = elip3d.mv('f','scalar',f=True)
A = elip3d.mv('A','vector',f=True)
B = elip3d.mv('B','bivector',f=True)
print('#Derivatives in Elliptic Cylindrical Coordinates')
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-elip3d.i*(grad^A))
print('grad^B =',grad^B)
return
示例8: derivatives_in_oblate_spheroidal_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def derivatives_in_oblate_spheroidal_coordinates():
Print_Function()
a = symbols('a', real=True)
coords = (xi,eta,phi) = symbols('xi eta phi', real=True)
(os3d,er,eth,ephi) = Ga.build('e_xi e_eta e_phi',X=[a*cosh(xi)*cos(eta)*cos(phi),a*cosh(xi)*cos(eta)*sin(phi),
a*sinh(xi)*sin(eta)],coords=coords,norm=True)
grad = os3d.grad
f = os3d.mv('f','scalar',f=True)
A = os3d.mv('A','vector',f=True)
B = os3d.mv('B','bivector',f=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-os3d.i*(grad^A))
print('grad^B =',grad^B)
return
示例9: derivatives_in_bipolar_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def derivatives_in_bipolar_coordinates():
Print_Function()
a = symbols('a', real=True)
coords = (u,v,z) = symbols('u v z', real=True)
(bp3d,eu,ev,ez) = Ga.build('e_u e_v e_z',X=[a*sinh(v)/(cosh(v)-cos(u)),a*sin(u)/(cosh(v)-cos(u)),z],coords=coords,norm=True)
grad = bp3d.grad
f = bp3d.mv('f','scalar',f=True)
A = bp3d.mv('A','vector',f=True)
B = bp3d.mv('B','bivector',f=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-bp3d.i*(grad^A))
print('grad^B =',grad^B)
return
示例10: derivatives_in_toroidal_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def derivatives_in_toroidal_coordinates():
Print_Function()
a = symbols('a', real=True)
coords = (u,v,phi) = symbols('u v phi', real=True)
(t3d,eu,ev,ephi) = Ga.build('e_u e_v e_phi',X=[a*sinh(v)*cos(phi)/(cosh(v)-cos(u)),
a*sinh(v)*sin(phi)/(cosh(v)-cos(u)),
a*sin(u)/(cosh(v)-cos(u))],coords=coords,norm=True)
grad = t3d.grad
f = t3d.mv('f','scalar',f=True)
A = t3d.mv('A','vector',f=True)
B = t3d.mv('B','bivector',f=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',-t3d.i*(grad^A))
print('grad^B =',grad^B)
return
示例11: derivatives_in_spherical_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def derivatives_in_spherical_coordinates():
Print_Function()
X = (r,th,phi) = symbols('r theta phi')
s3d = Ga('e_r e_theta e_phi',g=[1,r**2,r**2*sin(th)**2],coords=X,norm=True)
(er,eth,ephi) = s3d.mv()
grad = s3d.grad
f = s3d.mv('f','scalar',f=True)
A = s3d.mv('A','vector',f=True)
B = s3d.mv('B','bivector',f=True)
print('f =',f)
print('A =',A)
print('B =',B)
print('grad*f =',grad*f)
print('grad|A =',grad|A)
print('-I*(grad^A) =',(-s3d.E()*(grad^A)).simplify())
print('grad^B =',grad^B)
示例12: test_derivatives_in_spherical_coordinates
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def test_derivatives_in_spherical_coordinates(self):
X = r, th, phi = symbols('r theta phi')
s3d = Ga('e_r e_theta e_phi', g=[1, r ** 2, r ** 2 * sin(th) ** 2], coords=X, norm=True)
er, eth, ephi = s3d.mv()
grad = s3d.grad
f = s3d.mv('f', 'scalar', f=True)
A = s3d.mv('A', 'vector', f=True)
B = s3d.mv('B', 'bivector', f=True)
assert str(f) == 'f'
assert str(A) == 'A__r*e_r + A__theta*e_theta + A__phi*e_phi'
assert str(B) == 'B__rtheta*e_r^e_theta + B__rphi*e_r^e_phi + B__thetaphi*e_theta^e_phi'
assert str(grad*f) == 'D{r}f*e_r + D{theta}f*e_theta/r + D{phi}f*e_phi/(r*sin(theta))'
assert str((grad|A).simplify()) == '(r*D{r}A__r + 2*A__r + A__theta/tan(theta) + D{theta}A__theta + D{phi}A__phi/sin(theta))/r'
assert str(-s3d.I()*(grad^A)) == '(A__phi/tan(theta) + D{theta}A__phi - D{phi}A__theta/sin(theta))*e_r/r + (-r*D{r}A__phi - A__phi + D{phi}A__r/sin(theta))*e_theta/r + (r*D{r}A__theta + A__theta - D{theta}A__r)*e_phi/r'
assert latex(grad) == r'\boldsymbol{e}_{r} \frac{\partial}{\partial r} + \boldsymbol{e}_{\theta } \frac{1}{r} \frac{\partial}{\partial \theta } + \boldsymbol{e}_{\phi } \frac{1}{r \sin{\left (\theta \right )}} \frac{\partial}{\partial \phi }'
assert latex(B|(eth^ephi)) == r'- B^{\theta \phi } {\left (r,\theta ,\phi \right )}'
assert str(grad^B) == '(r*D{r}B__thetaphi - B__rphi/tan(theta) + 2*B__thetaphi - D{theta}B__rphi + D{phi}B__rtheta/sin(theta))*e_r^e_theta^e_phi/r'
示例13: test_conv7b
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def test_conv7b():
x = sympy.Symbol("x")
y = sympy.Symbol("y")
assert sympify(sympy.sin(x/3)) == sin(Symbol("x") / 3)
assert sympify(sympy.sin(x/3)) != cos(Symbol("x") / 3)
assert sympify(sympy.cos(x/3)) == cos(Symbol("x") / 3)
assert sympify(sympy.tan(x/3)) == tan(Symbol("x") / 3)
assert sympify(sympy.cot(x/3)) == cot(Symbol("x") / 3)
assert sympify(sympy.csc(x/3)) == csc(Symbol("x") / 3)
assert sympify(sympy.sec(x/3)) == sec(Symbol("x") / 3)
assert sympify(sympy.asin(x/3)) == asin(Symbol("x") / 3)
assert sympify(sympy.acos(x/3)) == acos(Symbol("x") / 3)
assert sympify(sympy.atan(x/3)) == atan(Symbol("x") / 3)
assert sympify(sympy.acot(x/3)) == acot(Symbol("x") / 3)
assert sympify(sympy.acsc(x/3)) == acsc(Symbol("x") / 3)
assert sympify(sympy.asec(x/3)) == asec(Symbol("x") / 3)
示例14: run_benchmark
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def run_benchmark(n):
a0 = symbols("a0")
a1 = symbols("a1")
e = a0 + a1
f = 0;
for i in range(2, n):
s = symbols("a%s" % i)
e = e + sin(s)
f = f + sin(s)
f = -f
t1 = clock()
e = expand(e**2)
e = e.xreplace({a0: f})
e = expand(e)
t2 = clock()
print("%s ms" % (1000 * (t2 - t1)))
示例15: xiu
# 需要導入模塊: import sympy [as 別名]
# 或者: from sympy import sin [as 別名]
def xiu(n):
points = []
for k in range(n + 1):
pt = []
# Slight adaptation:
# The article has points for the weight 1/sqrt(2*pi) exp(−x**2/2)
# so divide by sqrt(2) to adapt for 1/sqrt(pi) exp(−x ** 2)
for r in range(1, n // 2 + 1):
alpha = (2 * r * k * pi) / (n + 1)
pt += [cos(alpha), sin(alpha)]
if n % 2 == 1:
pt += [(-1) ** k / sqrt(2)]
points.append(pt)
points = numpy.array(points)
weights = numpy.full(n + 1, frac(1, n + 1))
return Enr2Scheme("Xiu", n, weights, points, 2, source)