How to make mathematica give 1/0 as infinity
Use the two-arg version of ArcTan
instead:
ArcTan[0, 4]
π/2
You can convert expressions of ComplexInfinity
to Infinity
by using the ReplaceAll
operator /.
.
ArcTan[4/0 /. ComplexInfinity -> Infinity]
which gives Pi/2
as output.
On the off chance that what is desired in a computational environment in which n/0
evaluates to (positive) Infinity
and t = ArcTan[..]
falls in the range -Pi/2 <= t <= Pi/2
. One should use caution when overwriting built-in functions. I doubt this will cause problems in computations in which n/0
should always mean positive Infinity
and not ComplexInfinity
.
ClearAll[evaluateWithRealPower];
SetAttributes[evaluateWithRealPower, HoldFirst];
evaluateWithRealPower[code_] :=
Internal`InheritedBlock[{Power},
Unprotect[Power];
Power[0, p_?Negative] := Infinity;
Power[0., p_?Negative] := Infinity; (* optional *)
Protect[Power];
code];
evaluateWithRealPower[ArcTan[4/0]]
(* \[Pi]/2 *)