1.11 DerivativesΒΆ

Use the FriCAS function D to differentiate an expression.

To find the derivative of an expression f with respect to a variable x,

\[\frac{d\,f(x)}{d\,x}\]

enter D(f, x).

f := exp exp x
\[{e} ^ {{{e} ^ {x}}}\]

Type: Expression Integer

D(f, x)
\[{{e} ^ {x}} \ {{e} ^ {{{e} ^ {x}}}}\]

Type: Expression Integer

An optional third argument n in D asks FriCAS for the n-th derivative of f. This finds the fourth derivative of f with respect to x.

D(f, x, 4)
\[{\left( {{{{e} ^ {x}}} ^ {4}}+{6 \ {{{{e} ^ {x}}} ^ {3}}}+{7 \ {{{{e} ^ {x}}} ^ {2}}}+{{e} ^ {x}} \right)} \ {{e} ^ {{{e} ^ {x}}}}\]

Type: Expression Integer

You can also compute partial derivatives by specifying the order of differentiation.

g := sin(x^2 + y)
\[\sin \left( {{y+{{x} ^ {2}}}} \right)\]

Type: Expression Integer

D(g, y)
\[\cos \left( {{y+{{x} ^ {2}}}} \right)\]

Type: Expression Integer

D(g, [y, y, x, x])
\[{4 \ {{x} ^ {2}} \ {\sin \left( {{y+{{x} ^ {2}}}} \right)}} -{2 \ {\cos \left( {{y+{{x} ^ {2}}}} \right)}}\]

Type: Expression Integer

FriCAS can manipulate the derivatives (partial and iterated) of expressions involving formal operators. All the dependencies must be explicit.

This returns 0 since F (so far) does not explicitly depend on x.

D(F,x)
\[0\]

Type: Polynomial Integer

Suppose that we have F a function of x, y, and z, where x and y are themselves functions of z.

Start by declaring that F, x, and y are operators. operator

F := operator 'F; x := operator 'x; y := operator 'y
\[y\]

Type: BasicOperator

You can use F, x, and y in expressions.

a := F(x z, y z, z^2) + x y(z+1)
\[{x\left({{y\left({{z+1}}\right)}}\right)}+{F \left({{x\left({z}\right)},\: {y \left({z}\right)},\: {{z} ^ {2}}}\right)}\]

Type: Expression Integer

Differentiate formally with respect to z. The formal derivatives appearing in dadz are not just formal symbols, but do represent the derivatives of x, y, and F.

dadz := D(a, z)
\[\scriptstyle{ {2 \ z \ {{F _ {{,3}}} \left({{x\left({z}\right)},\: {y\left({z}\right)},\: {{z} ^ {2}}} \right)}}+{{{y_ {{\ }} ^ {,}}\left({z}\right)}\ {{F _ {{,2}}} \left({{x\left({z}\right)},\: {y\left({z}\right)},\: {{z} ^ {2}}} \right)}}+{{{x_ {{\ }} ^ {,}}\left({z}\right)}\ {{F _ {{,1}}} \left({{x\left({z}\right)},\: {y\left({z}\right)},\: {{z} ^ {2}}} \right)}}+{{{x_ {{\ }} ^ {,}}\left({{y\left({{z+1}}\right)}} \right)}\ {{y _ {{\ }} ^ {,}}\left({{z+1}}\right)}}}\]

Type: Expression Integer

You can evaluate the above for particular functional values of F, x, and y. If x(z) is exp(z) and y(z) is log(z+1), then evaluates dadz.

eval(eval(dadz, 'x, z +-> exp z), 'y, z +-> log(z+1))
\[\scriptstyle{ {{{\left( {2 \ {{z} ^ {2}}}+{2 \ z} \right)} \ {{F _ {{,3}}}\left({{{e} ^ {z}}, \: {\log\left({{z+1}}\right)}, \: {{z} ^ {2}}}\right)}}+{{F_ {{,2}}}\left({{{e} ^ {z}}, \: {\log \left({{z+1}}\right)},\: {{z} ^ {2}}}\right)}+{{\left(z+1\right)} \ {{e} ^ {z}} \ {{F _ {{,1}}}\left({{{e} ^ {z}}, \: {\log \left({{z+1}}\right)},\: {{z} ^ {2}}}\right)}}+z+1}\over {z+1}}\]

Type: Expression Integer

You obtain the same result by first evaluating a and then differentiating.

eval(eval(a, 'x, z +-> exp z), 'y, z +-> log(z+1))
\[{F\left({{{e} ^ {z}}, \: {\log\left({{z+1}}\right)},\: {{z} ^ {2}}} \right)}+z+2\]

Type: Expression Integer

D(%, z)
\[\scriptstyle{ {{{\left( {2 \ {{z} ^ {2}}}+{2 \ z}\right)}\ {{F _ {{,3}}} \left({{{e} ^ {z}}, \: {\log\left({{z+1}}\right)},\: {{z} ^ {2}}} \right)}}+{{F_ {{,2}}}\left({{{e} ^ {z}}, \: {\log\left({{z+1}} \right)},\: {{z} ^ {2}}}\right)}+{{\left(z+1\right)} \ {{e} ^ {z}} \ {{F _ {{,1}}}\left({{{e} ^ {z}}, \: {\log \left({{z+1}}\right)},\: {{z} ^ {2}}}\right)}}+z+1}\over {z+1}}\]

Type: Expression Integer