Equation Compiler Plugin 
Author Message
 Equation Compiler Plugin

Some years ago I purchased a non-commercial license for Kevin Raner's
Equation Compiler for the PowerPC microprocessor. While an application
is running his compiled C source software can parse a user entered text
string containing an equation (or, more properly, a function) and
compile it into PPC machine code and store it into a Handle. A function
pointer can then be used by the program in the same way as for any
other function installed at application compile time. This will be much
faster than having to interpret the equation every time it is used.

I have succeeded in compiling Equation Compiler Plugin for REALbasic.
This plugin brings most of the functionality of Equation Compiler to a
REALbasic programmer.

Kevin has graciously allowed me to distribute my plugin provided that
i) the source code is not disclosed and that ii) the plugin is not used
commercially. He also says: "If a third party did want to use your
plugin commercially I would give my permission if the third party
purchased a commercial license for my portion of the intellectual

http://www.*-*-*.com/
Compiler on his site.

The API for the plugin consists of three REALbasic functions or
subroutines. They are:

compile theEquation.text
Here "theEquation" is the name of a REALbasic EditField  where a user
would enter an equation. Of course, the programmer could use any other
name than "theEquation". If there is an error a REALbasic message box
will appear with information about the error.

setCoeffs a, b, c, d, e
The arguments are REALbasic doubles. The plugin uses these arguments to
update a coeff[ ] array for Equation Compiler. The user can use none,
any, or all of these coefficients in the entered equation. The
programmer should provide a means for providing values for these
coefficients, if used, before passing them to the plugin by this
subroutine.

evaluate(x)
is a function which evaluates the compiled equation using the REALbasic
double x (or any other name) as argument, and returns the REALbasic
double value. The entered equation always uses x as the independent
variable.

Equations are to be input in C format. In addition to explicit numbers,
any combination of the following can be used in the equation text:

The symbols for the allowed arithmetic operators are:

+  addition
-  subtraction, unary minus
*  multiplication
/  division
^  exponentiation

  PowerPC functions
sin(x)        sine  
cos(x)        cosine
tan(x)        tangent
asin(x)       arcsine
acos(x)       arccosine
atan(x)       arctangent
ln(x)         natural logarithm (base e)
log(x)        common logarithm (base 10)
log2(x)       binary logarithm (base 2)
exp(x)        natural exponent (e^x)
exp10(x)      common exponent (10^x)
exp2(x)       binary exponent (2^x)
sinh(x)       hyperbolic sine
cosh(x)       hyperbolic cosine
tanh(x)       hyperbolic tangent
asinh(x)      arc hyperbolic sine
acosh(x)      arc hyperbolic cosine
atanh(x)      arc hyperbolic tangent
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, 1 if x>=y}
box(x,y,z)    {1 if x<=y<=z, 0 if x>y or y>z}
? or pi       Pi

For example, here is a possible function:
x*tan(x)-sqrt(b*b-x*x)

I can add additional functions if users request them.

Applications using my plugin (a so-called fat plugin) can run in the
classic Mac OS 8.x to 9.x environment or as a Carbon application which
also can run under Mac OS X. It's the programmers choice as to what
environments to support.

You can download my plugin and supporting files from my web site:
http://www.*-*-*.com/

I've included the REALbasic project "Newton's Method.rb" which shows
how to use my plugin. It compiles "Newton's Method". Open "Newton's
Method desc.txt" which describes its use.

Bob Delaney



Tue, 25 May 2004 13:27:15 GMT  
 Equation Compiler Plugin

Quote:

> Some years ago I purchased a non-commercial license for Kevin Raner's
> Equation Compiler for the PowerPC microprocessor.

Why to use it instead of RBScript?

Mfg
Christian

--
If Microsoft owned OS X, they woulda shipped it looong ago

http://www.christians-software.de (Free Mac/Win software)



Wed, 26 May 2004 09:10:12 GMT  
 Equation Compiler Plugin

Quote:


> > Some years ago I purchased a non-commercial license for Kevin Raner's
> > Equation Compiler for the PowerPC microprocessor.

> Why to use it instead of RBScript?

> Mfg
> Christian

Joseph J. Strout has told me that RBScript was interpreted in RB 3.5
and is compiled in RB 4.0. So my plugin may not have a speed advantage.
It is easy to use.

Bob



Wed, 26 May 2004 10:03:15 GMT  
 Equation Compiler Plugin

Quote:

> > Why to use it instead of RBScript?

> Joseph J. Strout has told me that RBScript was interpreted in RB 3.5
> and is compiled in RB 4.0. So my plugin may not have a speed advantage.
> It is easy to use.

Anyway, more options are generally better!

Cheers,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Wed, 26 May 2004 13:17:32 GMT  
 Equation Compiler Plugin

Quote:


> > Some years ago I purchased a non-commercial license for Kevin Raner's
> > Equation Compiler for the PowerPC microprocessor.

> Why to use it instead of RBScript?

Well, for one thing, MPCalc can handle numbers with up to 30,000 decimal
digits, and numbers whose absolute values lie between 1e-167100000 and
1e+167100000. Let's see RBScript do that. m.

--

      *** REALbasic: The Definitive Guide! 2nd edition! ***
http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt



Fri, 28 May 2004 02:11:23 GMT  
 Equation Compiler Plugin

Quote:

> Well, for one thing, MPCalc can handle numbers with up to 30,000 decimal
> digits, and numbers whose absolute values lie between 1e-167100000 and
> 1e+167100000. Let's see RBScript do that. m.

Okay. But I don't need that for me and MPCalc is not the Equation
Compiler!

Mfg
Christian

--
NO RISC - NO FUN! THINK DIFFERENT!
http://www.christians-software.de (Free Mac/Win software)



Fri, 28 May 2004 02:37:39 GMT  
 Equation Compiler Plugin

Quote:


> > Well, for one thing, MPCalc can handle numbers with up to 30,000 decimal
> > digits, and numbers whose absolute values lie between 1e-167100000 and
> > 1e+167100000. Let's see RBScript do that. m.

> Okay. But I don't need that for me and MPCalc is not the Equation
> Compiler!

Yes, I see. It is *an* equation compiler, though. Too many
equation-compiling choices here. :-) m.

--

      *** REALbasic: The Definitive Guide! 2nd edition! ***
http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt



Fri, 28 May 2004 05:35:54 GMT  
 Equation Compiler Plugin

Quote:


> > Well, for one thing, MPCalc can handle numbers with up to 30,000 decimal
> > digits, and numbers whose absolute values lie between 1e-167100000 and
> > 1e+167100000. Let's see RBScript do that. m.

> Okay. But I don't need that for me and MPCalc is not the Equation
> Compiler!

> Mfg
> Christian

Right! I've been busy and have released two plugins recently, MPCalc
and Equation Compiler. They are unrelated.

Bob



Fri, 28 May 2004 11:46:15 GMT  
 Equation Compiler Plugin

Quote:




> > > Well, for one thing, MPCalc can handle numbers with up to 30,000 decimal
> > > digits, and numbers whose absolute values lie between 1e-167100000 and
> > > 1e+167100000. Let's see RBScript do that. m.

> > Okay. But I don't need that for me and MPCalc is not the Equation
> > Compiler!

> > Mfg
> > Christian

> Right! I've been busy and have released two plugins recently, MPCalc
> and Equation Compiler. They are unrelated.

They're not unrelated; you made them both, so they're siblings! And it's
the family resemblance that confused me. :-)) m.

--

      *** REALbasic: The Definitive Guide! 2nd edition! ***
http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt



Fri, 28 May 2004 14:43:06 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Vim compiler plugin for Ruby

2. netscape.plugin.Plugin?!

3. Equation evaluator

4. Pell Equation (was: Continued Fractions.)

5. APL or J Solutions of Complex Partial Differential Equations

6. cubic equation in J

7. Deriving Equation out of a set of numbers

8. numerical equation solver

9. Equations solution

10. OLE in VisualWorks (HotDraw, Equation Editor)

11. Q: Differential Equations ?

12. Help Needed with equations in Reports

 

 
Powered by phpBB® Forum Software