Finding zero crossing of equation

11 visualizaciones (últimos 30 días)
Gökhan Kumtas
Gökhan Kumtas el 26 de Mayo de 2020
Editada: John D'Errico el 27 de Mayo de 2020
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 comentario
David Goodmanson
David Goodmanson el 26 de Mayo de 2020
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.

Iniciar sesión para comentar.

Respuestas (1)

John D'Errico
John D'Errico el 27 de Mayo de 2020
Editada: John D'Errico el 27 de Mayo de 2020
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

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by