On Mon, Mar 23, 2009 at 12:26 PM, [email protected]
<[email protected]> wrote:
>
> Most of the time I am dealing with PDEs and as such think it would be
> cool if sympy can do the right thing when pprinting an expression
> involving partial derivatives. Currently it's my understanding that
> only the 'd' gets rendered rather than \partial.  So my question is
> whether sympy can be educated to  make the right choice?  As an

Indeed, it'd be really awesome. I just implemented a curvilinear
coordinates demo (see my other email to this list) and the Laplace
operator would look much better if pprint could handle the partial
sign.

> example, here is a simple example of what I get with the current
> convention:
>
> from sympy import *
> from sympy import Symbol
>
> t,x,y,z,v = symbols('txyzv')
>
> phi = Function("rphi")
>
> advectionEQ = phi(t,x,y,z).diff(t) + v * phi(t,x,y,z).diff(x)
>
> pprint(advectionEQ) with the result:
>
>
>    d                            d
> v⋅──(φ(t, x, y, z)) + ──(φ(t, x, y, z))
>    dx                           dt
>
> As a probably too primitive suggestion, how about having the pprint
> look at the number of independent variables in the above expression
> and if the count is greater than 1 use \partial in place of 'd' ?

Yes, that occured to me too, that it should be easy to fix it this way.

>
> Or have the pprint do its usual thing except at the end of its work
> the resulting expression is parsed for d and turned into \partial?

I suggest the pprint handles this as you described above.

>
> Another thing that  is sort of not beautiful in the above output is
> that the d/dx term is always first even though the object advectionEQ
> has the d/dt in the first term in the expression.  How can I get the
> desired order in the output of the pprinted expression?

You can create your own printer, that sorts the terms in any way you
want. See here for an example of such a custom printer:

http://github.com/hazelnusse/pydy/blob/0ccb8699817068831b7218abd86edff573469a04/pydy.py#L605

>
> Thanks for suggestions/corrections.

Thanks for fresh ideas on this!

> Another thought:
>
> Make a new diff function and call it pdiff.  The only difference
> between diff and pdiff would be that pdiff always returns \partial for
> 'd'.

I don't like this, I think the best approach is to just teach the
pretty printer to look at the function and determine if it has just
one ore more arguments and act accordingly.

>
> Not certain that this suggestion is much different than the
> above...developers will know, I'm sure.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to