This repository contains the course materials from Math 157: Intro to Mathematical Software.
Creative Commons BY-SA 4.0 license.
License: OTHER
Math 157: Intro to Mathematical Software
UC San Diego, winter 2018
January 24, 2018: SageMath (part 2 of 3)
Administrivia:
Homework 2 is due Friday, January 26 at 8pm. If you do not have it, contact course staff immediately.
We are continuing to monitor the course waitlist. If you are on it and still want to join the course, please continue to keep up with lectures and homework, and watch your email for further instructions.
Finding Roots: symbolic
You can use the solve command to solve for zeroes of a function.
File "<ipython-input-67-d6dc05fa28e5>", line 1
x**Integer(2)+Integer(3) = Integer(5) # This is an error; a Python assignment cannot have a complex expression on its left-hand side.
SyntaxError: can't assign to operator
Here we numerically find a single zero of a function in a given interval.
One can also turn a symbolic expression into a numerical approximation, to any desired accuracy (with some caution).
In order to obtain an answer which is guaranteed to have all reported digits be accurate (assuming no bugs in CoCalc, cosmic rays, or other irreproducible phenomena), one can use interval arithmetic. This is like keeping track of "error bars". It is somewhat less efficient, and so not commonly used in "real-life" applications; but it absolutely essentially if you want to use real-number arithmetic as the basis of a mathematical proof, as in the solution of the Kepler conjecture.
More about 2d plots
You can do much more than just plot(function...)
. E.g.,
a point
a bunch of points
text
"line" through a bunch of points
polygon
ellipse
implicit plot
contour plot
vector field