フィルターのクリア

integration of l^c * exp(-l)

3 ビュー (過去 30 日間)
Jonas Colmsjö
Jonas Colmsjö 2021 年 10 月 13 日
回答済み: Abhinav Aravindan 2024 年 2 月 16 日
Why do the following code snippets give different results. The only difference is exp(-l*(m+1)) vs. exp(-l*3), l) where m=2. Any help is much appreciated!
>> syms l ct m cf
ncons_ = int(l^(c_1+c_2) * exp(-l*3), l)
ncons = eval(- subs(ncons_, l, 0))
eval(subs(ncons, [m, ct, cf, c_1, c_2], [2, sum([3,4]), prod(1./factorial([3,4])), 3, 4]))
ncons_ =
-((1/3)^(c_1 + c_2)*igamma(c_1 + c_2 + 1, 3*l))/3
ncons =
((1/3)^(c_1 + c_2)*gamma(c_1 + c_2 + 1))/3
ans =
0.7682
>> syms l ct m cf
ncons_ = int(l^(c_1+c_2) * exp(-l*(m+1)), l)
ncons = eval(- subs(ncons_, l, 0))
eval(subs(ncons, [m, ct, cf, c_1, c_2], [2, sum([3,4]), prod(1./factorial([3,4])), 3, 4]))
ncons_ =
-(l^(c_1 + c_2)*igamma(c_1 + c_2 + 1, l*(m + 1)))/((l*(m + 1))^(c_1 + c_2)*(m + 1))
ncons =
gamma(c_1 + c_2 + 1)/(m + 1)
ans =
1680
>>
``

回答 (1 件)

Abhinav Aravindan
Abhinav Aravindan 2024 年 2 月 16 日
While computing the integral with symbolic variables using the “int” function, “int” by default, uses strict mathematical rules. For instance, these rules do not allow to rewrite “acos(cos(x))” as “x”. A potential solution is to use “int” with the argument “IgnoreAnalyticConstraints” set to “true”.
Note: This option can provide simpler results for expressions but can lead to results that do not always hold for all values of variables.
More information can be found in the documentation link below:
Assuming “c_1” and “c_2” are also symbolic variables, please find a code snippet for your reference below.
syms l ct m cf c_1 c_2
% Method 1
ncons_ = int(l^(c_1+c_2) * exp(-l*3), l)
ncons = eval(- subs(ncons_, l, 0))
method1_result = eval(subs(ncons, [m, ct, cf, c_1, c_2], [2, sum([3,4]), ...
prod(1./factorial([3,4])), 3, 4]))
% Method 2
ncons_ = int(l^(c_1+c_2) * exp(-l*(m+1)), l, "IgnoreAnalyticConstraints", true)
ncons = eval(- subs(ncons_, l, 0))
method2_result = eval(subs(ncons, [m, ct, cf, c_1, c_2], [2, sum([3,4]), ...
prod(1./factorial([3,4])), 3, 4]))

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by