Using solve function to find the roots

조회 수: 12 (최근 30일)
fert
fert 2016년 1월 18일
댓글: fert 2016년 1월 18일
syms x
y = 2*x*exp(-x)-sin(x)==0;
d=solve(y,x)
It gives the "zero" as the only value that makes the y zero. But the roots should be 0.8030 and 2.7923 (I have looked from ezplot). Why can't I find the roots with the solve function?

채택된 답변

Walter Roberson
Walter Roberson 2016년 1월 18일
solve() can only find all solutions for polynomials. For non-linear functions, it will give a warning and find one numeric solution.
Since you need to switch to numeric solutions anyhow, use vpasolve() with initial guesses to select the range to find the solution over. vpasolve() will only find one solution at a time, but it will allow you to select the range to look in.
  댓글 수: 3
Walter Roberson
Walter Roberson 2016년 1월 18일
Looks plausible, except that I would use
y = (log(1+x)+x.^2/2)./(1+x).^2
fert
fert 2016년 1월 18일
Thank you very much indeed.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by