On Thu, Oct 28, 2010 at 9:41 PM, Bj Raz <whitequill...@gmail.com> wrote: > I am working with differential equations of the higher roots of negative > one. (dividing enormous numbers into other enormous numbers to come out with > very reasonable numbers). > I am mixing this in to a script for Maya (the final output is graph-able as > a spiral.) > I have heard that Sage, would be a good program to do this in, but I'd like > to try and get this to work in native python if I can. > The script I am trying to port to Python is; http://pastebin.com/sc1jW1n4.
Unless your code is really long, just include it in the message in the future. So, for the archive: indvar = 200; q = 0; lnanswer = 0; for m = 1:150 lnanswer = (3 * m) * log(indvar) - log(factorial(3 * m)) ; q(m+1) = q(m)+ ((-1)^m) * exp(lnanswer); end lnanswer q Also, it helps to point out *what language non-Python code is in*. I'm guessing MATLAB in this case. Naive translation attempt (Disclaimer: I don't know much MATLAB): from math import log, factorial, exp indvar = 200 q = [0] lnanswer = 0 for m in range(1, 151): lnanswer = (3 * m) * log(indvar) - log(factorial(3 * m)) q.append(q[-1] + (1 if m % 2 == 0 else -1) * exp(lnanswer)) print(lnanswer) print(q) Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list