This looks like a bug. I haven't read through their source code thoroughly enough to say for sure, but I'd go ahead and report it and then use a workaround for now.
There are some ways to address the problem.
To start out, you could look at how SymPy is installed.
I use the development version of SymPy and have gmpy installed as a backend for all the arbitrary precision arithmetic.
On my system this problem shows up between 6.67E-32
and 6.67E-33
instead of 6.67E-8
and 6.67E-9
.
Getting the development release and switching the backend may help.
On the other hand, that is just a guess about your system and how SymPy is configured.
I could be entirely wrong.
Changing the set up only partially avoids the error. Here is a modified version of your code that avoids this problem entirely:
import sympy as sy
m1, m2, r, F, G = sy.symbols("m_1, m_2, r, F_g, G")
rhs = (G * m1 * m2/r**2)
eq = sy.Eq(F, rhs)
print eq
s=sy.solve(eq, m1)
print s[0].subs(G, sy.Float("6.67E-10000000000000000000", 1000))
The only difference is that this code has SymPy do all the work with symbols and then substitutes the floating point number in at the end.
This returns the correct answer on my machine in spite of the outrageous exponent.
The second parameter used to instantiate the Float
object is the precision.
This shows the answer to 1000 digits of precision (though this approach works with the default precision as well).