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

Hanoi University of Mining and Geology

ECM6: Homework # 1 (2012)


Guidelines
This homework assignment is due at the beginning of class Tuesday, Dec11 after second lecture. No late homework
will be accepted. Your homework should be presented for grading in the form of a typed Mathematica Notebook . Do
not submit an electronic copy unless requested. Download the template for this notebook from the web site.

Your homework should show the Mathematica code that you used to obtain the solutions. Make use of the notebook
type setting capabilities to layout your homework clearly.
Thus it is important that you always retain a electronic copy of the homework you turn in for grading.
Problem 1
Write a Mathematica function that evaluates the following product. Take n = 10
n
x-xi
HiL = xi -xj
j=0
ji

Problem 2:
Define the following function in Mathematica: f HxL = x2 + sin Ix - x3 M. Then determine the following:
f H2L, f J t2 M, f H3.1L. Before you begin this assignment Type in Remove[f] and then evaluate. This is to remove all
previous definitions of functions called f.

Problem 3
Define a new function, say g[x_]=Tan[x] and evaluate the cell. Check the the definition using ?. Evaluate g[3.],
g[Sin[x]]. Evaluate the latter at x=/2. Next type in the following and evaluate: ?g, Clear[g]. Then use ? to check on
the definition of g again. Note that the symbol g for your function is still listed in the kernel but the definition has been
deleted. Now evaluate Remove[g] Use ? to check on the definition. In summary, Clear deletes defintions from the
kernel, while Remove deletes all refereneces to that variable or function.

Problem 4
Type in the following expression into an input cell: f[x]:=Tan[x], and then evaluate the expressions f[x], and f[3].Com-
pare the outcome of your result with Problem 8.4. Can you explain what is going on? (Caution: Be sure to remove all
previous defintions of f before doing this problem, using the function Remove)

Problem 5:
Define a function f that has the following RHS

p
H-1Ln x2 n
n
n=0 H2 mL2
m=1

Then define a second function g that calls f as follows

g= 2 - f
Use your definitions to evaluate g at =3.4, =2, p=7. Then evaluate g at another set of parameter values
=.6, =1,p=30. Be sure to use Remove to clear out all previous definitions of g and f in the kernel.
Define a function f that has the following RHS

p
H-1Ln x2 n
2 ECM6Hw1_2012.nb n
n=0 H2 mL2
m=1

Then define a second function g that calls f as follows

g= 2 - f
Use your definitions to evaluate g at =3.4, =2, p=7. Then evaluate g at another set of parameter values
=.6, =1,p=30. Be sure to use Remove to clear out all previous definitions of g and f in the kernel.

Problem 6
p
H-1Ln x2 n
Define a function f(p)= n
n=0 H2 mL2
m=1

that will allow you to evaluate the expression for arbitrary integer values of p. Use Table to generate a list of partial
sums for p=1,2, 10. Use Remove to clear all previous definitions of f

Problem 7:
Use Range to create a numerical vector that has the following properties: (i) the first element is 0.5, the last element is
4.5, each element is separated by 0.125. How many elements are there in the vector you created? Hint: Use the Help
Browser to learn about the function Length and its properties. Repeat the excercise using Table.

Problem 8
Define the following vectors: u={2,4,6,8}, v={3,5,7,9}, w={a,b,c,d} (i) Compute 3u+6v ; (ii) Find the scalar product of
u and v; Hint: the scalar product operator is Dot. (iii) Determine the magnitude of v. (iv) Is the vector product (cross
product) of u and v defined? What about the vector product of u, v, w? (v) Find a vector that is orthogonal to u,v,and
w? Hint: Use the function Simplify to simplify algebraic expressions. Before you start use Remove to clear out all
previous definitions of u,v,w

Excercise 9
Use Solve to find the solution of of the system of equations
U1 2 H1 - U1 L - U1 U2 = 0
U2 HU1 - L = 0
Note that equations are defined by the Equal(==) function not the Set(=) function. Use the replacement operator to
show that the solution you found acually satisfies the original system of equations. Hint Use Simplify after you have
replaced the solutions into the equations.

Problem 10:
p
H-1Ln x2 n
Define a function f(p)= n
n=0 H2 mL2
m=1

that will allow you to evaluate the expression for arbitrary integer values of p. Use Table to generate a list of partial
sums for p=1,2, 10. Then use Plot to display the partial sums for 0 x 10.

Problem 11:
Use Table to generate the power series expansion approximations of
ECM6Hw1_2012.nb 3

1
f HxL =
2
1+Sin 2 +x

about x=0. Obtain 2,3,4,5 term approximations.Hint: Be careful how you input the function: Mathematica's default
inputstyle is different from conventional math usage. Use Normal to convert the power series expansion to expres-
sions that can be plotted. Plot the original function together with the various seriesapproximations on the graph for x in
the range 0<x<10. Use the PlotStyle option to show the original function in blue, and the various series approxima-
tions in diffrent hues of red.

You might also like