# Summation question

1. May 29, 2014

### lilly92

1. The problem statement, all variables and given/known data

I have a set of data (i, yi). A polynomial fit of 1st degree would be y=ai+b, right?
If I have c=Σ(i2*yi) is it correct to substitute y=ai+b inside the summation?

2. Relevant equations

3. The attempt at a solution

Last edited by a moderator: May 29, 2014
2. May 29, 2014

### Ray Vickson

You are being careless with notation, and it is landing you in trouble. You have data $\{ (i, y_i) \}$ and fit a formula of the form $Y(x) = ax + b$ to the data; that is, you are approximating $y_i$ by the value $Y(i) = ai + b$. Hopefully, the approximation is good in some sense, but that is another, separate issue. Anyway, you have a quantity $c = \sum i^2 y_i$. When you substitute $Y(i)$ instead of $y_i$ you are computing an approximation $C = \sum i^2 Y(i)$ instead of the exact value of $c$.

Last edited by a moderator: May 29, 2014
3. May 29, 2014

### lilly92

I don't care about the exact approximation because I test various polynomials to figure out for which c approximates a specific known value. But my problem is what to do about the coefficients of the polynomials. Is there a way to calculate them in order to calculate c?

4. May 29, 2014

### Ray Vickson

How do you perform the fit to the data? If you use the least-squares method there are formulas for the coefficients. If you use some other method, there may not be formulas---only algorithms. For example, if you do a least average absolute-deviation fit, you can set up the problem as a linear program and solve it using a standard package (such as the EXCEL Solver). The solution of the linear program will include values of the coefficients.

5. May 29, 2014

### lilly92

Okay I understand that, thank you. But what if I want to test with polynomials of second degree or higher?
My y data can be manually changed and c takes a specific value. What I'm trying to do is figure out which ys to change to make c take that value and/or by how much. Is that possible?

6. May 29, 2014

### Ray Vickson

Are you asking whether we can find numbers $a$ and $b$ that give
$$\sum_{i=1}^n i^2 (ai+b) = c$$
then the answer is an obvious yes. If we let $s_3 = \sum_{i=1}^n i^3$ and $s_1 = \sum_{i=1}^n i^2$ then the equation just says that $s_3 a + s_2 b = c$ and there are lots of $(a,b)$ combinations that satisfy that. If you also want the form $Y(i) = ai + b$ to be a (hopefully good) fit to some data $\{ i, y_i \}$, then you just have a constrained version of the usual data-fitting methods. The standard fitting formulas may no longer apply--- because of your specified constraint $s_3 a + s_2 b = c$---but you can use a constrained optimization method to get a numerical solution. For example, you can do it using the EXCEL Solver.