Ask Your Question

Keeping zeros after matrix multiplication

asked 2019-12-01 10:46:45 -0600

dsejas gravatar image

Hello, Sage Community!

Suppose I do the following:

var('x y z')
u = vector([0, 1, 1])
v = vector([x, y, z])
u * v

The result is obviously y+z. I would like to keep the zeros after the multiplication, in order to have 0x+y+z as my result. Is it possible?

Thanks in advance for your answers!

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2019-12-03 23:59:20 -0600

slelievre gravatar image

One way to obtain the complete expression is as follows:

sage: print(' + '.join('({})*({})'.format(a, b) for a, b in zip(u, v)))
(0)*(x) + (1)*(y) + (1)*(z)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-12-01 10:46:45 -0600

Seen: 40 times

Last updated: Dec 03