python求解幂函数 python中幂函数( 三 )


Eq(x, y),,solveset(Eq(x**2, 1), x)解出来x,当二式相等 。和solveset(Eq(x**2 - 1, 0), x)等价 。solveset(x**2 - 1, x)
solveset(x**2 - x, x)解,solveset(x - x, x, domain=S.Reals)解出来定义域 。solveset(exp(x), x)# No solution exists解出EmptySet()表示空集 。
等式形式linsolve([x + y + z - 1, x + y + 2*z - 3 ], (x, y, z))和矩阵法linsolve(Matrix(([1, 1, 1, 1], [1, 1, 2, 3])), (x, y, z))得到{(-y - 1, y, 2)}
A*x = b 形式,M=Matrix(((1,1,1,1),(1,1,2,3))),system=A,b=M[:,:-1],M[:,-1],linsolve(system,x,y,z),,solveset(x**3 - 6*x**2 + 9*x, x)解多项式 。roots(x**3 - 6*x**2 + 9*x, x),得出,{3: 2, 0: 1} , 有2个3的重根,1个0根 。solve([x*y - 1, x - 2], x, y)解出坐标 。
f, g = symbols('f g', cls=Function)函数的定义,解微分方程diffeq = Eq(f(x).diff(x, x) - 2*f(x).diff(x) + f(x), sin(x))再和dsolve(diffeq,f(x))结合 。得到Eq(f(x), (C1 + C2*x)*exp(x) + cos(x)/2),dsolve(f(x).diff(x)*(1 - sin(f(x))), f(x))解出来Eq(f(x) + cos(f(x)), C1), , 
Matrix([[1,-1],[3,4],[0,2]]),,Matrix([1, 2, 3])列表示 。M=Matrix([[1,2,3],[3,2,1]])
N=Matrix([0,1,1])
M*N符合矩阵的乘法 。M.shape显示矩阵的行列数 。
M.row(0)获取M的第0行 。M.col(-1)获取倒数第一列 。
M.col_del(0)删掉第1列 。M.row_del(1)删除第二行,序列是从0开始的 。M = M.row_insert(1, Matrix([[0, 4]]))插入第二行, , M = M.col_insert(0, Matrix([1, -2]))插入第一列 。
M+N矩阵相加,M*N,3*M , M**2,M**-1 , N**-1表示求逆 。M.T求转置 。
eye(3)单位 。zeros(2, 3),0矩阵,ones(3, 2)全1,diag(1, 2, 3)对角矩阵 。diag(-1, ones(2, 2), Matrix([5, 7, 5]))生成Matrix([
[-1, 0, 0, 0],
[ 0, 1, 1, 0],
[ 0, 1, 1, 0],
[ 0, 0, 0, 5],
[ 0, 0, 0, 7],
[ 0, 0, 0, 5]])矩阵 。
Matrix([[1, 0, 1], [2, -1, 3], [4, 3, 2]])
一行一行显示, , M.det()求行列式 。M.rref()矩阵化简 。得到结果为Matrix([
[1, 0,1,3],
[0, 1, 2/3, 1/3],
[0, 0,0,0]]), [0, 1]) 。
M = Matrix([[1, 2, 3, 0, 0], [4, 10, 0, 0, 1]]),M.nullspace()
Columnspace
M.columnspace()和M = Matrix([[1, 2, 3, 0, 0], [4, 10, 0, 0, 1]])
M = Matrix([[3, -2,4, -2], [5,3, -3, -2], [5, -2,2, -2], [5, -2, -3,3]])和M.eigenvals()得到{3: 1, -2: 1, 5: 2}, , This means thatMhas eigenvalues -2, 3, and 5, and that the eigenvalues -2 and 3 have algebraic multiplicity 1 and that the eigenvalue 5 has algebraic multiplicity 2.
P, D = M.diagonalize(),P得Matrix([
[0, 1, 1,0],
[1, 1, 1, -1],
[1, 1, 1,0],
[1, 1, 0,1]]),,D为Matrix([
[-2, 0, 0, 0],
[ 0, 3, 0, 0],
[ 0, 0, 5, 0],
[ 0, 0, 0, 5]])
P*D*P**-1 == M返回为True 。lamda = symbols('lamda') 。
lamda = symbols('lamda')定义变量,p = M.charpoly(lamda)和factor(p)
expr = x**2 + x*y,srepr(expr)可以将表达式说明计算法则 , "Add(Pow(Symbol('x'), Integer(2)), Mul(Symbol('x'), Symbol('y')))" 。。
x = symbols('x')和x = Symbol('x')是一样的 。srepr(x**2)得到"Pow(Symbol('x'), Integer(2))" 。Pow(x, 2)和Mul(x, y)得到x**2 。x*y
type(2)得到class 'int',type(sympify(2))得到class 'sympy.core.numbers.Integer'..srepr(x*y)得到"Mul(Symbol('x'), Symbol('y'))" 。。。
Add(Pow(x, 2), Mul(x, y))得到"Add(Mul(Integer(-1), Pow(Symbol('x'), Integer(2))), Mul(Rational(1, 2), sin(Mul(Symbol('x'), Symbol('y')))), Pow(Symbol('y'), Integer(-1)))" 。。Pow函数为幂次 。
expr = Add(x, x),expr.func 。。Integer(2).func , class 'sympy.core.numbers.Integer',,Integer(0).func和Integer(-1).func , ,,expr = 3*y**2*x和expr.func得到class 'sympy.core.mul.Mul',,expr.args将表达式分解为得到(3, x, y**2) , ,expr.func(*expr.args)合并 。expr == expr.func(*expr.args)返回True 。expr.args[2]得到y**2,expr.args[1]得到x , expr.args[0]得到3. 。

推荐阅读