Sunteți pe pagina 1din 8

Instructor: Hacker Name:Arnaz Asa Sholeh

Course: AME 302


Chapter 5 Homework Set (Roots: Bracketing Methods)
Module 2: SLOs #1-2 [Solving Nonlinear Algebraic Equations]
Due Date: 26/02/2019 (The due date will be announced in class.)
Instructions: Print your name neatly. If you forget to write your name, or if I can’t read your writing,
you can lose up to 100 points. Answer all the questions that you can.

You must show your work. You will not receive credit for lucky guesses. Show your work as clearly
as you can: if I can’t understand how you got an answer, I will not give you credit for it. Remember, I
know how to solve the problem; and to make matters worse, I have a lot of training in following logical
arguments!
Warning: The definition of “little or no work” will be determined by the instructor, not the student.

On any problems, clarity is as important as the correct procedure and the correct answer. If you do not
clearly label your steps, and your work within those steps, then I will grade your work as wrong. I will
not waste time struggling to read an incoherent mess that is purported to be the solution; and after the
assignment is handed in and graded, I will not improve your grade based on your explanation of what
you were trying to say. One purpose of these problems is to teach you how to lay out a logical argument
that someone else with a technical background can follow. If in doubt, write it down!

The rules for turning in homework


• All homework must be submitted electronically on d2l. No exceptions! Paper homework will be
graded as zero, regardless of whether all of the problems are correct!
• I will not accept a series of individual photographs of your homework. Only one file will be
excepted. You can enter photos into a word file or use a free program like CamScanner or
iScanner. Moreover, if the problems are not in numerical order, then there is an automatic 20%
reduction in points on top of any other deduction in points for incorrect answers. No Exceptions!
• You must show your work to get any credit.
• You do not need to turn in the questions or the front page of this homework set. Moreover,
you shouldn’t turn it in since there is not enough space provided on this homework set for the
solutions. When you turn in your homework be sure to provide your solutions on clean paper
with the problem you are solving clearly labelled. If the grader can’t locate them, they will not
search for them and the problem will be graded as wrong.

Multiple-choice problems are graded as right or wrong. Some problems have multiple parts with the
points listed. There is no partial credit on any one-point subproblems (e.g., part (a), etc.). All problems
are graded out of 5 points according to the general grading algorithm (rubric):
5 points: Problem is solved correctly with all details clearly shown.
3-4 points: Minor mistake with neat work; correct answer, but work is sloppy; problems are correct, but out
of order; answers are not boxed.
1-2 points: Major mistake, and/or work is very sloppy, etc.
0 points: Solution is not close, or a solution to a wrong problem is given.
Attention: The difference between major and minor mistakes will be determined by the grader, not
the student!
Attention: For all problems involving writing a MATLAB program you must turn in
your MATLAB code with the output to receive any credit!
AME 302 chapter 5 hw set Copyright ©Wayne Hacker 2018. All rights reserved. 2

Problem 1. Use the bisection method to determine the drag coefficient needed so that an
95-kg bungee jumper has a velocity of 46 m/s after 9 s of free fall. Note: The acceleration
of gravity is 9.81 m/s 2. Start with initial guesses of xl = 0.2 and xu = 0.5 and iterate
until the approximate relative error falls below 5%.
Governing equation:
𝑔𝑚 𝑔𝑐𝑑
𝑣(𝑡) = √ (𝑡𝑎𝑛ℎ (√ ) 𝑡)
𝑐𝑑 𝑚
Since,
𝑣(9) = 46, 𝑤ℎ𝑒𝑟𝑒 ∶
𝑚 = 95 𝑘𝑔
𝑚
𝑔 = 9.81 2
𝑠
𝑐𝑑(𝑥𝑙 ) = 0.2
𝑐𝑑(𝑥𝑢 ) = 0.5
Therefore,
𝑔𝑚 𝑔𝑐𝑑
𝑣(𝑡) = √ (𝑡𝑎𝑛ℎ (√ ) 𝑡) − 46
𝑐𝑑 𝑚

No. 𝑥𝑙 𝑓(𝑥𝑙) 𝑥𝑢 𝑓(𝑥𝑢) 𝑥𝑚 𝑓(𝑥𝑚) %error


1. 0.2 12.7065 0.5 -4.2486 0.35 2.3387 60
2. 0.35 2.3387 0.5 -4.2486 0.425 -1.2809 42.8571
3. 0.35 2.3387 0.425 -1.2809 0.3875 0.4341 17.6471
4. 0.3875 0.4341 0.425 -1.2809 0.4062 -0.4430 9.6774
5. 0.3875 0.4341 0.4062 -0.4450 4.6036

So, the drag coefficient is between the interval [0.387,0.4062] with relative error value 4.6036%
(below 5%)
Problem 2. Use the M-file given below for the false position method to determine the
drag coefficient needed so that an 95-kg bungee jumper has a velocity of 46 m/s after 9
s of free fall. Note: The acceleration of gravity is 9.81 m/s 2. Start with initial guesses of
xl = 0.2 and xu = 0.5 and iterate until the approximate relative error falls below 5%.
function [root,ea,iter]=falsepos(func,xl,xu,es,maxit,varargin)
%falsepos: root location zeroes
% [root,ea,iter]=falsepos(func,xl,xu,es,maxit,p1,p2,...): uses
% false position to find the root of func
% input:
% func = name of function
% xl, xu = lower and upper guesses
% es = desired relative error (default = )
% maxit = maximum allowable iterations (default = 50)
%p1,p2,... = additional parameters used by function
%output:
% root = real root
% ea = approximate relative error )
% iter = number of iterations
AME 302 chapter 5 hw set Copyright ©Wayne Hacker 2018. All rights reserved. 3

if nargin<3,error(’at least 3 input arguments required’),end


test = func(xl,varargin{:})*func(xu,varargin{:});
if test>0,error(’no sign change’),end
if nargin<4|es<=0, es=0.0001;end
if nargin<5|maxit<=0, maxit=50;end
iter = 0; xr = xl;
while (1)
xrold = xr;
xr = (xl + xu)/2;
fl=func(xl,varargin{:});
fu=func(xu,varargin{:});
xr = xu - fu*(xl - xu)/(fl - fu);
iter = iter + 1;
if xr ~= 0,ea = abs((xr - xrold)/xr) * 100;end
test = fl*func(xr,varargin{:});
if test < 0
xu = xr;
elseif test > 0
xl = xr;
else
ea = 0;
end
if ea <= es | iter >= maxit,break,end
end
root = xr;

func=@(cd) sqrt(9.81*95/cd)*tanh(sqrt(9.81*cd/95)*9)-46;
[root,ea,iter]=falsepos(func,0.2,0.5,5)

root =

0.3987

ea =

1.4046

iter =

3
AME 302 chapter 5 hw set Copyright ©Wayne Hacker 2018. All rights reserved. 4

Problem 3. Locate the first nontrivial root of the equation: sin(x) = x2 where x is in
radians. Use a graphical technique and bisection with the initial interval from 0.5 to 1.
Perform the computation until sa is less than the stopping criteria ss = 2%.

sin(𝑥) = 𝑥 2 𝑖𝑠 𝑒𝑞𝑢𝑎𝑙 𝑤𝑖𝑡ℎ 𝑓(𝑥) = sin(𝑥) − 𝑥 2 𝑠𝑖𝑛𝑐𝑒 𝑡ℎ𝑒 𝑦 𝑣𝑎𝑙𝑢𝑒 𝑚𝑢𝑠𝑡 𝑏𝑒 0

No. 𝑥𝑙 𝑓(𝑥𝑙) 𝑥𝑢 𝑓(𝑥𝑢) 𝑥𝑚 𝑓(𝑥𝑚 ) %error


1. 0.5 0.2294 1 -0.1585 0.75 0.1191 57
2. 0.75 0.1191 1 -0.1585 0.875 0.001919 28.5
3. 0.875 0.001919 1 -0.1585 0.9375 -0.07283 14.25
4. 0.875 0.001919 0.9375 -0.07283 0.90625 -0.03409 7.13
5. 0.875 0.001919 0.90625 -0.03409 0.890625 -0.01575 3.6
6. 0.875 0.001919 0.890625 -0.01575 0.8828125 -0.00683 1.8

So, the root is between the interval [0.875,0.890625] with relative error value 1.8% (below 2%).
This is proved with the graphical method that shows the true value of 0.877.

Problem 4. As shown in the figure below, the velocity of water, v (m/s), discharged
from a cylindrical tank through a long pipe can be computed as
2𝑔𝐻
𝑣(𝑡) = √2𝑔𝐻 (𝑡𝑎𝑛ℎ (√ ) 𝑡)
2𝐿

where g = 9.81 m/s2, H = initial head (m), L = pipe length (m), and t = elapsed time
(s). Develop a MATLAB script that
(a) plots the function f(H) versus H for H = 0 to 4 m (make sure to label the plot)
AME 302 chapter 5 hw set Copyright ©Wayne Hacker 2018. All rights reserved. 5
h=0:0.1:4;
v=(sqrt(19.62.*h).*tanh(sqrt(19.62.*h)./8).*2.5)-5;
plot(h,v);
xlabel('H');
ylabel('v(m/s)');
xlabel('H(m)');
title('velocity (v) vs initial head (H)');

(b) uses LastNameBisect with initial guesses of xl = 0 and xu = 4 m to determine the


initial head needed to achieve v = 5 m/s in 2.5 s for a 4-m long pipe. In addition, use
Ead = 0.0000001. Also, set format long in your script so you display 15 significant
digits for your results. Attention: The ratio of 2’s in the argument is not a typo!

function [root,fx,ea,iter]=bisect(func,xl,xu,es,maxit,varargin)
% bisect: root location zeroes
% [root,fx,ea,iter]=bisect(func,xl,xu,es,maxit,p1,p2,...):
% uses bisection method to find the root of func
% input:
% func = name of function
% xl, xu = lower and upper guesses
% es = desired relative error (default = 0.0001%)
% maxit = maximum allowable iterations (default = 50)
% p1,p2,... = additional parameters used by func
% output:
AME 302 chapter 5 hw set Copyright ©Wayne Hacker 2018. All rights reserved. 6
% root = real root
% fx = function value at root
% ea = approximate relative error (%)
% iter = number of iterations
if nargin<3,error('at least 3 input arguments required'),end
test = func(xl,varargin{:})*func(xu,varargin{:});
if test>0,error('no sign change'),end
if nargin<4|isempty(es), es=0.0001;end
if nargin<5|isempty(maxit), maxit=50;end
iter = 0; xr = xl; ea = 100;
while (1)
xrold = xr;
xr = (xl + xu)/2;
iter = iter + 1;
if xr ~= 0,ea = abs((xr-xrold)/xr) * 100;end
test = func(xl,varargin{:})*func(xr,varargin{:});
if test < 0
xu = xr;
elseif test > 0
xl = xr;
else
ea = 0;
end
if ea <= es | iter >= maxit,break,end
end
root = xr; fx = func(xr, varargin{:});
fm=@(h) (sqrt(19.62.*h).*tanh(sqrt(19.62.*h)./8).*2.5)-5;
[H fx ea iter]=bisect(@(h) 0,4,0.1,200)

H =

1.4678

fx =

8.0591e-04

ea =

0.0665

iter =

12
AME 302 chapter 5 hw set Copyright ©Wayne Hacker 2018. All rights reserved. 7
Problem 5. For fluid flow in pipes, friction is described by a dimensionless number,
the Fanning friction factor f . The Fanning friction factor is dependent on a number of
parameters related to the size of the pipe and the fluid, which can all be represented
by another dimensionless quantity, the Reynolds number Re. A formula that predicts f
given Re is the von Karman equation:

Typical values for the Reynolds number for turbulent flows are 10,000 to 500,000 and
for the Fanning friction factor are 0.001 to 0.01. Develop a function that uses bisection
to solve for f given a user-supplied value of Re between 2500 and 1,000,000. Design the
function so that it ensures that the absolute error in the result is Ea,d < 0.000005.
function [f,ea]=friction_factor(func,xl,xu,varargin)
if nargin<3,error('at least 3 input arguments required'),end
test = func(xl,varargin{:})*func(xu,varargin{:});
if test>0,error('no sign change'),end
Ead=0.000005;
maxit=50;
iter = 0; xr = xl; ea = 100;

while (1)
xrold = xr;
xr = (xl + xu)/2;
iter = iter + 1;
if xr ~= 0,ea = abs((xr - xrold)/xr) * 100;end
test = func(xl,varargin{:})*func(xr,varargin{:});
if test < 0
xu = xr;
elseif test > 0
xl = xr;
else
ea = 0;
end
if ea <= Ead | iter >= maxit,break,end
end
f = xr;

Matlab Output
>> func=@(f,R) (4.*log10(R.*sqrt(f)))-0.4-(1./sqrt(f));
>> [f,ea]=friction_factor(func, 0.001, 0.1, 2500)
f =
0.011524763640016
ea =
3.200098074059325e-06
>> [f,ea]=friction_factor(func, 0.001, 0.1, 50000)
f =
0.005226501366124
ea =
3.528208596760714e-06
>> [f,ea]=friction_factor(func, 0.001, 0.1, 100000)
f =
0.004500375853851
ea =
4.097477091479237e-06
>> [f,ea]=friction_factor(func, 0.001, 0.1, 1000000)
f =
0.002912819127552
ea =
AME 302 chapter 5 hw set Copyright ©Wayne Hacker 2018. All rights reserved. 8
3.165350500101047e-06

So Ea<5<10^-6

S-ar putea să vă placă și