1. Apr 16, 2005

### µ³

I was bored yesterday and started messing around with Maxwell equations to try to solve for electric field for spherically symmetric cases (as opposed to just using the integral formulation).

For example, a simple case of a solid sphere with uniform charge distribution $\rho$. Using Gauss's Law an equation can be simply derived for the electric field inside the sphere.
$$\oint_S \mathbf{E} \cdot d\mathbf{A} = \frac{1}{\epsilon_0} \int_S \rho dV$$
(Edit - whoops)
$$E4\pi r^2 = \frac{4/3 \pi r^3 \rho_0}{\epsilon_0}$$
$$E = \frac{r\rho_0}{3\epsilon_0}$$

However, when I try plugging this back into Maxwell Equation:
$$\nabla \cdot E = \frac{\rho}{\epsilon_0}$$
...using Mathematica and spherical coordinates I take:
$$E = <\frac{r\rho_0}{3\epsilon_0},\phi, \theta>$$
and it becomes
$$\nabla \cdot E = \frac{\rho_0}{\epsilon_0} + \frac{1 + \phi cot(\phi) + csc(\phi)}{r}$$

I then tried a simpler case such as the Electric field from a static charge.
$$E = \frac{q}{4\pi\epsilon_0 r^2}$$
When I plugin
$$E = <\frac{q}{4\pi\epsilon_0 r^2}, \phi, \theta>$$
into Mathematica I get.
$$\nabla \cdot E = \frac{1 + \phi cot(\phi) + csc(\phi)}{r}$$

I'm confused as to where this
$$\frac{1 + \phi cot(\phi) + csc(\phi)}{r}$$
is coming from or what am I doing wrong in the application of the equation. I originally had trouble when I tried to solve the differential equation
$$\nabla \cdot E(r,\phi,\theta) = \frac{\rho(r) }{\epsilon_0}$$
using
$$E(r,\phi,\theta) = <E(r), \phi, \theta>$$
to get a general solution for any spherically symmetric charge distribution $\rho(r)$

Last edited: Apr 17, 2005
2. Apr 16, 2005

### Meir Achuz

You should have put <E_r,0,0> into div E. Your input gave angular derivatives of the \phi and \theta.

3. Apr 16, 2005

### Andrew Mason

Your statement of Gauss' law should be:

$$\oint_S \mathbf{E} \cdot d\mathbf{A} = \frac{q_{encl}}{\epsilon_0} = \frac{\rho V}{\epsilon_0}$$

$$\nabla \cdot E = \frac{\rho}{\epsilon_0}$$

You correct that in your calculation but when you plug it back into mathematica you omit the Volume.

Edit: corrected $$\nabla \cdot E$$ - Brad's post - thanks

AM

Last edited: Apr 17, 2005
4. Apr 16, 2005

the right side of the differential form of gauss' law should be "rho/epsilon_0."

5. Apr 17, 2005

### µ³

Woops, I made a mistake when writing out the formula for Gauss's law. However, I still applied it correctly (Q = 4/3 rho * pi * r^3) . Also, The differential form doesn't have a V in it, as Brad already stated. Lastly, <E_r,0,0> I believe is incorrect since the electric field does have a direction and that is the direction away from the center of charge--assuming spherical symmetry (i.e. the electric field lines aren't just pointing at 0,0 all the time. They are pointing radially outwards). Additionally I don't understand what you mean by "omit[ing] the volume" when plugging back into Mathematica. I calculated E using Gauss's law and then use the differential form to try to find the divergence of E.

Last edited: Apr 17, 2005
6. Apr 17, 2005

### Claude Bile

Pointing radially outward is exactly equivalent to pointing toward the centre. Meir is correct, your phi and theta components should both be zero.

The divergence of an electric field in spherical coordiantes is;

$$\nabla.E = \frac{1}{r^2} \frac{\partial}{\partial r} (r^2 E_r)$$

(Omitting the terms that contain derivatives of $$E_\phi$$ and $$E_\theta$$)

When you plug your result in, the divergence comes out as it should. Your problem was either a) You didn't specify spherical coordinates or b) The program got confused because you specified non-zero values for phi and theta.

Claude.

7. Apr 19, 2005

### µ³

Sorry, I don't understand how 0,0 for $(\phi,\theta)$ could be radial, I don't have that much experience with the coordinate system. Converting <E(r),0,0> back to Cartesian yields:
$$\mathbf{E} = <E(r)cos(\theta)sin(\phi),E(r)sin(\theta)sin(\phi),E(r)cos(\phi)>$$
for
$$(\phi,\theta) = (0,0)[/itex] it becomes $$\mathbf{E} = <0,0,E(r)>$$ ($\mathbf{E}$ Is the electric field and E(r) is the magnitude of the electric field) So all of the vector field lines are pointing in the z direction? Could you point out where my fallacy is please? Many thanks in advance. . 8. Apr 19, 2005 ### jdavel microncubed, "So all of the vector field lines are pointing in the z direction?" So in spherical coordinates the field points radial out from the origin. But in cartesian coordinates it points in the z direction? Does that make sense? Are you sure your conversion from spherical to cartesian coordinates is right? 9. Apr 19, 2005 ### µ³ That's the point, I don't see how <E(r), 0 ,0> is radial based on the definition of spherical coordinates. <E(r), 0, 0> means that the vector has magnitude E(r) and has a zenith angle of 0, (it's ponting up) and has an azimuthal angle of 0 (irrelevant because the polar angle is zero). That's why I'm confused people are telling me that the vector field function for the electric field should be <E(r), 0, 0> in spherical coordinates but that doesn't really make sense to me and I'm wondering where my reasoning is wrong, since when I use my reasoning it leads to conflicting results. I'm using all conversions and equations from http://mathworld.wolfram.com/SphericalCoordinates.html by the way. Last edited: Apr 19, 2005 10. Apr 19, 2005 ### robphy It seems to me that <E(r),0,0> means "the angular components satisfy E(phi)=0 and E(theta)=0 [for any values of r, phi and theta]" ...and not that "phi=0 and theta=0". 11. Apr 19, 2005 ### µ³ I have a feeling I'm wrong but I've always thought of vector fields (in this case spherical coordinates) as a function which takes a position vector <r, phi, theta> which corresponds to the location of the point to be evaluated and returns another vector (r, phi, theta) which corresponds to the value and direction of the vector. So a vector field <E(r), 0, 0> takes a position at any given point in space given by (r, theta, phi) and returns a vector at that point with length E(r) (i.e some function only dependant on the distance to the origin) and with direction 0 for phi and 0 for theta (i.e pointing up). A vector field <E(r), phi, theta> takes a position (r, phi, theta) and returns a vector <E(r), phi, theta> (i.e a vector with the same direction to the origin as it's position, with a length described by the function E(r)), which is why I said would be a radially symmetric electric field.)Why is this wrong? 12. Apr 19, 2005 ### jdavel microncubed, Now I see your problem! The spherical coordinate system is an example of a more general type of system of coordinates called curvilinear coordinates. They differ from cartesian coordinates in that the three basis vectors that define the system are not the same at all points in space. In particular, for the spherical system, the r basis vector is defined at any point P in space to point along the line between the origin and the point P. In other words r always points radially away from the origin. So any vector expressed in spherical coordinates that has phi and theta coordinates equal to zero, will point in the radial direction. Does that help? 13. Apr 19, 2005 ### cepheid Staff Emeritus Your notation: <E(r), theta, phi> really doesn't make a whole lot of sense to me. How can you have a vector quantity whose components are not all the same types of quantities? The radial component is an electric field. The other two are merely position coordinates. The units don't even match. Let's go through it from the top: You are correct that a vector field is a function that assigns a vector to every point in space. (Look at a diagram of a vector field, and you will these vectors drawn for selected points in space). All this is saying is that, at any given point in space, the electric field has a certain magnitude and direction. Hence it can be represented by a vector at that point. The magnitude and direction of the electric field vector depends on the point in space where you look. So the electric field vector is a function of the three spatial position coordianates. In spherical coordinates: $$\vec{E} = \vec{E}(r, \theta, \phi )$$ Just so we're absolutely clear, that is just function notation. Now, the E-field is a function of position, which is given by the three coords. But since knowing the position vector of a point in space, you know the position coordinates by definition, the E-field is a function of the spatial position vector (I realise I'm going over stuff you already know): $$\vec{r} = \ \ < r, \theta, \phi >$$ so we can write: $$\vec{E} = \vec{E}(\vec{r} )$$ Now, in general, the E-field vector is pointing in some direction, that is a combination of the three directions of the basis vectors. So we can resolve E into components, part of it is pointing in the radial direction, part of it in the circumferential direction (phi), part of it in the polar direction (theta). We'll use subscripts to denote which component of the E vector is being referred to: $$\vec{E} = \ \ <E_r, E_{\theta}, E_{\phi}>$$ But what determines the value of each component? Well, the magnitude and direction of the E vector is a function of position. It follows that the value of each component is a function of position: $$\vec{E}(r, \theta, \phi ) = <E_r(r, \theta, \phi ), \ \ E_{\theta}(r, \theta, \phi ), \ \ E_{\phi}(r, \theta, \phi )>$$ Now, you happen to know that the field in question points in the radial direction only. What does this mean? It means that it has an r component only. The theta and phi components are zero: $$\vec{E}(r, \theta, \phi ) = <E_r(r, \theta, \phi ),\ \ 0,\ \ 0>$$ If you don't believe me, consider an analogous case in cartesian coordinates: what if the electric field pointed in, say, the x-direction only? Then its y and z components would be zero, and the vector would be given by: $$\vec{E}(x, y, z) = <E_x(x, y, z), \ \ 0, \ \ 0>$$ But I digress. Back to the example at hand. I believe from Coulomb's law we have some additional information for this particular case: not only is the field radial, but also its strength depends only on how far away you are (radially) from the source. That means that (by symmetry arguments for this type of charge distribution), The electric field is constant (in magnitude) at every point in space a given radius away from the source. We say that its magnitude is a function of r only. There is no theta dependence, or phi dependence. If E is not a function of theta or phi, we can write: $$\vec{E}(r) = <E_r(r), \ \ 0, \ \ 0>$$ Lastly, I don't like the angle bracket notation much. We can also write vectors as as a sum of the scalar components, each multiplied by its respective unit vector: $$\vec{E}(r) = E_r(r) \hat{r} + 0\hat{\theta} + 0\hat{\phi}$$ r hat, theta hat, and phi hat are the three basis vectors (to which jdavel referred) for this coordinate system. So they are analogous to i, j, and k in the cartesian coordinate system. Since E is unidirectional and a function of only one variable, we can clean that last expression up a little and simply write: $$\vec{E}(r) = E(r) \hat{r}$$ I hope all of this helps. 14. Apr 19, 2005 ### µ³ I understand everything up to here. This is news to me. I understand most of it except for the meaning of theta and phi. Few things I still don't understand or am note sure about: (1) If you have a field vector (i.e a vector that is the output of a vector field) <r,0,0> (or $r\hat{\mathbf{r}}$ if you prefer) would it be possible to convert to cartesian without knowing it's position vector? (2) Considering I completely misunderstood what the radial (r) component meant/denote, what do the theta and phi component indicate? Are they sort of like deviations from the radial vector? (3) Does having non-zero theta and phi components change the magnitude of the vector? Also, thank you (and jdavel) so much for clearing up my misconception, it had been bugging me for days. 15. Apr 19, 2005 ### jdavel microncubed, This is pretty hard to see without a good perspective diagram of a 3D coordinate system. Try Googling spherical coordinates; you'll get all the pictures you want! And feel free to ask more questions if you get stuck. If you describe a 3D figure you find, people here will know what you're talking about and be able to help. Good luck. 16. Apr 19, 2005 ### Claude Bile Recall that you have converted from Spherical to Cartesian coordinates, thus you are saying that at phi=0, theta=0, which corresponds to a point on the z axis, thus it makes sense that the electric field will point in the z direction at this point (i.e. radially outward from the centre). There is nothing contradictory in your statement. (1) No, because the unit vector is the normalised position vector (i.e. same direction, length 1). This is one of the key differences between Spherical and Cartesian coordinate systems, the unit vectors are not constant, they depend on position. (2) Theta is the angle from the x axis (in the horizontal (xy) plane). Phi is the angle from the z axis (otherwise know as the azimuth angle for this reason). The direction of the phi component is toward the z axis, perpendicular to the radial vector. The direction of the theta component is perpendicular to both the phi and radial vector. (3) Absolutely. The mutual orthogonality of the unit vectors, means that calculating the length of a vector in spherical coordinates is exactly the same as you would calculate in cartesian coordinates. I suggest looking up the Mathworld website (Look up geometry -> Coordinate Geometry -> Spherical coordinates) for more information (and a picture!). Claude. 17. Apr 19, 2005 ### Hurkyl Staff Emeritus Hrm, I see what may be the problem. As we all know, a geometric model for spherical coordinates is that given an (r, &theta;, &phi;) tuple, we can construct the corresponding point in x-y-z space as follows: Start with the point on the x-axis with coordinate r. Rotate this through an angle of &theta; around the z-axis. Now, in the plane containing the point and the z-axis, rotate it an angle of &phi; about the origin. (positive &phi; means upwards, etc) (For the record, I'm a mathematician -- I understand that physicists like to swap the meaning of &theta; and &phi;. Ah well) It would seem natural to do the same thing for a vector as well -- given an (r, &theta;, &phi;) tuple, make the same construction to produce the corresponding vector in (x, y, z) coordinates... But that's wrong -- there are various reasons to prefer another way... The right way is that the each basis vector for spherical coordinates points in the direction where the corresponding position variable is increasing, but the others remain the same. Or, to say that in an easier way, the r basis vector points in the direction in which r increases, and &theta; and &phi; remain constant. Similarly for the other two basis vectors. 18. Apr 19, 2005 ### Andrew Mason Just a comment. You have to be careful not to mix coordinates of these two different vectors: 1. the location of a point in space (displacement from origin) and 2. the field vector at that point. To describe the field, you pick a displacement vector $\vec r(r, \theta, \phi)$$ and express the field vector at that displacement. Since E is in the same direction as [itex]\vec r$, $\vec E(\vec r) = \vec E(\vec r(r,\theta,\phi)) = E\hat r[/tex] AM 19. Apr 20, 2005 ### pmb_phy I'm afraid you've made a very serious error here. You're confusing the total charge of the sphere with the charge contained within the Gaussian surface. With that in mind try this again and you'll clearly see your mistake. Hope that was helpful. Pete Last edited: Apr 20, 2005 20. Apr 20, 2005 ### jdavel pmb phy, "You're confusing the total charge of the sphere with the charge contained within the Gaussian surface." Are you sure that's right? He said his equation is for the field "inside the sphere". So as long as r is less than the radius of the entire sphere, the field will vary as r. Right? 21. Apr 20, 2005 ### pmb_phy Let me read this entire thread over during the next day or two and I'll get back to you. Until then please state the exact question that you wish answered. There was a bunch of dialog here that I got lost as far as what the question you are seeking to get answered (and why you're using Mathematica). Also, it is unclear to me if you understand that the electric field is spherically symmetric or not. That is taken as a basic assumption when you're using Gauss's law on these kinds of problems. The position vector is (r, theta, Phi) and the E vector is (E_r, E_theta, E_phi) = (E_r, 0, 0). Pete Last edited: Apr 20, 2005 22. Apr 20, 2005 ### Andrew Mason Why would it be (E_r, 0, 0)? Shouldn't it be: $$\vec E(\vec r) = |\vec{E}|\hat r = (|\vec{E}|, \theta_r, \phi_r)$$ where [itex]\theta_r, \phi_r$ are the spherical angles for displacement vector $\vec r$.

AM

23. Apr 20, 2005

### Claude Bile

Only the radial component of the field will contribute to the flux through the Gaussian surface. Thus the phi and theta components must be zero.

They must also be zero due to the symmetry.

Andrew, when you claim that;

$$\vec E(\vec r) = |\vec{E}|\hat r$$

You are essentially saying that $\theta_r, \phi_r$ are zero, since this is only true if the Electric field points in the radial direction to begin with.

Claude.

24. Apr 20, 2005

### Hurkyl

Staff Emeritus
Vectors don't transform like points when you convert from rectangular to spherical coordinates.

25. Apr 20, 2005

### Andrew Mason

Ques: What is the field at a point $\vec r = (r, \theta_r, \phi_r)$?

Ans: The unit vector at $\vec r$ is $\hat r = (1, \theta_r, \phi_r)$. So, at this point the field is:

$$\vec E = |\vec E|\hat r = (\frac{r\rho}{3\epsilon_0}, \theta_r, \phi_r)$$

The vector (E(r), 0, 0) is a radial vector only for points along the spherical equivalent of the x axis.

AM