From 119caa0f27f86bb0ac036c285fcf9f1885e669cd Mon Sep 17 00:00:00 2001 From: mattmaliniak <31718098+mattmaliniak@users.noreply.github.com> Date: Fri, 6 Oct 2017 13:32:12 -0400 Subject: [PATCH] Edits --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index bbc778e..c04852f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 02_roots_and_optimization #Problem 2 -``matlab +```matlab function [root,fx,ea,iter]=bisect(func,xl,xu,es,maxit,varargin) % bisect: root location zeroes % [root,fx,ea,iter]=bisect(func,xl,xu,es,maxit,p1,p2,...): @@ -38,8 +38,8 @@ while (1) if ea <= es || iter >= maxit,break,end end root = xr; fx = func(xr, varargin{:}); -`` -`matlab +``` +```matlab function [root,fx,ea,iter]=falsepos(func,xl,xu,es,maxit,varargin) % bisect: root location zeroes % [root,fx,ea,iter]=bisect(func,xl,xu,es,maxit,p1,p2,...): @@ -79,8 +79,8 @@ while (1) if ea <= es || iter >= maxit,break,end end root = xr; fx = func(xr, varargin{:}); -`` -``matlab +``` +```matlab function [root,ea,iter]=mod_secant(func,dx,xr,es,maxit,varargin) % newtraph: Modified secant root location zeroes % [root,ea,iter]=mod_secant(func,dfunc,xr,es,maxit,p1,p2,...): @@ -111,8 +111,8 @@ while (1) if ea <= es || iter >= maxit, break, end end root = xr; -`` -``matlab +``` +```matlab cat_cable= @(T) T/10.*cosh(10./T*30)+30-T/10-35; [root,fx,ea,iter]=falsepos(cat_cable,100,1000,.00001,10000); [root1,fx1,ea1,iter1]=bisect(cat_cable,100,1000,.00001,10000); @@ -126,7 +126,7 @@ title('Final Shape of Powerline') xlabel('Distance in meters') ylabel('Height in meters') print('figure01','-dpng') -`` +``` ###Method Analysis Table | solver | initial guess(es) | ea | number of iterations| @@ -172,7 +172,7 @@ table = [iter' root' ea']; | 5 | 1.0000 | 0.0000 | #Problem 4 -``matlab +```matlab epsilon = 0.039; % kcal/mol epsilon = epsilon*6.9477e-21; % J/atom epsilon = epsilon*1e18; % aJ/J @@ -228,7 +228,7 @@ fprintf('\nThe nonlinear spring constants are K1=%1.2f nN/nm and K2=%1.2f nN/nm^ fprintf('The mininum sum of squares error = %1.2e \n',SSE_min) plot(dx,F_applied,'o',dx,K(1)*dx+1/2*K(2)*dx.^2) -`` +``` ![Parabolic Method](./figures/figure02.png) ![SUm Squares Error](./figures/figure03.png)