Partial Differential Equations
PDEs can be also solved with the sympy module and the pdsolve
function.
Here is how this can be done, step by step to solve the PDE 1 + (2(ux/u)) + (3(uy/u)):
-
Import sympy
from sympy.solvers.pde import pdsolve from sympy import Function, Eq
-
Create symbols
We need to tell sympy that the letters
x
andy
represents a symbol whilstf
is a function..from sympy.abc import x, y f = Function('f')
-
Calculate derivatives and define equation
u = f(x, y) ux = u.diff(x) uy = u.diff(y) eq = Eq(1 + (2*(ux/u)) + (3*(uy/u)), 0)
-
Solve the PDE.
pdsolve(eq)