From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e7e6e919cef50811 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-14 03:15:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uwm.edu!newsfeed.cs.utexas.edu!geraldo.cc.utexas.edu!not-for-mail From: "Bobby D. Bryant" Newsgroups: comp.lang.ada Subject: Re: comparing gnat/Ada95 and g77 Date: Thu, 14 Mar 2002 05:07:30 -0600 Organization: dis- Message-ID: References: <3c9081f5$1@pull.gecm.com> <5s%j8.55660$yc2.6017500@news2-win.server.ntlworld.com> NNTP-Posting-Host: dial-104-34.ots.utexas.edu Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: geraldo.cc.utexas.edu 1016104143 1547 128.83.176.130 (14 Mar 2002 11:09:03 GMT) X-Complaints-To: abuse@utexas.edu NNTP-Posting-Date: Thu, 14 Mar 2002 11:09:03 +0000 (UTC) User-Agent: Pan/0.11.2 (Unix) X-Comment-To: "chris.danx" Xref: archiver1.google.com comp.lang.ada:21213 Date: 2002-03-14T05:07:30-06:00 List-Id: On Thu, 14 Mar 2002 05:04:51 -0600, chris.danx wrote: > "Martin Dowie" wrote in message > news:3c9081f5$1@pull.gecm.com... >> > x := x*0.5 + 1.0 + sin(x)*cos(x) + sin(x) + cos(x) + >> > sin(x)*sin(x) + cos(x)*cos(x); >> >> Try changing this line to: >> >> Sin_X := Sin(X); >> Cos_X := Cos(X); >> X := X*0.5 + 1.0 + Sin_X*Cos_X + Sin_X + Cos_X + >> Sin_X*Sin_X + Cos_X*Cos_X; > > what is the point of calculating sin(x)*sin(x) + cos(x)*cos(x)? It is > equal to (sin(x))^2 + (cos(x)^2) which is always 1.0 so you can do > > x := x * 0.5 + 1.0 + sin_x*cos_x + sin_x + cos_x + 1.0; > > and that'll be even faster. Since the program doesn't take any inputs, the programmer concerned with "fast" should just pre-calculate the answers and have the program spit them out whole. Or dispense with the program altogether, and just offer a text file with the answers in it. Bobby Bryant Austin, Texas