title: How can write and indicator function in Python?
body: <p>I want to make an indicator function for pde in Python u(x) = 2<em>x if 0&lt;x&lt;1/2 and 2-2</em>x if 1/2&lt;x&lt;1
  but when i do it an error occurs.</p>
  <p>I have chosen the np.where which is a if else function.</p>
  <p>Can someone help me?</p>
  <pre><code>import numpy as np
  x = np.linspace(0,1)
  x
  np.where(x&gt;0 &amp; x&lt;1/2,2*x,2-2*x)
  </code></pre>