Finding all roots of nonlinear function

39 Ansichten (letzte 30 Tage)
Hmm!
Hmm! am 4 Mär. 2021
Kommentiert: Bjorn Gustavsson am 8 Mär. 2021
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

Antworten (1)

Bjorn Gustavsson
Bjorn Gustavsson am 4 Mär. 2021
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 Kommentare
Hmm!
Hmm! am 5 Mär. 2021
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 am 8 Mär. 2021
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...)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by