Linear Algebra and Numerical Analysis - Assignment 2 | AMATH 352, Study notes of Mathematics

Homework solution 2 Material Type: Notes; Professor: Hetmaniuk; Class: LINR ALG & NUM ANLY; Subject: Applied Mathematics; University: University of Washington - Seattle; Term: Autumn 2011;

Typology: Study notes

2010/2011

Uploaded on 10/28/2011

uschohk
uschohk 🇺🇸

3 documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
homework02ex2m
Page
1
of
1
Printed:
10/12/11
12:29:20
PM
Printed
For:
hetmaniu
%
Code
to
approximate
the
value
of
pi
clear
all;
MySum
=
0;
for
n
=
1:20,
MySum
=
MySum
+
l/((2*fl1)2*(2*fl+1)A2);
[n,
sqrt(MySum*16+8)pJ
end
save
s2Odat
MySum
-ascii
MyError
=
abs(
sqrt(MySum*16+8)
-
pi
);
save
e2Odat
MyError
-ascii
nn
=
0;
ss
=
00;
MyValue
=
sqrt(16*ss
+
8);
while
(abs(Myvalue
-
pi)
>
10e-08)
nn
=
nn
+
1;
ss
=
ss
+
MyValue
=
sqrt(16*ss
+
8);
end
save
n08dat
nn
-ascii;
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Linear Algebra and Numerical Analysis - Assignment 2 | AMATH 352 and more Study notes Mathematics in PDF only on Docsity!

homework02ex2m Printed: (^) 10/12/11 (^) 12:29:20 (^) PM Page^1 of (^1) Printed (^) For: (^) hetmaniu

% Code (^) to (^) approximate (^) the (^) value of pi

clear (^) all;

MySum = 0; for (^) n (^) = 1:20, MySum (^) = MySum (^) + l/((2fl1)2(2fl+1)A2); [n, sqrt(MySum16+8)pJ end

save (^) s2Odat (^) MySum (^) -ascii

MyError (^) = abs( sqrt(MySum*16+8)

  • pi (^) ); save (^) e2Odat (^) MyError (^) -ascii

nn (^) = 0; ss (^) = 00; MyValue =^ sqrt(16ss^ + (^) 8); while (^) (abs(Myvalue (^) - pi) (^) > 10e-08) nn = nn + (^) 1; ss = ss (^) + MyValue = sqrt(16ss (^) + (^) 8); end

save (^) n08dat nn (^) -ascii;

homeworkO2exlm Printed: (^) 10/12/11 (^) 12:29:29 (^) PM Page (^1) of 1 Printed (^) For: (^) hetmanin

%---- (^) The goal (^) is to (^) compute the (^) norm of (^) a vector,

clear (^) all;

x (^) = [1; 2; (^) 3.0; (^) 5.0; 7.Oj;

NormXl = norm ( x, 1);

save (^) NormXl,dat (^) NormXl -ascii

NormX2 (^) = norm(x, (^) 2); save (^) NormX2 (^) .dat (^) NormX2 (^) -ascii

NormX4 (^) = norm(x, (^) 4); save (^) NormX4,dat (^) NormX4 (^) -ascii

x = [1; (^) 3.0; (^) 5.0; (^) 7.0; (^) 9.Oj; y = [1; (^) 2; (^) 4.0; 6.0; (^) 8.0j;

mydot (^) = dot(x,y); save (^) dot (^) xy.dat (^) mydot (^) -ascii

theta (^) = save (^) angle (^) xy.dat (^) theta (^) -ascii

.

-^

rp. r

4

N

%J

f

cr

-^

n

t____.j

••

•u

ii

t

.

1

P

-^

n

‘3-.)

t’’

It

;

[

i

I

.s

ta

Ct

-^

t

4

...

.^

r-

cr

A^

•c

v

r——--——

I

P

.^

.

4’

n

.

wtsJ__.

t

5,

I

1•

r


!•!

r

4

F

o%\

.maøL.

L—.--—

—‘

‘S

a

51

‘F’

c,J

I

..te

e

•tJ

tjj

tfl

(

P

p

I^

4

cr

çj

r

.^

trw

1

t

tr

(

‘\O

4%

Ii^

“j’

‘a.

V

(^141)

4%

rz

tr-

A

(h

.

I’

jI

1’ I

Jr

I

1’ i.

j1t

‘Cj

t

tJ

tNt.

N 01 1 0

rfl

C.

—-i

ft .s

as

Li^0

t frt frOt

‘I,

?tcti

I’

0 II

‘I;

1 z.t.÷

0

‘3 ‘ $

I.

0* em

4 Vt

÷

ci

t

t

N)

il•

. r

‘I

aV

r

ci

.,

Y0t

ad1)

••>h

(^44) lb 6

Sc’

I

$

-------------auiaaaaae.fl

C^

(

,

;

i

:

t

2

—F

.

\

L^

_—J

a

^

A

R\

Q

v

ThN

7

3

S H

C

-t

CN

I^

‘C

000

‘S

c-

k

C—

—J

op

t

Uyr

.p

V 1

p ‘p

lt’P’

r

0

I

S

  • -^

r

Lt

I ‘St 1

‘0N

-o eqt

S

.

%%

-r

4

.

4%•_)

t%

E

er

r

c)

G

Nee_st

%

.

•ia 4

•.O 4 Ocr

a

•N 1•

0

.

•.

E

.

.

:

I

C%w%.m

.

.f-.v.

t

.

C’

aS

.r:i

.

.L

a

10

*aLt

1

S

a.

S

t

‘I?

%f

‘V

.

Ob

.

1\ ‘c

t Ii 4

t

---n

%

‘k

‘N

N

N

f

N.

a

‘N

N

N L

SN

N:

N)^5 it

N

N’

V.

z

r

‘P.

p

-r

.

..^

I^

, 3 z

Cc

I

1

÷

-^

.

-_Th

r-&

rfll

.^

E

Pr.. C-----?

r

-^

4

•F

U

I’ V

x I’

•‘t;i

L

C (Mt^

csir).^ s-^ c^ a’

C>

C.

Co

kc 4-^ 5c

Cct•z 1 a

Wa (^31)

Ic 4r:LE 4 t2J

Ui-cit

.=:,.

•c:tt

rw, L4)# (^) I

(i*r.c49. At^ Ca’^ a>^

t (^) “a 44. C1tiZ_cm%s

C

Ui (^) L

  • r21 (^) r’

LeJ (^) U

(we3v).. *r

r-z