User Tools

Site Tools


gibson:teaching:spring-2015:math445:hw1

Math 445 HW1

If you have your own computer and want to run Matlab on it, download and install Matlab from UNH academic software. Otherwise you can do your homework on the computers in Kingsbury N129. Save your Matlab session to a file by turning “diary on”. When you're done, edit the diary in a text editor to remove errors and add appropriate comments. Print the edited diary to turn in. Your name, the date, and “Math 445 HW 1” should appear prominently at the top.

Remember, you are required to do these homeworks by yourself. If you get stuck, refer to your textbook. If you are absolutely stuck, talk to a fellow student, the teaching assistant, or the instructor, and get hints for how to proceed. But do not copy someone else's solved problem.

Problem 1: Given two numeric variables $x$ and $y$, write a Matlab expression that evaluates to true (1) if $x$ and $y$ have opposite signs and false (0) otherwise. By opposite signs, I mean one is positive and one is negative. Test the expression by evaluating it with a few choice values of $x$ and $y$.

Problem 2: The combined resistance $R_T$ of three resistors $R_1, R_2, R_3$ in parallel is given by

\begin{eqnarray*}
R_T =  \frac{1}{\frac{1}{R_1} + \frac{1}{R_2} + \frac{1}{R_3}}
\end{eqnarray*}

Create variables for the three resistors $R_1, R_2, R_3$, with values 5, 3, and 4. Then calculate $R_T$ by translating the above formula into Matlab syntax.

Problem 3: Another series expansion of $\pi$ is

\begin{eqnarray*}
\pi = 4 \sum_{k=1}^{\infty} \frac{(-1)^{k+1}}{2k-1} = 4 \left(1 - \frac{1}{3} + \frac{1}{5} - \ldots \right)
\end{eqnarray*}

Do you think finite truncations of this series will converge to $\pi$ faster or slower than the Ramanujan series from lab 1? Take a guess before testing in Matlab!

How many digits of accuracy do you get for two terms of this series? How many digits did you get for two terms of the Ramanujan series? What reason is there for the difference in the convergence rate of the two formulae?

Problem 4: A series expansion for $e$ is

\begin{eqnarray*}
e = \sum_{k=0}^{\infty} \frac{1}{k!} = 1 + \frac{1}{1!} + \frac{1}{2!} + \frac{1}{3!} + \ldots
\end{eqnarray*}

How many terms of this series do you need to get four digits of accuracy?

Problem 5: Let $e_n$ be the truncation of the above series after the $n$th term, i.e. $e_1 = 1$, $e_2 = 1 + 1/1!$, etc. Devise a Matlab expression that uses the log10 function to count the number of digits of accuracy in any given $e_n$.

Problem 6: Read help xor. Then devise an expression using only &&, ||, and ~that has the same value as xor(P,Q) for all possible combinations of P and Q. Demonstrate the correctness of your expression using Matlab code like this

P=0; Q=0; (my expression) == xor(P,Q)

etc.

gibson/teaching/spring-2015/math445/hw1.txt · Last modified: 2015/01/29 07:52 by gibson