[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Classic game LUNAR and G=1E-03



Nama wrote:
On May 6, 12:45 am, -scooter- <scooter....@gmail.com> wrote:
Ok...that makes sense.
So one last question before I can say this port is finished:
According to the document here (http://www.atariarchives.org/
basicgames/showpage.php?page=106):
(Q-Q*Q/2-Q^3/3-Q^4/4-Q^5/5)
can be replaced by the notation
-Q*(1+Q*(1/2+Q*(1/3+Q*(1/4+Q/5))))
If that is the case, then what would be the replacement for:
(Q/2+Q^2/6+Q^3/12+Q^4/20+Q^5/30)
Look up "Horner's Method" -- the quick and dirty explanation is that
Horner's is a linear time evaluation method for polynomials. It allows
you to avoid computing the exponents. However, there is a bug in that
expression -- it shouldn't start with -Q.

Q*(1-Q*(1/2-Q*(1/3-Q*(1/4-Q/5))))
= Q-Q^2*(1/2-Q*(1/3-Q*(1/4-Q/5)))
= Q-Q^2/2-Q^3*(1/3-Q*(1/4-Q/5))
= Q-Q^2/2-Q^3/3-Q^4*(1/4-Q/5)
= Q-Q^2/2-Q^3/3-Q^4/4-Q^5/5

BTW: Horner's method still shows up frequently on the Computer Science
Graduate Record Exam here in the US. And it's a favorite interview
torture question of mine, along with the XOR hack.

-scooter

So I should replace:

-Q*(1+Q*(1/2+Q*(1/3+Q*(1/4+Q/5))))

with

Q*(1-Q*(1/2-Q*(1/3-Q*(1/4-Q/5))))

I think the leading minus sign is correct for this use of the
function.  Certainly the program will function differently if it is
removed, and I presume that it once worked.  ;-)

And both series computations can be replaced with simple LOG functions.
See other replies in this thread by myself and John.

-michael

NadaNet 3.0 for Apple II parallel computing!
Home page:  http://home.comcast.net/~mjmahon/

"The wastebasket is our most important design
tool--and it's seriously underused."