This project has moved. For the latest updates, please go here.

Is the reference point (x, y) above or below the non-linear equation?

Apr 24, 2014 at 7:53 PM
Dear community member,

In short, I have a series of 3 to 10 data points that will be used to represent a curve. For example:
  • X=0, Y=10
  • X=4, Y=7
  • X=9, Y=12
  • X=16, Y=10
What I am trying to do is determine whether or not a reference point is above or below the curve.

My gut feeling is that for people in the know, this is a relatively straight forward problem to solve. Unfortunately, my area of expertise is programming... not mathematics :(

Any guidance you can provide would be greatly appreciated.
Coordinator
Apr 24, 2014 at 9:00 PM
Edited Apr 24, 2014 at 9:09 PM
The problem is that in order to decide whether the point is above or below, you need to define the exact curve instead of just a few points.

The simplest approach would be to connect the closest points with straight lines, i.e. a linear spline interpolation. Or a cubic spline if the curve needs to be smooth (you mentioned "non-linear"). Using the interpolation you can then compute y' = f(x) for the curve, and compare this with your y value.
var spline = Interpolate.CubicSpline(new[] {0.0, 4.0, 9.0, 16.0}, new[] {10.0, 7.0, 12.0, 10.0});

spline.Interpolate(5.0).Dump(); // 7.519
spline.Interpolate(12.0).Dump(); // 12.621
Thanks,
Christoph
Marked as answer by cdrnet on 5/2/2014 at 10:32 AM
Apr 24, 2014 at 9:49 PM
Thanks for taking the time to reply to my inquiry cdrnet!

I am assuming that the Math.Net library has been refactored as MathNet.Numerics (v2.6.1.30) only has the following static methods:
  • LinearBetweenPoints
  • RationalWithoutPoles
  • RationalWithPoles
If this is the case... should I be using RationalWithoutPoles?
Coordinator
May 2, 2014 at 6:32 PM
In v2, you can get a cubic spline interpolation by using the class directly from the MathNet.Numerics.Interpolation.Algorithms namespace:
var spline = new CubicSplineInterpolation(new[] {0.0, 4.0, 9.0, 16.0}, new[] {10.0, 7.0, 12.0, 10.0});
Marked as answer by cdrnet on 5/2/2014 at 10:32 AM