Finding zero crossing of equation

조회 수: 11 (최근 30일)
Gökhan Kumtas
Gökhan Kumtas 2020년 5월 26일
편집: John D'Errico 2020년 5월 27일
syms x
assume(x,'real')
f(x) = -x^3+x^2-x+5;
df = diff(f(x));
symEq = (df==0);
sols = solve(symEq);
zero_crossing_complete = double(sols);
zero_crossing_real =real(double(sols)) ;
when i run the scipt code , the answer of the 'sols' is empty sym: 0-by-1.
but when I run symEq, the answer is - 3*x^2 + 2*x - 1 == 0.I can not find the zero crossing of the equation due to this missing.
  댓글 수: 1
David Goodmanson
David Goodmanson 2020년 5월 26일
Hello GK,
It appears that you are trying to find a zero crossing for g(x)= -3*x^2 + 2*x - 1, not for the original cubic equation f(x). But for real x, g(x) does not have a zero crossing.

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

답변 (1개)

John D'Errico
John D'Errico 2020년 5월 27일
편집: John D'Errico 2020년 5월 27일
Are you trying to solve for a zero crossing of f(x)? if so, then computing the derivative is irrelevant, unless you might want to use Newton's method or such. And even then, this is not how you would be using the derivative.
Solving for a zero crossing of the derivative is equivalent to solving for a stationary point of the function, thus a location where the function is either at a maximum or a minimum. (Or on somewhat rare occasions, where the function has a stationary point at a point of inflection.)
syms x
vpa(solve(diff(-x^3+x^2-x+5)))
ans =
0.3333333333333333333333333 - 0.4714045207910316829338962i
0.3333333333333333333333333 + 0.4714045207910316829338962i
So we see only complex roots of the derivative. Since this otherwise well behaved function has no real roots of the derivative, therefore one can show the function must always be either monotonic increasing or decreasing. With a negative coefficient of x.^3, we know f(x) must be a monotone decreasing function. There is no stationary point, although it comes close.
fplot(-x^3+x^2-x+5)
grid on
The point of inflection lives at
xinf = solve(diff(-x^3+x^2-x+5,2))
xinf =
1/3

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by