CS计算机代考程序代写 matlab 3.2 (a)

3.2 (a)
ENGR20005
Numerical Methods in Engineering
Workshop 3 Solutions
When considering the function
f(x)=x3 −x (1) It’s always a good idea to plot the function so that we have a general idea of
where the roots are located
3 2 1 0
−1 −2
−1.5 −1 −0.5 0 0.5 1 1.5 x
From the figure above we can see that there are three roots to Eq. (1), located at x = −1,0,1
If we consider the initial guesses i. xl =−1.2andxu =1.2
ii. xl =−1.2andxu =1.3
1
f (x)

iii. xl = −1.2 and xu = 1.1
The bisection method will converge to the roots
i. xr = 0 ii. xr =1
iii. xr = −1
(b) Moving onto the function
3 2 1 0
−1 −2
The root of the equation is located at approximately x = 0.6. So a choice of boundscanbexl =0,andxu =1.
An implementation of the Bisection method to solve Eq. (2) with these bounds is given in the MATLAB script Q3 2b sol.m.
3.3 An example of the method of False Position may be found in the MATLAB script Q 3 3 sol.m.
f (x) = exp (−x) − x (2)
3.4
(a) The frictional force on the fluid is given by Fwall = τwπDL
And the pressure force is given by
Fpressure=p1 4 −p2 4 (4)
0 0.2 0.4 0.6 0.8 1 1.2 1.4 x
2
πD2 πD2
(3)
f (x)

At steady state, these forces are in equilibrium, giving the force balance
πD2
τwπDL = (p1 − p2) 4 (5)
(b) Rearranging for the pressure gradient dp/dx, we have
dp=p2−p1 =−4τw (6)
dx L D
(c) An implementation of a function to determine the friction factor as a function of the Reynolds number and the roughness ratio is given in Q3 4 sol.m.
Your plot should look something like
102 101 100
10−1
10−2
10−3
100 101 102
103 104 105 Re
106 107 108
3
f