Finding all roots of nonlinear function

39 次查看(过去 30 天)
How would I find all the roots of the function
I know all sine functions have multiple roots and so this function may also have multiple roots but how would I find all these roots? Using matlab fzero which uses the brackect criteria for the existence of solution only gives one root to the function.
So plotting the function might help but I think I have problems understanding what the graph is telling me. Can someone help to interpret the graph for me? How would I know the root(s) of the function? Atleast, I know one root is 0.25957 using fzero.
fplot( @(x) sin(10*x)-2*x, [-.5,.5])
%ploting the function with interval [-5, 5]
grid on

回答(1 个)

Bjorn Gustavsson
Bjorn Gustavsson 2021-3-4
Read the help for the fzero function and you will see that it returns a solution, not all. It accepts a range for x0 that restricts the region where it searches for the solution. Use that to work in a systematic way.
  8 个评论
Hmm!
Hmm! 2021-3-5
Of course different intervals will give different solution estimates right? So in conclusion can we conclude the function has many roots and these roots depends on the intervals???
Bjorn Gustavsson
Bjorn Gustavsson 2021-3-8
Yes, possibly. If you specify a region with 2 components then the function needs to have different signs at the 2 end-points, if you select regions snuggly around a zero you will get that root. If you have an odd number of solutions in that region you will get one of them, I don't know which that will be in a general case.
You an also draw three additional lines in your plot:
fplot( @(x) sin(10*x)-2*x, [-2,2])
%ploting the function with interval [-5, 5]
grid on
hold on
fplot(@(x) -2*x+1,[-2 2])
fplot(@(x) -2*x-1,[-2 2])
fplot(@(x) sin(10*x+sqrt(2))-2*x,[-2 2])
From those three curves you can also conclude that this function only has those 3 zeros.
@John D'Errico: If you help me then maybe we can make it a technical term! (From my name and lack of spelling skills you must have guessed that "the language of the Bard" is not my native tounge - but I derive great joy from cobbling up terms that you natives find quirky...)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by