Before you turn this problem in, make sure everything runs as expected. First, restart the kernel (in the menubar, select Kernel\(\rightarrow\)Restart) and then run all cells (in the menubar, select Cell\(\rightarrow\)Run All).
Make sure you fill in any place that says YOUR CODE HERE or “YOUR ANSWER HERE”, as well as your name and collaborators below:
NAME = ""
COLLABORATORS = ""
Linear BVP#
This boundary value problem is linear.
\(y'' + y = 0\)
With boundary conditions \(y(0) = 0\) and \(y(\pi/2) = 2\)
First, derive the equations that approximate this equation using finite differences. You should write out the equations in a form that allow you to construct a set of linear equations, e.g. \(\mathbf{A} \mathbf{y} = \mathbf{b}\).
Part 2#
Next, write code to construct 𝐀 and 𝐛 , and solve for 𝐲 .
Show some evidence that your solution is reasonable
Finally, there is a known analytical solution to this equation: 𝑦=2sin𝑥 . Compare your answer to the known solution. Comment on any differences.
When you are done, download a PDF and turn it in on Canvas. Make sure to save your notebook, then run this cell and click on the download link.
%run ~/f23-06623/f23.py
%pdf