0

I am trying to create a piecewise function using numpy, and I followed the examples in its documentation, however, only the outer bounds return the correct values.

The function I have for the 44 < x < 58 returns 0, while it should return the value calculated in the cell below. I'm sure this is a simple syntax error, but I am having trouble seeing it.

x = 50
numpy.piecewise(x, [(44 < x) & (x < 58), x <= 44, x >= 58], [(0.4876 +0.1201*math.cos(x*1.017) + 0.5111*math.sin(x*1.1017)), 0, 1])

Edit: I updated the syntax of the boolean and am still getting the same error.

jared
  • 4,165
  • 1
  • 8
  • 31

0 Answers0