フィルターのクリア

How do I generate the first four polynomials?

2 ビュー (過去 30 日間)
veru
veru 2013 年 5 月 10 日
A Legendre polynomial of degree n is given by the following expression: Pn(x)=1/(2^n*n!) * nth derivative of (x^2-1)^n
How do I generate the first four polynomials?
I have tried the following code but no output is being given:
function y=f(x,n)
function z=S(w,n)
for k=4
syms w
z=(w^2-1)^n
subs(S,w,x)
diff(S,n);
y=(1/2^n)*factorial(n)*S
subs(f,w,x)
end
Thanks in advance.

採用された回答

Friedrich
Friedrich 2013 年 5 月 10 日
編集済み: Friedrich 2013 年 5 月 10 日
Hi,
what about:
for i=1:4
P{i} = 1/(( 2^i)*factorial(i)) * diff(sym(['(x^2-1)^',num2str(i)]),i)
end
Since you have Symbolic MATH Toolbox you can also do:
for i=1:4
L{i} = feval(symengine,'orthpoly::legendre',i,'x');
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by