I have this function.
SetAttributes[zf,HoldAllComplete];
zf[x_] :=If[Denominator[Unevaluated[x]]==0=
If[Denominator[Unevaluated[x]] == 0,
Numerator[Unevaluated[x]],
Numerator[Unevaluated[x]]];
It is supposed to just return the numerator anytime the denominator is 0.
In[1]:= zf[1/0]
Out[1]= 1
In[2]:=
1
Cos[-(3*Pi)/2]
Out[2]= 0
In[3]:=
0
zf[1/Cos[-(3*Pi)/2]]
Out[3]= ComplexInfinity
ComplexInfinity
It works fine when the denominator is literally 0, but it fails when there are functions/variables, such as when Cos[x]==0Cos[x] == 0
.
How would I go about evaluating the denominator separately, then if that equals 0zero, drop the denominator, and evaluate the numerator only without evaluating the entire fraction?
Basically my question is how do I make zf[1/Cos[-(3*Pi)/2]]
output 1
?