Re: [sympy] solvers - solve(), solve_poly_system

83 views
Skip to first unread message

Mateusz Paprocki

unread,
Sep 10, 2012, 5:24:22 PM9/10/12
to sy...@googlegroups.com
Hi,

On 10 September 2012 21:04, billpap <bill...@yahoo.gr> wrote:
I have posted my problem already in StackOverflow,


A second problem that I have, is, that although when I use solve_poly_system in gnome terminal
everything it's ok, when I use solve_poly_system in Hadoop streaming, I have the same issue that
I have with solve() when I use it in gnome terminal.

Can you try the most recent version (master branch) from github.com/sympy/sympy? I tried your example and it doesn't work in 0.7.x but works in master. Here is a sample session:

IPython console for SymPy 0.7.1-git (Python 2.7.2-64-bit) (ground types: gmpy)

In [1]: var('r,d,l,k,u,a')
Out[1]: (r, d, l, k, u, a)

In [2]: system = [Eq(r*d, l*k), Eq(u*a, l*k), Eq(k, a*d)]

In [3]: system
Out[3]: [d⋅r = k⋅l, a⋅u = k⋅l, k = a⋅d]

In [4]: solve(system, a, d, l)
Out[4]: 
⎡⎛       _____         _____            ⎞  ⎛      _____        _____           ⎞⎤
⎢⎜      ╱ r⋅u         ╱ r⋅u             ⎟  ⎜     ╱ r⋅u        ╱ r⋅u            ⎟⎥
⎢⎜-k⋅  ╱  ───   -k⋅  ╱  ───        _____⎟  ⎜k⋅  ╱  ───   k⋅  ╱  ───       _____⎟⎥
⎢⎜   ╲╱    k       ╲╱    k        ╱ r⋅u ⎟  ⎜  ╲╱    k      ╲╱    k       ╱ r⋅u ⎟⎥
⎢⎜────────────, ────────────, -  ╱  ─── ⎟, ⎜───────────, ───────────,   ╱  ─── ⎟⎥
⎣⎝     u             r         ╲╱    k  ⎠  ⎝     u            r       ╲╱    k  ⎠⎦

In [5]: solve(system, [a, d, l])
Out[5]: 
⎡⎛       _____         _____            ⎞  ⎛      _____        _____           ⎞⎤
⎢⎜      ╱ r⋅u         ╱ r⋅u             ⎟  ⎜     ╱ r⋅u        ╱ r⋅u            ⎟⎥
⎢⎜-k⋅  ╱  ───   -k⋅  ╱  ───        _____⎟  ⎜k⋅  ╱  ───   k⋅  ╱  ───       _____⎟⎥
⎢⎜   ╲╱    k       ╲╱    k        ╱ r⋅u ⎟  ⎜  ╲╱    k      ╲╱    k       ╱ r⋅u ⎟⎥
⎢⎜────────────, ────────────, -  ╱  ─── ⎟, ⎜───────────, ───────────,   ╱  ─── ⎟⎥
⎣⎝     u             r         ╲╱    k  ⎠  ⎝     u            r       ╲╱    k  ⎠⎦

In [6]: [ eq.subs(zip((a, d, l), _5[0])).simplify() for eq in system ]
Out[6]: 
⎡       _____          _____         _____          _____       ⎤
⎢      ╱ r⋅u          ╱ r⋅u         ╱ r⋅u          ╱ r⋅u        ⎥
⎢-k⋅  ╱  ───  = -k⋅  ╱  ─── , -k⋅  ╱  ───  = -k⋅  ╱  ─── , k = k⎥
⎣   ╲╱    k        ╲╱    k       ╲╱    k        ╲╱    k         ⎦

In [7]: [ bool(eq.subs(zip((a, d, l), _5[0])).simplify()) for eq in system ]
Out[7]: [True, True, True]

In [8]: [ bool(eq.subs(zip((a, d, l), _5[1])).simplify()) for eq in system ]
Out[8]: [True, True, True]

When reporting a problem please include project version number and exact code. Otherwise it's only guessing what's wrong.


Do you have any ideas? 

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/Qq8W3Qu1ot4J.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.

Mateusz
Message has been deleted

billpap

unread,
Sep 11, 2012, 5:33:49 AM9/11/12
to sy...@googlegroups.com
Finally, I solved my problem.

The problem was that my program was dependent from the order that some input files were read.
This caused a lot of side effects.

Of course you suggestion about the sympy( github.com/sympy/sympy) helped me a lot to find my issue.

Thanks a lot! Have a nice day.
Reply all
Reply to author
Forward
0 new messages