Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Staple Here

Family Name:

First/Given Name:

Student Number:

MIE334: Numerical Methods Assignment 1: Solution


Due: Friday, January 26th, 4:00 pm, 2018

1. The following data represent the radial intensity of a radio-frequency plasma obtained by
scanning the plasma with an optical spectrometer.
Radius (mm) 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Intensity (cps) 49274 49274 46541 45423 44551 40707 33570 28643 20877 16443 8809

Also, the following equation is a 3rd order polynomial which has been fit to the data points
above using the least-square regression method.
𝐼 = 135.65𝑟 3 − 2679𝑟 2 + 1971.9𝑟 + 48768
Develop a simple m-file in MATLAB to plot both the data points and the fitted curve in one
figure.
Your m-file should include the following:

 A command to automatically set 𝑥 axis limits to 0 < 𝑥 < 5


 A command to automatically set 𝑦 axis limits to 0 < 𝑦 < 60000
 A command to set the plot title to your “Family Name”
 A command to set the 𝑥 axis label to “radius (mm)”
 A command to set the 𝑦 axis label to “Intensity (cps)”
 Plot both functions in the same window
 Set the color of data points to “red” and the color of the fitted curve to “black”
 Set the line style for the fitted curve to “dash-dot”
 Set a legend for the graph wherein the data points are denoted as “experimental” and the fitted
curve as “analytical”.

Print your m-file in the box below. Also, after plotting the graph, in the plot window, “save-
as” your image with JPEG format, paste it in a word document and print it. Then cut it and
paste it in the designated box.
1
Staple Here

Family Name/ First Name Initial: Student Number:

m-file
clear
clc

% Creating variables containing the data points


I = [49274 49274 46541 45423 44551 40707 33570 28643 20877 16443 8809];
r = [0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5];

% Plotting the data points in "red" color


scatter(r,I,'r')

hold on

% Creating a symbolic relation for the fitted curve


syms x
II = 135.65*x^3-2679*x^2+1971.9*x+48768;

% Plotting the fitted curve as a line in "black" color


fplot(II,'--k')

% Setting graph parameters


axis([0, 5, 5, 60000]);
legend('analytical','experimental')
xlabel('r (mm)')
ylabel('I (cps)')
title('Family Name')

Plot

2
Staple Here

Family Name/ First Name Initial: Student Number:

2. The Genco Olive Oil Company intends to sell its oil products to the customers in 1-Liter
cylindrical cans. The owner has asked you to minimize the cost of metal sheet for fabricating
the cans. To fulfill his request:
a) First obtain a formula for the surface area 𝐴 of the can in terms of its base radius 𝑟.
(Hint: Remember that the container has to have a lid as well).
b) Then using the Newton-Raphson method and the formula you obtained in the previous
part, find the base radius 𝑟 for which the surface area and, as a result, the metal sheet
required to fabricate the can is minimum. Use 𝑟 = 10 𝑐𝑚 as you initial guess and
continue your iterations to achieve a relative error of less than 1%. Use the table
provided below to organize your calculations. Write the details of your calculations for
the first two iterations and keep 4 significant figures after the decimal point. (First fill out
the table and then print the page).
c) What would be the height ℎ of the cans?

Newton-Raphson Method:
iteration 𝑟, 𝑐𝑚 𝑓(𝑟) 𝑓 ′ (𝑟) 𝜀𝑎 (%)
1 10 105.6600 16.5660
2 3.6219 −106.9499 96.7557 176.1000
4.7272 −30.0960 50.4310 23.3828
5.3240 −3.6574 39.0719 11.2091
5.4176 −0.0639 37.7216 1.7278
𝟓. 𝟒𝟏𝟗𝟑 0.0000 37.6980 𝟎. 𝟎𝟑𝟏𝟑
< 𝟏%

Calculations:

3
Staple Here

Family Name/ First Name Initial: Student Number:

4
Staple Here

Family Name/ First Name Initial: Student Number:

3. First, explain the difference between truncation error and round-off error. Then using the
Taylor series expansion, derive an expression for the truncation error due to approximating
the 2nd derivative of 𝑓(𝑥) at 𝑥 = 𝑥0 using the following relation. Also determine the order 𝑛
of the error for this approximation.

𝑓(𝑥0 − 2ℎ) + 𝑓(𝑥0 + 2ℎ) − 2𝑓(𝑥0 )


𝑓′′(𝑥0 ) = + 𝑂(ℎ𝑛 )
4ℎ2

4. First plot 𝑓(𝑥) = 𝑥 2 |cos(√𝑥)| using the grid provided below by finding some (at least 25)
points and then connecting the points using a smooth curve. Next, based on the insight
obtained from plotting the function, use the false-position method to determine the smallest
positive root of 𝑥 2 |cos(√𝑥)| = 0.5 where 𝑥 is in radians. Use the table provided below for
your iterations and calculations. In solving the problem use a stopping criterion of 𝜀𝑠 = 0.5%.
Write the details of your calculations only for the first two iteration. In your calculations, keep
4 significant figures after the decimal point. (First fill out the table and then print the page).

5
Staple Here

Family Name/ First Name Initial: Student Number:

False-Position Method:
iteration 𝑥𝑙 𝑥𝑢 𝑓(𝑥𝑙 ) 𝑓(𝑥𝑢 ) 𝑥𝑟 𝑓(𝑥𝑟 ) 𝑓(𝑥𝑙 ) × 𝑓(𝑥𝑟 ) 𝜀𝑎 (%)
1 0.2 1.2 0.4639 −0.1590 0.9447 −0.003089 −0.001433
2 0.2 0.9447 0.4639 −0.003089 0.9398 0.0002941 0.0001364 0.5241
3 0.9398 0.9447 0.0002941 −0.003089 𝟎. 𝟗𝟒𝟎𝟐 −0.0000003891 −0.0000000001144 𝟎. 𝟎𝟒𝟓𝟓𝟒
< 𝟎. 𝟓%

6
Staple Here Answer Sheet

Family Name/ First Name Initial: Student Number:

Page Number: 7

You might also like