Message Boards Message Boards

GROUPS:

Using CoefficientArrays to Invert simultaneous equations

Posted 4 months ago
732 Views
|
2 Replies
|
2 Total Likes
|

The table obtained via the CoefficientArrays command of a list of vector equations does not seem to result in 3x3 Matrix as the coefficients of the original simultaneous equations.

I tried using LinearSolve to invert the simultaneous equations, and I faced the same issue. `(Deformation Equations)

X = {X1, X2, X3};
x = {x1, x2, x3};
Eulerian = {e^-\[ScriptT]*x1 + 0*x2 + (e^-\[ScriptT] - 1)*x3, 
  0*x1 + x2 + (e^-\[ScriptT] - e^\[ScriptT])*x3, 0*x1 + 0*x2 + x3}
CoefficientArrays[Eulerian, {x1, x2, x3}]
Normal[%] // MatrixForm
Take[%, {2}] // MatrixForm
q = Flatten[%, 1] (* q is the Coefficients Matrix of x *)
q // MatrixForm
qInv = Inverse[q] // MatrixForm (* Eulerian in terms of q *)
x = qInv . X(* Lagrangian Form *)

(* Velocity Vector Field*)
v = D[x, \[ScriptT]] // MatrixForm(* Material derivative*)`
2 Replies

Thanks, Craig Very helpful, and it fixed my code!

A couple things: 1) When you do this:

m = {{1,2},{3,4}}//MatrixForm

m is no longer a matrix, it is a "Form" and

m.{x,y}

will not operate as you might expect. 2) It is much easier to debug if you put your input into separate Input cells and evaluate one at a time.

I've rewritten things here:

X = {X1, X2, X3};
x = {x1, x2, x3};

Eulerian = {e^-\[ScriptT]*x1 + 0*x2 + (e^-\[ScriptT] - 1)*x3, 
  0*x1 + x2 + (e^-\[ScriptT] - e^\[ScriptT])*x3, 0*x1 + 0*x2 + x3}

I suspect you want Exp[..] or E^(..) instead of e? It is a good habit to define your own symbols with lower case letters.

ca = CoefficientArrays[Eulerian, {x1, x2, x3}] (*same as CoefficientArrays[Eulerian, x]*)

(nca = Normal[ca]) // MatrixForm 

notice that the = is done before the output is turned into a "Form"

Also, you can just do this directly:

Inverse[ca[[2]]]

Continuing....

(tnca = Take[nca, {2}]) // MatrixForm (*do you mean nca[[2]] here? tnca has dimensions {1,3,3}, and nca[[2]] has dimensions {3,3} I'll keep working as though Take is what you want*)

q = Flatten[tnca, 1]

q has dimensions {3,3} now

qInv = Inverse[q]

You are redefining x here.

x = qInv . X

And this gives an expression:

D[x,-\[ScriptT]]
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