Xref: utzoo comp.lang.c:6353 junk:894 Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!husc6!sri-unix!quintus!sun!pitstop!sundc!seismo!uunet!mcvax!diku!dde!be From: be@dde.uucp (Bjorn Engsig) Newsgroups: comp.lang.c,sci.math.num-analysis Subject: Power (Re: all those :-) Keywords: No need, No good, NO! (This is new; read it!) Message-ID: <302@Aragorn.dde.uucp> Date: 18 Jan 88 09:30:12 GMT Organization: Dansk Data Elektronik A/S, Herlev, Denmark Lines: 42 A short resume for sci.math.num-analysis readers: -- A lot of people have written pro et contra for the inclusion -- of a power (which power? most don't bother :-) operator in the -- C programming language. The discussion has been on which symbol -- to use for power, where to put it in the operator hierarchy, and -- wether it should have integer or real exponents. C currently includes -- a pow function with real exponents, defined for nonnegative mantissa -- only. Let me start to comment on power with integer exponents. Pick up any first grade textbook on numerical analysis, and you will be told NEVER to use a power function like that. First, if you need to calculate x ** n (fortran notation), you will most often need x ** (n-1) etc. as well, and it should be calculated using recursion, to optimize calculation time. Second, you should bear in mind, that using ordinary polynmials is often a bad practice in numerical computation, since they are higly unorthogonal (i.e. similar, try to graph x ** 9 and x ** 10 for x between 0 and 1.). If you are doing computations with polynomials involved, you will normally pick a set of orthogonal polynomials, such as the chebychef polynomials. These kinds of polynomials are always calculated by recursion for speed and accuracy. Thus: Power with integer exponent is not needed! Next, the power with real exponent, which we have as the pow() function, is according to my knowledge not very heavily used. If a lot of people can come up with a lot of REAL application, where the call of pow() really makes their code look ugly compared with an infix operator, one MIGTH consider the inclusion of the operator. However, a lot of non numerics will definately use this operator for integer exponention, and they will not understand why they can't square -2.0, and why their progam is using that much CPU time. Thus: Power with real exponent is not good! -- Bjorn Engsig, E-mail: ..!uunet!mcvax!diku!dde!be or be@dde.uucp -- Hofstadters Law: It always take longer than you expect, even if you take into account Hofstadters Law.