Ask Your Question

nholtz's profile - activity

2023-05-19 20:40:38 +0200 received badge  Famous Question (source)
2018-09-16 17:34:33 +0200 received badge  Notable Question (source)
2015-03-09 17:34:00 +0200 received badge  Popular Question (source)
2012-11-26 15:52:21 +0200 answered a question Substituting numerical values without partial evaluation.

Actually, I found sympy to do almost exactly what I want, with:

   sympy.latex( e, mul_symbol='times', symbol_names=d )
   

where d is a dictionary of symbols -> numerical strings mappings. sympy might turn out to be just enough for my purposes, though I still would like to know if this is possible with a reasonable (i.e. small ;-)) amount of work in sage, just in case.

Basically I have a small number (3-6) of mostly linear eqns to solve where the variables to solve for are not known ahead of time. I'm generating worked out examples of equilibrium eqns for students.

2012-11-26 14:31:56 +0200 asked a question Substituting numerical values without partial evaluation.

Given an expression of the form:

   var('x y')
   e = x*y + 1
   

I would like to be able to substitute numerical values into an expression without it being simplified. I'm not too concerned about seeing it in the notebook, but I would like the latex display to be affected. In other words, I would like the equivalent of:

   latex(e(x=5,y=6))   =>   "5 \times 6 + 1"
   

Any hope of doing this? I could substitute into the text of the latex, but then I would get "5 6 + 1".