Differential equations
Author Message
Differential equations

Hi

Is there a module that provides a function to do differential equations in python, for example: func(2x^3+3x-10,x) returns a string or anything else like "6x^2+3". I googled around but I couldn't find anything.

thanks

Sun, 29 May 2005 02:37:12 GMT
Differential equations

Hi

Is there a module that provides a function to do differential equations in python, for example: dy/dx(2x^3+3x-10,x) returns a string or anything else like "6x^2+3". I googled around but I couldn't find anything.

thanks

Sun, 29 May 2005 05:30:21 GMT
Differential equations

Quote:

> Is there a module that provides a function to do differential
> equations in python, for example: func(2x^3+3x-10,x) returns a
> string or anything else like "6x^2+3". I googled around but I
> couldn't find anything.

The hard part of stuff like this is parsing the string "2x^3+3x-10".
If you can convince yourself you can live with Lisp's prefix notation,
writing this sort of thing is dead easy in scheme or CL...

I don't know of anything off hand in Python, sorry.

Cheers,
M.

--
And not only in the sense that they imagine heretics where these do
not exist, but also that inquistors repress the heretical
putrefaction so vehemently that many are driven to share in it, in
their hatred of the judges.     -- The Name Of The Rose, Umberto Eco

Sun, 29 May 2005 22:35:25 GMT
Differential equations

Hi

Is there a module that provides a function to do differential equations in python, for example: dy/dx(2x^3+3x-10,x) returns a string or anything else like "6x^2+3". I googled around but I couldn't find anything.

thanks

Mon, 30 May 2005 01:53:27 GMT
Differential equations

Quote:

> Is there a module that provides a function to do differential
> equations in python, for example: dy/dx(2x^3+3x-10,x) returns a
> string or anything else like "6x^2+3". I googled around but I
> couldn't find anything.

Try googling for "symbolic differentiation".  Differential equations
means something different.  If it's for a homework assignment, though,
you're supposed to write the code yourself.

Mon, 30 May 2005 02:12:59 GMT
Differential equations

Quote:

> [-- text/plain, encoding quoted-printable, 8 lines --]

> Hi

> Is there a module that provides a function to do differential
> equations in python, for example: func(2x^3+3x-10,x) returns a string
> or anything else like "6x^2+3". I googled around but I couldn't find
> anything.

> thanks

It is derivative.  Differential equation is slightly different
thing.  Search for
symbolic+derivative+integral+differentiation+integration

--

Linux solution for data management and processing.

Mon, 30 May 2005 03:44:16 GMT
Differential equations

Quote:
> The hard part of stuff like this is parsing the string
> "2x^3+3x-10".

I looked around and couldn't find a python interface to Maxima.
But it should be straightforward to create an interface that ships
off various symbolic computations to be computed to Maxima (built
on lisp).

Emacs also has a "calc" module that does symbolic derivatives, and
pymacs should be able to access it.

--
Bay Area Python Interest Group - http://www.baypiggies.net/

Mon, 30 May 2005 03:34:05 GMT
Differential equations

Quote:

> Hi

> Is there a module that provides a function to do differential equations in
> python, for example: func(2x^3+3x-10,x) returns a string or anything else
> like "6x^2+3". I googled around but I couldn't find anything.

differentiation module. Big, big difference. For the first, look at SciPy. It
has features for _numerical_ integration of odes, and I think also some basic
stuff for pdes (could be wrong there). There's no well developed symbolic
math project in python that I know of. Your best bet is PyGiNaC at:
http://cens.ioc.ee/projects/pyginac. But I know Pearu has been busy with
other things lately, so I don't know under how much development this is.

I've also heard rumors of people calling Mathematica from python, but haven't
seen any code.

Doing polynomials is trivial, but it's also trivial by hand, so you don't need
a computer for that :) Writing a generic differentiator isn't really that
difficult either, even if it's tricky to get all the details right. An
integrator, on the other hand...

Good luck,

f.

Mon, 30 May 2005 05:25:08 GMT
Differential equations

Ok, first of all I'm sorry for my fault. That's the problem if you only
learn specific expressions in german which you would never learn in the
english course.
Anyway. What I would like to say is that I need this function for a python
script where I have a long equation where practically all parameters change
during runtime. So I'm not very fond of derive this huge equation and then
type it in, and I thought if even small pocket calculators with their CAS
(Ti-92) are able to perfom it, with python there shouldn't exist any
problem. To write code by myself would be funny (and not so easy when I
think at rules like:
(f(x)*g(x))'=f(x)'*g(x)+g(x)'*f(x), here especially the parsing is difficult
in my oppinion) but the loss of time wouldn't be comparable to the use for
my main script. All in all thank you for the hints. I will try them.

Greetings

Quote:
----- Original Message -----

> Newsgroups: comp.lang.python

> Sent: Wednesday, December 11, 2002 10:25 PM
> Subject: Re: Differential equations

> > > Hi

> > > Is there a module that provides a function to do differential
equations
> in
> > > python, for example: func(2x^3+3x-10,x) returns a string or anything
> else
> > > like "6x^2+3". I googled around but I couldn't find anything.

> symbolic
> > differentiation module. Big, big difference. For the first, look at
SciPy.
> It
> > has features for _numerical_ integration of odes, and I think also some
> basic
> > stuff for pdes (could be wrong there). There's no well developed
symbolic
> > math project in python that I know of. Your best bet is PyGiNaC at:
> > http://cens.ioc.ee/projects/pyginac. But I know Pearu has been busy with
> > other things lately, so I don't know under how much development this is.

> > I've also heard rumors of people calling Mathematica from python, but
> haven't
> > seen any code.

> > Doing polynomials is trivial, but it's also trivial by hand, so you
don't
> need
> > a computer for that :) Writing a generic differentiator isn't really
that
> > difficult either, even if it's tricky to get all the details right. An
> > integrator, on the other hand...

> > Good luck,

> > f.
> > --
> > http://mail.python.org/mailman/listinfo/python-list

Mon, 30 May 2005 06:16:00 GMT
Differential equations

Quote:

> What I would like to say is that I need this function for a python
> script where I have a long equation where practically all parameters change
> during runtime. So I'm not very fond of derive this huge equation and then
> type it in, and I thought if even small pocket calculators with their CAS
> (Ti-92) are able to perfom it, with python there shouldn't exist any
> problem.

Well, it's not compute-intensive, but the code needs to be written :) And as I
said, while a symbolic differentiator is not a _fundamentally_ difficult
problem, making sure that all the details are done right can be tricky. Maybe
PyGinac will help you, or look into calling one of the existing heavyweights
from python (Maple, Mathematica, Maxima).

I'd love to see full symbolic capabilities available to python. But with
limited manpower, I'll be happy to replace IDL/matlab first. Maybe later
we'll be able to worry about messing with Mathematica :)

Cheers,

f.

Mon, 30 May 2005 07:27:23 GMT
Differential equations

Quote:

> Well, it's not compute-intensive, but the code needs to be written :)
> And as I
> said, while a symbolic differentiator is not a _fundamentally_
> difficult
> problem, making sure that all the details are done right can be

tricky.

As you say, it's pretty straightforward to write a program that does
symbolic differentiation.  What really gets into the hairy stuff is when
you want to simplify the resulting functions, which you inevitably want
to do after you look at the output of a straighforward implementation of
a symbolic differentiator.

--

__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Even paranoids have real enemies.
\__/ Delmore Schwartz
Bosskey.net: Aliens vs. Predator 2 / http://www.bosskey.net/avp2/
A personal guide to Aliens vs. Predator 2.

Mon, 30 May 2005 08:07:50 GMT
Differential equations

Quote:

> As you say, it's pretty straightforward to write a program that does
> symbolic differentiation.  What really gets into the hairy stuff is when
> you want to simplify the resulting functions, which you inevitably want
> to do after you look at the output of a straighforward implementation of
> a symbolic differentiator.

At which point you realize you're a loooong way from beating Mathematica &
friends :)  That's why I suggested to the OP that he look into ways of
calling the 'big boys' from within his python code.

cheers,

f

Mon, 30 May 2005 08:39:16 GMT
Differential equations

Quote:

> The hard part of stuff like this is parsing the string "2x^3+3x-10".
> If you can convince yourself you can live with Lisp's prefix notation,
> writing this sort of thing is dead easy in scheme or CL...

If you're willing to write your expression in a form
such as

Sum(Pow(Prod(2,"x"),3),Prod(3,"x"),-10)

you could delegate the parsing problem to Python
by defining suitable classes Sum, Prod, etc.

Taking this a step further, with suitably clever
__add__ etc. methods you could probably reduce this
to something like

x = Var("x")
y = 2*x^3+3*x-10

Then it's simply a matter of giving each class an

appropriate differentiate() method. :-)

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg

Mon, 30 May 2005 08:29:59 GMT
Differential equations

Quote:

> At which point you realize you're a loooong way from beating
> Mathematica &
> friends :)  That's why I suggested to the OP that he look into ways of
> calling the 'big boys' from within his python code.

Absolutely, couldn't agree more.  After a little bit of experimentation,
one will come to realize that the basics are straightforward, but
getting everything nice and pretty is a monumental task.  And, as you
say, there are applications that are dedicated to doing the job much
better than you could.

Still, writing a symbolic differentiator is a fun and useful project.
It's still a standard problem given to pretty much all Prolog students,
for instance.

--

__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Yes I'm / Learning from falling down / Heavily
\__/ Lamya
PyUID / http://www.alcyone.com/pyos/uid/
A module for generating "unique" IDs in Python.

Mon, 30 May 2005 09:23:23 GMT

 Page 1 of 1 [ 14 post ]

Relevant Pages