Comparing the Parsers:

I felt it would be helpful to compare the parsers directly. The first section shows a comparison of calculation times. The following sections show the various functions that are available for each of the parsers. The last section gives my own thoughts of the usefulness of each parser.

Note that all comparisons were done using RB 4.1. RBScript, especially, will be different for each version of RB.

Time Comparisons

I compared how long it took each of the parsers to calculate two different equations.

The first equation was a*b, where I calculated how long it took to do just one calculation (a=2.5, b=3.7), and how long it took to do 100 different calculations (a was increased by .5 and b was increased by .1 for each calculation).

The second equation only has one variable in it: a. For the single calculation a=1, and for the 100 calculations, a was increased by 1 each time.

Times are in microseconds

 a*b e-a/50+cos(a*Pi/25) one 100 one 100 EquationEvaluator (plug-in) 640 39000 640 40000 Expression Evaluator (class) 700 63000 2350 230000 Equation Compiler (plug-in) 43 100 90** 190** Eval (class) 690 24200 2110 26200 Evil/Eval (plug-in) 640 24100 * * RB Script 3100 6800 3850 7000

* EvilEval has a limited set of functions and was not able to do this calculation

** These results may be misleading for Equation Compiler. It is set up to accept x as the independent variable and a as a coefficient. If this calculation had been made only changing x instead of resetting a for each of the 100 tries, I'm sure it would have been faster.

Top

Funtions in Each Parser

 EquationEvaluator +, -, *, /, ^,% sin(), cos(), tan() asin(), acos(), atan() sinh(), cosh(), tanh() exp(), log(), log10() sqrt(), floor(), ceil() abs(), hypot() deg() to convert to degrees rad() to convert to radians pi = pi (~3.1415) e = e (~2.7182) Expression Evaluator +, _, *, /, %, \, ^ abs, acos, asin, atan ceil, cos, deg, exp, floor, log, max, min, pi pow, rad, rnd, round, sin sqrt, tan Equation Compiler +, -, *, /, ^ sin(x), cos(x), tan(x) asin(x), acos(x), atan(x) ln(x), log(x), log2(x) exp(x) - natural exponent (e^x) exp10(x) - common exponent (10^x) exp2(x) - binary exponent (2^x) sinh(x), cosh(x), tanh(x) asinh(x), acosh(x), atanh(x) theta(x) - {0 if x<0, .5 if x=0, 1 if x>0} sqrt(x) - square root sqr(x) - x^2 abs(x) - {x if x>=0, -x if x<0} sign(x) - {+1 if x>0, 0 if x=0, -1 if x<0} step(x,y) - {0 if x=y} box(x,y,z) - {1 if x<=y<=z, 0 if x>y or y>z} pi - Pi Eval +, -, *, / Sin, Cos, Tan ASin, ACos, ATan Sinh, Cosh, Tanh ASinh, ACosh, ATanh Log, Exp, Sqrt Evil/Eval +, -, * / - division, double precision // - division, single precision Sin, Cos, Tan Log, Sqrt RB Script Check with RB for details

Top

My Thoughts

Scientific Notation
None of these parsers can handle scientific notation (like 3e-2, which is .02), except for Equation Compiler. With all the rest you need to convert to some other notation, like 3*10^-2. With Eval and EvilEval it is tougher, since they can't handle ^ (meaning "to the power of"). Usually this is not critical, but it is something to keep in mind.

Cross Platform Compatibility
I think only Equation Compiler and Expression Evaluator are cross-platform (PPC/Carbon/Windows) compatible. EquationEvaluator is both PPC and Carbon compatible. Evil/Eval is PPC only. Eval seems to work under OS X and classic, I do not know if it will work with Windows.

Speed
Clearly Equation Compiler is the big winner, with speeds that are an order of magnitude faster than all the other plugins and classes. RBScript is an order of magnitude slower than everything else when only doing one calculation. But it is much faster than everything (except Equation Compiler) when doing the 100 step loop. Of the remaining plugins and classes, it looks like EquationEvaluator returns an answer in about the same amount of time regardless of how complicated the equation is. The other two both took somewhat longer for the more complicated equation.

Other Issues
EquationEvaluator works by passing a single string to the plugin, and recieving a double for an answer. This has been handy with my cgi because I can just save the string somewhere and send it to the plugin when I need it. If you are trying to calculate equations with the other classes/plugins, you usually need to set the coefficients/variables separately, and then parse the equation to get the answer. This may involve several more lines of code, but it is not usually slower than the one line needed in EquationEvaluator. And this can be very handy when you want to generate a listing of answers, possibly for plotting. In the end, you should pick whichever way fits into your program better.

But Why Not Just Use Equation Compiler?
It is the fastest by far, and it is Windows, classic, and OS X compatible. What's not to love? Only one thing - you can't name your variables whatever you want. Equations can have up to 5 coefficients, lettered a through e, and then one independent variable, which is x. This can be very unhandy if you need to calculate something like V=I*R. You can use the coeffecients like they are variables, but you have to remember to convert your I into an a, and your R into a b before you do the calculation. This is most unhandy.

The Bottom Line
The bottom line is if you can always be sure you can write your equations in the form that Equation Compiler can read, then use it by all means. It is the fastest way. If you can't, then use one of the other plugins/classes. I think Eval and EvilEval make it a little harder with their limited set of functions (mostly the ^ that is missing). Expression Evaluator is cross-platform but a little slower than EquationEvaluator, other than that they seem roughly equal. RBScript is probably a good choice if you have a lot of calculations to do and you can put them all (via a loop or something) in the script at compile time. It does not seem like a good choice if you only have an equation to calculate once, because you loose a lot of time during the compiling process. I find RBScript sort of a pain to use - the other plug-ins and classes all have easier methods for setting the variables and the equation you are trying to evaluate. EquationEvaluator is probably the easiest to use, as it involves just passing one string to the plug-in. In the end which method you use will depend on how you plan to use it and what you plan to do with it. I think they all have their merits.

Top

Back to RB Math Stuff