Need help with complicated Legendre function to be integrated
10 ビュー (過去 30 日間)
古いコメントを表示
I am trying to figure out how to integrate a complicated function that has legendre polynomials in it. Mu is the variable by which I am attempting to integrate, from 0 to Muo. I am not sure why the legendres are turning into arrays instead of scalars, which I believe is the main problem. Also, the dGam is an array as well, which might not be right. I'm thinking that I need to differentiate Phi first, then plug in the value of Mu, but I am not sure what the derivative would be, and wolframaplha wasn't much help. Any advice would be greatly appreciated. Thank you!
------
m = 2; %choosing the index
muo = 5; %length of blade
nGam = 2; %order of gamma
B = quad(@Bfun,0.0001,muo,[],[],m,muo,nGam)
---------
function y = Bfun(mu,m,muo,nGam)
x = 2*mu/muo - 1; %change of variable (-1<x<1)
P1 = legendre(m+1,x); %Legendre polynomial
P1 = P1(m+2,:) %Selecting first order
P2 = legendre(m-1,x); %Legendre polynomial
P2 = P2(m,:) %Selecting first order
Phi2 = (P1 - P2)/(sqrt(2*(2*m-1))); %eqn for Phi2
dPhi2 = gradient(Phi2); %deriving Phi2
dPhi = 2/muo * dPhi2; %deriving Phi
dGam = [(nGam*(mu./sqrt(1 + mu.^2)).^nGam)./(nGam + mu.^3)]' %deriving gamma
y = -1* mu .* dPhi * dGam %sending final function
end
1 件のコメント
Walter Roberson
2011 年 5 月 31 日
If you post the original formula, there is a possibility that I could figure it out in Maple.
回答 (3 件)
Mike Hosea
2011 年 6 月 1 日
I haven't looked at your example in any kind of detail, but I wonder if you're aware that QUAD requires your function to operate elementwise on an array of mu values? If this is inconvenient, you can meet the requirement in a trivial way with arrayfun. Try it this way (and then debug from there, if need be):
integrand = @(mu)Bfun(mu,m,muo,nGam); % scalar mu only
vintegrand = @(mu)arrayfun(integrand,mu); % vector mu supported
B = quad(vintegrand,0.0001,muo)
Notice that this also "binds" the values of m, muo, and nGam in the definition of the integrand function rather than passes them in as arguments to quad. If you do it that way, you can use quadgk if you want. -- Mike
0 件のコメント
Andrew
2011 年 6 月 3 日
3 件のコメント
Walter Roberson
2011 年 6 月 3 日
fun = matlabFunction(-(2*10^(1/2)*mu^3*(((2*mu)/5 - 1)^2 + ((2*mu)/5 - 1)*((4*mu)/5 - 2) - 1))/(25*(mu^2 + 1)*(mu^3 + 2)));
参考
カテゴリ
Help Center および File Exchange で Numerical Integration and Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!