From: Saga on
Hi,

I've got matlab to generate a equation of polynomial.

a = 0.0015 -0.1084 3.8509 -35.1232

which is of order 3 i.e.

0.0015*x^3 - 0.1084*x^2 + 3.8509*x - 35.1232

when I type on matlab: polyval (a,19.13)

the answer is: 9.4393

x being the value of 19.13,

But when I compute the value on matlab manually:

0.0015*19.13^3 - 0.1084*19.13^2 + 3.8509*19.13 - 35.1232

The value it returns is 9.3759

How is this possible when, is there a mistake I'm making while calculating the formula manually?

Please advice.

Thanks
From: Steven Lord on

"Saga " <a5stargamescompany(a)googlemail.com> wrote in message
news:hlre9m$7eh$1(a)fred.mathworks.com...
> Hi,
>
> I've got matlab to generate a equation of polynomial.
>
> a = 0.0015 -0.1084 3.8509 -35.1232
>
> which is of order 3 i.e.
>
> 0.0015*x^3 - 0.1084*x^2 + 3.8509*x - 35.1232
>
> when I type on matlab: polyval (a,19.13)
>
> the answer is: 9.4393
> x being the value of 19.13,
> But when I compute the value on matlab manually:
>
> 0.0015*19.13^3 - 0.1084*19.13^2 + 3.8509*19.13 - 35.1232
>
> The value it returns is 9.3759

That's correct. The value of the highest-order coefficient is not exactly
0.0015; it's just being displayed that way, so when you use the truncated
value to evaluate the expression manually, you receive a (slightly)
different result. After all, even though the difference in the coefficient
is small, you're multiplying the truncated coefficient by 19^3 so the small
difference is magnified.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ