cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
natalie_
Level V

Calculating Derivatives/Slopes in JMP

Hello again,

I have to columns of data, let's call them x and y.  I want to calculate the center derivative of y with respect to x (dy/dx).  If I am using the center derivative, that means I will be "missing" a point at the beginning and end of the dy/dx column.

For example, in row two of dy/dx, I want it to equal dy/dx = y3-y1/x3-x1 and on row three of dy/dx, I want it to equal dy/dx = y4-y2/x4-x2.  I am having a hard time not using jmp like I would with excel, so I am not even sure if is possible to do this in the formula editor.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: Calculating Derivatives/Slopes in JMP

This code should give you some ideas.  The column formula makes use of the LAG function:

dt = open("$sample_data\Big Class.jmp");

// Create formula column

// Height = X

// Weight = Y

// dy/dx = (y+1) - (y-1)/(x+1) - (x-1)

// y+1: lag(:weight, -1)

// y-1: lag(:weight, 1)

// x+1: lag(:height, -1)

// x-1: lag(:height, 1)

dt << New Column( "dy/dx",

            Numeric,

            Continuous,

            Format( "Best", 12 ),

            Formula( lag(:weight, -1) - lag(:weight, 1) / lag(:height, -1) - lag(:height, 1))

      );

View solution in original post

3 REPLIES 3
DaveLee
Level IV

Re: Calculating Derivatives/Slopes in JMP

natalie_,

The Formula Editor has a derivative option.  You can access it by clicking the red triangle at the top of the Editor dialog. 

10730_pastedImage_0.png

Hope this helps.


Dave

pmroz
Super User

Re: Calculating Derivatives/Slopes in JMP

This code should give you some ideas.  The column formula makes use of the LAG function:

dt = open("$sample_data\Big Class.jmp");

// Create formula column

// Height = X

// Weight = Y

// dy/dx = (y+1) - (y-1)/(x+1) - (x-1)

// y+1: lag(:weight, -1)

// y-1: lag(:weight, 1)

// x+1: lag(:height, -1)

// x-1: lag(:height, 1)

dt << New Column( "dy/dx",

            Numeric,

            Continuous,

            Format( "Best", 12 ),

            Formula( lag(:weight, -1) - lag(:weight, 1) / lag(:height, -1) - lag(:height, 1))

      );

natalie_
Level V

Re: Calculating Derivatives/Slopes in JMP

Thank you, it worked well.

I used it in a script, but I had to add As Column. 

col <<Set Formula( (lag(As Column("Y"), -1) - lag(As Column("Y"),1))/(lag(As Column("X"),-1)-lag(As Column("X"),1)));