0

Sir,

Is it possible to use the value of a variable to make a subsitution ?

Example:

x = symbols("x")

c = IndexedBase("c")

eq1 = c[0] + c[1]*x+c[2]*x**2

x1 = 2

eq1.subs(x,x1)

Nothing change. How can we use the value of x1, here 2 ?

Sincerely.

  • `eq1 = eq1.subs(x,x1)` – JohanC Jan 12 '22 at 13:04
  • Thank you. It is the affectation that makes the transformation. It is not obvious, but now I jnow it. – Pascal KREZEL Jan 12 '22 at 14:27
  • See wikipedia: ["immutable objects"](https://en.wikipedia.org/wiki/Immutable_object). Sympy gotchas: [Sympy expressions are immutable](https://docs.sympy.org/latest/gotchas.html#immutability-of-expressions) – JohanC Jan 12 '22 at 15:37

0 Answers0