How can I write "StruveL function" in matlab?
조회 수: 3 (최근 30일)
이전 댓글 표시
How can I write "StruveL function" in matlab?
댓글 수: 0
채택된 답변
David Goodmanson
2023년 12월 9일
Hello Shreen,
Here are two ways although you will need the symbolics toolbox for the first one. I used benign values for z and nu and the two methods agree very closely. When either z or nu get excessively large there will be numerical issues, and you might explore to see which method gives up first.
nu = 1.2;
z = 0:.1:4;
% hypergeometic function 1F2
C = 2/(sqrt(pi)*gamma(nu+3/2));
L1 = C*(z/2).^(nu+1).*hypergeom(1,[3/2+nu,3/2],z.^2/4)
% numerical integration
D = 2/(sqrt(pi)*gamma(nu+1/2));
fun = @(th,z,nu) sinh(z*cos(th)).*sin(th).^(2*nu);
L2 = D*(z/2).^nu.*integral(@(th) fun(th,z,nu),0,pi/2,'arrayvalued',true);
checkdel = max(abs(L1-L2))
L1 =
Columns 1 through 9
0 0.0010 0.0046 0.0113 0.0214 0.0351 0.0528 0.0748 0.1012
Columns 10 through 18
0.1325 0.1691 0.2112 0.2594 0.3141 0.3758 0.4452 0.5228 0.6095
Columns 19 through 27
0.7059 0.8129 0.9316 1.0629 1.2080 1.3682 1.5449 1.7396 1.9540
Columns 28 through 36
2.1901 2.4498 2.7355 3.0496 3.3948 3.7742 4.1911 4.6491 5.1522
Columns 37 through 41
5.7048 6.3118 6.9783 7.7104 8.5143
checkdel =
3.5527e-15
ans = 3.5527e-15
댓글 수: 3
Walter Roberson
2023년 12월 10일
Pi = sym(pi);
syms z
nu0 = sym(0);
C0 = 2/(sqrt(Pi)*gamma(nu0+3/2));
L0 = C0*(z/2).^(nu0+1).*hypergeom(1,[3/2+nu0,3/2],z.^2/4)
nu1 = sym(1);
C1 = 2/(sqrt(Pi)*gamma(nu1+3/2));
L1 = C1*(z/2).^(nu1+1).*hypergeom(1,[3/2+nu1,3/2],z.^2/4)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!