[squeakdev] Quadrangle >> exampleInViewer baby graphics bug
Enrico Spinielli
enrico.spinielli at googlemail.com
Sun Apr 25 13:00:16 UTC 2010
There is a nice description of exponentiation in SICP:
http://mitpress.mit.edu/sicp/fulltext/book/bookZH11.html#%_sec_1.2.4
<http://mitpress.mit.edu/sicp/fulltext/book/bookZH11.html#%_sec_1.2.4>The
number of multiplications required is in the order of O(log n) where n is
the exponent.
Enjoy the (inspiring) reading...
Bye
Enrico
On Sun, Apr 25, 2010 at 10:54, Igor Stasenko <siguctua at gmail.com> wrote:
> On 24 April 2010 10:55, Lawson English <lenglish5 at cox.net> wrote:
> > Lawson English wrote:
> >>
> >> Thanks. I had gotten that far with John Dougan's help and tried to save
> >> back to the repository but it wouldn't accept since I lack a password.
> I
> >> converted all references of Floats to Fractions just to see if there was
> an
> >> easy way to give it higher precision but it slowed down to < Apple ][
> speeds
> >> when I did that.
> >>
> >>
> >> Obviously the naive way isn't going to work. I gotta think there's some
> >> glitch with what I did, or incompatibility with the algorithm and
> >> Fractions....
> >>
> >>
> > Or maybe things like x^100/y^100 takes a rather long time to
> calculate...
> >
>
> you can optimize, rather than multiplying x*x*...*x 100 times in a row,
>
> use a power of two numerics.
> Given that:
> x^y = (x^a)*(x^b)
> where y = a+b
>
> so,
>
> x^100 = (x^64)*(x^32)*(x^4)
>
> then, you can reuse an intermediate results of computation i.e:
>
> x2 := x*x.
> x4 := x2*x2.
> x8 := x4*x4.
> x16 := x8*x8.
> x32 := x16*x16.
> x64 := x32*x32.
>
> result := x64*x32*x4.
>
> so, totally 8 multiplications, instead of 100.
>
> >
> > sigh...
> >
> >
> > So an arbitrary precision Mandelbrot generator in Squeak isn't going to
> be a
> > cakewalk, apparently, or perhaps I'm missing something else obvious.
> >
> >
> > Lawson
> >
>
> 
> Best regards,
> Igor Stasenko AKA sig.
>
>

Enrico Spinielli
"Do Androids dream of electric sheep?"— Philip K. Dick
"Hear and forget; see and remember;do and understand."—Mitchel Resnick
 next part 
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeakdev/attachments/20100425/da17f09b/attachment.htm
More information about the Squeakdev
mailing list
