help lopy lopy.m not found. help poly POLY Convert roots to polynomial. POLY(A), when A is an N by N matrix, is a row vector with N+1 elements which are the coefficients of the characteristic polynomial, DET(lambda*EYE(SIZE(A)) - A) . POLY(V), when V is a vector, is a vector whose elements are the coefficients of the polynomial whose roots are the elements of V . For vectors, ROOTS and POLY are inverse functions of each other, up to ordering, scaling, and roundoff error. ROOTS(POLY(1:20)) generates Wilkinson's famous example. See also ROOTS, CONV, RESIDUE, POLYVAL. help polyval POLYVAL Evaluate polynomial. Y = POLYVAL(P,X), when P is a vector of length N+1 whose elements are the coefficients of a polynomial, is the value of the polynomial evaluated at X. Y = P(1)*X^N + P(2)*X^(N-1) + ... + P(N)*X + P(N+1) If X is a matrix or vector, the polynomial is evaluated at all points in X. See also POLYVALM for evaluation in a matrix sense. Y = POLYVAL(P,X,[],MU) uses XHAT = (X-MU(1))/MU(2) in place of X. The centering and scaling parameters MU are optional output computed by POLYFIT. [Y,DELTA] = POLYVAL(P,X,S) or [Y,DELTA] = POLYVAL(P,X,S,MU) uses the optional output structure S provided by POLYFIT to generate error estimates, Y +/- delta. If the errors in the data input to POLYFIT are independent normal with constant variance, Y +/- DELTA contains at least 50% of the predictions. See also POLYFIT, POLYVALM. edit horner fschange('C:\data\matlab\horner.m'); clear horner P=[1,2,3] P = 1 2 3 polyval(P,4) ans = 27 horner(P,4) ??? Undefined function or variable 'n'. Error in ==> C:\data\matlab\horner.m On line 6 ==> for k=n:-1:0, fschange('C:\data\matlab\horner.m'); clear horner horner(P,4) ans = 24 fschange('C:\data\matlab\horner.m'); clear horner horner(P,4) ans = 27 horner(P,10) ans = 123 polyval(P,10) ans = 123 edit naivep fschange('C:\data\matlab\naivep.m'); clear naivep naivep(P,10) ans = 123 fschange('C:\data\matlab\naivep.m'); clear naivep uisave fschange('C:\data\matlab\horner.m'); clear horner P=[1,2,-3,4,-5] P = 1 2 -3 4 -5 naivep(P,10) maxn = 5 maxn = 35 maxn = 265 maxn = 1735 maxn = 11735 ans = 11735 horner(P,10) maxn = 1 maxn = 12 maxn = 117 maxn = 1174 maxn = 11735 ans = 11735 naivep(P,100) maxn = 5 maxn = 395 maxn = 29605 maxn = 1970395 maxn = 101970395 ans = 101970395 horner(P,100) maxn = 1 maxn = 102 maxn = 10197 maxn = 1019704 maxn = 101970395 ans = 101970395 P=[1,2,-3,40,-40,6,-7,8,-9] P = 1 2 -3 40 -40 6 -7 8 -9 horner(P,10) maxn = 1 maxn = 12 maxn = 117 maxn = 1210 maxn = 12060 maxn = 120606 maxn = 1206053 maxn = 12060538 maxn = 120605371 ans = 120605371 naivep(P,10) maxn = 9 maxn = 71 maxn = 629 maxn = 5371 maxn = 394629 maxn = 3605371 maxn = 3605371 maxn = 20605371 maxn = 120605371 ans = 120605371 roots(P) ans = -4.7704 0.8839 + 2.7424i 0.8839 - 2.7424i 1.0320 -0.4452 + 0.5181i -0.4452 - 0.5181i 0.4306 + 0.5353i 0.4306 - 0.5353i r=roots(P) r = -4.7704 0.8839 + 2.7424i 0.8839 - 2.7424i 1.0320 -0.4452 + 0.5181i -0.4452 - 0.5181i 0.4306 + 0.5353i 0.4306 - 0.5353i x=r(1) x = -4.7704 naivep(P,x) maxn = 9 maxn = 47.1629 maxn = 206.4575 maxn = 857.7946 maxn = 2.1572e+004 maxn = 1.2039e+005 maxn = 1.5574e+005 maxn = 2.6817e+005 maxn = 2.6817e+005 ans = -2.3283e-010 horner(P,x) maxn = 1 maxn = 2.7704 maxn = 10.2156 maxn = 10.2156 maxn = 10.2156 maxn = 10.2156 maxn = 10.2156 maxn = 10.2156 maxn = 10.2156 ans = -2.3124e-010 diary off