{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

japoly - end if nargout==2 if n==0 varargout{2}=ones(size(x...

Info icon This 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;
Image of page 1

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

View Full Document Right Arrow Icon
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern