function y = lu_find_y( y, a ) % See the Epage 163 in Wilmotts book: The Mathematics of Financial Derivatives % % Written by: % -- % John L. Weatherwax 2008-06-11 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- asq = a*a; y(2) = 1+2*a; %y(3:(end-1)) = 1+2*a - asq./y(2:(end-2)); % <- incorrect. We cannot vectorize this in this way ... Nminus = 1; Nplus = length(y); for n=3:(Nplus-1), y(n) = 1+2*a - asq/y(n-1); if( y(n)==0 ) error( 'failure / singular ...' ); end end