Error, non-algebraic expressions cannot be differentiated
Description
Examples
This error occurs when an argument that is not of type algebraic is passed to the diff command.
Example 1
In
diffx→x2,x
Solution 1: Use an expression, not function, for the first argument:
diffx2,x
2⁢x
Solution 2: The differential operator D can differentiate procedures (including functional operators).
Dx→x2
x↦2⋅x
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≔5 t+1,12−10t2+50
diffv,t
This is as expected since v is not of type algebraic.
typev,algebraic
false
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.
diff~v,t
typev1,algebraic,typev2,algebraic
true,true
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 r1 and r2, rather than VectorCalculus[diff]. Since the top-level diff function does not accept Vectors as arguments, an error occurs.
x≔r,t→r⋅sint
x:=r,t→r⁢sin⁡t
y≔r,t→r⋅cost
y:=r,t→r⁢cos⁡t
z≔r,t→r2⋅sint⋅cost
z:=r,t→r2⁢sin⁡t⁢cos⁡t
R≔r,t→xr,t,yr,t,zr,t
R:=r,t→x⁡r,t,y⁡r,t,z⁡r,t
Rr,t;
r1≔diffRr,t,r
r2≔diffRr,t,t
Adding with(VectorCalculus) before the sequence of statements results in VectorCalculus[diff]. This corrects the error.
withVectorCalculus:
R:=r,t→VectorCalculus:-<,>⁡x⁡r,t,y⁡r,t,z⁡r,t
See Also
diff
D
operators/elementwise
type/algebraic
VectorCalculus[diff]
Download Help Document