% % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % % Problem on EPage 63; Solutions on EPage 161 % %----- close all; clc; clear all; addpath('../../BookCode'); format long; n = 6; for( k=3:n ) coefs = zeros(1,k); for( l=0:k ) coefs(l+1) = (-1)^l * ( 1/factorial(l) )^2 ; end % order so that the coefs(1) is the coefficient of highest degree and % coefs(end) is the coefficient of lowest degree % then we can use polyval with them % coefs = fliplr( coefs ); fn = @(x) polyval( coefs, x ); if( false ) coefs_degrees = k:-1:0; fn_prime_coefs = coefs_degrees .* coefs; fn_prime_coefs = fn_prime_coefs(1:end-1); % drop the constant term (its derivative is zero) end fn_prime = @(x) polyval( fn_prime_coefs, x ); fzero( fn, 1 ) end format short;