I have the following linear equation:
$$a X^2 - b X - cI = 0$$
Where, I is the identity matrix 5. And a,b,c will be arbitrary values to be later set, 1,2,3 is fine. How might one take that linear equation and turn it into a matrix?
Thank you
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI have the following linear equation:
$$a X^2 - b X - cI = 0$$
Where, I is the identity matrix 5. And a,b,c will be arbitrary values to be later set, 1,2,3 is fine. How might one take that linear equation and turn it into a matrix?
Thank you
Here's a way you could set this up, since you say you $X$ is all variable:
baseMX = Hold[
a*MatrixPower[X, 2] \[Minus] b*X \[Minus] c*IdentityMatrix[5]];
subbedMX =
baseMX /. {X ->
Array[Symbol["x" <> Map[ToString, {##}]] &, {5, 5}], a -> 1,
b -> 2, c -> 3} // ReleaseHold;
baseEq = subbedMX == Array[0 &, {5, 5}];
Then looking at subbedMX
:
subbedMX // TeXForm
$$\tiny\begin{pmatrix} \text{x11}^2-2 \text{x11}+\text{x12} \text{x21}+\text{x13} \text{x31}+\text{x14} \text{x41}+\text{x15} \text{x51}-3 & \text{x11} \text{x12}+\text{x22} \text{x12}-2 \text{x12}+\text{x13} \text{x32}+\text{x14} \text{x42}+\text{x15} \text{x52} & \text{x11} \text{x13}+\text{x33} \text{x13}-2 \text{x13}+\text{x12} \text{x23}+\text{x14} \text{x43}+\text{x15} \text{x53} & \text{x11} \text{x14}+\text{x44} \text{x14}-2 \text{x14}+\text{x12} \text{x24}+\text{x13} \text{x34}+\text{x15} \text{x54} & \text{x11} \text{x15}+\text{x55} \text{x15}-2 \text{x15}+\text{x12} \text{x25}+\text{x13} \text{x35}+\text{x14} \text{x45} \\ \text{x11} \text{x21}+\text{x22} \text{x21}-2 \text{x21}+\text{x23} \text{x31}+\text{x24} \text{x41}+\text{x25} \text{x51} & \text{x22}^2-2 \text{x22}+\text{x12} \text{x21}+\text{x23} \text{x32}+\text{x24} \text{x42}+\text{x25} \text{x52}-3 & \text{x13} \text{x21}+\text{x22} \text{x23}-2 \text{x23}+\text{x23} \text{x33}+\text{x24} \text{x43}+\text{x25} \text{x53} & \text{x14} \text{x21}+\text{x22} \text{x24}-2 \text{x24}+\text{x23} \text{x34}+\text{x24} \text{x44}+\text{x25} \text{x54} & \text{x15} \text{x21}+\text{x22} \text{x25}-2 \text{x25}+\text{x23} \text{x35}+\text{x24} \text{x45}+\text{x25} \text{x55} \\ \text{x11} \text{x31}+\text{x33} \text{x31}-2 \text{x31}+\text{x21} \text{x32}+\text{x34} \text{x41}+\text{x35} \text{x51} & \text{x12} \text{x31}+\text{x22} \text{x32}-2 \text{x32}+\text{x32} \text{x33}+\text{x34} \text{x42}+\text{x35} \text{x52} & \text{x33}^2-2 \text{x33}+\text{x13} \text{x31}+\text{x23} \text{x32}+\text{x34} \text{x43}+\text{x35} \text{x53}-3 & \text{x14} \text{x31}+\text{x24} \text{x32}+\text{x33} \text{x34}-2 \text{x34}+\text{x34} \text{x44}+\text{x35} \text{x54} & \text{x15} \text{x31}+\text{x25} \text{x32}+\text{x33} \text{x35}-2 \text{x35}+\text{x34} \text{x45}+\text{x35} \text{x55} \\ \text{x11} \text{x41}+\text{x44} \text{x41}-2 \text{x41}+\text{x21} \text{x42}+\text{x31} \text{x43}+\text{x45} \text{x51} & \text{x12} \text{x41}+\text{x22} \text{x42}-2 \text{x42}+\text{x32} \text{x43}+\text{x42} \text{x44}+\text{x45} \text{x52} & \text{x13} \text{x41}+\text{x23} \text{x42}+\text{x33} \text{x43}-2 \text{x43}+\text{x43} \text{x44}+\text{x45} \text{x53} & \text{x44}^2-2 \text{x44}+\text{x14} \text{x41}+\text{x24} \text{x42}+\text{x34} \text{x43}+\text{x45} \text{x54}-3 & \text{x15} \text{x41}+\text{x25} \text{x42}+\text{x35} \text{x43}+\text{x44} \text{x45}-2 \text{x45}+\text{x45} \text{x55} \\ \text{x11} \text{x51}+\text{x55} \text{x51}-2 \text{x51}+\text{x21} \text{x52}+\text{x31} \text{x53}+\text{x41} \text{x54} & \text{x12} \text{x51}+\text{x22} \text{x52}-2 \text{x52}+\text{x32} \text{x53}+\text{x42} \text{x54}+\text{x52} \text{x55} & \text{x13} \text{x51}+\text{x23} \text{x52}+\text{x33} \text{x53}-2 \text{x53}+\text{x43} \text{x54}+\text{x53} \text{x55} & \text{x14} \text{x51}+\text{x24} \text{x52}+\text{x34} \text{x53}+\text{x44} \text{x54}-2 \text{x54}+\text{x54} \text{x55} & \text{x55}^2-2 \text{x55}+\text{x15} \text{x51}+\text{x25} \text{x52}+\text{x35} \text{x53}+\text{x45} \text{x54}-3 \\ \end{pmatrix}$$
This gives a sense for how unwieldy it is.
Then you can run Solve[baseEq]
but I have low expectations you'll actually get a solution.
If X
can be diagonal this is much, much nicer (so much so as to pretty much be trivial). It'd then look like:
subbedMX2 =
baseMX /. {X ->
DiagonalMatrix@Array[Symbol["x" <> Map[ToString, {##}]] &, 5],
a -> 1, b -> 2, c -> 3} // ReleaseHold;
baseEq2 = subbedMX2 == Array[0 &, {5, 5}];
And subbedMX2
will be:
$\left( \begin{array}{ccccc} \text{x1}^2-2 \text{x1}-3 & 0 & 0 & 0 & 0 \\ 0 & \text{x2}^2-2 \text{x2}-3 & 0 & 0 & 0 \\ 0 & 0 & \text{x3}^2-2 \text{x3}-3 & 0 & 0 \\ 0 & 0 & 0 & \text{x4}^2-2 \text{x4}-3 & 0 \\ 0 & 0 & 0 & 0 & \text{x5}^2-2 \text{x5}-3 \\ \end{array} \right)$