1 |
.\" RCSid "$Id: ev.1,v 1.3 2004/01/01 19:31:44 greg Exp $" |
2 |
.TH EV 1 10/28/96 RADIANCE |
3 |
.SH NAME |
4 |
ev - evaluate expressions |
5 |
.SH SYNOPSIS |
6 |
.B ev 'expr' .. |
7 |
.SH DESCRIPTION |
8 |
.I Ev |
9 |
evaluates expressions given on the command line, and sends the |
10 |
results to the standard output, one per line. |
11 |
An expression contains real numbers, function calls, |
12 |
and the following operators: |
13 |
.PP |
14 |
+ - * / ^ |
15 |
.PP |
16 |
Operators are evaluated left to right, except '^', |
17 |
which is right associative. |
18 |
Powers have the highest precedence; multiplication and |
19 |
division are evaluated before addition and subtraction. |
20 |
Expressions can be grouped with parentheses. |
21 |
All values are double precision real. |
22 |
.PP |
23 |
The following library of functions is available: |
24 |
.TP 10n |
25 |
.BR "if(cond, then, else)" |
26 |
if cond is greater than zero, |
27 |
then is evaluated, otherwise else is evaluated. |
28 |
.TP |
29 |
.BR "select(N, a1, a2, ..)" |
30 |
return aN (N is rounded to the nearest integer). |
31 |
If |
32 |
.I N |
33 |
is zero, the number of available arguments is returned. |
34 |
.TP |
35 |
.BR "rand(x)" |
36 |
compute a random number between 0 and 1 based on x. |
37 |
.TP |
38 |
.BR "floor(x)" |
39 |
return largest integer not greater than x. |
40 |
.TP |
41 |
.BR "ceil(x)" |
42 |
return smallest integer not less than x. |
43 |
.TP |
44 |
.BR "sqrt(x)" |
45 |
return square root of x. |
46 |
.TP |
47 |
.BR "exp(x)" |
48 |
compute e to the power of x (e approx = 2.718281828). |
49 |
.TP |
50 |
.BR "log(x)" |
51 |
compute the logarithm of x to the base e. |
52 |
.TP |
53 |
.BR "log10(x)" |
54 |
compute the logarithm of x to the base 10. |
55 |
.TP |
56 |
.BR "sin(x), cos(x), tan(x)" |
57 |
trigonometric functions. |
58 |
.TP |
59 |
.BR "asin(x), acos(x), atan(x)" |
60 |
inverse trigonometric functions. |
61 |
.TP |
62 |
.BR "atan2(y, x)" |
63 |
inverse tangent of y/x (range \-pi to pi). |
64 |
.SH EXAMPLE |
65 |
To pass the square root of two and the sine of .5 to a program: |
66 |
.IP "" .2i |
67 |
program `ev 'sqrt(2)' 'sin(.5)'` |
68 |
.SH AUTHOR |
69 |
Greg Ward |
70 |
.SH "SEE ALSO" |
71 |
icalc(1), rcalc(1) |