Consider the equation (a) Write a MATLAB program that solves the diffusionreaction problem on the domain x

Question:

Consider the equationdc dx2 -c=0

(a) Write a MATLAB program that solves the diffusion–reaction problem on the domain x ∈ [0, 0.5] subject to c(0) = 1 and c(0.5) = 0. Your program should generate two plots: (i) the numerical solution and the exact solution for Δx = 0.01 and (ii) the norm of the difference between the numerical and exact solution for values of Δx between 0.001 and 0.5. Explain the behavior in the plot of the error.

(b) Now let’s see how well the program from part (a) can solve the same problem for the unbounded domain x ∈ [0,∞) with c(0) = 1 and c → 0 as x→∞. Modify your program so that you can change the upper bound. The new program should produce three plots: (i) the exact solution and numerical solution using an upper bound of x = 0.5 for the numerical solution, which is the same as part (a); (ii) the same plot with an upper bound x = 15; and (iii) a comparison of the error between the exact and numerical solution as a function of the upper bound for values between these two limits. Explain the behavior in the plot of the error. It may be useful to look at the results for c(x) in semilogarithmic plots to understand the error.

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: