The Applcato of Vsual Basc Computer Programmg Laguage to Smulate Numercal Iteratos A.B. Hassa, M.S. Abolar ad O.H.Jmoh Departmet of Mechacal Egeerg, Federal Uversty of Techology Ma, Ngera Abstract Ths paper exames the applcato of Vsual Basc Computer Programmg Laguage to Smulate Numercal Iteratos, the mert of Vsual Basc as a Programmg Laguage ad the dffcultes faced whe solvg umercal teratos aalytcally, ths research paper ecourage the uses of Computer Programmg methods for the executo of umercal teratos ad fally fasho out ad develop a relable soluto usg Vsual Basc package to wrte a program for some selected terato problems. Keywords: Smulato, Algorthm, Costra, Itegrato, errors, Ruge-Kutta, Euler, Improved Euler, Predctor-Corrector, Newto-Raphso, Lagraga Iterpolato Polyomal, Itroducto Computer Smulato s a powerful alteratve approach to solve umercal terato usg a hgh level laguage of terest. Smulato s a very useful research tool ad s a legtmate, dscpled approach to scetfc vestgato ad ts value eeds to be recogzed ad apprecated. Smulato aalyss offers a varety of beefts; t ca be useful developg theory ad gudg emprcal work. It ca provde sght to the operato of complex systems ad explore ther behavour. It ca exame the cosequece of theoretcal argumets ad assumptos geerate alteratve explaatos ad hypothess, test the valdty of explaatos Numercal aalyss s cocer wth the mathematcal dervato descrpto ad aalyss of methods of obtag umercal soluto of mathematcal problems wth lttle or o error resultg from approxmato. It s ca also be referred to as that brach of appled mathematcas whch studes the methods ad algorthms to fd (approxmate) umercal solutos to varous mathematcal problems usg a fte sequece of arthmetc ad logcal operato. It s a process of repeatg a set of structo, a specfed umber of tmes utl a specfc result s acheved. The veto of moder techology has greatly makes lfe easy for scetst & Egeerg wth veto of computer maches of varous specfcatos, desg speed ad the developmet of varous computer applcato programmg laguages whch helps wrtg ad developmet of programs that ca be used to solve qute a umber of umercal teratos. Scetst ad Egeerg are ot oly terested the formulato of equatos but also desg ad model varous methods for whch problem ca be solved. Aalytcal techques s cosder to be tme wastg ad there s a lmt to ths terms of solvg a complex mathematcal teratos, however applcato of computer ca do eve more complex forms of ay gve formular ad equatos ad ths s the focus of ths paper. Cote S.D (965), dd a excellet job o umercal aalyss ad programmg aspect of t whe they make uses of Fortra IV programmg laguage they make a comparsm betwee aalytcal method of solvg umercal teratos ad programmg method of solvg umercal teratos ad came up wth a cocluso that programmg method of solvg umercal teratos usg 09
computer s faster tha usg aalytcal method ad safe tme wth a very eglgble errors or o errors curred at all. Haggerty G.B(97), vew that more ofte that ot all umercal aalyss are oreted toward a mathematcal treatmet of the subject, he attempt to brdge ths gap wthout eglectg the mathematcal aspect, so the etre cotet of hs work cotas abudace of flow chart ad programs wth output ragg from smple to rather sophstcated type of problems. He also used FORTRAN IV programmg laguages for the algorthms. Above all, these researchers make uses of FORTRAN IV programmg laguage whch s a text based laguage. Text based laguage do ot allow the users to work drectly wth graphcs ad ths s oe dsadvatages why the use of FORTRAN IV programmg laguage s ot cosder for use ths research work, rather vsual basc programmg laguage s cosder for use. Vsual basc programmg laguage s oe of the most wdely use hgh level laguage today because of ts advatages. Types of Programmg Laguage Hudreds of hgh level laguages have bee developed ad desged amog these are BASIC whch s (Beger, All purpose Symbolc Istructo Code) FORTRAN, COBALT, PASCAL, DBASE, C-Laguage JAVA etc. FORTRAN (Fortra Traslator) was developed by IBM Corporato betwee 954 ad 957 to be used for scetfc ad egeerg applcato that requre complex mathematcal computato but t s a text base programmg laguage. Des Rche 97 at Bell laboratores developed a C- programmg laguage, C laguage s a very popular package amog the computer user, t was frst used to develop the UNIX Operatg system. C s a exteso of C, developed by Bjare stroustrup the early 980 s at Bell laboratores. C provdes a umber of features that spruce up the C laguage hast the capabltes for dog so called object- oreted programmg (OOP) May people beleve that (OOP) ca greatly mprove the software developmet process C has become the domat system mplemetato laguage. Java was developed by SUN Mcro system ad released 995. Java s based o C ad C ad corporates a umber of features from other object oreted laguage. Java cludes extesve lbrares for dog multmeda, etworkg, mult readg graphcs data base access ad much more. Mcrosoft verso of Java s called vsual J may people beleve that Java ad vsual J wll be the most sgfcat log-term compettor to Vsual Basc. Desg Aalyss The desg aalyss volve developg,wrtg of program ad the stallato applcato package that s compatble wth the program that have bee developed ad be able to ru cocurretly wth the program already stalled the system. The applcato program that was cosdered sutable for the program s Vsual Basc verso 6. Methodology The techques used for ths project cludes cosultatos of relevat text books that treated umercal teratos ad some programmg text books that treated Vsual Basc ad other mathematcal text books. Evoluto of Vsual Basc Vsual basc s derved form the BASIC programmg laguages, t s a Mcrosoft wdow programmg laguage, vsual basc program are created a tegrated developmet evromet (IDE), whch allows the programmer to create ru ad desg vsual basc programs coveetly t s also allow a programmer to create workg programs a fracto of tme that ormally takes to code programs wthout usg IDES. The wde spread use of BASIC Laguage wth varous types of computer (sometmes called hardware platform) led to may ehacemet 0
to the laguages wth the developmet of Mcrosoft wdows graphcal user terface (GVI) the late 980 s ad the early 990 s, the atural evoluto of basc was vsual basc whch was created by Mcrosoft corporato 99. Vsual basc s the worlds most wdely use RAD laguage, (Rapd Applcato Developmet (RAD) s the process of rapdly creatg a applcato. Vsual Basc provde a powerful features such as graphcal user terface, evets hadlg assess to W 3 API, object- oreted features, error hadlg, structured programmg ad much more. Not utl Vsual Basc appeared, developg Mcrosoft wdows based applcato was a dffcult ad cumbersome process. Vsual basc greatly smplfes wdow applcato developmet. The advatages of vsual basc programmg laguage Qute a umber of programmg laguages are text based ad text based laguages whch do ot allow user to work drectly wth graphcs but vsual basc s a graphcal based laguage whch allows user to work drectly wth graphc. Graphcal based laguage ca be used to develop wdows program quckly. Basc gves a dscpled approach to wrtg programs that are clearer tha ustructured programs, easer to test, debug ad ca be easly modfy. It allows for the creato of powerful ad professoal lookg applcato wth less tme ad codg. It allows for strog typg.e. has wde varety of put data types ad support Rapd Applcato Developmet (RAD).It has a complete edfyg ad debuggg facltes ad has the ablty to geerate a Dyamc Lk Lbrares (DLL`S), t allows for easer maagemet of documet ad t s easy to lear. Vsual Basc s a complete form of package for buldg user terface Theores & aalyss Ths a method use obtag a ew approxmate soluto,t s a repeatg process for obtag a ew approxmate soluto.ths process ca be carred out ether aalytcally or by wrtg a programmg laguage usg a partcular programmg laguage of terest. As early stated ths research paper Start Dsplay the splash scree Dsplay the Ma Scree Newto Rapso Euler Improved Euler Rugekutta Lagrages terpolatg polyomal Ext Fg.. Flow Chart of Numercal Iteratos Process. Stop
Vsual Basc programmg laguage has bee chose for use. Ths paper s oly gog to cosder, applcato of Vsual Basc to solve the solutos of fve dfferet umercal terato methods. These are Newto Raphso, Euler, Improved Euler, Ruge- kutta ad Lagrage s terpolato methods ad ths s the lmt of ths paper. A algorthm to look to how ths program ca be wrtte has bee developed whch follows the patters of the flow chart The flow-chart shows some of the terato methods adopted wrtg the programs Ruge-Kutta method Ruge-Kutta s amed after two Germa mathematcas Carl Ruge (856-97) ad y y ( k k k3 k4 ) 6 where k hf x. y ( ) Wlhelm Kutta (867-944) ad ths method s used for approxmatg the soluto y g(x), t has a hgher order of accuracy tha ay of the umercal methods. The Ruge Kutta method s oe of the most wdely used ad t s partcularly sutable cases whe the computato of hgher duratos s complcated. It ca be used for regulato of arbtrary order by meas of a trasformato to a system of frst order equatos. Ths method utlze the weghted sum of the value of (x,y) evaluated at the startg pot of each step ad of varous pot across the tegrato step. Although there are may Ruge Kutta methods of order,,3,4,5 ad so o but the fourth order s most popularly use ad fourth order s the lmt of ths paper. I each terval the value of y s calculated for: k h k h k ( x h y k ) hf x ; y ; k3 hf x ; y ; k4 hf ; 3
Euler s method The Euler method amed after Leo hard Euler (707-783), hs method s used for computg umercal approxmatos to the soluto of the tal value problem. I Euler s method or Euler Cauchy method f(x,y) s assumed to be approxmately costat wth the terval X, X If we let h x x, the y y hf ( x, y Startg wth y o y( X 0), Y ca be determed. e y y( x h) Where 0,,. ) 3
Improved Euler Method (Predctor-Corrector Method) Ths method s a mproved verso of Euler s method. I ths method, computato s doe usg auxlary value y* To compute for y ; y h f ( x, y ) f ( x, y ) y [ f( x, y ) ] The predctor ths case s y y 0.( x y The corrector s f y y ) 0.[( x y) ( x y )] h! 3 h 3! ( x h) F x) hf'( x) f ( x) f x)... f ( x) EF ( ) 0 ( 0 0 0 0 o E h! Newto Raphso method The Newto-Raphso method was developed for solvg roots of equatos, If F(x) 0, where f(x) ca be algebrac or trascedetal fucto. Let x 0 deote a approxmate value of the root ad h deote the correcto that must be appled to gve the true value of the root whch we shall deote by x. A geeral method for solvg root of the equato s adopted;.e. F ( x) 0, where F (x) the algebrac fucto The geeral formular adopted s deduce form the equato XX 0 h The the equato F(x) 0 becomes, ( x 0 h) 0, applyg Taylor s rules Where E 0 (E) Remader terms after th terms trucatg the seres after two terms. I geeral X X f ( X ) f ( X ) 4
Lagraga Iterpolato Polyomal Largrage terpolatg polyomal s a secto of umercal methods used for evaluatg polyomals, The Lagraga P ( x ), f ( x ) Gve by P ( x ), Where 0 L ( x) 0,,, 3 L ( x) f ( x ) x x j x x j 0,, Nth degree polyomal x ad multples each fuctoal value of f(x ) cluded the polyomal ft ad L (x) has the propertes L ( xj) 0 j & I geeral P( x) L f ( x0) L f ( x ) L f ( x) L j f ( x ) 0 The ( x x0)( x x )( x x)( x x3)( x x4) ( x x )( x x )( x x )( x x )( x x ) 0 0 3 3 4 j 0; J Program desg The applcato program was stalled the system wth the program wrtte for each of the terato to be mplemeted the program, these are show below: 5
6
Computer system System Aalyss Computer system falls to two classes: the software system ad the hardware system. The software s the collecto of programs or structos that cotrol the operatos of computer hardware. O the other had, the computer hardware s the physcal compoets ad devces, whch make up the vsble computer. Computer hardware cossts of at least oe computer ad ts perpheral devces. Perform Arthmetc ad Logc operato Data ad structos ALU Hold data, structo ad the processed result From operator Iput Memory Ut Output Ut To operator Cotrol Ut Fg..Computer hardware cofgurato Orgazato of a Dgtal Computer A dgtal computer s fuctoally orgazed to the followg fudametal uts: Iput: The put devces read the ecessary data to mache. It matas commucato betwee the computer ad ts evromet by acceptg commucato from the devces ad covertg t to a form sutable for use by the rest of the computer systems. Examples of put devces clude the keyboard, puched card ad paper tape readers, magetc tape readers ad varous maual put devces such as toggle ad pushbuttos. Cotrol: It s usually geerated by the cotrol ut of a computer to sequece the operato of the computer as well as cotrollg the actos of all other uts such as the put store ad ALU. It also cotrols the future operato of the cotrols ut tself. Memory: The memory, or storage, secto of the computer cossts of the devces used to 7 store the formato that wll be used durg the computatos. The memory s also used to hold by termedate ad fal results as the computer proceeds through the program. Examples of storage devces are tegrated crcut memores, magetc tape, ad magetc dsks. Arthmetc-Logc Ut: Ths s acto of the computer to trasforms data by performg arthmetc ad logcal operato that s, t s capable of performg addto, subtracto, dvso, ad multplcato as well as some logcal operatos. The ALU operates uder the commad of the cotrol uts, whch cotrols the operato of the varous sectos ad drect the flow of formato amog them. Output: Ths s used to record the results obtaed by the computer ad preset them to the outsde world. Commo output devces are CRT dsplays, prters, card puchg maches, ad magetc tape drves etc. I the system aalyss the system wll be provded wth the equatos other detals such as tal value x, the steps ad some other requre put codtos as bee requred,
specfed for the equato to be terated, wth all the requred data avalable, the user ca eter the data to the computer by structg ad specfy what the system should do, oce ths s doe the system wll process t, come wth result whch ca be vewed o the scree. However there are some requremets whch must be satsfed order to acheve the best result, these are hghlghted below. The terato to be performed must be chose; all the tal codtos must be specfed. The system should be able to serve the purpose rrespectve of where t s used provded the package ad all ecessary Operatg System (OS) requre rug the terato s stall the system. System Desg The package requre to ru the teratos process has bee wrtte wth the Vsual Basc(VB) stalled to the system to be used for the executo of the terato process t has also bee tested ad ru wth dfferet data tested for ts lmt ad level of ts accuracy. To obta the best possble result the put data must coform to the rules of the terato to be mplemeted. Parallel approach s system adopted the mplemetato of the desg for the system, parallel approach s a system whereby the computer s allow to rus alogsde the exstg maual method. After a gve tme depedg o the cofguratos ad the speed of the system use the mplemetato of the terato a report from the system ut s dsplay o the scree whch ca be evaluated ad f the results are acceptable the system ca be fully adopted. Securty: The act of applyg securty for the protecto of the data ad t volve hard-ware relablty. A system aalyss eeds to have a workable securty system to protect the system from damage error ad by uauthorzed user System Requremet Software Specfcatos The soft requremet for the system cludes: Wdow XP operatg System Mcafee Atvrus Package Mcrosoft Vsual Basc Ver 6.0 Hardware Specfcatos The hardware specfcatos for ths project work are stated as follow: Petum Motherboard Processor Itel 333 HZ Memory (RAM): 8MB Hard dsk 5GB Motor SVGA 7 Ich Prter HP 00 Laser jet A ehaced Key board System evaluato Ths program was developed to elmate the problem face the aalytcal method of solvg umercal terato whch ams at provdg the followg: Accuracy; Hgh Speed; Hgh storage capacty; Good effcecy; Relablty; Reduce errors; Adequate securty for the program. Objectves of system desg Results ad Dscussos Effcecy: These volve accuracy, speed ad comprehesveess of the system output. Flexbly: Ths s the ablty of the system to adjust to the chagg requremet of user. It also volves portablty of system. 8 Havg stated the formulae to be used the executo of the terato processes for oly fve selected mathematcal teratos, a program wrtte Vsual Basc verso 6.0 laguages was successfully ru a PC system, wth ths package, oe ca slot ay value provded the value falls wth the valdty of
the smulato model of the program. The program has the capablty to accept, ru, perform, execute ad gve the fal aswers to umercal terato method adopted. Cocluso Computer Smulato s a useful research tool that opes up ew techques for solvg umercal terato problems. It saves tme ad reduces errors to ts mmum level as compare wth aalytcal approach whch have lmtg pot. Solvg umercal teratos usg Vsual Basc s more coveet to use the smulato of umercal teratos ad s less proe to errors. Recommedato It s recommeded that a more elaborate ad extesve research be fashoed out usg Vsual Basc programmg laguage to be used the executo of a very complex terato problems whch s expected to surpass what s ths research work, due to the parallel approach method that were adopted the system, t s also recommeded that for the rug of the system that total eradcato of maual operato s ot possble ad also the user ca ot operate the system wthout pror kowledge of the maual method. Refereces Axelrod R. 997. Advacg the Art of Smulato the Socal Scece, I Rosara Cote, Raer Hegselma ad Petro Tera (eds.), Smulatg Socal Pheomea. Sprger, Berl, Germay. Cote S.A; ad Boor, C.D. 965. Elemetary Numercal Aalyss, A Algorthmc Approach. McGraw-Hll, New York, NY, USA. Edwards C.H.; ad Davd E.P.990. Calculus ad Geometry, 3 rd ed. Pretce-Hall, Eglewood Clffs, NJ, USA. Fatula, S.O. 988. Numercal Methods for Ital Value problems Ordary Dfferetal Equatos. Academc Press, pp. 78-79. Hammg R.W. 96. Numercal Methods for Scetfc ad Egeers, McGraw-Hll, New York, NY, USA. Harrso, J.R. 997. Domat Coalto Dyamcs, the Poltcs of Orgazatoal Adaptato ad Falure. Paper preseted at It. Cof.Computer Smulato ad the Soc. Sc., Cortoa, Italy. Roald J.H.; ad James, J.R. 990. Calculus wth Applcatos, D.C. Health ad Compay, Caada. Trauls, J.F. 967. Iteratve Methods for the Soluto of Equatos. Pretce-Hall, Eglewood Clffs, NJ, USA. 9