PDEs module

95 views
Skip to first unread message

KSHITIJ SONI 19PE10041

unread,
Mar 15, 2022, 4:51:04 AM3/15/22
to sympy
Hey!

I went through all the SymPy ideas, I also mailed Aaron regarding my interest in Risch Algorithm. But as GSoC allow open ideas. I would like to take up the task of solving PDEs.

To start with we can develop :
1. Lagrange's  Equation
2. Charpit's method

I think that within 350 hr constraint these two methods can be developed and improvised. After the GSoC timeline, I would like to add Non-Linear First order equations, higher-order linear equations with constant coefficients, quasi-linear second-order equations ( Monge's method).

Partial Differential Equations have enormous applications, if we can introduce this module we can take it forward with SymPy. PDEs has the capability to have software of their own. 




 

Oscar Benjamin

unread,
Mar 16, 2022, 6:21:13 PM3/16/22
to sympy
While PDEs do have enormous applications the vast majority of work
with them is numeric rather than symbolic and there are clear reasons
for that. It's really not clear to me if it is even possible to define
a meaningful subset of PDEs that can be handled purely analytically in
a systematic way.

Various methods for PDEs are commonly taught in various courses and
textbooks but few of them actually stand up when applied to problems
that are not contrived. Speaking as someone who has taught such things
I can tell you that the examples that are used (in lectures, books and
exams) are selected very carefully. That's because there is an
extremely thin line between problems that are totally trivial and the
problems where some or other method theoretically applies but is
completely intractable and fails in practice.

Charpit's method is a good example where exam questions are recycled
not out of laziness but necessity: there are really only a handful of
problems that you could ever pose for it. I'm not convinced that it is
useful to add functionality for this sort of thing to SymPy. Certainly
it is not a priority right now.

A more useful way to go with PDEs is probably something like making
use of symbolics to complement or facilitate numerical applications.
SymPy currently lacks even the capability to numerically solve ODEs
though and that's far more important:
https://github.com/sympy/sympy/issues/18023

--
Oscar

Peter Stahlecker

unread,
Mar 16, 2022, 7:33:22 PM3/16/22
to sy...@googlegroups.com
Dear Oscar,

Just for my understanding:

Why do you feel, it would be useful for sympy to be able to numerically solve ordinary differential equations?
Scipy seems to have very good routines to do this - or am I wrong, and they are not as good as I think?

Thanks!

Peter

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAHVvXxTxzeqGcqE_a0-S3rEz-0YQzzg63ZvF6k6Cy2Tz0u2o%3DQ%40mail.gmail.com.
--
Best regards,

Peter Stahlecker

Oscar Benjamin

unread,
Mar 16, 2022, 8:54:53 PM3/16/22
to sympy
On Wed, 16 Mar 2022 at 23:33, Peter Stahlecker
<peter.st...@gmail.com> wrote:
>
> Dear Oscar,

Hi Peter!

> Just for my understanding:
>
> Why do you feel, it would be useful for sympy to be able to numerically solve ordinary differential equations?
> Scipy seems to have very good routines to do this - or am I wrong, and they are not as good as I think?

The SciPy routines are good for most usage. The mpmath library that
sympy depends on also has routines that can do high accuracy
multiprecision routines. I don't propose that SymPy should reimplement
what those libraries do.

What is lacking is simply the code that connects from SymPy to the
existing routines in the other libraries. It should be
straight-forward for someone to use SymPy to build up a system of ODEs
and then obtain a numerical solution. Currently that is possible using
lambdify but it's more awkward than it should be given that it is a
common task.

Those of us who are used to numerical libraries are used to the idea
that you have to transform your system to obtain a numerical solution.
Let's give an example:

You want to solve x'' = -x with initial conditions x(0) = 1 and
x'(0)=0. How do I do that with SciPy:

1. First transform the 2nd order ODE into a system of 1st order ODEs:

x' = v
v' = -x

2. Imagine that this is a matrix ODE X' = f(X, t) and create the function f:

def f(X, t):
x, v = X
dxdt = v
dvdt = -x
dXdt = [dxdt, dvdt]
return dXdt

3. Now pass this to the numerical solver:

from scipy.integrate import ...
X0 = [1, 0]
t = np.linspace(0, 100, 1000)
(etc.)

My point is that it would be nice if SymPy could do most of these
steps for you. Why should you have to translate a 2nd order ODE to 1st
order when the computer can do that for you? Why should you have to
explicitly write out the function f when you already have equations
that describe your ODE?

The example I gave above was very simple but it takes time for people
to get their heads round how to implement those steps. (I have run
classes that teach this so I know it's not trivial!)

Yesterday I sat next to a student and carefully compared his code with
the relevant paper and I found three mistakes in one equation. That
equation spanned several lines of code and the comparison (code vs
paper) was painstaking. If the code had built up a SymPy equation then
the equation could have been printed and compared with the paper and
then the differences would have been much more obvious. Also by using
subs etc the chance of a mistake is lower.

That's one reason why it is better to build up your function f using
something like SymPy. Why shouldn't you do that and then ask for the
numerical solution (which the computer would then find with no other
input needed)? The chance of making mistakes could be much smaller.

--
Oscar

Peter Stahlecker

unread,
Mar 16, 2022, 9:12:28 PM3/16/22
to sy...@googlegroups.com
Dear Oscar,

Fully clear now!
My main 'toy' ( I am a semi retired salesman and do all this programing for the fun of it only) is symy.physics.mechanics, which gives the first order ODE's.
So, I did not think about your points.
I agree, such an 'interface', to avoid the trouble and the mistakes would be excellent!
Thanks,

Peter  

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.

Chris Smith

unread,
Mar 18, 2022, 9:55:30 AM3/18/22
to sympy
Another example of letting symbolics help numerics is in solving a BVP where a boundary conditions must be stated. When one is experimenting with conditions and how to state them, it is useful to check the symbolic representation on a small number of nodes to see if the conditions are mathematically meaningful, i.e. don't lead to a singular system because of circular reasoning.

/c

KSHITIJ SONI 19PE10041

unread,
Mar 20, 2022, 1:25:12 PM3/20/22
to sympy
Dear Oscar, 

I got your point!

Apologies for being inactive as I was unwell 

Reply all
Reply to author
Forward
0 new messages