forked from sed12008/ME3255S2017
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from rcc02007/master
blah
- Loading branch information
Showing
23 changed files
with
5,450 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{:}); |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.