Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!ucbvax!agate!eos!amelia!lemming.nas.nasa.gov!fouts From: fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) Newsgroups: comp.lang.fortran Subject: Re: Confused about optimizing 1-COS(X)*COS(X) Message-ID: <1054@amelia.nas.nasa.gov> Date: 23 Sep 88 22:55:27 GMT References: <1041@amelia.nas.nasa.gov> <4090@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: 37 In article <4090@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >From article <1041@amelia.nas.nasa.gov>, by fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts): >> 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. [...] > >Subtract isn't associative! (A-B)-C is _mathematically_ different from >A-(B-C). In any case, Fortran is not allowed to optimize across >parenthesis. Fortran _is_ allowed to optimize expressions to any >_mathematically_ identical result (so long as it doesn't optimize >across parenthesis). So, 1-COS(x)*COS(x) may be optimized to SIN(x)**2. >But, 1-(COS(x)*COS(x)) may only be optimized to 1-(COS(x)**2). > Ignore the fact that at 1 AM i hit the - key instead of the + key and think about what I was trying to say. >Meanwhile, A-B-C _must_ be implemented as (A-B)-C. Read chapter 6 of >the standard: it's all in there! > I didn't say it wasn't there. What I was trying to say was that spirit of respecting parenthesis seems to be different than the spirit of replacing expressions involving functions with algebraicly equivalent expressions, and I got fouled up with a bad example. Care to comment on my content rather than my form? >J. Giles >Los Alamos +-+-+-+ 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. +-+-+-+