Finding min point of a second derivative function

5 Ansichten (letzte 30 Tage)
Harel Harel Shattenstein
Harel Harel Shattenstein am 8 Jul. 2018
Beantwortet: Eduard Reitmann am 3 Aug. 2018
What I have done is:
f=@(x)2./sqrt(pi).*integral(@(t)exp(-t.^2),0,x);
fplot(f,[-5,5])
DELTA=0.01;
X=-5:DELTA:5;
Y=f(X);
DY_DX=diff(Y)./DETLA;
But it does not work, is there an easier way to the first/second derivative? (not symbolic)

Antworten (1)

Eduard Reitmann
Eduard Reitmann am 3 Aug. 2018
You were almost there. Hope this helps. The zero in the differential is a bit crude (just to keep the vectors the same length), but a small enough step size should give you are very accurate answer.
f = @(x) (2./sqrt(pi)).*integral(@(t) exp(-t.^2),0,x);
dx = 0.01;
x = (-5:dx:5)';
y = arrayfun(f,x);
dydx = [0;diff(y)./dx];
d2ydx2 = [0;diff(dydx)./dx];
[dy2d2x_min,minpos] = min(d2ydx2);
x_min = x(minpos)
figure;
plot(x,[y dydx d2ydx2],x_min,dy2d2x_min,'*')
legend('erf(x)','erf''(x)','erf''''(x)')

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by