turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Calculating Derivatives/Slopes in JMP

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 7, 2016 10:29 AM
(1749 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 7, 2016 11:55 AM
(3076 views)

Solution

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))**

**)**;

3 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 7, 2016 11:06 AM
(1538 views)

natalie_,

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

Hope this helps.

Dave

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 7, 2016 11:55 AM
(3077 views)

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))**

**)**;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 8, 2016 10:55 AM
(1538 views)

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)));