[sympy] Re: simplification question

2009-06-01 Thread David Roberts
> So no, no one could come up with a Python variable that broke that > convention, unless there are foreign language Pythons I don't know about > that allow characters that wouldn't match in A-Za-z. It looks like only Python 3.0 and above support non-ascii identifiers

[sympy] Re: another simplication question

2009-06-01 Thread Ondrej Certik
On Mon, Jun 1, 2009 at 9:33 PM, Ryan Krauss wrote: > So, I think I have a good test and a better understanding of the problem: > > mylist = ['m', 's', 'b', 'x', 'y', 's', 'x', 'y', 's', 'EI'] > sympy.var(mylist) > test = m*s**2+b*x*y*s+x**2+y**2+s+EI > args = list(test.args) > args.sort(sympy.Bas

[sympy] Re: Installing under Windows -- Best Practices

2009-06-01 Thread Ondrej Certik
Hi Joel, On Mon, Jun 1, 2009 at 9:41 PM, Aaron S. Meurer wrote: > On Jun 1, 2009, at 9:33 PM, Joel C. Salomon wrote: > > Neighbors, > > I’ve been looking to play with SymPy to do some of my thesis work. I’ve > got a Windows system, and could not get any “pretty printing” to work > for me last ti

[sympy] Re: Installing under Windows -- Best Practices

2009-06-01 Thread Aaron S. Meurer
On Jun 1, 2009, at 9:33 PM, Joel C. Salomon wrote: > > Neighbors, > > I’ve been looking to play with SymPy to do some of my thesis work. > I’ve > got a Windows system, and could not get any “pretty printing” to work > for me last time I tried it. I’m starting afresh, from fresh > installations o

[sympy] Installing under Windows -- Best Practices

2009-06-01 Thread Joel C. Salomon
Neighbors, I’ve been looking to play with SymPy to do some of my thesis work. I’ve got a Windows system, and could not get any “pretty printing” to work for me last time I tried it. I’m starting afresh, from fresh installations of everything, and I’d like the list’s opinions on a few things: • W

[sympy] Re: another simplication question

2009-06-01 Thread Ryan Krauss
So, I think I have a good test and a better understanding of the problem: mylist = ['m', 's', 'b', 'x', 'y', 's', 'x', 'y', 's', 'EI'] sympy.var(mylist) test = m*s**2+b*x*y*s+x**2+y**2+s+EI args = list(test.args) args.sort(sympy.Basic._compare_pretty) args.reverse() This doesn't get my list in t

[sympy] Re: simplification question

2009-06-01 Thread Aaron S. Meurer
From the Python 2.6.2 reference manual: 2.3 Identifiers and keywords Identifiers (also referred to as names) are described by the following lexical definitions: identifier ::= (letter|”_”) (letter | digit | “_”)* letter ::= lowercase | uppercase lowercase ::= “a”...”z” uppercase ::= “A”...”Z” digit

[sympy] Re: simplification question

2009-06-01 Thread Robert Kern
On Mon, Jun 1, 2009 at 22:18, Ryan Krauss wrote: > Chris, > > Can you demystify this regexp for me: > re.findall('([A-Za-z_][A-Za-z_0-9]*)',eq) > It seems like that says that a variable is anything that starts with a > letter or underscore and then continues until it gets to something that is > n

[sympy] Re: simplification question

2009-06-01 Thread Ryan Krauss
Chris, Can you demystify this regexp for me: re.findall('([A-Za-z_][A-Za-z_0-9]*)',eq) It seems like that says that a variable is anything that starts with a letter or underscore and then continues until it gets to something that is not alpha-numeric or an underscore. Is that right? It seems lik

[sympy] Re: Motion equation generation script sharing

2009-06-01 Thread Luke
Alan, Thanks for the information. I'll check out both the Lasenby book and the Hestenes book at the UC Davis library. If I have time this summer, maybe I can implement some approaches for formulating the equations of motion that utilize the machinery of what you have implemented for Geometric

[sympy] Re: Motion equation generation script sharing

2009-06-01 Thread Alan Bromborsky
Luke wrote: > Alan, > I've browsed this text a little, but to be honest, I was unable to > see the direct advantage of such an approach, at least for the type of > work I'm involved with. I'm willing to trust that the mathematics are > cleaner and more complete, but I'm curious what the advanta

[sympy] Re: combining similar powers

2009-06-01 Thread Aaron S. Meurer
If sympy automatically pulls apart square roots, then you won't find a function that pulls them together. On the other hand, you should note that sqrt(x) is equivalent to x**Rational(1,2), not x**(1/2), which is just x**(0.5). Using 1/2 does work at least in your brute force method, if you a

[sympy] Re: Motion equation generation script sharing

2009-06-01 Thread Luke
Alan, I've browsed this text a little, but to be honest, I was unable to see the direct advantage of such an approach, at least for the type of work I'm involved with. I'm willing to trust that the mathematics are cleaner and more complete, but I'm curious what the advantage is in the end. Do

[sympy] combining similar powers

2009-06-01 Thread William Purcell
I am trying to combine an expression containing similar exponents that are multiplied to each other ... In [20]: wn Out[20]: (1/m)**(1/2)*(k1 + k2 + k3)**(1/2) In [21]: together(wn) Out[21]: (1/m)**(1/2)*(k1 + k2 + k3)**(1/2) but I would like something like In [21]: together(wn) Out[21]: ((k

[sympy] Re: Any Updates? - Pretty Printing with Windows

2009-06-01 Thread Joel C. Salomon
Ondrej Certik wrote: > On Sun, May 31, 2009 at 9:55 PM, cjkogan111 wrote: >> Ideally I would like to output to the terminal. Showing a picture is >> also ok as long as I can quickly update it from the terminal. >> > > Thanks for the clarification. If it doesn't work, we need to fix it. > Pri

[sympy] Re: another simplication question

2009-06-01 Thread Ondrej Certik
On Mon, Jun 1, 2009 at 3:39 PM, Ryan Krauss wrote: > So, when would just adding an args.reverse() breakdown: > > den3 = s**4*m1*m2+k*s**2*m2+Gc*k > args = list(den3.args) > args.sort(sympy.Basic._compare_pretty) > args.reverse() > > seems to produce the ordering that I want.  Adding the reverse l

[sympy] Re: another simplication question

2009-06-01 Thread Ryan Krauss
So, when would just adding an args.reverse() breakdown: den3 = s**4*m1*m2+k*s**2*m2+Gc*k args = list(den3.args) args.sort(sympy.Basic._compare_pretty) args.reverse() seems to produce the ordering that I want. Adding the reverse line to str.py and latex.py _print_Add methods seems to work. But o

[sympy] Re: Motion equation generation script sharing

2009-06-01 Thread Alan Bromborsky
Luke wrote: > If you are familiar with Autolev, then you are probably familiar with > some of the behavior that makes it very convenient and easy to derive > equations of motion in. You might also be familiar with some of its > limitations. One of the main goals of PyDy is to replicate (in a mor

[sympy] Re: another simplication question

2009-06-01 Thread Ryan Krauss
That sounds good, but what do you mean by "write a sympy code that orders the list of arguments of the Add instance above, which it is easy -- you just order it with respect to 's'" I understand that that is what I want to do, but how do I get started coding it up? On Mon, Jun 1, 2009 at 3:29 PM,

[sympy] Re: another simplication question

2009-06-01 Thread Ondrej Certik
On Mon, Jun 1, 2009 at 2:24 PM, Ryan Krauss wrote: > I have a sympy result: > > In [57]: x1_res_up > Out[57]: Gc*k*xd/(Gc*k + k*m1*s**2 + k*m2*s**2 + m1*m2*s**4) > > In [58]: type(x1_res_up) > Out[58]: > > but I would like the denominator to print in decending powers of s: > > Gc*k*xd/(m1*m2*s**

[sympy] another simplication question

2009-06-01 Thread Ryan Krauss
I have a sympy result: In [57]: x1_res_up Out[57]: Gc*k*xd/(Gc*k + k*m1*s**2 + k*m2*s**2 + m1*m2*s**4) In [58]: type(x1_res_up) Out[58]: but I would like the denominator to print in decending powers of s: Gc*k*xd/(m1*m2*s**4 + k*m2*s**2 + Gc*k + k*m1*s**2) If the numerator had powers of s, I

[sympy] Re: tweaking the output of sympy.latex

2009-06-01 Thread Ryan Krauss
I will work on that shortly. On Mon, Jun 1, 2009 at 2:51 PM, Ondrej Certik wrote: > > Hi Ryan! > > > On Mon, Jun 1, 2009 at 12:46 PM, Ryan Krauss wrote: > > So, I have something that I think is working. No idea if people who > > understand more of sympy's design than I do will think this is a

[sympy] Re: tweaking the output of sympy.latex

2009-06-01 Thread Ondrej Certik
Hi Ryan! On Mon, Jun 1, 2009 at 12:46 PM, Ryan Krauss wrote: > So, I have something that I think is working.  No idea if people who > understand more of sympy's design than I do will think this is a good idea > or not. looks good. Could you please send it as a patch to sympy? We'll include it.

[sympy] Re: tweaking the output of sympy.latex

2009-06-01 Thread Ryan Krauss
So, I have something that I think is working. No idea if people who understand more of sympy's design than I do will think this is a good idea or not. class LatexPrinter(Printer): printmethod = "_latex_" def __init__(self, inline=True, matstr='bmatrix', matdelim=None): Printer.__

[sympy] Re: tweaking the output of sympy.latex

2009-06-01 Thread Ryan Krauss
Either of those could work. A keyword argument makes sense. As I look at the code, it seems like trying to handle too many options is going to get messy fast. Any thoughts on how to proceed? A full-fledged rc file might be overkill and confusing to the novice user. Ryan On Mon, Jun 1, 2009 at

[sympy] Re: tweaking the output of sympy.latex

2009-06-01 Thread Tim Lahey
On Mon, Jun 1, 2009 at 2:18 PM, Ryan Krauss wrote: > > What is the best solution to my problem?  I can hack my own code to replace > the > \left(\begin{smallmatrix} --> \begin{bmatrix} > and > \end{smallmatrix}\right  --> \end{bmatrix} > > and if I am the only one who wants this feature, no probl

[sympy] Re: tweaking the output of sympy.latex

2009-06-01 Thread Ryan Krauss
So, unless I am looking in the wrong place, it appears to be hard-coded: def _print_Matrix(self, expr): lines = [] for line in range(expr.lines): # horrible, should be 'rows' lines.append(" & ".join([ self._print(i) for i in expr[line,:] ])) if self._inlin

[sympy] tweaking the output of sympy.latex

2009-06-01 Thread Ryan Krauss
I am trying to use sympy in some code that I have that allows me to put Python code blocks in a Latex document and replace the block with pretty output. For my code to work ideally, I need to tweak the output of sympy.latex for a matrix. I have In [19]: type(Uk) Out[19]: In [20]: Uk Out[20]: [

[sympy] Re: Motion equation generation script sharing

2009-06-01 Thread Luke
If you are familiar with Autolev, then you are probably familiar with some of the behavior that makes it very convenient and easy to derive equations of motion in. You might also be familiar with some of its limitations. One of the main goals of PyDy is to replicate (in a more Pythonic way) the