CalculusWithJulia.jl is a package for a set of notes for learning calculus using the
Julia languge. The package contains some support functions and the files that generate the notes being read now.
Since the mid 90s there has been a push to teach calculus using many different points of view. The Harvard style rule of four says that as much as possible the conversation should include a graphical, numerical, algebraic, and verbal component. These notes use the programming language Julia to illustrate the graphical, numerical, and, at times, the algebraic aspects of calculus.
There are many examples of integrating a computer algebra system (such as
Sage) into the calculus conversation. Computer algebra systems can be magical. The popular WolframAlpha website calls the full power of
Mathematica while allowing an informal syntax that is flexible enough to be used as a backend for Apple's Siri feature. ("Siri what is the graph of x squared minus 4?") For learning purposes, computer algebra systems model very well the algebraic/symbolic treatment of the material while providing means to illustrate the numeric aspects. Theses notes are a bit different in that
Julia is primarily used for the numeric style of computing and the algebraic/symbolic treatment is added on. Doing the symbolic treatment by hand can be very beneficial while learning, and computer algebra systems make those exercises seem kind of pointless, as the finished product can be produced much easier.
Our real goal is to get at the concepts using technology as much as possible without getting bogged down in the mechanics of the computer language. We feel
Julia has a very natural syntax that makes the initial start up not so much more difficult than using a calculator. The notes restrict themselves to a reduced set of computational concepts. This set is sufficient for working many of the problems in calculus, but do not cover thoroughly many aspects of programming. (Those who are interested can go off on their own and
Julia provides a rich opportunity to do so.) Within this restricted set, are operators that make many of the computations of calculus reduce to a function call of the form
action(function, arguments...). With a small collection of actions that can be composed, many of the problems associated with introductory calculus can be attacked.
These notes are presented in pages covering a fairly focused concept, in a spirit similar to a section of a book. Just like a book, there are try-it-yourself questions at the end of each page. All have a limited number of self-graded answers. These notes borrow ideas from many sources including Strang, Knill, Schey, Thomas Calculus, Rogawski and Adams, and several Wikipedia pages.
Before beginning, we need to get started with Julia. This is akin to going out and buying a calculator, though it won't take as long.
Julia can be used through the internet for free using the mybinder.org service. Click on the
CalculusWithJulia.ipynb file after launching Binder by clicking on the badge.
Many of the necessary computational skills needed for employing
Julia successfully to assist in learning calculus are in direct analogy to concepts of mathematics that are first introduced in precalculus or prior. This precalculus review, covers some of the basic materials mathematically (though not systematically). More importantly it illustrates the key computational mechanics we will use throughout.
A quick rundown of the
Julia concepts presented in this setion is in a Julia overview.
Taking for granted a familiarity with basic calculators, we show in these two sections how
Julia implements the functionality of a calculator in a manner not so different.
Calculators really only use one type of number - floating point numbers. Floating point numbers are a model for the real numbers. However, there are many different sets of numbers in mathematics. Common ones include the integers, rational numbers, real numbers, and complex numbers. As well, we discuss logical values and vectors of numbers. Though integers are rational numbers, rational numbers are real numbers, and real numbers may be viewed as complex numbers, mathematically, these distinctions serve a purpose.
Julia also makes these distinctions and more.
Vectors as a mathematical object could be postponed for later, but they are introduced here as the
Julia implementation makes an excellent choice for a container of one or more values. We also see how to work with more than one value at a time, a useful facility in future work.
An arithmetic progression is a sequence of the form $a, a+h, a+2h, \dots, a+kh$. For example $3, 10, 17, 24, .., 52$. They prove very useful in describing collections of numbers. We introduce the range operator that models these within
Julia and comprehensions that allow one to easily modify the simple sequences.
The use of functions within calculus is widespread. This section shows how the basic usage within
Julia follows very closely to common mathematical usage. It also shows that the abstract concept of a function is quite valuable.
A graphing calculator makes it very easy to produce a graph.
Julia, using the
Plots package, makes it even easier and more flexible.
Polynomials play an important role in calculus. They give a family of functions for which the basic operations are well understood. In addition, they can be seen to provide approximations to functions. This section discusses polynomials and introduces the add-on package
SymPy for manipulating expressions in
Julia symbolically. (This package uses the SymPy library from Python.)
The roots of a univariate polynomial are the values of $x$ for which $p(x)=0$. Roots are related to its factors. In calculus, the zeros of a derived function are used to infer properties of a function. This section shows some tools in
SymPy to find factors and roots, when they are available, and introduces the
Roots package for estimating roots numerically.
A rational expression is the ratio of two polynomial expressions. This section covers some additional details that arise when graphing such expressions.
Trigonometric functions are used to describe triangles, circles and oscillatory behaviors. This section provide a brief review.
The notion of a limit is at the heart of the two main operations of calculus, differentiation and integration.
Continuous functions are at the center of any discussion of calculus concepts. These sections define them and illustrate a few implications for continuous functions.
The derivative of a function is a derived function that for each $x$ yields the slope of the tangent line of the graph of $f$ at $(x,f(x))$.
The derivative of a function has certain features. These next sections explore one of the first uses of the derivative - using its zeros to characterize the original function.
The tangent line to the graph of a function at a point has slope given through the derivative. That the tangent line is the best linear approximation to the curve yields some insight to the curve through knowledge of just the tangent lines.
The derivative finds use outside of the traditional way of specifying a function or relationship. These two sections look at some different cases.
A generalization of the tangent line as the "best" approximation to a function by a line leads to the concept of the Taylor polynomial.
The integral is initially defined in terms of an associated area and then generalized. The Fundamental Theorem of Calculus allows this area to be computed easily through a related function and specifies the relationship between the integral and the derivative.
Integration is not algorithmic, but rather problems can involve an array of techniques. Many of these are implemented in
SymPy. Theses sections introduce the main techniques that find widespread usage.
Various applications of the integral are presented. The first two sections continue with the idea that an integral is related to area. From there, it is seen that volumes, arc-lengths, and surface areas may be expressed in terms of related integrals.
Ordinary differential equations are an application of integration and the fundamental theorem of calculus.
Univariate functions take a single number as an input and return a number as the output. Notationally, we write $f: R \rightarrow R$. More generally, a function might have several input variables and might return several output variables, notationally $F: R^n \rightarrow R^m$, for positive, integer values of $n$ and $m$. Special cases are when $n=1$ (a space curve) or when $m=1$ (a scalar-valued function). Many of the concepts of calculus for univariate functions carry over, with suitable modifications.
Polar coordinates are an often useful alternative to describing location in the $x$-$y$ plane.
The calculus of functions involving more than $1$ variable is greatly simplified by the introduction of vectors and matrices. These objects, and their associated properties, allow many of the concepts of calculus of a single variable to be carried over.
In general we will consider multivariable functions from $R^n$ into $R^m$ (functions of $n$ variables that return $m$ different values), but it is helpful to specialize to two cases first. These are vector valued functions ($f: R \rightarrow R^n$) and scalar functions ($f:R^n \rightarrow R$).
We discuss applications of the derivative for scalar functions. These include linearization, optimization, and constrained optimization.
The derivative of a mulitvariable function is discussed here. We will see that with the proper notation, many formulas from single variable calculus will hold with slight modifications.
Integral vector calculus begins with a generalization of integration to compute area to integration to compute volumes (and its generalization to higher dimensions). The integration concept is then extended to integration over curves and surfaces. With this, generalizations of the fundamental theorem of calculus are discussed.
We begin with the generalization of the Riemann integral to compute area to the computation of volume and its higher dimensional interpretations.
Line and surface integrals are computed by 1- and 2-dimensional integrals, but offer new interpretations, espcially when vector fields are considered.
There are three main operations in differential vector calculus, the gradient, the divergence, and the curl. This is an introduction to the two latter ones.
The fundamental theorem of calculus states that a definite integral over an interval can be computed using a related function and the boundary points of the interval. The fundamental theorem of line integrals is a higher dimensional analog. In this section, related theorems are considered: Green's theorem in $2$ dimensions and Stokes' theorem and the divergence theorem in $3$ dimensions.
Here is a quick review of the math topics discussed on vector calculus.
For reference purposes, there are examples of creating graphics for
A review of the
Julia concepts used within these notes.
Some different interfaces interfaces to
The CalculusWithJulia package.
Unicode symbol usage in
This is a work in progress. To report an issue, make a comment, or suggest something new, please file an issue. In your message add the tag
@jverzani to ensure it is not overlooked. Otherwise, an email to
math.csi.cuny.edu will also work.
To make edits to the documents directly, a pull request with the modified
*.jmd files in the
CwJ directory should be made. Minor edits to the
*.jmd files should be possible through the GitHub web interface. The
*.html files are generated using
Weave package. This need not be done.