Download Assignment 1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

History of trigonometry wikipedia , lookup

History of the function concept wikipedia , lookup

Big O notation wikipedia , lookup

Principia Mathematica wikipedia , lookup

Transcript
EGR106 Section 7
Assignment # 1
Due Feb 5, 2008
NAME
This exercise is to provide a first look at “Matlab” by completing some simple
assignments. It is critical in “Matlab” to be very precise with input, otherwise the output
is meaningless. Problem 10 highlights the issue – do not miss out any of the punctuation
marks or replace them with others by miss-hitting keys.
Directions: Log on to ECL then open up “Matlab” . Solve the following problems
using MATLAB (not your calculator or pencil and paper or your fellow student – his/her
assignment will likely be different!) and write the answers in the spaces provided. When
appropriate, please show 4 significant digits for each answer.
Preferable to use the “Help” command when looking for explanations, for example at the
command prompt, >>, type in “help exp” and a brief description will pop up in the
command window. “Lookfor” command just lists everything with the letters that you ask
for, for example “lookfor exp” goes on for several pages with every combination of “exp”
and the computer will feel as if it locked up!!! You have been warned!!
1. 4 * 15 + 9 / 5 =
Think about which operation happens first
(so called precedence of operators).
2. 2 – 8 =
A superscript means raise to a power, computed
in MATLAB using the hat operator ^.
3. 25 + 9 e 2.4 =
e is the constant 2.71828 so e with a superscript
is that constant raised to a power. While the hat
^ operator would work, for the special case of e
there is a built in function in MATLAB called
exp. Type help exp in the command window
to learn how to use this. Note the need for
parentheses to identify the exponent! Also, note
that the 9 is multiplying the exponential – be
sure to use a multiplication sign!
4. 4.2  log10 4 =
log10 is common mathematical notation for
computing a logarithm to the base 10. Use
help log to find the precise usage of that
function.
5.  5.2734 =
Use lookfor and help to find out how to
compute square roots. Remember, lookfor
takes only a single word to search with.
6. 2.2 tan 30 o =
tan is the trigonometric tangent (use lookfor).
Recall that MATLAB normally uses radians,
not degrees, in its trigonometric functions
(and that π radians equals 180 degrees) so
you will need to convert (by the way, pi is a
built in constant for π). Another approach is
to use the degrees version of the trig
functions.
7. ln 0.39 =
ln is standard mathematical notation for the
natural logarithm, to the base e. Use “help”.
8. cos -1 0.5 =
degrees
=
radians
A trigonometric function with a superscript
of minus one means the inverse function, in
this case the inverse or arc cosine (not one
divided by the cosine!). Note that I want the
answer in both degrees and radians. MATLAB
has functions to do both. Use help.
9. In this problem start using the arrow keys on the keyboard and copy and paste in
the bar menu to repeat the lines in the program and just change the variables.
Recall from high school math that the quadratic function of a variable x is of the form
 b  b 2  4ac
2a
a x2 + bx + c = 0 (where a, b, and c are constants). This equation has two solutions,
or “roots”, that can be found by the evaluating the quadratic equation
x
(using the plus sign yields one solution, using the minus sign yields the other).
Further, if the coefficients a, b, and c are real numbers then the solutions are either
both real values or occur as a complex conjugate pair; which depends upon the sign of
the discriminant (the term under the square root). Find the two solutions for x of the
equation x 2 + 3.5 x + c = 0 for each of the two choices for c below (i.e. plug into the
quadratic equation for x above – note that you can easily edit previous commands
using arrow keys; hence, you need only type in the above expression once):

c=2
x=
and x =

c=8
x=
and x =
10. For this problem you will generate a simple graph using MATLAB. Specifically, for x
between –3 and 3 you will plot the function y = x4  4x2 + 3. You should use the
following commands to generate the plot – type them exactly as shown (including the
periods), the particular syntax used will make more sense over the next few weeks.
xv = –2:0.1:2;
yv = xv.^4 – 3*xv.^2 + 1;
plot(xv,yv)

Then use the commands xlabel, ylabel, and title to annotate the plot (use
“Help” to find out how to use these). Finally, to personalize it, use the command
text to include your name, the course title, assignment number, and today’s date on
the plot. Once you have the plot visible on your screen, call either the TA or myself
over to check your result.
11. Problem 3a from chapter 1. Write your answer on the line below:
12. Problem 7a from chapter 1. In this problem, use variables for the values of a, b, and c
and then use math to find d. Evaluate the requested expression. Then, without doing
much work beyond pressing the up arrow, reevaluate the expression for a = 16.62. Put
your two answers on the lines provided: