Message Boards Message Boards

0
|
6110 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Using the "D" command to take derivatives and then apply variable values

Posted 4 years ago

Hello;

While taking partial derivatives of a previously defined function (f[x, y] := 4 - x^2 - y^2), I would like to load x and y with specific values of x = 1 and y = 1 with the resulting Mathematica commands of:

D[f[1, 1], x]
D[f[1, 1], y]

My intention was for the "D" command to first take the partial derivatives and then apply the values of x=1 and y=1 to the derived functions. However it appears that the command is doing just the opposite by applying the values of [1,1] to the function before taking the derivative - see attached.

Am I using the Mathematica command correctly and if so, is there a way that I can override the processing sequence of the command forcing the command to first take the derivative of the function and then apply the values to the derived function.

Thanks,

Mitch Sandlin

Attachments:
POSTED BY: Mitchell Sandlin
3 Replies

If I evaluate D[f[1, 1], x] the output is zero, as it should, because f[1,1] does not depend on x. The D operator acts on expressions that contain variables with symbolic names such as x,y etc. With D you take the derivative of the expression with respect to a variable.

The Derivative operator acts on functions, which are constructs that have numbered slots: slot number 1, slot number 2 etc. With Derivative you take the derivative with respect to a slot, which we identify with its number, not with a variable name. The function f[x_,y_]=x^2y has two slots, forget about the variables which are used to define f. Then Derivative[1,0][f][x,y] is the first derivative with respect to the first slot and zeroeth derivative with respect to the second slot. Then the slots are filled in with whatever is x and y.

When we call Derivative[0,1][f][whatever arguments] the f object must be something for which f[x,y] makes sense. It does not make sense to call Derivative[0,1][x^2y], because (x^2y)[3,2] has no meaning.

What you call Subscript[f, yx] would correspond to Derivative[1,1][f][whatever arguments].

POSTED BY: Gianluca Gorni

Mathematica has two different ways to make derivatives. The operator D makes derivatives of expressions, and outputs other expressions. The operator Derivative makes derivatives of functions and outputs functions. The syntax of Derivative is like this:

f[x_, y_] := 4 - x^2 - y^2;
Derivative[1, 0][f][x, y]
Derivative[1, 0][f][1, 1]

as you can see, you can calculate the derivative in a given point just by giving the coordinates. For functions of one variable, there is the much more convenient shorthand f'[x], which is equivalent to Derivative[1][f][x]. You can find documentation in the page defining derivatives

POSTED BY: Gianluca Gorni

Thanks so much for your reply. I was under the impression that D was a shortcut for Derivative, which is apparently not the case. However there seems to still be a problem with D[f[1, 1], x] and D[f[1, 1], y], since it still gave me an answer without any warnings or errors. Additionally Derivative seems a little odd since all of its trailing terms are not enclosed in a single set of [ ] like the rest of Mathematica's commands. Could you explain why Mathematica chose to handle Derivative differently.

I found your response very helpful. However your response brought up another question. Whenever you are taking the 2nd derivative of a function with 2 variables, you actually end up with 4 solutions: Subscript[f, xx], Subscript[f, yy], Subscript[f, xy], Subscript[f, yx]. Taking the 2nd derivative of xx and yy is not a problem for the Derivative command. However, is there a way to calculate the 2nd derivative of first taking the derivative of x and then taking the derivative of y and subsequently the y and x variables using the Derivative command? I certainly can calculate the derivatives manually but with the ability to select the derivative level with the variable using the Derivative command, there might be a better way to perform the calculations within the command.

Thanks again,

Mitch Sandlin

POSTED BY: Mitchell Sandlin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract