Skip to content
Permalink
a84132c794
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
86 lines (65 sloc) 1.49 KB

02_roots_and_optimization

Repository for homework 2

Question 2

cat_cable = @(T) -35+T/10.*cosh(10./T*30)+30-T/10;
[root,fx,ea,iter]=falsepos(cat_cable,900,910,0.00001)
cat_cable = @(T) -35+T/10.*cosh(10./T*30)+30-T/10;
[root,fx,ea,iter]=bisect(cat_cable,908,909,0.00001)
cat_cable = @(T) -35+T/10.*cosh(10./T*30)+30-T/10;
[root,ea,iter]=mod_secant(cat_cable,900,910,0.00001)
| solver | initial guess | ea | number of iterations|
| --- | --- | --- | --- |
|falsepos   | 900, 910 |  0.00001| 4  |
|mod_secant | 900, 910 |  0.00001| 50 |
|bisect     | 900, 910 |  0.00001| 17 |

Powerline Plot

Question 3

f = @(x) (x-1)*exp(-(x-1)^2);
df = @(x) -(2*(x)^2-4*x+1)*exp(-(x-1)^2);
[root,ea,iter]=newtraph(f,df,3,.00001,5)
### divergence of Newton-Raphson method

| iteration | x_i | approx error |
| --- | --- | --- |
| 0 | 3 |    n/a    |
| 1 | 3 |   8.6957  |
| 2 | 3 |   6.8573  |
| 3 | 3 |   5.7348  |
| 4 | 3 |   4.9605  |
| 5 | 3 |   4.3873  |
### convergence of Newton-Raphson method

| iteration | x_i | approx error |
| --- | --- | --- |
| 0 |  1.2 |     n/a       |
| 1 |  1.2 |   22.1239     |
| 2 |  1.2 |    1.7402     |
| 3 |  1.2 |    0.0011     |
| 4 |  1.2 |    2.3315e-13 |
| 5 |  1.2 |    2.3315e-13 |

Question 4 a)

lj = @(x) 4*0.039*((2.394./x).^12-(2.394./x).^6);
[x,E,ea,its] = goldmin(lj,2.8,6)

x =

2.8000

E =

-0.0371

ea =

9.9392e-05

its =

27