{VERSION 2 3 "SUN SPARC SOLARIS" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 494 " # The following p rocedure uses Euler's method to compute\n # approximate solutions to \+ Initial Value Problems of the form\n # d(y(x),x)=f(x,y) y(xo)=y o\n # Meaning of the variables:\n # f function in two varaibles\n # xo initial x-value\n # yo initial y-value ( y(xo)=yo )\n # x1 last \+ x-value, \n # h stepsize (the smaller the more precise)\n # !!!!! \+ NOTE: Use Shift-Return to start new line , this way all !!!! \n # !!! !! commands will be executed at the same time !!!!" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 695 " Euler:=proc(f,xo,yo,x1,h) # means Euler is a procedure using f,xo,yo,x1,h as entries \n \+ local x,y,hh,p,e,yk; # local variables, will not leave th e procedure\n global output,y1; # the output will be t he list y(xo),y(xo+h),y(xo+2h),....\n y:=yo; \+ # initialization \n hh:=h;\n e:=NULL;\n for x from xo by hh to x1 do # Start of loop in which y(xo),y(xo+h),y(xo+2h),....\n \+ p:=[x,y]; # will be computed iteratively\n e:= e,p;\n yk:=y;\n y:=evalhf(y+hh*f(x,y)); # using linear approximation to comput next y-value\n od; \+ # end of loop\n output:=[e];\n y1:=yk;\n end:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 " # Lets use that procedure" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 " g:=(x,y)->x+cos(y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 " Euler(g,0,1,3,.1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "y1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "outpu t;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "display([plot(output,0..3,0. .5)]);" }}}}{MARK "6 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }