factorial of negative one (-1)
Bj Raz
whitequill.bj at gmail.com
Mon Nov 1 09:19:26 CET 2010
On Fri, Oct 29, 2010 at 1:02 AM, Chris Rebert <clp2 at rebertia.com> wrote:
> On Thu, Oct 28, 2010 at 9:41 PM, Bj Raz <whitequill.bj at 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
>
I'm sorry I didn't read the thread very carefully. thank you for your help
Chris. :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101101/8dd95074/attachment.html>
More information about the Python-list
mailing list