critical points of a third order polynomial fit (simplification)
- To: mathgroup at smc.vnet.net
- Subject: [mg68466] critical points of a third order polynomial fit (simplification)
- From: "Chris Chiasson" <chris at chiasson.name>
- Date: Sun, 6 Aug 2006 02:56:47 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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/
- Follow-Ups:
- Re: critical points of a third order polynomial fit (simplification)
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: critical points of a third order polynomial fit (simplification)