----- Messaggio originale ----- > Da: Joe Schaefer > FWIW I refreshed my memory about how > to compute polynomials numerically by > looking back at my old copy of Numerical > Recipes in C and it's always considered > bad form to evaluate the terms individually, > especially not by using the POWER function to > do it. Most of the time you want to > compute p = c[0] x^0 + ... + c[n] x^n by doing > > p = c[j=n]; > while (j > 0) > p = p*x + c[--j]; > > > which does the right thing and pulls out > c[0] when x=0. Obviously there are overflow > issues to deal with for large degree polynomials > and large values of x, but you get the idea. >
Ah yes, that's an old numerical trick when n is an integer. The non-integer case is, of course, more interesting ;). What I was noting in a previous reply (to Norbert) is that you actually never even write x^0, you just write: p = c[0] + c[1] x^1 + ... + c[n] x^n so when calculating the derivative (using the power rule) you completely ignore the first term as it's a waste of time (the derivate of a constant is 0). It somewhat silly (and a waste of time) to write POWER($A1, 0) in a spreadsheet where 0 ^ 0 is 1. My HP Calculator does have a valid reason for setting 0 ^ 0 =1, but it doesn't apply to a spreadsheet so I will leave at that :-P. Pedro.