Skip to content

2/18/17 #6

Merged
merged 10 commits into from
Feb 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions HW3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
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.
d. Use the four solvers `falsepos.m`, `bisect.m`, `newtraph.m` and `mod_secant.m`
to solve for the angle needed to reach h=1.72 m, with an initial speed of 15 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
Expand All @@ -29,7 +29,7 @@
| solver | initial guess(es) | ea | number of iterations|
| --- | --- | --- | --- |
|falsepos | | | |
|incsearch | | | |
|bisect | | | |
|newtraph | | | |
|mod_secant | | | |
```
Expand All @@ -49,7 +49,7 @@ using the numerical solvers, `newtraph.m` and `mod_secant.m`, there are certain
guesses that do not converge.

a. Calculate the first 5 iterations for the Newton-Raphson method with an initial
guess of x_i=2.
guess of x_i=2 for f(x)=x*exp(-x^2).

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

Expand All @@ -70,5 +70,4 @@ guesses that do not converge.
'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)
copy and paste the "clone URL" into the following Google Form [Homework 3](https://goo.gl/forms/UJBGwp0fQcSxImkq2)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ general, I will not post homework solutions.
|3|1/31||Consistent Coding habits|
| |2/2|5|Root Finding|
|4|2/7|6|Root Finding con’d|
| |2/9|7|Optimization|
|5|2/14||Intro to Linear Algebra|
| |2/9|7| **Snow Day**|
|5|2/14|| Optimization |
| |2/16|8|Linear Algebra|
|6|2/21|9|Linear systems: Gauss elimination|
| |2/23|10|Linear Systems: LU factorization|
Expand Down
Binary file added lecture_07/.lecture_07.md.swp
Binary file not shown.
6 changes: 6 additions & 0 deletions lecture_08/.ipynb_checkpoints/lecture_08-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
Binary file added lecture_08/Auchain_model.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lecture_08/Auchain_model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lecture_08/au_chain.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lecture_08/goldenratio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions lecture_08/goldmin.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function [x,fx,ea,iter]=goldmin(f,xl,xu,es,maxit,varargin)
% goldmin: minimization golden section search
% [x,fx,ea,iter]=goldmin(f,xl,xu,es,maxit,p1,p2,...):
% uses golden section search to find the minimum of f
% input:
% f = name of function
% xl, xu = lower and upper guesses
% es = desired relative error (default = 0.0001%)
% maxit = maximum allowable iterations (default = 50)
% p1,p2,... = additional parameters used by f
% output:
% x = location of minimum
% fx = minimum function value
% ea = approximate relative error (%)
% iter = number of iterations
if nargin<3,error('at least 3 input arguments required'),end
if nargin<4|isempty(es), es=0.0001;end
if nargin<5|isempty(maxit), maxit=50;end
phi=(1+sqrt(5))/2;
iter=0;
while(1)
d = (phi-1)*(xu - xl);
x1 = xl + d;
x2 = xu - d;
if f(x1,varargin{:}) < f(x2,varargin{:})
xopt = x1;
xl = x2;
else
xopt = x2;
xu = x1;
end
iter=iter+1;
if xopt~=0, ea = (2 - phi) * abs((xu - xl) / xopt) * 100;end
if ea <= es | iter >= maxit,break,end
end
x=xopt;fx=f(xopt,varargin{:});
2,762 changes: 2,762 additions & 0 deletions lecture_08/lecture_08.ipynb

Large diffs are not rendered by default.

Loading