integration of l^c * exp(-l)

3 次查看(过去 30 天)
Jonas Colmsjö
Jonas Colmsjö 2021-10-13
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 CenterFile Exchange 中查找有关 Polynomials 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by