On Tue, May 8, 2012 at 2:27 PM, phneoix <neo.stea...@gmail.com> wrote:
> values={T: 300, a: 3, f: 6, W: 200}
>
> print sy.solve([
>     sy.Eq(f, m*a).subs(values),
>     sy.Eq(T, f*d).subs(values),
>     sy.Eq(W, m*g).subs(values)
>     ])
>
>>>>    For nonlinear systems of equations, symbols should be
>     given as a list so as to avoid ambiguity in the results.
>     solve sorted the symbols as [d, g, m]
> [(50, 100, 2)]
>
>
> for ssolve function i am getting...

Make sure you are in the current master and that your ssolve looks like this:


def ssolve(s, *v):
    """
    Solve lines of equations as a set of equations:
    >>> from sympy.my import ssolve
    >>> ssolve('''
    ... y=x+3
    ... x+y=4''')
    {x: 1/2, y: 7/2}

    Any line containing an '?' will be ignored.

    >>> ssolve('''
    ... y=x+3
    ... y=4
    ... x=?''')
    {x: 1, y: 4}
    """
    from sympy import Eq, solve, Tuple
    eq=[]
    for li in [si for si in s.strip().splitlines() if si]:
        li.replace('==','=')
        if '?' in li: continue
        if '=' in li: eq.append(Eq(*[S(p) for p in li.split('=')]))
        else: eq.append(S(li))
    syms = (v or list(Tuple(*eq).free_symbols))
    soln = solve(eq, *syms)
    if type(soln) is dict:
        return soln
    if len(soln) == 1:
        return dict(zip(syms, soln[0]))
    else:
        return [dict(zip(syms, s)) for s in soln]

ans = ssolve('''
f=a*m
W=g*m
T=d*f
m=?
f=6.0
a=3.0
W=200
g=?
T=300
d=?
''')

>>> print filldedent(ans)

{f: 6.00000000000000, m: 2.00000000000000, W: 200.000000000000, d:
50.0000000000000, a: 3.00000000000000, g: 100.000000000000, T:
300.000000000000}

/c

-- 
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 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to