I'm trying to solve the following differential equation: $$\frac{d^2u}{dx^2}=\frac{du}{dx}u+u^2+x$$ $$x \in \Omega=[0,1]$$ $$BCS:u|_{x=0}=1;\frac{du}{dx}|_{x=1}=1$$
You can see that the right side contains $u^2$. So when I paste it in the weighted residual form, I get nonlinear term. For example, if I have approximation:
$$ u=1+\sum_{i=1}^n\alpha_i x^i$$ There will be nonlinear integral in weighted residuals $$\int (1+\sum_{i=1}^n\alpha_i x^i)^2dx$$ That's why the system will be nonlinear. What am I missing?
I tried to switch from $u$ to $u^2$ in equation because $u\frac{du}{dx}=\frac{1}{2}\frac{du^2}{dx}$, but can't make it for $\frac{d^2u}{dx^2}$
Edit, according to the answer:
I won't write BCS integrals, because they don't make real sense in the question. I'll write only the integral in the main domain. So I have $$\int_0^1w(\frac{d^2u}{dx^2}-\frac{du}{dx}u-u^2-x)dx=0$$ $w-$weight function. Paste approximation of $u$. Let's take $n = 2$ $$\int_0^1w(2\alpha_2-(\alpha_1 + 2\alpha_2 x)(1+\alpha_1 x +\alpha_2 x^2)-(1+\alpha_1 x +\alpha_2 x^2)^2-x)dx=0$$ Take in account Bubnov-Galerkin approximation of weight function: $$ w=\beta_1x+\beta_2x^2$$ $$\int_0^1\beta_1x(2\alpha_2-(\alpha_1 + 2\alpha_2 x)(1+\alpha_1 x +\alpha_2 x^2)-(1+\alpha_1 x +\alpha_2 x^2)^2-x)dx +\int_0^1\beta_2x^2(2\alpha_2-(\alpha_1 + 2\alpha_2 x)(1+\alpha_1 x +\alpha_2 x^2)-(1+\alpha_1 x +\alpha_2 x^2)^2-x)dx=0$$ From here since $\beta_i $ arbitrary we have system
$$\begin{cases} \int_0^1x(2\alpha_2-(\alpha_1 + 2\alpha_2 x)(1+\alpha_1 x +\alpha_2 x^2)-(1+\alpha_1 x +\alpha_2 x^2)^2-x)dx =0\\ \int_0^1x^2(2\alpha_2-(\alpha_1 + 2\alpha_2 x)(1+\alpha_1 x +\alpha_2 x^2)-(1+\alpha_1 x +\alpha_2 x^2)^2-x)dx=0 \end{cases} $$
Here we exactly have unknowns only $\alpha_i;i=1,2$.But if we extend polynomial to $2n=4$ we will have new $\alpha_i;i=1..4$ with 2 equations only
Edit 2:
Actually I need two terms approximation, so I don't think that switching to 2n terms and then solving 2n equations is the key point. I suppose we should simplify ode, or choose another interpolation functions rather then $x^i$

You missed nothing, the product is non-linear. However, you can extend your polynomial expansion with
$$\int (1+\sum_{i=1}^n\alpha_i x^i)^2dx\equiv\int (1 + \sum_{i=1}^{2n}\tilde{\alpha_i} x^i) dx.$$
The product of $u\cdot u$ is still a polynomial, however with a higher polynomial degree of $2n$.
The Galerkin solution can be derived by integrating $$\int (1 + \sum_{i=1}^{2n}\tilde{\alpha_i} x^i) dx$$ and considering only the first $n$ coefficients of $\tilde{\alpha_i}$. Simply spoken: Coefficients greater $n$ are neglected.
The truncation of the additional $n$ modes can be intepreted as projection in a $2n$ dimensional space onto a $n$ dimensional space where the solution is orthogonal to the chosen subspaces.
This is the key property of the Galerkin approach.
Regards