如何在SymPy中获得方程式的任何一方?

eri*_*i0o 5 python math sympy

假设我有以下代码.我想得到方程的右边(C1 + x ......).我怎么做?

我的问题是我在特定点有f(x)导数的一些边界条件,所以我想计算它们并找出常数.我对w(x)也有不同的值,所以最终的代码将开始定义一个名为wx的变量,而不是函数w(x).

from __future__ import division
from sympy import *
x, y = symbols('x y')
w, f = symbols('w f', cls=Function)
init_printing(use_unicode=True)

diffeq = f(x).diff(x,x,x,x)-w(x)
expr = dsolve(diffeq, f(x))

print diffeq
print expr
Run Code Online (Sandbox Code Playgroud)

结果:

-w(x) + Derivative(f(x), x, x, x, x)
f(x) == C1 + x**3*(C4 + Integral(w(x)/6, x)) + x**2*(C3 - Integral(x*w(x)/2, x)) + x*(C2 + Integral(x**2*w(x)/2, x)) - Integral(x**3*w(x)/6, x)
Run Code Online (Sandbox Code Playgroud)

asm*_*rer 5

expr.lhs并且expr.rhs会给你等式的左边和右边。