Message Boards Message Boards

GROUPS:

Convert equation to matrix form?

Posted 3 months ago
838 Views
|
13 Replies
|
2 Total Likes
|

I want to convert set of equation into required matrix for my vibrational analysis. I am attaching herewith the two files. One with set of equation (named as questio1) and other one with required format(Named as required format).

Kindly help me out to get the final output.

input file/code

(A11 Amn \[Alpha]^2 + C11 Dmn \[Alpha]^2 - B11 Cmn \[Alpha]^3 + 
    A12 Bmn \[Alpha] \[Beta] + A66 Bmn \[Alpha] \[Beta] + 
    C12 Emn \[Alpha] \[Beta] + C66 Emn \[Alpha] \[Beta] + 
    A66 Amn \[Beta]^2 + C66 Dmn \[Beta]^2 - 
    B12 Cmn \[Alpha] \[Beta]^2 - 2 B66 Cmn \[Alpha] \[Beta]^2 - 
    Amn I0 \[Omega]^2 - Dmn I3 \[Omega]^2 + 
    Cmn I1 \[Alpha] \[Omega]^2) Cos[x \[Alpha]] Sin[y \[Beta]] == 0
(A12 Amn \[Alpha] \[Beta] + C12 Dmn \[Alpha] \[Beta] - 
    B12 Cmn \[Alpha]^2 \[Beta] - 2 B66 Cmn \[Alpha]^2 \[Beta] + 
    A22 Bmn \[Beta]^2 + C22 Emn \[Beta]^2 - B22 Cmn \[Beta]^3 + 
    A66 \[Alpha] (Bmn \[Alpha] + Amn \[Beta]) + 
    C66 \[Alpha] (Emn \[Alpha] + Dmn \[Beta]) - Bmn I0 \[Omega]^2 - 
    Emn I3 \[Omega]^2 + Cmn I1 \[Beta] \[Omega]^2) Cos[y \[Beta]] Sin[
   x \[Alpha]] == 0

Required output

( {
    {A11 \[Alpha] ^2 + A66 \[Beta]^2, 
     A12 \[Alpha] \[Beta] + A66 \[Alpha] \[Beta], -B11 \[Alpha]^3 - 
      B12 \[Alpha] \[Beta]^2 - 2 B66 \[Alpha] \[Beta]^2, 
     C11 \[Alpha]^2 + C66 \[Beta]^2, 
     C12 \[Alpha] \[Beta] + C66 \[Alpha] \[Beta]},
    {A12 \[Alpha] \[Beta] + A66 \[Alpha] \[Beta], 
     A22 \[Beta]^2 + A66 \[Alpha]^2, -B12 \[Alpha]^2 \[Beta] - 
      B22 \[Beta]^3 - 2 B66 \[Alpha]^2 \[Beta], 
     C12 \[Alpha] \[Beta] + C66 \[Alpha] \[Beta], 
     C22 \[Beta]^2 + C66 \[Alpha]^2}
   } ) - \[Omega]^2 ( {
     {-I0, 0, \[Alpha] I1, -I4, 0},
     {0, -I0, I1 \[Beta], 0, -I3}
    } ) ( {
     {Amn},
     {Bmn},
     {Cmn},
     {Dmn},
     {Emn}
    } ) == 0
13 Replies

This may go some way:

vars = {Amn, Bmn, Cmn, Dmn, Emn};
expr1 = (A11 Amn \[Alpha]^2 + C11 Dmn \[Alpha]^2 - 
     B11 Cmn \[Alpha]^3 + A12 Bmn \[Alpha] \[Beta] + 
     A66 Bmn \[Alpha] \[Beta] + C12 Emn \[Alpha] \[Beta] + 
     C66 Emn \[Alpha] \[Beta] + A66 Amn \[Beta]^2 + 
     C66 Dmn \[Beta]^2 - B12 Cmn \[Alpha] \[Beta]^2 - 
     2 B66 Cmn \[Alpha] \[Beta]^2 - Amn I0 \[Omega]^2 - 
     Dmn I3 \[Omega]^2 + Cmn I1 \[Alpha] \[Omega]^2) Cos[
    x \[Alpha]] Sin[y \[Beta]];
expr2 = (A12 Amn \[Alpha] \[Beta] + C12 Dmn \[Alpha] \[Beta] - 
     B12 Cmn \[Alpha]^2 \[Beta] - 2 B66 Cmn \[Alpha]^2 \[Beta] + 
     A22 Bmn \[Beta]^2 + C22 Emn \[Beta]^2 - B22 Cmn \[Beta]^3 + 
     A66 \[Alpha] (Bmn \[Alpha] + Amn \[Beta]) + 
     C66 \[Alpha] (Emn \[Alpha] + Dmn \[Beta]) - Bmn I0 \[Omega]^2 - 
     Emn I3 \[Omega]^2 + Cmn I1 \[Beta] \[Omega]^2) Cos[
    y \[Beta]] Sin[x \[Alpha]];
Collect[{expr1, expr2}, \[Omega],
 Inactive[Dot][Normal@Last@CoefficientArrays[#, vars], vars] &]
Simplify[Activate[%] == {expr1, expr2}]
Posted 3 months ago

Sir Thank you for the reply but then I want it in a format as specified in attached formatrequired,nb orelse coefficient as given below

K11 = A11 \[Alpha]^2 + A66 \[Beta]^2;
K12 = A12 \[Alpha] \[Beta] + A66 \[Alpha] \[Beta];
K13 = -B11 \[Alpha]^3 - B12 \[Alpha] \[Beta]^2 - 
   2 B66 \[Alpha] \[Beta]^2;
K14 = C11 \[Alpha]^2 + C66 \[Beta]^2;
K15 = C12 \[Alpha] \[Beta] + C66 \[Alpha] \[Beta];
K21 = A12 \[Alpha] \[Beta] + A66 \[Alpha] \[Beta];
K22 = A22 \[Beta]^2 + A66 \[Alpha]^2;
K23 = -B12 \[Alpha]^2 \[Beta] - B22 \[Beta]^3 - 
   2 B66 \[Alpha]^2 \[Beta];
K24 = C12 \[Alpha] \[Beta] + C66 \[Alpha] \[Beta];
K25 = C22 \[Beta]^2 + C66 \[Alpha]^2;
m11 = I0; m12 = 0; m13 =- \[Alpha] I1; m14 = I3; m15 = 0;
m21 = 0; m22 = I0; m23 = -I1 \[Beta]; m24 = 0; m25 = I3;
Posted 3 months ago

Sir

I was trying to use similar technique for three equations but getting some error. Please do help me.

vars = {Amn, Bmn, Cmn, Dmn, Emn};
expr1 = (A11 Amn \[Alpha]^2 + C11 Dmn \[Alpha]^2 - 
    B11 Cmn \[Alpha]^3 + A12 Bmn \[Alpha] \[Beta] + 
    A66 Bmn \[Alpha] \[Beta] + C12 Emn \[Alpha] \[Beta] + 
    C66 Emn \[Alpha] \[Beta] + A66 Amn \[Beta]^2 + C66 Dmn \[Beta]^2 -
     B12 Cmn \[Alpha] \[Beta]^2 - 2 B66 Cmn \[Alpha] \[Beta]^2 - 
    Amn I0 \[Omega]^2 - Dmn I3 \[Omega]^2 + 
    Cmn I1 \[Alpha] \[Omega]^2) ;
expr2 = (A12 Amn \[Alpha] \[Beta] + C12 Dmn \[Alpha] \[Beta] - 
    B12 Cmn \[Alpha]^2 \[Beta] - 2 B66 Cmn \[Alpha]^2 \[Beta] + 
    A22 Bmn \[Beta]^2 + C22 Emn \[Beta]^2 - B22 Cmn \[Beta]^3 + 
    A66 \[Alpha] (Bmn \[Alpha] + Amn \[Beta]) + 
    C66 \[Alpha] (Emn \[Alpha] + Dmn \[Beta]) - Bmn I0 \[Omega]^2 - 
    Emn I3 \[Omega]^2 + Cmn I1 \[Beta] \[Omega]^2) ;
expr3 = (-Dmn E11 \[Alpha]^3 - B12 Bmn \[Alpha]^2 \[Beta] - 
    2 B66 Bmn \[Alpha]^2 \[Beta] - E12 Emn \[Alpha]^2 \[Beta] - 
    2 E66 Emn \[Alpha]^2 \[Beta] - Dmn E12 \[Alpha] \[Beta]^2 - 
    2 Dmn E66 \[Alpha] \[Beta]^2 - B22 Bmn \[Beta]^3 - 
    E22 Emn \[Beta]^3 + Dmn I4 \[Alpha] \[Omega]^2 + 
    Bmn I1 \[Beta] \[Omega]^2 + Emn I4 \[Beta] \[Omega]^2 - 
    Amn \[Alpha] (B11 \[Alpha]^2 + B12 \[Beta]^2 + 2 B66 \[Beta]^2 - 
       I1 \[Omega]^2) + 
    Cmn (Kw + nx \[Alpha]^2 + D11 \[Alpha]^4 + ny \[Beta]^2 + 
       2 D12 \[Alpha]^2 \[Beta]^2 + 4 D66 \[Alpha]^2 \[Beta]^2 + 
       D22 \[Beta]^4 + Ks (\[Alpha]^2 + \[Beta]^2) - I0 \[Omega]^2 - 
       I2 \[Alpha]^2 \[Omega]^2 - I2 \[Beta]^2 \[Omega]^2)) ;
Collect[{expr1, expr2 . expr3}, \[Omega], 
 Inactive[Dot][Normal@Last@CoefficientArrays[#, vars], vars] &]
Simplify[Activate[%] == {expr1, expr2, expr3}]

How about this:

vars = {Amn, Bmn, Cmn, Dmn, Emn};
expr1 = (A11 Amn \[Alpha]^2 + C11 Dmn \[Alpha]^2 - 
    B11 Cmn \[Alpha]^3 + A12 Bmn \[Alpha] \[Beta] + 
    A66 Bmn \[Alpha] \[Beta] + C12 Emn \[Alpha] \[Beta] + 
    C66 Emn \[Alpha] \[Beta] + A66 Amn \[Beta]^2 + C66 Dmn \[Beta]^2 -
     B12 Cmn \[Alpha] \[Beta]^2 - 2 B66 Cmn \[Alpha] \[Beta]^2 - 
    Amn I0 \[Omega]^2 - Dmn I3 \[Omega]^2 + 
    Cmn I1 \[Alpha] \[Omega]^2);
expr2 = (A12 Amn \[Alpha] \[Beta] + C12 Dmn \[Alpha] \[Beta] - 
    B12 Cmn \[Alpha]^2 \[Beta] - 2 B66 Cmn \[Alpha]^2 \[Beta] + 
    A22 Bmn \[Beta]^2 + C22 Emn \[Beta]^2 - B22 Cmn \[Beta]^3 + 
    A66 \[Alpha] (Bmn \[Alpha] + Amn \[Beta]) + 
    C66 \[Alpha] (Emn \[Alpha] + Dmn \[Beta]) - Bmn I0 \[Omega]^2 - 
    Emn I3 \[Omega]^2 + Cmn I1 \[Beta] \[Omega]^2);
expr3 = (-Dmn E11 \[Alpha]^3 - B12 Bmn \[Alpha]^2 \[Beta] - 
    2 B66 Bmn \[Alpha]^2 \[Beta] - E12 Emn \[Alpha]^2 \[Beta] - 
    2 E66 Emn \[Alpha]^2 \[Beta] - Dmn E12 \[Alpha] \[Beta]^2 - 
    2 Dmn E66 \[Alpha] \[Beta]^2 - B22 Bmn \[Beta]^3 - 
    E22 Emn \[Beta]^3 + Dmn I4 \[Alpha] \[Omega]^2 + 
    Bmn I1 \[Beta] \[Omega]^2 + Emn I4 \[Beta] \[Omega]^2 - 
    Amn \[Alpha] (B11 \[Alpha]^2 + B12 \[Beta]^2 + 2 B66 \[Beta]^2 - 
       I1 \[Omega]^2) + 
    Cmn (Kw + nx \[Alpha]^2 + D11 \[Alpha]^4 + ny \[Beta]^2 + 
       2 D12 \[Alpha]^2 \[Beta]^2 + 4 D66 \[Alpha]^2 \[Beta]^2 + 
       D22 \[Beta]^4 + Ks (\[Alpha]^2 + \[Beta]^2) - I0 \[Omega]^2 - 
       I2 \[Alpha]^2 \[Omega]^2 - I2 \[Beta]^2 \[Omega]^2));
expr = {expr1, expr2, expr3};
{m0, m1, m2} = 
  Normal@CoefficientArrays[Collect[expr, \[Omega]], \[Omega]];
{n0, n1} = Normal@CoefficientArrays[m0, vars];
{n2, n3} = Normal@CoefficientArrays[m2 . {1} . {1}, vars];
Inactive[Plus][Inactive[Dot][n1, vars], 
 Inactive[Times][Inactive[Dot][n3, vars], \[Omega]^2]]
Activate[%] == expr // Simplify
Posted 2 months ago

Thank you very much sir. It's working fine.

Sir I am having one more doubt in the equation

(A11 Amn \[Alpha]^2 + C11 Dmn \[Alpha]^2 - B11 Cmn \[Alpha]^3 + 
    A12 Bmn \[Alpha] \[Beta] + A66 Bmn \[Alpha] \[Beta] + 
    C12 Emn \[Alpha] \[Beta] + C66 Emn \[Alpha] \[Beta] + 
    A66 Amn \[Beta]^2 + C66 Dmn \[Beta]^2 - 
    B12 Cmn \[Alpha] \[Beta]^2 - 2 B66 Cmn \[Alpha] \[Beta]^2 - 
    Amn I0 \[Omega]^2 - Dmn I3 \[Omega]^2 + 
    Cmn I1 \[Alpha] \[Omega]^2) Cos[x \[Alpha]] Sin[y \[Beta]] == 0

want to eliminate constant term Cos[x \[Alpha]] Sin[y \[Beta]] from the equation. Please help me.

Can't you just delete the terms?

It is not quite clear to me what you want to do. If Amn etc. are your variables you can get the appropriate matrix mat by

eq1 = (A11 Amn \[Alpha]^2 + C11 Dmn \[Alpha]^2 - B11 Cmn \[Alpha]^3 + 
      A12 Bmn \[Alpha] \[Beta] + A66 Bmn \[Alpha] \[Beta] + 
      C12 Emn \[Alpha] \[Beta] + C66 Emn \[Alpha] \[Beta] + 
      A66 Amn \[Beta]^2 + C66 Dmn \[Beta]^2 - 
      B12 Cmn \[Alpha] \[Beta]^2 - 2 B66 Cmn \[Alpha] \[Beta]^2 - 
      Amn I0 \[Omega]^2 - Dmn I3 \[Omega]^2 + 
      Cmn I1 \[Alpha] \[Omega]^2) Cos[x \[Alpha]] Sin[y \[Beta]] == 0;
eq2 = (A12 Amn \[Alpha] \[Beta] + C12 Dmn \[Alpha] \[Beta] - 
      B12 Cmn \[Alpha]^2 \[Beta] - 2 B66 Cmn \[Alpha]^2 \[Beta] + 
      A22 Bmn \[Beta]^2 + C22 Emn \[Beta]^2 - B22 Cmn \[Beta]^3 + 
      A66 \[Alpha] (Bmn \[Alpha] + Amn \[Beta]) + 
      C66 \[Alpha] (Emn \[Alpha] + Dmn \[Beta]) - Bmn I0 \[Omega]^2 - 
      Emn I3 \[Omega]^2 + Cmn I1 \[Beta] \[Omega]^2) Cos[
     y \[Beta]] Sin[x \[Alpha]] == 0;

v = {Amn, Bmn, Cmn, Dmn, Emn};

{vec, mat} = Normal@CoefficientArrays[{eq1, eq2}, v];

Then check it

mat // MatrixForm;
Dimensions[mat]
(mat.v)[[1]] - eq1[[1]] // Simplify
(mat.v)[[2]] - eq2[[1]] // Simplify

And to eliminate the trig-functions

#/( Cos[x \[Alpha]] Sin[y \[Beta]]) & /@ (A11 Amn \[Alpha]^2 + 
      C11 Dmn \[Alpha]^2 - B11 Cmn \[Alpha]^3 + 
      A12 Bmn \[Alpha] \[Beta] + A66 Bmn \[Alpha] \[Beta] + 
      C12 Emn \[Alpha] \[Beta] + C66 Emn \[Alpha] \[Beta] + 
      A66 Amn \[Beta]^2 + C66 Dmn \[Beta]^2 - 
      B12 Cmn \[Alpha] \[Beta]^2 - 2 B66 Cmn \[Alpha] \[Beta]^2 - 
      Amn I0 \[Omega]^2 - Dmn I3 \[Omega]^2 + 
      Cmn I1 \[Alpha] \[Omega]^2) Cos[x \[Alpha]] Sin[y \[Beta]] == 0 // Expand
Posted 2 months ago

Sir, I can delete the common terms, but want to automate the process. I am doing vibrational analysis by solving governing equation. Since the assumption made in displacement are trigonometric series so want to cancel the trigonometric function if it is common in the equation.

This is a way to eliminate common trig factors:

expr = (A11 Amn \[Alpha]^2 + C11 Dmn \[Alpha]^2 - B11 Cmn \[Alpha]^3 +
     A12 Bmn \[Alpha] \[Beta] + A66 Bmn \[Alpha] \[Beta] + 
    C12 Emn \[Alpha] \[Beta] + C66 Emn \[Alpha] \[Beta] + 
    A66 Amn \[Beta]^2 + C66 Dmn \[Beta]^2 - 
    B12 Cmn \[Alpha] \[Beta]^2 - 2 B66 Cmn \[Alpha] \[Beta]^2 - 
    Amn I0 \[Omega]^2 - Dmn I3 \[Omega]^2 + 
    Cmn I1 \[Alpha] \[Omega]^2) Cos[x \[Alpha]] Sin[y \[Beta]]; 
Factor[expr]/Times @@ Cases[Factor[expr], _Cos | _Sin]
Posted 2 months ago

Thank you very much sir

Posted 2 months ago

Thank you everyone for valuable suggestion.

Posted 2 months ago

Sir,

I am finding difficulty in picking one of the elements from first matrixenter image description here

For example

I want to pick (2,3) from first matrix i.e

K23= B12 \[Alpha]^2 \[Beta] + 2 B66 \[Alpha]^2 \[Beta] + B22 \[Beta]^3

Similarly,

(2,3) from second matrix

M23=-I1 \[Beta]

I couldn't get direct command. Kindly suggest me the solution for this

Attachments:

To get the elements it is better to act on the matrix in isolation, before it is inserted into the wider expression:

matr = ( {
    {-A11 \[Alpha]^2 - A66 \[Beta]^2, -A12 \[Alpha] \[Beta] - 
      A66 \[Alpha] \[Beta], 
     B11 \[Alpha]^3 + B12 \[Alpha] \[Beta]^2 + 
      2 B66 \[Alpha] \[Beta]^2},
    {-A12 \[Alpha] \[Beta] - A66 \[Alpha] \[Beta], -A66 \[Alpha]^2 - 
      A22 \[Beta]^2, 
     B12 \[Alpha]^2 \[Beta] + 2 B66 \[Alpha]^2 \[Beta] + 
      B22 \[Beta]^3},
    {-C11 \[Alpha]^2 - C66 \[Beta]^2, -C12 \[Alpha] \[Beta] - 
      C66 \[Alpha] \[Beta], 
     E11 \[Alpha]^3 + E12 \[Alpha] \[Beta]^2 + 
      2 E66 \[Alpha] \[Beta]^2}
   } );
matr[[2, 3]]
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