# Creating a table from a matrix and two vectors

Suppose I have the following matrix (8x4) matrix

$\begin{bmatrix} 1 & 2 & 3 & 4 & 1 & 0 & 0 & 20 \\ 1 & 4 & 5 & 4 & 0 & 1 & 0 & 10 \\ 2 & 2 & 3 & 4 & 1 & 0 & 1 & 30 \\ 1 & -1 & 2 & -1 & 0 & 0 & 0 & 0 \end{bmatrix}$

I want to create a table in adding the following vector above

$\begin{bmatrix} &x_1 & x_2 & x_3 & x_4 & \epsilon_1 & \epsilon_2 & \epsilon_3 & b \end{bmatrix}$

which will be invariant

and the following column vector on its right

$\begin{bmatrix} \epsilon_1 \\ \epsilon_2 \\ \epsilon_3 \\ b \end{bmatrix}$

Two answers to my previous question "Concatenation of symbolic vectors" help me construct the line vector which is a concatenation of two vectors. But I cannot use the answer in the table() mechanism simply because it doesn't work as expected that is

table(name_of_the_matrix, header_row=name_of_the_line_vector)


Is there a way to obtain what I expect? I observed that html.table() doesn't work.

edit retag close merge delete

I edited the question to fix the formatting and removed your technical post-scriptum:

PS. I do not understand why the formatting doesn't work for the matrix.

To answer that: it is a technical issue with escape sequences and backslash characters.

Workaround: in LaTeX code between $...$, type \\ for \ and so \\\\ for\.

This probably has to do with the MathJax configuration of the Askbot engine powering Ask Sage.

Starting input to get anyone started on an answer:

x = [SR.var(f'x_{i}', latex_name=f'x_{i}') for i in range(5)]
y = [SR.var(f'y_{i}', latex_name=f'\\epsilon_{i}') for i in range(4)]
b = SR.var('b')

a = matrix([[1,  2, 3,  4, 1, 0, 0, 20],
[1,  4, 5,  4, 0, 1, 0, 10],
[2,  2, 3,  4, 1, 0, 1, 30],
[1, -1, 2, -1, 0, 0, 0,  0]])

u = vector(SR, x[1:] + y[1:] + [b])
v = vector(SR, y[1:] + [b])


Now all there is to do is to arrange a, u, v` as in the question.

For reference it seems such tables are often used when applying the "simplex algorithm" (or "simplex method") and in that context they are sometimes called simplex tables.