Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added HW3
  • Loading branch information
rcc02007 committed Feb 8, 2017
1 parent 3bfd22a commit 3519f1b
Show file tree
Hide file tree
Showing 10 changed files with 1,225 additions and 136 deletions.
60 changes: 60 additions & 0 deletions HW3/README.html
@@ -0,0 +1,60 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<h1 id="homework-3">Homework #3</h1>
<h2 id="due-21517-by-1159pm">due 2/15/17 by 11:59pm</h2>
<ol style="list-style-type: decimal">
<li><p>Create a new github repository called ‘roots_and_optimization’.</p>
<ol style="list-style-type: lower-alpha">
<li><p>Add rcc02007 and pez16103 as collaborators.</p></li>
<li><p>Clone the repository to your computer.</p></li>
<li><p>Copy your <code>projectile.m</code> function into the ‘roots_and_optimization’ folder. <em>Disable the plotting routine for the solvers</em></p></li>
<li><p>Use the four solvers <code>falsepos.m</code>, <code>incsearch.m</code>, <code>newtraph.m</code> and <code>mod_secant.m</code> to solve for the angle needed to reach h=1.72, with an initial speed of 1.5 m/s.</p></li>
<li><p>The <code>newtraph.m</code> function needs a derivative, calculate the derivative of your function with respect to theta, <code>dprojectile_dtheta.m</code>. This function should output d(h)/d(theta).</p></li>
<li><p>In your <code>README.md</code> file, you will document the following under the heading <code># Homework #3</code>:</p>
<ol style="list-style-type: lower-roman">
<li>Compare the number of iterations that each function needed to reach an accuracy of 0.00001%. Include a table in your README.md with:</li>
</ol>
<pre><code>| solver | initial guess(es) | ea | number of iterations|
| --- | --- | --- | --- |
|falsepos | | | |
|incsearch | | | |
|newtraph | | | |
|mod_secant | | | |</code></pre>
<ol start="2" style="list-style-type: lower-roman">
<li>Compare the convergence of the 4 methods. Plot the approximate error vs the number of iterations that the solver has calculated. Save the plot as <code>convergence.png</code> and display the plot in your <code>README.md</code> with:</li>
</ol>
<p><code>![Plot of convergence for four numerical solvers.](convergence.png)</code></p>
<ol start="3" style="list-style-type: lower-roman">
<li>In the <code>README.md</code> provide a description of the files used to create the table and the convergence plot.</li>
</ol></li>
</ol></li>
<li><p>The Newton-Raphson method and the modified secant method do not always converge to a solution. One simple example is the function f(x) = x*exp(-x^2). The root is at 0, but using the numerical solvers, <code>newtraph.m</code> and <code>mod_secant.m</code>, there are certain initial guesses that do not converge.</p>
<ol style="list-style-type: lower-alpha">
<li><p>Calculate the first 5 iterations for the Newton-Raphson method with an initial guess of x_i=2.</p></li>
<li><p>Add the results to a table in the <code>README.md</code> with:</p></li>
</ol>
<pre><code>### divergence of Newton-Raphson method

| iteration | x_i | approx error |
| --- | --- | --- |
| 0 | 2 | n/a |
| 1 | | |
| 2 | | |
| 3 | | |
| 4 | | |
| 5 | | |</code></pre>
<ol start="3" style="list-style-type: lower-alpha">
<li>Repeat steps a-b for an initial guess of 0.2. (But change the heading from ‘divergence’ to ‘convergence’)</li>
</ol></li>
<li><p>Commit your changes to your repository. Sync your local repository with github. Then copy and paste the “clone URL” into the following Google Form <a href="https://goo.gl/forms/UJBGwp0fQcSxImkq2">Homework #3</a></p></li>
</ol>
</body>
</html>
74 changes: 74 additions & 0 deletions HW3/README.md
@@ -0,0 +1,74 @@
# Homework #3
## due 2/15/17 by 11:59pm


1. Create a new github repository called 'roots_and_optimization'.

a. Add rcc02007 and pez16103 as collaborators.

b. Clone the repository to your computer.

c. Copy your `projectile.m` function into the 'roots_and_optimization' folder.
*Disable the plotting routine for the solvers*

d. Use the four solvers `falsepos.m`, `incsearch.m`, `newtraph.m` and `mod_secant.m`
to solve for the angle needed to reach h=1.72 m, with an initial speed of 1.5 m/s.

e. The `newtraph.m` function needs a derivative, calculate the derivative of your
function with respect to theta, `dprojectile_dtheta.m`. This function should
output d(h)/d(theta).


f. In your `README.md` file, document the following under the heading `#
Homework #3`:

i. Compare the number of iterations that each function needed to reach an
accuracy of 0.00001%. Include a table in your README.md with:

```
| solver | initial guess(es) | ea | number of iterations|
| --- | --- | --- | --- |
|falsepos | | | |
|incsearch | | | |
|newtraph | | | |
|mod_secant | | | |
```

ii. Compare the convergence of the 4 methods. Plot the approximate error vs the
number of iterations that the solver has calculated. Save the plot as
`convergence.png` and display the plot in your `README.md` with:

`![Plot of convergence for four numerical solvers.](convergence.png)`

iii. In the `README.md` provide a description of the files used to create the
table and the convergence plot.

2. The Newton-Raphson method and the modified secant method do not always converge to a
solution. One simple example is the function f(x) = x*exp(-x^2). The root is at 0, but
using the numerical solvers, `newtraph.m` and `mod_secant.m`, there are certain initial
guesses that do not converge.

a. Calculate the first 5 iterations for the Newton-Raphson method with an initial
guess of x_i=2.

b. Add the results to a table in the `README.md` with:

```
### divergence of Newton-Raphson method

| iteration | x_i | approx error |
| --- | --- | --- |
| 0 | 2 | n/a |
| 1 | | |
| 2 | | |
| 3 | | |
| 4 | | |
| 5 | | |
```

c. Repeat steps a-b for an initial guess of 0.2. (But change the heading from
'divergence' to 'convergence')

3. Commit your changes to your repository. Sync your local repository with github. Then
copy and paste the "clone URL" into the following Google Form [Homework
#3](https://goo.gl/forms/UJBGwp0fQcSxImkq2)
Binary file added lecture_07/.newtraph.m.swp
Binary file not shown.

0 comments on commit 3519f1b

Please sign in to comment.