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. 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 > #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 ? ) All, what do you think? > #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. > thanks in advance for any comments / corrections, Thanks again for your effort and your interest to SymPy! Please feel free to ask more questions and discuss things on this list and in the issues. > dean Ah, now I see - you are Dean :) -- Всего хорошего, Кирилл. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---