Sample Assignment-based Part of Exam

advertisement
Sample MATH 272 Exam
Assignment-Based Portion (60 marks)
1. Consider the function
[5 marks]
2 −4x
y=x e
Write a MATLAB script that will produce a smooth graph of this function on the interval x = [0..3].
Submit your entire MATLAB script.
2. Consider the function
[5 marks]
f (x, y) = cos(x2 ) + cos(y 2 )
Write a MATLAB script that will produce a pcolor plot of this function on the domain x = [-3..3], y = [-3..3].
The graph should have appropriate scaling on the x and y axes.
Submit your entire MATLAB script.
3. Explain why using a matrix inverse is an inefficient way to solve a large triangular system of linear equations, and name
a better technique for solving such a system.
[3 marks]
No MATLAB is required for this question.
4. This set of two questions refers to the equation
[3 marks]
2
log10 (x) + 1 = 0.05x
Using any method of your choosing, write a MATLAB script that will find one solution to the equation.
Submit your entire MATLAB script.
5. This set of two questions refers to the equation
[2 marks]
2
log10 (x) + 1 = 0.05x
Using your MATLAB script, and modifying as necessary, find both solutions to the equation.
Report just the solutions, to 6 digits after the decimal. You do not need to submit any MATLAB code for this
question.
6. This set of two questions refers to the points
[5 marks]
x = [-3, -1, 0, 1, 3];
y = [1, 2, 0, 1, 2];
Using a spline interpolant, write a MATLAB script which
• plots the given points as dots, and, on the same axes,
• plots a spline interpolant of the form y = f(x) through those points
Submit your entire MATLAB script.
7. This set of two questions refers to the points
[3 marks]
x = [-3, -1, 0, 1, 3];
y = [1, 2, 0, 1, 2];
The spline interpolant defines a distinct polynomial on each interval between the given x points.
Write out the polynomial that describes the interpolant on the fourth interval i.e. the last interval, between x=1 and
x=3.
No MATLAB code need be submitted for this question.
8. Write a MATLAB script that creates a 4 x 20 matrix called M such that
• the first row contains the values 1, 2, 3,..., 20,
• the second row 2, 4, ..., 40
1
[4 marks]
• the third row row 3, 6, ..., 60
• fourth row 4, 8, ..., 80
Submit your entire MATLAB script.
9. This set of two questions refers to the same integral:
Z 20
(sin(x))2 dx
[9 marks]
0
Write a script that uses Simpson’s rule to estimate the value of the integral above.
• You will need to write the Simpson’s rule algorithm yourself: it is not given.
• The formula for computing the integral on one panel in Simpson’s rule is given on your reference sheet.
Put the full MATLAB script you used below. If you wrote Simpson’s rule as a separate function, separate the main
script and the function with a break like ”——-”.
10. This set of two questions refers to the same integral:
Z 20
(sin(x))2 dx
[ 1 mark]
0
Report the Simpson’s rule estimate for the integral, using N = 100 intervals Report your answer to 8 digits after the
decimal.
11. This set of three questions refers to the same differential equation:
[6 marks]
dP
= AP (1 − P ) − BP
dt
In this model, P (t) represents a relative population over time (0 ≤ P ≤ 1), and A and B represent growth and predation
constants respectively.
Write a script that uses ode45 to simulate the population over time, with parameters
• A = 3.0
• B = 1.0
• time span t=[0, 10], and
• initial population P(0) = 0.9.
Have the script plot the population against time, over the given time interval.
Put the full MATLAB script you used below. If you wrote anything in a separate function, separate the main
script and the function with a break like ”——-”.
12. This set of three questions refers to the same differential equation:
[1 mark]
dP
= AP (1 − P ) − BP
dt
Based on the simulation in your last question, report the value of P at time t=10. Report the value to 8 digits after
the decimal.
No MATLAB needs to be submitted for this question.
13. This set of three questions refers to the same differential equation:
dP
= AP (1 − P ) − BP
dt
We will now investigate the effect of using different values for B on the long-term population.
Write a script that
• loops over B, with values B = 0, 0.1, 0.2, ... 4.9, 5.
• for each B value, simulate the population until t = 10.
• records the final population at the instant t = 10.
2
[ 5 marks]
Based on that loop, you will have a set of B values with their matching resulting final populations: create a plot of the
relationship between them (B value on the x axis, final population on the y axis.)
Except for the changing value of B, use all the same parameters (A, time span, initial conditions) as in the earlier questions.
Put the full MATLAB script you used below. If you wrote anything in a separate function, separate the main
script and the function with a break like ”——-”.
14. Consider the function
2
2
[8 marks]
2
4
f (x, y) = 10x y − 5x − 4y − x − 2y
4
Write a MATLAB script that will find the values of x and y that produce a local maximum of this function, where x
and y are limited to the ranges x = [0..2], and y = [1..4].
Report the optimal values you find for x and y, and then put the full MATLAB script you used below.
Include 4 digits after the decimal for all numeric values.
3
Download