====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
gibson:teaching:spring-2015:math445:lab4 [2015/02/05 03:56] gibson |
gibson:teaching:spring-2015:math445:lab4 [2015/02/05 03:58] (current) gibson |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Math 445 lab 4: dot syntax and plotting ====== | ====== Math 445 lab 4: dot syntax and plotting ====== | ||
+ | |||
+ | ----- | ||
**Problem 1:** Create a plot that shows $\sin x$ and $\cos x$ over $-\pi \leq x \leq \pi$ with the sine in | **Problem 1:** Create a plot that shows $\sin x$ and $\cos x$ over $-\pi \leq x \leq \pi$ with the sine in | ||
Line 6: | Line 8: | ||
Helpful Matlab commands: ''linspace, plot, xlabel, legend, help.'' | Helpful Matlab commands: ''linspace, plot, xlabel, legend, help.'' | ||
+ | |||
+ | ----- | ||
**Problem 2:** Consider the two functions $f(x) = x^n$ and $g(x) = n^x$ for the fixed value $n=5$. | **Problem 2:** Consider the two functions $f(x) = x^n$ and $g(x) = n^x$ for the fixed value $n=5$. | ||
Line 13: | Line 17: | ||
Helpful Matlab commands: ''linspace, semilogy, xlabel, legend, help,'' plus dot-syntax. | Helpful Matlab commands: ''linspace, semilogy, xlabel, legend, help,'' plus dot-syntax. | ||
+ | |||
+ | ----- | ||
**Problem 3:** How many real roots does the function $f(x) = x^3 - 5x^2 + 2x + 4$ have? | **Problem 3:** How many real roots does the function $f(x) = x^3 - 5x^2 + 2x + 4$ have? | ||
Line 22: | Line 28: | ||
particular you can use ''axis([xmin xmax ymin ymax])'' to zoom in on regions near zeros. | particular you can use ''axis([xmin xmax ymin ymax])'' to zoom in on regions near zeros. | ||
Or you can zoom in by refining the range of $x$ and replotting. | Or you can zoom in by refining the range of $x$ and replotting. | ||
+ | |||
+ | ----- | ||
**Problem 4:** The exponential function $e^x$ can be computed from the power series | **Problem 4:** The exponential function $e^x$ can be computed from the power series | ||
Line 33: | Line 41: | ||
this question very quickly by writing one line of Matlab code that evaluate the truncated sum for a fixed value of $N$, and then rerunning it with changing values of $N$. | this question very quickly by writing one line of Matlab code that evaluate the truncated sum for a fixed value of $N$, and then rerunning it with changing values of $N$. | ||
- | Helpful Matlab commands: ''sum, format, exp'' (for getting the correct value of $e$ to sixteen digits), dot syntax, and ''log10'' (for counting digits of precision). | + | Helpful Matlab commands: ''sum, format, exp'' (for getting the correct value of $e$ to sixteen digits), colon syntax, dot syntax, and ''log10'' (for counting digits of precision). |
+ | |||
+ | ----- | ||
**Problem 5:** The sine function can be computed from the power series | **Problem 5:** The sine function can be computed from the power series | ||
Line 43: | Line 53: | ||
Like the exponential function, in practice one truncates this sum at $n=N$. How large does $n$ need to | Like the exponential function, in practice one truncates this sum at $n=N$. How large does $n$ need to | ||
be to calculate $\sin \pi/3$ to sixteen digits? | be to calculate $\sin \pi/3$ to sixteen digits? | ||
+ | |||
+ | Helpful Matlab commands: same as problem 4. |