当前位置: 首页>>代码示例>>Python>>正文


Python sympy.cos方法代码示例

本文整理汇总了Python中sympy.cos方法的典型用法代码示例。如果您正苦于以下问题:Python sympy.cos方法的具体用法?Python sympy.cos怎么用?Python sympy.cos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy的用法示例。


在下文中一共展示了sympy.cos方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_equations

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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 
开发者ID:EmbersArc,项目名称:SCvx,代码行数:24,代码来源:diffdrive_2d.py

示例2: get_equations

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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 
开发者ID:EmbersArc,项目名称:SCvx,代码行数:27,代码来源:rocket_landing_2d.py

示例3: derivatives_in_spherical_coordinates

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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 
开发者ID:pygae,项目名称:galgebra,代码行数:21,代码来源:spherical_latex.py

示例4: derivatives_in_spherical_coordinates

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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 
开发者ID:pygae,项目名称:galgebra,代码行数:21,代码来源:terminal_check.py

示例5: derivatives_in_spherical_coordinates

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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) 
开发者ID:pygae,项目名称:galgebra,代码行数:20,代码来源:latex_check.py

示例6: derivatives_in_paraboloidal_coordinates

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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 
开发者ID:pygae,项目名称:galgebra,代码行数:24,代码来源:curvi_linear_latex.py

示例7: derivatives_in_elliptic_cylindrical_coordinates

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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 
开发者ID:pygae,项目名称:galgebra,代码行数:24,代码来源:curvi_linear_latex.py

示例8: derivatives_in_prolate_spheroidal_coordinates

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [as 别名]
def derivatives_in_prolate_spheroidal_coordinates():
    #Print_Function()
    a = symbols('a', real=True)
    coords = (xi,eta,phi) = symbols('xi eta phi', real=True)
    (ps3d,er,eth,ephi) = Ga.build('e_xi e_eta e_phi',X=[a*sinh(xi)*sin(eta)*cos(phi),a*sinh(xi)*sin(eta)*sin(phi),
                                                        a*cosh(xi)*cos(eta)],coords=coords,norm=True)
    grad = ps3d.grad

    f = ps3d.mv('f','scalar',f=True)
    A = ps3d.mv('A','vector',f=True)
    B = ps3d.mv('B','bivector',f=True)

    print('#Derivatives in Prolate Spheroidal Coordinates')

    print('f =',f)
    print('A =',A)
    print('B =',B)

    print('grad*f =',grad*f)
    print('grad|A =',grad|A)
    (-ps3d.i*(grad^A)).Fmt(3,'-I*(grad^A)')
    (grad^B).Fmt(3,'grad^B')
    return 
开发者ID:pygae,项目名称:galgebra,代码行数:25,代码来源:curvi_linear_latex.py

示例9: derivatives_in_oblate_spheroidal_coordinates

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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 
开发者ID:pygae,项目名称:galgebra,代码行数:23,代码来源:curvi_linear_latex.py

示例10: derivatives_in_toroidal_coordinates

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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 
开发者ID:pygae,项目名称:galgebra,代码行数:24,代码来源:curvi_linear_latex.py

示例11: test_conv7b

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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) 
开发者ID:symengine,项目名称:symengine.py,代码行数:18,代码来源:test_sympy_conv.py

示例12: xiu

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [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) 
开发者ID:nschloe,项目名称:quadpy,代码行数:19,代码来源:_xiu.py

示例13: stroud_s2_9_3

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [as 别名]
def stroud_s2_9_3():
    # spherical product gauss 9
    sqrt = numpy.vectorize(sympy.sqrt)
    pm_ = numpy.array([+1, -1])
    cos = numpy.vectorize(sympy.cos)
    sin = numpy.vectorize(sympy.sin)
    frac = sympy.Rational
    pi = sympy.pi

    r1, r2 = sqrt((6 - pm_ * sqrt(6)) / 10)

    a = (numpy.arange(10) + 1) * pi / 5
    x = numpy.array([cos(a), sin(a)]).T

    B0 = frac(1, 9)
    B1, B2 = (16 + pm_ * sqrt(6)) / 360

    data = [(B0, z(2)), (B1, r1 * x), (B2, r2 * x)]
    points, weights = untangle(data)
    return S2Scheme("Stroud S2 9-3", weights, points, 9, _source) 
开发者ID:nschloe,项目名称:quadpy,代码行数:22,代码来源:_stroud.py

示例14: albrecht_4

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [as 别名]
def albrecht_4():
    sqrt111 = sqrt(111)
    rho1, rho2 = sqrt((96 - pm_ * 4 * sqrt(111)) / 155)

    alpha = 2 * numpy.arange(6) * pi / 6
    s = numpy.array([cos(alpha), sin(alpha)]).T

    alpha = (2 * numpy.arange(6) + 1) * pi / 6
    t = numpy.array([cos(alpha), sin(alpha)]).T

    B0 = frac(251, 2304)
    B1, B2 = (110297 + pm_ * 5713 * sqrt111) / 2045952
    C = frac(125, 3072)

    data = [(B0, z(2)), (B1, rho1 * s), (B2, rho2 * s), (C, sqrt(frac(4, 5)) * t)]

    points, weights = untangle(data)
    return S2Scheme("Albrecht 4", weights, points, 9, _source) 
开发者ID:nschloe,项目名称:quadpy,代码行数:20,代码来源:_albrecht.py

示例15: hammer_stroud_18

# 需要导入模块: import sympy [as 别名]
# 或者: from sympy import cos [as 别名]
def hammer_stroud_18():
    # ENH The article only gives floats, but really this is the spherical-product gauss
    # formula as described in Strouds book, S2 7-2.
    #
    # data = [
    #     (frac(1, 16), fs([0.4247082002778669, 0.1759198966061612])),
    #     (frac(1, 16), fs([0.8204732385702833, 0.3398511429799874])),
    # ]
    r1, r2 = sqrt((3 - pm_ * sqrt(3)) / 6)

    a = (2 * numpy.arange(8) + 1) * pi / 8
    x = numpy.array([cos(a), sin(a)]).T

    data = [(frac(1, 16), r1 * x), (frac(1, 16), r2 * x)]
    points, weights = untangle(data)
    return S2Scheme("Hammer-Stroud 18", weights, points, 7, _source) 
开发者ID:nschloe,项目名称:quadpy,代码行数:18,代码来源:_hammer_stroud.py


注:本文中的sympy.cos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。