I’ve tried Normal[CoefficientArrays to create the matrix from the coefficients, but then i’m completely lost . Any help would be greatly appreciated.
Are you trying to do something like this?
In[1]:= (* some equations *)
eqs = {a x + b y == k1, c x + d y == k2};
In[2]:= (* this contains same information as augmented array *)
s = Normal[CoefficientArrays[eqs, {x, y}]]
Out[2]= {{-k1, -k2}, {{a, b}, {c, d}}}
In[3]:= (* LinearSolve can use it *)
LinearSolve[s[[2]], -s[[1]]]
Out[3]= {(d k1 - b k2)/(-b c + a d), (c k1 - a k2)/(b c - a d)}
In[4]:= (* Solve gives the same answer *)
Solve[eqs, {x, y}]
Out[4]= {{x -> -((d k1 - b k2)/(b c - a d)),
y -> -((-c k1 + a k2)/(b c - a d))}}
SoQ
(-19 u-19 w+6 x-18 y+10 z==-2,
-15 u-17 w-16 x-11 y+11 z==-15,
14 u-8 w+13 x-11 y==16,
13 u-17 w-10 x+18 y+12 z==17,
4 u+9 w+20 x-16 y-9 z==13)
i’m simply trying to construct the augmented matrix. Looking at the instructions, it’s actually asking to use the system assignment.
Thank you for your help.
I don’t follow you with regard to “system assignment.”
There may be a more abbreviated way to append a column, but the code below constructs the traditional augmented matrix form the coefficients.
In[5]:= (* an augmented matrix *)
am = Transpose[Append[Transpose[s[[2]]], -s[[1]]]]
Out[5]= {{a, b, k1}, {c, d, k2}}
Can you please explain the syntax? specifically the s[] and -s[]
Thank you
The [[ ]] is a form of Part. (look up Part in the help system.)
In 5 above, we transpose the 2nd part of am, which is the coefficient matrix, so columns become rows. Then append a row which is the constants, then transpose it all back so columns are columns again.
Using your equations:
In[14]:= eqs = {-19 u - 19 w + 6 x - 18 y + 10 z == -2, -15 u -
17 w - 16 x - 11 y + 11 z == -15, 14 u - 8 w + 13 x - 11 y == 16,
13 u - 17 w - 10 x + 18 y + 12 z == 17,
4 u + 9 w + 20 x - 16 y - 9 z == 13};
In[15]:= (* this contains same information as augmented array *)
s = Normal[CoefficientArrays[eqs, {u, w, x, y, z}]];
In[16]:= (* an augmented matrix *)
am = Transpose[Append[Transpose[s[[2]]], -s[[1]]]]
Out[16]= {{-19, -19, 6, -18, 10, -2}, {-15, -17, -16, -11,
11, -15}, {14, -8, 13, -11, 0, 16}, {13, -17, -10, 18, 12, 17}, {4,
9, 20, -16, -9, 13}}
Thank you, very helpful.