next up previous
Next: About this document ...

ESC 251 HW 13 Due: Oct. 3

Remember to indent the bodies of your IF-THEN and looping structures.



1)
(2 pts) Look up the floor function in MATLAB to see what it does. Write a short section of code that will use the floor function to test whether or not a given number is an integer.
2)
(4 pts) Write a MATLAB script that will have the user input a value of n, then compute n!. Your script should include error checking. If the value of n is negative or not an integer, the script should print out an appropriate error message, otherwise the program should print out the value of n!. Remember that 0! = 1. Test your program using n = 5, 7.8, -6. This program is an accumulation operation, but this time you are accumulating a product, not a sum.
3)
(7 pts) Write a single MATLAB script that will compute the sums below:
a)
$ \displaystyle {\sum_{i=1}^{10} i^2 + i}$
b)
$ \displaystyle {\sum_{i=10}^{1} i^2 + i}$     You should check the value of this sum versus Mathematica, Maple or the Wolfram Alpha site.
c)
$ \displaystyle {\sum_{i=1}^{20} \frac{i+1}{i}}$
d)
$ \displaystyle {\sum_{i=n}^{n^2} \sqrt{i}}.$     You should read the value of n from the keyboard. Test your program using n = 8.
e)
$ \displaystyle {\sum_{i=1}^{15} \sum_{j = 0}^{i} i + j + ij}$




next up previous
Next: About this document ...
2018-10-01