This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
gibson:teaching:fall-2013:math445:lab1 [2013/08/26 18:23] gibson |
gibson:teaching:fall-2013:math445:lab1 [2013/08/28 18:33] (current) gibson |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Math 445 Lab #1 ====== | ====== Math 445 Lab #1 ====== | ||
| - | These problems are taken from Attaway chapter 1, both 2nd and 3rd editions. | + | These problems are taken from Attaway chapter 1, both 2nd and 3rd editions. Remember, Matlab's //help// function is your friend. |
| **Problem 1:** Evaluate these expressions in your head and write down the answer. Then evaluate them with Matlab. If you made a mistake, figure out what it was. | **Problem 1:** Evaluate these expressions in your head and write down the answer. Then evaluate them with Matlab. If you made a mistake, figure out what it was. | ||
| Line 16: | Line 16: | ||
| - | **Problem 2:** What is the type of the answers in problem 5? | + | **Problem 2:** What is the type of the answers in problem 1? |
| - | **Problem 3:** Use //intmin// and //intmax// to determine the range of values that can be stored in the types //uint32// and //unint64//? Express the answer both as an integer and in scientific notation. | + | **Problem 3:** Use //intmin// and //intmax// to determine the range of values that can be stored in the types //uint32// and //unint64//. Express the answers as integers and in scientific notation. |
| **Problem 4:** Wind chill factor: The WCF conveys how cold it feels with a given air | **Problem 4:** Wind chill factor: The WCF conveys how cold it feels with a given air | ||
| Line 34: | Line 34: | ||
| - | **Problem 12.** Use Matlab help to understand the following questions, and then answer them based on your understanding. Then use Matlab to check your answers. Rethink any questions you answered incorrectly. | + | **Problem 5:** Use Matlab help to understand the following questions, and then answer them based on your understanding. Then use Matlab to check your answers. Rethink any questions you answered incorrectly. |
| is fix(3.5) == floor(3.5)? | is fix(3.5) == floor(3.5)? | ||
| Line 44: | Line 44: | ||
| is fix(-3.2) == floor(-3.2)? | is fix(-3.2) == floor(-3.2)? | ||
| - | is fix(-3.2) === ceil(-3.2)? | + | is fix(-3.2) == ceil(-3.2)? |
| - | **Problem 13.** Find Matlab expressions for | + | What is the type of //fix(-3.2) == ceil(-3.2)//? |
| - | square root of 19 | + | **Problem 6:** Find Matlab expressions for |
| + | |||
| + | cube root of 19 | ||
| 3 to the 1.2 | 3 to the 1.2 | ||
| Line 54: | Line 56: | ||
| tangent of pi | tangent of pi | ||
| - | **Problem 17.** Generate random numbers | + | Evaluate the expressions. Do you notice anything unexpected? Can you explain it? |
| + | |||
| + | **Problem 7:** Generate random numbers | ||
| real in range 0-1 | real in range 0-1 | ||
| Line 68: | Line 72: | ||
| integer in range 50-100 | integer in range 50-100 | ||
| - | ** Problem 18.** Get into new Command window and type rand to get a random real number. | + | **Problem 8:** Get into new Command window and type rand to get a random real number. |
| Make a note of the number. Then exit and restart matlab, and repeat. The | Make a note of the number. Then exit and restart matlab, and repeat. The | ||
| random number should be the same. Exit and restart matlab again. This time, | random number should be the same. Exit and restart matlab again. This time, | ||
| change the random number seed before generating a new random number. The | change the random number seed before generating a new random number. The | ||
| random number should be different this time. | random number should be different this time. | ||
| + | |||
| + | **Problem 9:** Evaluate these expressions in your head, and then check your answers by evaluating them with Matlab. If you made any mistakes, figure out why. | ||
| + | |||
| + | 'b' >= 'c' + 1 | ||
| + | | ||
| + | 3 == 2 + 1 | ||
| + | | ||
| + | (3 == 2) + 1 | ||
| + | | ||
| + | xor(5 < 6, 8 > 4) | ||
| + | | ||
| + | What is the type of each of the answers? | ||
| + | |||
| + | **Problem 10:** The geometric mean g of n numbers $x_1, x_2, \ldots, x_n$ is given by | ||
| + | |||
| + | <latex> | ||
| + | g = \sqrt[n]{x_1 x_2 \ldots x_n} | ||
| + | </latex> | ||
| + | |||
| + | This is useful, for example, in finding the average rate of return on an investment with varying yearly return. If an investment returns 15% its first year, 5% its second, and 10% its third, the average rate of return is | ||
| + | |||
| + | <latex> | ||
| + | \sqrt[3]{1.15 \cdot 1.05 \cdot 1.10} | ||
| + | </latex> | ||
| + | |||
| + | Compute the average rate of return, expressed as a percent. | ||
| + | | ||