# Mathematica: Div in Cylindrical and Shadowing

• Mathematica
Mathematica: Div in Cylindrical and "Shadowing"

I have a vector given in cylindrical coordinates. I know that the divergence of the vector should be zero. However, I am not sure why Mathematica is not returning zero. Also, the Div operator is showing up red (Div) and it is saying something about Shadowing. I have no idea what this means and the help is a little cryptic about it. I tried using Remove[Div] but it is protected. I am not sure what to do about that. This is the code i am using:

Code:
Clear["Global*"]
Needs["VectorAnalysis"]
Vr = (A/r^2 - B) Cos[theta];
Vtheta = (A/r^2 + B) Sin[theta];
Div[{Vr, Vtheta, 0}, Cylindrical[r, theta, z]]

which should give zero, but instead it gives me an algebraic expression.

Bill Simpson

For your red Div and warning search in this

http://reference.wolfram.com/mathematica/tutorial/Contexts.html

for red and read the explanation. Somehow you or perhaps VectorAnalysis has introduced a definition of Div that is going to be used before the built-in definition of Div and Mathematica is warning you about that.

Why your divergence isn't zero I haven't pursued.

Bill Simpson

For your red Div and warning search in this

http://reference.wolfram.com/mathematica/tutorial/Contexts.html

for red and read the explanation. Somehow you or perhaps VectorAnalysis has introduced a definition of Div that is going to be used before the built-in definition of Div and Mathematica is warning you about that.

Why your divergence isn't zero I haven't pursued.

Sorry, must have clicked twice, so edit this to add some additional information.

It isn't necessarily a bad thing that Div was redefined. VectorAnalysis may have broadened the definition or added new abilities. The reason for the warning when you tried to Remove[Div] is that for your safety most internal features have write/delete protection. If you really want to Remove[Div] you would have to Unprotect it first, but I would make certain that you know you need to do that and you understand the consequences. If VectorAnalysis did redefine Div then what it did was Unprotect, change the definition and then Protect it again.

Last edited:
Oudeis Eimi

I have a vector given in cylindrical coordinates. I know that the divergence of the vector should be zero. However, I am not sure why Mathematica is not returning zero. Also, the Div operator is showing up red (Div) and it is saying something about Shadowing. I have no idea what this means and the help is a little cryptic about it. I tried using Remove[Div] but it is protected. I am not sure what to do about that. This is the code i am using:

Code:
Clear["Global*"]
Needs["VectorAnalysis"]
Vr = (A/r^2 - B) Cos[theta];
Vtheta = (A/r^2 + B) Sin[theta];
Div[{Vr, Vtheta, 0}, Cylindrical[r, theta, z]]

which should give zero, but instead it gives me an algebraic expression.

Have you tried to simplify the result? Here's what I obtain in Mathematica 6:

Code:
In[1]:= Vr = (A/r^2 - B) Cos[theta];
Vtheta = (A/r^2 + B) Sin[theta];
divV = 1/r D[r Vr, r] + 1/r D[Vtheta, theta] // Simplify

Out[3]= 0

In[4]:= Needs["VectorAnalysis"]
Div[{Vr, Vtheta, 0}, Cylindrical[r, theta, z]]

Out[5]= ((-B + A/r^2) Cos[theta] + (B + A/r^2) Cos[theta] - (
2 A Cos[theta])/r^2)/r

In[6]:= % // Simplify

Out[6]= 0`