Math 480b: Homework Assignment 5
Due: Thursday, May 26 by 11:30pm.
{{{id=7|
///
}}}
Instructions: Do all the following 3 problems. You may have to explore the Sage documentation to figure out how to do some of these problems (that's part of the point of the problem). The lecture notes from class should also be very helpful.
{{{id=9|
///
}}}
Problem 1: Symbolic Calculus.
- Compute the derivative with respect to $x$ of $\sin(x)\cos(\sin(x)) \arctan(x) + e^{x^2 \cos(y)}$.
{{{id=19|
///
}}}
- Compute a symbolic integral with respect to $x$ of the function $f(x) = \sin(x) \cos(x) \tan(x) e^x$
{{{id=21|
///
}}}
- Compute limit as $x\to 0$ of the function $f(x) = \sin(x^2)/x + (\cos(x)-1)/x$. Also, draw a plot of $f(x)$ on the interval $(-1,1)$.
{{{id=22|
///
}}}
{{{id=6|
///
}}}
{{{id=25|
///
}}}
{{{id=24|
///
}}}
{{{id=41|
///
}}}
Problem 2: Fast Expression Evaluation.
- Draw a plot of where the function $f(x,y) = x\sin(y) - \cos(y)\cos(x)$ is equal to 0 using the Sage function implicit_plot.
{{{id=26|
///
}}}
- Use fast_float to create a callable Python object $g$ from $f$. Then benchmark the difference in speed between evaluating $f$ at $(0.0, 0.0)$ versus evaluating $g$ at $(0.0, 0.0)$ using timeit.
{{{id=31|
///
}}}
{{{id=32|
///
}}}
{{{id=34|
///
}}}
- Implement a function $h$ in Cython that takes two floats x, y as input and returns $f(x,y)$. How fast is it? (Make sure to look at the lecture notes from May 14, 2010.)
{{{id=33|
///
}}}
{{{id=30|
///
}}}
{{{id=28|
///
}}}
- Use the scipy function scipy.optimize.fmin to find a zero of $f(x,y)$ by finding a local minimum of the function $f(x,y)^2$ on the plane, where you should start the optimization at the initial point $(0,0)$. Time using $f$, $g$, and $h$ as input to scipy.optimize.fmin. Hint: scipy.optimize.fmin expects a callable f that takes a single input z with x=z[0] and y=z[1]. So you may want to write code like this: scipy.optimize.fmin(lambda z: f(z[0],z[1])^2, (0,0))
{{{id=39|
///
}}}
{{{id=43|
///
}}}
{{{id=40|
///
}}}
{{{id=37|
///
}}}
{{{id=36|
///
}}}
{{{id=27|
///
}}}
- Draw a plot that includes both the implicit_plot above and a big red dot at the local minimum that fmin found.
{{{id=5|
///
}}}
{{{id=46|
///
}}}
- Create an interact that looks like the image below. There are two sliders which allow you to select an $(x,y)$ point. Once you select that point it is used as the starting point for the fmin iteration, and a blue dot is plotted at that point and a red dot at the zero that fmin finds. The sliders should allow you to select $x,y$ values between -1 and 1.

{{{id=48|
///
}}}
{{{id=44|
///
}}}
{{{id=49|
///
}}}
{{{id=45|
///
}}}
{{{id=4|
///
}}}
Problem 3. Matrices
- Create $8\times 8$ matrix $M$ whose $i,j$ entry (for $0\leq i, j \leq 7$) is the last digit of $i^2+j^2 + ij -i +1$. Create $M$ as a Sage matrix with integer entries.
{{{id=50|
///
}}}
{{{id=53|
///
}}}
- Compute the following invariants of this matrix $M$: determinant, rank, nullity, kernel, and characteristic polynomial.
{{{id=3|
///
}}}
{{{id=14|
///
}}}
{{{id=16|
///
}}}
{{{id=18|
///
}}}
{{{id=54|
///
}}}
{{{id=57|
///
}}}
- Create the same matrix as $M$ (call it $N$), but with entries in the "double precision" real numbers. (In Sage, this means the ring RDF.) Then compute all the same invariants as above for this new matrix $N$.
{{{id=56|
///
}}}
{{{id=55|
///
}}}
{{{id=59|
///
}}}
{{{id=60|
///
}}}
{{{id=1|
///
}}}
{{{id=61|
///
}}}
{{{id=63|
///
}}}
{{{id=62|
///
}}}