2022 Gen 12 Final
2022 Gen 12 Final
2022 Gen 12 Final
Question 1: (6pts)
a. Calculate the arithmetic operations below:
i. 123 + 15! – √𝐴𝐴𝐴
̅̅̅̅̅̅
ii. Define a column vector x = (1, 2, 3, 4, 5); Transpose this vector?
Question 2: (8pts)
a) Determine an equation using curve fitting in Matlab to predict the metabolism rate as a
function of mass based on the following data. Use it to predict the metabolism rate of a
200-kg tiger:
b) Use the function newtraph.m to find the root of the function 𝑦 = 𝑥 2 − ̅̅̅̅̅̅
𝐴𝐴𝐴 (select
suitable guess, tolerance, number of iterations).
function [root,ea,iter]=newtraph(func,dfunc,xr,es,maxit)
% newtraph: Newton-Raphson root location zeroes
[root,ea,iter]=newtraph(func,dfunc,xr,es,maxit,p1,p2,...):
% uses Newton-Raphson method to find the root of func
% input:
% func = name of function
% dfunc = name of derivative of function
% xr = initial guess
% es = desired relative error (default = 0.0001%)
% 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
iter = 0;
while(1)
xrold = xr;
xr = xr - func(xr)/dfunc(xr);
iter = iter + 1;
if xr ~= 0, ea = abs((xr - xrold)/xr) * 100; end
if ea <= es | iter >= maxit, break, end
end
root = xr;
1 1 1 1 1
c) Write a script file to computes and display 1 ... using for statement
3 5 7 9 1003
d) Solve the system of linear equation using three methods: inv, mldivide, and lu:
𝑥 − 2𝑦 + 3𝑧 = 9
−𝑥 + 3𝑦 − 𝑧 = −6
2𝑥 − 5𝑦 + 5𝑧 = 17
Question 3: (6pts)
a. A company makes two types of products A and B. These products are produced during a
40-hour work week and then shipped out at the end of the week. They require 20 and 5 kg
of raw material per kg of product, respectively, and the company has access to 9500 kg of
raw material per week. Only one product can be created at a time with production times
for each of 0.04 and 0.12 hr, respectively. The plant can only store 550 kg of total product
per week. Finally, the company makes profits of $45 and $20 on each unit of A and B,
respectively. Each unit of product is equivalent to a kg.
Solve the problem above to maximize profit using function linprog ?
b. Given the function: (𝑥) = 2 + 𝑥 3 + 𝑒 2𝑥+1 . Use the forward difference formula to
differentiate the function f(x) with the step 0.1 and 0.01.