SUNY Geneseo Department of Mathematics
Misc
Emailed Reading Summaries
Please just use plain text in the body of the email, not attachments, etc.
Hour Exam 2
Next Wednesday, April 12
Covers material since first exam, e.g., if
statements, while
and for
loops, possibly algorithms we’ve studied such as Newton’s
method or numerical integration, etc.
Style and rules otherwise similar to first exam, especially open-references rule.
See the sample exam in the “Exam 2 Materials”
folder under the “Files” tab in Canvas.
Questions?
Debugger
Here’s an issue that came up in the Newton’s method lab:
- Using the
newton
function to find the root of f(x) = x3 (which
should be 0) with an initial guess of 12 and a tolerance of 0.4 produces 8 (a very poor estimate),
while with a tolerance of 0.3 and the same function and initial guess, newton
produces an answer very close to 0.
- Use the debugger to figure out why this is.
- You can download my newton.m and derivative.m
files from the “Lab Files” folder under “Files” in Canvas, or click
on the file names here, or use your own if they work.
Relevant ideas or questions from the debugger video
- Breakpoints let you pause execution at any line(s) of a program
- Insert breakpoints from the editor by clicking on the dash next to a numbered line.
- Use the step button to execute code line by line.
- The video’s example of a logical expression with an error shows how you can use
the command window to execute pieces of a complicated statement to see exactly where an error is.
- You can also add statements to your code to display key values.
- Conditional breakpoints?
- Let you pause only if control reaches a breakpoint and a condition is true (usually the
condition means “interesting” things are about to happen).
Try the debugger and see if you can explain what’s going on with newton
.
Comments.
- The overarching point of a debugger is to let you see step-by-step how a program executes.
- This can be either for finding bugs or for just understanding the program’s behavior
in detail.
- Breakpoints are how you pause the program.
- The step command, using the command window to explore individual expressions within a
statement, and conditional breakpoints are well covered in the summary.
- The workspace window shows the values of variables during debugging. You can also hover
over a variable name in the editor to see its value.
Next
Digital images.
Read “Introduction
to Digital Images” at http://www.geneseo.edu/~baldwin/reference/images.html