Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use subs on a matrix to substitute variables by values:

sage: sample = {}
sage: sample['M1'] = matrix(QQ, 2, [7, 5, 2, 4])
sage: R.<t> = QQ[]
sage: sample['M2'] = matrix(R, 2, [t^2, 2, 3, 1 - t])
sage: sample['M2'].subs({t: 10})
[100   2]
[  3  -9]
sage: sample['M2'].subs({t: 20})
[400   2]
[  3 -19]