With the plain evaluation:
In [19]: f=lambda x:np.sqrt(1-x**2)
In [20]: f(np.linspace(0,2,10))
C:\Users\paul\AppData\Local\Temp\ipykernel_1604\1368662409.py:1: RuntimeWarning: invalid value encountered in sqrt
f=lambda x:np.sqrt(1-x**2)
Out[20]:
array([1. , 0.97499604, 0.89580642, 0.74535599, 0.45812285,
nan, nan, nan, nan, nan])
This produces nan and a warning for x>1. np.where as suggested by other answers can change the nan to 0, but you'll still get the warning. The warning can be silenced. But an alternative is to use the where parameter of np.sqrt (and other ufunc):
In [21]: f=lambda x:np.sqrt(1-x**2, where=x<=1, out=np.zeros_like(x))
In [22]: f(np.linspace(0,2,10))
Out[22]:
array([1. , 0.97499604, 0.89580642, 0.74535599, 0.45812285,
0. , 0. , 0. , 0. , 0. ])
np.where. See examples