integration of l^c * exp(-l)
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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]))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!