Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get either side of equation in SymPy?

Tags:

python

math

sympy

Suppose I have the code below. I want to get either the right side of the equation (C1 +x...). How do I do that?

My problem is I have some boundary conditions for derivatives of f(x) at specific points, so I want to calculate those and find out the constants. I have also different values for w(x), so the final code will begin defining a variable called wx instead of having the function 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

results:

-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)
like image 584
eri0o Avatar asked Jan 13 '15 19:01

eri0o


1 Answers

expr.lhs and expr.rhs will give you the left- and right-hand sides of the equation.

like image 109
asmeurer Avatar answered Oct 14 '22 23:10

asmeurer