![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1618948/image.png)
integration of l^c * exp(-l)
3 views (last 30 days)
Show older comments
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
>>
``
0 Comments
Answers (1)
Abhinav Aravindan
on 16 Feb 2024
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]))
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1618948/image.png)
0 Comments
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!