Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello, @Cyrille! I don't know if this is what you want, but you can create variables with the var command. These variable will be symbolic variables, so they cannot carry any value. Let me explain:

Suppose you want to create 8 of these variables. You have to do

x = var('x', n=8, latex_name='x')

Then you can write show(x), which will produce

$(x_0,x_1,x_2,x_3,x_4,x_5,x_6,x_7)$

Note that the latex_name argument doesn't make any difference in this particular case. However, you can use it at your own discretion to create more complicated LaTeX representations. For example,

x = var("x", n=8, latex_name='\overline{x}')
show(x)

will produce

$(\overline{x}_0,\overline{x}_1,\overline{x}_2,\overline{x}_3,\overline{x}_4,\overline{x}_5,\overline{x}_6,\overline{x}_7)$

The disadvantage of this method is that you cannot assign values to the variables x[0], x[1], etc. In case you want to do that, you have to first convert x to a list:

x = list(var("x", n=8, latex_name='\overline{x}'))
x[0]=123
show(x)

This code has changed the value of $x_0$ into $1$, but you have missed the LaTeX representation. The output here is:

$(123,\overline{x}_1,\overline{x}_2,\overline{x}_3,\overline{x}_4,\overline{x}_5,\overline{x}_6,\overline{x}_7)$