Two-dimensional graphics with MapleMapleGetting started with MapleMaple functions, expressions, and equations

Maple functions, expressions, and equations

A common confusion in elementary mathematics classes is that a single symbol can have multiple meanings. For example, is the statement f(x)= x2+5x+6 the definition of a function, or is it an equation? A human distinguishes the different meanings from context, but a computer program needs to have different syntax or different data types in order to make a correct interpretation.

Thus Maple has different symbols for equality (2+2=4) and for assignment (A:=4). A function, written with a syntax like f:=x->x^2+5*x+6, is different from the expression x^2+5*x+6, and both are different from the equation f(x)=x^2+5*x+6.

Maple commands make sense only when applied to the right kind of object. You can differentiate a function via D(f), or you can differentiate an expression via diff(x^2+5*x+6,x). If f is an arrow-defined function, then f(x) is an expression. On the other hand, an expression can be converted into a function via unapply(x^2+5*x+6,x).

Occasionally, Maple is tolerant: you can solve the equation x2+5x+6=0 by using the command solve(x^2+5*x+6=0,x);, or by using the command solve(x^2+5*x+6,x);, or by using the command solve(x^2+5*x+6);. What do you think the Maple command solve({x+y+2,x-y-2},{x,y}); does? Try it to see. How many other ways can you find to write the same command?

On the other hand, Maple is sometimes quirky. Consider the following Maple session:

> a:=5: b:=7: f:=x->a*x+b;
              f := x -> a x + b

Why doesn't Maple respond f := x -> 5x + 7 instead? This is a situation in which Maple behaves better with expressions than with functions. To get the expected result (as an arrow-defined function), you have to tell Maple f:=unapply(a*x+b,x);.

Exercise

  1. Use Maple to find a third-degree polynomial whose values at the positive integers 1, 2, 3, 4 are 2, 3, 5, 9.

    In other words, find p(n) of the form an3+bn2+cn+d such that p(1)=2, p(2)=3, p(3)=5, p(4)=9. Try doing this by setting up four simultaneous linear equations in the four unknowns a, b, c, d and using Maple's solve function; then you can use Maple to substitute the values of a, b, c, d back into p, for instance with the subs command or the assign command.

  2. Look in Maple's help browser for commands related to interpolation. See if you can find a single simple Maple command that will solve the above problem in one step.

  3. Run the following Maple loop:

           for i from -10 to 10 do
                  p(i);
                  od;
    

    and observe that these values of the polynomial p are integers, even though the coefficients of p are fractions. Can you find a proof that p(n) is an integer for every integer n? (You do not necessarily have to use Maple in the proof.)

  4. Go back and edit your Maple worksheet to clean up the presentation. Put in some sentences of explanation. (You can use the Insert menu to insert text, in-line mathematics, new Maple command prompts, and so forth.) In particular, put your name at the top of your worksheet, formatted with the Author style. Use the Print feature on the File menu to print your worksheet.

Remark: This problem is a special case of a general theorem. G. Pólya proved [Über ganzwertige ganze Funktionen, Rend. Circ. Mat. Palermo 40 (1915) 1-16] that the polynomials that take integer values at all integer points are precisely the linear combinations with integral coefficients of the "binomial polynomials" of the form x(x-1)...(x-k+1)/k!, where k=0, 1, .... See Manjul Bhargava, "The factorial function and generalizations", American Mathematical Monthly 107 (2000), number 9 (November), 783-799.


logo The Math 696 course pages were last modified April 5, 2005.
These pages are copyright © 1995-2005 by Harold P. Boas. All rights reserved.
 
Two-dimensional graphics with MapleMapleGetting started with MapleMaple functions, expressions, and equations