# Help deriving a Fourier-Galerkin approximation for a variable coefficient partial differential equation

I've been trying to derive a Fourier-Galerkin approximation of

$$$$\frac{\partial u}{\partial t} + \sin(x) \frac{\partial u}{\partial x} = 0$$$$

But I'm not sure that my steps are correct. My steps are as follows.

First, derive a Fourier-Galerkin approximation of

$$$$\frac{\partial u}{\partial t} + \sin(x) \frac{\partial u}{\partial x} = 0$$$$

Next, express $$u$$ in terms of a Fourier expansion

$$$$u \approx u_n = \sum_{|n| \leq N/2} a_n(t) e^{inx}$$$$

Then the partial derivatives can be approximated as

$$$$\frac{\partial u_n}{\partial t} = \sum_{|n| \leq N/2} \frac{d a_n(t)}{dt} e^{inx}, \quad \frac{\partial u_n}{\partial x} = \sum_{|n| \leq N/2} in a_n(t) e^{inx}$$$$

and so

$$$$\frac{\partial u_n}{\partial t} + \sin(x) \frac{\partial u_n}{\partial x} = \sum_{|n| \leq N/2} \frac{d a_n(t)}{dt} e^{inx} + \sin(x) \sum_{|n| \leq N/2} in a_n(t) e^{inx}$$$$

The residual is

$$$$r_n = \sum_{|n| \leq N/2} \left(\sin(x) \cdot in a_n(t) + \frac{d a_n(t)}{dt} \right) e^{inx}$$$$

and projecting the residual onto $$B_N = \text{span}\{e^{inx}\}$$ yields

$$$$(r_n, \phi) = \int \sum_{|n| \leq N/2} \left( \sin(x) \cdot in a_n(t) + \frac{d a_n(t)}{dt} \right) e^{inx} e^{-inx} = 0$$$$

It follows then that

$$$$\int \sum_{|n| \leq N/2} \sin(x) \cdot in a_n(t) + \frac{d a_n(t)}{dt} = 0$$$$

from which we obtain a system of ODEs to determine the coefficients $$a_n$$

\begin{align} \sin(x) \cdot in a_n(t) + \frac{d a_n(t)}{dt} &= 0 \\ \implies \frac{d a_n(t)}{dt} &= -\sin(x) \cdot in a_n(t) \quad \forall |n| \leq N/2 \end{align}

Are my steps correct?

Moreover let's say I want to impose the boundary condition $$u(0, t) = u(\pi, t)$$, if my understanding of the method is correct I have to change my space $$B_n$$ accordingly to these boundary conditions. In this case, the periodic function that satisfies these boundary conditions is $$\sin(x)$$ and therefore $$B_n = \text{span}\{\sin(nx)\}$$. Am I correct?

• Thanks to the method of characteristics , solving $\frac{\partial u}{\partial t} + sin(x) \frac{\partial u}{\partial x} = 0$ gives the general solution : $$u(x,t)=F\left(e^{-t}\tan(x/2)\right)$$ where $F$ is an arbitrary function. The condition $u(0,t)=u(\pi,t)$ requires $F(0)=F(\infty)$. They are an infinity many functions satisfying this condition. Thus the specified condition is not sufficient to determine a unique solution. So far I doubt that the problem be well posed. Aug 11, 2020 at 8:29
• @JJacquelin it would be well-posed if I add the condition u(x, 0) = g(x), wouldn't it?
– Rage
Aug 14, 2020 at 7:12
• With the condition is $u(x,0)=g(x)$ instead of $u(0,t)=u(\pi,t)$ the solution is : $$u(x,t)=g\big(2\tan^{-1}(e^{-t}\tan(x/2))\big)$$ Aug 14, 2020 at 7:27
• @JJacquelin with both the conditions $u(x,0) = g(x)$ and u(0, t) = u(\pi, t)$not by replacing them. However, I'm looking for a Galerkin-Fourier formulation, not an analytical solution so I'm not really following why you are showing me these – Rage Aug 14, 2020 at 7:38 • Togheter the conditions$u(x,0)=g(x)$and$u(0,t)=u(\pi,t)$supposes$g(0)=g(\pi)$. If not there is no solution. If yes they are an infinity many solutions since an infinity many such functions$g$exist. The well-posedness or not depends on the function$g\$. This changes nothing to my preceeding comment. Nevertheless what ever one is looking for knowing the exact solution (analytical) generaly helps a lot. Of course all this is comment nothing else. If knowing the exact solution is of no help for you, just ignore the comment. Aug 14, 2020 at 9:04