|simplification of formula (compiler? sorta...) email@example.com (Colin Prepscius) (1996-02-27)|
|Should it be done? Was: Re: simplification of formula firstname.lastname@example.org (1996-03-01)|
|From:||email@example.com (Herman Rubin)|
|Date:||1 Mar 1996 13:52:00 -0500|
|Organization:||Purdue University Statistics Department|
Colin Prepscius <firstname.lastname@example.org> 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
email@example.com 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]
Return to the
Search the comp.compilers archives again.