Re: Why won't Hornerwork?
- To: mathgroup at smc.vnet.net
- Subject: [mg59046] Re: Why won't Hornerwork?
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Wed, 27 Jul 2005 01:26:06 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 7/26/05 at 4:01 AM, paul.mchale at _NO_$PAMearthlink.net (Paul McHale) wrote: >When I issue the command: >In:= Fit[ {{1,200},{200,0},{400,200}}, {1,x,x^2}, x] >Out:= 202.01 - 2.01508 x + 0.00502513 x^2 >This seems good. But when I do >In:= Horner[Fit[ {{1,200},{200,0},{400,200}}, {1,x,x^2}, x]] >Out:= Horner[202.01 - 2.01508 x + 0.00502513 x^2] >Why doesn't it evaluate the polynomial? Did you load the package Algebra`Horner` using one of the following: <<Algebra`Horner` Get["Alegbra`Horner`"] Needs["Algebra`Horner`"] ? I stongly suspect you didn't since that is the main reason for Mathematica to return Horner unevaluated as you have indicated. But note, Horner doesn't evaluate the polynomial, it converts it to Horner form. That is: In[1]:= << "Algebra`"; Horner[Fit[{{1, 200}, {200, 0}, {400, 200}}, {1, x, x^2}, x]] Out[2]= (0.005025125628140703*x - 2.0150753768844214)*x + 202.0100502512562 If you want to evaluate the polynomial at a specific point (say x = 10) then the syntax is In[7]:= poly = Fit[{{1, 200}, {200, 0}, {400, 200}}, {1, x, x^2}, x]; poly /. x -> 10 Out[8]=182.36180904522604 Here, I've assigned the output of Fit to a variable so as to make it easy to evaluate at more than one point. That is (poly/.x->#)&/@list will evaluate poly at each point in list -- To reply via email subtract one hundred and four