{VERSION 4 0 "IBM INTEL NT" "4.0" }
{USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0
1 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0
0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }}
{SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 442 "#Dr. Gustafson,\n#I
am in your 2250-4 class and am continually struggling with the codes \+
for\n#the problems in section 2.4, 2.5, and 2.6. Actually 2.5 (Improv
ed Euler)\n#seems to be going pretty well, but I can't get very good \+
results for 2.4\n#(Euler) or 2.6 (Runge-Kutta Idea). Is there a websi
te where I may be able\n#to find help and/or codes on these sections, \+
as nothing I type in for my\n#codes will seem to work? Thanks for you
r time.\n\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 1131 "# ========
=================================\n# Can't copy with the mouse? Work-a
rounds:\n# ========================================\n# Try first: hold
down SHIFT and then hit the paste button on\n# the mouse. Usually nee
ded from xterm windows and firefox to other\n# edit windows and browse
r forms.\n#\n# If pasting into Xmaple, then try just the mouse paste b
utton. It\n# might work. For some systems, ctrl-V will perform the pas
te.\n#\n# Lastly: Run the application \"xclipboard &\" to capture mous
e copies.\n# Keep xclipboard near the xmaple window. Go to the browser
window,\n# copy with the mouse. Switch to the xclipboard window. Copy
with\n# the mouse from the xclipboard. Then paste with mouse button 2
or\n# mouse button 3 into xmaple.\n# ================================
=========\n# Maple code doesn't work? Read this:\n# ==================
======================\n# To type in a group, hold shift then press re
turn, except\n# for the last line of group, in which case use just ret
urn.\n# If you copy multiple groups with the mouse, then split\n# them
using key F3 with the cursor placed at the front of\n# a line where t
he split is to happen.\n\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
314 "# Warning: These snips of code made for y'=1-x-y, y(0)=3.\n# \+
Code computes approx values for y(0.1) to y(1.0).\n# 'Dots' is th
e list of dots for connect-the-dots graphics.\n# =====================
===================\n# Euler. Group 1, initialize.\n f:=(x,y)->1-x-y:
\n x0:=0:y0:=3:h:=0.1:Dots:=[x0,y0]:n:=10:\n " }}}{EXCHG {PARA 0 "> \+
" 0 "" {MPLTEXT 1 0 127 "# Group 2, repeat n times. Euler's method\n f
or i from 1 to n do\n Y:=y0+h*f(x0,y0);\n x0:=x0+h:y0:=Y:Dots:=Dots,
[x0,y0];\n od:\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "# Grou
p 3, display dots and plot.\n seq(Dots[j],j=1..n);\n plot([Dots]);\n
\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 135 "# =================
=======================\n # Heun. Group 1, initialize.\n f:=(x,y)->1-
x-y:\n x0:=0:y0:=3:h:=0.1:Dots:=[x0,y0]:n:=10:\n " }}}{EXCHG {PARA 0
"> " 0 "" {MPLTEXT 1 0 161 "# Group 2, repeat n times. Heun method.\n \+
for i from 1 to n do\n Y1:=y0+h*f(x0,y0);\n Y:=y0+h*(f(x0,y0)+f(x0+h
,Y1))/2:\n x0:=x0+h:y0:=Y:Dots:=Dots,[x0,y0];\n od:\n " }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 75 "# Group 3, display dots and plot.\n
seq(Dots[j],j=1..n);\n plot([Dots]);\n\n " }}}{EXCHG {PARA 0 "> "
0 "" {MPLTEXT 1 0 134 "# ========================================\n # \+
RK4. Group 1, initialize.\n f:=(x,y)->1-x-y:\n x0:=0:y0:=3:h:=0.1:Do
ts:=[x0,y0]:n:=10:\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 228 "#
Group 2, repeat n times. RK4 method.\n for i from 1 to n do\n k1:=h*
f(x0,y0):\n k2:=h*f(x0+h/2,y0+k1/2):\n k3:=h*f(x0+h/2,y0+k2/2):\n k
4:=h*f(x0+h,y0+k3):\n Y:=y0+(k1+2*k2+2*k3+k4)/6:\n x0:=x0+h:y0:=Y:Do
ts:=Dots,[x0,y0];\n od:\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
86 "# Group 3, display some dots and plot.\n Dots[1],Dots[2],Dots[n+1
];\n plot([Dots]);\n\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0
315 "# Code snips for exact/error reports 2.4-#5\n # =================
========================\n # Making multiple curves on one plot\n # ==
======================================\n Exact:=x->2+x-exp(x); \+
# An exact solution for 2.4-5\n plot(\{Exact(x),[Dots]\},x=
0..1/2); # plot exact and approx solutions\n\n " }}}{EXCHG {PARA 0 "
> " 0 "" {MPLTEXT 1 0 232 "# ========================================
\n # How to create a Dots table for the exact solution\n # ===========
=============================\n Exact:= x -> 2+x-exp(x):n:=10:\n Exact
Dots:=seq([Dots[j][1],Exact(Dots[j][1])],j=1..n+1);\n\n " }}}{EXCHG
{PARA 0 "> " 0 "" {MPLTEXT 1 0 416 "# ================================
========\n # How to define and print percentage relative error:\n # ==
======================================\n P:=unapply(evalf(100*abs(ex
act-approx)/abs(exact)),(exact,approx));\n ExactVal:=ExactDots[11][2
]: # Pick off exact y-value for x=0.5\n ApproxVal:=Dots[11][2]: \+
# Get Euler approx y-value for x=0.5\n P(ExactVal),ApproxVal); \+
# print percent relative error\n\n " }}}{EXCHG {PARA 0 "> " 0 ""
{MPLTEXT 1 0 278 "# ========================================\n # How t
o create a Dots table for percentage error\n # =======================
=================\n P:=unapply(evalf(100*abs(exact-approx)/abs(exact
)),(exact,approx));\n Pdots:=seq([Dots[j][1],P(ExactDots[j][2],Dots[
j][2])],j=1..11);\n\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 272 "
# =========================================\n # Printing results and t
ables\n # Make tables with a pencil, it saves time.\n # ==============
==========================\n # To extract and print items 1,101,201,10
01 from a list:\n Dots1:=Dots[1],Dots[101],Dots[201],Dots[1001];\n\n \+
" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 333 "# ====================
=====================\n # Loop control\n # ===========================
=============\n # To automate the production of a Dots list,\n # enclo
se the desired code between 1 and 2 below.\n # 1. for k from 1 to 10 \+
do\n # 2. od:\n #\n # Keyword \"od:\" is short for \"end do:\"\n # Us
e \":\" to stop loop results from printing.\n\n " }}}{EXCHG {PARA 0 ">
" 0 "" {MPLTEXT 1 0 387 "# =========================================
\n # Debug\n # ========================================\n # To remove \+
loop control and do it by hand, insert\n # pound (#) signs as follows:
\n # 1. # for k from 1 to 10 do\n # 2. # od:\n # The hand-done loop \+
is made by placing the mouse cursor\n # in the group, then press retur
n. Repeat for each loop step,\n # which is 10 times for the loop above
.\n " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "# the end" }}}}
{MARK "1 0 0" 699 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1
2 33 1 1 }