A powerful tool now available
Sometimes you need to create a function runtime. It was a big problem.
This Delphi 2.00 and 2.01 unit lets you create your own functions runtime.
Specifications
If the Input String is 'cos(1/x + 1/y)', where y is an undefined variable, the parsing process is stopped and returns the message: Unknown Variable.
If the Input String is '1/x, where x is the Complex (0,0), the parsing process is succesful, but when you Evaluate, it returns (0,0), makes true an error flag and returns the message 'Division by Zero';
Complex Functions:
+ - * / ^ | Basic operators :Complex Addition, Subtraction, Multiplication, Division, Power |
abs(z) | absolute value of complex |
re(z) | real part of complex |
im(z) | imaginary part of complex |
arg(z) | angle of complex (-p..., pi] |
sqrt(z) | square root of complex |
int(z) | integer part. (z must be real, otherwise Error is generated) |
u1(z) | step (z must be real, otherwise Error is generated) |
u2(z) | ramp(z must be real, otherwise Error is generated) |
sgn(z) | sign (z must be real, otherwise Error is generated) |
round(z) | round (z must be real, otherwise Error is generated) |
trunc(z) | trunc (z must be real, otherwise Error is generated) |
frac(z) | fractional part of (z must be real, otherwise Error is generated) |
sin(z) | Complex Sin of z |
cos(z) | Complex Cos of z |
tan(z) | Complex Tan of z |
asin(z) | Complex Inverse Sin of z (Forget the error message of real parsers; remember that asin(1.365) does exist and has an important meanng !) |
acos(z) | Complex Inverse Cos of z |
atan(z) | Complex Inverse Tan of z |
sinh(z) | Complex Hyperbolc Sin of z |
cosh(z) | Complex Hyperbolc Cos of z |
tanh(z) | Complex Hyperbolc Tan of z |
asinh(z) | Complex Inverse Hyperbolc Sin of z |
acosh(z) | Complex Inverse Hyperbolc Cos of z |
atanh(z) | Complex Inverse Hyperbolc Tan of z |
exp(z) | Complex Exp of z |
ln(z) | Complex Ln of z |
log(z) | Complex log 10 of z |
not(z) | Boolean negation of |
min(x,y) | Returns the smaller of x and y (x and y must be real, otherwise Error is generated) |
max(x,y) | Returns the bigger of x and y (x and y must be real, otherwise Error is generated) |
logx(z,b) | Returns the log in b base of (b must be real, otherwise Error is generated) |
if(condition, true_expr, false_expr) | Returns true_expr if condition is different from (0,0), otherwise returns false_expr. |
simpson(expr,a,b,m,var) | Simpson integral of expr from a to b (expr, a b, and m must be real) respect the variable var. |
pi | Returns 3.141592654 + 0.00000000*i |
i | Returns 0.000000000 + 1.00000000*i |
e | Returns 2.718281828 + 0.00000000*i |
= | Returns 1 if the arguments have the same real and imaginary parts, otherwise returns 0. |
< | Returns 1 if the first argument is smaller than the second one, otherwise returns 0. (Both arguments must be real) |
> | Returns 1 if the first argument is bigger than the second one, otherwise returns 0. (Both arguments must be real) |
>= | Returns 1 if the first argument is bigger or equal than the second one, otherwise returns 0. (Both arguments must be real) |
<= | Returns 1 if the first argument is smaller or equal than the second one, otherwise returns 0. (Both arguments must be real) |
Real Functions
+ - * / ^ | Basic operators : Addition, Subtraction, Multiplication, Division, Power |
abs(x) | absolute value of x |
sqrt(x) | square root of x |
int(x) | integer part of x |
u1(x) | step |
u2(x) | ramp |
sgn(x) | sign |
round(x) | round |
trunc(x) | trunc |
frac(x) | fractional part of x |
sin(x) | Sin of x |
cos(x) | Cos of x |
tan(x) | Tan of x |
asin(x) | Inverse Sin of x |
acos(x) | Inverse Cos of x |
atan(x) | Inverse Tan of x |
sinh(x) | Hyperbolc Sin of x |
cosh(x) | Hyperbolc Cos of x |
tanh(x) | Hyperbolc Tan of x |
asinh(x) | Inverse Hyperbolc Sin of x |
acosh(x) | Inverse Hyperbolc Cos of x |
atanh(x) | Inverse Hyperbolc Tan of x |
exp(x) | Exp of x |
ln(x) | Ln of x |
log(x) | log 10 of x |
not(x) | Boolean negation of x |
min(x,y) | Returns the smaller of x and y |
max(x,y) | Returns the bigger of x and y |
logx(z,b) | Returns the log in b base of |
if(condition, true_expr, false_expr) | Returns true_expr if condition is different from 0, otherwise returns false_expr. |
simpson(expr,a,b,m,var) | Simpson integral of expr from a to b respect the variable var. |
pi | Returns 3.141592654 |
e | Returns 2.718281828 |
= | Returns 1 if the arguments are have the same value. |
< | Returns 1 if the first argument is smaller than the second one, otherwise returns 0. |
> | Returns 1 if the first argument is bigger than the second one, otherwise returns 0. |
>= | Returns 1 if the first argument is bigger or equal than the second one, otherwise returns 0. |
<= | Returns 1 if the first argument is smaller or equal than the second one, otherwise returns 0. |
Easy to use: ... we're doing some hard work for you. You have more time for thinking in your application.
Real code fragment:
Var s : String; x, y, z : TComplex; { The Complex Type } t : Tree; { Defined also into the parse unit }
begin s := 'acos(10*5*x - 1/exp(y))'; { Don't worry, it has meaning in Complex Domain } t := CParse(s,'xy'); { You can use your OWN variables, they are NOT predefined ! }
If BAnyParseError then writeln('Wrong expression') else begin X := Complex(1.23, 1.5); { x = 1.23 + 1.5*i } Y := Complex(0.5, -0.5); { y = 0.50 - 0.5*i } Z := CmxEval(t,X,Y,Complex(0,0)); If BAnyEvalError then writeln('Evaluation - Time - Error : ', SError); .... end end
Easy, not ?
We're Beggining, so we have a gift
for you... FREE...
COMPLEX AND REAL CALCULATOR
You can order the Delphi Compiled Unit of the Real and Complex Parser.
Pricing:
For payment procedures, please drop us a mail.
This page last updated on Apri1 1, 1997.
Copyright © 1997 Diego Velez.
Microsoft Windows 95 is a registered trademark of Microsoft Corporation.
Borland Delphi is a registered trademark of Borland International, Inc.