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

Homework #3

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

In degrees (root = 2.9655):
solver initial guess(es) ea number of iterations
falsepos xl = 0, xu = 45 3.3785e-06 11
bisect xl = 0, xu = 45 5.6529e-06 28
newtraph xr = 0 9.9216e-06 687
mod_secant xr = 0 4.4638e-09 3
In radians (root = 0.0518):
solver initial guess(es) ea number of iterations
falsepos xl = 0, xu = pi/4 3.3785e-06 11
bisect xl = 0, xu = pi/4 5.6529e-06 28
newtraph xr = 0 5.6054e-09 3
mod_secant xr = 0 1.1874e-09 3

ii. Compare the convergence of the 4 methods.

Plot of convergence for four numerical solvers. (degrees) Plot of convergence for four numerical solvers. (radians)

iii. Creation code

To create degrees table:

[root,fx,ea,iter]=falsepos(@(x) projectile(15,x),0,45,0.00001,100)
[root,fx,ea,iter]=bisect(@(x) projectile(15,x),0,45,0.00001,100)
[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,100)

To create radians table:

[root,fx,ea,iter]=falsepos(@(x) projectile2(15,x),0,pi/4,0.00001,100)
[root,fx,ea,iter]=bisect(@(x) projectile2(15,x),0,pi/4,0.00001,100)
[root,ea,iter]=newtraph(@(x) projectile2(15,x),@(x) dprojectile2_dtheta(15,x),0,0.00001,1000)
[root,ea,iter]=mod_secant(@(x) projectile2(15,x),0.001,0,0.00001,100)

To create the convergence plots:

Degrees: run convergence.m
Radians: run convergence2.m

Divergence of Newton-Raphson method

iteration x_i approx error
0 2 n/a
1 2 12.5000
2 2.2857 9.5703
3 2.5276 7.8262
4 2.7422 6.6492
5 2.9375 5.7945

Convergence of Newton-Raphson method

iteration x_i approx error
0 0.2 n/a
1 0.2 1.2500e+03
2 -0.0174 1.6531e+05
3 1.0527e-05 4.5122e+11
4 -2.3329e-15 4.5122e+11
5 0 4.5122e+11

Homework #4

a. collar potential energy function

function [PE] = collar_potential_energy(x_C, theta)
% theta taken in terms of degrees
% x_C in meters
theta1 = theta*(pi/180);
PE_g = (0.5)*x_C*9.81*sin(theta1);
DL = 0.5 - sqrt((0.5)^2 + (0.5 - x_C)^2);
PE_s = (0.5)*30*(DL^2);
PE = PE_g + PE_s;
end

b. minimum PE at theta = 0

PE = 0, x_C = 0.5

function [PE] = min_PE
[x,fx,ea,iter]=goldmin(@(x) collar_potential_energy(x, 0),0,10,0.0001,100);
PE = collar_potential_energy(x, 0);
end

c. minimum PE position for theta 0 to 90

theta = linspace(0,90,91);
x_C = zeros(1,91);
for n = 0:90
    [x,fx,ea,iter]=goldmin(@(x) collar_potential_energy(x,n),0,20,0.00001,100);
    x_C(n+1) = x;
end

d. plot of part c

Steady-state position of collar on rod at angle theta