| Author |
Comment/Response |
Sinval Santos
|
02/23/00 5:51pm
Be the following expression:
exp= ax+Sin[rx+1]-Cos[bx+a];
The coefficients of variable x are: {a , r, b}.
I tried with several forms to collect these coefficients but I didn't get.
d1=Depth[exp]
6
p1=Position[exp,x]
{{1,2},{2,2,1,2,2},{3,1,2,2}}
01 - exp//Coefficient[#,x,p1]&
{{a,0},{0,0,a,0,0},{0,a,0,0}}
02 - exp//Coefficient[#,x,d1]&
0
03 - exp//Map[Coefficient[#,x]&,#,p1]&
Map[Coefficient[#1,x]&,a x-Cos[a+b x]+Sin[1+r x], {{1,2},{2,2,1,2,2},{3,1,2,2}}
04 - exp//Map[Coefficient[#,x]&,#,d1]&
0
I didn't get to collect the coefficients of x indicating the positions and the maximum level. I also used MapAt but I didn't get.
In big expressions, to simplify, it is necessary to substitute the coefficients of some variable.
How to do to collect the exp coefficients?.
Sinval Santos
URL: , |
|