0
$\begingroup$

Here is the example of an equation, I'm trying to solve:

The equation: http://mathprofi.ru/i/matrichnye_uravneniya_primery_reshenij_clip_image012.gif

The solution:http://mathprofi.ru/i/matrichnye_uravneniya_primery_reshenij_clip_image023_0000.gif

I tried to use Solve, but apparently it doesn't work the way I expected:

In[132]:= matrixA:={{1,-3},{8,0}}
matrixB:=3 {{-1,1},{0,4}}

In[131]:= Solve[matrixA-2 X==matrixB,X]

Out[131]= {}
$\endgroup$
  • 1
    $\begingroup$ You need to specify the unknown X = {{x1,x2},{x3,x4}}, and type Solve[matrixA-2 X==matrixB,{x1,x2,x3,x4}]. Also, there is no need to use SetDelayed (:=) here; use Set (=). $\endgroup$ – corey979 Nov 2 '16 at 17:50
  • $\begingroup$ it worked, thanks! $\endgroup$ – Elias Nov 2 '16 at 18:04
1
$\begingroup$

Here's a simple way to do it:

A = {{1, -3}, {8, 0}}; X = {{x11, x12}, {x21, x22}}; B = {{-1, 1}, {0, 4}};

Solve[A - 2*X == 3*B, Flatten[X]]

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Thanks. Is there a way to easily convert the output into matrix, rather than manually extract x1, x2, x3, x4 from the solution, using Evaluate? $\endgroup$ – Elias Nov 2 '16 at 18:06
  • $\begingroup$ Something like this?Flatten[X] /. Solve[A - 2*X == 3*B, Flatten[X]] $\endgroup$ – M. Veruete Nov 2 '16 at 18:07
  • $\begingroup$ Not exactly. The result of Flatten[X] /. Solve[A - 2*X == 3*B, Flatten[X]] is {{5,-6,4,-18}}, but it supposed to be {{5,-6},{4,-18}} $\endgroup$ – Elias Nov 2 '16 at 18:10
  • $\begingroup$ Ok! So it would be: First[X /. Solve[A - 2*X == 3*B, Flatten[X]]] $\endgroup$ – M. Veruete Nov 2 '16 at 18:13

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.