Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Edits
  • Loading branch information
mattmaliniak committed Oct 6, 2017
1 parent ca88f05 commit 119caa0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions 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,...):
Expand Down Expand Up @@ -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,...):
Expand Down Expand Up @@ -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,...):
Expand Down Expand Up @@ -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);
Expand All @@ -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|
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 119caa0

Please sign in to comment.