Implementing generalized cosine and sine integrals
이전 댓글 표시
hello everybody,
I have been trying to implement a formula which includes generalized sine and cosine integrals. I didn't succeed yet.
Any of you please might help me with this??
The formula is:
W = 2[ sinh^-1 (h/a) - C(2ba, 2bh) - jS(2ba, 2bh) ]
+ (j/bh) *(1 - e^(-jbh)),
where b = 57.8, h = 25 mm (0.025 m), a = 0.5 mm (0.0005 m).
C(x, y) and S(x, y) are the generalized cosine and sine integrals defined as:
C(x, y) = Integral [ cos y / t^y dt], with 0-x as integration borders
S(x, y) = Integral [ sin y / t^y dt], with 0-x as integration borders
I have been trying to calculate the S(x, y) like (same for the C(x, y)):
b = 57.8;
h = 0.025; % 25 mm
a = 0.0005; % 5 mm
k = 2* b * h;
l = 2 * b * a;
fun = @(x) sin(x) ./ (x.^k);
q = integral (fun, 0, l);
but it doesn't work.
Can, please, any of you help me with this?
Thanks in advance for your time!
댓글 수: 3
Jan
2013년 7월 4일
"It doesn't work" does not allow to reconsider which problem you are faced with. Do the results differ from your expectations? Do you get an error message and if so, which one? Do the error message reveal important information, e.g. that integral operates on symbolic variables only?
Vera
2013년 7월 4일
Oliver K
2013년 7월 7일
It was just the warning in the output. Didn't you get any result in q? What was your expected result of q?
채택된 답변
추가 답변 (2개)
Walter Roberson
2013년 7월 8일
0 개 추천
At 0, your formula comes out to 0 / 0 which is Not A Number.
integral() is supposed to be able to handle a singularity at the lower limit, so it should just be a warning.
If your results are not good you might want to look on the integral() documentation page to see how to specify tolerances.
Mike Hosea
2013년 7월 8일
Well, first of all, I think we need 0 < k < 2 for the generalized sine integral and 0 < k < 1 for the generalized cosine integral. But the main issue is that the singularity is too strong. Here is what I would suggest. Get QUADSAS
This should evaluate the generalized cosine integrals directly as well as the generalized sine integrals where k < 1. For 1 < k < 2 you can employ integration by parts and reduce the generalized sine integral to a generalized cosine integral. The "varargin" parts here are so you can pass 'AbsTol' and 'RelTol'.
function q = gencosint(b,k,varargin)
q = quadsas(@cos,0,b,-k,0,varargin{:});
function q = gensinint(b,k,varargin)
if k < 1
q = quadsas(@sin,0,b,-k,0,varargin{:});
elseif k == 1
q = integral(@(x)sin(x)./x,0,b,varargin{:});
else
q = (gencosint(b,k-1,varargin{:}) - sin(b)/(b^(k-1)))/(k-1);
end
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!