Message Boards Message Boards

0
|
4782 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Convert an expression into a list?

Posted 7 years ago

Dear all,

I got a set of coupled Second Order Differential Equations (ODEs). To go on with a solution I need to convert the set of ODEs into a matrices equation. Now I need to grab the factors of the ODEs to put them into a matrix.

Let us assume, we would have the following expression:

    a (a - x) (a^2 c1 + a (12 c2 c3 + c1 (-17 + 8 c4)) x + 16 c1 x^2) u1[x] 
+ 2 (2 a^4 + a^3 x (-20 + 2 c2^2 + 3 c1 c3 + 8 c4 + 8 l + 8 l^2 - 16 b x^2)
 + 8 x^4 (-l - l^2 + 2 b x^2) - 8 a x^3 (2 + 4 c4 - 3 l - 3 l^2 + 6 b x^2) 
+ a^2 x^2 (34 - 2 c2^2 - 3 c1 c3 + 24 c4 - 8 c4^2 - 24 l - 24 l^2 + 48 b x^2)) u2[x]
 +  x (a^3 (4 c1 c2 + 15 c3) + a^2 (-4 c1 c2 + 3 c3 (11 - 8 c4)) x - 16 b x^5
 + 16 a (-3 c3 x^2 + b x^4)) u3[x] -  8 a c1 (a - x)^3 x u1'[x] 
-  16 (a - x)^2 x (a^2 - 2 x^2 + a (x - 2 c4 x)) u2'[x] + 24 a c3 (a - x)^2 x^2 u3'[x] 
- 16 (a - x)^4 x^2 u2''[x]

How do I get for example - 16 (a - x)^4 x^2 in front of the second derivative u2''[x] ?

Attached you can find the file containing the above mentioned expression. If you run this script, you will get 4 expressions which have to be set to 0 . Each expression contains the derivatives. I need to get all factors in front of the functions to create a matrix.

Sorry for this question, but I am new to Mathematica.

Regards,

Guido

Attachments:
POSTED BY: Guido Nierhauve
2 Replies

Your Input seems to contain CR's, so that different lines of Output are produced. Withoaut These I obtain

dgl = a (a - x) (a^2 c1 + a (12 c2 c3 + c1 (-17 + 8 c4)) x + 
     16 c1 x^2) u1[x] + 2 (2 a^4 + a^3 x (-20 + 2 c2^2 + 3 c1 c3 + 8 c4 + 8 l + 8 l^2 - 16 b x^2) + 
     8 x^4 (-l - l^2 + 2 b x^2) -  8 a x^3 (2 + 4 c4 - 3 l - 3 l^2 + 6 b x^2) + 
     a^2 x^2 (34 - 2 c2^2 - 3 c1 c3 + 24 c4 - 8 c4^2 - 24 l - 24 l^2 + 48 b x^2)) u2[x] + 
  x (a^3 (4 c1 c2 + 15 c3) + a^2 (-4 c1 c2 + 3 c3 (11 - 8 c4)) x - 
     16 b x^5 + 16 a (-3 c3 x^2 + b x^4)) u3[x] - 
  8 a c1 (a - x)^3 x u1'[x] - 
  16 (a - x)^2 x (a^2 - 2 x^2 + a (x - 2 c4 x)) u2'[x] + 
  4 a c3 (a - x)^2 x^2 u3'[x] - 16 (a - x)^4 x^2 u2''[x]

Then use

Coefficient[dgl, Derivative[2][u2][x]]
POSTED BY: Hans Dolhaine

Have a look at the following functions, I think one of them will work for you:

CoefficientRules
FromCoefficientRules
CoefficientList
Coefficient
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract