All, thanks much for the quick response & valuable comments. i can't be as fast (or valuable), but i will digest the responses and put it on the wiki - hopefully in the next month (sorry). then i'll look into the internals, maybe starting w/ latex printing.
just some basic follow-up: (1) regarding the subscripting: (1a) Ondrej's output on my browser is: In [5]: Symbol("F_x") Out[5]: Fₓ i.e., shows up as F^*, not F_x. maybe that is just a unicode(?) problem on my browser. (1b)in order to obtain subscripts in symbol/function names, should/ must the user include the underscore, or is either acceptable to you? (e.g., x1=Symbol('x1') versus x1=Symbol('x_1'); in the former case, the subscripting is magic(?!), and no superscripting is possible(?)) (2)do you want the wiki cookbook entries to be doctest-able or otherwise in a form suitable for testing? regards, dean On Apr 17, 8:23 am, "Ondrej Certik" <[EMAIL PROTECTED]> wrote: > Hi Dean! > > first thanks a lot for doing this. Feel free to put it on our wiki. > Some comments below: > > On Thu, Apr 17, 2008 at 5:03 PM, Kirill Smelkov > > > > > > <[EMAIL PROTECTED]> wrote: > > > Hi fred2 (what is your name, btw)! > > > On Wed, Apr 16, 2008 at 10:36:46PM -0700, fred2 wrote: > > > Hello sympy experts, > > > I'm not an expert, but I'll try to answer some questions. > > > > Thanks for making sympy available. it looks like a great package. i > > figured i would put together a cookbook page for wiki/Cookbook on how to > > define and manipulate differential equations as i learned sympy. however, > > after a bit of testing, i am not sure whether all features for this type of > > application are supported. > > > Indeed, for some problems we don't have all features ready, but SymPy is > > developed with the idea that it should be easily extendable. > > > > the attached file is just an (incomplete) commented script that shows > > some of the questions a user may have, with some possible answers (but > > definitely lacking references into the documentation, as it is). it needs > > some expert inputs in order to be useful. > > > also, if you think another package currently would be more suitable than > > sympy, let me know and i'll try to make this more of a rosetta stone for a > > new user to help explain what features are/aren't available or supported > > for this application. > > > Thanks for doing this! > > > I don't usually work with pde, but at least one of your question is > > answered now: > > > > #Q2b: ok, but the (pprint,latex) display of the differential operator > > does not have a subscript (e.g., pprint displays as dx1, not dx_1)? > > > #A2b: [expected feature? or possible bug?] > > > Yes, this was a bug, it is fixed now in hg version of SymPy > > > In [1]: t=Symbol('t'); x1=Symbol('x1'); x2=Symbol('x2') > > > In [2]: rho=Function('rho')(t,x1,x2) #dep vars > > > In [3]: rho.diff(x1) > > Out[3]: > > d > > ───(ρ(t, x₁, x₂)) > > dx₁ > > > ---- > > > As to your other questions, below are my thoughs. I'm sure other SymPy > > developers would want to add their comments too. > > > > #e.g., the continuity equation for a compressible gas (unsteady + 2 > > spatial dimensions) > > > t,x,y=symbols('txy') #indep vars > > > rho=Function('rho')(t,x,y) #dep vars > > > u=Function('u')(t,x,y) > > > v=Function('v')(t,x,y) > > > cont = rho.diff(t) + (rho*u).diff(x) + (rho*v).diff(y) > > > > #Q1b: ok, but (pprint,print,latex) cont explicitly displays the > > independent vars - how do i hide them? > > > #A1b: [unknown] > > > I think we don't have support for this yet. > > > Maybe we just need to extend the concept of variable and introduce > > variables dependencies. > > Yes, I think we need something like this. But I have no ideas here so > far. Maybe something like: > > x = x(y) > > would create a function "x" of "y", but you could also work with "x" > as a symbol. > > > > > > > > > Suggestions welcome! > > > > #Q1c: ok, but (pprint,print,latex) cont simplifies the differential > > terms [e.g., d(rho u) becomes rho*du + u*drho]; how do i retain d(rho u) > > (i.e., "conservative form")? > > > #A1c: [unknown. Expand 'basic' is the default. does expand() apply to > > diff or algebraic terms? does expand(basic=False) apply only to alg. > > terms?. can expand() be turned off at the point of Function definition? can > > expand() be turned off globally?] > > > This is not related to pprint or latex. > > > The point here is that diff expands product via (uv)' = u'v + uv' rule > > > In [1]: g = Function('g') > > > In [2]: diff(f(x)*g(x), x) > > Out[2]: > > d d > > f(x)*──(g(x)) + g(x)*──(f(x)) > > dx dx > > > I think diff should not automatically expand products, so could you > > please create an issues for this? > > > http://code.google.com/p/sympy/issues/entry > > We have this implemented already imho, just use the Derivative class: > > In [1]: g = Function("g") > > In [2]: diff(f(x)*g(x), x) > Out[2]: > d d > f(x)*──(g(x)) + g(x)*──(f(x)) > dx dx > > In [3]: Derivative(f(x)*g(x), x) > Out[3]: > d > ──(f(x)*g(x)) > dx > > > > > > > > #Q1d: when diff operates on a multi-variate function, should d/dx > > display in pprint like (the ascii form of) \partial / \partial x? > > > #A1d: [unknown. maybe not possible under ~pprint?] > > > I agree we should use partial derivative symbols, just because > > semantically > > > diff(f(x,y), x) > > > means > > > ∂ > > ──(f(x, y)) > > ∂x > > > i.e. partial derivative > > > (also, maybe we should simplify it more, e.g. > > > ∂ f(x, y) > > x > > > ? > > ) > > Both. In Quantum Field Theory or General Relativity, we definitely > need the second syntax. At least I prefer it. But the ascii art for > this is not so sufficient. Why not to use unicode subscripts for "x" > like this: > > In [5]: Symbol("F_x") > Out[5]: Fₓ > > > All, what do you think? > > I think we should implement that. Dean, if you want to help here, feel > free to ask us for guidance, we'll help you. > > > > > > > > #Q2: can i use subscripted variables instead of x,y,z, etc.? > > > #A2: yes. subscripting is defined implicitly(?) via Symbol(); you cannot > > use symbols()[?]. > > > Yes, implicitely indexed symbols gets subscripts and superscripts when > > pprinted > > > In [1]: Symbol('Y^+_00') > > Out[1]: Y⁺₀₀ > > > But this is only some kind of eye-candy, nothing more. > > > What we really need is to support array, or better tensors. > > > http://code.google.com/p/sympy/issues/detail?id=16 > > > Comments, Suggestions, Patches -- all welcome! > > > > #Q3: subscripting is just a way to indicate vectors/tensors. i have the > > equation written in vector form. can i define vector variables (e.g., the > > tuple (x1,x2), and have sympy do all the work (e.g., apply a gradient > > differential operator)? these features would be similar to macsyma's tensor > > package, e.g., contvec = rho_{,t} + (rho u_i)_{,i}. > > > #A3: [unknown; see also: matrix; a matrix can contain symbols] > > > See above about tensors. > > > >Q4: what do i need in a latex/tex file to make use of the output of > > latex()? e.g., latex(cont) has (Undefined) control sequences like > > \operatorname{rho}. > > >A4: [unknown] > > > Unfortunately we have to wait what others will say -- at present I'm not > > using latex printing. > > I think our latex printing needs some polishing -- I think Mateusz uses it? > > BTW the latex printing is easy to fix, just look into sympy/printing/latex.py. > > Ondrej- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---