フィルターのクリア

Evaluate definite integral numerically, where the function is indeterminate

6 ビュー (過去 30 日間)
jake gamma
jake gamma 2020 年 5 月 30 日
回答済み: Walter Roberson 2020 年 5 月 30 日
I'm trying to evaluate the following integral
Suppose I define a function handle as
f = @(x) x.*cosh(x)./( sinh(x).*(cosh(Phi*x)).^2 );
and evaluate the integral as
I = integral(f,-inf,inf)
the result gives NaN.
This is because the function is indeterminate at -inf, 0 and inf. However, using l'Hopital's rule, one can verify that the function's limits at these points are 0, 1, and 0, respectively, and the integral is indeed finite.
What is the best way to evaluate integrals of this kind numerically in MATLAB?

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 30 日
編集済み: Ameer Hamza 2020 年 5 月 30 日
If you have Symbolic toolbox, then you can try
syms x
Phi = 1;
f(x) = x.*cosh(x)./( sinh(x).*(cosh(Phi*x)).^2 );
y = vpaintegral(f, -inf, inf)
Result
y =
2.4674
Alternative solution using integral()
y = integral(@f, -inf, inf)
function y = f(x)
Phi = 1;
y = x.*cosh(x)./( sinh(x).*(cosh(Phi*x)).^2 );
y(isnan(y)) = 0;
end

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 5 月 30 日
Break the integration up into parts that are piecewise numerically integratable, and add the parts together. Do not, however, expect matlab to be able to find the boundary conditions for you. For example it is not enough to integrate from -realmax to - eps(realmin) and the mirror of that, because the hyperbolic expressions are going to overflow to inf by 708 or so for each term and sinh*cosh^2 would overflow about cube root of 708 roughly.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by