@Walter Roberson How can I use "result"? I am not that handy with symbolic functions. A is basically a variable (a number) and B is basically my variable eta, the same for GAMMA, that you defined
Integral of another integral
1 回表示 (過去 30 日間)
古いコメントを表示
I want to integrate h1b_eta and then plot it (m1b_eta). However, h1b_eta depends on other functions that also contain integrals. How can I do this?
h1b_eta=@(eta) blablabla and some integrals;
m1b_eta=@(eta) pi*(airy(2,eta)*integral(@(n) airy(n)*h1b_eta(n),eta_infts,eta)-airy(eta)*integral(@(n) airy(2,n)*h1b_eta(n),eta0ts,eta));
V1VEC=arrayfun(m1b_eta,0:0.01:N);
plot(abs(V1VEC),0:0.01:N)
I want to do this symbollically because I need to integrate m1b_eta aftwerwards (this can now be done numerically)
回答 (1 件)
Walter Roberson
2017 年 5 月 19 日
Code h1b_eta as a symbolic function; then
syms m1b_eta(eta) n
Pi = sym('pi');
m1b_eta(eta) = Pi * (airy(2,eta)*int(airy(n)*h1b_eta(n),n,eta_infts,eta) - airy(eta)*int( airy(2,n)*h1b_eta(n),n,eta0ts,eta));
x = 0:0.01:N;
V1VEC = m1b_eta(x);
plot(x, V1VEC)
Possibly the call will not be enough because it might have to turn the integral into numeric; you might need to use
V1VEC = arrayfun(@(ETA) double(m1b_eta(ETA)), x);
Also, if your expression is complicated, you might wan to use vpaintegral() instead of int() for performance: if you do, be sure to specify the RelTol option to get enough accuracy for your purpose.
4 件のコメント
Walter Roberson
2017 年 5 月 22 日
V1s(eta)=((i*alpha1*lambda_0)^(-1/3))*q1*integral2(@(x, y) airy(y),...
eta01, eta, eta01, @(x) x);
V2s(eta)=((i*alpha2*lambda_0)^(-1/3))*q2*integral2(@(x, y) airy(y),...
eta02, eta, eta02, @(x) x);
comes out as
GAMMA=@(x) gamma(sym(x)); Pi = sym('pi');
V1s(eta) = (1/3)*(eta-eta01)*(-(3/4)*3^(1/6)*(hypergeom([2/3], [4/3, 5/3], (1/9)*x^3)*x^2-eta01^2*hypergeom([2/3], [4/3, 5/3], (1/9)*eta01^3))*GAMMA(2/3)^2+Pi*3^(1/3)*(x*hypergeom([1/3], [2/3, 4/3], (1/9)*x^3)-eta01*hypergeom([1/3], [2/3, 4/3], (1/9)*eta01^3)))*q1/((I*alpha1*lambda_0)^(1/3)*Pi*GAMMA(2/3));
V2s(eta) = (1/6)*(-2*3^(1/3)*eta02*Pi*(eta-(1/2)*eta02)*hypergeom([1/3], [4/3, 5/3], (1/9)*eta02^3)+(3/2)*GAMMA(2/3)^2*3^(1/6)*eta02^2*(eta-eta02)*hypergeom([2/3], [4/3, 5/3], (1/9)*eta02^3)-(1/20)*Pi*3^(1/3)*eta02^4*(eta-eta02)*hypergeom([4/3], [7/3, 8/3], (1/9)*eta02^3)+Pi*hypergeom([1/3], [4/3, 5/3], (1/9)*eta^3)*3^(1/3)*eta^2+3*GAMMA(2/3)^2*hypergeom([-1/3], [1/3, 2/3], (1/9)*eta^3)*3^(1/6)-3*GAMMA(2/3)^2*3^(1/6)*hypergeom([-1/3], [1/3, 2/3], (1/9)*eta02^3))*q2/((I*alpha2*lambda_0)^(1/3)*Pi*GAMMA(2/3));
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!