Enforcing that vectors returned from Vector Calculus functions have 3 components

  • Maple TA Interns 2016 Banned

    When taking the gradient of a scalar function that has only 1 or 2 variables, it will return a vector of length 1 or 2. This will compare falsely with any vector of length 3. For example the gradient of the function "phi(x, y, z) = 2x + z" is "del phi = (2, 0, 1)", however when using the function "Student[VectorCalculus][Gradient]($function)" maple will return the vector "(2, 1)" plus a list "[x, z]" to specify which unit vectors those components were associated with. Obviously we want the student to be able to enter the former vector "(2, 0, 1)" as their answer, and so we would like the Gradient function to return a 0 for components that are zero, rather than discarding them.

    To enforce this, use "Student[VectorCalculus][Gradient]($function, [x, y, z])" which will return a vector of length 3 even if some of the components are zero.

  • administrators

    I would advise against using the Student package in maple most of the time, it often returns more information than you want and separating it can be hard. In this case, there is a function VectorCalculus:-Gradient which appears to be identical.