Mathematica: Div in Cylindrical and Shadowing

  • Mathematica
  • Thread starter Saladsamurai
  • Start date
  • #1
3,003
3
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.
 

Answers and Replies

  • #2
1,069
29


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.
 
  • #3
1,069
29


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:
  • #4


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
 

Related Threads on Mathematica: Div in Cylindrical and Shadowing

Replies
1
Views
3K
Replies
1
Views
3K
Replies
2
Views
2K
Replies
2
Views
971
Replies
3
Views
3K
Replies
6
Views
2K
Replies
9
Views
2K
  • Last Post
Replies
4
Views
2K
Replies
1
Views
2K
Top