Peque Peque - 1 year ago 257
Python Question

Plotting with SymPy

With SymPy, I can plot a function with:

f, a = symbols('f a')
f = a + 10

However, if I define the function as:

f, a, b = symbols('f a b')
f = a + b
b = 10

Then I get an error stating:

ValueError: The same variable should be used in all univariate
expressions being plotted.

How can I plot
if I define
f = a + b
, considering that
is assigned a constant value before plotting the function?

Answer Source

You must substitute b into f:

plot(f.subs('b', b))