# How to create a symbolic arbitrary dimensional zero vector?

one way:

sage: symbolic_expression(list(zero_vector(k)))
# k, dim. of vector, k is some fixed integer, e.g. k = 10,
# many thanks to @tmonteil 

but it is too long!!

edit retag close merge delete

Can you make your wish more explicit ? Is k a fixed number ? Wich order of magnitude ?

the length of the string "symbolic_expression(list(zero_vector(k)))", can we use some command like "zero_list(k)"?

Sort by » oldest newest most voted

You can make your expression shorter by typing:

sage: w = zero_vector(SR, 10) ; w
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)


You can check that it is the same object:

sage: v = symbolic_expression(list(zero_vector(10)))
sage: v
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
sage: v == w
True

more

Thanks! Yes, that is what I want! SR = Symbolic Ring, super.

Can we create a list whose entries are all 1, using a similar method?

For the follow-up question posted as a comment to @tmonteil's answer:

vector(SR, *10)


is worth mentioning as well. Here, *10 is just the Python way of constructing a list with 10 repeats of 1.

more

A version with 14 characters

sage: (SR^10).zero()
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)


that could even be shorten to 9

sage: (SR^10)()
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

more

This is an answer to the follow-up question posted as a comment to @tmonteil's answer.

There is no function ones_vector but we can define a vector of ones as the first row of a matrix of ones:

sage: v = matrix.ones(SR, 1, 10)
sage: v
(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
sage: v.parent()
Vector space of dimension 10 over Symbolic Ring


It lives in the same space as the zero vector:

sage: u = zero_vector(SR, 10)
sage: u
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
sage: u.parent()
Vector space of dimension 10 over Symbolic Ring

more