Numerical Methods in Engineering: Assignment week 4
1. Define the smallest positive root of the polynomial x3 + 3.8 x 2 − 8.6 x − 24.4 = 0 .
(a) Use Newton-Raphson’s method to determine the solution in the first five iterations. Use
as a first estimate x=2.
(b) Plot the function and select two points near the root to start the solution process with
the secant method by using five iterations.
Use four decimal points and compare the results. Which method converges faster? Solve
the problem by hand. (25%)
2r sin
2. The centroid c of a circular sector is provided by the equation: x = . Find the
3
r
angle so that x = , by using the bisection method with starting points a=1 and b=2.
2
b −a
Stop the process when the toli = i i 0.002 , where i is the number of iterations. In
2
x (i ) − x (i −1)
every step, calculate also the Estimated Relative Error ERE i = NS (i −1)NS , where xNS
(i )
xNS
is the numerical solution at ith iteration. Use eight decimal points. Solve the problem by
hand. (25%)
Fig. 1. Centroid c of circular sector
3. Write a user-defined function in MatLab named RegulaFalsiRootMod1 that
solves the nonlinear equation f(x)=0 with modified Regula Falsi method (see Fig.2).
The function should check if the endpoints stay the same. If an endpoint stays the same
for three iterations, the value of the function at that point should be divided by 2. If the
value of the point stays the same for three more iterations the value of the function at
that point should be divided again by 2 (the true value is now divided by 4), and so on.
The function should have as input arguments, the function (function handle), two values
that bracket the root and the error. The function should stop when the Estimated
( i −1)
(i )
xNS − xNS
Relative Error ERE i = ( i −1)
becomes smaller or equal to the error (inserted as
xNS
an input argument). If the input arguments are less than 4, the function should
automatically define the error equal to 0.0001. The maximum number of iterations
should be imax=100 and when it has been reached the program should print a message
that states that the solution has not been derived in imax iterations should be shown.
Use the function RegulaFalsiRootMod1 you wrote, to find the smallest positive
root of the polynomial x3 + 12 x 2 − 100 x − 6 = 0 with the initial two values to be 4 and
6. Compare the result you obtained by using MatLab build-in functions fzero and
roots. Use format long to compare as many figures as possible.
For the RegulaFalsiRootMod1 function you are allowed to use the following
build-in functions of MatLab: feval, nargin, error, rem, abs, fprintf. Submit a MatLab
files with explanations and report with comparisons and explanations. (25%)
Fig. 2. Modified Regula falsi method (modification 1, see lecture slides)
4. Write a user-defined function NewtonManyVariables(x,f,jf,tol) where x
is the initial approximation in column array, f is a column array containing the
functions, jf is the Jacobian matrix and tol is the tolerance. The function should be
able to solve a system of nonlinear equations by using the Newton’s method for a
system of nonlinear equations. The user-defined function should return the roots and
number of iterations. The functions f and the matrix jf should be given with function
handle (@). The function should stop when the tolerance has been achieved. Use the
Euclidean norm (norm in MatLab) of the function as tolerance measure. If the tolerance
is not given when the function is called, define it equal to 0.00005. After developing
the function use it solve the following system of equations and report the roots and the
number of iterations, (use as initial values x=5 and y=1 with tolerance 0.00005):
For this assignment you can only use the following build-in functions of MatLab feval,
\, norm, nargin, Use the following set of equations and not the Cramer’r rule: (25%)
Grading criteria:
Correctness
Justification
Efficiency
Presentation