Math/CSE 1560 Lab 5

Exercise: Writing procedures and functions in Maple

Objective
The objective of this exercise is to test your familiarity with writing your own procedures and functions in Maple.

Grading
This lab exercise is worth 10% of the course. It is meant to be completed in the lab, individually (Collaboration is NOT allowed for this exercise).

NOTE: This is a 2 hour lab. The submission server will close shortly after 4:30 pm. You will not be able to submit your work after that time.

Starting off:

  1. Log in to a Gauss lab (aka AML) computer. If you have trouble, ask a system support staff. The TA will not be able to help you wih account/login/password issues.
  2. Open Maple 12 by clicking on the icon marked as such. If Maple does not start, let the TA know immediately. If asked, choose to start a new worksheet.
  3. You should now see the standard 2-d or math view of Maple.
  4. On the first 2 lines, enter your name and student number as comments -- start the lines with character # to indicate to Maple that these are not to be interpreted as Mathematical statements. Then save the file as`lab5.mw` by clicking on `File` and then `save as`.

Problems
Note: You are free to use piecewise() and if-then statements as you wish. However, if you wish to use piecewise, use cond-val pairs as mentioned in class, instead of implicit or default values.

  1. (4 points) Write a function that takes 6 integers as inputs and returns the largest integer. For full credit, type check each input. Test your function with a variety of test cases that you can think of, including real numbers. Do not use the max() function in this question.
  2. (4 points) Write a procedure that takes in 3 integers n, i and j and returns the ith and jth least significant digits of n as a set. You must typecheck each input and also print an error message (the precise message is not important) if either i or j is greater than the number of digits in n.
  3. (4 points) Write a procedure that takes an integer n and returns the largest digit that is not in n. You can use the max() function of Maple if you like.
  4. (4 points) Write a procedure that takes as input an integer n and returns the set of all integers in 1..n that are not powers of 2. E.g. in the range 1..10, 1, 2, 4,8 are powers of 2. For full credit, type check the input.
  5. (4 points) Write a function that takes an integer as input and returns 1 if all the digits in the number are odd and 0 otherwise. For full credit, type check the input.

Final steps

  1. Save your worksheet.
  2. Submit the assignment as lab 5 in Moodle (the URL is moodle.math.yorku.ca - NOTE: there is no "www" in the URL). You can upload several times, but remember to submit using the "send for marking" at the end ONCE - otherwise it may not be sent.
  3. You are done with this assignment! Remember to logout before you leave the lab.