Docsity

Program Declaration | Computer Application in Engineering and Construction | CVEN 302, Assignments of Civil Engineering

Toggle sidebar
bg1
Problem 2 Program declaration
function StressStrain
% StressStrain The program does a stress-stain curve
%
%
% Synopsis: StressStrain
%
% Input: The values are inputed from the console
%
% data - name of the data file
% elongation - elongation of the test sample
% load - load related to the strain
% diameter - original diameter of the sample
% length - original length of the sample
% area - area of the cross-section
% stress - stress in the sample
% strain - strain in the sample
%
% Output: plots a stress-strain curve
datafile = input('\n\n What is the name of the data file? - ','s');
data = load(datafile);
flag = input('\n What type of inputs are you dealing with (SI/E)? - ','s');
switch flag
case 'SI'
diameter = input('\n What is the diameter of the sample? (mm) - ');
length = input('\n What is the length of the sample? (mm) - ');
area = pi* ((diameter*10^-3)/2)^2; % Converts the mm into m
load = data(:,1);
elongation = data(:,2);
stress = ((load*10^3) / area); % The load is in kN
stress = stress/10^6; % The stress will be displayed in MPa
strain = elongation / length;
plot(strain,stress);
xlabel('Strain');
ylabel('Stress (MPa)');
title('Stress vs Strain');
case 'E'
diameter = input('\n What is the diameter of the sample? (in.) - ');
length = input('\n What is the length of the sample? (in.) - ');
area = pi* (diameter/2)^2;
load = data(:,1);
elongation = data(:,2);
flag2 = input('\n What type of stress units (ksi/psi)? - ','s');
strain = elongation / length;
switch flag2
case 'ksi'
stress = (load / area)*10^-3;
plot(strain,stress);
ylabel('Stress (ksi)');
case 'psi'
stress = (load / area);
plot(strain,stress);
ylabel('Stress (psi)');
end
xlabel('Strain');
title('Stress vs Strain');
end
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Program Declaration | Computer Application in Engineering and Construction | CVEN 302 and more Assignments Civil Engineering in PDF only on Docsity!

Problem 2 Program declaration function StressStrain % StressStrain The program does a stress-stain curve % % % Synopsis: StressStrain % % Input: The values are inputed from the console % % data - name of the data file % elongation - elongation of the test sample % load - load related to the strain % diameter - original diameter of the sample % length - original length of the sample % area - area of the cross-section % stress - stress in the sample % strain - strain in the sample % % Output: plots a stress-strain curve datafile = input('\n\n What is the name of the data file? - ','s'); data = load(datafile); flag = input('\n What type of inputs are you dealing with (SI/E)? - ','s'); switch flag case 'SI' diameter = input('\n What is the diameter of the sample? (mm) - '); length = input('\n What is the length of the sample? (mm) - '); area = pi* ((diameter10^-3)/2)^2; % Converts the mm into m load = data(:,1); elongation = data(:,2); stress = ((load10^3) / area); % The load is in kN stress = stress/10^6; % The stress will be displayed in MPa strain = elongation / length; plot(strain,stress); xlabel('Strain'); ylabel('Stress (MPa)'); title('Stress vs Strain'); case 'E' diameter = input('\n What is the diameter of the sample? (in.) - '); length = input('\n What is the length of the sample? (in.) - '); area = pi* (diameter/2)^2; load = data(:,1); elongation = data(:,2); flag2 = input('\n What type of stress units (ksi/psi)? - ','s'); strain = elongation / length; switch flag case 'ksi' stress = (load / area)*10^-3; plot(strain,stress); ylabel('Stress (ksi)'); case 'psi' stress = (load / area); plot(strain,stress); ylabel('Stress (psi)'); end xlabel('Strain'); title('Stress vs Strain'); end

Problem 2 from Assignment 1- f(x) = x^3 – 3 Problem 2 -Bisection

Prob2_BS(1,2,8) k a xmid b f(xmid) 1 1.00000000 1.50000000 2.00000000 3.750e- 2 1.00000000 1.25000000 1.50000000 -1.047e+ 3 1.25000000 1.37500000 1.50000000 -4.004e- 4 1.37500000 1.43750000 1.50000000 -2.954e- 5 1.43750000 1.46875000 1.50000000 1.684e- 6 1.43750000 1.45312500 1.46875000 6.838e- 7 1.43750000 1.44531250 1.45312500 1.915e- 8 1.43750000 1.44140625 1.44531250 -5.259e- ans =

Problem 2 – Regula Falsi

Prob2_RF(1,2,8) k a xmid b f(xmid) 1 1.00000000 1.28571429 2.00000000 -8.746e- 2 1.28571429 1.39205955 2.00000000 -3.024e- 3 1.39205955 1.42673363 2.00000000 -9.579e- 4 1.42673363 1.43750932 2.00000000 -2.948e- 5 1.43750932 1.44080668 2.00000000 -8.995e- 6 1.44080668 1.44181086 2.00000000 -2.737e- 7 1.44181086 1.44211623 2.00000000 -8.320e- 8 1.44211623 1.44220905 2.00000000 -2.529e- ans =

Functional Plot

  • 0 2 4 6 -1.5 -1 -0.5 0 0.5 1 1.5 2 2. x value f(x)

Problem 3 – Assignment 1 - f(x) = x^4 – 0. Problem 3 – Bisection Method

Prob3_BS(0,1,8) k a xmid b f(xmid) 1 0.00000000 0.50000000 1.00000000 -3.875e- 2 0.50000000 0.75000000 1.00000000 -1.336e- 3 0.75000000 0.87500000 1.00000000 1.362e- 4 0.75000000 0.81250000 0.87500000 -1.419e- 5 0.81250000 0.84375000 0.87500000 5.682e- 6 0.81250000 0.82812500 0.84375000 2.031e- 7 0.81250000 0.82031250 0.82812500 2.811e-

Prob2_BS(1,2,8) k a xmid b f(xmid) 1 1.00000000 1.50000000 2.00000000 3.750e- 2 1.00000000 1.25000000 1.50000000 -1.047e+ 3 1.25000000 1.37500000 1.50000000 -4.004e- 4 1.37500000 1.43750000 1.50000000 -2.954e- 5 1.43750000 1.46875000 1.50000000 1.684e- 6 1.43750000 1.45312500 1.46875000 6.838e- 7 1.43750000 1.44531250 1.45312500 1.915e- 8 1.43750000 1.44140625 1.44531250 -5.259e- ans = 1. >> Problem 2 – Regula Falsi >> Prob2_RF(1,2,8) k a xmid b f(xmid) 1 1.00000000 1.28571429 2.00000000 -8.746e- 2 1.28571429 1.39205955 2.00000000 -3.024e- 3 1.39205955 1.42673363 2.00000000 -9.579e- 4 1.42673363 1.43750932 2.00000000 -2.948e- 5 1.43750932 1.44080668 2.00000000 -8.995e- 6 1.44080668 1.44181086 2.00000000 -2.737e- 7 1.44181086 1.44211623 2.00000000 -8.320e- 8 1.44211623 1.44220905 2.00000000 -2.529e- ans = 1. ## Functional Plot - - - 0 2 4 6 -1.5 -1 -0.5 0 0.5 1 1.5 2 2. x value f(x) Problem 3 – Assignment 1 - f(x) = x^4 – 0. Problem 3 – Bisection Method >> Prob3_BS(0,1,8) k a xmid b f(xmid) 1 0.00000000 0.50000000 1.00000000 -3.875e- 2 0.50000000 0.75000000 1.00000000 -1.336e- 3 0.75000000 0.87500000 1.00000000 1.362e- 4 0.75000000 0.81250000 0.87500000 -1.419e- 5 0.81250000 0.84375000 0.87500000 5.682e- 6 0.81250000 0.82812500 0.84375000 2.031e- 7 0.81250000 0.82031250 0.82812500 2.811e- 8 0.81250000 0.81640625 0.82031250 -5.752e- ans =

Problem 3 – Regula Falsi

Prob3_RF(0,1,8) k a xmid b f(xmid) 1 0.00000000 0.45000000 1.00000000 -4.090e- 2 0.45000000 0.68456520 1.00000000 -2.304e- 3 0.68456520 0.77768815 1.00000000 -8.422e- 4 0.77768815 0.80720911 1.00000000 -2.543e- 5 0.80720911 0.81573072 1.00000000 -7.221e- 6 0.81573072 0.81811857 1.00000000 -2.013e- 7 0.81811857 0.81878197 1.00000000 -5.586e- Prob2_RF(1,2,8) k a xmid b f(xmid) 1 1.00000000 1.28571429 2.00000000 -8.746e- 2 1.28571429 1.39205955 2.00000000 -3.024e- 3 1.39205955 1.42673363 2.00000000 -9.579e- 4 1.42673363 1.43750932 2.00000000 -2.948e- 5 1.43750932 1.44080668 2.00000000 -8.995e- 6 1.44080668 1.44181086 2.00000000 -2.737e- 7 1.44181086 1.44211623 2.00000000 -8.320e- 8 1.44211623 1.44220905 2.00000000 -2.529e- ans = 1. ## Functional Plot - - - 0 2 4 6 -1.5 -1 -0.5 0 0.5 1 1.5 2 2. x value f(x) Problem 3 – Assignment 1 - f(x) = x^4 – 0. Problem 3 – Bisection Method >> Prob3_BS(0,1,8) k a xmid b f(xmid) 1 0.00000000 0.50000000 1.00000000 -3.875e- 2 0.50000000 0.75000000 1.00000000 -1.336e- 3 0.75000000 0.87500000 1.00000000 1.362e- 4 0.75000000 0.81250000 0.87500000 -1.419e- 5 0.81250000 0.84375000 0.87500000 5.682e- 6 0.81250000 0.82812500 0.84375000 2.031e- 7 0.81250000 0.82031250 0.82812500 2.811e- 8 0.81250000 0.81640625 0.82031250 -5.752e- ans = 0. Problem 3 – Regula Falsi >> Prob3_RF(0,1,8) k a xmid b f(xmid) 1 0.00000000 0.45000000 1.00000000 -4.090e- 2 0.45000000 0.68456520 1.00000000 -2.304e- 3 0.68456520 0.77768815 1.00000000 -8.422e- 4 0.77768815 0.80720911 1.00000000 -2.543e- 5 0.80720911 0.81573072 1.00000000 -7.221e- 6 0.81573072 0.81811857 1.00000000 -2.013e- 7 0.81811857 0.81878197 1.00000000 -5.586e- 8 0.81878197 0.81896583 1.00000000 -1.548e- ans =

Functional Plot

x value

f(x)

Problem 3 – Secant Method

Prob3_Sec(0,1,8) k a b xmid f(xmid) 1 0.00000000 1.00000000 0.45000000 -4.090e- 2 1.00000000 0.45000000 0.68456520 -2.304e- 3 0.45000000 0.68456520 0.98713181 4.995e- 4 0.68456520 0.98713181 0.78006781 -7.972e- 5 0.98713181 0.78006781 0.80856634 -2.257e- 6 0.78006781 0.80856634 0.81982262 1.731e- 7 0.80856634 0.81982262 0.81902103 -3.347e- 8 0.81982262 0.81902103 0.81903624 -4.816e- ans =

Problem 3 – Newton Method

Prob3_New(0.5) k f(x) dfdx x(k+1) 0 -3.875e-001 5.000e-001 1. 1 2.193e+000 8.291e+000 1. 2 5.928e-001 4.128e+000 0. 3 1.148e-001 2.606e+000 0. 4 8.460e-003 2.229e+000 0. 5 5.836e-005 2.198e+000 0. 6 2.838e-009 2.198e+000 0. 7 -5.551e-017 2.198e+000 0.

Problem 3 – Muller Method

Prob3_Mul(0,0.5,1,8) k a b c xmid f(xmid) 1 0.00000000 0.50000000 1.00000000 3.60000000 1.675e+ 2 0.50000000 1.00000000 3.60000000 0.70666667 -2.006e- 3 1.00000000 3.60000000 0.70666667 0.99143516 5.162e- 4 3.60000000 0.70666667 0.99143516 0.71012775 -1.957e- 5 0.70666667 0.99143516 0.71012775 0.78636919 -6.761e- 6 0.99143516 0.71012775 0.78636919 0.78746107 -6.548e- 7 0.71012775 0.78636919 0.78746107 0.82661224 1.688e- 8 0.78636919 0.78746107 0.82661224 0.82105647 4.456e- ans =

Problem 4 – Secant Method

Prob4_Sec(2,3,8) k a b xmid f(xmid) 1 2.00000000 3.00000000 2.55555556 -1.372e+ 2 3.00000000 2.55555556 2.66905005 -2.338e- 3 2.55555556 2.66905005 2.69236876 1.888e- 4 2.66905005 2.69236876 2.69062668 -2.275e- 5 2.69236876 2.69062668 2.69064743 -2.169e- 6 2.69062668 2.69064743 2.69064745 2.498e- 7 2.69064743 2.69064745 2.69064745 1.776e- 8 2.69064745 2.69064745 2.69064745 1.776e- ans =

Problem 4 – Newton Method

Prob4_New(2.5,8) k f(x) dfdx x(k+1) 0 -1.875e+000 8.750e+000 2. 1 2.624e-001 1.124e+001 2. 2 3.332e-003 1.096e+001 2. 3 5.613e-007 1.096e+001 2. 4 1.776e-014 1.096e+001 2. 5 -1.776e-015 1.096e+001 2. 6 -1.776e-015 1.096e+001 2. 7 -1.776e-015 1.096e+001 2.

Problem 4 – Muller Method

Prob4_Mul(2,2.5,3,8) k a b c xmid f(xmid) 1 2.00000000 2.50000000 3.00000000 2.80000000 1.272e+ 2 2.50000000 3.00000000 2.80000000 2.65957447 -3.346e- 3 3.00000000 2.80000000 2.65957447 2.70674487 1.779e- 4 2.80000000 2.65957447 2.70674487 2.68882087 -1.999e- 5 2.65957447 2.70674487 2.68882087 2.69036863 -3.054e- 6 2.70674487 2.68882087 2.69036863 2.69063124 -1.775e- 7 2.68882087 2.69036863 2.69063124 2.69064773 3.095e- 8 2.69036863 2.69063124 2.69064773 2.69064745 2.744e- ans =

Problem 5 – Assignment 1 f(x) = x^3 – x^2 – 24x – 32 Problem 5 – Bisection Method: 1 st^ Root (-4,-3)

Prob5_BS(-4,-3,8) k a xmid b f(xmid) 1 -4.00000000 -3.50000000 -3.00000000 -3.125e+ 2 -3.50000000 -3.25000000 -3.00000000 1.109e+ 3 -3.50000000 -3.37500000 -3.25000000 -8.340e- 4 -3.37500000 -3.31250000 -3.25000000 1.804e- 5 -3.37500000 -3.34375000 -3.31250000 -3.160e- 6 -3.34375000 -3.32812500 -3.31250000 -6.511e- 7 -3.32812500 -3.32031250 -3.31250000 5.832e- 8 -3.32812500 -3.32421875 -3.32031250 -3.228e- ans = -3. Problem 4 – Newton Method >> Prob4_New(2.5,8) k f(x) dfdx x(k+1) 0 -1.875e+000 8.750e+000 2. 1 2.624e-001 1.124e+001 2. 2 3.332e-003 1.096e+001 2. 3 5.613e-007 1.096e+001 2. 4 1.776e-014 1.096e+001 2. 5 -1.776e-015 1.096e+001 2. 6 -1.776e-015 1.096e+001 2. 7 -1.776e-015 1.096e+001 2. >> Problem 4 – Muller Method >> Prob4_Mul(2,2.5,3,8) k a b c xmid f(xmid) 1 2.00000000 2.50000000 3.00000000 2.80000000 1.272e+ 2 2.50000000 3.00000000 2.80000000 2.65957447 -3.346e- 3 3.00000000 2.80000000 2.65957447 2.70674487 1.779e- 4 2.80000000 2.65957447 2.70674487 2.68882087 -1.999e- 5 2.65957447 2.70674487 2.68882087 2.69036863 -3.054e- 6 2.70674487 2.68882087 2.69036863 2.69063124 -1.775e- 7 2.68882087 2.69036863 2.69063124 2.69064773 3.095e- 8 2.69036863 2.69063124 2.69064773 2.69064745 2.744e- ans = 2. >> Problem 5 – Assignment 1 f(x) = x^3 – x^2 – 24x – 32 Problem 5 – Bisection Method: 1 st^ Root (-4,-3) >> Prob5_BS(-4,-3,8) k a xmid b f(xmid) 1 -4.00000000 -3.50000000 -3.00000000 -3.125e+ 2 -3.50000000 -3.25000000 -3.00000000 1.109e+ 3 -3.50000000 -3.37500000 -3.25000000 -8.340e- 4 -3.37500000 -3.31250000 -3.25000000 1.804e- 5 -3.37500000 -3.34375000 -3.31250000 -3.160e- 6 -3.34375000 -3.32812500 -3.31250000 -6.511e- 7 -3.32812500 -3.32031250 -3.31250000 5.832e- 8 -3.32812500 -3.32421875 -3.32031250 -3.228e- ans = -3. 2 nd^ Root (-2,-1) Prob5_BS(-2,-1,8) k a xmid b f(xmid) 1 -2.00000000 -1.50000000 -1.00000000 -1.625e+ 2 -2.00000000 -1.75000000 -1.50000000 1.578e+ 3 -1.75000000 -1.62500000 -1.50000000 6.836e- 4 -1.62500000 -1.56250000 -1.50000000 -7.561e- 5 -1.62500000 -1.59375000 -1.56250000 -3.382e- 6 -1.62500000 -1.60937500 -1.59375000 -1.335e- 7 -1.62500000 -1.61718750 -1.60937500 -3.222e- 8 -1.62500000 -1.62109375 -1.61718750 1.816e- ans = -1.

Functional Plot

x value

f(x)

Problem 5 – Secant Method 1 st^ Root (-4,-3)

Prob5_Sec(-4,-3,8) k a b xmid f(xmid) 1 -4.00000000 -3.00000000 -3.20000000 1.792e+ 2 -3.00000000 -3.20000000 -3.36231884 -6.212e- 3 -3.20000000 -3.36231884 -3.32053600 5.481e- 4 -3.36231884 -3.32053600 -3.32392377 1.432e- 5 -3.32053600 -3.32392377 -3.32401464 -3.467e- 6 -3.32392377 -3.32401464 -3.32401442 2.183e- 7 -3.32401464 -3.32401442 -3.32401442 -7.105e- 8 -3.32401442 -3.32401442 -3.32401442 1.421e- ans = -3. 2 nd^ Root (-2,-1) Prob5_Sec(-2,-1,8) k a b xmid f(xmid) 1 -2.00000000 -1.00000000 -1.71428571 1.166e+ 2 -1.00000000 -1.71428571 -1.63968668 2.555e- 3 -1.71428571 -1.63968668 -1.61875811 -1.194e- 4 -1.63968668 -1.61875811 -1.61969258 1.098e- 5 -1.61875811 -1.61969258 -1.61968407 4.620e- 6 -1.61969258 -1.61968407 -1.61968406 -1.847e- 7 -1.61968407 -1.61968406 -1.61968406 7.105e- 8 -1.61968406 -1.61968406 -1.61968406 0.000e+ ans = -1. 3 rd^ Root (5,6) Note 6 iterations were used, because the problem converged to the solution. Prob5_Sec(5,6,6) k a b xmid f(xmid) 1 5.00000000 6.00000000 5.92857143 -1.056e+ 2 6.00000000 5.92857143 5.94349550 -1.423e- 3 5.92857143 5.94349550 5.94369922 5.183e- 4 5.94349550 5.94369922 5.94369848 -2.526e- 5 5.94369922 5.94369848 5.94369848 0.000e+ 6 5.94369848 5.94369848 5.94369848 0.000e+ ans =

Problem 5 – Newton Method 1 st^ Root (-3.5)

Prob5_New(-3.5,8) k f(x) dfdx x(k+1) 0 -3.125e+000 1.975e+001 -3. 1 -2.840e-001 1.619e+001 -3. 2 -3.388e-003 1.580e+001 -3. 3 -5.045e-007 1.580e+001 -3. 4 -2.132e-014 1.580e+001 -3. 5 -7.105e-015 1.580e+001 -3. 6 1.421e-014 1.580e+001 -3. 7 -1.421e-014 1.580e+001 -3.

2 nd^ Root (-1.5)

Prob5_New(-1.5,8) k f(x) dfdx x(k+1) 0 -1.625e+000 -1.425e+001 -1. 1 -7.300e-002 -1.296e+001 -1. 2 -1.857e-004 -1.289e+001 -1. 3 -1.215e-009 -1.289e+001 -1. 4 -3.553e-015 -1.289e+001 -1. 5 0.000e+000 -1.289e+001 -1. 6 0.000e+000 -1.289e+001 -1. 7 0.000e+000 -1.289e+001 -1.

3 rd^ Root (5.5)

Prob5_New(5.5,8) k f(x) dfdx x(k+1) 0 -2.788e+001 5.575e+001 6. 1 4.000e+000 7.200e+001 5. 2 5.230e-002 7.012e+001 5. 3 9.363e-006 7.010e+001 5. 4 3.126e-013 7.010e+001 5. 5 0.000e+000 7.010e+001 5. 6 0.000e+000 7.010e+001 5. 7 0.000e+000 7.010e+001 5.

Problem 5 – Muller Method 1 st^ Root (-4,-3.5,-3)

Prob5_Mul(-4,-3.5,-3,8) k a b c xmid f(xmid) 1 -4.00000000 -3.50000000 -3.00000000 -3.37864078 -8.957e- 2 -3.50000000 -3.00000000 -3.37864078 -3.28070175 6.636e- 3 -3.00000000 -3.37864078 -3.28070175 -3.30936343 2.291e- 4 -3.37864078 -3.28070175 -3.30936343 -3.32238228 2.575e- 5 -3.28070175 -3.30936343 -3.32238228 -3.32447121 -7.217e- 6 -3.30936343 -3.32238228 -3.32447121 -3.32403120 -2.650e- 7 -3.32238228 -3.32447121 -3.32403120 -3.32401390 8.186e- 8 -3.32447121 -3.32403120 -3.32401390 -3.32401443 -8.405e- ans = -3. 2 nd^ Root (-2,-1.5,1) Prob5_Mul(-2,-1.5,-1,8) k a b c xmid f(xmid) 1 -2.00000000 -1.50000000 -1.00000000 -1.64444444 3.156e- 2 -1.50000000 -1.00000000 -1.64444444 -1.59701493 -2.952e- 3 -1.00000000 -1.64444444 -1.59701493 -1.62473005 6.490e- 4 -1.64444444 -1.59701493 -1.62473005 -1.61993953 3.293e- 5 -1.59701493 -1.62473005 -1.61993953 -1.61973549 6.629e- 6 -1.62473005 -1.61993953 -1.61973549 -1.61968348 -7.578e- 7 -1.61993953 -1.61973549 -1.61968348 -1.61968406 -7.699e- 8 -1.61973549 -1.61968348 -1.61968406 -1.61968406 1.771e- ans = -1.

2 nd^ Root (1,2)

Prob6_BS(1,2,8) k a xmid b f(xmid) 1 1.00000000 1.50000000 2.00000000 -1.500e+ 2 1.00000000 1.25000000 1.50000000 7.813e- 3 1.25000000 1.37500000 1.50000000 -3.867e- 4 1.25000000 1.31250000 1.37500000 1.948e- 5 1.31250000 1.34375000 1.37500000 -9.711e- 6 1.31250000 1.32812500 1.34375000 4.864e- 7 1.32812500 1.33593750 1.34375000 -2.430e- 8 1.32812500 1.33203125 1.33593750 1.215e- ans =

3 rd^ Root (2,3)

Prob6_BS(2,3,8) k a xmid b f(xmid) 1 2.00000000 2.50000000 3.00000000 0.000e+ 2 2.00000000 2.25000000 2.50000000 -3.094e+ 3 2.25000000 2.37500000 2.50000000 -1.855e+ 4 2.37500000 2.43750000 2.50000000 -1.009e+ 5 2.43750000 2.46875000 2.50000000 -5.256e- 6 2.46875000 2.48437500 2.50000000 -2.681e- 7 2.48437500 2.49218750 2.50000000 -1.354e- 8 2.49218750 2.49609375 2.50000000 -6.802e- ans =

Problem 6 –Regula Falsi Method 1 st^ Root (-0.5,0.5)

Prob6_RF(-0.5,0.5,8) k a xmid b f(xmid) 1 -0.50000000 0.26744186 0.50000000 3.819e+ 2 -0.50000000 0.12321387 0.26744186 2.126e+ 3 -0.50000000 0.05206972 0.12321387 9.799e- 4 -0.50000000 0.02112194 0.05206972 4.122e- 5 -0.50000000 0.00841964 0.02112194 1.668e- 6 -0.50000000 0.00333245 0.00841964 6.639e- 7 -0.50000000 0.00131522 0.00333245 2.626e- 8 -0.50000000 0.00051850 0.00131522 1.036e- ans = 5.1850e- 2 nd^ Root (1,2) Prob6_RF(1,2,8) k a xmid b f(xmid) 1 1.00000000 1.42857143 2.00000000 -8.746e- 2 1.00000000 1.33182844 1.42857143 1.405e- 3 1.33182844 1.33335771 1.42857143 -2.275e- 4 1.33182844 1.33333334 1.33335771 -3.635e- 5 1.33182844 1.33333333 1.33333334 -5.812e- 6 1.33182844 1.33333333 1.33333333 7.105e- 7 1.33333333 1.33333333 1.33333333 0.000e+ 8 1.33333333 1.33333333 1.33333333 0.000e+ ans =

3 rd^ Root (2,3)

Prob6_RF(2,3,8) k a xmid b f(xmid) 1 2.00000000 2.21052632 3.00000000 -3.368e+ 2 2.21052632 2.35528039 3.00000000 -2.090e+ 3 2.35528039 2.43412610 3.00000000 -1.059e+ 4 2.43412610 2.47144366 3.00000000 -4.819e- 5 2.47144366 2.48789703 3.00000000 -2.086e- 6 2.48789703 2.49492066 3.00000000 -8.832e- 7 2.49492066 2.49787722 3.00000000 -3.705e- 8 2.49787722 2.49911439 3.00000000 -1.548e- ans =

Problem 6 – Secant Method 1 st^ Root (-0.5, 0.5)

Prob6_Sec(-0.5,0.5,8) k a xmid b f(xmid) 1 -0.50000000 0.50000000 0.26744186 3.819e+ 2 0.50000000 0.26744186 -0.48419120 -1.576e+ 3 0.26744186 -0.48419120 0.12082380 2.091e+ 4 -0.48419120 0.12082380 0.04993403 9.421e- 5 0.12082380 0.04993403 -0.00817840 -1.651e- 6 0.04993403 -0.00817840 0.00048762 9.747e- 7 -0.00817840 0.00048762 0.00000455 9.110e- 8 0.00048762 0.00000455 -0.00000000 -5.111e- ans = -2.5554e- 2 nd^ Root (1,2) Note there are only 6 iterations because it converged on the number Prob6_Sec(1,2,6) k a xmid b f(xmid) 1 1.00000000 2.00000000 1.42857143 -8.746e- 2 2.00000000 1.42857143 1.26865672 6.062e- 3 1.42857143 1.26865672 1.33412048 -7.346e- 4 1.26865672 1.33412048 1.33333668 -3.126e- 5 1.33412048 1.33333668 1.33333333 2.649e- 6 1.33333668 1.33333333 1.33333333 0.000e+ ans =

3 rd^ Root (2,3)

Prob6_Sec(2,3,8) k a xmid b f(xmid) 1 2.00000000 3.00000000 2.21052632 -3.368e+ 2 3.00000000 2.21052632 2.35528039 -2.090e+ 3 2.21052632 2.35528039 2.59204140 1.802e+ 4 2.35528039 2.59204140 2.48242850 -3.007e- 5 2.59204140 2.48242850 2.49810736 -3.304e- 6 2.48242850 2.49810736 2.50004262 7.460e- 7 2.49810736 2.50004262 2.49999990 -1.778e- 8 2.50004262 2.49999990 2.50000000 -9.528e- ans =