# HG changeset patch # User nir-krakauer # Date 1367434156 0 # Node ID 623e142cbebba479657101067f73cc48d948a7a5 # Parent f1b4cc8303022ac29d8fc1fbe0cdb61dfc4ceedd added test to chebyshevpoly diff -r f1b4cc830302 -r 623e142cbebb main/miscellaneous/inst/chebyshevpoly.m --- a/main/miscellaneous/inst/chebyshevpoly.m Wed May 01 02:55:33 2013 +0000 +++ b/main/miscellaneous/inst/chebyshevpoly.m Wed May 01 18:49:16 2013 +0000 @@ -18,11 +18,11 @@ ## ## Compute the coefficients of the Chebyshev polynomial, given the ## @var{order}. We calculate the Chebyshev polynomial using the recurrence -## relations, Tn+1(x) = (2*x*Tn(x) - Tn-1(x)). The @var{kind} can set to -## compute the first or second kind chebyshev polynomial. +## relations Tn+1(x) = (2*x*Tn(x) - Tn-1(x)). The @var{kind} can be set to +## compute the first or second kind Chebyshev polynomial. ## -## If the value @var{x} is specified, the polynomial is also evaluated, -## otherwise just the return the coefficients of the polynomial are returned. +## If the value @var{x} is specified, the polynomial is evaluated at @var{x}, +## otherwise just the coefficients of the polynomial are returned. ## ## This is NOT the generalized Chebyshev polynomial. ## @@ -64,3 +64,12 @@ endif endfunction + +%!test +%! x = logspace(-2, 2, 30); +%! maxdeg = 10; +%! for n = 1:maxdeg +%! assert( chebyshevpoly(1,n,cos(x)), cos(n*x), 1E3*eps ) +%! assert( chebyshevpoly(2,n,cos(x)) .* sin(x), sin((n+1)*x), 1E3*eps ) +%! endfor +