!! File: Linear Response !! May 26,2003 Hubert Hohn PUBLIC PCFlag,Mac5Flag,M68KFlag,UnixFlag,xmax,ymax PUBLIC toolLft,toolRgt,toolBas,toolTop,toolhdr,toolHgt,toolWid ! tool boundaries PUBLIC winLft,winRgt,winBas,winTop,winHgt,winWid ! window PUBLIC workLft,workRgt,workBas,workTop,workMidx ! work area PUBLIC backclr,black,drkgry,drkmid,midgry,litmid,litgry,white PUBLIC red,yellow,green,cyan,blue,magenta,pink,colorscheme PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr,rightsclr PUBLIC numberlineclr,slotdrkclr,slotlgtclr,slideclr PUBLIC largefonts, title$, SLUmode LET toolHgt= 520 LET toolWid= 780 LET window$= "D'Arbeloff Interactive Math Project" LET colorscheme= 0 LET title$ = "Linear System Response" SUB ThisProgram CALL ShiftedFunction CLEAR END SUB !! --------------------------------------------------------- !! ------ Start TB4 Mac Header and Subs ------ !LET M68KFlag = 1 !LIBRARY "MacTools*", "HHLib.trc" !ASK PIXELS winWid,winHgt !LET winLft= 0 !LET winTop= 0 !LET winRgt= winWid-1 !LET winBas= winHgt-1 !SET WINDOW 0,winRgt,winBas,0 !CALL Palette !CLEAR ! !CALL ToolPanel !CALL ThisProgram ! !END !EXTERNAL ! !MODULE Mac4Parts ! SUB SetTextFont(font,size,style$) ! CALL MacTextFont(font) ! CALL MacTextSize(size) ! CALL MacTextFace(style$) ! END SUB ! ! SUB StringWidth(sw$,sl) ! DECLARE DEF MacStringWidth ! LET sl= MacStringWidth(sw$) ! END SUB ! ! SUB SetLineWeight(wgt) ! CALL MacPenSize(wgt,wgt) ! END SUB ! ! SUB BoxDisk(Lft,Rgt,Bas,Top) ! CALL MacPaintOval(Lft,Rgt,Bas,Top) ! END SUB !END MODULE !! --- End TB4 Mac Header and Subs --- !!--------------------------------------------------------- !!--- Start TB5 Cross-Platform header and subs --- LIBRARY "c:\TB Gold 51a\TBLibs\TrueCtrl.trc" ! windows LIBRARY "c:\TB Gold 51a\TBLibs\HHLib.trc" ! !LIBRARY ":TBLibs:TrueCtrl.trc" ! macintosh !LIBRARY "HHLib.trc" ! PUBLIC WinID DECLARE PUBLIC OBJM_SET,OBJM_SYSINFO LET winHgt= toolHgt LET winWid= toolWid DIM values(1) CALL TC_Init CALL Object(OBJM_SYSINFO,WinID,"MACHINE",system$,values()) IF system$="MAC" then LET Mac5Flag= 1 ELSE IF system$="WIN32" then LET PCFlag = 1 END IF CALL TC_SetUnitsToPixels ! 5.1 and up needs this CALL TC_GetScreenSize(scrnLft,scrnRgt,scrnBas,scrnTop) LET winLft= int((scrnRgt-scrnLft-winWid)/2) LET winRgt= winLft+winWid-1 LET winTop= int((scrnBas-winHgt)/2) !+ 10 LET winBas= winTop+winHgt-1 CALL TC_Win_Create (WinID,"TITLE",winLft,winRgt,winBas,winTop) LET values(1)= 2 CALL Object(OBJM_SET, WinID, "TYPE", "", values()) IF PCFlag=1 then ! kill dithering LET values(1)= 1 CALL Object(OBJM_SET, WinID, "SOLID MIX", "", values()) END IF LET values(1)= 0 CALL TC_SetRect(WinID,winLft,winRgt,winBas,winTop) CALL TC_Win_SetTitle(WinID,window$) CALL TC_Show(WinID) SET MODE "COLORSTANDARD" ASK PIXELS winWid,winHgt ! must follow set mode LET winLft= 0 LET winTop= 0 LET winRgt= winWid-1 LET winBas= winHgt-1 SET WINDOW 0,winRgt,winBas,0 CALL Palette IF PCFlag=1 then LET values(1)= 0 ! now force solid colors CALL Object(OBJM_SET, WinID, "SOLID MIX", "", values()) CALL TC_Win_RealizePalette(WinID) ! some PCs need this CALL TC_Win_SetFont(WinID,"arial",9,"plain") CALL StringWidth("0",sw) IF sw>7 then LET largefonts=1 else LET largefonts=0 END IF CALL TC_Win_Switch(WinID) CALL ToolPanel CALL ThisProgram CALL SetTextFont(1,12,"bold") ! now shut down and clean up LET quit$= "click the mouse or press a key to close..." CALL PlotTextCJ(workmidx,(workbas+worktop)/2,quit$,yellow) CALL TC_CleanUp END EXTERNAL MODULE TB5Parts SUB StringWidth(sw$,sl) DECLARE PUBLIC WinID LET sl= StrWidth(WinID,sw$) END SUB SUB SetLineWeight(wgt) DECLARE PUBLIC OBJM_SET DECLARE PUBLIC WinID DIM values(1) LET values(1)= wgt CALL Object(OBJM_SET,WinID, "WIDTH", "", values()) END SUB SUB SetTextFont(font,size,style$) DECLARE PUBLIC WinID,Mac5Flag,PCFlag,largefonts IF Mac5Flag=1 then SELECT CASE font CASE 4 LET font$= "Courier" CASE 16 LET font$= "Times" CASE else LET font$= "Geneva" END SELECT ELSE IF PCFlag=1 then IF largefonts=1 then IF size<12 then LET size= 6 ELSE IF size=14 then LET size= 10 ELSE IF size=18 then LET size= 12 ELSE IF size=24 then LET size= 14 ELSE IF size=12 then LET size= 8 ELSE LET size= round(72/96 * size * .8) END IF ELSE IF size<12 then LET size= 7 ELSE IF size=14 then LET size= 12 ELSE IF size=12 then LET size= 9 ELSE IF size=18 then LET size= 14 ELSE IF size=24 then LET size= 18 ELSE LET size= round(72/96 * size) END IF END IF SELECT CASE font CASE 4 LET font$= "Courier New" CASE 16 LET font$= "Times New Roman" CASE else LET font$= "Verdana" END SELECT END IF IF style$= "normal" then LET style$= "plain" CALL TC_Win_SetFont(WinID,font$,size,style$) END SUB SUB BoxDisk(Lft,Rgt,Bas,Top) BOX DISK Lft,Rgt,Bas,Top END SUB END MODULE ! --- End TB5 Cross-platform header and subs --- !! --------------------------------------------------------- ! *** SUB ShiftedFunction DECLARE PUBLIC worklft,workrgt,workbas,worktop,workmidx ! work area DECLARE PUBLIC backclr,black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta DECLARE PUBLIC slideclr,axisclr,axislabelclr,gridclr,true,false DECLARE DEF InfoWithin, QuitWithin ! --- help screen array --- DIM info$(1:1) MAT READ info$ DATA "Population Growth: Logistic and Exponential" ! ---------- Utility functions --- DECLARE DEF clamp,roundn,e DEF badarg= -0.01234543210 ! --- functions and parameters --- LET bignum= 10^10 ! DEF f(x)= 0 DEF delta(t) ! delta(t) makes a vertical arrow with a large head ! starting at the t-axis at t = 0 ! the number 1/b or 1/k should appear next to arrow LET f= bignum LET g= bignum LET h= bignum END DEF DEF ddelta(t) ! delta'(t) makes a vertical arrow at t = 0 ! with two heads one above the other ! the number 1/k should appear next to arrow LET f= bignum LET g= bignum LET h= bignum END DEF SUB GetValues IF t<0 then LET f= 0 LET g= 0 LET h= 0 ELSE ! t is <> 0 IF m<>0 then LET omega= sqr(abs( (b/(2*m))^2 - k/m) ) IF omega<>0 then LET mk4 = 4*m*k IF b > mk4 then LET r = (-b/(2*m)) + omega LET s = (-b/(2*m)) - omega IF k <> 0 then LET f = (1/k)*(1 + (s/(2*omega))*e^(r*t) - (r/(2*omega))*e^(s*t)) LET g = (1/(2*m*omega))*(e^(r*t) - e^(s*t)) LET h = (1/(2*m*omega))*(r*e^(r*t) - s*e^(s*t)) ELSE IF k = 0 then ! b <> 0 LET f = (1/b)*(t - (1/(2*b*omega))*(e^(r*t) - e^(s*t)) ) LET g = (1/b)*(1 - (1/(2*b*omega))*(r*e^(r*t) - s*e^(s*t))) LET h = - (1/(2*b^2*omega))*(r^2 * e^(r*t) - s^2*e^(s*t)) END IF ! k ELSE IF b = mk4 then IF k <> 0 then LET f = (1/k)*(1 - (1 + (b*t/(2*m)))*e^(-b*t/(2*m))) LET g = (b*t/m)*e^(-b*t/(2*m)) LET h = (b/m)*(1 - (b^2*t/(2*m^2)))*e^(-b*t/(2*m)) ELSE IF k = 0 then ! b = 0 LET f = t^2/(2*m) LET g = t/m LET h = 1/m END IF ! k ELSE IF b < mk4 then IF k <> 0 then LET f = (1/k)*(1 - e^(-b*t/(2*m))*(cos(omega*t) + (b/(2*m*omega))*sin(omega*t))) LET g = (1/(m*omega))*e^(-b*t/(2*m))*sin(omega*t) LET h = (1/m)*e^(-b*t/(2*m))*(cos(omega*t) - (b/(2*m*omega))*sin(omega*t)) ELSE IF k = 0 then ! ?? END IF ! k END IF ! b END IF ELSE ! m = 0 - it's a first order system IF b <> 0 then LET f = (1/k)*(1 - e^(-(k/b)*t)) LET g = (1/b)*e^(-(k/b)*t) LET h = -(k/b^2)*e^(-(k/b)*t) + (1/b)*delta(t) ELSE IF b = 0 then IF k <> 0 then ! k is not zero - it's a zeroth order system LET f = 1/k LET g = (1/k)*delta(t) LET h = (1/k)*ddelta(t) ELSE ! all params zero ! don't plot - all three curves are turned off END IF ! k END IF ! b END IF ! m END IF ! t END SUB ! --- Graphing plane parameters and methods --- LET wwid = 300 LET whgt = 300 LET fwid = 4 LET fhgt = 40 LET vrule1= worklft + 80 LET vrule2= vrule1 + wwid + 120 LET vrule3= vrule2 + wwid + 60 LET gstp = 2 ! ----- graph window 1 ----- DECLARE PUBLIC w1Lft,w1Rgt,w1Bas,w1Top,w1Midx,w1Midy DECLARE PUBLIC w1fLft,w1fRgt,w1fBas,w1fTop,w1x0,w1y0 DECLARE PUBLIC w1xFirst, w1xSTik, w1xLTik, w1xLabel, w1xGridstep DECLARE PUBLIC w1yFirst, w1ySTik, w1yLTik, w1yLabel, w1yGridstep DECLARE PUBLIC w1wWid,w1wHgt,w1fWid,w1fHgt DECLARE PUBLIC w1fxRatio,w1fyRatio,w1wxRatio,w1wyRatio,w1Aspect DECLARE PUBLIC w1xPiFlag, w1xMult, w1yPiFlag, w1yMult LET w1Flag = 1 LET w1xPiFlag= 0 LET w1xMult = 1 LET w1yPiFlag= 0 LET w1yMult = 1 LET w1Lft = vrule1 LET w1Rgt = w1Lft + 300 LET w1Top = worktop + 80 LET w1Bas = w1Top + 300 LET w1fLft= -1 LET w1fRgt= 14 LET w1fBas= -4 LET w1fTop= 4 LET w1xAx$= "t" ! axis labels LET w1yAx$= "x" LET w1xGridstep= 0 ! horizontal grid intervals LET w1yGridstep= 0 ! vertical grid intervals LET w1xSTik = .5 ! horizontal axis Tik marks LET w1xLTik = 1 LET w1xLabel = 1 LET w1xFirst = w1fLft LET w1ySTik = 0 ! vertical axis Tik marks LET w1yLTik = .50 LET w1yLabel = .50 LET w1yFirst = w1fBas ! --- Plane 1 methods --- DECLARE DEF w1fncx,w1fncy,w1wndx,w1wndy ! window/function transforms DECLARE DEF w1Within,w1wWithin,w1fWithin CALL w1Variables SUB w1Init BOX CLEAR w1Lft-25,w1Rgt+20,w1Bas+15,w1Top-20 CALL w1DrawPlane(1,1,1) CALL SetTextFont(1,12,"bold") CALL PlotTextLJ(w1Rgt+8,w1y0+3,w1xAx$,litgry) CALL PlotTextCJ(w1x0,w1Top-11,w1yAx$,litgry) CALL SetTextFont(1,9,"normal") CALL w1KeepGridLayer END SUB ! --- Slider parameters and methods --- ! --- h1 slider data --- DECLARE PUBLIC h1axis,h1wLft,h1wRgt,h1wBas,h1wTop,h1fLft,h1fRgt DECLARE PUBLIC h1name$,h1form$,h1clr,h1First,h1STik,h1LTik,h1Label DECLARE PUBLIC h1PiAxis,h1Mult,h1fMin,h1fMax LET h1Flag= 1 LET h1PiAxis= 0 LET h1Mult = 1 LET h1clr = cyan LET h1name$ = "m" LET h1form$ = "---%.##" LET h1Places= 2 LET h1axis = w1Bas - 100 !13 LET h1wLft = w1Rgt + 100 LET h1wRgt = h1wLft + 200 LET h1fLft = 0 LET h1fRgt = 8 LET h1STik = .5 ! short tick marks LET h1LTik = 1 ! long tick marks LET h1Label = 1 ! labels LET h1First = h1fLft ! first tick mark LET h1Click = .5 ! --- h1 slider methods --- DECLARE DEF h1Within CALL h1SliderVariables SUB h1Init CALL h1SliderVariables CALL h1DrawSlider(h1name$,m) END SUB ! --- h2 slider data --- DECLARE PUBLIC h2axis,h2wLft,h2wRgt,h2wBas,h2wTop,h2fLft,h2fRgt DECLARE PUBLIC h2name$,h2form$,h2clr,h2First,h2STik,h2LTik,h2Label DECLARE PUBLIC h2PiAxis,h2Mult,h2fMin,h2fMax LET h2Flag = 1 LET h2PiAxis= 0 LET h2Mult = 1 LET h2clr = cyan LET h2name$ = "b" LET h2form$ = "--%.##" LET h2Places= 2 LET h2axis = h1Axis + 45 LET h2wLft = h1wLft LET h2wRgt = h1wRgt LET h2fLft = 0 LET h2fRgt = 4 LET h2STik = .5 ! short tick marks LET h2LTik = 1 ! long tick marks LET h2Label = 1 ! labels LET h2First = h2fLft ! first tick mark LET h2Click = 1 ! --- h2 slider methods --- DECLARE DEF h2Within CALL h2SliderVariables SUB h2Init CALL h2SliderVariables CALL h2DrawSlider(h2name$,b) END SUB ! --- h3 slider data --- DECLARE PUBLIC h3axis,h3wLft,h3wRgt,h3wBas,h3wTop,h3fLft,h3fRgt DECLARE PUBLIC h3name$,h3form$,h3clr,h3First,h3STik,h3LTik,h3Label DECLARE PUBLIC h3PiAxis,h3Mult,h3fMin,h3fMax LET h3PiAxis= 0 LET h3Mult = 1 LET h3clr = cyan LET h3name$ = "k" LET h3form$ = "--%.##" LET h3Places= 3 LET h3axis = h2axis + 45 LET h3wLft = h2wlft LET h3wRgt = h2wrgt LET h3fLft = 0 LET h3fRgt = 2 LET h3STik = 0.5 ! short tick marks LET h3LTik = 1 ! long tick marks LET h3Label = 1 ! labels LET h3First = h3fLft ! first tick mark LET h3Click = 1 ! --- h3 slider methods --- DECLARE DEF h3Within SUB h3Init CALL h3SliderVariables CALL h3DrawSlider(h3name$,k) END SUB SUB h3Clear BOX LINES h3wLft-20,h3wRgt+30,h3wBas+5,h3wTop-5 END SUB ! --- t1 text - Linear Equation --- ! m x" + b x' + k x LET t1BasLn = w1Top + 8 LET t1Lft = h1wLft LET t1Rgt = t1Lft + 300 LET t1Top = t1BasLn - 15 LET t1Bas = t1BasLn + 5 LET t1Clr1 = cyan SUB t1Init CALL SetTextFont(1,12,"bold") CALL PlotTextLJ(t1Lft,t1BasLn,"mx'' + bx' + kx" ,white) END SUB SUB t1ClearValue BOX CLEAR t1Eqx-2,t1Rgt,t1Bas2,t1Top2 END SUB ! --- t2 text - Linear Equation --- LET t2BasLn1= w1Top + 8 + 40 LET t2BasLn2= t2BasLn1 + 20 LET t2BasLn3= t2BasLn2 + 20 LET t2Lft = h1wLft LET t2Rgt = t2Lft + 300 LET t2Top = t2BasLn1 - 15 LET t2Bas = t2BasLn3 + 5 LET t2Clr1 = cyan SUB t2Init CALL SetTextFont(1,12,"bold") CALL PlotTextLJ(t2Lft,t2BasLn1,"Step Response" ,yellow) CALL PlotTextLJ(t2Lft,t2BasLn2,"Impulse Response" ,cyan) CALL PlotTextLJ(t2Lft,t2BasLn3,"Doublet Response" ,green) !step response f !impulse response g !doublet response h END SUB SUB t2ClearValue BOX CLEAR t2Eqx-2,t2Rgt,t2Bas2,t2Top2 END SUB ! --- t5 text - rollover x and y values --- LET t5BasLn1 = w1Bas + 35 LET t5BasLn2 = t5BasLn1 + 20 LET t5Lft = w1Lft LET t5Rgt = t5Lft + 150 LET t5Top = t5BasLn1 - 15 LET t5Bas = t5BasLn2 + 5 LET t5Form$ = "---%.##" LET t5Label1$= "x = " LET t5Label2$= "y = " CALL StringWidth(t5Label2$,sw) LET t5Eqx = t5Lft + sw LET t5Clr1 = cyan SUB t5Clear BOX CLEAR t5Lft,t5Rgt,t5Bas,t5Top LET t5State= 0 END SUB SUB t5ClearValue BOX CLEAR t5Eqx,t5Rgt,t5Bas,t5Top END SUB SUB t5Init CALL SetTextFont(1,12,"bold") CALL PlotTextRJ(t5Eqx,t5Basln1,t5Label1$,t5Clr1) CALL PlotTextRJ(t5Eqx,t5Basln2,t5Label2$,t5Clr1) CALL t5Value END SUB SUB t5Value CALL t5ClearValue LET x$= trim$(using$("####",x+1790)) LET y$= trim$(using$(t5Form$,y)) CALL PlotTextLJ(t5Eqx,t5Basln1,x$,t5Clr1) CALL PlotTextLJ(t5Eqx,t5Basln2,y$,t5Clr1) LET t5State= 1 END SUB ! --- t6 text - profit --- LET t6BasLn = tb1Bas + 23 LET t6Top = t6BasLn - 15 LET t6Bas = t6BasLn + 5 LET t6Form$ = "---%.##" LET t6Label$ = "profit = " CALL StringWidth(t6Label$&t6Form$,sw) LET t6Lft = tb1Lft LET t6Rgt = t6Lft + 200 CALL StringWidth(t6Label$,sw) LET t6Eqx = t6Lft + sw LET t6Clr1 = litgry SUB t6Clear BOX CLEAR t6Lft,t6Rgt,t6Bas,t6Top LET t6State= 0 END SUB SUB t6ClearValue BOX CLEAR t6Eqx,t6Rgt,t6Bas,t6Top END SUB SUB t6Init CALL SetTextFont(1,12,"bold") CALL PlotTextRJ(t6Eqx,t6BasLn,t6Label$,t6Clr1) CALL t6Value END SUB SUB t6Value CALL t6ClearValue !LET y = f(x) LET p = 55.45*x - y LET p$= trim$(using$(t6Form$,p)) CALL PlotTextLJ(t6Eqx,t6Basln,p$,t6Clr1) LET t6State= 1 END SUB ! --- LET btnHgt= 19 LET bfRgt = w1Rgt LET bfLft = bfRgt - 75 LET bfTop = w1Bas + 30 LET bfBas = bfTop + btnHgt SUB Buttons CALL SetTextFont(1,12,"Bold") CALL DrawButton(bfLft,bfRgt,bfBas,bfTop,5,"") END SUB ! ! --- radio boxes --- ! ! DECLARE PUBLIC r1cnt, r1stp, r1siz ! DECLARE PUBLIC r1Lft, r1Rgt, r1Bas, r1Top, r1Name$, r1NameClr ! DECLARE PUBLIC r1NameList$(),r1ColorList() ! ! LET r1cnt= 3 ! box count ! LET r1Lft= bfLft ! LET r1Top= bfBas + 45 ! ! CALL r1SetVars ! ! LET r1Name$ = "Model" ! LET r1NameClr= litgry ! ! MAT redim r1NameList$(1:r1cnt) ! text strings ! DATA "Logistic","Exponential","Both" ! MAT READ r1NameList$ ! ! MAT redim r1ColorList(1:r1cnt) ! colors ! DATA 26,24,21 ! MAT READ r1ColorList ! ! DECLARE DEF r1Within ! --- default parameters --- ! LET L= 197.27 ! 0 to 200 ! LET a= 49.58 ! 0 to 100 ! LET k= 0.03134 ! 0 to 0.5 ! LET b= 1.031 ! 0 to 2 ! LET c= 3.926 ! 0 to 4 LET tb1Pntr = 1 LET m,oldm = 1 LET b,oldb = 0 LET k,oldk = 2 LET f$ = form$ LET r1num = 1 LET eq = r1num ! --- Draw screen --- CALL InitScreen SUB InitScreen BOX CLEAR worklft,workrgt,workbas,worktop CALL w1Init CALL w1LogGraph CALL h1Init CALL h2Init CALL h3Init CALL t1Init CALL t2Init END SUB ! --- Event manager ------------------------------ DO LET initflag= 1 BOX KEEP w1Lft-5,w1Rgt+5,w1Bas+5,w1Top-5 in temp$ DO GET MOUSE: mx,my,ms ! IF w1Within(mx,my)=1 then ! IF t5State=0 then CALL t5init ! IF dataPntr=3 then ! IF t6State=0 then CALL t6init ! END IF ! IF mx<>oldmx then ! LET x = round(w1Fncx(mx),-1) ! LET y = round(f(x),2) ! IF dataPntr=3 then ! CALL t5Value ! CALL t6Value ! LET wx= w1Wndx(x) ! LET wy= w1Wndy(y) ! IF w1wWithin(wx,wy)=true then ! LET clr= litgry ! BOX SHOW temp$ at w1Lft-5,w1Bas+5 ! LET r = 55.45*x ! LET wr= w1Wndy(r) ! IF wp>w1Top and wpw1Top and wybfLft and mxbfTop and myoldm then CALL w1ShowGraphLayer CALL w1LogGraph ! call t2function LET oldm= m END IF END SUB ! ----- h2 slider ----- SUB h2ClickEvent(ms,b) CALL h2GetClickVal(ms,h2Click,b) CALL h2Action END SUB SUB h2DragEvent(ms,b) DO CALL h2GetDragVal(ms,h2Places,b) CALL h2Action LOOP until ms=3 END SUB SUB h2Action IF b<>oldb then CALL w1ShowGraphLayer CALL w1LogGraph ! call t2function LET oldb= b END IF END SUB ! ----- h3 slider ----- SUB h3ClickEvent(ms,k) CALL h3GetClickVal(ms,h3Click,k) CALL h3Action END SUB SUB h3DragEvent(ms,k) DO CALL h3GetDragVal(ms,h3Places,k) CALL h3Action LOOP until ms=3 END SUB SUB h3Action IF k<>oldk then CALL w1ShowGraphLayer CALL w1LogGraph ! call t2function LET oldk= k END IF END SUB ! --- draw the function graphs --- SUB w1LogGraph ! internal LOCAL x,y,wx,wy CALL w1ShowGridLayer FOR wx= w1Lft to w1Rgt LET t= w1Fncx(wx) CALL GetValues SET COLOR yellow LET wy= w1Wndy(f) IF w1wWithin(wx,wy)=true then PLOT wx,wy SET COLOR cyan LET wy= w1Wndy(g) IF w1wWithin(wx,wy)=true then PLOT wx,wy SET COLOR green LET wy= w1Wndy(h) IF w1wWithin(wx,wy)=true then PLOT wx,wy NEXT wx PLOT END SUB END SUB ! --- end of regression ex1 function ----------------