MATLAB: Finding a derivative. (Newton Raphson)

derivativenewton raphson help

Hi there,
I am new to this so be nice. Also this WAS a homework, which was months ago and still don't understand, so you aren't helping my grades ect, just trying to further my understanding and get back on track with the rest of my class.
I have a script which calls the function, script:
a=0.5; b=4;
ya = myfunc(a);
yb = myfunc(b);
This I understand, the script calls the function (myfunc) and returns with the y co-ordinates. What I don't understand is how to do the same technique but to call back the derivative, so y'a rather than ya.
Any help would be greatly appreciated.

Best Answer

There is no way to do this. The input of myfunc is a scalar value, and you cannot calculate a derivative using only one value.
Perhaps you are looking for something like this:
h = sqrt(eps(h));
dy_a = (myfunc(a+h) - myfunc(a)) / h
Then you use two values, which are near to eachother, to determine the local derivative at the point a. The choice of h is in first order arbitrary, but you can write a book about it. h must be sufficiently small.