Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Substitution of free variable

I have sagecells on a page that are used to solve some equations. In a further cell, I want to substitute a given value in place of a free variable. Sage's free variables have names such as r1, r2 etc.

Is there a way (some kind of wildcard) to substitute a value for a free variable without knowing its name? I'd like this because depending on the order of execution a user would press the cells, the names would change.

It would look like this

CELL1

sol1=solve([x+y==1],x,y)

CELL2

sol2=solve([x-y==3],x,y)

and then further down I would like a new cell that would substitute the free variable in sol1 to a given value, say 0.

However if I use something along the line of

sol1part=sol1.substitute(r1=0) and the user executed for some reason cell2 before cell1, it will not work.

Substitution of free variable

I have sagecells on a page that are used to solve some equations. equations. In a further cell, I want to substitute a given value in place of a a free variable. Sage's free variables have names such as r1, r2 r1, r2, etc.

Is there a way (some kind of wildcard) to substitute a value for for a free variable without knowing its name? I'd like this because because depending on the order of execution a user would press the cells, cells, the names would change.

It would look like this

CELL1

sol1=solve([x+y==1],x,y)

sol1 = solve([x + y == 1], x, y)

CELL2

sol2=solve([x-y==3],x,y)

sol2 = solve([x - y == 3], x, y)

and then further down I would like a new cell that would substitute substitute the free variable in sol1 sol1 to a given value, say 0.0.

However if I use something along the line of

sol1part=sol1.substitute(r1=0)

sol1part = sol1.substitute(r1=0)

and the user executed for some reason cell2 before cell1, it will not work.