Solve a viscous Burgers' equation with a Newton-GMRes method I implemented a preconditioner for a GMRes method. To test this preconditioner I want to solve this one dimensional viscous Burgers' equation
$$\partial_t u(x,t) + u(x,t) \partial_x u(x,t)-\varepsilon\partial_x^2u(x,t)=0,\tag{1}$$
where $\partial_x := \frac{\partial}{\partial x}$ and $\partial_t$ accordingly, with a Newton method so that I can solve the resulting system of linear equations in each Newton iteration with my preconditioned GMRes method.
I found this description among others but I struggle here to get everything together.
So far I discretize the terms in the following manner:
$$\begin{align}
\partial_t u(x,t) &\approx \frac{u(x_i, t^{n+1})-u(x_i,t^n)}{\Delta t} \\
u(x,t) \partial_x u(x,t) &\approx u(x_i,t^n)\frac{u(x_i,t^n)-u(x_{i-1},t^n)}{\Delta x} \\
\partial_x^2 u(x,t) &\approx \frac{u(x_{i-1},t^n)-2u(x_i,t^n)+u(x_{i+1},t^n)}{\Delta x^2}
\end{align}$$
With the short form $u_i^n := u(x_i,t^n)$, one can write $(1)$ in the discretized form:
$$\frac{u_i^{n+1}-u_i^n}{\Delta t} + u_i^n\frac{u_i^n-u_{i-1}^n}{\Delta x}-\varepsilon\frac{u_{i-1}^n-2u_i^n+u_{i+1}^n}{\Delta x^2}\approx 0. \tag{2}$$
In the description mentioned above, they introduced the Jacobian in the analytical formula and discretized after that, but I don't recognize the structure of a Newton method.
I thought, I somehow transfer $(2)$ in a function $F(u)$ and then calculate the Jacobian $J := \partial_u F(u)$. After that I can choose a startvalue $u^0$ and then solve iteratively the system $J(u^i) \delta_i = -F(u^i)$ and update the solution with $u^{i+1} = u^i + \delta_i$.
But how do I get the function $F(u)$ from $(2)$?
Thanks for any hints on that!
 A: The solution to my question, is to use an implicit discretization and not an explicit one, like I did. That means that one has to use the following approximations for the derivatives:
The discretization for $\partial_t u$ was right, but the one for the diffusive term should be like this:
$$\partial_x^2 u(x,t) \approx \frac{u(x_{i-1}, t^{n+1})-2u(x_i, t^{n+1})+u(x_{i+1}, t^{n+1})}{\Delta x^2}.$$
The difference quotient for the nonlinear term is more tricky and so far I don't have the complete answer. But under the assumption that we want to use a backward differences it should look like:
$$u(x,t) \partial_x u(x,t) \approx u(x_i, t^{n+1}) \frac{u(x_i, t^{n+1})-u(x_{i-1}, t^{n+1})}{\Delta x}.$$
Remark:
The problem for the discretization of this advection term, linear or nonlinear, is the stability of the resulting finite difference scheme. Using the backward difference like I did, one has to assure that the coefficient (here $u(x_i,t^n)$) is greater than zero. But there is a lot more theory behind that and this was not the relevant part of my question.
Having said that and again using the short form $u_i^n := u(x_i, t^n)$, we can write equation $(1)$ from the question above in the discretized form:
$$\frac{u_i^{n+1}-u_i^n}{\Delta t}+u_i^{n+1}\frac{u_i^{n+1}-u_{i-1}^{n+1}}{\Delta x}-\varepsilon\frac{u_{i+1}^{n+1}-2u_i^{n+1}+u_{i+1}^{n+1}}{\Delta x^2}=0. \tag{3}$$
That gives us the ability to define a function $F(v)$ with
$$F(v) := \begin{pmatrix}f_1(v_1) \\ f_2(v_2) \\ \vdots\end{pmatrix}$$
where
$$f_i(v_i) := \frac{v_i-u_i^n}{\Delta t}+\frac{v_i^2-v_i v_{i-1}}{\Delta x}-\varepsilon\frac{v_{i-1}-2v_i+v_{i+1}}{\Delta x^2}.$$
Now we can write equation $(3)$ as
$$F(u^{n+1}) = 0$$
and solve this set of nonlinear functions with a Newton method.
