You are on page 1of 1

AMATH 301 Summer 2012

Homework One Due 3:00:00 am July 2, 2012 Problem 1: Loops


Compute the variables x and y dened as the following.
25

(a) x = 100
a=1

1000

a,

(b) y = 100
i=1

0.1 .

Answers: Save the two results as A1.dat and A2.dat

Problem 2: Vector and Matrix Operations


Suppose we have the following vectors and matrices: A= D= 1 5 4 2 3 ,B = 2 4 8 1 ,C = 2 1 4 3 2 1 ,x = = 1 1 3 4 ,y = 9 0 1 , . (1)

1+3

1+3+5

1 + 3 + + 99

150

Dene the vectors and matrices in Matlab, and calculate the following: (a) 2 A + B (b) A y (c) B (x + 3y ) (d) 2 B C (e) C T (f) D/2, where C T is the transpose of matrix C . Answers: Save the results in (a) (f) as A3.dat A8.dat

Problem 3: Bisection Algorithm


Consider the function f (x) = x sin(3x) ex + 2 Use the bisection method to solve for the x value near .9 that satises f (x) = 0. Use the initial end points xlef t = .5 and xright = 1.5 for the bisection method. Keep track of the value of f (x) at the mid point values, and the number of iterations needed so that |f (xmid )| < 105 is achieved. Answers: Save the values of f (xmid ) (xmid is the midpoint in each iteration) as a row vector in A9.dat. Save the number of iterations needed for |f (xmid )| < 105 as a scalar in A10.dat. Save your last value of xmid that you accepted as the root of f (x) in A11.dat. Note: you might want to plot the values of f (xmid ) versus the iteration number to make sure your method is converging.

You might also like