japoly - end; if nargout==2, if n==0,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
function [varargout]=japoly(n,alp,bet,x); % The function y=japoly(n,alp,bet,x) computes the values of Jacobi polynomial % of degree n, and parameters (alp,bet) at x. % The function [dy,y]=japoly(n,alp,bet,x) also returns the values of 1st-order % derivatives (in the first output argument dy). if nargout==1, if n==0, varargout{1}=ones(size(x)); return; end; if n==1, varargout{1}=0.5*(alp-bet+(alp+bet+2)*x); return; end; polylst=ones(size(x)); poly=0.5*(alp-bet+(alp+bet+2)*x); apb=alp+bet; for k=2:n, a1=2.0*k*(k+apb)*(2.0*k+apb-2.); a2=(2.0*k+apb-1.)*(alp^2-bet^2); b3=(2.0*k+apb-2.); a3=b3*(b3+1.)*(b3+2.); a4=2.0*(k+alp-1.)*(k+bet-1.)*(2.0*k+apb); polyn=((a2+a3*x).*poly-a4*polylst)/a1; polylst=poly; poly=polyn; end; varargout{1}=poly;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end; if nargout==2, if n==0, varargout{2}=ones(size(x)); varargout{1}=zeros(size(x)); return;end; if n==1, varargout{2}=0.5*(alp-bet+(alp+bet+2)*x); varargout{1}=0.5*(alp+bet+2)*ones(size(x)); return; end; polylst=ones(size(x)); pderlst=zeros(size(x)); poly=0.5*(alp-bet+(alp+bet+2)*x); pder=0.5*(alp+bet+2)*ones(size(x)); apb=alp+bet; for k=2:n, a1=2.0*k*(k+apb)*(2.0*k+apb-2.); a2=(2.0*k+apb-1.)*(alp^2-bet^2); b3=(2.0*k+apb-2.); a3=b3*(b3+1.)*(b3+2.); a4=2.0*(k+alp-1.)*(k+bet-1.)*(2.0*k+apb); polyn=((a2+a3*x).*poly-a4*polylst)/a1; pdern=((a2+a3*x).*pder-a4*pderlst+a3*poly)/a1; polylst=poly; poly=polyn; pderlst=pder; pder=pdern; end; varargout{2}=poly; varargout{1}=pder; end;...
View Full Document

This document was uploaded on 01/25/2012.

Page1 / 2

japoly - end; if nargout==2, if n==0,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online