Author Archives: lipshitz@uoregon.edu

Singular weather decomposition

The topic this week is the Singular Value Decomposition. In class, I talked about an example using weather data; we’ll walk through that example again here. The basics Given a matrix A, A.singular_values() returns the singular values of A, and A.SVD() gives the singular value decomposition. There’s a wrinkle, though: Sage only knows how to compute […]

Posted in Uncategorized | Leave a comment

Plotting Differential Equations

(I am continuing to use a Jupyter notebook, as in the previous two posts.) CoCalc (Sage) will solve systems of linear differential equations with constant coefficients exactly. (In fact, it will solve a fairly wide range of differential equations either exactly or numerically.) It can also plot the results. For example, to solve the system […]

Posted in Uncategorized | Leave a comment

Fourier Series

(I’m continuing to use a Jupyter notebook, as in the last post, Least Squares.) Sage has some rudimentary support for Fourier series, as part of the “piecewise-defined function” class, but it seems to be very slow and very flaky. Let’s implement our own. To make things run reasonably efficiently, we’re going to have Sage do […]

Posted in Uncategorized | Leave a comment

Least-squares

For fun this week, I’ll use Jupyter notebooks inside Sage, which you create like this: To turn on pretty output (typesetting), type %display typeset. As far as I know, Sage does not have a built-in method to find a “least-squares solution” to a system of linear equations. The description of a least squares solution to […]

Posted in Uncategorized | Leave a comment

Dot Products and Orthogonality

These computations are easy in Sage, with some quirks. Dot products v=vector([1,2,3]) w = vector([1,1,1]) v.dot_product(w) v*w v.norm() Testing whether sets are orthogonal, orthonormal The easiest way to test whether a set of vectors v_1, …, v_k is orthogonal is: Create a matrix A=[v_1 … v_k] with the vectors as its columns. Compute A^T*A, the […]

Posted in Uncategorized | Leave a comment

Complex Numbers

This week, the main new computational topic is complex eigenvalues and eigenvectors. CoCalc finds complex eigenvalues / eigenvectors by default, so we already know how to find complex eigenvectors: A = matrix([[1,-2],[1,3]]) A.eigenvalues() A.eigenvectors_right() Note that CoCalc (Sage) uses “I” to stand for i, the square root of -1. (This choice is because “i” is often […]

Posted in Uncategorized | Leave a comment

Eigenvectors and Eigenvalues

Finding eigenvectors and eigenvalues is hard. Our general strategy was: Compute the characteristic polynomial. For an n x n matrix, this involves taking the determinant of an n x n matrix with entries polynomials, which is slow. (The fast method for computing determinants, row reduction, doesn’t help much since the entries are polynomials.) Find the roots […]

Posted in Uncategorized | Leave a comment

Matrix Operations in CoCalc

This post’s goal is to quickly get up to speed with doing linear algebra manipulations in Sage. Work through this, typing the code into Sage. Remember to press shift-return after each piece of code. Start by creating a new Sage worksheet. Pretty printing To make the matrices look nicer, type: %typeset_mode True and press shift-return. […]

Posted in Uncategorized | Leave a comment

Getting Started

This post contains detailed instructions for creating your first worksheet on CoCalc. It should take you about 15 minutes to work through. (Click on any of the screen shots below for a bigger version.) Visit https://cocalc.com .  You will see a screen where you can create an account: Fill out the form, using a real e-mail […]

Posted in Uncategorized | Leave a comment
Skip to toolbar