Defining 2x2 Matrices with Variables for Solving DEs

In summary, the user is seeking to solve a set of closed differential equations with 2x2 matrices as variables. They are struggling with defining a matrix with four variables and are wondering if there is an easier solution. The expert advises against using 2-d notation and suggests manually translating the equations into simpler forms. They also mention that trying to "desktop publish" the queries may result in difficulties. However, the user is free to try using matricies of equations with DSolve and report the results.
  • #1
McLaren Rulez
292
3
Hi,

I have a bunch of closed differential equations that I want to solve. The variables of the DEs are 2x2 matrices. So, I want to enter some 2x2 matrices of variables and then use NDSolve to get the solution.

How should I define a 2x2 matrix with four variables inside it? I tried

matrix[a_, b_, c_, d_] := {{a, b}, {c,d}} but this doesn't work. Rather embarassingly, I can't find the solution after quite a bit of googling.


Thank you for your help!
 
Last edited:
Physics news on Phys.org
  • #2


In Mathematica = and := are very different things. := means, and this is way too simplified but you almost certainly don't want to know all the ugly details, that sometime in the future if you ever use matrix[p,q,r,s] THEN you replace it with the right hand side {{p,q},{r,s}}. But until that future gets here := just tells Mathematica to remember that direction and do nothing until then.

I will warn you, the more anyone wants to "desktop publish" their problem, the more desperately they want to have everything in 2-d notation, the more problems they are likely going to find in trying to actually get a useful answer out of Mathematica.

If I were going to try to get an answer to your differential equations I would manually translate the whole mess into a form that looks very much like the simplest examples that you find in the help system. I've found that is the quickest path to a hopefully correct and useful answer.
 
  • #3


Thank you for the reply Bill.

So, what you're saying is that I should simply write out each matrix DE as four independent DEs? For instance if I have a very simple example

[tex]\frac{d}{dt}A=B[/tex]

I should simply write four equations of the form [itex]\frac{d}{dt}A_{ij}=B_{ij}[/itex]

This can indeed be done (and for me, it's not too bad since they are only 2x2 matrices) but I was wondering if there was an easier way to tell mathematica to create a matrix that has all its entries as variables. The reason I thought matrix[a_, b_, c_, d_] := {{a, b}, {c,d}} might work was because it worked for one variable. If I try matrix[a_] := {{a, 2}, {3,4}}, it understands that a is a variable so the input of matrix[1] gives the output {{1, 2}, {3,4}} and so on.

It's not that I am lazy to write it out, I just wanted to see if there was a nicer solution. Thank you :)
 
  • #4


McLaren Rulez said:
Thank you for the reply Bill.

So, what you're saying is that I should simply write out each matrix DE as four independent DEs? For instance if I have a very simple example

[tex]\frac{d}{dt}A=B[/tex]

I should simply write four equations of the form [itex]\frac{d}{dt}A_{ij}=B_{ij}[/itex]

Yes. And avoiding the urge to subscript your variables will make your life easier too.

McLaren Rulez said:
This can indeed be done (and for me, it's not too bad since they are only 2x2 matrices) but I was wondering if there was an easier way to tell mathematica to create a matrix that has all its entries as variables. The reason I thought matrix[a_, b_, c_, d_] := {{a, b}, {c,d}} might work was because it worked for one variable. If I try matrix[a_] := {{a, 2}, {3,4}}, it understands that a is a variable so the input of matrix[1] gives the output {{1, 2}, {3,4}} and so on.

It's not that I am lazy to write it out, I just wanted to see if there was a nicer solution. Thank you :)

You can write function definitions to create matricies and vectors. That is not a problem. But usually the more you try to "desktop publish" the queries you are giving Mathematica the more difficulty you will have.

Mathematica, like many other pieces of software, started out as a command line driven tool. Only later did they try to glue on desktop publishing and that is not uniformly implemented.

You are certainly free to try giving matricies of equations to DSolve. Give it a good serious try. Then report how well that worked.
 
  • #5


Thank you for your help.
 

FAQ: Defining 2x2 Matrices with Variables for Solving DEs

What is a 2x2 matrix?

A 2x2 matrix is a rectangular array of numbers with two rows and two columns. It can be written in the form [a b;c d], where a, b, c, and d are numbers.

How are variables used in 2x2 matrices for solving differential equations?

Variables can be used in the elements of a 2x2 matrix to represent the coefficients of a system of differential equations. This allows for a more general solution to be found, as the equations can be solved for any values of the variables.

Can 2x2 matrices with variables represent any type of differential equation?

Yes, 2x2 matrices with variables can represent any system of first-order linear differential equations. However, they may not be able to represent higher-order or nonlinear differential equations.

How do you solve a system of differential equations using 2x2 matrices with variables?

The first step is to write the system of equations in matrix form, with the variables representing the coefficients. Then, the matrix can be manipulated using matrix operations to solve for the variables. The resulting solution can then be used to solve the original system of differential equations.

Are there any limitations to using 2x2 matrices with variables for solving differential equations?

While 2x2 matrices with variables can be a useful tool for solving certain types of differential equations, they may not be able to represent more complex systems or nonlinear equations. It is important to carefully consider the limitations and applicability of this method before using it to solve a system of differential equations.

Similar threads

Replies
1
Views
867
Replies
3
Views
2K
Replies
4
Views
5K
Replies
1
Views
1K
Replies
4
Views
3K
Back
Top