Re: critical points of a third order polynomial fit (simplification)

• To: mathgroup at smc.vnet.net
• Subject: [mg68487] Re: [mg68466] critical points of a third order polynomial fit (simplification)
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Mon, 7 Aug 2006 01:41:08 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```The diffrerent results are due to loss of precision in the calculations. Use exact numbers (Rationalize) until the end and they come out the same (and different from your initial results).

bracket=Rationalize[{0.040911501042171394,9.797734083340343,0.\
003643048928782312,
9.939642325021731,0.0007478278717134088,10.027346441664564,
0.028647147834538127,10.169254683345951},0];

eqn[1]=Plus@@
Table[Times[c[i],Power[x,i-1]],{i,4}]==y;
eqn[2]=eqn[1]/.{x->x[#],y->y[#]}&/@Range[4];
rep[1]=FullSimplify@Solve[eqn[2],
Array[c,{4}]];
rep[2]=FullSimplify@Solve[D[eqn[1],x],x];
rep[3]=Simplify[rep[2]/.rep[1][[1]]];
rep[4]=rep[2]/.rep[1][[1]];
rep[5]={x[num_]:>bracket[[2 num]],y[num_]:>bracket[[2 num-1]]};

x/.rep[3]/.rep[5]//N//InputForm

{-1.7354138825983832*^13, 10.001481270475566}

x/.rep[4]/.rep[5]//N//InputForm

{-1.7354138825983832*^13, 10.001481270475566}

Bob Hanlon

---- Chris Chiasson <chris at chiasson.name> wrote:
> Here are some commands that find the (two) critical locations of a
> cubic polynomial fitted to four points. The four points are given as
> bracket={y1,x1,y2,x2,y3,x3,y4,x4}, where y is the range and x is the
> domain location. The code produces two sets of critical points. Both
> solution sets involve substituting the coefficients obtained from the
> four point "fit" into the general solution of the critical points
> (from calculus D[poly,x]==0). The only difference is that one of them
> calls a Simplify command that the other doesn't (compare rep[3] with
> rep[4]).
>
> Why are the answers for the second critical point so different? Do you
> think the simplification made in rep[3] is invalid? Does your computer
> give the same results that mine gives?
>
> In[1]:=
> \$Version
>
> Out[1]=
> 5.2 for Microsoft Windows (June 20, 2005)
>
> In[2]:=
> bracket={0.040911501042171394,9.797734083340343,0.003643048928782312,
>       9.939642325021731,0.0007478278717134088,10.027346441664564,
>       0.028647147834538127,10.169254683345951};
>
> In[3]:=
> eqn[1]=Plus@@Table[Times[c[i],Power[x,i-1]],{i,4}]\[Equal]y;
> eqn[2]=eqn[1]/.{x\[Rule]x[#],y\[Rule]y[#]}&/@Range[4];
> rep[1]=FullSimplify@Solve[eqn[2],Array[c,{4}]];
> rep[2]=FullSimplify@Solve[D[eqn[1],x],x];
> rep[3]=Simplify[rep[2]/.rep[1][[1]]];
> rep[4]=rep[2]/.rep[1][[1]];
> rep[5]={x[num_]\[RuleDelayed]bracket[[2 num]],
>       y[num_]\[RuleDelayed]bracket[[2 num-1]]};
>
> In[10]:=
> x/.rep[3]/.rep[5]//InputForm
>
> Out[10]//InputForm=
> {-1.4838127878952383*^10,
>  17.999998818597952}
>
> In[11]:=
> x/.rep[4]/.rep[5]//InputForm
>
> Out[11]//InputForm=
> {-1.4838127878952383*^10,
>  9.999999069105009}
>
> --
> http://chris.chiasson.name/
>

```

• Prev by Date: Re: Re: Finding the Number of Pythagorean Triples below a bound
• Next by Date: Re: Re: Finding the Number of Pythagorean Triples below a bound
• Previous by thread: Re: critical points of a third order polynomial fit (simplification)
• Next by thread: Re: critical points of a third order polynomial fit (simplification)