4

I want to have a series of piecewise functions with each being a shifted copy of the base function, but I do not know how to do that in sympy. Here is an example:

from sympy import Symbol
from sympy import Piecewise
from sympy import And

x = Symbol('x')
s = Symbol('s')
f0 = Piecewise((1, And(x > 0, x < 1)), (0, True))
fs = f0(x - s)

However, the last line gives me an error:

TypeError: 'Piecewise' object is not callable

How do I make a Piecewise callable and specify, that fs is a function of x and s?

Student4K
  • 916
  • 2
  • 9
  • 20

0 Answers0