Upload
ngokiet
View
221
Download
0
Embed Size (px)
Citation preview
1
Homework Set #3, Math 475A
2
Part
3
I:
4
The-
5
ory
6
An-
7
swer
8
the
9
fol-
10
low-
11
ing
12
ques-
13
tions
14
as
15
rig-
16
or-
17
ously
18
as
19
pos-
20
si-
21
ble.
22
The
23
first
24
3
25
ques-
26
tions
27
come
28
from
29
Kin-
30
caid
31
&
32
Ch-
33
eney’s
34
book.
35
1.
36
Let
37
cn =
38
12(an+
39
bn),
40
r =
41
limn→∞ cn,
42
and
43
en =
44
r−
45
cn.
46
Here
47
[an, bn],
48
with
49
n ≥
50
0,
51
de-
52
notes
53
the
54
suc-
55
ces-
56
sive
57
in-
58
ter-
59
vals
60
that
61
arise
62
in
63
the
64
bi-
65
sec-
66
tion
67
method
68
when
69
it
70
is
71
ap-
72
plied
73
to
74
a
75
con-
76
tin-
77
u-
78
ous
79
func-
80
tion
81
f .
82
(a)
83
Show
84
that
85
|en| ≤
86
2−n(b1−
87
a1).
88
(b)
89
Show
90
that
91
en =
92
O(2−n
93
as
94
n→
95
∞.
96
(c)
97
Is
98
it
99
true
100
that
101
|e0 ≥
102
|e1| ≥
103
· · ·?
104
Ex-
105
plain.
106
(d)
107
Show
108
that
109
|cn−
110
cn+1| =
111
2−n−2(b0−
112
a0)
113
(f)
114
Show
115
that
116
for
117
all
118
n
119
and
120
m,
121
am ≤
122
bn.
123
(g)
124
Show
125
that
126
for
127
all
128
n,
129
[an+1, bn+1] ⊆
130
[an, bn].
131
2.
132
Give
133
an
134
ex-
135
am-
136
ple
137
in
138
which
139
a0 =
140
a1 <
141
a2 =
142
a3 <
143
a4 =
144
a5 <
145
a6 =
146
· · ·
147
3.
148
If
149
the
150
bi-
151
sec-
152
tion
153
method
154
is
155
used
156
in
157
IEEE
158
32
159
bit
160
sin-
161
gle
162
pre-
163
ci-
164
sion,
165
start-
166
ing
167
with
168
the
169
in-
170
ter-
171
val
172
[128, 129],
173
can
174
we
175
com-
176
pute
177
the
178
root
179
with
180
ab-
181
so-
182
lute
183
pre-
184
ci-
185
sion
186
<
187
10−6?
188
An-
189
swer
190
the
191
same
192
ques-
193
tion
194
for
195
the
196
rel-
197
a-
198
tive
199
pre-
200
ci-
201
sion.
202
4.
203
For
204
the
205
Con-
206
trac-
207
tive
208
Map-
209
ping
210
The-
211
o-
212
rem
213
(also
214
called
215
the
216
Fixed
217
Point
218
The-
219
o-
220
rem)
221
to
222
be
223
valid,
224
three
225
con-
226
di-
227
tions
228
are
229
es-
230
sen-
231
tial:
232
(a)
233
The
234
set
235
C
236
is
237
a
238
closed
239
sub-
240
set
241
of
242
R;
243
(b)
244
The
245
func-
246
tion
247
F
248
maps
249
C
250
into
251
C;
252
(c)
253
|F (x)−
254
F (y)| ≤
255
λ|x−
256
y|
257
for
258
all
259
x, y ∈
260
C
261
with
262
λ <
263
1.
264
Find
265
counter-
266
examples
267
to
268
the
269
con-
270
clu-
271
sion
272
of
273
the
274
the-
275
o-
276
rem
277
when
278
only
279
two
280
of
281
the
282
three
283
con-
284
di-
285
tions
286
are
287
re-
288
quired.
289
i.e.,
290
one
291
coun-
292
terex-
293
am-
294
ple
295
when
296
con-
297
di-
298
tions
299
(a)
300
and
301
(b)
302
but
303
not
304
(c)
305
are
306
true,
307
one
308
where
309
(a)
310
and
311
(c),
312
but
313
not
314
(b),
315
and
316
one
317
where
318
(b)
319
and
320
(c)
321
but
322
not
323
(a).
324
Part
325
II:
326
This
327
part
328
should
329
be
330
done
331
us-
332
ing
333
MAT-
334
LAB.
335
You
336
have
337
learned
338
some
339
ba-
340
sics
341
about
342
MAT-
343
LAB
344
in
345
the
346
pre-
347
vi-
348
ous
349
home-
350
work.
351
Here
352
you
353
will
354
learn
355
more
356
about
357
how
358
to
359
write
360
M-
361
files.
362
There
363
are
364
two
365
types
366
of
367
M-
368
files:
369
script
370
files
371
and
372
func-
373
tion
374
files.
375
A
376
script
377
file
378
con-
379
sists
380
of
381
a
382
se-
383
quence
384
of
385
nor-
386
mal
387
MAT-
388
LAB
389
state-
390
ments
391
as
392
you
393
have
394
seen
395
in
396
home-
397
work
398
set
399
#1.
400
A
401
func-
402
tion
403
file
404
is
405
a
406
spe-
407
cial-
408
ized
409
form
410
of
411
M-
412
file
413
which
414
cre-
415
ates
416
a
417
new
418
func-
419
tion
420
spe-
421
cific
422
to
423
your
424
prob-
425
lem.
426
(a)
427
Open
428
two
429
win-
430
dows,
431
one
432
for
433
edit-
434
ing
435
files,
436
the
437
other
438
for
439
run-
440
ning
441
MAT-
442
LAB.
443
The
444
two
445
win-
446
dows
447
should
448
work
449
in
450
the
451
same
452
di-
453
rec-
454
tory
455
or
456
folder.
457
In-
458
voke
459
MAT-
460
LAB
461
in
462
one
463
of
464
the
465
win-
466
dows.
467
You
468
don’t
469
need
470
to
471
use
472
di-
473
ary
474
this
475
time
476
to
477
record
478
your
479
ses-
480
sion.
481
(b)
482
You
483
can
484
write
485
a
486
func-
487
tion
488
file
489
for
490
any
491
func-
492
tion.
493
Put
494
the
495
fol-
496
low-
497
ing
498
in
499
the
500
file
501
fun1.m.
502
503
function y = fun1(x)
504
y = exp(x) - sin(x);
505
506
Save
507
the
508
file
509
and
510
in
511
the
512
MAT-
513
LAB
514
win-
515
dow,
516
type
517
fun1(-
518
1.1)
519
It
520
will
521
re-
522
turn
523
the
524
value
525
of
526
e−1.1−
527
sin(−1.1).
528
So
529
fun1(x)
530
works
531
just
532
like
533
any
534
built-
535
in
536
MAT-
537
LAB
538
func-
539
tion
540
such
541
as
542
sin(x).
543
No-
544
tice
545
that
546
for
547
a
548
func-
549
tion
550
file,
551
the
552
file
553
name
554
and
555
the
556
func-
557
tion
558
name
559
need
560
to
561
be
562
the
563
same!
564
The
565
fol-
566
low-
567
ing
568
is
569
a
570
MAT-
571
LAB
572
code
573
for
574
the
575
bi-
576
sec-
577
tion
578
al-
579
go-
580
rithm.
581
Put
582
it
583
in
584
the
585
script
586
file
587
bi-
588
sec-
589
tion.m.
590
591
% bisection.m
592
% MATLAB code for the bisection algorithm.
593
594
clear; % Clear the MATLAB environment
595
596
a = input(’The left value of the interval [a,b]: ’);
597
b = input(’The right value of the interval [a,b]: ’);
598
M = input(’Maximum number of iterations: ’);
599
d = input(’The smallest interval size: ’);
600
ep = input(’The smallest absolute function value: ’);
601
602
u = fun1(a); v = fun1(b);
603
e = b - a;
604
disp([a,b,u,v]);
605
if sign(u) ~= sign(v)
606
for k = 1:M
607
e = e/2; c = a + e; w = fun1(c);
608
disp([k,c,w,e]);
609
if ( abs(e) < d ) | ( abs(w) < ep )
610
break;
611
end
612
if sign(w) ~= sign(u)
613
b = c; v = w;
614
else
615
a = c; u = w;
616
end
617
end
618
end
619
620
Compare
621
the
622
above
623
with
624
the
625
pseudo-
626
code
627
in
628
the
629
notes
630
line-
631
by-
632
line
633
and
634
also
635
use
636
MAT-
637
LAB
638
on-
639
line
640
help
641
to
642
un-
643
der-
644
stand
645
the
646
above
647
M-
648
file.
649
Now
650
in
651
MAT-
652
LAB,
653
type:
654
bisection
655
It
656
then
657
will
658
ask
659
you
660
for
661
the
662
val-
663
ues
664
of
665
a, b,M, d, ep.
666
Use
667
a =
668
1; b =
669
2,M =
670
20, d =
671
1.e−
672
12, ep =
673
1.e−
674
14.
675
Can
676
you
677
tell
678
what
679
the
680
best
681
ap-
682
prox-
683
i-
684
ma-
685
tion
686
to
687
the
688
root
689
is?
690
Uti-
691
lize
692
the
693
above
694
m-
695
file
696
but
697
with
698
other
699
func-
700
tion
701
m-
702
files
703
to
704
solve
705
the
706
fol-
707
low-
708
ing
709
root-
710
finding
711
prob-
712
lems:
713
•
714
x−1−
715
tanx,
716
on
717
[0, π/2].
718
•
719
2−x+
720
ex+
721
2 cosx−
722
6,
723
on
724
[1, 3].
725
Hand
726
in
727
both
728
the
729
codes
730
(script
731
files
732
and
733
func-
734
tion
735
files)
736
and
737
the
738
out-
739
put
740
of
741
20
742
it-
743
er-
744
a-
745
tions.
746
Part
747
III:
748
5.
749
In
750
this
751
ex-
752
er-
753
cise
754
we
755
com-
756
pare
757
the
758
Bi-
759
sec-
760
tion,
761
Se-
762
cant,
763
False
764
Po-
765
si-
766
tion
767
and
768
New-
769
ton
770
meth-
771
ods
772
for
773
the
774
fol-
775
low-
776
ing
777
prob-
778
lems:
779
(a)
780
x3−
781
2x2−
782
5 =
783
0 , [1, 4]
784
785
(b)
786
x =
787
cosx , [0, π/2]
788
(c)
789
ex+
790
2−x+
791
2 cosx−
792
6 =
793
0 , [1, 2]
794
(d)
795
(10−6x−
796
2)2−
797
lnx+
798
6 ln 10 =
799
0 , [106, 2·
800
106]
801
(e)
802
erf(0.5+
803
x) =
804
0.520508, , [10−6, 10−3]
805
For
806
New-
807
ton’s
808
method
809
use
810
the
811
mid-
812
point
813
of
814
the
815
pro-
816
vided
817
in-
818
ter-
819
val
820
as
821
ini-
822
tial
823
guess.
824
You
825
should
826
find
827
the
828
so-
829
lu-
830
tions
831
within
832
10−14
833
(rel-
834
a-
835
tive)
836
ac-
837
cu-
838
racy
839
(but
840
start
841
with
842
lower
843
ac-
844
cu-
845
racy
846
while
847
de-
848
bug-
849
ging
850
your
851
code).
852
What
853
you
854
should
855
hand
856
in:
857
(a)
858
Your
859
pro-
860
grams
861
for
862
the
863
four
864
meth-
865
ods
866
for
867
case
868
(5a).
869
Make
870
your
871
pro-
872
grams
873
easy
874
to
875
un-
876
der-
877
stand
878
by
879
us-
880
ing
881
mean-
882
ing-
883
ful
884
names
885
for
886
vari-
887
ables,
888
adding
889
com-
890
ments,
891
writ-
892
ing
893
in
894
a
895
struc-
896
tured
897
for-
898
mat,
899
etc.
900
(b)
901
For
902
each
903
case,
904
give
905
the
906
fi-
907
nal
908
so-
909
lu-
910
tion,
911
the
912
num-
913
ber
914
of
915
it-
916
er-
917
a-
918
tions
919
and
920
the
921
cpu
922
run-
923
time
924
for
925
each
926
of
927
the
928
three
929
meth-
930
ods.
931
(c)
932
Two
933
ta-
934
bles
935
to
936
com-
937
pare
938
these
939
meth-
940
ods
941
in
942
the
943
for-
944
mat:
945
946
Bisection False Position Secant Newton
a
b
c
d
e
947
using:
948
i.
949
number
950
of
951
it-
952
er-
953
a-
954
tions
955
and
956
ii.
957
cpu
958
run-
959
time
960
(for
961
cpu
962
run-
963
time
964
you
965
may
966
need
967
to
968
av-
969
er-
970
age
971
over
972
sev-
973
eral
974
runs).
975
(d)
976
Do
977
these
978
ta-
979
bles
980
al-
981
ways
982
agree?
983
If
984
not,
985
why?
986
(e)
987
Which
988
ta-
989
ble
990
should
991
we
992
con-
993
sult
994
when
995
judg-
996
ing
997
which
998
method
999
is
1000
faster?
1001
1002
1003