0

Find maximums and minimums of an approximation of a funtion given by a serie of points

If you have an approximation of a function given by a serie of points on a vector, how to find it's maximums and minimums?

Maximums and minimums can be found with the roots of the derivative of the function. This could be done with the diff(y) function. Is there an easy way to get the indexes of the zeroes of diff(y)? And interpolated indexes?

Thanks for your help.

Scilab

0

What I have found so far is this:

diff(y) // approximative derivative of y

diff(y)<0 // negative y'=T, positive y'=F

diff(diff(y)<0) // sign change of y' =1 or -1, otherwise 0

find(diff(diff(y)<0)) //return indexes of sign change of y'

diff(y)<0 // negative y'=T, positive y'=F

diff(diff(y)<0) // sign change of y' =1 or -1, otherwise 0

find(diff(diff(y)<0)) //return indexes of sign change of y'

The indexes are not interpolated with that solution. Diff making the difference of contiguous values, the size of the vector is decreased by one. As this function is applied twice, the index position may be wrong by up to a couple of indexes I guess.

0

I am of the same opinion that this process was repeated twice resulting in the halving. diff(y) // approximative derivative of y

diff(y)<0 // negative y'=T, positive y'=F

diff(diff(y)<0) // sign change of y' =1 or -1, otherwise 0

find(diff(diff(y)<0)) //return indexes of sign change of y' <mapquest driving directions>

diff(y)<0 // negative y'=T, positive y'=F

diff(diff(y)<0) // sign change of y' =1 or -1, otherwise 0

find(diff(diff(y)<0)) //return indexes of sign change of y' <mapquest driving directions>

Login to add comment