While loops - Your turn#
Part 1#
In the demonstrated algorithm, \(x\) is a list containing all the successive approximations of \(\sqrt{10}\). We are usually interested only in the final result and don’t need to store each intermediate step. Modify the previous script so that \(x\) is now a scalar iterate that overwrites the previous one. Compute \(\sqrt{11}\) to an error of less than \(10^{-4}\), starting with \(x = 1\).
# TODO: Write your solution below
Part 2#
Using the modified code, determine how many iterations are necessary to reach the required accuracy.
Hint: Add a counter whose value is incremented by one each time you perform an iteration.
# TODO: Write your solution below
Exporting your work#
When you’re ready, the easiest way to export the notebook is to File > Print
it and save it as a PDF.
Remove any excessively long, unrelated outputs first by clicking the arrow → next to the output box and then Show/hide output
.
Obviously don’t obscure any necessary output or graphs!