# Solving a system of equations using subscripted variables

I want to solve this equation:

X(i, j) + C*Y(i, j) = Z(i, j)


Where

i = 2
j = 2
C = 5
X(i, j) = {{1, 1}, {1, 1}}
Y(i, j) = {{2, 2}, {2, 2}}


How can I get Mathematica to solve for values of Z(1, 1), Z(2, 1), Z(1, 2), Z(2, 2)?

I’m relatively new the Mathematica, and I’d like to solve these 4 equations, but I’d also like to be able to scale up i and j (to say, 10) without rewriting the code. Any syntax help would be very helpful. My code looks like this, but I can’t get Mathematica to find the solution.

Solve[
Table[Subscript[X, i, j] - (C*Subscript[Y, i, j]), {i, 2}, {j, 2}] ==
Table[Subscript[Z, i, j], {i, 2}, {j, 2}], {X, Y, Z}]

-
–  David Carraher Apr 16 '13 at 3:01
Thanks David, but I already found that, it didn't answer my question. –  Thermoguy Apr 16 '13 at 3:28
If you just want to do the matrix operation, I think you can do something like this X = {{1, 1}, {1, 1}}; Y = {{2, 2}, {2, 2}}; C0 = 5; Z = X + C0 Y. –  user0501 Apr 16 '13 at 4:28

Mathematica doesn't allow implicit definition of a matrix, so your Z should be defined as something like:

Z = {{z1, z2}, {z3, z4}};


For the case in which the order of Z is very high, you may prefer this kind of definition (just in case, I'd like to mention that something like Z(1, 1) doesn't make sense in Mathematica):

Z = Table[z[i, j], {i, 2}, {j, 2}];


Then, you seem to mix up Subscript and List. They're totally different. Personally, I suggest you not to use Subscript, since (I think) it's a compromise to the traditional form of math symbol and a somewhat pathological object in Mathematica. You'll find that List or just something like a[1, 1] = 1; a[1, 2] = 2; … more convinient when you get more familiar with Mathematica. Here your X and Y can be defined like this:

X = {{1, 1}, {1, 1}};
Y = {{2, 2}, {2, 2}};


The third problem in your code is that you choose capital letters for the name of variables, it's not a good choice since all the built-in functions in Mathematica are begun with capital letter so it may cause problems, and for your code, your C gets caught: it's a protected symbol. We can change it into c:

c = 5;


After running all the code above, we can solve your equation (by the way, your syntax of Solve is also wrong, it should not be {X, Y, Z} because X and Y are not unknown variables):

Solve[X + c Y == Z, Flatten@Z]
(* {{z1 -> 11, z2 -> 11, z3 -> 11, z4 -> 11}}
or
{{z[1, 1] -> 11, z[1, 2] -> 11, z[2, 1] -> 11, z[2, 2] -> 11}} *)

-
Thanks for clarifying in your edit. I need to read and reread this a few times. I really appreciate your time. –  Thermoguy Apr 16 '13 at 3:48
@user6941 Everything's hard in the beginning :). –  xzczd Apr 16 '13 at 4:00