|, evalAt

Insert a value (evaluate at a point)

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

```` f | x = v`
evalAt(`f`, `x = v`)
`f | ( x1= v1, x2= v2, … )`
evalAt(`f`, `x1 = v1, x2 = v2, …`)
evalAt(`f`, `x1 = v1, x2 = v2, …`)
`f | [x1= v1, x2= v2, …] `
evalAt(`f`, `[x1 = v1, x2 = v2, …]`)
`f | {x1= v1, x2= v2, …} `
evalAt(`f`, `{x1 = v1, x2 = v2, …}`)
```

Description

`evalAt(f, x = v)` substitutes ```x = v``` in the object `f` and evaluates.

The MuPAD® statement `f | x = v` serves as a shortcut for calling `evalAt(f, x = v)`.

`evalAt(f, x = v)` evaluates the object `f` at the point `x = v`. Essentially, it is the same as ```eval ( subs(f, x = v))```, but limited to free (as opposed to bound) variables.

Several substitutions of indeterminates by values can be done by `evalAt(f, x1 = v1, x2 = v2, ...)`. This is equivalent to ```evalAt(... (evalAt(evalAt(f, x1 = v1), x2 = v2), ...), ...)```, i.e., `x1 = v1` is substituted in `f`, then `x2 = v2` is substituted in the result etc. E.g., `evalAt(x, x = y, y = 1)` yields 1.

Note that the three (equivalent) calls ```evalAt(f, (x1 = v1, x2 = v2, ...))```, ```evalAt(f, [x1 = v1, x2 = v2, ...])```, `evalAt(f, {x1 = v1, x2 = v2, ...})` do parallel substitutions, i.e., the substitutions `x1 = v1`, ```x2 = v2``` are all performed on `f` simultaneously. Consequently, `evalAt(x, [x = y, y = 1])` yields `y`, not 1!

The operator `|` provides a shortcut for calling `evalAt`:

The command `f | x = v` is equivalent to calling ```evalAt(f, x = v)```.

Similarly, `f | (x1=v1, x2=v2, ...)` is equivalent to `evalAt(f, (x1=v1, x2=v2, ...))`, ```f | [x1=v1, x2=v2, ...]``` is equivalent to ```evalAt(f, [x1=v1, x2=v2, ...])```, `f | [x1=v1, x2=v2, ...}` is equivalent to `evalAt(f, {x1=v1, x2=v2, ...})`.

 Note:   The sequential substitution ```evalAt(f, x1 = v1, x2 = v2, ...)``` cannot be done via ```f | x1 = v1, x2 = v2, ...```: this produces the sequence ```evalAt(f, x1 = v1)```, x2 = v2, .... Use ```f | x1 = v1 | x2 = v2 | ...``` for sequential substitution. E.g., the statement ```x | x = y | y = 1``` yields 1.

Examples

Example 1

Calls to `evalAt` and corresponding statements using the operator `|` are equivalent:

```evalAt(x^2 + sin(x), x = 1); x^2 + sin(x) | x = 1```

We use the operator `|` to evaluate an expression `f` representing a function of `x` at several points:

```f := x + exp(x): f | x = 3; f | x = 5.0; f | x = y;```

We create a matrix with symbolic entries and evaluate the matrix with various values for the symbols:

```A := matrix([[x, sin(PI*x)], [2, y]]); A | x = a; A | [x = a, y = b]```

`delete f, A:`

Example 2

We do several substitutions simultaneously:

```f := cos(y) + sin(x) + x*y; f | (x = 1, y = 2); f | [x = 1, y = 2]; f | {x = 1, y = 2};```

`delete f:`

Parameters

 `f` An arbitrary MuPAD object. `x, x1, x2, …` `v, v1, v2, …` The values for ```x, x1, x2, …```.

Return Values

Copy of the input object `f` with replaced operands.

`f`

Get trial now