In subdomain \(\Omega \), supposing local basis functions
\( \textcolor{red}{\boldsymbol{g}=\left\{ 1 \ x \ x^2\right\} }\) ,
any function \(f\) can be written as:
\[
f(x)=\boldsymbol{g}\left\{a\right\}=\left\{ 1 \ x \ x^2\right\} \left\{ \begin{array}{l} a_0\\ a_1\\ a_2 \end{array} \right\}
\tag{1}
\]
Given data \( \left( x_i, f_i \right) \) are expected to be:
\[
\left\{ f_i \right\}=
\left\{ \begin{array}{c}
f_0\\f_1\\...\\f_{n-1}
\end{array}
\right\}
=\left\{ \begin{array}{ccc}
1 & x_0 & x_0^2 \\
1 & x_1 & x_1^2 \\
1 & x_{n-1} & x_{n-1}^2 \\
\end{array}
\right\} \left\{ \begin{array}{l} a_0\\ a_1\\ a_2 \end{array} \right\}
=\textcolor{red}{G}\left\{a\right\}
\tag{2}
\]
"Least Squares" can solve it and \(\left\{a\right\}\) is given:
\[
\left\{ a\right\}=\left( G^TG\right)^{-1}G^T \left\{ f_i \right\} = \boldsymbol{G}^{+}\left\{ f_i \right\}
\tag{3}
\]
\((\partial f) \), the space derivatives of \(f\) can be written with \(\left\{ f_i \right\}\) like:
\[
(\partial f ) \equiv
\left\{
\begin{array}{c}
f\\f'\\f''
\end{array}
\right\}_{x=0}
=(\partial\boldsymbol{g})\boldsymbol{G}^{+}\left\{ f_i \right\}
\quad
\text{where}
\quad
(\partial\boldsymbol{g})=
\left(
\begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 2 \\
\end{array}
\right)
\tag{4}
\]
Linear PDE can be written in matrix form. For examle: