function f = polyn( x, n ) %POLYN Evaluate expanded form of (x-1)^n % % polyn( x, n ) = ( x - 1 )^n = x^n - n*x^(n-1) + ... % % evaluated in expanded form. % % Simple little function for testing sensistivity of % polynomial roots computed via 'fzero()'. % % Typical usage: % % >> fzero( 'polyn', [ .1 1.7 ], [], [], 3 ) % % which searches for root of polyn(x,3) on [ .1, 1.7 ] % using default tolerance and no verbose tracing. % % See also FZERO. % % C.G. (11-97) % switch n case 1 f = x - 1 ; case 3 f = x.^3 - 3 * x.^2 + 3 * x - 1 ; case 5 f = x.^5 - 5 * x.^4 + 10 * x.^3 - 10 * x.^2 + 5 * x - 1 ; otherwise disp(' ') disp('bad degree for polynomial') f = 0 ; end