Mathematica: Div in Cylindrical and Shadowing

  • Context: Mathematica 
  • Thread starter Thread starter Saladsamurai
  • Start date Start date
  • Tags Tags
    Cylindrical Mathematica
Click For Summary

Discussion Overview

The discussion revolves around the use of the divergence operator (Div) in Mathematica for a vector field expressed in cylindrical coordinates. Participants are exploring issues related to unexpected outputs from the Div operator, specifically why it does not return zero as anticipated, and the implications of a warning about "shadowing" in the context of Mathematica's functions.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant reports that the divergence of their vector in cylindrical coordinates should be zero but Mathematica returns an algebraic expression instead.
  • Another participant suggests that the red warning about Div indicates that a definition of Div may have been introduced that takes precedence over the built-in definition, potentially causing the unexpected output.
  • It is noted that the warning about shadowing is related to the redefinition of Div, which may have been altered by the VectorAnalysis package.
  • A later reply mentions that redefining Div may not be inherently negative, as it could enhance functionality, but cautions about the implications of unprotecting built-in functions.
  • One participant shares their experience with simplifying the divergence expression, indicating that they were able to obtain zero using a different approach in Mathematica.

Areas of Agreement / Disagreement

Participants express uncertainty about the cause of the divergence not being zero, and there is no consensus on the implications of the shadowing warning or the redefinition of Div. Multiple viewpoints on these issues remain unresolved.

Contextual Notes

There are limitations regarding the assumptions made about the vector field and the definitions of the functions involved. The discussion does not resolve the mathematical steps leading to the divergence not equating to zero.

Saladsamurai
Messages
3,009
Reaction score
7
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.
 
Physics news on Phys.org


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.
 


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:


Saladsamurai said:
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
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 18 ·
Replies
18
Views
1K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K