I have this function.
SetAttributes[zf,HoldAllComplete];
zf[x_] :=
If[Denominator[Unevaluated[x]] == 0,
Numerator[Unevaluated[x]],
Numerator[Unevaluated[x]]];
It is supposed to just return the numerator anytime the denominator is 0.
zf[1/0]
1
Cos[-(3*Pi)/2]
0
zf[1/Cos[-(3*Pi)/2]]
ComplexInfinity
It works fine when the denominator is literally 0, but it fails when there are functions/variables, such as when Cos[x] == 0
.
How would I go about evaluating the denominator separately, then if that equals zero, 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
?
1/Cos[-(3*Pi)/2 + z]
or of1/(Cos[-(3*Pi)/2] + z)
for $z\to 0$. But more information is needed to decide what you really need. $\endgroup$