How to get partial expression from symbolic expression containing specific variable MAPLE?

后端 未结 2 1259
清歌不尽
清歌不尽 2021-01-15 07:06

I have a symbolic expressions as below

y1 = (1/a)-(b/a^2)+x*a*b-x/b
y2 = a*b+a*x+b*sqrt(x)

now I need to get the partial expressions which

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-15 07:13

    listOfTerms = op(expression);  # y1 or y2
    numberOfSubExpressions=nops(expression); # for y1 or y2
    
    requiredTerm = 0;
    
    for i 1 to numberOfSubExpressions do 
        if has(listOfTerms [i], x) then # x is our required term
           requiredTerm := requiredTerm +listOfTerms [i] 
        end if 
    end do
    

    Above code does my requirement. But, if are there any bugs for special expressions please let me know. Because op function behaves differently when we have functions like(sin,cos Log ..etc)

提交回复
热议问题