Symbolic integration has 3 solutions based on integration variable range, how to extract one of these?

7 ビュー (過去 30 日間)
r is the integration variable. The integration is:
mom_2 = int((umax*(1-r/Radius)^(1/7))^2*2*pi*r,r,0,Radius)
and the result is:
size(mom_2) = 1 1
Question: how do I access each of these three possible solutions?
For example, I would like to use (50/49)*pi*U_0^2 in further calculations. Thanks ahead of time!

採用された回答

Paul
Paul 2024 年 2 月 17 日
syms U_0 r Radius
mom_2 = int((U_0*(1-r/Radius)^(1/7))^2*2*sym(pi)*r,r,0,Radius)
mom_2 = 
One approach that just extracts the case you want
c = children(mom_2)
c = 3×2 cell array
{[(49*pi*U_0^2)/72 ]} {[Radius == 1]} {[(49*pi*Radius^2*U_0^2)/72 ]} {[0 < Radius ]} {[2*U_0^2*pi*int(r*(1 - r/Radius)^(2/7), r, 0, Radius)]} {[~0 < Radius]}
case1 = c{1,1}
case1 = 

その他の回答 (1 件)

John D'Errico
John D'Errico 2024 年 2 月 17 日
Or do this:
syms r umax Radius
mom_2 = int((umax*(1-r/Radius)^(1/7))^2*2*pi*r,r,0,Radius)
mom_2 = 
subs(mom_2,Radius,1)
ans = 
Note that it resolves the three cases into 1.
  5 件のコメント
Paul
Paul 2024 年 2 月 17 日
It's usually better to use assume before calling int to give it some help. In this case, if R>0, we'd try
syms U_0 r Radius
assume(Radius,'positive')
mom_2 = int((U_0*(1-r/Radius)^(1/7))^2*2*sym(pi)*r,r,0,Radius)
mom_2 = 
Not sure why that didn't work. Instead, we can do
syms rho
assume(rho,'positive')
mom_2 = int((U_0*(1-r/rho)^(1/7))^2*2*sym(pi)*r,r,0,Radius)
mom_2 = 
mom_2 = subs(mom_2,rho,Radius)
mom_2 = 
Jason Oakley
Jason Oakley 2024 年 2 月 17 日
Yes, that is a good tip and now this looks like the cleanest solution

サインインしてコメントする。

カテゴリ

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

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by