0
$\begingroup$

I solve a system of 4 equations with 4 variables z_i (see below).

I would like to change the way results are written as such for each i: y_i = AX + sum[By_(-i)] + Cz_i + u_i

where the sum comes from the other indices than i, u_i gathers all the terms not in X, y_(-i), and z_i.

for instance: y_1 = AX + By_2 + Cy_3 + Dy_4 + Ez_1 + u_1

Is it possible to do so?

Thanks.

Solve[{Subscript[\[Pi], 11] Subscript[z, 1] + 
    Subscript[\[Pi], 12] Subscript[z, 2] + 
    Subscript[\[Pi], 13] Subscript[z, 3] + 
    Subscript[\[Pi], 14] Subscript[z, 4] + Subscript[\[Pi], 10] X + 
    Subscript[\[Nu], 1] == Subscript[y, 1], 
  Subscript[\[Pi], 21] Subscript[z, 1] + 
    Subscript[\[Pi], 22] Subscript[z, 2] + 
    Subscript[\[Pi], 23] Subscript[z, 3] + 
    Subscript[\[Pi], 24] Subscript[z, 4] + Subscript[\[Pi], 20] X + 
    Subscript[\[Nu], 2] == Subscript[y, 2], 
  Subscript[\[Pi], 31] Subscript[z, 1] + 
    Subscript[\[Pi], 32] Subscript[z, 2] + 
    Subscript[\[Pi], 33] Subscript[z, 3] + 
    Subscript[\[Pi], 34] Subscript[z, 4] + Subscript[\[Pi], 30] X + 
    Subscript[\[Nu], 3] == Subscript[y, 3], 
  Subscript[\[Pi], 41] Subscript[z, 1] + 
    Subscript[\[Pi], 42] Subscript[z, 2] + 
    Subscript[\[Pi], 43] Subscript[z, 3] + 
    Subscript[\[Pi], 44] Subscript[z, 4] + Subscript[\[Pi], 40] X + 
    Subscript[\[Nu], 4] == Subscript[y, 4]}, {Subscript[z, 1], 
  Subscript[z, 2], Subscript[z, 3], Subscript[z, 4]}]
$\endgroup$
0

1 Answer 1

0
$\begingroup$

Long for a comment, but not a complete answer...

system = {Subscript[\[Pi], 11] Subscript[z, 1] + 
Subscript[\[Pi], 12] Subscript[z, 2] + 
Subscript[\[Pi], 13] Subscript[z, 3] + 
Subscript[\[Pi], 14] Subscript[z, 4] + Subscript[\[Pi], 10] X + 
Subscript[\[Nu], 1] == Subscript[y, 1], 
Subscript[\[Pi], 21] Subscript[z, 1] + 
Subscript[\[Pi], 22] Subscript[z, 2] + 
Subscript[\[Pi], 23] Subscript[z, 3] + 
Subscript[\[Pi], 24] Subscript[z, 4] + Subscript[\[Pi], 20] X + 
Subscript[\[Nu], 2] == Subscript[y, 2], 
Subscript[\[Pi], 31] Subscript[z, 1] + 
Subscript[\[Pi], 32] Subscript[z, 2] + 
Subscript[\[Pi], 33] Subscript[z, 3] + 
Subscript[\[Pi], 34] Subscript[z, 4] + Subscript[\[Pi], 30] X + 
Subscript[\[Nu], 3] == Subscript[y, 3], 
Subscript[\[Pi], 41] Subscript[z, 1] + 
Subscript[\[Pi], 42] Subscript[z, 2] + 
Subscript[\[Pi], 43] Subscript[z, 3] + 
Subscript[\[Pi], 44] Subscript[z, 4] + Subscript[\[Pi], 40] X + 
Subscript[\[Nu], 4] == Subscript[y, 4]}

Next we Eliminate from this e.g. Subscript[y, 1] and solve for all Subscript[z, i] except Subscript[z, 1]:

Solve[Eliminate[system, Subscript[y, 1]], {Subscript[z, 2], Subscript[z, 3], 
Subscript[z, 4]}]

Now we can substitute this in first equation of system (equation on Subscript[y, 1]):

system[[1, 1]] /. 
Solve[Eliminate[system, Subscript[y, 1]], {Subscript[z, 2], 
Subscript[z, 3], Subscript[z, 4]}][[1]]

and collect terms:

coly1=Collect[%, {X, Subscript[y, 2], Subscript[y, 3], Subscript[y, 4], 
Subscript[z, 1]}, FullSimplify]

The result is complicated enough, but in the desired form. You can use Coefficient[coly1,X] to get your A etc. The same technique can be use for Subscript[y, 2], Subscript[y, 3], Subscript[y, 4].

$\endgroup$
2
  • $\begingroup$ thanks a lot. You made me save so much time! $\endgroup$ Oct 1, 2019 at 8:47
  • $\begingroup$ Glad to help you and thanks for acceptance the answer! $\endgroup$
    – Alx
    Oct 1, 2019 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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