EML 3002L M.E. Tools Lab 11/08/18
Matlab Exam 1 Van Dommelen 12:30-1:45 pm
NO CELL PHONES, HEADPHONES/BUDS, NO CALCULATORS. SAVE FREQUENTLY.
SAVE BEFORE PUBLISHING!!!
ONLY MATLAB MAY BE ACTIVE ON YOUR COMPUTER. Acrobat may only be open
at the end, when you are ready except for publishing and actively
looking at exam2q1.pdf, exam2q2.pdf, or exam2q3.pdf with it.
VARIABLE NAMES MUST BE APPROPRIATE AND CLEARLY SHOW WHAT VARIABLE IT
IS OR A 50% CREDIT REDUCTION IS APPLIED.
After translation into mathematics, only Matlab may be used to
solve the full problem as posed. Use the appropriate procedures
as covered in the lectures.
Open notes: print-outs of lectures and homeworks allowed. You
can also use your own homework .m files.
- Create a script
solvesys.m
(lowercase) that, assuming
that a matrix size
is set before the script is called, solves
the following system of equations
For example, if
, the system in matrix/vector form
should look like, written out,
Script solvesys.m
should initialize the system matrix
and
right hand side vector
to zeros, then put in the
individual nonzero coefficients using an appropriate
for
loop over the interior equations. (Do not use special
matrices here. And the nonzero coefficients of the initial and
final equations should be done separately.) The final matrix and
right hand side vector should be printed out.
Then have Matlab check whether it will be able to find a reasonable
solution to the system, and if not, display a message to that
effect.
Otherwise let Matlab solve the system using the proper method, and
print the solution. However, assuming that the right hand sides of
the equations are measured values with a relative error of 0.001,
let Matlab also estimate the relative error that that solution will
have, and if it is greater than 5%, let Matlab print the following
warning:
*** May have an error of *%
using an appropriate fprintf
(no decimals in the percentage).
Your script should work for any reasonable value of
, but use the
provided script exam2q1.m
to test it out for
and
.
Grading
- One extremely important elementary function is the natural log
; it is used to evaluate powers. Unfortunately, computers used
to be very slow to evaluate the
function. Let's explore one
possibility. Using manipulations that should be relatively easy for
a digital computer but that do not concern us here, the problem can
be reduced to evaluating
where
and in the worst case
Your job is to write a script (being examq2.m
) that tries to
sum the above Taylor series in terms of
to the maximum achievable
accuracy, and to no more than that. However, make sure to never sum
more than 500 terms. To make the summation more efficient, use the
fact that, as long as
is at least 2,
(This relation could be improved upon, but we will keep it simple.)
Before your summation solution, set variable
equal to the worst
case value above. After your summation solution, display a warning if
the maximum accuracy was not achieved, and also, using fprintf
,
print out:
Total number of terms summed: *
The obtained value is 1.1234567890123456
The "exact" value is 1.1234567890123456
The difference between the two is 1.1E-12.
where for the exact
value use
as evaluated
by Matlab directly. Absolutely no data numbers in the fprintf
FORMATSTRINGs.
Grading
- Using the Symbolic Math Toolbox, do the following:
- An unstable system has the Laplace transform solution
- To get an idea of the system properties, factor this ratio
exactly. Your answer should take the form of a single ratio of
multiplied factors.
- Find the exact partial fraction expansion.
- The equation of the normalized “Lemniscate of
Bernoulli” is:
Let Matlab find the exact values of
in terms of
.
- Define the following symbolic function:
Next:
- Let Matlab find the symbolic antiderivative
.
- Let Matlab exactly evaluate
when
and
- Let Matlab convert
into a numerical function
that evaluates the antiderivative numerically.
- Evaluate
when the values 1 and
are substituted for
and
respectively. Print out this
value to 32 decimals behind the point using fprintf
.
- Compare with the earlier exact value, printed out to 32
correct digits.
Grading
Solutions.