All published worksheets from http://sagenb.org
Image: ubuntu2004
A Smattering of Multivariate Calculus Commands
Tim McLarnan, Earlham College
Multivariate calculus is actually one of Sage's weaker areas. Sage's 3D graphics capability is somewhat awkward. Sage lacks a vector field class. The authors of Sage are clearly more interested in algebra and in number theory than in analysis. That said, Sage can still be used for the basic tools we need in Multivariate Calculus.
3D Plots
Vectors and Matrices
Matrices and vectors work pretty much the way you would expect, except that in keeping with a number of programming languages, entries and rows and columns are numbered starting at 0, not 1.
Notice that in this last product, v was treated as a row vector, and u as a column vector.
Here v was viewed as a column vector.
And here v was a row vector.
Although matrices can be written as simply as we did above, Sage would really rather we specified what ring the entries of any matrix lie in: the integers , which Sage writes as ZZ, the rationals , which Sage calls QQ, the reals , which is roughly Sage's RR, the integers mod 7, , which is Sage's Zmod(7), etc. Depending on what ring the entries lie in, some matrix operations will behave differently.
As a tool in teaching and learning, it's cute that Sage lets one do Gaussian elimination a step at a time, like this:
(Notice that the row operations don't return a new matrix, but that they modify the original matrix in place.)
Div, Grad, Curl, and All That
Weirdly, Sage has gradients built in, but not divergence or curl or even the vector fields for which these operators would make sense. Of course, we can implement these things ourselves, but it's somewhat shocking that we need to. Here are some very quick and dirty definitions of these functions assuming that the variables involved are , , and . The Sage wiki has a somewhat more professional version, but obviously Sage needs someone to build a proper vector field class.