Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Partial Differential Equations: The Heat Equation (Implementing the explicit sch

ID: 3751086 • Letter: P

Question

Partial Differential Equations: The Heat Equation (Implementing the explicit scheme)

Goal: In Matlab work through Example 5.4, to reproduce Figure 5.2. (Please include all Matlab code and explanations!)

I have attached exmaple 5.4 and figure 5.2 below. Thank you!

Example 5.4. Let us fix the diffusivity 1 and the interval length l I. For illustrative purposes, we take a spatial step size of .1. We work with the initial data 1- T, used earlier in Example 4.1. In Figure 5.2 we compare the numerical solutions resulting from two (slightly) different time step sizes. The first row uses (A2)2-01 and plots the solution at the indicated times. The numerical solution is already showing signs of instability (the final plot does not even fit in the window), and indeed, soon thereafter, it becomes completely wild. The second row takes .005. Even though we are employing a rather coarse mesh, the numerical solution is not too far away from the true solution to the initial value problem, which can be seen in Figure 4.1.

Explanation / Answer

dt=[0.01,0.04,0.005];
dx=sqrt(dt);
for i=1:length(dx)
interval=0:dx(i):1;
f=[];
for j=1:length(interval)
if(interval(j)>=0 && interval(j)<=(1/5))
f(j)=interval(j);
elseif(interval(j)>=(1/5) && interval(j)<=(7/10))
f(j)=interval(j)-(2/5);
else
f(j)=1-interval(j);
end
end
figure,plot(interval,f);
end