I got a little problem:

  • Thread starter Curl
  • Start date
  • #1
757
0
So I was trying to do this:

I want to approximate derivative of some discrete data, so I pick a point, then pick 2 other points, one on the right, and one on the left. I fit a parabola, and then differentiate the equation of the parabola with respect to X and evaluate it at the middle point.

So, I have (x1,y1), (x2,y2), (x3,y3)

The parabola equation, ax2+bx+c=y gives a 3x3 matrix to solve:

|x12 x1 1| |a|
|x22 x2 1| |b| = [y1, y2, y3]T
|x32 x3 1| |c|

Then I find the equation that goes through the three points: ax2+bx+c=y. I take derivative and evaluate dy/dx at x2. This gives dy/dx = 2ax2+b
What??? The constant C is not needed at all. So is there any way to reduce the matrix so that it won't have to solve for c, which will get thrown out anyways? It is computationally cheaper, and it seems like a waste to perform useless calculations.

I suck at math so I couldn't figure out what to do here, I'm sure there's a better method but this little paradox strikes me. Anyone know what's going on?
 

Answers and Replies

  • #2
mathman
Science Advisor
7,867
450
I haven't looked at the question in detail, but I suspect that you could set the problem up in terms of the differences between the points.
 
  • #3
LeonhardEuler
Gold Member
859
1
Probably the fastest way to get the unique polynomial of degree at most n passing through n+1 points with different x values is the Lagrange interpolation formula:
http://en.wikipedia.org/wiki/Lagrange_interpolation
the idea is to come up with a polynomial for each point where pi(xi)=yi for point i, and pi(xj)=0 for j not equal to i. Then you add all of these polynomials together in the end to get the answer you want. So in this case you would get
[tex]p(x)=y_1\frac{(x-x_2)(x-x_3)}{(x_1-x_2)(x_1-x_3)}+y_2\frac{(x-x_1)(x-x_3)}{(x_2-x_1)(x_2-x_3)}+y_3\frac{(x-x_1)(x-x_2)}{(x_3-x_1)(x_3-x_2)}[/tex]
And you can find the derivative of this pretty easily. But this is generally not an especially good way to calculate a derivative if you don't know that you have a parabola. The behavior of the parabola passing through a set of points is specific to that type of curve, so implementing the somewhat complicated expression you get at the end won't give you a systematic improvement over a simple midpoint approximation:
[tex]f'(x)\approx \frac{f(x_3)-f(x_1)}{x_3-x_1}[/tex]
If you go to a higher number of points and use a higher order polynomial, the performance will become very strange because the high order polynomials that solve these equations can be very complicated and have critical points in unexpected places. Using difference methods is generally preferred.
 

Related Threads on I got a little problem:

  • Last Post
Replies
9
Views
2K
  • Last Post
Replies
7
Views
1K
Replies
6
Views
1K
Replies
3
Views
2K
  • Last Post
Replies
21
Views
3K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
5
Views
2K
Replies
2
Views
1K
Replies
24
Views
3K
Top