# Revision history [back]

### Newbie question: introducing symbols (variables) inside vectors and matrices

Hi,

I would like to have linear algebra operations to be evaluated with symbols instead of numerically. For example, having the following matrix:

A = matrix(QQ,[
[2,1,2,-6],
[-1,2,1,7],
[3,-1,-3,-1],
[1,5,6,0],
[2,2,1,1]
])


I would like to multiply for a vector with symbolic variables as follows:

t = 'real'
var('x1')
assume(x1,t)
var('x2')
assume(x2,t)
var('x3')
assume(x3,t)
var('x4')
assume(x4,t)
xx = vector(QQ,[x1,x2,x3,x4])
A * xx.transpose()


Unfortunately building the xx vector is unsuccessful, producing this vector:

TypeError: Cannot evaluate symbolic expression to a numeric value.


This does not work, so how can I use symbols in sage's linear algebra framework?

thank you very much, -Francesco

### Newbie question: introducing symbols (variables) inside vectors and matrices

Hi,

I would like to have linear algebra operations to be evaluated with symbols instead of numerically. For example, having the following matrix:

A = matrix(QQ,[
[2,1,2,-6],
[-1,2,1,7],
[3,-1,-3,-1],
[1,5,6,0],
[2,2,1,1]
])


I would like to multiply for a vector with symbolic variables as follows:

t = 'real'
var('x1')
assume(x1,t)
var('x2')
assume(x2,t)
var('x3')
assume(x3,t)
var('x4')
assume(x4,t)
xx = vector(QQ,[x1,x2,x3,x4])
A * xx.transpose()


Unfortunately building the xx vector is unsuccessful, producing this vector:error message:

TypeError: Cannot evaluate symbolic expression to a numeric value.


This does not work, so how can I use symbols in sage's linear algebra framework?

thank you very much, -Francesco

 3 retagged FrédéricC 5114 ●3 ●42 ●111

### Newbie question: introducing symbols (variables) inside vectors and matrices

Hi,

I would like to have linear algebra operations to be evaluated with symbols instead of numerically. For example, having the following matrix:

A = matrix(QQ,[
[2,1,2,-6],
[-1,2,1,7],
[3,-1,-3,-1],
[1,5,6,0],
[2,2,1,1]
])


I would like to multiply for a vector with symbolic variables as follows:

t = 'real'
var('x1')
assume(x1,t)
var('x2')
assume(x2,t)
var('x3')
assume(x3,t)
var('x4')
assume(x4,t)
xx = vector(QQ,[x1,x2,x3,x4])
A * xx.transpose()


Unfortunately building the xx vector is unsuccessful, producing this error message:

TypeError: Cannot evaluate symbolic expression to a numeric value.


This does not work, so how can I use symbols in sage's linear algebra framework?

thank you very much, -Francesco