o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6...

10
r ~ ~ ~ .~~ 4 ~~ ~ _ .:~ r ~~ ~— ~ ~~ ~~~.~ ~ 'o ~. ~^ .s—°--- -.- ----- -----_ y6^~~~~j~ T _.._ C~~..._6 a i~' :: ~_,~ ~ a,ti Ck So~ /~- {✓r1t`..r.~t~"`pD ~?4~'' ~ "~+u "~...'3,1~ ~`°-... sx 'may r e?'.:`~~ Fy`.`I n x gt a— ~ - `~ ~.n~ Be a %~.... r~'~s~ ~... °PY ~ eGVrr'~.~,~,,,~., ~~' ~~C~.~:L~,,~'If~~...... ~la' 6~ 4~fS ~9~J~s.~ <d' ". ~~~,✓'~,.~ > v o~ Q i ~' _ ? ,..~ ~ ~ _ ~~ _ n ~ .~ f ~~ ~r~J z ~~ ~j ~ '~~ I ~;~s ~ x r a _ ~ s r~~k~ ~ °~f~ -- a ~, _ t s. _~ r ~ .~. a . , d ~~ ,_,. , ~ .~ ~~~ ~..~ ~ ~~" <~ s w _~ Ed ~~ ~ ~' n C. ~- —~P ~— C ~ ! ~ ~' ~~,~~?~'J~ds ~ _ ~' ;~ ~ r t~~d5~ c ~ ~E ~, ~~~~ ~'>'a ",.mss' d;;.;. , ~y!°°tJ °.~. -~b~ ~ F~ ~~` Tp~~ ' ~~:~i ~~~°'. ~ ~~C ~ e'~t s; °~1 ~ ~J ~ P ~~ts, , ~.~ -~,,d .',~ ~ "°`y.~ i~~~bs;,~ ~-p ' ~ p ~L ~ ~ ~~'~~ C~~ ~ "~y , ' -~ ~ 'tip ~~'v.]+2 ~~~ f~~~ ~~"` < +' ,~ I~°y ~.~.~e ~ ~~ ° '~ s' °a ~t~ ''~/r ~~ '`' 'IM "~~~,I 'ate. /t` ~ _ ~....~, ~ ~J''?l."'j ~ ~B.L ~.,'I ~ ~ ~ ~' _."l~ P .- ~s '~ L' ' ~ „C.g ~" f ' ~-0°t _. ~3t~ ) n ~~~ ~c~~ ~ (~ a _ ~ ~ r~~ ~~~ ~ ! ~ -~~ ~~~ ~. _ ~ ;~ ~~... 1 :~~s P' ' ~ 2 ~ ~ ~5~ ~f~° :. °~~~~ 1 ~~~k ;; - ~ ~`:~~~- tit "~~~ ~~ ~f ~G ~ ~ ~ ,~ .; G~~ 2~'~ ~~"1~~~"' f~ i{ ~a~~`~t° , °t~'1ds~~,sl~ ~a~~~,?~rG~~~`~` ~~~°f'~~~~ -~~ ~ ~ihLo~( ~

Upload: others

Post on 25-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

r

~ ~ ~ .~~4

~~ ~ _ .:~r ~~~—~ ~~ ~~~.~ ~ 'o

~. ~^.s—°----.-----------_ y6^~~~~j~ T

_.._ C~~..._6 a i~' :: ~_,~ ~ a,ti Ck So~ /~- {✓r1t`..r.~t~"`pD ~?4~'' ~ "~+u "~...'3,1~ ~`°-...

sx 'may r e?'.:`~~ Fy`.`I

nx

gt a— ~ - ̀ ~~.n~ Be a %~.... r~'~s~ ~...°PY ~

eGVrr'~.~,~,,,~., ~~' ~~C~.~:L~,,~'If~~...... ~la' 6~ 4~fS ~9~J~s.~<d'

". ~~~,✓'~,.~> v o~Q i

~' _ ?

,..~ ~ ~ _ ~~ _ n ~ .~

f~~

~r~J z~~

~j ~ '~~ I ~;~s ~xr

a _ ~s r~~k~ ~°~f~ --a ~, _ t s.

_~r ~ .~.a

. , d ~~,_,. , ~.~~~~ ~..~ ~ ~~"<~ sw _~

Ed

~~ ~ ~'n

C. ~-

—~P~— C ~ ! ~ ~'

~~,~~?~'J~ds ~ _ ~' ;~ ~ r t~~d5~ c ~ ~E ~, ~~~~ ~'>'a",.mss' d;;.;. , ~y!°°tJ°.~.-~b~ ~ F~ ~~` Tp~~

' ~~:~i ~~~°'. ~ ~~C ~ e'~t s;°~1 ~ ~J ~ P ~~ts, , ~.~ -~,,d .',~ ~"°`y.~ i~~~bs;,~ ~-p ' ~ p ~L ~ ~ ~~'~~ C~~ ~

"~y , '-~ ~ 'tip ~~'v.]+2 ~~~ f~~~ ~~"` < +' ,~ I~°y ~.~.~e ~ ~~ ° '~ s' °a ~t~ ''~/r ~~ '`' 'IM "~~~,I 'ate.

/t` ~ _

~....~, ~ ~J''?l."'j ~ ~B.L ~.,'I ~ ~ ~ ~' _."l~ P .- ~s '~ L' ' ~ „C.g ~" f ' ~-0°t _. ~3t~ )

n ~~~ ~c~~ ~ (~ a _ ~ ~ r~~ ~~~ ~ !~ -~~ ~~~~. _ ~ ;~~~...

1 :~~s P'

' ~ 2 ~ ~ ~5~ ~f~° :. °~~~~ 1 ~~~k ;; - ~ ~`:~~~-tit"~~~ ~~ ~f ~G ~ ~ ~ ,~

.; G~~ 2~'~ ~~"1~~~"' f~ i{ ~a~~`~t° ,°t~'1ds~~,sl~ ~a~~~,?~rG~~~`~` ~~~°f'~~~~-~~ ~ ~ihLo~( ~

Page 2: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

Ire, ~~ ~~a_.... g9 °~' ~ ~°" '= _ c~ ~adr~` G? ~~.~~r='a'

'"'~„ Ys 7 ~ ~ ~YL~~ ~.J v G°~0~L°b ~ ~°~~

~ ~~p by ~ «~1_~d~,f`~e~~~ ~ r ~i h ~ ~,,~r ~,,, ~~C~ ~ ~ ~ + ~'~~ ~ _

~ ~~= ',~ ~~ c '~ ~C„J ~ ~,

1%~ .. ~~ ~~~ ~ , ~~~ :~. ~ ~~~ `F ~"~ `~~ y ~~ ~' ~'~;f r.~ ;;~ ~ It,✓ rr ~ &-~7

FCC ~ ~'~ , ~~~- ,~y~ ,~ ~/~ 1 v P ~ ~ ~,. d

~~ ~ ~'' L

t ,~ j rI ~'ib~

., ) ' ~ ~`~~'lx~~ ~1~ ~,

~~ ~__

~ P f ~L Cc~ J ~~;, ~~ ~~ ~+~ ... !rte ~~ .~ ~` ~~~

nom, fro, ~ ,

' ~t U _ °~~~ Li' -̂~Y 3 ~et ~~ c.✓'j~,,' ~ r~~e'! J`~~`~`v3 ~.r'i ~ '°"~%'"a^°b ~ ~,^ ~ c GIB ler'~' GJ~~' ~°a ~~"~ )1~~~~/r~.Pr~G, ~I ly ,(~ ✓ aFi .~j ~ ~

r

_ _ F Ca,~ I ~ ' l°~z 1

z

> ~ ~q ,it 71 f~,,~ / ~- •~,2 S'v ~+~ inn"~

g l >

•~ ~,_ J ~,

i ~ ~ y 11 ~ ~ l ~~`

,,

.~ 1,, ~ ~ 1 _...........

~~ 1 .yon, l ~:~'f't r~ '~a'~, (~'-n ~ 1 -~ ~ -~ y'C I'P"n ~ ~ ~~r~7~ ( `°

E ` p ~/ ,~/'~ ~~ `ale:)- _ (:c~tv~ y~jc7'+~~`! ~•~-y' '~ ~ ~;~ .. 1~~~~",- ~3 %~ :~c:~;~F' g,~ :1 -~t~~~ l~ '~ ~+ ~ ~-`

' (~,.~ 1 G

.C~ ~T ~ lJ~.-- _ ._

,~~ r

a~r ~Z.s~-~-~(, ~-~ ~~s y~~e~!~rr~,, °~ ,~~ ~~,~A,a~~ ~r-~aF ~ ~r~ r ~Sy,-it~,~~i~b" ~~~y;~~~,

ro v._

~ ~~

~_ a~ ~,,~

(_ ~._

Page 3: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

3r7

%~v8f' ~w s

..,,.-fl _, ~~

f,~g `~ + J ~yCy., ~^~+ ~` q, ~7 ~ T-.1~'~~.~~~~(C✓/ ~..4" ~'"~P ~'' 4~C~.'~`~" 3 X~ ~F~,~ ~3 4 v°4d! d 4~

5.~+~~5 ~a. V ~ j ~~g

~~„D~~~.....

..~ ~1 a f~ 7 q'°~✓,.~r ~' ..=.~N~'~~' a"~ifs~ ~`~a`~~~+~'~~F~e~ "'~a~~''~f1 ~`~1,tij ~ `~.~'~~~~~/f~~ ~~~~~&~~`

f~+l~tGZ.f'~~ _ ~ ~ -

{ , ~¢~'a 1f~

e_.,

°~ ~9 + ~:_ F P~~~

~.. _ .. ~~GVw ~'~a j — t r 5 ~ ~ uf' ~ l~a~~ ~~;~

y~/~^~~~1 -~~~7qF ~/~ti~ _/ /

e `3 ~ /Of )U °b ~~~~~ ''.._...,f,~

~_... ~ ~.~~ ~~ U ~:.~ ~$~f.E i'~wG~t 4`,... ~,i;~~tl~q Y>

~f. ~. ~qy'"'"`~'r~ ~ ~j~~~~~

,_ ~ y'

~y^ @°~ . /~ ~" y~^ {g—

C ~°~ ~ ~' '~' C(-' `T ~t~t) ~~i —tom ~ g "~~- 5~'d'~ e~'„ "~t~`~,~, °

. j ~~o w-

y, i~q ~

t ~~g~~ ~ ~

iYi~~- 1 -a 61M ~ ~ ~~~~:)

t -' f ~ ~ ~~ ~~~ ~' ~c

~~~~~~` "'' C~ ~a i~' pro

_ ~

ptl .,. ~~~~ ~,,~-~ y fay, -~- ~~,~, ~ ~~N~ ~ ~~~rt'~i (` °,'€~~~~ ,,n ~~C~,~)~%. ~- a ~.~-~---

~ ~~,_ e ~~r

~-~, d ~, ~ , ~

Page 4: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

~- ,~

5 ,

°~

a ~ ~ ~ "~ r~~ ~~' ~;,~

~. w ,,, G~ z 6....... ~. ° ~ ~....-~ ~ 1`9..+6 r~`~,'t ~✓7 aee..a f ~ ~ ~... ~~ -}

. ~~ ~~ ~_~z j /„ .+~ / ~f

fx ~'

!"L~ ~d '~`c/I ~L'ih v 6 ~ Z'f J I I_,7 ~ ~~ °s ~Y .✓~ A~ ~ / ~1 ~ b~~ /~~K' r +'6',7~ y

t` ~

~,a

~ ~ ~~ ~ .~. Ic-v,C-~~ !fir_-~ ~~~ ~e~a~~,i' .~8 — ~~ ~ ~ ~~ ~'~~'¢~ ~~ ~

4- v

uY ~~ ~,~ ~ ~ ~ ~"~ 3~ ~~ ~,,fi

~ ~ f~ _ ~

'~ , Z,Z( ~ ~ I 't ~,

v/ AL

..i C L"i~✓'~`~?~, `1 ~'7 d:~t+t~ `1 -rp f ~ _ < fit,-, `o' .m.a ~ -° ! ~ ~ .J ~J ~ ~ c~t~. "^

C~~~

~.

Page 5: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

J~ ~ ~{'~ I

[~ d;

m.

q~ ~-~ ~F ~

r

s ~~~"~

~;~~~:~~. ~ !~~(~ „~ d✓ ~~z E't'~ ~'~~al ~a~t~, %ate ~~[~a.d s'!,p~'

f aL,d; .r

r~_r~ °~ ,_ ~

~~~—

rt.~r~1_

~r ~t4s ~~.~ ~ ,~

~ ~~~~c ~~~ x" ~

z -°,~,~

b ~~~ p~~~ __(a°~ a'~y ,~ ~ ~3 ~~3~"~~1 ~ ter, ~—r`°H 'e a+ ~1

6s a

r"

E y(s, u ~pg ~.y^ ,#2~ p~p~y~ {° [ )

y..... ~ _ '1 i (~' ~.t~iEy4S ~'1~.~. K ~G"~fS ••~ ~~ y'P~~n ~"~c:'~.. rti,.-p ~ 9G-. q7 ''e~/'~~.g,l r... ~c,Cl`„~., f c% ~ a l f ~'

°~q ( n. g gf~ `/{~ d,,~ )q 6 ~Gg~ Gi~ ~.._ ~,"n'~8~.bi U:, '`E ~l~~Z~7 ,{.

pb ,1(,~ d ~

t~~ _~"~rJO tigl~'~ -U4~.~°dN ~° ~!~7._..... _.... ~ , e~x .... p b

,.,..,_ _ ~ ~a

__ ~ (~ ~' ~ - — a ~ ~~1 a. ~i d~' a~. y~ ~

~ "~ e 9 .I- ~ (7 +`.:~4t~~`~ ~ ~'i G/,~'y''o ~. ~'! ~- ~ ~ ~t ~ ~> u ~ ; ~✓ 7.~ ~ ~'~,~'M..?Gi r ~ ~C ~ +,r ='~4

w r y~

a - %~-s ~ ~ ~~~y

-- '?w.~ ~ ~- ~~

t~ ° - . ~~~~~~,~~~~~ ~~e Val ~ ' ~ ~:s ~ ~.~~ ~-~,~. ~ ,~~

w - =cif

Page 6: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

~7s'°,

~u~~_ __

w-

~~~'~ l ~ln~7 e? ~ , ~ t (" ~ ~ 2~{ i i IA's ~~ e~ - ~1 t~!—

~ x

r ~,A ~ e

~,~~m̀.

~~~~ ~~~11~' 7~, ~ ~ _ ~

r ~~ ~ ~ ~ ~ f 'T .ate e_. _ ~

/ / ~~ ~~ f?T ~/ ~ ~~ U~ ~

r~ ~~~~~~~~

~--~~ '

~_

-~- _,., ..~.<e a

Page 7: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

function [xc,yc,errx]=newtonldr(fun,funpr,xl,tol,kmax,pcon)

Input.fun function (inline function or m-file function)funpr derivative function (inline or m-file)xl starting estimate

o tol allowable tolerance in computed zerokmax maximum number of iterations

o pcon=expected order of convergence, p$ Output:

xc approximation to the root fun(xc)=0o yc =fun (xc)errx = approximation to error in xc

x(1)=xl;err(1)=0.;papp(1)=0.;capp(1)=0.;cap2(1)=0.;y(1)=feval (fun,x(1)) ;ypr(1)=feval(funpr,x(1));for k = 2:kmax

x(k)=x(k-1)-y(k-1)/ypr(k-1);err(k)=abs(y(k-1)/ypr(k-1));if k<4

papp(k)=0.;capp(k)=0.;cap2(k)=0.;if k==3cap2(3)=abs(err(k)/(err(k-1))^pcon);end %if k==3elsepapp(k)=(log(err(k))-log(err(k-1)))/(log(err(k-1))-log(err(k-2)));capp(k)=abs(err(k)/(err(k-lj)^papp(k));cap2(k)=abs(err(k)/(err(k-1))^pcon);

end oif k<4y (k) =feval (fun, x (k)) ;if abs(x(k)-x(k-1)) < tol

disp('Newton method has converged'); break;endypr(k)=feval(funpr,x(k));iter=k;

endif liter >= kmax)

disp(' zero not found to desired tolerance');endn=length(x);if imag(x(1)) ~=0 ~ imag(y(1)) ~=0disp(' n x y err

Pa1~P ~ )else

disp(' n x y err papp Cappcwithpcon')end oif

for k=1:n;gout = [k' x' y' err' papp'];odisp(out)if imag(x(l))~= 0 ( imag(y(1)) ~= 0fprintf('%3.Of o10.6f o10.6f %-13.5g o-13.5g o-13.58o8.4f\n',k,real(x(k)),imag(x(k)),real(y(k)),,imag(y(k)),err(k),papp(k));

elsefprintf('%3.Of o10.6f o-13.5g o-13.5g %8.4f o8.4f

%8.4f\n',k,x(k),y(k),err(k),papp(k),capp(k),cap2(k));

end oifend %for

Page 1 of ~

Page 8: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

>o output for problem 6>[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2)Newton method has convergedn x y err papp capp cwithpcon1 0.000000 -3 0 0.0000 0.0000 0.00002 3.000000 1441.5 3 0.0000 0.0000 0.00003 2.822099 548.43 0.1779 0.0000 0.0000 0.01984 2.631425 209.48 0.19067 -0.0245 0.1828 6.02475 2.425401 80.251 0.20602 1.1167 1.3110 5.66686 2.201692 30.667 0.22371 1.0635 1.2005 5.27047 1.961003 11.48 0.24069 0.8884 0.9103 4.80948 1.715613 3.9921 0.24539 0.2645 0.3576 4.23599 1.505268 1.1135 0.21035 -7.9651 0.0000 3.4931

10 1.389750 0.16916 0.11552 3.8891 49.6435 2.610911 1.365232 0.005603 0.024518 2.5862 6.5118 1.837412 1.364363 6.6398e-006 0.00086888 2.1548 2.5664 1.445313 1.364362 9.3507e-012 1.0321e-006 2.0167 1.5375 1.367114 1.364362 0 1.4535e-012 2.0003 1.3698 1.3645xc = 1.36436159792756yc = 0errx = 1.45349815489365e-012>%>o output for problem 3b>[xc yc errx]=newtonldr("pr3fun","pr3fpr",l,l.e-11,20,2)Newton method has convergedn x y err papp capp cwithpcon1 1.000000 -1 0 0.0000 0.0000 0.00002 1.100000 0.27972 0.1 0.0000 0.0000 0.00003 1.082551 0.011028 0.017449 0.0000 0.0000 1.74494 1.081805 1.9165e-005 0.00074605 1.8055 1.1149 2.45045 1.081804 5.8158e-011 1.301e-006 2.0150 2.6036 2.33756 1.081804 1.7764e-015 3.948e-012 2.0003 2.3431 2.3325

xc = 1.08180405955982yc = 1.77635683940025e-015errx = 3.94804435424867e-012>o

>% output for problem 4a>[xc yc errx]=newtonldr("pr4fun","pr4fpr",0,5.e-9,26,1)Newton method has convergedn x y err papp Capp cwithpcon1 0.000000 1 0 0.0000 0.0000 0.00002 0.166667 0.1234 0.16667 0.0000 0.0000 0.00003 0.202177 0.027537 0.03551 0.0000 0.0000 0.21314 0.217257 0.0065717 0.01508 0.5539 0.0958 0.42475 0.224298 0.0016082 0.0070409 0.8893 0.2934 0.46696 0.227708 0.00039792 0.0034102 0.9519 0.3816 0.48437 0.229387 9.8979e-005 0.0016791 0.9773 0.4329 0.49248 0.230220 2.4683e-005 0.00083321 0.9890 0.4625 0.49629 0.230635 6.1631e-006 0.00041505 0.9946 0.4793 0.4981

10 0.230842 1.5398e-006 0.00020714 0.9973 0.4887 0.499111 0.230946 3.8483e-007 0.00010347 0.9987 0.4939 0.499512 0.230997 9.6193e-008 5.1712e-005 0.9993 0.4967 0.499813 0.231023 2.4046e-008 2.585e-005 0.9997 0.4982 0.499914 0.231036 6.0114e-009 1.2923e-005 0.9998 0.4991 0.499915 0.231043 1.5028e-009 6.4613e-006 0.9999 0.4995 0.500016 0.231046 3.757e-010 3.2306e-006 1.0000 0.4997 0.500017 0.231047 9.3924e-011 1.6153e-006 1.0000 0.4998 0.5000

Page 1 of ~

Page 9: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

s

j

~ ~ ~~ ~

v~ ~ ~ ~~. ~~. ~m~~

~, ~~~~,~ ~. ~ ~ ~,f~~y ~ ~~ z:: -~ ~ ~ ~~ Y , ~

.gip ~~ ~ c ~ ~" ~ ~1 ~ ~, ~~1

~ ~f'J~ r., a c ~> ~ ? .~, ' A ~' 9 ~'Td 'e~4~ a ~' '~ ~ ~ ~~-~ l~. ~~ ~~~ ~

~~~ ~ ~ , ~~ ,~~ ~~~ p

~~' P

~ ~!' /

i ~'`~ -a ~t,~~ y

`~? i ~r

'~--~ i ~—~ i ~ ~„ i ~` r~~

p~,. ~ ~

~ ~° ~ ~ ~

~ ~ d~.~ ~, _~

f~-

t '~~~

~ 1{

~°~. ~ ~ "}8 'T-a~''~ ~ 4 -a as ~ -R—~"9A E~ '~ ~>B a~' ~ ~

s

~ ~~

~ (a~~~

~. .._~ v,a.

R`

~.~ 2~ l a ~

> r, r ~ ~ ~ c~ ~~

`~

~a ~r

`~=3 ~~ ~`

~~

Page 10: o ~~~—w3.salemstate.edu/~arosenthal/ma723/pr2_solutions_part2.pdf · >o output for problem 6 >[xc yc errx]=newtonldr("pr6fun","pr6fpr",O,l.e-11,20,2) Newton method has converged

0 output for problem 6 using pr6ftaylor.m to evaluateo f(x)=integral 0 to x e^(t^2) dt with a Taylor polynomial>[xc yc errx]=newtonldr("pr6ftaylor","pr6fpr",O,l.e-11,20,2)Newton method has convergedn x y err papp cape1 0.000000 -3 0 0.0000 0.00002 3.000000 1441.5 3 0.0000 0.00003 2.822099 548.43 0.1779 0.0000 0.00004 2.631425 209.48 0.19067 -0.0245 0.18285 2.425401 80.251 0.20602 1.1167 1.31106 2.201692 30.667 0.22371 1.0635 1.20057 1.961003 11.48 0.24069 0.8884 0.91038 1.715613 3.9921 0.24539 0.2645 0.35769 1.505268 1..1135 0.21035 -7.9651. 0.0000

10 1.389750 0.16916 0.11552 3.8891 49.643511 1.365232 0.005603 0.024518 2.5862 6.511812 1.364363 6.6398e-006 0.00086888 2.1548 2.566413 1.364362 9.3494e-012 1.0321e-006 2.0167 1.537514 1.364362 0 1.4533e-012 2.0003 1.3700xc = 1.36436159792756yc = 0errx = 1.45329106454103e-012

function [y ier nfun err]=pr6ftaylor(x)[y ier nfun err]=quad("pr6fpr",O,x);

o This integrates the function integral 0 to x e^(t^2) dto using a Taylor polynomial.

ier=0 is returned iff the integration was successfulnfun=how many terms were used in the Taylor polynomialerr = an estimate of the error in the solutionsum=x;dfact=l.;term=x;nmax=900;efact=exp(x.^2);ier=0;k=0;err=1;if x < 0efact=l;end oifwhile err > l.e-15k=k+l;

dfact=dfact+2;term=term*x^2/k;sum=sum+term/dfact;err=abs(efact*term*x^2/(k+l)/(dfact+2));if k > nmaxier=1;break;

end oifend °whilenfun=k;if ier==1;

disp 'more terms are needed in the Taylor polynomial'xy=sumnfunerrbreak;

end %ify=sum-3;

return

cwithpco0.00000.00000.01986.02475.66685.27044.80944.23593.49312.61091.83741.44531.36711.3643