Should it be done? Was: Re: simplification of formula (Herman Rubin)
1 Mar 1996 13:52:00 -0500

          From comp.compilers

Related articles
simplification of formula (compiler? sorta...) (Colin Prepscius) (1996-02-27)
Should it be done? Was: Re: simplification of formula (1996-03-01)
| List of all articles for this month |

From: (Herman Rubin)
Newsgroups: comp.compilers
Date: 1 Mar 1996 13:52:00 -0500
Organization: Purdue University Statistics Department
References: 96-02-313
Keywords: optimize

Colin Prepscius <> wrote:
>If any one knows of info about simplification of formula (esp existing
>code in C/C++), I'd be obliged. I think this is related to compilers
>- it seems to be related to forming parse trees...

>say I have 2x+3x+5=2+7, I'd like to encode the algorithm to simplify
>2x+3x=5x. That kind of thing...

The C compiler originally exercized this option. I believe that it
has been deleted.

A "natural" example to show why the compiler should not have this
latitude occurs in the problem of computing x - ln(1+x). If we
set 1+x = 2^k * (1+y), where sqrt(.5) <= 1+y <= sqrt(2.) the
accurate computational formula becomes

(((x - y) - k*c1) -k*c2) + (y - ln(1+y)),

and we have a special routine for the latter. Now this formulation,
with all of its parentheses, keeps the error close to its minimum,
but any change in the order of computaions is likely to lose this.
Such changes are easy to make.
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399 Phone: (317)494-6054 FAX: (317)494-0558
[I've never seen any C compiler that did that. Perhaps you are thinking of
an early Fortran compiler? -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.