A set of six data points are given in terms of $X$ and $Y$ like $(x,y)$ or just say six coordinates data set. How can I use least square method to make linear combination of $x$ , $\sin(x)$ and $\exp(x)$ that best describe the curve that passes through all those points ? I can do it if only $x$ or $\sin(x)$ or $\exp$ is present.
Using least squares method by using data points
545 Views Asked by user427132 https://math.techqa.club/user/user427132/detail AtThere are 2 best solutions below
On
@Claude Leibovici provides critical insights. Some details are added.
Input data: $m=6$ points $$ \left\{ x_{k}, y_{k} \right\}_{k=1}^{m} $$ Linear model: $$ y(x) = a_{0} + a_{1} x + a_{2} \sin x + a_{3} e^{x} $$ Linear system: $$ \begin{align} \mathbf{A} \, a &= y \\ \left[ \begin{array}{cccc} 1 & x_1 & \sin \left(x_1\right) & e^{x_1} \\ 1 & x_2 & \sin \left(x_2\right) & e^{x_2} \\ 1 & x_3 & \sin \left(x_3\right) & e^{x_3} \\ 1 & x_4 & \sin \left(x_4\right) & e^{x_4} \\ 1 & x_5 & \sin \left(x_5\right) & e^{x_5} \\ 1 & x_6 & \sin \left(x_6\right) & e^{x_6} \\ \end{array} \right] % \left[ \begin{array}{cccc} a_{0} \\ a_{1} \\ a_{2} \\ a_{3} \end{array} \right] % & = % \left[ \begin{array}{cccc} y_{1} \\ y_{2} \\ y_{3} \\ y_{4} \\ y_{5} \\ y_{6} \end{array} \right] % \end{align} $$ Least squares solution: $$ a_{LS} = \left\{ a \in \mathbb{C}^{4} \colon \lVert \mathbf{A} \, a - y \rVert_{2}^{2} \text{ is minimized} \right\} $$
Solution option: normal equations
$$ \begin{align} % \mathbf{A}^{*} \mathbf{A} \, a &= \mathbf{A}^{*} y \\ % \left[ \begin{array}{llll} \sum 1 & \sum x & \sum sin(x) & \sum e^{x} \\ \sum x & \sum x^2 & \sum x sin(x) & \sum x e^{x} \\ \sum sin(x) & \sum x sin(x) & \sum sin^{2}(x) & \sum sin(x) e^{x} \\ \sum e^{x} & \sum e^{x} x & \sum e^{x} sin(x) & \sum e^{2x} \\ \end{array} \right] \left[ \begin{array}{cccc} a_{0} \\ a_{1} \\ a_{2} \\ a_{3} \end{array} \right] &= \left[ \begin{array}{cccc} \sum y \\ \sum x y \\ \sum y\sin(x) \\ \sum y \exp(x) \end{array} \right] % % \end{align} $$ Solution $$ a_{LS} = \left( \mathbf{A}^{*} \mathbf{A} \right)^{-1} \mathbf{A}^{*}\, y $$
You want a model like $$y=a+bx+c \sin(x)+d e^x$$ It is fully linear with respect to parameters. So define $t_i=\sin(x_i)$, $z_i=e^{x_i}$ and the model is just $$y=a+b x+c t+d z$$ Just apply multilinear regression.
Warning : $6$ points is very very small as a number of points for tuning $4$ parameters.