====== Differences ====== This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
gibson:teaching:spring-2015:math445:lab1 [2015/01/19 11:31] gibson created |
gibson:teaching:spring-2015:math445:lab1 [2015/01/21 12:52] (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. Remember, Matlab's //help// function is your friend. | + | Most of 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. | + | **Problem 1:** Evaluate these Matlab expressions in your head and write down the answer. |
- | Then evaluate them with Matlab. If you made a mistake, figure out what it was. | + | Then type them into Matlab and see how Matlab evaluates them. If you made a mistake, figure out what it was. |
25/4*4 | 25/4*4 | ||
Line 17: | Line 17: | ||
- | **Problem 2:** Translate these mthematical expressions into Matlab expressions, and then evaluate them. | + | **Problem 2:** Translate these mathematical expressions into Matlab expressions, and then evaluate them. |
$e^{3/4}$ | $e^{3/4}$ | ||
Line 32: | Line 32: | ||
- | **Problem 3:** Wind chill factor: The WCF conveys how cold it feels with a given air | + | **Problem 3:** Wind chill factor: The WCF supposedly conveys how cold it feels with a given air |
temperature T (degrees Farenheit) and wind speed V (miles per hour). A formula | temperature T (degrees Farenheit) and wind speed V (miles per hour). A formula | ||
for WCF is | for WCF is | ||
Line 43: | Line 43: | ||
calculate the WCF for (a) T = 45 F and V = 10 mph and (b) T = 45 F and V = 0 mph. | calculate the WCF for (a) T = 45 F and V = 10 mph and (b) T = 45 F and V = 0 mph. | ||
- | **Problem 4:** Translate the following Matlab logical expressions into English. | + | **Problem 4:** The geometric mean g of n numbers $x_1, x_2, \ldots, x_n$ is given by |
+ | |||
+ | \begin{eqnarray*} | ||
+ | g = \sqrt[n]{x_1 x_2 \ldots x_n} | ||
+ | \end{eqnarray*} | ||
+ | |||
+ | This is useful, for example, in finding the average rate of return on an investment with varying yearly return. | ||
+ | |||
+ | **(a)** If an investment returns 15% its first year, 5% its second, and 10% its third, the average rate of return is | ||
+ | |||
+ | \begin{eqnarray*} | ||
+ | \sqrt[3]{1.15 \cdot 1.05 \cdot 1.10} | ||
+ | \end{eqnarray*} | ||
+ | |||
+ | Compute the average rate of return, expressed as a percent. | ||
+ | |||
+ | **(b)**Which is better, a steady 5% per year return on investment, or alternating between 0% and 10% year by year? | ||
+ | |||
+ | **Problem 5:** The astoundingly brilliant but short-lived mathematician [[http://en.wikipedia.org/wiki/Srinivasa_Ramanujan | Srinivasa Ramanujan]] devised the following very powerful formula for for $1/\pi$ | ||
+ | |||
+ | \begin{eqnarray*} | ||
+ | \frac{1}{\pi} = \frac{2\sqrt{2}}{9801} \sum_{k=0}^{\infty} \frac{(4k)!\, (1103 + 26390\,k)}{(k!)^4 \, 396^{4k}} | ||
+ | \end{eqnarray*} | ||
+ | |||
+ | You can get an approximation of $\pi$ using only arithmetic operations by evaluating and summing a finite number of terms of this series. What is the numerical approximation of $\pi$ using just the first term ($k=0$)? Using the first and second ($k=0$ and $k=1$)? How many digits of accuracy does each of these approximation have? Be sure to use ''format long''. | ||
+ | |||
+ | (adapted from a problem in //Introduction to Matlab Programming// by Siauw and Bayen) | ||
+ | |||
+ | |||
+ | **Problem 6:** Translate the following Matlab logical expressions into English. | ||
x < y | x < y | ||
Line 50: | Line 79: | ||
- | **Problem 5:** Translate the following mathematical expressions into Matlab and evaluate for $x=3, y=4, z=5$. | + | **Problem 7:** Translate the following mathematical expressions into Matlab and evaluate for $x=3, y=4, z=5$. |
- | $x < y < z$ | + | $x < y < z$ |
- | $x < y$ and $x < z$ | + | |
- | $y < z$ or $x == z$ | + | |
+ | $x < y$ and $x < z$ | ||
- | **Problem 6:** Evaluate the following Matlab expressions and explain the results. | + | $y < z$ or $x == z$ |
+ | |||
+ | |||
+ | **Problem 8:** Evaluate the following Matlab expressions and explain the results. | ||
3 == 4 | 3 == 4 | ||
Line 67: | Line 98: | ||
(3 == 2) + 1 | (3 == 2) + 1 | ||
| | ||
+ | **Problem 9:** If P is a logical expression, the law of noncontradiction states that P AND (NOT P) is always false. Use Matlab to verify this for both P false and P true. | ||
- | **Problem 7:** The geometric mean g of n numbers $x_1, x_2, \ldots, x_n$ is given by | + | **Problem 10:** Let P and Q be logical expressions. De Morgan's rule states that NOT (P OR Q) = (NOT P) AND (NOT Q) and also that NOT (P AND Q) = (NOT P) OR (NOT Q). Demonstrate with Matlab that both these rules hold for all possible combinations of P and Q. |
- | \begin{eqnarray*} | + | **Problem 11:** Construct an equivalent logical expression for P OR Q using only AND and NOT. Translate that into Matlab and then test for all possible values of P and Q. Write your demonstration in the following fashion, in order to make it easy to follow |
- | g = \sqrt[n]{x_1 x_2 \ldots x_n} | + | |
- | \end{eqnarray*} | + | |
- | + | ||
- | 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 | + | |
- | + | ||
- | \begin{eqnarray*} | + | |
- | \sqrt[3]{1.15 \cdot 1.05 \cdot 1.10} | + | |
- | \end{eqnarray*} | + | |
- | + | ||
- | Compute the average rate of return, expressed as a percent. | + | |
- | + | ||
- | **Problem 8:** The astoundingly brilliant but short-lived mathematician Srinivasa Ramanujan devised the following very powerful formula for for $1/\pi$ | + | |
- | + | ||
- | \begin{eqnarray*} | + | |
- | \frac{1}{\pi} = \frac{2\sqrt{2}}{9801} \sum_{k=0}^{\infty} \frac{(4k)!\, (1101 + 26390\,k)}{(k!)^4 \, 296^{4k}} | + | |
- | \end{eqnarray*} | + | |
- | You can get an approximation of $\pi$ using only arithmetic operations by evaluating and summing a finite number of terms of | + | <code matlab> |
- | this series. What is the numerical approximation of $\pi$ using just the first term ($k=0$)? Using the first and second | + | P=0; Q=0; (my expression) == (P || Q) |
- | ($k=0$ and $k=1$)? How many digits of accuracy does each of these approximation have? | + | P=1; Q=0; (my expression) == (P || Q) |
+ | </code> | ||
+ | etc. | ||
+ | **Problem 12:** Construct an equivalent logical expression for P AND Q using only OR and NOT. Translate that into Matlab and then test for all possible values of P and Q. Folow the same kind of pattern as in problem 11. |