How Prism computes the derivatives of curves.
As part of the Smooth analysis, Prism can convert a curve to its first- or second-derivative. Curves are defined as a series of line segments, and Prism computes the derivative numerically. No calculus involved. It uses this algorithm:
First Prism sorts the input (X,Y) pairs in increasing order by X values. If two or more points have the same X value, Prism averages the Y values to create a single (X,Y) pair. So the resulting sorted list of XY pairs will be shorter than the original data table if any X values are repeated. We'll call this array of sorted (X,Y) pairs the Src array.
Prism computes the resulting derivative table, with one fewer XY pair than the Src array, using a simple idea. Each row in the results table is computed from two adjacent rows in the sorted input table. The X value for each row in the results table is the mean of two adjacent X values in the input table. The Y value in each row in the results table equals the difference between the two Y values, divided by the difference between the two X values:
Resulting X[i] = (SrcX[i+1] + SrcX[i]) / 2
Resulting Y[i] = (SrcY[i+1] - SrcY[i]) / (SrcX[i+1] - SrcX[i])
To compute a second derivative, the first-derivative table is used as the input to the same algorithm a second time. So the second derivative table has two fewer rows that the sorted input table (after removing duplicates).
After creating either the first or second derivative, Prism can smooth the resulting curves (depending on your choices on the dialog).