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

  • Context: MATLAB 
  • Thread starter Thread starter Curl
  • Start date Start date
  • Tags Tags
    Matlab Roots
Click For Summary
SUMMARY

The discussion focuses on finding the roots of the equation x*tan(x) - A = 0 using MATLAB. Users suggest utilizing MATLAB functions such as fzero and fsolve for root-finding, but emphasize the necessity of initial guesses. To locate multiple roots, participants recommend scanning the function over a large interval, such as [-1000000, 1000000], and identifying sign changes to determine potential root locations. The conversation highlights the challenge of root-finding when the exact locations of roots are unknown.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Familiarity with numerical methods for root-finding, specifically fzero and fsolve
  • Knowledge of function behavior and sign changes
  • Basic concepts of trigonometric functions and their properties
NEXT STEPS
  • Research how to implement a root-finding algorithm using MATLAB's fzero function
  • Explore MATLAB's capabilities for plotting functions to visualize roots
  • Learn about interval bisection methods for root-finding
  • Investigate existing MATLAB toolboxes or scripts for automated root-finding
USEFUL FOR

Mathematicians, engineers, and MATLAB users seeking to solve complex equations involving trigonometric functions and optimize their root-finding processes.

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 16 ·
Replies
16
Views
5K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K