Sponsored links: Algebra eBooks ### The Maxima on-line user's manual

Algebra Calculator

#### Search: #### Ev

Function: ev (<expr>, <arg_1>, ..., <arg_n>) Evaluates the expression <expr> in the environment specified by the arguments <arg_1>, ..., <arg_n>. The arguments are switches (Boolean flags), assignments, equations, and functions. `ev` returns the result (another expression) of the evaluation.

The evaluation is carried out in steps, as follows.

1. First the environment is set up by scanning the arguments which may be any or all of the following.

* `simp` causes <expr> to be simplified regardless of the setting of the switch `simp` which inhibits simplification if `false`.

* `noeval` supresses the evaluation phase of `ev` (see step (4) below). This is useful in conjunction with the other switches and in causing <expr> to be resimplified without being reevaluated.

* `nouns` causes the evaluation of noun forms (typically unevaluated functions such as integrate or diff) in <expr>.

* `expand` causes expansion.

* `expand (<m>, <n>)` causes expansion, setting the values of `maxposex` and `maxnegex` to <m> and <n> respectively.

* `detout` causes any matrix inverses computed in <expr> to have their determinant kept outside of the inverse rather than dividing through each element.

* `diff` causes all differentiations indicated in <expr> to be performed.

* `derivlist (<x>, <y>, <z>, ...)` causes only differentiations with respect to the indicated variables.

* `risch` causes integrals in <expr> to be evaluated using the Risch algorithm. See `risch`. The standard integration routine is invoked when using the special symbol `nouns`.

* `float` causes non-integral rational numbers to be converted to floating point.

* `numer` causes some mathematical functions (including exponentiation) with numerical arguments to be evaluated in floating point. It causes variables in <expr> which have been given numervals to be replaced by their values. It also sets the `float` switch on.

* `pred` causes predicates (expressions which evaluate to `true` or `false`) to be evaluated.

* `eval` causes an extra post-evaluation of <expr> to occur. (See step (5) below.) `eval` may occur multiple times. For each instance of `eval`, the expression is evaluated again.

* `A` where `A` is an atom declared to be an evaluation flag (see `evflag`) causes `A` to be bound to `true` during the evaluation of <expr>.

* `V: expression` (or alternately `V=expression`) causes `V` to be bound to the value of `expression` during the evaluation of <expr>. Note that if `V` is a Maxima option, then `expression` is used for its value during the evaluation of <expr>. If more than one argument to `ev` is of this type then the binding is done in parallel. If `V` is a non-atomic expression then a substitution rather than a binding is performed.

* `F` where `F`, a function name, has been declared to be an evaluation function (see `evfun`) causes `F` to be applied to <expr>.

* Any other function names (e.g., `sum`) cause evaluation of occurrences of those names in <expr> as though they were verbs.

* In addition a function occurring in <expr> (say `F(x)`) may be defined locally for the purpose of this evaluation of <expr> by giving `F(x) := expression` as an argument to `ev`.

* If an atom not mentioned above or a subscripted variable or subscripted expression was given as an argument, it is evaluated and if the result is an equation or assignment then the indicated binding or substitution is performed. If the result is a list then the members of the list are treated as if they were additional arguments given to `ev`. This permits a list of equations to be given (e.g. `[X=1, Y=A**2]`) or a list of names of equations (e.g., `[%t1, %t2]` where `%t1` and `%t2` are equations) such as that returned by `solve`.

The arguments of `ev` may be given in any order with the exception of substitution equations which are handled in sequence, left to right, and evaluation functions which are composed, e.g., `ev (<expr>, ratsimp, realpart)` is handled as `realpart (ratsimp (<expr>))`.

The `simp`, `numer`, and `float` switches may also be set locally in a block, or globally in Maxima so that they will remain in effect until being reset.

If <expr> is a canonical rational expression (CRE), then the expression returned by `ev` is also a CRE, provided the `numer` and `float` switches are not both `true`.

2. During step (1), a list is made of the non-subscripted variables appearing on the left side of equations in the arguments or in the value of some arguments if the value is an equation. The variables (subscripted variables which do not have associated array functions as well as non-subscripted variables) in the expression <expr> are replaced by their global values, except for those appearing in this list. Usually, <expr> is just a label or `%` (as in `%i2` in the example below), so this step simply retrieves the expression named by the label, so that `ev` may work on it.

3. If any substitutions are indicated by the arguments, they are carried out now.

4. The resulting expression is then re-evaluated (unless one of the arguments was `noeval`) and simplified according to the arguments. Note that any function calls in <expr> will be carried out after the variables in it are evaluated and that `ev(F(x))` thus may behave like `F(ev(x))`.

5. For each instance of `eval` in the arguments, steps (3) and (4) are repeated.

Examples:

```          (%i1) sin(x) + cos(y) + (w+1)^2 + diff (sin(w), w);
d                    2
(%o1)              cos(y) + sin(x) + -- (sin(w)) + (w + 1)
dw
(%i2) ev (%, numer, expand, diff, x=2, y=1);
2
(%o2)                cos(w) + w  + 2 w + 2.449599732693821```

An alternate top level syntax has been provided for `ev`, whereby one may just type in its arguments, without the `ev()`. That is, one may write simply

<expr>, <arg_1>, ..., <arg_n>

This is not permitted as part of another expression, e.g., in functions, blocks, etc.

Notice the parallel binding process in the following example.

```          (%i3) programmode: false;
(%o3)                                false
(%i4) x+y, x: a+y, y: 2;
(%o4)                              y + a + 2
(%i5) 2*x - 3*y = 3\$
(%i6) -3*x + 2*y = -4\$
(%i7) solve ([%o5, %o6]);
Solution```

```                                                    1
(%t7)                               y = - -
5```

```                                                   6
(%t8)                                x = -
5
(%o8)                            [[%t7, %t8]]
(%i8) %o6, %o8;
(%o8)                              - 4 = - 4
(%i9) x + 1/x > gamma (1/2);
1
(%o9)                          x + - > sqrt(%pi)
x
(%i10) %, numer, x=1/2;
(%o10)                      2.5 > 1.772453850905516
(%i11) %, pred;
(%o11)                               true```

There are also some inexact matches for `ev`. Try `?? ev` to see them.

```(%o1)                                true
(%i2) ```

### Related Examples

0.5 + 0.1 * -3*0.1;

dt: 0.01;

Calculate

##### ev

pol:2*x^2+5+x^3-5*x^2...

pol2:3*x^3+2*x^2-5*x^...

pol3:-4*x^2-5*x^3+2*x...

Calculate

##### ev-integrate

integrate((y-a)^(k-1)...

ev (%, integrate);

Calculate

##### ev-kill-plot3d kill(all);

fz:a+b*N+c*N^2+d*P+e*...

a:1000;

Calculate

##### ev

m_kg: 2e30;

c_m: 3e8;

emc2_j: m_kg*c_m^2;

Calculate

##### ev-expand-float-fullratsimp-integrate-rhs-solve

f(m):=m+t;

eq1:''integrate(f(m),...

sol1:solve(eq1,t);

Calculate

##### ev

y: (b*0 + d*d/2 + b*d...

ev(y, numer, b=3, d=4);

Calculate

##### ev

pol: -2*x^3+3*x-5;

ev(pol ,x=-2);

Calculate

##### ev-solve

solve(a^2 + b^2 = c^2...

ev(%,c=2,b=1);

Calculate

##### ev

ev([x^2+5*x-7], [x=5]);

Calculate 