MATLAB Finding Roots of x*tan(x)-A=0 in MATLAB

  • Thread starter Thread starter Curl
  • Start date Start date
  • Tags Tags
    Matlab Roots
Click For Summary
To find the roots of the function x*tan(x) - A = 0 in MATLAB, users can utilize numerical methods like fzero or fsolve, which require initial guesses. However, identifying multiple roots can be challenging without prior knowledge of their locations. The discussion highlights that some functions, including trigonometric ones, can have infinite roots, complicating the search. A suggested approach involves scanning the function over a wide range and noting intervals where the function changes sign, indicating potential roots. This method allows for subsequent application of fzero on those intervals. Additionally, there is interest in existing algorithms that could automate the guessing process for root-finding, although no specific algorithms were confirmed to exist in the discussion.
Curl
Messages
756
Reaction score
0
I want to find roots of a function using MATLAB. The function is x*tan(x)-A=0. "A" is an arbitrary constant.
If I use fzero or fsolve, it will find the root closest to the guess.

Is there any way of getting, say, the first 5 roots of this function? I don't know where the roots are at, so I can't do a loop with multiple guesses since I have no idea what to guess.

There's got to be a way, can anyone help?
 
Physics news on Phys.org
Curl said:
Is there any way of getting, say, the first 5 roots of this function?

What do you mean by this? If you're talking about the 5 closest roots to x = 0, this sometimes does not exist. Take for example, f(x) = sin(1/x)

Also note that some functions have an infinite number of roots. e.g. f(x) = sin(x), f(x) = cos(x) ...

Curl said:
I don't know where the roots are at, so I can't do a loop with multiple guesses since I have no idea what to guess.

Unfortunately, that's the crux of root-finding problems. You need to find the roots and unless you know more information depending on the type of problem you're given, the best you can do is give an initial guess. Then you leave it to the numerical method to find the root. My best advice for you is to do multiple initial guesses insides of a big range ( [-1000000,1000000]) and call froot for each value you choose.

edit: fixed sin(1/x)
 
Last edited:
since xtan(x) is symmetric, yes I meant first zeroes from x=0. I just wanted to know if someone wrote an algorithm that makes guesses on its own.

You can go through the function in small intervals and check when the function changes sign. If it does, make a mark. Then go back and use fzero on each of those... I guess I could write one but I don't want to do it if it already exists.
 

Similar threads

Replies
6
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
5K