User Tools

Site Tools


gibson:teaching:fall-2012:math445:lab3

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gibson:teaching:fall-2012:math445:lab3 [2012/09/05 19:45]
gibson
gibson:teaching:fall-2012:math445:lab3 [2012/12/05 09:11] (current)
gibson [Problem F]
Line 10: Line 10:
 labeling different lines in the same plot via the ''​legend''​ command. labeling different lines in the same plot via the ''​legend''​ command.
  
-AWrite a function ''​mysort.m''​ that will take in a vector of any size and sort +==== Problem ​A====   
 +Write a function ''​mysort.m''​ that will take in a vector of any size and sort 
 it from least to greatest. Use the strategy of comparing neighbors and swapping it from least to greatest. Use the strategy of comparing neighbors and swapping
 them if necessary. If this process is done throughout the entire vector ​ them if necessary. If this process is done throughout the entire vector ​
Line 17: Line 18:
 then by switching the outer loop to use a ''​while''​ command. then by switching the outer loop to use a ''​while''​ command.
  
-BSuppose you opened a savings account that promised a 100% interest rate +==== Problem ​B==== 
 + Suppose you opened a savings account that promised a 100% interest rate 
 (typical rates are closer to 2.25% today). We are going to try and calculate ​ (typical rates are closer to 2.25% today). We are going to try and calculate ​
 how much money that account would have after one year depending on how the  how much money that account would have after one year depending on how the 
Line 54: Line 56:
 quartely, monthly, and bi-weekly. Hint: one of your answers should be 26130.35. quartely, monthly, and bi-weekly. Hint: one of your answers should be 26130.35.
  
-CNow we will compound the interest weekly. Let's use a ''​for''​ loop to + 
 +==== Problem ​==== 
 + Now we will compound the interest weekly. Let's use a ''​for''​ loop to 
 compute not only how much money we will have in our account at the end of  compute not only how much money we will have in our account at the end of 
 the year but each week as well. Use the command ​ the year but each week as well. Use the command ​
Line 91: Line 95:
 get the exact same plot and a final value of 26925.97 for B(53) . get the exact same plot and a final value of 26925.97 for B(53) .
  
-Bonus: Can you think of a way to calculate the same vector ''​B''​ in one line, +**Bonus:** Can you think of a way to calculate the same vector ''​B''​ in one line, 
 without using a loop?  without using a loop? 
  
-DAs the number of compounds increases, the final amount appears to be get +==== Problem ​====  
 +As the number of compounds increases, the final amount appears to be get 
 closer to some final value. In order to check this, let's compound the interest ​ closer to some final value. In order to check this, let's compound the interest ​
 every second. Compute the result of compounding the interest every second on  every second. Compute the result of compounding the interest every second on 
Line 106: Line 111:
 commonly in exponential and natural logarithms. commonly in exponential and natural logarithms.
  
-EAt this point I am going to make a guess that+====Problem ​E==== 
 +At this point I am going to make a guess that
  
 <​latex>​ <​latex>​
-(1 + 1.00/​n)^n ​≈ e.+(1 + 1.00/​n)^n ​\approx  ​e.
 </​latex>​ </​latex>​
  
Line 125: Line 131:
 values for ''​n''​ where $n_j = 2^j$ with //j = 1, ..., 20//. Then for each of  values for ''​n''​ where $n_j = 2^j$ with //j = 1, ..., 20//. Then for each of 
 the values of n, again using a ''​for''​ loop, calculate ​ the values of n, again using a ''​for''​ loop, calculate ​
-$a_j = (1 + 1.00/n_j )^{n_j}$ for ''​j = 1, ..., 20''​. Plot the values of //a//.+$a_j = (1 + 1.00/n_j )^{n_j}$ for //j = 1, ..., 20//. Plot the values of //a//.
 Next plot //e − a//.  You should see a graph that is not very informative ​ Next plot //e − a//.  You should see a graph that is not very informative ​
 since the values quickly go to zero. Instead we will plot the graph on a log  since the values quickly go to zero. Instead we will plot the graph on a log 
Line 134: Line 140:
 Turn in all plots. ​ Turn in all plots. ​
  
-Bonus: What happens if you let ''​j = 1, ..., 60''​? What happens if when you  +**Bonus:** What happens if you let //j = 1, ..., 60//? What happens if when you  
-let $n_j = 10^j$ for ''​j = 1,...,16''​? Can you make a reasonable guess as to+let $n_j = 10^j$ for //j = 1,...,16//? Can you make a reasonable guess as to
 what's happening here? what's happening here?
  
-FUsing the same procedure as in the previous problem, confirm that+==== Problem ​==== 
 +Using the same procedure as in the previous problem, confirm that
  
 <​latex>​ <​latex>​
-\lim_{n\rightarrow \infty} (1 + 0.754/n)^nn = e^{0.754}+\lim_{n\rightarrow \infty} (1 + 0.754/n)^n= e^{0.754}
 </​latex>​ </​latex>​
  
Line 149: Line 156:
 the command ''​exp(0.754)''​. the command ''​exp(0.754)''​.
  
-GWe have used several MATLAB functions so far. Now we are going to write our +==== Problem ​==== 
 + 
 + We have used several MATLAB functions so far. Now we are going to write our 
 own function. In the main MATLAB window click File → New → Script ​ own function. In the main MATLAB window click File → New → Script ​
 (or File → New → m-file depending on your version of MATLAB). This will open a  (or File → New → m-file depending on your version of MATLAB). This will open a 
Line 185: Line 194:
 the last line. Turn in the code for your function. the last line. Turn in the code for your function.
  
-HEnter the command ''​format long''​ then verify the following properties of +==== Problem ​==== 
 + 
 + Enter the command ''​format long''​ then verify the following properties of 
 exponentials and logarithms by testing the appropriate MATLAB functions with  exponentials and logarithms by testing the appropriate MATLAB functions with 
 the parameters indicated: ​ the parameters indicated: ​
Line 198: Line 209:
  
 <​latex>​ <​latex>​
-log(ab) = log(a) + log(b), \text{ for } a = 0.1, b = 5+\log(ab) = \log(a) + \log(b), \text{ for } a = 0.1, b = 5
 </​latex>​ </​latex>​
  
  
 <​latex>​ <​latex>​
-log(a^b) = b log(a), \text{ for } a = 3, b = 3+\log(a^b) = b \log(a), \text{ for } a = 3, b = 3
 </​latex>​ </​latex>​
  
 Note the ''​log''​ function in matlab is the natural logarithm. How would you  Note the ''​log''​ function in matlab is the natural logarithm. How would you 
-calculate $\log_{10}$ , $log_2$ , or $log_5$?+calculate $\log_{10}$ , $\log_2$ , or $\log_5$?
  
gibson/teaching/fall-2012/math445/lab3.1346899528.txt.gz · Last modified: 2012/09/05 19:45 by gibson