Finding all roots of nonlinear function

조회 수: 39 (최근 30일)
Hmm!
Hmm! 2021년 3월 4일
댓글: Bjorn Gustavsson 2021년 3월 8일
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