Welcome to our community

Be a part of something great, join today!

[SOLVED] Method of least square: initial position & velocity

mathmari

Well-known member
MHB Site Helper
Apr 14, 2013
4,036
Hey!! :eek:

A point is moving linearly with constant velocity $v$ and the movement is $x=a+vt$.
The below information is given:

a_v.JPG

Find the initial position $a$ and the velocity using the method of least square.


Could you give me a hint how we use this method here? Couldn't we use the data of the matrix and get a $2\times 2$ linear system? (Wondering)
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,736
A point is moving linearly with constant velocity $v$ and the movement is $x=a+vt$.
The below information is given:

Find the initial position $a$ and the velocity using the method of least square.

Could you give me a hint how we use this method here?
Hey mathmari !!

The method of least squares is that we minimize the sum of the squared deviations $\sum\limits_{i=1}^n (x_i - x(t_i))^2$, isn't it? (Wondering)

We should be able to find formulas for it somewhere, either in matrix form or in formula form.
Or we can derive those formulas ourselves.
Or we can use a tool like Excel to do it for us. (Thinking)

Couldn't we use the data of the matrix and get a $2\times 2$ linear system?
Which $2\times 2$ linear system do you mean? (Wondering)
 

mathmari

Well-known member
MHB Site Helper
Apr 14, 2013
4,036
The method of least squares is that we minimize the sum of the squared deviations $\sum\limits_{i=1}^n (x_i - x(t_i))^2$, isn't it? (Wondering)

We should be able to find formulas for it somewhere, either in matrix form or in formula form.
Or we can derive those formulas ourselves.
Or we can use a tool like Excel to do it for us. (Thinking)
Ah I think now I have an idea how we have to apply the method in this case.

From the matrix we have the exact values of $x_i$'s and from the formula of the movement we get an approximation $x(t_i)$, or not?

So we get \begin{align*}\sum\limits_{i=1}^5 (x_i - x(t_i))^2&=(x_1 - x(t_1))^2+(x_2 - x(t_2))^2+(x_3 - x(t_3))^2+(x_4 - x(t_4))^2+(x_5 - x(t_5))^2 \\ & =(-11 - [a-2v])^2+(-5 - [a-v])^2+(1 - a)^2+(5 - [a+v])^2+(10 - [a+2v])^2\end{align*}

(Wondering)
 

HallsofIvy

Well-known member
MHB Math Helper
Jan 29, 2012
1,151
What do you mean by "the initial position"? I would think that would be x(0) but the table itself tells you that x(0)= 1. There is no calculation at all required for that!
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,736
Ah I think now I have an idea how we have to apply the method in this case.

From the matrix we have the exact values of $x_i$'s and from the formula of the movement we get an approximation $x(t_i)$, or not?

So we get \begin{align*}\sum\limits_{i=1}^5 (x_i - x(t_i))^2&=(x_1 - x(t_1))^2+(x_2 - x(t_2))^2+(x_3 - x(t_3))^2+(x_4 - x(t_4))^2+(x_5 - x(t_5))^2 \\ & =(-11 - [a-2v])^2+(-5 - [a-v])^2+(1 - a)^2+(5 - [a+v])^2+(10 - [a+2v])^2\end{align*}
Yep.
We can minimize that with respect to $a$ and $v$ can't we? (Wondering)

What do you mean by "the initial position"? I would think that would be x(0) but the table itself tells you that x(0)= 1. There is no calculation at all required for that!
The value of $x(0)$ given in the table is a measurement.
The approximation of $a$ is the approximation of $x(0)$ based on a linear least square interpolation.
The question asks for $a$, which should be a more accurate version of the position at time $t=0$.
 

mathmari

Well-known member
MHB Site Helper
Apr 14, 2013
4,036
Yep.
We can minimize that with respect to $a$ and $v$ can't we? (Wondering)
For that we use the gradient, don't we? (Wondering)

\begin{align*}S(a,v)=&(-11 - [a-2v])^2+(-5 - [a-v])^2+(1 - a)^2+(5 - [a+v])^2+(10 - [a+2v])^2 \\ =&11^2 +22[a-2v]+ [a-2v]^2+5^2 +10[a-v]+ [a-v]^2+1 -2a+ a^2+5^2 -10[a+v]+ [a+v]^2\\ & +10^2 -20[a+2v]+ [a+2v]^2 \\ =&121 +22a-44v+ a^2-4av+4v^2+25 +10a-10v+ a^2-2av+v^2+1 -2a+ a^2\\ &+25 -10a-10v+ a^2+2av+v^2+100 -20a-40v+ a^2+4av+4v^2 \\ =& 5a^2+10v^2-104v+272 \end{align*}

The partial derivatives are:
\begin{align*} & \frac{\partial{S}}{\partial{a}}= 10a \\ & \frac{\partial{S}}{\partial{v}} = 20v-104 \end{align*}

We set these partial derivatives equal to zero and we get \begin{align*} & \frac{\partial{S}}{\partial{a}}= 0 \Rightarrow 10a=0 \Rightarrow a=0 \\ & \frac{\partial{S}}{\partial{v}} = 0 \Rightarrow 20v-104=0 \Rightarrow v=\frac{104}{20} \Rightarrow v=5.2 \end{align*}


Is everything correct? (Wondering)
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,736
We set these partial derivatives equal to zero and we get \begin{align*} & \frac{\partial{S}}{\partial{a}}= 0 \Rightarrow 10a=0 \Rightarrow a=0 \\ & \frac{\partial{S}}{\partial{v}} = 0 \Rightarrow 20v-104=0 \Rightarrow v=\frac{104}{20} \Rightarrow v=5.2 \end{align*}


Is everything correct?
The answer is correct so I think the intermediate steps are correct as well. (Nod)
 

mathmari

Well-known member
MHB Site Helper
Apr 14, 2013
4,036
The answer is correct so I think the intermediate steps are correct as well. (Nod)
How did you get the correct answer? Is there also an other method we can use? Or is there an online tool? (Wondering)
 

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
8,736
How did you get the correct answer? Is there also an other method we can use? Or is there an online tool?
I entered the data in Excel and used the [M]LINEST[/M] array function to get the result. (Thinking)

linest.jpg
 

mathmari

Well-known member
MHB Site Helper
Apr 14, 2013
4,036