0
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Are you sure $I$ isn't the identity? Also this isn't, strictly speaking, a linear equation as you're solving for a quadratic term. And is $X$ diagonal or is every element a variable? $\endgroup$ – b3m2a1 Mar 20 '18 at 1:25
  • $\begingroup$ @b3m2a1 Yes I correctly it, it is the identity matrix. Every element in a variable. $\endgroup$ – Jwizz Mar 20 '18 at 1:28
  • $\begingroup$ If every element can change it'll take a long time for Mathematica to compute the solutions. I can give you how you could set up such a system, but not how the results. $\endgroup$ – b3m2a1 Mar 20 '18 at 1:36
  • $\begingroup$ @b3m2a1 would appreciate it. Been stuck on this problem for quite some time. New to mathematica. $\endgroup$ – Jwizz Mar 20 '18 at 1:37
  • 2
    $\begingroup$ Then we have to wait until your friend wakes up. In the meantime, you might have a look at the algebraic Ricatti equation. $\endgroup$ – Henrik Schumacher Mar 20 '18 at 1:44
1
$\begingroup$

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)$

$\endgroup$
  • $\begingroup$ Thank you so much for this! I really appreciate the insights! I hope this doesn't come off as annoying to you. But out of curiosity. How would this look differently if diagonal? $\endgroup$ – Jwizz Mar 20 '18 at 1:52
  • $\begingroup$ @Jwizz it'll be significantly simpler. I'll post how to build it. $\endgroup$ – b3m2a1 Mar 20 '18 at 1:53
  • $\begingroup$ Thank you again $\endgroup$ – Jwizz Mar 20 '18 at 1:54
  • $\begingroup$ This broke website formatting. $\endgroup$ – Vsevolod A. Mar 20 '18 at 1:58
  • $\begingroup$ @VsevolodA. yeah that made my point for me very nicely $\endgroup$ – b3m2a1 Mar 20 '18 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.