# Approximating co-efficents

1. Nov 9, 2004

### Zurtex

I've got a situation where I can approximate a line by the function:

$$y = a_0 + a_1 \sin x + a_2 \sin 2x + b_1 \cos x + b_2 \cos 2x$$

From experimental data I will be able to find certain values for x and y, namely yn and xn for some value of n. Now I can easily write a computer program which could work out the co-efficients in this problem if I have 5 values for y and 5 values for x. However, being a particle situation and wanting as many results as possible or perhaps not being able to gain that many results due to constraints, how would I be able to approximate these co-efficient please?

2. Nov 9, 2004

### shmoe

Let the ith row of an n by 5 matrix $$M$$ be given by $$[ 1\ \sin(x_i)\ \sin(2x_i)\ \cos(x_i)\ \cos(2x_i)]$$, and let $$Y=[y_1,\ldots,y_n]^T$$.

Then coefficients that will minimize the sum of the squares of the differences of your data points to $$y = a_0 + a_1 \sin x + a_2 \sin 2x + b_1 \cos x + b_2 \cos 2x$$ will be any column $A=[a_0,a_1,a_2,b_1,b_2]^T$ which satisfies the linear system $(M^{T}M)A=M^{T}Y$

3. Nov 9, 2004

### Zurtex

Thanks I haven't seen that method yet (well I've researched it but not been able to make sense of it). Thanks a lot, just need to try and make sense of it, but I think I can