non-algebraic expressions cannot be differentiated - Maple Help

Home : Support : Online Help : System : Error Message Guide : non-algebraic expressions cannot be differentiated

Error, non-algebraic expressions cannot be differentiated

 Description This error occurs when an argument that is not of type algebraic is passed to the diff command.

Examples

Example 1

In

 > $\mathrm{diff}\left(x\to {x}^{2},x\right)$

Solution 1: Use an expression, not function, for the first argument:

 > $\mathrm{diff}\left({x}^{2},x\right)$
 ${2}{}{x}$ (2.1)

Solution 2: The differential operator D can differentiate procedures (including functional operators).

 > $\mathrm{D}\left(x\to {x}^{2}\right)$
 ${x}{↦}{2}{\cdot }{x}$ (2.2)

For users of Maple 2017 and earlier versions:  Previously, this error was generated in the following cases.  As a result of updates made in Maple 2018, these examples no longer result in an error.

Example 2

In the following example, an error is generated when a Vector, $v$, is passed to the diff command.

 >
 ${v}{:=}\left[\begin{array}{c}{5}{}{t}{+}{1}\\ {-}{5}{}{{t}}^{{2}}{+}{50}\end{array}\right]$ (2.3)
 > $\mathrm{diff}\left(v,t\right)$

This is as expected since $v$ is not of type algebraic.

 > $\mathrm{type}\left(v,\mathrm{algebraic}\right)$
 ${\mathrm{false}}$ (2.4)

Solution:

Here, we assume that the intention was to differentiate each element of the Vector.  Since each element in the Vector is an algebraic expression, differentiating element-wise corrects the above error.  Specifically, use ~ to differentiate each element of the Vector.  For more information on ~, see the operators/elementwise help page.

 > $\mathrm{diff}~\left(v,t\right)$
 $\left[\begin{array}{c}{5}\\ {-}{10}{}{t}\end{array}\right]$ (2.5)
 > $\mathrm{type}\left(v\left[1\right],\mathrm{algebraic}\right),\mathrm{type}\left(v\left[2\right],\mathrm{algebraic}\right)$
 ${\mathrm{true}}{,}{\mathrm{true}}$ (2.6)

Example 3

In the following example, the call to the VectorCalculus package has been omitted.  This results in the top-level diff function being used for the right-hand side values of $\mathrm{r1}$ and $\mathrm{r2}$, rather than VectorCalculus[diff].  Since the top-level diff function does not accept Vectors as arguments, an error occurs.

 > $x≔\left(r,t\right)\to r\cdot \mathrm{sin}\left(t\right)$
 ${x}{:=}\left({r}{,}{t}\right){→}{r}{}{\mathrm{sin}}{}\left({t}\right)$ (2.7)
 > $y≔\left(r,t\right)\to r\cdot \mathrm{cos}\left(t\right)$
 ${y}{:=}\left({r}{,}{t}\right){→}{r}{}{\mathrm{cos}}{}\left({t}\right)$ (2.8)
 > $z≔\left(r,t\right)\to {r}^{2}\cdot \mathrm{sin}\left(t\right)\cdot \mathrm{cos}\left(t\right)$
 ${z}{:=}\left({r}{,}{t}\right){→}{{r}}^{{2}}{}{\mathrm{sin}}{}\left({t}\right){}{\mathrm{cos}}{}\left({t}\right)$ (2.9)
 > $R≔\left(r,t\right)\to ⟨x\left(r,t\right),y\left(r,t\right),z\left(r,t\right)⟩$
 ${R}{:=}\left({r}{,}{t}\right){→}⟨{x}{}\left({r}{,}{t}\right){,}{y}{}\left({r}{,}{t}\right){,}{z}{}\left({r}{,}{t}\right)⟩$ (2.10)
 > $R\left(r,t\right);$
 $\left[\begin{array}{c}{r}{}{\mathrm{sin}}{}\left({t}\right)\\ {r}{}{\mathrm{cos}}{}\left({t}\right)\\ {{r}}^{{2}}{}{\mathrm{sin}}{}\left({t}\right){}{\mathrm{cos}}{}\left({t}\right)\end{array}\right]$ (2.11)
 > $\mathrm{r1}≔\mathrm{diff}\left(R\left(r,t\right),r\right)$
 > $\mathrm{r2}≔\mathrm{diff}\left(R\left(r,t\right),t\right)$

Solution:

Adding with(VectorCalculus) before the sequence of statements results in VectorCalculus[diff]. This corrects the error.

 > $\mathrm{with}\left(\mathrm{VectorCalculus}\right):$
 > $x≔\left(r,t\right)\to r\cdot \mathrm{sin}\left(t\right)$
 ${x}{:=}\left({r}{,}{t}\right){→}{r}{}{\mathrm{sin}}{}\left({t}\right)$ (2.12)
 > $y≔\left(r,t\right)\to r\cdot \mathrm{cos}\left(t\right)$
 ${y}{:=}\left({r}{,}{t}\right){→}{r}{}{\mathrm{cos}}{}\left({t}\right)$ (2.13)
 > $z≔\left(r,t\right)\to {r}^{2}\cdot \mathrm{sin}\left(t\right)\cdot \mathrm{cos}\left(t\right)$
 ${z}{:=}\left({r}{,}{t}\right){→}{{r}}^{{2}}{}{\mathrm{sin}}{}\left({t}\right){}{\mathrm{cos}}{}\left({t}\right)$ (2.14)
 > $R≔\left(r,t\right)\to ⟨x\left(r,t\right),y\left(r,t\right),z\left(r,t\right)⟩$
 ${R}{:=}\left({r}{,}{t}\right){→}{\mathrm{VectorCalculus}}{:-}{\mathrm{<,>}}{}\left({x}{}\left({r}{,}{t}\right){,}{y}{}\left({r}{,}{t}\right){,}{z}{}\left({r}{,}{t}\right)\right)$ (2.15)
 > $R\left(r,t\right);$
 $\left({r}{}{\mathrm{sin}}{}\left({t}\right)\right){{e}}_{{x}}{+}\left({r}{}{\mathrm{cos}}{}\left({t}\right)\right){{e}}_{{y}}{+}\left({{r}}^{{2}}{}{\mathrm{sin}}{}\left({t}\right){}{\mathrm{cos}}{}\left({t}\right)\right){{e}}_{{z}}$ (2.16)
 > $\mathrm{r1}≔\mathrm{diff}\left(R\left(r,t\right),r\right)$
 ${\mathrm{r1}}{:=}\left({\mathrm{sin}}{}\left({t}\right)\right){{e}}_{{x}}{+}\left({\mathrm{cos}}{}\left({t}\right)\right){{e}}_{{y}}{+}{2}{}{r}{}{\mathrm{sin}}{}\left({t}\right){}{\mathrm{cos}}{}\left({t}\right){{e}}_{{z}}$ (2.17)
 > $\mathrm{r2}≔\mathrm{diff}\left(R\left(r,t\right),t\right)$
 ${\mathrm{r2}}{:=}\left({r}{}{\mathrm{cos}}{}\left({t}\right)\right){{e}}_{{x}}{-}{r}{}{\mathrm{sin}}{}\left({t}\right){{e}}_{{y}}{+}\left({{r}}^{{2}}{}{{\mathrm{cos}}{}\left({t}\right)}^{{2}}{-}{{r}}^{{2}}{}{{\mathrm{sin}}{}\left({t}\right)}^{{2}}\right){{e}}_{{z}}$ (2.18)