Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #10805
| Newsgroups | comp.lang.forth |
|---|---|
| From | Albert van der Horst <albert@spenarnc.xs4all.nl> |
| Subject | Re: Sum of squares |
| Date | 2012-04-03 09:47 +0000 |
| Message-ID | <m1wdut.5q3@spenarnc.xs4all.nl> (permalink) |
| Organization | Dutch Forth Workshop |
| References | <10851509008435@frunobulax.edu> <m1jito.mmz@spenarnc.xs4all.nl> <87y5qjpb09.fsf@stud.uni-frankfurt.de> <5785867.675.1333044979048.JavaMail.geo-discussion-forums@ynjc20> |
In article <5785867.675.1333044979048.JavaMail.geo-discussion-forums@ynjc20>, Helmar Wodtke <helmwo@gmail.com> wrote: >Am Donnerstag, 29. M=C3=A4rz 2012 19:33:58 UTC+2 schrieb Alexander Adler: >> albert@spenarnc.xs4all.nl schrieb: <SNIP> <Other problem skipped> >> > >> > A much more interesting problem is: >> > It is well-known that a prime is the sum of 2 squares in exactly >> > one way 1]. Find them. <SNIP> < One of two algorithms skipped> >> > Groetjes Albert >> > >> > -- >>=20 >> Cheers, Alexander. > >The joke about this is: > >1010150873 =3D 16187^2 + 27352^2 > >real 0m0.035s >user 0m0.036s >sys 0m0.000s > >(yours) > >1010150873 --- s1 =3D 16187 s2 =3D 27352 result: 1010150873=20 > >real 0m0.024s >user 0m0.020s >sys 0m0.004s > >(mine) > >(this was done by forth4p) > >Now for Gforth, as it is shiped by Ubuntu LTS: > >1010150873 =3D 16187^2 + 27352^2 > >real 0m0.015s >user 0m0.016s >sys 0m0.000s > >(yours) > >1010150873 --- s1 =3D 16187 s2 =3D 27352 result: 1010150873=20 > >real 0m0.018s >user 0m0.012s >sys 0m0.008s > >(mine) > >The differences (at least at input that fits what my implementation can do)= > is not really big. You use sophisticated math, I use a basically simple id= >ea. >I'm not sure you can speed up processing if you would have 2000 processor c= >ores more - I can do (by factor, 2000 because this problem is like this). Let's have a look what happens if the numbers get a tad bigger. " calculate .results 1000000000000000177 --- s1 = 633708561 s2 = 773571884 result: 1000000000000000177 ok real 1m50.927s user 1m50.860s sys 0m0.020s " That's right: your solutions takes 2 minutes on the same machine and Forth that took 500 uS before. It demonstrates dramatically what difference an algorithm makes. Even your 2000 machines together would take .1 second. > >But nice - I did not think that much how to get it better. > >Regards, >-Helmar -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
Sum of squares mhx@iae.nl (Marcel Hendrix) - 2012-03-26 20:50 +0200
Re: Sum of squares "A. K." <akk@nospam.org> - 2012-03-26 21:43 +0200
Re: Sum of squares Paul Rubin <no.email@nospam.invalid> - 2012-03-26 16:52 -0700
Re: Sum of squares Helmar Wodtke <helmwo@gmail.com> - 2012-03-27 03:15 -0700
Re: Sum of squares Paul Rubin <no.email@nospam.invalid> - 2012-03-28 08:16 -0700
Re: Sum of squares BruceMcF <agila61@netscape.net> - 2012-03-28 06:06 -0700
Re: Sum of squares Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2012-03-27 12:13 +0100
Re: Sum of squares Helmar Wodtke <helmwo@gmail.com> - 2012-03-27 04:03 -0700
Re: Sum of squares Zbiggy <zbigniew2011REMOVE@gmail.REMOVE.com> - 2012-03-27 13:55 +0100
Re: Sum of squares Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-27 11:05 +0000
Re: Sum of squares Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-28 11:41 +0000
Re: Sum of squares Paul Rubin <no.email@nospam.invalid> - 2012-03-28 07:41 -0700
Re: Sum of squares mhx@iae.nl (Marcel Hendrix) - 2012-03-29 22:06 +0200
Re: Sum of squares Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-31 11:48 +0000
Re: Sum of squares Alexander Adler <alexander.adler@stud.uni-frankfurt.de> - 2012-03-29 19:33 +0200
Re: Sum of squares Helmar Wodtke <helmwo@gmail.com> - 2012-03-29 11:16 -0700
Re: Sum of squares Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-04-03 09:47 +0000
Re: Sum of squares Helmar Wodtke <helmwo@gmail.com> - 2012-03-28 09:42 -0700
Re: Sum of squares Helmar Wodtke <helmwo@gmail.com> - 2012-03-28 11:08 -0700
Re: Sum of squares Ecki <ecki@intershop.de> - 2012-03-27 16:15 +0200
Re: Sum of squares Helmar Wodtke <helmwo@gmail.com> - 2012-03-27 07:35 -0700
Re: Sum of squares hwfwguy@gmail.com - 2012-03-27 08:00 -0700
Re: Sum of squares Helmar Wodtke <helmwo@gmail.com> - 2012-03-27 08:21 -0700
Re: Sum of squares Ecki <ecki@intershop.de> - 2012-03-29 09:05 +0200
csiph-web