# LabVIEW

cancel
Showing results for
Did you mean:

## Inflection point from second derivative

Hi all,

I'm trying to find the inflection point of a discrete set (10-20 points) of measured data.

I thought I would use the second derivative test.  Is this the best way?

The first step would be to calculate the second derivative function for my data (I may need to interpolate?).

Please refer to the attached VI.  The simple function y = 3x^2 should have an inflection (strictly speaking it's a turning point) at x = 0.  Therefore y''(0) = 0.

The problem is that the VI does not return the second derivative equal to zero.  It is even worse for 10 datapoints.

I'm wondering if anyone can help.

Thanks,

Battler.

Message 1 of 10
(7,325 Views)

## Re: Inflection point from second derivative

Hello battler,

You should be careful with your math: if y=3x^2, then first derivative is y'=6x and second derivative is y''=6, i.e. a constant and not y''(0)=0.

What exactly do you mean by "inflection point" ?   See this in wikipedia: http://en.wikipedia.org/wiki/Inflection_point

What do you want to find ?

Does your discrete set of data contain experimentally obtained values that have only finite accuracy (and have therefore some error) ?  If so, then simple derivation could be quite problematic.

Unfortunately I cannot open your .vi since I have LV 8.5.2

regards,

Bojan

Message 2 of 10
(7,308 Views)

## Re: Inflection point from second derivative

Hi,

If your aim is to find points where the gradient changes sign (Usually a minimum or maximum)  I have used a for loop with the point by point differentiation to find the gradient (I am fairly sure this is the first derivitive).  Using this in conjunction with a threshold where i expect minima or maxima to be (Only checks the gradient above or below a threshold).

i.e dy/dx of x^2 at x=o => 2x0 = 0.

dy/dx of x^2 at x=-1 => 2x-1 = -1,

dy/dx of x^2 at x=1 => 2x1 = 1,

If gradient changes sign and is above / below said threshold that is your point you are looking for.

The second derivitive is rate of change of gradient.  i.e is the gradient getting steeper than my curent  gradient.  (Acceleration in comparison to speed for example)

Craig

Message Edited by craigc on 15--02-2010 12:04 PM
LabVIEW 2012
Message 3 of 10
(7,302 Views)

## Re: Inflection point from second derivative

You should be very carefull then using continious math methods on discrete values. The continious math method of finding local minima and maximum points will only in very rare cases work 100%

Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 4 of 10
(7,289 Views)

## Re: Inflection point from second derivative

If your function is quadratic (ie to the second power) it does not have an inflection point.

An inflection point is when the function changes from positive first derivative to negative or visa versa.

This only occurs in functions with powers 3 or greater

Cory K
Message 5 of 10
(7,277 Views)

## Re: Inflection point from second derivative

It was a typo: I meant x^3.

All of you should read this:

# Second derivative test

The test states: If the function f is twice differentiable at a stationary point x, meaning that $\ f^{\prime}(x) = 0$, then:
• If $\ f^{\prime\prime}(x) < 0$ then $\ f$ has a local maximum at $\ x$.
• If $\ f^{\prime\prime}(x) > 0$ then $\ f$ has a local minimum at $\ x$.
• If $\ f^{\prime\prime}(x) = 0$, the second derivative test says nothing about the point $\ x$, a possible inflection point.

In the last case, although the function may have a local maximum or minimum at x, because the function is sufficiently "flat" (i.e. $\ f^{\prime\prime}(x) = 0$) the extremum is rendered undetected by the second derivative. In this case one has to examine the third derivative. The point at which $\ f^{\prime\prime}(x) = 0$ is an inflection point if concavity changes on either side of it. For example, (0,0) is an inflection point on $\ f(x) = x^3$ because $\ f^{\prime\prime}(0) = 0$, and $\ f^{\prime\prime}(-1) < 0$ and $\ f^{\prime\prime}(1) > 0$.

Message 6 of 10
(7,258 Views)

## Re: Inflection point from second derivative

Finding (possible) inflection point for discrete x, y test data:

The way my algorithm works:

1.  Convert X-values to equal spacings (required for discrete differentiation).

2.  Apply spline interpolation to discrete x (at equal spacing), y.

3.  Differentiate twice using discrete Derivative x(t) with dt as equal spacing determined in Step 1.

4.  Index f''(x) array and check for change in sign (i.e. zero crossing).  If True then between the current and previously indexed values there is an inflection point.

5.  Fit a linear curve between the two points.  Using the linear equation find the zero crossing (i.e. y=0).  This is close to where the inflection point occurs.

I will try to post the VI once completed.

Message 7 of 10
(7,256 Views)

## Re: Inflection point from second derivative

Dear battler,

You still did not tell us what is the origin of your datapoints. If they have a significant amount of noise added, then a more robust algorithm is needed. The location of the inflection point as given by your algorithm will depend entirely on few datapoints around it and if you slightly change a value of any of them, the location of the inflection point my shift significantly. In other words: if you have noisy datapoints, you can have a significant error bar on the location of the inflection point.

regards,

Bojan

Message 8 of 10
(7,228 Views)

## Re: Inflection point from second derivative

Coq Rouge

I hear you which is why i tune this type of vi from case to case to get the point I am looking for.  I dont usually use at all for finding definitive points more for array subsets / meas triggers etc.  have used it successfully in the past in a robust manner, but only if i can predict what i am trying to measure.  i.e a pulse above a threshold etc.  Out of interest what methods do you use for finding these type of points? (Always open to a better way of doing things) 🙂

Craig

LabVIEW 2012
Message 9 of 10
(7,207 Views)

## Re: Inflection point from second derivative

craigc wrote:

Coq Rouge

I hear you which is why i tune this type of vi from case to case to get the point I am looking for.  I dont usually use at all for finding definitive points more for array subsets / meas triggers etc.  have used it successfully in the past in a robust manner, but only if i can predict what i am trying to measure.  i.e a pulse above a threshold etc.  Out of interest what methods do you use for finding these type of points? (Always open to a better way of doing things) 🙂

Craig

I have used Labview peak detection functions. Not the Express VI version of course. With some extra application specific fine tuning this will work well in most cases. The picture is a random example from my computer. The picture is somewhat edited but the blue and red dots are from Labview, and not edited

Message Edited by Coq Rouge on 02-16-2010 11:16 AM

Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 10 of 10
(7,205 Views)