Comment #1 on issue 4112 by [email protected]: solve doesn't work with rational=True
http://code.google.com/p/sympy/issues/detail?id=4112

The reason is that the small term simplifies to 0 at the given tolerance. Two options: 1) do a variable substitution like se -> 1e8*x, 2) nsimplify with your desired tolerance before solving.

solve(eq.subs(se,1e8*x))
[0.118679598581086]

Although I don't think that not getting a solution is the best option, I'm not sure there can be a solution that will please everyone. That's the nature of working with floats. If you try to convert all numbers to rationals you get "odd" results because of the underlying what-you-see-is-not-what-is-there issues:

[Rational(n) for n in eq.atoms(Number)]
[3022314549036573151115727451828646838272,-1,11709359031163294503599627370496,57646075230342359007199254740992]


Solving the equation with those raw substitutions gives

solve(eq.subs([(n,Rational(n)) for n in eq.atoms(Number)]))
[117422457186352050056524946076655π(-226491943422576653733158080737265582080π+1361129467683753853853498429727072845824)]

(I'm not sure that's all right but can't check right now.)

You'll get close to what you want if you would pass your constants to Rational wrapped in quotes:

# define the symbols we wish to use
... se = symbols('se')
...
... # assign some constants
... D = Rational('0.24')
... sn = Rational('38e6')
... Q = Rational('0.64')
...
... Dprime = 1 - D
...
... mc = 1 + (se/sn)
...
... # this is the expression that we wish to make equal to Q
... expr = (1/(pi * (mc * Dprime - S.Half)))
...
... # this should print the value for se
... print(solve(Eq(expr, Q),se))
...
[-13000000 + 78125000/pi]

eq.subs(se,solve(Eq(expr, Q),se)[0])
True

I would mark this as WontFix: if one uses floats they must understand the limitations and adapt accordingly.

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to