SymPy - Arbitrary number of Symbols
numbered_symbols("t")
will return a generator that generates t0
, t1
, t2
, etc. You can use the start
parameter to choose a different starting value. And if you want to use dummy variables, use numbered_symbols("t", cls=Dummy)
.
The symbols
function can be used to easily generate lists of symbols
In [1]: symbols('a0:3')
Out[1]: (a₀, a₁, a₂)
In [2]: numEquations = 15
In [3]: symbols('a0:%d'%numEquations)
Out[3]: (a₀, a₁, a₂, a₃, a₄, a₅, a₆, a₇, a₈, a₉, a₁₀, a₁₁, a₁₂, a₁₃, a₁₄)