The add-on MTH229 package defines some convenience functions for this class. This package must be loaded during a session. The command is using MTH229, as shown. (This needs to be done only once per session, not each time you make a plot or use a provided function.)

For example, the package provides a function tangent that returns a function describing the tangent line to a function at x=c. These commands define a function tline that represents the tangent line to f(x)=sin(x) at x=π/4:


| using MTH229

| f(x) = sin(x)

| c = pi/4

| tline(x) = tangent(f, c)(x)

(To explain, tangent(f, c) returns a new function, for a pedagogical reason we add (x) on both sides so that when tline is passed an x value, then this returned function gets called with that x.)


The tangent line has the from y=mx+b. Use tline above to find b by selecting an appropriate value of x:
?



Now use tline to find the slope m:
?



Note, there are two ways to define tline, as above, or as:

| tline = tangent(f, pi/4)

Though both define a function (though technically differently), and the latter is easier to write and has other advantages, we suggest using the extra (x) on both sides, so that functions are defined consistently.