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 the following example, an error is generated when a Vector, , is passed to the diff command.
>
|
|
| (2.1) |
>
|
|
This is as expected since is not of type algebraic.
>
|
|
| (2.2) |
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.
>
|
|
| (2.3) |
>
|
|
| (2.4) |
Example 2
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 and , rather than VectorCalculus[diff]. Since the top-level diff function does not accept Vectors as arguments, an error occurs.
>
|
|
| (2.5) |
>
|
|
| (2.6) |
>
|
|
| (2.7) |
>
|
|
| (2.8) |
>
|
|
| (2.9) |
>
|
|
>
|
|
Solution:
Adding with(VectorCalculus) before the sequence of statements results in VectorCalculus[diff]This corrects the error.
>
|
|
>
|
|
| (2.10) |
>
|
|
| (2.11) |
>
|
|
| (2.12) |
>
|
|
| (2.13) |
>
|
|
| (2.14) |
>
|
|
| (2.15) |
>
|
|
| (2.16) |
|
|
Download Help Document
Was this information helpful?