Forcing a Least squares Polynomial through a fixed point

In summary, you can calculate the original polynomial of the Nth degree, then shift the data so that the last data point is at the origin, set the constant term (the Nth degree coefficient) equal to zero, and recalculate the polynomial using the first data point as the new origin. This will result in a new polynomial that passes through the last data point and has a constant term of zero. Alternatively, you can use the Lagrange multiplier method to find the minimum error polynomial that satisfies the constraint of passing through the last data point. Overall, it is important to simplify the approach and not overcomplicate the solution.
  • #1
KayWarner
3
0
Hi guys,

Thanks for taking the time to read the post.

I have a question related to curve fitting and polynomials that i was hoping someone might be able to help me with.

I have a set of x and y data points, all on a graph. I have then calculated the 4th order least squares polynomial for those points, which gives me an equation for that fit.

I would now like to go one step further and calculate what the least squares polynomial will be if i force the fit line through the last data point? Does anyone have a reference or any advice on how to do this?

Many thanks for your help in advance,

Kay
 
Physics news on Phys.org
  • #2
Welcome to Physics Forums.

I would shift the data so that last data point is at the origin. Then fit a polynomial with the constant term =0, to force it to contain that point at the origin. Finally, do a reverse shift on that polynomial to match it up with the original data.

Hope that helps.
 
  • #3
Thank you so much Redbelly, that is an outstanding answer! I think i may have been trying to overcomplicate the solution to this.

So as i understand it;

1- calculate the original polynomial which will yeild an equation of: ax^4 + bx^3 + cx^2 + dx + e,
2- reverse the data so that the last data point is now first.
3- set (in my case) e = 0;
4- recalculate the polynomial using the first data point as (0,0).

this should give me a new polynomial fit that passes right through the origin?

the only bit I am unclear about is the reverse shift, what do you mean by do a reverse shift?

many thanks for your help,

kay
 
  • #4
Hello !
If the fixed point is (a,b) with a and b given constants, simply write the polynomial as :
y(x) = b + (x-a)*P(x) where P(x) is a polynomial which coefficients can be computed thanks to least squares fitting.
Alternatively, you may define Y(x) = (y-b)/(x-a) so that each value of Y can be previously computed from each given couple (x,y). Then the coefficients of the polynomial P can be computed thanks to least squares fitting. (But not convenient if (x-a)=0, or too close to 0, for a particular point)
Both methods will lead to slightly différent polynomial b+(x-a)*P(x) because the criterium for least squares are not the same. But, generally, the difference of fitting will be quite small.
 
Last edited:
  • #5
In general you are talking about least squares with equality constraints, which can be solved using Lagrange Multipliers. But, with only one constraint, there is an easier approach. Let n denote the last point (i.e. the one you want to fit exactly). Then you have:

yn = axn4 + bxn3 + cxn2 + dxn + e

or

e = yn - axn4 - bxn3 - cxn2 - dxn

If you substitute this expression for e into your original equation you end up with a function of only 4 parameters (a,b,c,d) which can be used for your least squares fit.
 
  • #6
If you're lazy and close is good enough, you could just put a near-infinite weight on the error at the point you want your curve to pass through.
 
  • #7
Thank you so much for the help guys, its really helped me out loads!

Its a huge tribute to the forum that i could get such accutrate and comprehensive guidance. Many thanks to all!
 
  • #8
Glad you got other good suggestions.
KayWarner said:
Thank you so much Redbelly, that is an outstanding answer! I think i may have been trying to overcomplicate the solution to this.

So as i understand it;

1- calculate the original polynomial which will yeild an equation of: ax^4 + bx^3 + cx^2 + dx + e,
2- reverse the data so that the last data point is now first.
3- set (in my case) e = 0;
4- recalculate the polynomial using the first data point as (0,0).

this should give me a new polynomial fit that passes right through the origin?
Not quite, I'll explain with more details below.
the only bit I am unclear about is the reverse shift, what do you mean by do a reverse shift?

many thanks for your help,

kay
More detailed explanation:

1. You have some (x,y) data values:
(x1, y1)
(x2, y2)
.
.
.
(xN, yN)​

2. Make a new set of data -- let's call these (x', y') -- by subtracting (xN, yN) from each (x,y) value. (This is the shift):
(x1-xN, y1-yN) = (x1', y1')
(x2-xN, y2-yN) = (x2', y2')
.
.
.
(xN-xN, yN-yN) = (0,0) = (xN', yN')​

3. Fit a polynomial, without the constant term, to the new data (x', y'). Since there is no constant term, the fit will contain the point (xN',yN')=(0,0), as required.

Eg., for a cubic you would have
y' = ax'3 + bx'2 + cx'​

4. We want to get an equation for x & y from the equation we have for x' and y'. This is the reverse shift.
Using the substitutions
x = x' + xN
y = y' + yN​
We get
y + yN = a(x+xN)3 + b(x+xN)2 + c(x+xN)​
or
y = a(x+xN)3 + b(x+xN)2 + c(x+xN) - yN​
You could either expand out the (x+xN)n terms, or leave them in that form.
 
  • #9
If your polynomial is of power N, having one fixed point makes a definite relation among the N + 1 coefficients and they are no longer independent. You may want to use the Lagrange multiplier method when differentiating the sum of the squared errors to find its minimum (least squares method).
 

FAQ: Forcing a Least squares Polynomial through a fixed point

What is the purpose of forcing a least squares polynomial through a fixed point?

The purpose of forcing a least squares polynomial through a fixed point is to find the best fitting curve that passes through a specific point, while minimizing the overall error between the curve and the given data points. This is useful in situations where the data does not perfectly fit a specific polynomial equation, but a specific point must still be included in the curve.

How is a fixed point determined in the context of least squares polynomial fitting?

A fixed point in the context of least squares polynomial fitting is a specific point that must be included in the curve, regardless of the overall error between the curve and the given data points. This point is usually predetermined based on the specific context and requirements of the problem.

What are the limitations of forcing a least squares polynomial through a fixed point?

Forcing a least squares polynomial through a fixed point can lead to a less accurate overall fit compared to other methods, as the curve must prioritize passing through the fixed point rather than minimizing the overall error. This can also result in a less smooth curve and may not accurately represent the true trend of the data.

How is the best fitting curve determined when forcing a least squares polynomial through a fixed point?

The best fitting curve is determined by finding the polynomial equation that minimizes the overall error between the curve and the given data points, while still passing through the fixed point. This is typically done using mathematical techniques such as gradient descent or the method of least squares.

Can forcing a least squares polynomial through a fixed point result in a unique solution?

No, forcing a least squares polynomial through a fixed point does not always result in a unique solution. In some cases, there may be multiple polynomial equations that can pass through the fixed point while still minimizing the overall error. In these situations, additional criteria must be considered in order to determine the best fitting curve.

Similar threads

Back
Top