### 13.2.2 Functional derivative

The function_diff command finds the derivatives of functions (as opposed to expressions, see Section 8.2.1).

- function_diff takes f, a function.
- function_diff(f) returns the derivative f′ of f.

#### Examples

function_diff(sin)

x↦cos x |  |  |  |  |  |  |  |  |  |

function_diff(sin)(x)

cos x |  |  |  |  |  |  |  |  |  |

f(x):=x^2+x*cos(x):; function_diff(f)

x↦cos x−x sin x+2 x |  |  |  |  |  |  |  |  |  |

function_diff(f)(x)

cos x−x sin x+2 x |  |  |  |  |  |  |  |  |  |

To define the function g as f′:

g:=function_diff(f)

The function_diff instruction has the same effect as using the expression derivative diff (see Section 13.2.1) in conjunction with unapply (see Section 8.2.2). For example:

g:=unapply(diff(f(x),x),x):; g(x)

cos x−x sin x+2 x |  |  |  |  |  |  |  |  |  |

##### Remark.

In Maple mode (see Section 2.5.2), for compatibility, D may be used in place of function_diff. For this reason, it is impossible to assign a variable named D in Maple mode (hence you cannot name a geometric object D).