#sfb 25 oct 03 How to use the TI-89 to do a two dimensional steepest decent. An aid to the big valley project. Strategy: Besides computing the next approximations we are going to want to store the answers in list variables. The Data Editor: One way of handling the lists/data/matrices is to use the data editor. One gets to the data editor via the APPS key, it is #6 on the list. It offers a choice of current/open/new. Use new to create new variables and open to find old ones. For new ones you will be given a choice of type Data/Matrix/List, we need lists, and you need to name the variable. We will use px and py. We might have other uses for the data editor, but we will create px and py without it below. Create our lists px and py Use newList, which is found in CATALOG (type n twice to jump to n's) scroll down to newList. Or alternately type newlist. Store into px and py. newList(0) sto> px newList(0) sto> py Create local index variables 1 sto> j1 # index into px and py 1 sto> px[j1] 0 sto> py[j1] # the zero^th point [Note: none of these are single letters -- this might be a good thing.] uninitialize variables p2, q2 # the current point obtained from px[j1], py[j1] at the top t1 # the t value of the next local minimum. Create functions put f(x,y) into z1 but MODE Graphing 3D green diamond y= z1=x^2-x*y+y^2 # The following need to be done only once d(z1(x,y),x) sto> fx(x,y) #fx for f_x d(z1(x,y),y) sto> fy(x,y) #fy for f_u p2-fx(p2,q2)*t sto> lx(t) q2-fy(p2,q2)*t sto> ly(t) # is Pu line z1(lx(t),ly(t) sto> g(t) #g is f restricted to Pu line Repeat loop px[j1] sto> p2 py[j1] sto> q2 j1 + 1 sto> j1 # the location to fill zeros(diff(g(t),t), t) # zeros is `F2 alg #4' diff is `F3 calc #1' @@@ Here is the only point where there is need for human like choice. There could be more than one zero and you have to pick the correct zero. Use [index of correct zero] zeros(diff(g(t),t), t)[1] sto> t1 lx(t1) sto> px[j1] ly(t1) sto> py[j1] Recall history to top of repeat I did the loop 5 times (j1 = 6 at the end) and got px {1 2/7 3/28 3/98 9/784 9/2744} py {0 5/14 0 15/392 0 45/10976} Which agrees with the project page. WE HAVE SUCCESS. More 1. Get the z-values seq(z1(px[n],py[n]),n,1,6) sto> pz The values are pz {1 3/28 9/784 27/21952 81/614656 243/17210368} 2. Draw a contour map (check your window) [DrwCtour in CATALOG] DrwCtour pz # it takes its time, default window too big, change to -1.5..1.5 for both x and y. But this changes the contours do the comand again DrwCtour pz 3. Draw the zig-zag line. Change the graphing mode to function, set the window 0..1 0..0.5 Line px[1],py[1],px[2],py[2] # then home button to type the next line Line px[2],py[2],px[3],py[3] Line px[3],py[3],px[4],py[4] Line px[4],py[4],px[5],py[5] Line px[5],py[5],px[6],py[6] # one can zoom in, but you have to redraw the lines. 4. We could put px and py into a data array and do and xyline plot might draw the lines faster. newData zig,px,py # We will use the data editor to recreate pz APPS 6 open variable=zig # define a statistics plot F2 F1 plot type -> xyline mark? x = c1 y = c2 enter enter green diamond y= # you can see plot1 appears and is checked check your window, 0..1 0..0.5 (MODE is function) look at graph, it is the zig-zag graph of #3, but you can zoom in on this 1 green diamond y= then uparrow to highlight plot1 F4 to deselect #optional way to recreate pz list APPS 6 open variable=zig Move the cursor to the rectangle named c3 hit enter c3 = z1(c1,c2) # recreates the pz list Notes: Apparently one can't use q1 or q3 as a variable name on ti-89 because they are used for the 1st and 3rd quartile for statistics.