Message Boards Message Boards

0
|
3209 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Perform Grad twice on a function?

Posted 5 years ago

I am basically checking that the answer which Mathematica gives for computing twice the grad of a function is the same as the one which I compute explicitly myself. So I define the function mu_1 and apply grad twice:

\[Phi] = 1/(4*pi*R);

\[Mu]1 = \[Phi]*Exp[-gam1*R];

\[Mu]11 = FullSimplify[Grad[\[Mu]1, r]];

\[Mu]12 = FullSimplify[Grad[\[Mu]11, r]];

However, when I try the explicit computation by applying the formula for grad in spherical coordinates I get the following:

$\mu_{\gamma}=-\frac{e^{-\gamma}}{4 \pi r}$

$\nabla \mu_{\gamma} = \frac{\textbf{r}}{|\textbf{r}|} \frac{\text{d}\mu_{\gamma}}{\text{d}|\textbf{r}|}$.

$\nabla (\nabla \mu_{\gamma}) = \frac{\nabla (\textbf{r})}{|\textbf{r}|}\frac{\partial}{\partial r}\mu_{\gamma} + \hat{r} \nabla \bigg( \frac{\partial}{\partial r} \mu_{\gamma} \bigg)=\frac{\textbf{r}}{|\textbf{r}|} \frac{\text{d} \mu_{\gamma}}{\text{d} |\textbf{r}|} + \frac{\textbf{r}}{|\textbf{r}|}\frac{\textbf{r}}{|\textbf{r}|} \frac{\partial }{\partial r} \bigg( \frac{\partial}{\partial r} \mu_{\gamma} \bigg) = \frac{\delta_{ij}}{|\textbf{r}|}\frac{\text{d} \mu_{\gamma}}{\text{d}|\textbf{r}|} + \frac{\textbf{r} \otimes \textbf{r}}{|\textbf{r}|^2} \frac{\text{d}^2 \mu_{\gamma}}{\text{d} |\textbf{r}|^2}. $

After performing the derivatives to get the expression, if I then try to subtract the result from Mathematica from the result of my brief computation, I do not get 0, so cl

POSTED BY: Hollis Williams
2 Replies

R and r are different variables - you take the derivative wrt r for an expression in R.. Also post your code using the format button (upper left) otherwise its impossible to see the code correctly. You may have other errors but itÂ’s hard to tell.

Regards

Neil

POSTED BY: Neil Singer

Hi Neil

I've made the change you requested. They are different, but I have used the same variable and way of differentiating with other functions and it all seems to have worked fine when you have the derivatives at the end.

r = {x, y, z};
R = Sqrt[x^2 + y^2 + z^2];
POSTED BY: Hollis Williams
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