The unapply command transforms an expression into a function.
Examples.
x↦ ex+2 |
⎛ ⎝ | x,y | ⎞ ⎠ | ↦ x y−x−y |
Warning.
When a function being is defined, the right side of the assignment is
not evaluated, hence g:=sin(x+1); f(x):=g does not define the
function f: x → sin(x+1) but defines the function f: x
→ g. To define the former function, unapply should
be used, as in the following example:
Example.
Input:
Output:
sin | ⎛ ⎝ | x+1 | ⎞ ⎠ | ,x↦ sin | ⎛ ⎝ | x+1 | ⎞ ⎠ |
hence, the variable g is assigned to a symbolic expression and the variable f is assigned to a function.
Examples.
x↦ 4 | ⎛ ⎝ | x−1 | ⎞ ⎠ | +4 |
x↦ x lnx−x+1 |
f:=unapply(integrate(log(t),t,1,x),x):; |
f(x) |
x lnx−x+1 |
Remark.
Suppose that f is a function of 2 variables f:(x,w)→
f(x,w), and that g is the function defined by g: w →
hw, where hw is the function defined by hw(x)=f(x,w).
unapply can also be used to define g.
Example.
Input:
f(x,w):=2*x+w:; |
g(w):=unapply(f(x,w),x):; |
g(3) |
Output:
x↦ 2 x+3 |