TeachE Documentation

NonGraphics Routines

CSpline

CSpline[data,var] provides a cubic spline approximation with independent variable var to the list of points data.

data = {{0,0.702},{1,0.871},{2,0.110},{3,-0.096},
{4,-0.256},{5,-0.807},{6,-0.378},{7,1.130},
{8,1.266},{9,-0.639},{10,-1.670}};
Define[c[x] = CSpline[data,x]];
c[x]
PlotE[c[x],data,{0,10}];

DiffE, IntegratE, and NIntegratE

TeachE provides enhancements for the commands D, Integrate, and NIntegrate to make the syntax more flexible. The enhanced commands are named DiffE, IntegratE, and NIntegratE, but these commands are intended to be used only through automatic conversion of D, Integrate, and NIntegrate, as shown in the examples below. (In order for this to work, EOn must be in effect.)
    All three commands no longer require the active variable to be specified if there is only one choice. You can specify the number of derivatives in DiffE by just putting a positive integer at the end. DiffE and IntegratE can be successfully applied to piece functions.

DiffE[Sqrt[1+x^2]]
DiffE[Sqrt[1+x^2],x]

DiffE[Sqrt[1+x^2],4]

DiffE[x^n,x,3]

IntegratE[Sqrt[1+x^2]]
IntegratE[Sqrt[1+x^2],{0,1}]
NIntegratE[Sqrt[1+x^2],{0,1}]

DefinE[f[x] = Piece[x^2,{0,1},1-x,{1,2}]]
DiffE[f[x]]
IntegratE[f[x]]

Difference & PartialSum

Difference and PartialSum are operations for lists of numbers and sequences.

Difference[list] will produce the list of differences between successive 
    entries of the form list[[n+1]]-list[[n]].
Difference[seq,{var,min,max}] will do the same for the list 
    Table[seq,{var,min,max}], where seq is a formula for a sequence. 
Difference[seq] will compute the formula for the difference sequence.

PartialSum[list] will produce the list of partial sums of list.
PartialSum[seq,{var,min,max}] will do the same for the list   
    Table[seq,{var,min,max}], where seq is a formula for a sequence. 
PartialSum[seq] will compute the formula for the sequence of partial sums. This use requires you to first load the standard package Algebra`SymbolicSum`. A disabled command for doing so is included under the "Begin" section of the package, which can enable if you wish.

data = {1, 2, 3, 5, 12, 18, 38, 54, 104, 256};
Difference[data]

Difference[N[Log[n]],{n,1,10}]

Difference[n^3-4n]

PartialSum[data]

PartialSum[1/3^n,{n,0,10}]

PartialSum[N[Log[n]],{n,1,10}]

PartialSum[n^3-4n]

DRule

DRule[expr] provides the rule required to differentiate expr.

DRule[Sin[x]/(1 + x)]

Clear[f];
DRule[f[x]^5]

DRule[Tan[3x]]

ÒBasic RuleÓ means the derivative of a specific function that you should know, in case the derivative of the tangent function.

Euler

Euler[slope,start,incr,steps] computes a list of points beginning with the point start, then repeating steps times the procedure of adding incr to the first coordinate and incr*slope to the second coordinate. slope can be a function of both the horizontal and vertical variables. The variables used are determined by those occuring in slope and by the Variables option.

Euler is a simple method of numerically approximating the solution of differential equations of the form y'(x) = f(x,y).  The following example illustrates this method applied to the equation y'(x) = x/y.

data = Euler[x/y,{0,1},0.2,10]
PlotE[data,{0,2},Square,Both,Field[x/y]];

FindInverse

The command FindInverse[func] attempts to find and simplify a formula for the inverse function of func. Its success is limited by the frequent inability of the Solve command to find exact solutions.

FindInverse[x/(1+x^2)]

Formats

The following code is contained in TeachE, and results in the numerical constant "e" being printed as "e" in all output instead of as "E". You may not like this; feel free to remove or disable this code if you wish. Or you can use this as an example for experimenting with formatting on your own.

Unprotect[E]; 
Format[E] = "e";
Protect[E];

ImplicitD

ImplicitD[expr] attempts to carry out implicit differentiation.
ImplicitD[expr,n] attempts to find an implicit derivative of order n. (Warning: This has not been test past order 2!)

ImplicitD[x^2 + y^2]

ImplicitD[x^2 + y^2,2]

ImplicitD[x^2 + y^2 == 1]

ImplicitD[x^2 + y^2 == 1,2]

ImplicitD[Cos[x y] + Sin[x y] == x + y + 1]

Improper

Improper[f,{a,b}] creates a table of numerical integrals of the function f over successively larger subintervals of {a,b} as an aid to determining the convergence of the integral of f over {a,b}.  a can be -Infinity and b can be Infinity. The options Factor->10 and Steps->6 control the creation of the table. Options and keywords for TablE may also be included.

The option Factor determines the rate at which the endpoints of the subinterval approach the endpoints of the given interval. If a given endpoint is finite, corresponding endpoints of the subintervals are each Factor times closer than the previous one to the given endpoint. If a given endpoint is infinite, corresponding endpoints of the subintervals are each Factor times larger than the previous one.
    The option Steps tells how many subintervals to use. Values for this option can also be given in the form '6 Steps'.
    The default is to have the subintervals approach both endpoints from the interior. By including one of the keywords Left or Right, you can approach only that endpoint and fix the other.

Improper[1/x,{0,1},Left,3 Steps];

Improper[1/x^(3/2),{1,Infinity},Factor->20];

Improper[1/x^2,{-Infinity,-1}];

Improper[1/Sqrt[1-x^2],{-1,1},10 Places];

Integral

TeachE provides routines to calculate the step-by step results of substitution and integration by parts techniques. I am skeptical of the value of these tools, but offer them for your consideration anyway. Both commands operate upon items of the form Integral[expr,var]. An interesting associated routine is InvTrigSimp[expr], which simplifies expressions of the form Trg[ArcTrg[x]] occurring within expr.

Subst[Integral[2x Cos[x^2],x],u == x^2]

Subst[Integral[2x Cos[x^2],x],u == x^2,Finish]

IBP[Integral[Log[x],x],u == Log[x]]
IBP[%,1]

IBP[#,1] effectively says "do the integral".

InvTrigSimp[Tan[ArcSec[t]]]

InterP

InterP[data,degree,var] is a generalization of the standard InterpolatingPolynomial command. If data is a list of two-dimensional data points, InterP generates a piece function using polynomials of degree  degree and variable var which pass through the points in data.

data = {{0,0.819},{0.01,-1.563},{0.02,-1.258},{0.03,1.},
{0.04,0.425},{0.05,0.256},{0.06,1.101}};

Define[L[t] = InterP[data,1,t]];
L[t]
PlotE[L[t],data,{0,0.06}];

Define[q[t] = InterP[data,2,t]];
q[t]
PlotE[q[t],data,{0,0.06}];

Define[c[t] = InterP[data,3,t]];
c[t]
PlotE[c[t],data,{0,0.06}];

LimitPict

LimitPict[lim,epsilon] is used only inside a PlotE command. It generates graphics illustrating the vertical region within epsilon of the value lim.

Define[a[n] = (Sqrt[3n^2+2n])/(4n + Cos[n])];
PlotE[a[n],{1,100},{0.4,0.5},Dots,
	LimitPict[Sqrt[3]/4,0.01]
];

RandomFunction

The command RandomFunction[var] generates a "random" elementary function with variable var.

RandomFunction[x]

Repeat as needed.

Special Functions

The function J0(x), the ordinary Bessel function of order 0, is defined by this package as J0[x], a substitute for BesselJ[0,x]. This provides a convenient non-elementary function to use in examples.

PlotE[J0[x],{-10,10}];

TrigSolve

TrigSolve[eqn] solves the simple trigonometric equation eqn, giving a list of solutions between 0 and 2 Pi. TrigSolve[eqn,{min,max}] gives solutions between min and max. In this release TrigSolve only handles equations of the form Trg[var] == c, or equations that easily reduce to this form. Trg can be any of the six trigonometric functions and c is a constant.

As with SolvE and NSolvE, TrigSolve accepts equations with a single equals sign, and answers will not be given in Rules form unless the keyword Rules is included.

TrigSolve[4 Sec[x] + 2 == 7,{-10,10},Rules]

Vectors

Some alterations are made to Dot and a function Cross is defined for calculating cross products. Both expand symbolic expressions and to deal with vectors in i-j-k notation. The routine ijkForm[vec] converts a two- or three-dimensional vector vec into i-j-k notation, and ijkSub[vec,dim:3] converts a vector vec of dimension dim (2 or 3) in i-j-k notation back to standard form.

(3i - 2j + k).(7i +3k)

(b + 4c).(3b - c)

Cross[3i - k,i + 2j + k]

ijkForm[{3,4,-5}]

ijkSub[2i - j + 6k]

Graphics Routines

Newton

Newton[func,x0] applies Newton's Method for finding roots to the function func with a starting point of x0. Optional items include those of the form n Steps and n Digits or n Places, indicating how many times to repeat Newton's Method and how many significant digits or decimal places to display. Newton will display a table of results unless the keyword Hide is included. A graph will drawn if an interval for plotting is included.

Newton[Cos[x] - x,1,5 Steps];

Newton[Cos[x] - x,1,5 Steps,Hide]

Newton[Cos[x] - x,1,{0.6,1.2}];

Newton[Cos[x] - x,1,{0.7,0.8}];

Newton[Cos[x] - x,1,5 Steps,16 Digits];

Riemann

Riemann[func,{min,max},items] calculates the Riemann sum of the function func over the interval {min,max}. The default method is to use 8 subintervals and evaluation at midpoints.

Riemann[Sin[x],{0,Pi}]

Including the keyword Show plots a graphic as well. For 10 subintervals or fewer, the ticks on the x-axis match the division points of the subintervals.

Riemann[Sin[x],{0,Pi},Show]

You can change the number of subintervals used by including a positive integer.  You can also give the division points directly in a list if you don't want subintervals of equal length. You can specify evaluation methods using the keywords Left, Right, Mid, Random, Upper and Lower.

Riemann[Sin[x],{0,Pi},20,Show]

Riemann[Sin[x],{0,Pi},Mid,{0,Pi/6,Pi/3,Pi/2,3Pi/4,Pi},Show]

Riemann[Sin[x],{0,Pi},Left,Show]

Riemann[Sin[x],{0,Pi},Right,Show]

Riemann[Sin[x],{0,Pi},Random,Show]

Riemann[Sin[x],{0,Pi},Upper,Show]

Riemann[Sin[x],{0,Pi},Lower,Show]

Riemann can be used with two functions and dealing with the area between them.

Riemann[{-Sqrt[36 - 4x^2]/3,Sqrt[36 - 4x^2]/3},{-3,3},
10,Lower,Show,Frame]

Riemann[{Sin[x],Cos[x]},{0,Pi/4},10,Upper,Show]

Riemann[{Sin[x],Cos[x]},{0,Pi/2},10,Lower,Show]

Riemann can also be used with functions of the vertical variable. Items appropriate for PlotE can be included in a Riemann command.

Riemann[{y^2,4 - y^2},{-2,2},10,Upper,Show,10 Places,
Interval->{-Sqrt[2],Sqrt[2]},{0,4},Frame]

Options for Riemann

Dots->True

Draws dots at the points used for evaluation. You can use Dots or Nodots keywords in place of this option.

Digits->6

Controls display of result. You can use n Digits or n Places keywords in place of this option.

Evaluation->Mid

Controls the default evaluation method. Keywords shown above can be used to specify method.

Interval->Automatic

Allows you to specify an interval for plotting different from that used for the Riemann sum, as shown in the last example.

RectStyle->{Cyan,Magenta,Gray}

Specifies the styles for positive rectangles, negative rectangles, and borders.

SubIntervals->8

Controls the default number of subintervals used.

Trapezoidal & Simpson

Trapezoidal[func,{min,max},subs] and Simpson[func,{min,max},subs] are commands for numerically approximating the value of a definite integral. They are similar to Riemann but do not have as many features. The following examples should be sufficient to demonstrate their use.

Trapezoidal[Sin[x],{0,Pi},4,Show]

Simpson[Sin[x],{0,Pi},4,Show,10 Digits]

Cobweb

Cobweb[func,{min,max},start,reps] is a command that shows graphically the effect of an iterated function func, starting with value start and iterating reps times, plotted over the interval {min,max}. You can append items intended for PlotE, and Square is often a good choice. Cobweb also outputs the result of NestListE[func,start,reps].

Cobweb[4x-4x^2,{0,1},0.6,10,Square]

Movies!

Three "movie makers" are included for your viewing enjoyment:
SlopeMovie[func,{a,b},{c,d},frames],
DerivMovie[func,x0,{a,b},{c,d},hlist], and
ParaMovie[para,{t,a,b},frames].
In each case you can append items intended for PlotE. 
Here are examples of each:

SlopeMovie[Sin[x],{-Pi,Pi},{-2,2},8];

DerivMovie[x^2,1,{0,2},{0,4},
{0.5,-0.5,0.2,-0.2,0.1,-0.1,0.05,-0.05,0.01,-0.01},
Tangent->False];

ParaMovie[{Cos[3t] Cos[t],Cos[3t] Sin[t]},{t,0,Pi},24,
	{x,-1,1},Square];

DrawArea

DrawArea[func,{min,max},a,b] plots func on the interval {min,max} and fills the area between the graph and the x-axis in the interval {a,b}.
AreaGraph[func,{min,max},a,b] plots the graph on the interval {min,max} of the function measuring the area under the graph of func between a and x, where x runs from a to b.

DrawArea[Sin[x],{0,Pi},1,2];

AreaGraph[Sin[x],{0,Pi},1,2,{0,1.5}];

Plot3DE Documentation

Plot3DE is an experimental preliminary version. I have vague plans to expand it considerably in the fashion of PlotE. Let me know what you would like to see in a comprehensive 3-D plot routine!
    There are really only three new features of significance in this version. One is an option for producing surfaces of revolution, illustrated below with examples. 
    The second is a set of keywords to produce certain commonly used views. std produces the default Mathematica viewpoint (with some enhancements), and xyz, xzy, yxz, yzx, zxy, and zyx produce standard textbook views, with the first variable axis perpendicular to the screen in perspective, the second and third variable axes horizontal and vertical in the plane of the screen.
    The third new feature is the ability to plot several surfaces at once just by listing the functions in the command.

Plot3DE[y == Sqrt[x],{0,4},Revolution->x,std];

Plot3DE[y == Sqrt[x],{0,4},Revolution->x,zxy];

Plot3DE[y == Sqrt[x],{0,4},Revolution->x,xyz];

Plot3DE[y == Sqrt[x],{0,4},Revolution->x,yzx];

Plot3DE[y == Sqrt[x],{0,2},Revolution->y,zxy,
BoxRatios->{2,1,1}];

Plot3DE[{y == Sqrt[x],y == x^2},{0,1},Revolution->x,
zxy,BoxRatios -> {1,2,2}];

Plot3DE[{y == Sqrt[x],y == x^2},{0,1},Revolution->{x,Pi,2Pi},
zxy,BoxRatios -> {1,2,1}];

Plot3DE[y == Sin[x],{0,2Pi},Revolution->{y==1},std];

Plot3DE[x + y,x^2 + y^2,{-2,2},{-2,2},std];