05-24-2017, 08:20 PM
Post: #1 KeithB Senior Member Posts: 409 Joined: Jan 2017
How does this work without the variable list? The example gives a "Bad Argument Value" when I delete [x y z].

Shouldn't it produce a unit vector that goes in a particular direction? How do I supply values?

And what the heck is the little +/- that appears when you hit []?
05-25-2017, 01:02 AM
Post: #2 Han Senior Member Posts: 1,882 Joined: Dec 2013
(05-24-2017 08:20 PM)KeithB Wrote:  How does this work without the variable list? The example gives a "Bad Argument Value" when I delete [x y z].

Shouldn't it produce a unit vector that goes in a particular direction? How do I supply values?

And what the heck is the little +/- that appears when you hit []?

grad() is a CAS command, so make sure that you are in CAS view. As an example:

It does not return a unit vector; it returns the gradient, which is defined as

$[ f_{x_1}, f_{x_2} , \dotsm, f_{x_n} ]$

where $$f$$ is a function of the variables $$x_1$$ through $$x_n$$, and $$f_{x_i}$$ denotes the partial derivative of $$f$$ with respect to $$x_i$$.

The +/- just means you can add row/columns by editing that position. If you place the cursor on the +/- and press + or - you can add/remove that particular row or column.

Graph 3D | QPI | SolveSys
05-25-2017, 03:09 PM
Post: #3 KeithB Senior Member Posts: 409 Joined: Jan 2017
"Returns the gradient of an expression. With a list of variables as second argument, returns the vector of partial derivatives."

That returns the partials. When you delete the list of variables you just get an error "Bad argument values", and no gradient which should be something where all the variables are a dimension. I think the option is so you can have variable constants, as it were.
05-25-2017, 08:21 PM (This post was last modified: 05-25-2017 08:22 PM by Han.)
Post: #4 Han Senior Member Posts: 1,882 Joined: Dec 2013
Arguments that are optional are shown with []'s surrounding the argument. As an example, look at the arguments for the input() command. The help for grad() does not show any arguments surrounded by []'s. So I took that to mean that the list of variables is required. By specifying all variables (in the list), then one obtains the gradient (which is basically a list of all partial derivatives). On the other hand, specifying only a (proper) subset of all the variables then one obtains a list of partial derivatives. This was how I interpreted the help text.

Graph 3D | QPI | SolveSys
05-25-2017, 08:35 PM
Post: #5 Han Senior Member Posts: 1,882 Joined: Dec 2013
You can write a short CAS program that will automatically generate the list of variables:

Code:
#cas gradient(f):= BEGIN   return(grad(f,lvar(f))); END; #end

This snippet of code, however, is not fool proof. It assumes that all variables in the expression are in fact undefined variables.

Graph 3D | QPI | SolveSys
05-25-2017, 09:55 PM
Post: #6 KeithB Senior Member Posts: 409 Joined: Jan 2017