Maple Worksheet
(With Guidance)
Math 356
February 1, 2007
  • Problem 1. A Prime Example.
    • Make a list of the prime numbers between 1 and 500.
    • Find their sum.
You can approach this problem in multiple ways. One way to start would be to declare an empty list (choose a variable, then define it to be []). Then write a for loop that checks each number up to 100 and sees if it is prime. (use ? prime (or something similar and hunt around to figure out what command to use.) In the do part of the loop, if the number is prime, add it onto the list, using op(). Don't forget to end your do loop. Next, add the numbers using add.
  • Problem 2. A Graphic Example.
    • Replicate Figures 1.27, 1.28a, 1.28b, and 1.28c.
You will need to use a for loop to generate the data. Then you will need to create a list of points (which are lists [x,y] themselves, where x is the x-coordinate and y is the y-coordinate) that you can feed into the plot function.
  • Problem 3. A Loopy Example.
    • Write a program that inputs a list L and uses iterated first differences to output a polynomial f(x) such that f(i)=L[i] for all i.

    (To make Problem 3 easier, you may assume that the polynomial is of degree 3 or less. You will get a bonus point if your program works for a polynomial of any degree on a list of finite length.)

Background for Problem 3: Given a list of numbers, you can determine if the list comes from a polynomial of degree n or less by seeing if the list of nth differences is constant.
As an example: If f(x)=5x+3, then [seq(f(i),i=1..5)]=[8,13,18,23,28]. The first differences are [5,5,5,5]. This tells us that f(x) is of degree 1 (linear).
[Make sure to investigate first what the second differences of L[i]:=i^2 are, the third differences of L[i]:=i^3 are, and the fourth differences of L[i]:=i^4 are.]

Guidance for Problem 3: One way to approach this problem is to create multiple functions (procedures) using proc to do the following tasks:
(a) Write a procedure first_diff that takes as input a list and gives as output a list of first differences.
(b) Write a procedure const_list that determines whether a list has all entries the same. (Input: list, Output: true or false.)
(c) Write a procedure list_degree that determines the degree of the polynomial that the data satisfy.
(d) Determine the polynomial that the data satisfy.


Back to the Maple Page.
Back to the Math 356 Home Page.