Science:Math Exam Resources/Courses/MATH307/December 2012/Question 02 (b)
Work in progress: this question page is incomplete, there might be mistakes in the material you are seeing here.
• Q1 (a) • Q1 (b) • Q1 (c) • Q1 (d) • Q1 (e) • Q2 (a) • Q2 (b) • Q3 (a) • Q3 (b) • Q3 (c) • Q3 (d) • Q3 (e) • Q4 (a) • Q4 (b) • Q4 (c) • Q4 (d) • Q4 (e) • Q5 (a) • Q5 (b) • Q5 (c) • Q5 (d) • Q6 (a) • Q6 (b) • Q6 (c) • Q6 (d) • Q6 (e) • Q6 (f) •
Question 02 (b)
The boundary value problem
can be approximated by an (N + 1) x (N + 1) system of linear equations of the form
(b) How would you use MATLAB/Octave to compute approximations to and ? Assume that N has been defined and write code that uses this value of N.
Make sure you understand the problem fully: What is the question asking you to do? Are there specific conditions or constraints that you should take note of? How will you know if your answer is correct from your work only? Can you rephrase the question in your own words in a way that makes sense to you?
If you are stuck, check the hint below. Consider it for a while. Does it give you a new idea on how to approach the problem? If so, try it!
Science:Math Exam Resources/Courses/MATH307/December 2012/Question 02 (b)/Hint 1
Checking a solution serves two purposes: helping you if, after having used the hint, you still are stuck on the problem; or if you have solved the problem and would like to check your work.
Found a typo? Is this solution unclear? Let us know here.
Please rate my easiness! It's quick and helps everyone guide their studies.
Set dx, L, Q and b in Matlab to be equal to values above:
dx = 1/N
L = 1/dx2*[[dx2 0 0 0]; diag(ones(3),-1) + diag(-2*ones(3)) + diag(ones(3),1); [0 0 -dx dx]]
for m = 1:N
qVector(m) = m-1
qVector(N+1) = 0
Q = 1/dx*diag(qVector)
f = (L + dx2*Q)
Find index of value corresponding that has x closest to 1/2:
Find points corresponding to x values on either side or equal to 1/2 and approximate f(1/2) as point on line joining both points:
xi = floor((1/2)/dx)
xf = ceil((1/2)/dx)
m = (f(xf) - f(xi))/dx b = f(x0) - m(x0) ans = m(1/2) + b