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

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



> 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