Skip to content

red12005/roots_and_optimization

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?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

Homework #3

i. Number of iterations that each function needed to reach an accuracy of 0.00001%.

solver initial guess(es) ea number of iterations
falsepos 0,45 3.3785e-06 11
bisect 0,45 5.6529e-06 28
newtraph 0 9.9216e-06 687
mod_secant 0 1.1874e-09 3

Root=2.965

ii.Compare the convergence of the 4 methods. Plot the approximate error vs the number of iterations that the solver has calculated.

![Plot of convergence for four numerical solvers.](convergence.png)

(couldnt get image to upload here, so i made it into an "issue" instead)

iii. Discription of files used

[root,fx,ea,iter]=falsepos(@(x) projectile(15,x),0,45,0.00001,150) [root,fx,ea,iter]=bisect(@(x) projectile(15,x),0,45,0.00001,150) [root,ea,iter]=newtraph(@(x) projectile(15,x),@(x) dprojectile_dtheta(15,x),0,0.00001,1000) [root,ea,iter]=mod_secant(@(x) projectile(15,x),0.001,0,0.00001,150)

run convergence.m

2

Divergence

iteration x_i approx error
0 2 n/a
1 2 12.50
2 2.285 9.57
3 2.527 7.82
4 2.742 6.65
5 2.937 5.79

Convergence

iteration x_i approx error
0 0.2 n/a
1 0.2 1.250e03
2 -0.17 1.653e05
3 1.052e-05 4.512e11
4 -2.332e-15 4.512e11
5 0 4.512e11

                                            HW#4

A) collar potential energy function:

function [ PE_t ] = collar_potential_energy(x_C,Theta ) %computes the total potential energy of a collar connected to a spring and sliding on a rod %

%initialize variables g=9.18; m=0.5; K= 30; DL= 0.5 - sqrt(0.5^2+(0.5-x_C)^2)

%The potential energy due to gravity PE_g= abs(m x_Cgsin(theta));

%potential energy due to the spring PE_s=abs(1/2*K *(DL)^2)

%Total potential energy PE_t= PE_g+PE_s end SEE ACTUAL FUCNTION

B) Finding Min with goldmin: Solving for x and fx: f =@(x_C) collar_potential_energy(x_C,theta) [x,fx,ea,iter]=goldmin(f,0,0.5,0.0000001,500); x fx

C)For loop for min PE position: theta(1) =0; for i=1:100 f =@(x_C) collar_potential_energy(x_C,theta(i)) [x(i),fx(i),ea(i),iter(i)]=goldmin(f,0,0.5,1e-6,1000); theta(i+1) = theta(i) +1; end

D) PLOT SEE ISSUE 2 (still havent figured out how to put a png into the repository)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages