Skip to content
Permalink
master
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
# roots_and_optimization
# Homework #3:
### Comparing Different Solvers
| solver | initial guess(es) | ea | number of iterations|
| --- | --- | --- | --- |
|falsepos |0, 1.5 | 7.3639e-06 | 33 |
|bisect |0, 1.5 | 5.3981e-06 | 29 |
|newtraph | 1 | 9.8618e-09 | 5 |
|mod_secant | 1 | 7.9314e-06 | 10 |
Plot of convergence for four numerical solvers:
![alt text](convergence.png)
The files used to create the table above are looking for the roots or zeros of the function using the input arguments of an inital guess, the desired relative error, and the maximum number of iterations.
### Divergence of Newton-Raphson method
| iteration | x_i | approx error |
| --- | :---: | ---: |
| 1 | 2 | 12.5 |
| 2 | 2 | 9.5703 |
| 3 | 2 | 7.8262 |
| 4 | 2 | 6.6491 |
| 5 | 2 | 5.7943 |
### Convergene of Newton-Raphson method
| iteration | x_i | approx error |
| --- | --- | --- |
| 1 | 0.2| 1.2e03 |
| 2 | 0.2| 1.6531e05 |
| 3 | 0.2| 4.5122e11 |
| 4 | 0.2| 4.5122e11 |
| 5 | 0.2| 4.5122e11 |
# Homework #4
![Steady-state position of collar on rod at angle theta](plot.png)
##Script that solves for xc:
for i= 0:90
theta= i*pi/180;
minimum_potential_energy= @(x_C) 0.5 * x_C*9.81*sin(theta) + 1/2*30 *(0.5 - sqrt(0.5^2+(0.5-x_C)^2))^2;
[C,fx,ea,iter]=goldmin(minimum_potential_energy,0,5,0.00001,50);
x_C(i+1)=C;
end