5

I am new to Mathematica and this is probably a simple question, but I can't figure it out at the moment...

f[x_]:=1/(x-3)

Clearly the vertical asymptote is at x->3, as1/0 is undefined.

I would like some kind of function that's output is simply:

3

I need to know where the function is undefined. Some functions give me:

{{x->3}} and things like that, but I can't work with that.

Any help would be great.

Yves Klett
  • 15,383
  • 5
  • 57
  • 124
Travis
  • 51
  • 1

2 Answers2

7

FunctionDomain

In versions 10+, you can use the built-in FunctionDomain:

f[x_]:=1/(x-3);
FunctionDomain[f[x], x]
(* x<3||x>3 *)
Not[%]//FullSimplify
(* x == 3 *)

or, more directly,

Not[FunctionDomain[f[x], x]]//FullSimplify
(* x == 3 *)

To get 3 use

Not[FunctionDomain[f[x], x]]//FullSimplify //Last
(* 3 *)

Further examples:

Not[FunctionDomain[Tan[x], x]]//FullSimplify
(* 1/2 + x/π ∈ Integers *)

Not[FunctionDomain[(x + y)/(x^2 - y^2), {x, y}]]//FullSimplify (* x^2==y^2 *)

Thanks: @BobHanlon for the comment that Reals is the default domain, and hence, FunctionDomain[f[x], x, Reals is equivalent to FunctionDomain[f[x], x].

For version 9,

Not[Reduce[Abs@f[x] < Infinity, x, Reals]] // FullSimplify // Last
(* 3 *)
kglr
  • 394,356
  • 18
  • 477
  • 896
1

I don't have V10 yet, so I am just going to extend @Sektor.

Let say you have a function with some divergences. I choose here a simple example like

f[x_] = Product[1/(x - a[i]), {i, 3}]

You can get the poles by

Solve[1/f[x] == 0, x]

It works if you have two variables as well like

f[x_, y_] = Product[1/(x + y - a[i]), {i, 3}]
Solve[1/f[x, y] == 0, x]

Now the final answer may depend on how complex your initial function is. You may get an conditional expression or in worst case you may have to go for a numerical solution.

Sumit
  • 15,912
  • 2
  • 31
  • 73