MCS 471 Computer Project 1, hints


Here are some hints for using Maple to solve the problem posed in cp1. You need to gererate a point set which you can then graph. One way to do this in Maple is:

> longpoly := expand((x+2)^3);
# long poly is an epression in x
> hornerpoly := convert(longpoly,horner);
# horner poly is the horner form of the same expression.
> f1 := unapply(longpoly,x);
# The above line creates the function f1
> f2:= unapply(hornerpoly,x);
# the above line creates the function f2.
# we now use a function to generate a set of points at which we can 
# evaluate the function.  Here we use another way of defining a function:	
> pt:=i -> -1.00+i*0.2;
# note that pt is a function (i is just a dummy variable)
# we can now generate a set of points which can be plotted:
> ptset1 := [seq([pt(x),f1(pt(x))],x=0..10)]:
# and a second set:
> ptset2 := [seq([pt(q),f2(pt(q))],q=0..10)]:
# we can plot each set					 
> plot(ptset1);
> plot(ptset2); 
# or plot both sets together
> plot({ptset1,ptset2});
Note that if you specify the function by f := x -> expand((x+2)^3) and then substitute into the function f by computing f(3) the "expand" will never be used. What happens is that expand(125) is calcuated which just gives 125. If, on the other hand, you define f as f:=unapply(expand((x+2)^3),x) then f(3) is computed by substituting x=3 into x**3 + 6*x**2 +12*x + 8. This makes a big difference in the case of the function you are asked to plot in cp1.
Back to cp1
Back to Cover Page