samuelaplc

2022-10-07

$\frac{\mathrm{\partial }y}{\mathrm{\partial }t}+c\frac{\mathrm{\partial }y}{\mathrm{\partial }x}=0,$
$y=cos\left(x\right),t=0,$
$\frac{\mathrm{\partial }y}{\mathrm{\partial }t}=csin\left(x\right),t=0$
has a solution
$y=cos\left(x-ct\right).$
I wanted to expand both the derivatives as centeblack differences. So, in order to expand my derivatives, I did as shown below;
$\frac{y\left(i+1\right)-y\left(i-1\right)}{2\Delta t}+c\left(\frac{y\left(i+1\right)-y\left(i-1\right)}{2\Delta x}\right)=0$
$\frac{y}{\Delta t}+c\left(\frac{y}{\Delta x}\right)=0$
Now, I also intend to prove that the algebraic solution is an exact solution of the difference formula if I choose $\Delta x=c\Delta t$. How do I achieve this goal?

Jane Reese

Your time-discretization in your update to your post is not right. Please note how I have indicated it in the comment above - there are 2 indices, one (subscript i) indicates the x dimension and the other (superscript n) indicates the time dimension. Your teacher should have taught you this. Anyway, look at equation 29 on this linked doc. For this problem, you don't even need to think about indexes, just that you are representing $\frac{\mathrm{\partial }y\left(t,x\right)}{\mathrm{\partial }x}$ as $\frac{y\left(t,x+\mathrm{\Delta }x\right)-y\left(t,x-\mathrm{\Delta }x\right)}{2\mathrm{\Delta }x}$. Similarly for $\frac{\mathrm{\partial }y\left(t,x\right)}{\mathrm{\partial }t}$ in terms of $\mathrm{\Delta }t$

Now, to show the $y=\mathrm{cos}\left(x-ct\right)$ satisfies the equation when the "grid speed" $\frac{\mathrm{\Delta }x}{\mathrm{\Delta }t}$ equals the wave speed $c$, just plug in $y=\mathrm{cos}\left(x-ct\right)$ into the discretized equation you just created.

You will need the trigonometric identity
$\mathrm{cos}\left(x\right)-\mathrm{cos}\left(y\right)=-2\mathrm{sin}\left(\frac{x+y}{2}\right)\mathrm{sin}\left(\frac{x-y}{2}\right)$
And indeed, when grid speed equals wave speed, the LHS of the discretized equation, then evaluates to zero, which is the RHS.

Do you have a similar question?