4works
(Oskar S)
September 26, 2016, 12:27pm
1
Good day, everyone
I have a problem in Mathematica 9.0
For example, I determine function:
f[x_] = ArcTan[1/Sin[x]]
but result of f[0] is:
Indeterminate
because result of 1/Sin[0] is ComplexInfinity.
How I can change it(ComplexInfinity) to Infinity.
One way could be with Piecewise:
f[x_] = Piecewise[{{Infinity, Sin[x] == 0}, {ArcTan[1/Sin[x]], True}}]
It depends on what you are going to do with this function. Numerics? Symbolics? Graphics?
4works
(Oskar S)
September 26, 2016, 1:04pm
3
Thank you very much.
My problem is that i get function f[x] after solving some equations (Solve function).
And this function generally f[x]=ArcTan[g[x]/Sin[x]] .
Then i need to get some plots and animations of function contain function f[x] and derivatives of f[x].
And i have problems in points Pi*k because of Indeterminate
Mathematica version 11 is supposed to take care of singularities when plotting. For previous versions you can use Exclusions:
Plot[ArcTan[1/Sin[x]], {x, -3 Pi, 3 Pi}, Exclusions -> {Sin[x] == 0}]
sghuisman
(Sander Huisman)
September 26, 2016, 3:54pm
5
I would recommend to add a special case:
f[x_] := ArcTan[1/Sin[x]]
f[0] := Limit[ArcTan[1/Sin[x]], x -> 0, Direction -> -1]
so it handles the singularity as it should (you can change the direction to 1 to approach the singularity from the other side.
4works
(Oskar S)
October 4, 2016, 9:05am
6
And what about functions where i don’t know in what point i have 1/0. Is it possible to change the Wolfram Mathematica rule. I mean, is it possible to force Wolfram Mathematica to count 1/0=Infinity not 1/0=ComplexInfinity?
sghuisman
(Sander Huisman)
October 6, 2016, 4:11pm
7
you can use replace after your computation:
expression /. ComplexInfinity[___] :> Infinity
4works
(Oskar S)
October 7, 2016, 2:30pm
8
It’s pitty but it does not work, for example:
Tan[1/0] /. ComplexInfinity[___] :> Infinity
sghuisman
(Sander Huisman)
October 7, 2016, 2:34pm
9
Sorry about that:
Tan[(1/0) /. ComplexInfinity :> Infinity]
now it should work.
But this does not make much sense; it’s asking basically to compute Exp[1/0], which, to my mind, makes little sense…
For the ArcTan case use the two-argument version to avoid division by zero:
ArcTan[0, 1]