Loading

Everything HP200LX: Knowledge, Products, Service 

COLUMN: Programmer's CornerEd reviews DERIVE, a 95LX program that solves symbolic mathematics, from algebra to calculus, as well performing numeric functions and plotting 2D and 3D graphs.By Ed KeefeDERIVE: A Mathematical Assistant for your HP 95LXIn 1982, Microsoft licensed and sold a program called muMath for the new IBMPC. The program did something amazing for its day. It solved math problems, symbolically, on a microcomputer. Eventually, Microsoft stopped selling muMATH and released it back to its authors at Soft Warehouse. Since then, the program has been entirely rewritten, and renamed Derive: A Mathematical Assistant for your Personal Computer. Now, with Derive available for the HP 95LX, it is possible to put 2,000 years of math in the palm of your hand. DERIVE on the HP 95LX The HP 95LX version of Derive comes preinstalled on a ROM card. The card contains all the relevant files from the desktop version of the program. The card also contains two other programs: RAMCRAM which squeezes as much working memory out of the 95LX as possible and FORWARD.COM which lets Derive print on a parallel printer through the serial port of the 95LX, via a desk top computer. Derive does not run from ROM. It still must be loaded into RAM (System Memory) before it runs. To get the program up and running requires at least 234K bytes of working memory. Any extra memory is used to hold data and intermediate results. Derive is strictly a DOS application and, as such, will not pop up over any other program. As a matter of fact, when it's running, Derive takes over the entire computer. The Look and Feel of Lotus Derive uses a Lotuslike menu to perform its operations. However, Derive's menu system is just enough different to make using it slightly bothersome at first. For one thing, Derive's menu is at the bottom of the screen rather than at the top. Also, the menu is always active. In addition, pressing tab key as well as the space bar will move the highlighter from one menu option to another. Like 123, you can also press capitalized letters to pick menu items. Pressing the right and left arrow keys doesn't change menu items as it does in Lotus. Rather, the right and left arrow keys make different parts of a math expression appear in inverse video. If there are no math expressions in the display and you press the arrow keys to choose a menu item, nothing will appear to happen. This different way of using the arrow keys takes some getting used to. There is one other feature of Derive that takes some getting used to as well. For instance, there is no easy way to edit an incorrect entry. In 123 you can press (F2) (Edit key) and change a cell's contents. With Derive, to correct an entry, you use the arrow keys to highlight part of a math expression. Then you must choose the Manage/ Substitute menuoption, and enter the correction. Derive then makes a copy of the expression on a separate line. If you have several corrections to make, you wind up with multiple copies of the formula, each one slightly more correct than the previous one. DERIVE Does Arithmetic Derive not only does "symbolic math," it also crunches numbers and how! For example, if you ask Derive to "simplify" the factorial of 100 (i.e. 1*2*3*...*100) the program will quickly respond with the complete answer: 9332621544394415268169923885626670049071596826438162146859296389 5217599993229915608941463976156518286253697920827223758251185210 916864000000000000000000000000 If you use the Derive function PMT(10%/12, 2*12, 1200) to compute the monthly payment on a two year loan for $1200 at 10% APR, you can have Derive give you an approximate or exact answer. If you tell Derive to show an approximate answer, you'll get 55.3739. However, if you tell Derive to "solve" the problem, you'll get a horrendous ratio: 97017233784872162402203715694511008214~0348256092810 17520386581481318268762179694511008214~034825609281 By default, Derive shows decimal quantities in a ratio format. This is a more accurate representation since it contains no rounding errors. Derive achieves this remarkable accuracy without a math coprocessor. DERIVE Does Algebra To get a better idea of how quickly, or slowly Derive does symbolic algebra, I chose the classic, compound interest formula: v*(1+i)^n+p*(1+i*t)*((1+i)^n1)/i+ f=0 where v is the present value, p is the fixed payment, n is the number of periods, i is the periodic interest rate, and f is the future value. (By default, Derive uses single letters to represent variables. If you wish, you can change this to use more meaningful names for variables.) Having keyed in the formula, I told Derive to solve for each variable in terms of the others. Here are the results: n=LN((p*(i*t+1)f*i)/(v*i+p*(i*t+1)))/LN(i+1) t=((v*i+p)*(i+1)^n+f*ip)/(i*p*(1(i+1)^n)) p=i*(v*(i+1)^n+f)/((1(i+1)^n)*(i*t+1))(i*(v+p*t)+p) *(i+1)^n+i*(fp*t)p=0 (Timings for each solution: n : 13 seconds: t : 7 seconds: p : 7 seconds: i : 184 sec. (3+ minutes). To see if Derive could handle a function made up of other functions, I declared the following two functions: FX(x):=x^2+x+1 FY(y):=y^33*y+6 I put the two functions together in one function, FXY(a,b):=FX(a)+FY(b). (I could have used x and y instead of a and b, but I wanted to see if I could confuse the program.) Then I entered the expression FXY(3,2) and told Derive to "Simplify" it. The correct answer, 21, appeared in less than a second. Next, I keyed in the expression FXY(r,s) and told Derive to Simplify that. The solution, r^2+r+s^33*s+7, appeared a couple of seconds later. Finally, I told Derive to solve this expression for "r". After 14 seconds here's what appeared: r = ((3*(4*s9)4*s^3)+1) / 2 Programming in DERIVE The ability to create functions that use other functions is the tipoff that Derive contains the rudiments of a programming language. (A good description of a C program is "functions using other functions.") Derive contains two special functions, ITERATES and IF(). These functions, along with a complete set of logical and relational operators, make up Derive's small programming language. To create a Derive program, you just build a set of related functions and save them in a file. It is possible to write programs in Derive. However, programming in Derive is not easy, and it's likely that everyone but diehard enthusiasts will find it next to impossible to master this feature of Derive. DERIVE Does Pascal? If Derive is difficult to program, perhaps it could be used to help write programs in a standard computer language. One of the menu options hints that Derive will save a set of functions as a Pascal file. To check this out, I chose the compound interest formulas, derived above, and saved them as a Pascal file. I expected to get a Pascal program that could be tweaked, compiled and run. Not so. Instead of a Pascal program, here's what appeared in the file. v*POW(1+i,n)+p*(1+i*t)*(POW(1+i,n)1)/i+f=0 n=LN((p*(i*t+1)f*i)/(v*i+p*(i*t+1)))/LN(i+1) t=((v*i+p)*POW(i+1,n)+f*ip)/(i*p*(1POW(i+1,n))) p=i*(v*POW(i+1,n)+f)/((1POW(i+1,n))*(i*t+1))(i* (v+p*t)+p)*POW(i+1,n)+i*(fp*t)p=0 Other than substituting Pascal's POW() function for Derive's "^" operator, very little coding was done by Derive. Saving the same file as a BASIC and a Fortran file produced comparable results. In short, Derive might be useful for converting extremely complex math formulae to Pascal code. DERIVE Does Calculus! If you're up to speed in Calculus, you can probably write down the solution to the following formula in a couple of seconds. (sum) x/a^2 + b^2X^4 dx With Derive, the solution is available at the push of a few keys. Just choose Calculus Integrate from the menu and enter the expression. When the integral appears, tell the program to simplify it. A couple of seconds later the answer will appear: ATAN(b*x^2/a)/2*a*b. Now tell Derive to find the indefinite integral of x/(a^3+b^3* x^5) with respect to x. Once the process is started, you can go get a cup of coffee and read a chapter from the Derive User's Manual. Come back 8 minutes later to pick up the answer. The complete solution takes 25 lines to print. We won't do that here. Derive makes no claim at being fast, just accurate! A Nuisance Sometimes, as in the case of the 8 minute solution above, an expression will extend beyond the right side of the screen. At that point it becomes a real nuisance to try and see the missing information. You can use the arrow keys to highlight parts of the equation and slowly display what you're missing. To speed up the viewing process, you can switch the screen from graphics mode to text mode. The display won't look as neat, but it will give you access to the full 80 column screen. Occasionally, even that won't help. The only recourse is to save the formula in a file and use an editor, and your knowledge of algebra, to write out the complex expression. Beyond Calculus Derive goes beyond calculus to give you a jump start at solving first and second order differential equations. Some solutions can be done exactly, while other solutions may be approximated through the use of other functions and series. Derive comes with several "utility files" which contain addin functions that extend the capabilities of the program. The functions include Bessel, Elliptic, Gamma, Fresnel, Legendre, Hypergeometric, Hermite, and Zeta. DERIVE Does Graphics Without a doubt, the most fascinating part of Derive is its ability to produce graphs of extremely complex functions. Not to take away from Derive's ability to plot 2D graphs, but rather to show the power of HP CALC's Solve function, I took all 18 functions from Derive's PLOT2D.MTH demo file and imported them into Solve. Solve was able to plot 12 of the 18 functions immediately. The other six contained hyperbolic and unsupported trig functions. Converting COSH, SINH, etc. to their exponential equivalents allowed Solve to plot those expressions as well. Furthermore, Solve has a much better interface when working with these types of graphs than does Derive. Derive, however, is the only program that can produce 3D plots on the HP 95LX. For example, the following graph was produced using the function BESSEL_Y_ASYMP(n,z):= SQRT(2/(pi*z)) *SIN(z(n+1/2) * pi/2). This is the ninth function in the BESSEL.MTH file. The Grids were set for 15 rows along the x and y axes. The graph was Centered at x=5 and y=0 and the Length settings were x=5 and y=10. It took about one and a half minutes to load the file and pick the function, another minute to set the plot parameters and approximately 3 minutes to produce the graph. Who is DERIVE For? If you're the kind of person who keeps threatening to relearn all the math you've forgotten over the past decade, then Derive will serve as a great learning aid. Derive seems to be used most widely as an educational tool. Several books have been written to support Derive. They all have a classroom setting in mind. The best of these books is Exploring Math from Algebra to Calculus with Derive, by Jerry Glynn, MathWare, 604 East Mumford, IL, 61801. (Jerry also runs an electronic bulletin board for Derive users.) If you're an engineer or physicist who wants math functions in a palmtop format, then Derive may meet 80% of your needs. Finally, if you're a programmer who does technical programming and want a way to check your algorithms for accuracy, then Derive will more than do the job. If you're looking for C code that will let you have the numeric accuracy of Derive, without the learning curve of a new program, let me recommend BCALC. BCALC (ON DISK ICON) is a calculator program that gives accuracy of up to 1075 digits without recourse to a math coprocessor. Its best feature is that it comes with complete source code for all its math routines. BCALC is available in the BPROGB forum on CompuServe. If you have an HP 48SX calculator, hang on to it. Although the 48SX and Derive share many of the same capabilities, each has unique, positive qualities. I like the 48SX for its dedicated keyboard and Derive for its compact size and accuracy. Please don't ask me to choose one over the other. Until next time, Happy Programming. 

Copyright © 2010 Thaddeus Computing Inc