legendrep - function p=legendrep(m,x) % function which...

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

View Full Document Right Arrow Icon
function p=legendrep(m,x) % function which construct Legendre polynomial Pm(x) % where M is the degree of polynomial and X is the variable. % Result - P is the char string that should be evaluated EVAL(P) % Example: % P=legendrep(2,'cos(theta)') will produce % P='(3*cos(theta).^2 -1)/2' which then can be evaluated as % theta=0.3; P=legendrep(2,'cos(theta)'); Lp=eval(P); produce % Lp = 0.8690 % For Matlab R14 the following example can be used: % x=-5:.1:5; p=legendrep(5,'x .*cos(x)'); xp = eval(p); % figure; plot(x, xp, 'r.-'); grid % % References: % Gradshteyn, Ryzhik "Table of Integrals Series and Products", 6th ed., p.973 % %__________________________________________________ % Sergei Koptenko, Resonant Medical Inc., Toronto % sergei.koptenko@resonantmedical.com %______________March/30/2004_______________________ % switch m case 0 p='1'; return case 1 p=x; return case 2 p=['(3*' x '.^2 -1)/2']; return case 3 p=['(5*' x '.^3 - 3 *' x ')/2']; return case 4 p=['(35 *' x '.^4 - 30 * ' x '.^2 + 3)/8'];
Background image of page 1

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

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

This note was uploaded on 09/19/2009 for the course MATH numerical taught by Professor Ford during the Spring '09 term at FAU.

Page1 / 2

legendrep - function p=legendrep(m,x) % function which...

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