Here are two definitions.
In[1]:=
In[2]:=
The definition for p1 applies only when x is manifestly a number.
In[3]:=
Out[3]=
The definition for p2 is more liberal.
In[4]:=
Out[4]=
In[5]:=