Creating a table from a matrix and two vectors

asked 4 years ago

Cyrille gravatar image

updated 4 years ago

slelievre gravatar image

Suppose I have the following matrix (8x4) matrix

[12341002014540101022341013011210000]

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

[x1x2x3x4ϵ1ϵ2ϵ3b]

which will be invariant

and the following column vector on its right

[ϵ1ϵ2ϵ3b]

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.

Preview: (hide)

Comments

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.

slelievre gravatar imageslelievre ( 4 years ago )

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.

slelievre gravatar imageslelievre ( 4 years ago )

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.

slelievre gravatar imageslelievre ( 4 years ago )