11fi-d.. •., ~..____:_c_u_r_r,___· c ___ u _l___u _m______)

USE OF PC BASED MATHEMATICS SOFTWARE IN THE UNDERGRADUATE CURRICULUM

JOSEPH M. SLAUGHTER, JAMES N. PETERSEN, RICHARD L. ZOLLARS it had to be a general purpose package, capable of all Washington State University the calculations (solving sets oflinear and/or nonlin­ Pullman, WA 99164-2710 ear equations, iterative calculations, vector/ manipulations, , simple statistics, re­ ith the advent of the personal computer, many gression) which are typically encountered by a stu­ W software packages have been developed which dent progressing through our curriculum. For this minimize the required programming, thus allowing reason, spreadsheet programs were not included the user to concentrate on understanding the prob­ since, although many typical problems can be solved, lem rather than on debugging. This is very desirable the structure of the program is not optimal for all from an educational point of view. However, if stu­ of the calculations (solution ofODE's, sets of nonlin­ dents are required to learn the use of many different ear equations, etc.). Likewise, such packages as packages, any advantages gained by reducing pro­ Matlab 141 and GAUSS 151 , which concentrate on gramming requirements are offset by increasing the matrix manipulations, were not included. time spent learning how to use the various pack­ Second, the program had to be capable of opera­ ages. In this article we will describe the experiences tion on the PC's available in our department of one of our undergraduate students in learning 111 (IBM PC/XT or AT's, or compatibles), which are and using three such programs (MathCAD , Point also typical of those owned by the students. Thus, Five 121, TK Solver Plus 131) which we have examined many of the symbolic manipulators ( 161) for incorporation into our curriculum. were not considered. Obviously, there are more packages available than Finally, we wanted the packages to be priced the three cited above, but we sought to find a single within the grasp of a typical student so that they package which met all of the following criteria. First, might be purchased for use away from the academic setting. Of the three packages evaluated, both Joseph Slaughter is a graduate student in chemical MathCAD and TK Solver Plus are available as stu­ engineering at Washington State University. He re­ ceived a BS degree in chemical engineering and a BA dent versions for approximately $50, while Point degree in foreign languages and literatures, French, Five can be site licensed for a reasonable fee. There from Washington State University in 1989. His current are also a number of packages available with inter­ research is in the area of bioseparations using large­ scale electrophoresis. faces and structures very similar to TK Solver Plus, such as Eureka 171 and FORMULA/ONE 181 • Of this group, however, only TK Solver Plus was evaluated,

James N. Petersen is currently an associate professor Richard L. Zollars is a professor of chemical engi­ of chemical engineering at Washington State Univer­ neering at Washington State University. He received sity. He received his BS degree from Montana State his BChE (1968) from the University of Minnesota University in 1976 and his PhD from Iowa State Univer­ and his MS (1972) and PhD (1974) from the Univer­ sity in 1979. His current research interests are in the sity of Colorado. His current research interests in­ adsorption of heavy metals from aqueous streams by clude adsorption, colloidal and interfacial phenom­ biological materials, and modeling and on-line optimi­ ena, and bioseparations. zation of biological processes.

© Copyright ChE Division ASEE 1991

54 Chemical Engineering Education In this article we will describe the experiences of one of our undergraduate students in learning and using three programs (Math CAD, Point Five, and TK Solver Plus) which we have examined for incorporation into our curriculum. due to its availability in a student version and its countered, help could be found either in the user's greater power. guide or with the on-line help facility. One of the strongest characteristics for use in education is its All of the packages evaluated can be run on IBM format. Graphically created symbols are used in­ PC/XT's or compatibles with no more than 512K, stead of names, i.e., ✓ ( arg ) instead of two 5 1/4" floppy disk drives, a graphics card, and a sqrt(arg), as shown in Figure 1. Also, eighteen com­ dot matrix printer. For this evaluation we used an monly used Greek letters are available for use in the IBM PS/2 Model 50Z personal computer equipped equations and text. These symbols make it easier for with a 80287 math co-processor. Feature-by-feature the user to find errors and to create a readable comparisons of many of these software packages have report. appeared 19•111 , but this type of comparison does not indicate how easily the package can be learned and The free-format style of the problem files makes used, nor its ability to easily solve typical chemical editing quite easy, much like erasing an error on engineering problems and create a readable report a paper scratchpad. However, moving about in (such as would be required if a student used the MathCAD can become tedious in large files since the package to solve homework problems). Therefore, maximum cursor movement is either 80% of a page one of our senior chemical engineering students (J . or to the beginning or end of the current region. Slaughter) was asked to solve typical homework Moving through the file is slowed even further if problems from a number of areas (thermodynamics MathCAD is in its automatic calculation mode. This 1121 , unit operations 1!3J, reactor design 1141 , kinetics 115 1, latter problem can be overcome by switching to the and numerical analysis 1161 ) using MathCAD, TK manual calculation mode. MathCAD can also write Solver Plus, and Point Five. Each program was then and read ASCII files so that data created from other evaluated for its utility. software can be analyzed.

MATHCAD MathCAD solves simultaneous equations (linear and non-linear) using a solve block technique (see MathCAD is a free-format scientific scratchpad Figure 2). This technique is initiated by guessing a supporting 69 built-in functions and 29 symbolic op­ value for the unknown, entering the equation to be erators. It comes on two disks with a well-written solved by using a "given" command, and requesting user's guide and a MathCAD reference booklet. Af­ the solution by using a "find" command. If the con­ ter reading the first three chapters of the user's vergence criteria is not met, MathCAD will supply a guide we felt fairly confident about setting up solu­ message to that effect, and the "find" command can tions to typical problems. When difficulties were en- be replaced by a "minerr" command to find the result

1 - •.6 Ca l cula tes the Re!Jno lds nu111b er using Gue ss . .. intcr atiuc ualuc s f o t he f ann ing fr iction .

1 . 07 10 Re =-- 1 f. g i ven . 1 G ~ Fl f.'.. :. . ' n' r I ka : = find[ka] n = 3

2 3 13 "' - 1 . 001 ~------~ k = 6 .683 -10 ·sec "<------ns" 100 Re ,l e+007. Figure 1 Figu re 2

FIGURE 1. MathCAD screen showing features such as FIGURE 2. Example of Math CAD use of a solve symbol opera tors and imbedded graphics. block and units. Winter 1990 55 with the smallest error. The results obtained using the base units, checks for compatibility and gives the "minerr" are good estimates which can then be used results in the base units. The user is able to change as new guess values. to any defined unit by simply entering the desired unit. Not only does this feature provide a means of MathCAD performs iterative calculations using detecting errors, but it also makes the report much vector notation and an iteration counter (range vari­ more readable (see Figure 2). MathCAD provides able), as shown in Figure 3. Only one equation may three files (for mks, cgs, and US customary units) appear inside this iteration loop, but multiple func­ that contain most of the desired unit conversions. tions may be used. In Figure 3, for example, a user­ defined function called "gradf(s,y)" is defined by us­ Perhaps MathCAD's strongest point is the reada­ ing the built-in derivative function. Other user-de­ bility of its output, as shown in Figures 1 through 4. fined functions [H(x,y), s(x,y), and A(x,y)J are subse­ The graphical representation of operators, ability to quently defined using "gradf', and all of the func­ mix text, plots, and calculations, and the inclusion of tions are combined into a single equation which is units on the calculations makes the output appear used in the calculation. much as it would if the user were using a paper and pencil. Indeed, one does not need to know much Graphs can be created very easily in MathCAD about MathCAD in order to be able to read the out­ and can be imbedded into the report. Graphs can be put. The only noticeable idiosyncracy in the output is formatted for size, type (linear, semi-log, or log-log), the use of the symbols ":=" and "=". MathCAD re- and number of subdivisions for each axis using six different symbols with or without a connecting line. One graphing feature that we found desirable d - rcx .y> was the ability to define the x-axis with more than dx .. . gradient of f(x , y) gradf(x,y) : = d one variable (neither Point Five nor TK Solver Plus - rcx,y) were able to do this), as shown in Figure 4. MathCAD dy d also creates tables, but they were limited to fifty - gradf Cx, y ) ~ gradf (x, yl d x 0 dy 0I IIC x, y) d d .. . llcss ian fll ll tri x elements per column and it takes practice to create - gradf(x ,y) - gradf( x ,y) presentable tables. d x 1 dy 1 1 MathCAD supports a wide array of vector and s (x, y) := - [Hcx,yl- ] gradf(x, y) .. . direction uc ctor - 1 matrix operations and functions, although they are )..Cx ,y l : = - C(gradf(x, y)) 1 · sC x ,yll CC s Cx ,y)) 1 · HCx,y) s(x,y)) . .. step s ize limited in certain aspects. The largest array that we i : = 0 .. 10 were able to create using the data editor was limited to fifty elements (newer versions can create 100-ele­ X X i + 1 l ment arrays on a 10-by-10 matrix). The absolute size y y • s X ,y -),. X ,y . .. iterative calc ulations I •1 I I i I i limit for arrays created by iterations and/or equa­ Figure 3 tions, is 8000 elements. We did not feel that this was FIGURE 3. Iterative calculation in MathCAD. a significant limitation since problems larger than this would typically not appear in classroom assign­ ments. A more significant problem occurred when Bot l lno Point Dia9ra111 intermediate results in a calculation produced a Benzene and Toluene Sain . 1-by-l array-a value which should be used as a scaler. MathCAD only recognizes this value as an array so that further computations, such as the multiplication of another array by this "scaler," were temp , tenp prohibited. I I Another feature that we found to be very useful was the ability of MathCAD to use units. MathCAD uses four base units: L (length), M (mass), T (time), and Q (charge). Any of these can be redefined if nec­ 70 ~ ------' 0 Xben , Ybcn essary (we found it convenient to redefine the base i l unit for charge as a base unit for temperature). These four base units are then used to derive other units Figure 4 such as force, energy, velocity, acceleration, etc .. FIGURE 4. Example of boiling point diagram created by During calculations, MathCad converts all units into Math CAD with multiple definition of the ordinate. 56 Chemical Engineering Education quires that all variables be defined first (using the ":=" symbol) before a value can be calculated (using In an attempt to give some impression of the the "=" symbol). This arrangement requires extra individual strengths and weaknesses of these keystrokes since any computed variable must be en­ various packages, we rated them on .. . ease of tered twice: once to define the variable and once to learning, ease of use, matrix operations, equation compute the value. solving capability, versatility, use of units, generation of graphs and tables, etc. MathCAD has also recently become available in a student's version. This version contains all of the defines the rules to be used, i. e., specifies the rela­ power of the full version, but is limited to only 120 tionships between variables, and initiates user-de­ lines of output (two pages). We found this limitation fined functions. Other sheets are used to create user­ on the output file size to be very restrictive for all defined functions and algorithms, lists, tables, and but the most elementary of problems. graphs, to define unit conversions, and to format the sheets and variables. TK SOL VER PLUS Editing and moving about in TK Solver Plus was not difficult. Convenient window commands are used TK Solver Plus is a structured equation solver to move from one sheet to another, and a split screen supporting 68 built-in functions and 13 relational can be used to display two sheets at a time (see and arithmetic operators. It comes on six disks with Figure 5). Errors were marked in the status column three manuals, a well-written (and much-needed) on each sheet, along with a brief description and an reference manual, an introduction to TK Solver Plus, indication of the line on which the error appeared. and application notes. Three of the disks contain 103 models and functions which are separated into 13 The strongest attribute ofTK Solver Plus is equa­ categories ranging from finance to matrix manipula­ tion solving. Ifit cannot solve an equation directly, it tions. As with MathCAD, a student version of TK automatically goes into its interation mode. We were Solver Plus is available which contains everything able to solve twenty linear equations with twenty included in the full version with the exception of the unknowns, using two guesses, in a matter of sec­ appplication notes and three library disks. TK Solver onds. IfTK Solver Plus could not converge using the Plus is also able to read and write ASCII, DIF, and guesses provided, it would leave the last calculated WKS files. values as the new guess values, and we only had to re-initiate the solve command until convergence Of the three programs that we evaluated, we was reached. On those occasions where convergence found TK Solver Plus to be the most difficult to could not be obtained, TK Solver Plus would indicate learn. It was necessary to complete the introduction this by displaying a convergence value in a high­ manual before feeling comfortable enough to start lighted window and leaving the output column blank. working. In part, this is due to the manner in which TK Solver Plus is organized. It is divided into nine Another strong attribute was the capability of main worksheets and several subsheets, with each TK Solver Plus to let the user create functions and sheet containing only a specific type of information. algorithms. The functions and algorithms may be The variable sheet is used to enter values for the defined as rule, list, or procedural functions. Rule variables and to view the results. The rule sheet functions are those which call other functions or de­ fine equations. Procedural functions create a proce­ Cir) Ihle: 11 TH, pro11re. 11. fiad, ttae tiae •eeded tor tl1.e batch reactioa di!:, 25+/F'9 dure which the variables follow in order to obtain a ------YlRilBLE S!IEET St Input - le.Ile - 01tpat - 'hit - Co1111ent ------result (this is where understanding how to program 0 le.a 1·#' IJl.itie.l con.ver:,ion of A . 65 I Conver:tion of A Ce.a . 00298507 lbl.ol/ft" In.1t1e.l co11.centrn.tion of A in TK Solver Plus is important, and we found that Cbo . 00268657 lb1.0l/f t'"' Illi tial co11.centratioa of B 're. fun Reaction rate fanction 6 a Ju.her of :step:, 11.:,ed in 5It1PSOI reviewing the models in the library disks was help­ rate 8097.'1945 hlle ot iltecrn.l ful). List functions are used in creating tables, inter­ t111.e 24, 172521 1. in. ,111.e needed for be.tell ree.ction ------RILE SHEET S Rule polating, and displaying intermediate values during "Thi, pro11rao. Un, the tio.e needed for the bl!.tcta reactio n de,cribed in "prob. 4-17 in ELEHEITS OF' C8Et1ICAL REACTIOJ EIGIIEERIIG , f"olger(1986) NJt ~1,e, the libnry a. ad.el 5IHP501 to ,olve tke inte11ri,.l iterative calculations. •r1n11 ve.lv.es !or Cao e.nd Cbo Cao•Jao/V Cbo• Jbo/V • Solve int.e11ral of h.n f r o 11 h .o t.o lf • s in11 Si11.pson1 s rule Creating tables and graphs is done on the table c e.11 S111.p5on(t.un , le.o. X, n ; re.te ) ti11.e•J ao/ V*ra te F'i Help F'2 Cancel F'S !:dit F'9 Solve / Co111111.nds • Sheets ; Window switch and plot sheets, respectively, and were fairly easy to Figure 5 generate. The graphs and tables could each be stored FIGURE 5. Variable sheet and rule sheet from TK Solver and transferred from one file to another. The only Plus using the direct solver mode. way to print a graph, however, was to first view it Winter1990 57 and then print it using the print screen key or com­ torial was easy to follow and took only about one mand. Three types of graphs may be created: line, hour to complete. After completing the tutorial, we pie, and bar. A line graph could produce as many felt comfortable with the scratchpad and had very plots on one graph as lists entered, using fifteen dif­ little trouble creating the desired models. Point Five ferent colors (for line only plots) and as many sym­ has very nicely- organized help files for quick, on­ bols as can be created using a standard IBM key­ screen help. Like the other progTams, Point Five is board and the approximately 249 ASCII characters, able to read and write ASCII and DIF files, thus as extended by IBM (including fifteen Greek letters). permitting it to interact with other software. An example of a line graph illustrating the path Point Five consists of two windows on one split taken in the optimization problem can be found in screen (see Figure 7). The lower window is the Figure 6. Plotting two lines, each having points at scratchpad where formulas are entered and edited. different values of the independent variable (as in The upper window is where the results are scrolled. Figure 4) was quite complex using TK Solver Plus Variables can be entered and edited either directly and involved concatenating two separate lists into a on the scratch pad or by using the data editor. Using single list so that the resulting list could be plotted. the data editor makes analyzing and manipulating One feature that we felt could use some impro­ data quite easy; one simply enters a set of data, ement was the unit sheet and the unit column on the computes the results, and then enters a new set of variable sheet. TK Solver Plus does not recognize data without having to change the scratch pad. units either in an equation or while performing cal­ The two best features of Point Five are the built­ culations and so will not give a warning of incompat­ in functions and the matrix operations. The variety ible units, as MathCAD does. On a few occasions we of functions helps limit the amount of programming entered incorrect units but did not find our mistakes until aner printing the report. Newton' s Method . 4 TK Solver Plus does not contain matrix opera­ tions within its basic package, although they are . 2 provided on the library disks or by creating your own algorithms. This is due to the algorithms TK -. 2 Solver Plus uses when solving sets of equations which do not rely on matrix operations. In those situations ~ -. 4 where matrix operations were desired, we found that -. 6 the calculations could be performed, but were gener­ - . 8 ally more trouble than they were worth. - 1 Printed output from TK Solver Plus is obtained - 1. 2-1--- -~--~--~ -~--~-----r- by separately printing each sheet, graph, and/or table. 1 1. 2 1. 4 1. 6 1.8 2 2. 2 We found these reports difficult to read and follow, X1 especially for the beginner or non-user. Comment statements, as shown on Figure 5, did help the read­ Figure 6 ability, but the reader must be familiar with TK FIGURE 6. Line graph created by TK Solver Plus for Solver Plus to understand and follow the report as a optimization problem. whole.

0'10--• • rov:, (n xi ), 11.at e ta ble (plot , A). addto table(plot. ,x1, x2) POINT FIVE 0'11 --plot

11 1 2 Point Five is a mathematical scratchpad contain­ 1. 00 o. 00 1. 33 -a. so 1 . 67 - 0 . 86 ing over 150 built-in functions divided into six cate­ 1 . 98 - 1 , 06 2 . 00 - 1.00 2 gories: arithmetic, statistics, finance, matrix opera­ ---,-- - ...-,~~0Edaca t i ~ !~~OI~ OJllY at. W11.:,kb11to n. Stat e 'D'lliv . --- 001 \ Pertonbg a 11.11.ual iteration tecl•iq1e tor tiadiag a 11111111.u, ulag 002 \ Jevt.o Jl ' :, • et,od . tions, data transformation, and procedure functions. 003 \ Exaaple 6 . 5 aiailllr:.e : t(xi, :r: 2 )•(:r:1-2)A oJ+ ( :r:1 - 2 )'"'2 *x2"2+( x2•1 )"2 0 0'1 1 • 0 This wide range of functions indicates that it is 0 05 zi[i]•i, x2{1J•O :1 a 1tial val ae:, t o r xi ud :z2 006 0 0? ; Calc •la te t he Put.ial derivat i ve~ to t ind. U. e ;re.d.ient. meant to be used by both engineering and non-engi­ 008 0 09 1•1+1 neering students alike. Point Five comes with one 010 ii rad( i] .4,it ( xi( i] -2 ) 111 3+2'f: x2( i] "2 'C' { xi[ i ] -2) systems disk (or can be installed with two master xe65 Hem ; '.1 5 1/ '.1 51 Replac e lu P11.d Cap ~--O f'f' l>i~p--0 1 Ca lc--01 Prn t.-Orf' disks), a well-written user's guide, an introductory Figure 7 FIGURE 7. Screen from Point Five illustrating an tutorial manual, and a quick reference card. The tu- interative calculation. 58 Chemical Engineering Education required to create various models, which makes Readable reports could be made in Point Five working with Point Five easier for the beginner. We with the use of comment statements. Turning the found the matrix functions to be the best of the three DISPLAY function off permits only comment state­ software packages that we evaluated. We were able ments, blank lines in a model, and results to be to enter an 89-by-89 matrix with the data editor, printed. Turning DISPLAY on prints each line exe­ invert it, and then check the results by multiplying cuted. When using a marked block to perform itera­ the inverted matrix by the original matrix, all on one tive calculations, with DISPLAY on, long reports line. The results were quite accurate. may be generated as each result computed during every iteration is displayed. We were able to avoid We were also able to solve simultaneous linear this problem by entering each line once to obtain a equations, such as the optimization problem, by us­ printout of the procedure and then executing the ing an augmented matrix and one function, block, but this was only working around a weakness SIMEQ(var. ). Graphs and tables are quickly and in Point Five. Unlike either MathCAD or TK Solver easily created in Point Five. The graphing abilities Plus, Point Five has no capability for working with are limited, however, to only scatter plots, line graphs, units. and bar graphs. Line graphs are limited to six lines, and the graphics are only CGA resolution (see Fig­ ure 8). Also, plots cannot be stored in separate files DISCUSSION AND CONCLUSION and can only be printed by doing a screen print. Of the five example problems we selected, both Unlike TK Solver Plus and MathCAD, Point Five MathCAD and TK Solver Plus were able to solve all is not an equation solver; it is more like a powerful five. Point Five was able to solve four of the five, but programmable calculator. This difference is particu­ could not solve the friction factor problem due to the larly noticeable in that Point Five requires that all implicit equation used. TK Solver Plus appeared to equations be in their explicit form. For example, we be the fastest of the three packages, although all were not able to solve for the Fanning friction, f, in were rapid enough for the example problems so as the equation not to be an inconvenience. 1 4.07 -log(NRe · 0.6 /.Jr = .Jr)- Comparing the three packages is very difficult used in Figure 1 since it could not be reduced to an since they are completely different, not only in struc­ explicit form. ture but in emphasis of capabilities. Keeping in mind that these programs were evaluated for use in an Iterative calculations are performed in two ways: engineering curriculum, we found Point Five to be a by line, using a "FOR. .. DO ... " statement, or in a very useful tool for performing quick, on-the-spot marked block by using the EXECUTE N TIMES calculations and data manipulations. Its library of command. Point Five limits the use of marked blocks functions was impressive and very useful for creat­ to one per file, thus limiting the use of the EXE­ ing educational models and statistical and financial CUTE command. analysis. It was very easy to use and a good tool for those who have little experience with personal com­ Newtons Method of Optimization puters, but the limitations encountered for non-lin­ 0.3 ear equation solving reduced its utility. 0.0 TK Solver Plus is a very powerful equation solver with the capability of a programming language. It is N -0.3 >< probably the most powerful of the three programs, -0 .6 but is also the hardest to learn. For quick, on-the­ spot calculations (especially matrix operations) it is -0.9 almost not worth the trouble. However, once the user becomes familiar with TK Solver Plus, its abili­ 1.2 1.5 1.8 2 .1 2.4 ties are practically unlimited. Its rigid structure xl makes learning the program somewhat easier, but it also makes printed reports hard to read. Figure 8 We found that we preferred going to MathCAD FIGURE 8. Line graph created by Point Five for optimiza­ when attempting to solve a problem because of tion problem. MathCAD's versatility, its ease of use, and the read- Winter1990 59 Rock Street, Rockford, IL 61101 4. Matlab, The Math Works, Inc., 20 N. Main Street, Suj te 250, Sherborn, MA 01 770 5. GAUSS, Aptech Systems, Inc., 26250196th Place SE, Kent,

DoCU'TlenUH ,on Point Five WA98042 Ease of Learn,ng 6. Macsyma, Symbolics Inc., 8 New England Executive Park TK:SolvC!r • East, Burlington, MA 01803 , ...... lt ~~ 7. Eureka, Borland International, 4585 Scotts Valley Drive, Ma t hCA('I - Scotts Valley, CA 95066 Vt?rsat, 1, ty 8. FORMULNONE, Soft-Sense, 12 Rockaway Lane, Arlington, use of un, t s MA 02174 GraphS 9. Shacham, M ., and M.B. Cutlip, Chem. Eng. Ed., 22(1), 18 Taoies (1988) A