Need help with complicated Legendre function to be integrated
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Walter Roberson
il 31 Mag 2011
If you post the original formula, there is a possibility that I could figure it out in Maple.
Risposte (3)
Mike Hosea
il 1 Giu 2011
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 Commenti
Andrew
il 3 Giu 2011
3 Commenti
Walter Roberson
il 3 Giu 2011
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)));
Vedere anche
Categorie
Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!