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
- :
- Discussions
- :
- How can I calculate the intersection point of two ...

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
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 2, 2015 9:12 AM
(3889 views)

I am graphing two functions in JMP using the YFunction command in JSL. I would like to calculate the point where they intersect. How should I do this either manually or in JSL?

Thanks for the help!

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 2, 2015 10:31 AM
(6778 views)

The minimize function might do what you need if your functions are well behaved. In this example, the black reference line is automatically placed at the intersection of the red and green curves.

f1 = Function( {a}, Abs( a ) ^ 1.5);

f2 = Function( {a}, 10 / a );

intersect_X = 1;// guess a value

Minimize( Abs( f1( intersect_X ) - f2( intersect_X ) ), {intersect_X}, <<tolerance(1e-3) );

New Window( "Example",

Graph Box(

xaxis( Add Ref Line( intersect_X, "Solid", "Black", "", 1 ) ),

X Scale( -5, 5 ), Y Scale( -20, 20 ),

Pen Color( "red" ); Y Function( f1( a ), a );

Pen Color( "green" ); Y Function( f2( a ), a );

)

);

Craige

8 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 2, 2015 10:31 AM
(6779 views)

The minimize function might do what you need if your functions are well behaved. In this example, the black reference line is automatically placed at the intersection of the red and green curves.

f1 = Function( {a}, Abs( a ) ^ 1.5);

f2 = Function( {a}, 10 / a );

intersect_X = 1;// guess a value

Minimize( Abs( f1( intersect_X ) - f2( intersect_X ) ), {intersect_X}, <<tolerance(1e-3) );

New Window( "Example",

Graph Box(

xaxis( Add Ref Line( intersect_X, "Solid", "Black", "", 1 ) ),

X Scale( -5, 5 ), Y Scale( -20, 20 ),

Pen Color( "red" ); Y Function( f1( a ), a );

Pen Color( "green" ); Y Function( f2( a ), a );

)

);

Craige

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 2, 2015 10:39 AM
(3499 views)

That works great, thanks! Do you know how I can output the x-coordinate of the intersection using that? The black line shows up perfectly but I cannot see the x-value.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 2, 2015 10:46 AM
(3499 views)

the JSL variable, intersect_X, holds the result of the minimize function. (minimize uses it for an initial guess, then modifies it.) You should check if F1(intersect_X) is close enough to F2(intersect_X) to meet your requirements. A bad initial guess might prevent it from working.

Craige

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 2, 2015 11:26 AM
(3499 views)

Exactly what i needed, thanks! It works perfectly.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 2, 2015 11:00 AM
(3499 views)

Or, if you just want it on the graph,

xaxis( Add Ref Line( intersect_X, "Solid", "Black",** char(intersect_x,6,4)**, 1 ) ),

6,4 is the field width and number of decimal digits after formatting the number to characters.

Craige

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 2, 2015 11:43 AM
(3499 views)

You can interactively find the intersection in this example using a slightly higher level of JMP machinery by using the Profiler.

1. New table with columns X and Y, 2 rows with values -5 and 5 for x.

2. Formula for Y: abs(x)^1.5 - x/10

3. Invoke standalone profiler

4. Specify Y as the prediction formula

5. Specify the desirability function to be Target = 0.

6. Maximize desireability

You will then get the solution X value spelled out on the X-axis.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 5, 2015 6:20 AM
(3499 views)

How do I specify desirability to be Target = 0? I keep getting stuck on that part. This seems to be exactly what i need.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Jun 5, 2015 8:01 AM
(3499 views)

1. Graph > Profiler

2. Y --> Y, Prediction Formula

3. Click on red triangle button next to "Prediction Profiler"

4. Click on Desirability Functions

5. Alt-Click the upper right hand box

6. Click the Maximize Button and change to Match Target

7. Change the Values to 20, 0, and -20 (for High, Middle, and Low)

8. Click Ok

9. Click on the red triangle button next to "Prediction Profiler"

10. Click on Maximize Desirability

At various stages you may want to fiddle with the axes to more clearly display what is going on.