SUNY Geneseo Department of Computer Science
“If” Statements, Day 3
Friday, April 4
CSci 120, Spring 2014
Prof. Doug Baldwin
Return to List of Lectures
Previous Lecture
Misc
Hour exam 2 next Friday (Apr. 11)
- Material since 1st hour exam (for, while, if)
- Otherwise similar to 1st hour exam in style, rules
- Particularly open reference material
GREAT Day next Tuesday (Apr. 8)
- Go hear/see (or present your own) student posters, talks etc.
- No appointments that day
Remember that I want to talk to groups even in weeks when you haven’t finished a lesson—chance to answer questions, check progress, etc.
Questions?
“If” Statements
Finding derivative of distance
- Letting Matlab do it symbolically for you seems tempting, but it requires that you provide the expression for distance expanded all the way out to a big expression in t, and then you have to take an even bigger result expression and turn it into a Matlab function.
- Lots of room for typos in this, and they will be almost impossible to find afterwards
- Be really careful in your typing if you do the derivative this way
- Working it out by hand is easier than you may think
- A(t) and B(t) are the differences of the cosine or sine expressions for Earth’s and Mars’s positions—they look ugly, but mostly that is just strange constants and bulky but constant coefficients, i.e., things that are easy to differentiate. Once you remember the derivatives of sine and cosine the rest is pretty easy
- Also notice that this way of approaching the problem suggests some subexpressions that you can calculate once and store in variables in Matlab to use when needed—A and B in particular
Next Lecture