Second Derivative (rate of change of the rate of change)

Version 2

Description:

This calculation computes the approximate second derivative at each point of a function f(x), using finite differences.

Example Calculation:

// The below calculation is a second order approximation to the second derivative of f(x).

// If the current row is the first row, then use a forward difference to compute the endpoint

IF FIRST()==0 THEN

(2*SUM([f(x)])-5*LOOKUP(SUM([f(x)]),1)+4*LOOKUP(SUM([f(x)]),2)-LOOKUP(SUM([f(x)]),3))/POWER((LOOKUP(SUM([x]),1)-SUM([x])),2)

// If the current row is the last row, then use a backward difference to compute the endpoint.

ELSEIF LAST()==0 THEN

(2*SUM([f(x)])-5*LOOKUP(SUM([f(x)]),-1)+4*LOOKUP(SUM([f(x)]),-2)-LOOKUP(SUM([f(x)]),-3))/POWER((LOOKUP(SUM([x]),-1)-SUM([x])),2)

ELSE

// Otherwise use a second order centered difference

(LOOKUP(SUM([f(x)]),1)-2*SUM([f(x)])+LOOKUP(SUM([f(x)]),-1))/(POWER((LOOKUP(SUM([x]),1)-SUM([x])),2))

END

Inputs and Setup: (for table calculations, delete if not applicable)

[x] - A numerical field.

[f(x)] - Another numerical field.

- Each [x] value in the partition must correspond to a single [f(x)] value in the partition.

- No two consecutive [x] values can be the same (otherwise we divide by zero).

Partitioning and Addressing: (for table calculations, delete if not applicable)

Compute using a field that partitions your data into the points in the view.

Alternately, if you wish to use all of the available points, you can turn off Aggregate Measures and compute using Table (Across).

For interior points, the calculation uses a second-order accurate centered difference formula.  This doesn't work for the endpoints (because we don't have data beyond the endpoints), so instead we use a forward or backward difference to compute the derivatives there.

If the difference between [x] values is too small compared to the difference in [f(x)] values, we may see some numerical instability.

Related Functions: