fsolve issue with high gradient function
Show older comments
Hello,
I am in front of an issue with fsolve, I have a function which varies very very quickly with at least 10 solutions where f(x) = 0
when I plot with log(1+f(x)) I can see where the solutions are :

for example for the sixth one it is 7.2* omg = 399 hz

I verified by plotting the function on the intertval 7.1 7.3 * omg and it cross 0 once (as you can see it is power 20)

So to find the root I tried to do
fre6 = @(x) det(f(x,xi,A,CAP,ns,ork))/10^21;
w6 = fsolve(fre1,7*omg)
fsolve return no solution even if :
- I change the initial guess
- I change 10^21 to decrease the gradient

any help will be amazing
I already read some topic such as
but it does not work when I change the initial guess
Answers (1)
You should not be using fsolve for a 1D root finding problem, and particularly not when the function is highly non-differentiable. Just do a sweep,
x= linspace(0,9,100);
fvals=arrayfun(fre,x);
loc=find(abs(fvals)<=tolerance);
xroots=x(loc);
Now, if you wish to refine the root calculations, you can use xroots as starting points in calls to fzero.
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!