Re: How to eliminate noises? A better way perhaps.
- To: mathgroup at smc.vnet.net
- Subject: [mg122670] Re: How to eliminate noises? A better way perhaps.
- From: Dana DeLouis <dana01 at me.com>
- Date: Sat, 5 Nov 2011 04:47:27 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
> HornerForm. In this case it is > > k^2 (14 + > k^3 (-1296 + .... > k requires computing k^2,k^3,k^6 Hi. As a side note to Richards excellent reply... HornerForm for me pulled out a common k^3 term instead of just factoring out a k^2 term. If I were to use this code in vb/vba or something, I like to add the following. Since k^3 is calculated multiple times, I like to set that to a variable as well. Series[p,{n,1/2,40}] //Normal; % //. n-1/2->k 14 k^2-1296 k^5+1451188224 k^11-2002639749120 k^14+598075300380672 k^17-83414577743659008 k^20 +3977900382788517888 k^23-113721152119718805504 k^26+1516282028262917406720 k^29 HornerForm[%,k] //.k^3->w k^2 (w (k^6 (w (w (w (w (w (1516282028262917406720 w-113721152119718805504) +3977900382788517888)-83414577743659008)+598075300380672)-2002639749120)+1451188224)-1296)+14) In vb, I might change the k^2 to k*k, and note that the odd ball k^6 is just w*w. Hense, a function without a lot of power terms might be something like: g[n_] := Module[{k = n - 1/2, w}, w = k*k*k; k*k (w (w*w (w (w (w (w (w (w*1516282028262917406720 -113721152119718805504)+3977900382788517888) -83414577743659008)+598075300380672)-2002639749120)+1451188224)-1296)+14)] If f[x] is the op's original equation, then a quick test at a few points: Table[ { f[n], g[n] }, {n,35/100,53/100,1/100}]; Equal@@@% //Union {True} = = = = = = = Dana DeLouis $Version 8.0 for Mac OS X x86 (64-bit) (February 23, 2011) = = = = = = = On Nov 4, 7:01 am, Richard Fateman <fate... at cs.berkeley.edu> wrote: > On 11/3/2011 1:59 AM, Bob Hanlon wrote:> Use higher precision. > > .. so say you all... > Well, that's the brute force method, and one reason to recommend it is > it doesn't require much thought. > > On the other hand, the person asking the question has an apparently > large expression which he knows has a double zero at n=1/2 and he wants > to know the behavior of the expression from 0.35 to 0.53. Namely, > around that zero. > > Let us call that expression p. A non-brute force, but mostly automatic > method is to note that (since p is a polynomial of degree 29) it is > EXACTLY equal to s, where > > s = Normal[Series[p, {n, 1/2, 29}]] > > A plot of s can be done in ordinary float arithmetic and looks to the > eye just like the plot of p, done with high working precision. Unique to > computer algebra systems, it is also possible to look at the structure > of s, and note that expanded around n=1/2 it is mighty sparse. > > Let k = n-1/2 . The expression being plotted is then > > 14 k^2 - 1296 k^5 + 1451188224 k^11 - 2002639749120 k^14 + > 598075300380672 k^17 - 83414577743659008 k^20 + > 3977900382788517888 k^23 - 113721152119718805504 k^26 + > 1516282028262917406720 k^29 > > Sometimes a better way to format expressions for evaluation is to use > HornerForm. In this case it is > > k^2 (14 + > k^3 (-1296 + .... > > Evaluating this expression at a value for k requires computing > k^2,k^3,k^6,and some other arithmetic for a total of about 18 arithmetic > operations, which can be done in double-float. > The real win here is that you can show how much more insight you might > get from using computer algebra. > > RJF