commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luc Maisonobe <Luc.Maison...@free.fr>
Subject Re: [math] how to get the second ferivatives of a group of data
Date Wed, 24 Sep 2008 19:26:34 GMT
Yang, Shuli a écrit :
> Here is the problem,

First, please do include a [math] prefix in the subject line when you
post a message related to commons-math to this list. It is shared by
several sub-projects and it helps people filtering their mail.

> 
> Function F(x) does not have a formula to specify the relation between x
> and f(x), but for each x, I have got the value of f(x) by a measurement
> machine.
> 
> I am interested in the point xi at which the second derivative of f(xi)
> is zero. 
> 
> Can anybody help me how to do that?

If you do not have an explicit formula, you should use either polynomial
interpolation or finite differences to get the derivatives.

Polynomial interpolation is better suited if you have a sample of points
f(xi) with large intervals between each xi and no way to reduce this
(i.e. you cannot redo as many measurements as you want). In this case,
you can fit a polynomial to a sub-sample of your points, compute the
derivative of the polynomial from the coefficients, and solve the
equation p''(x) = 0. If you can find a root in your sample, this is
good. If the root is far from your sample, it is probably not good as
the polynomial is a good approximation only near the sample. Beware not
to use a too high degree polynomial as they tend to oscillate a lot
between points (it is Gibbs phenomenon).

If you can perform as many measurement as you want and can use small
intervals between each xi, then finite differences is probably better
suited. You should choose a small step size h and evaluate the function
at several locations around x, for example f(x-2h), f(x-h), f(x),
f(x+h), f(x+2h) ... You can combine these values to compute an
approximation of the derivative. The more points you use and the smaller
the step size is, the better the approximation will be.

Here are some finite differences rules for second derivative, using the
notation pkh(x) = f(x + k h) + f(x - k h)

3 points: f''(x)  ≈ [ p1h - 2 f(x) ] / h^2

5 points: f''(x)  ≈ [ - p2h + 16 p1h - 30 f(x) ] / 12h^2

7 points: f''(x)  ≈ [ 2 p3h - 27 p2h + 270 p1h - 490 f(x) ] / 180h^2

Here are some finite differences rules for first derivative, using the
notation mkh = f(x + k h) - f(x - k h)

2 points: f'(x) ≈ m1h / 2h

4 points: f'(x) ≈ [ - m2h + 8 m1h ] / 12h

6 points: f'(x) ≈ [ m3h - 9 m2h + 45 m1h ] / 60h

8 points: f'(x) ≈ [ -3 m4h + 32 m3h - 168 m2h + 672 m1h ] / 840h

Luc

> 
>  
> 
> Thanks,
> 
>  
> 
> Shuli 
> 
> *********************************************************************
> This message and any attachments are solely for the
> intended recipient. If you are not the intended recipient,
> disclosure, copying, use or distribution of the information 
> included in this message is prohibited -- Please 
> immediately and permanently delete.
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message