Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amelia!lemming.nas.nasa.gov!fouts From: fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) Newsgroups: comp.lang.fortran Subject: Confused about optimizing 1-COS(X)*COS(X) Message-ID: <1041@amelia.nas.nasa.gov> Date: 23 Sep 88 00:30:08 GMT References: <1033@amelia.nas.nasa.gov> <4032@lanl.gov> Sender: news@amelia.nas.nasa.gov Reply-To: fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) Organization: NASA Ames Research Center Lines: 25 In article <4032@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >From article <1033@amelia.nas.nasa.gov>, by fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts): >> This is true, but only accurate when the expression evaluates to a >> constant. You couldn't (because of finite precision) replace >> 1-COS(X)*COS(X) with SIN(x)*SIN(x) and guarentee the same results. > >True, but Fortran would allow this anyway since optimized expressions >need only to be mathematically identical, not computationally identical >(see section 6.6 of the standard). > Hmm. Sounds like this is not in the same spirit as the fortran requirement that (A-B)-C be treated differently than A-(B-C) because they would produce different numerical results. I guess I haven't been bitten by it yet, but it looks like a smallish inconsistency in the logic behind the standard. Thanks for pointing it out. Marty +-+-+-+ I don't know who I am, why should you? +-+-+-+ | fouts@lemming.nas.nasa.gov | | ...!ames!orville!fouts | | Never attribute to malice what can be | +-+-+-+ explained by incompetence. +-+-+-+