|CS 107 - Introduction to Scientific Computation
For this homework, you will place all of your answers in a file hw2.m.
1. Wheat on a Chessboard: In The Math Book: From Pythagoras to the 57th Dimension, 250 Milestones in the History of Mathematics, Clifford Pickover writes:
The problem of Sissa's chessboard is notable in the history of mathematics because it has been used for centuries to demonstrate the nature of geometric growth or geometric progressions, and it is one of the earliest mentions of chess in puzzles. The Arabic scholar Ibn Khallikan in 1256 appears to be the first author to discuss the story of Grand Vizier Sissa ben Dahir, who, according to legend, was asked by the Indian King Shirham what reward he wanted for inventing the game of chess.
Sissa addressed the king: "Majesty, I would be happy if you were to give me a grain of wheat to place on the first square of the chessboard, and two grains of wheat to place on the second square, and four grains of wheat to place on the third, and eight grains of wheat to place on the fourth, and so on for the sixty-four squares."
"And is that all you wish, Sissa, you fool?" the astonished King shouted.
In a single expression, compute the number of grains of wheat that Sissa requested. (Related unassigned problems: text exercises 3.1, 3.2)
2. Drawing a Square: Exercise 3.6. Hint: "help plot".
3. Boolean Expression: Exercise 3.8. To present your work, you'll be provided a, b, and N vectors of appropriate respective values to cover all cases (e.g. sum greater and b nonnegative, sum greater and b negative, etc.).
4. Counting Leap Years: Exercise 3.12. Hint: start with a vector of years. Then evaluate Boolean vectors associated with the various conditions of the problem. Hint 2: "help mod". Finally, combine these vectors and perform an appropriate operation to compute the total number of leap years. See the Wikipedia article for clarification: "Years that are evenly divisible by 100 are not leap years, unless they are also evenly divisible by 400, in which case they are leap years."