On this page
The uniformly charged sphere is a standard result. Then a JEE question says the charge density is ρ = ρ0r/R, and the familiar formula stops working. Nothing about Gauss's law has changed. What changes is how you count the charge inside your surface. This post shows the shell-by-shell method and works three cases, one of them backwards.
What does the syllabus say?
The JEE (Main) 2026 syllabus lists Gauss's law and its applications to an infinitely long charged wire, an infinite plane sheet and a thin spherical shell, all uniformly charged. It also lists "continuous charge distribution". The NEET (UG) 2026 syllabus has the same three cases. A sphere with varying density is not named, so treat it as an extension that uses only listed ideas.
NCERT Class 12 Chapter 1 (reprint 2026-27) states in section 1.13 that Gauss's law holds for any closed surface, and that a suitable choice of surface makes the calculation easy. Section 1.14 derives the three uniform cases.
Why does a varying density need integration?
When ρ depends only on the distance r from the centre, the arrangement still looks the same from every direction. So the field is radial and has the same size everywhere on a sphere of radius r. Gauss's law still gives
E × 4πr² = Q_enc/ε0
What you cannot do is write Q_enc = ρ × (4/3)πr³, because ρ is not one number. Instead, split the sphere into thin shells. A shell of radius r′ and thickness dr′ has volume 4πr′²dr′, so
Q_enc = ∫ ρ(r′) 4πr′² dr′, from 0 to r.
For a point outside the sphere, the upper limit stops at R, because there is no charge beyond it.
Worked example 1: density rising outward, ρ = ρ0r/R
Q_enc = ∫ (ρ0r′/R) 4πr′² dr′ = (4πρ0/R)(r⁴/4) = πρ0r⁴/R.
Inside: E = Q_enc/(4πε0r²) = ρ0r²/(4ε0R). It grows as r², not as r.
Total charge: Q = πρ0R³. Outside: E = ρ0R³/(4ε0r²).
With sample numbers R = 10 cm and ρ0 = 1.0 µC/m³, using ε0 = 8.854 × 10⁻¹² F/m from NIST:
Q = π × 10⁻⁶ × 0.001 = 3.14 nC.
At r = 5 cm: E = 10⁻⁶ × 0.0025/(4 × 8.854 × 10⁻¹² × 0.10) = 706 N/C.
At r = R: 2,824 N/C. At 20 cm: 706 N/C again.
The match at 5 cm and 20 cm is a good check. Inside, halving r cuts E by (1/2)² = 1/4. Outside, doubling r also cuts it by 1/4.
Worked example 2: density falling outward, ρ = ρ0(1 − r/R)
Q_enc = 4πρ0(r³/3 − r⁴/(4R)).
Inside: E = (ρ0/ε0)(r/3 − r²/(4R)).
Set dE/dr = 0: 1/3 − r/(2R) = 0, so r = 2R/3.
At that point E_max = ρ0R/(9ε0). At the surface, E = ρ0R/(12ε0), which is smaller.
With the same sample numbers, E_max = 1,255 N/C at r = 6.7 cm, and the surface field is 941 N/C. The total charge is πρ0R³/3 = 1.05 nC, and Q/(4πε0R²) gives the same 941 N/C, confirming the result. So the strongest field is not always at the surface.
Worked example 3: working backwards
Suppose the field inside a sphere has the same value E0 at every radius. What density gives that?
Q_enc = 4πε0E0r².
The charge in a thin shell is dQ = 8πε0E0r dr, and that equals ρ × 4πr² dr.
So ρ = 2ε0E0/r.
With E0 = 1,000 N/C, at r = 5 cm the density is 3.54 × 10⁻⁷ C/m³, about 0.35 µC/m³. A density that falls as 1/r is the one that keeps the field constant.
Which mistakes cost marks?
Multiplying ρ by the volume when ρ varies.
Integrating past R for a point outside.
Assuming the field is largest at the surface. Example 2 shows it need not be.
Applying the method when ρ depends on direction. Without spherical symmetry, E is not constant over the surface.
Forgetting the 4πr′² factor inside the integral.
If you cannot picture how the field changes with radius, the Fermi Simulation Lab has interactive simulations for ideas that are easier to see than read.
A practice routine
Derive E inside and outside for ρ = ρ0r/R without notes.
Repeat for ρ = kr², and check that E inside grows as r³.
Find where E peaks for ρ = ρ0(1 − r/R), then sketch E against r.
Revise surface choice for wires and sheets with our Gauss's law problems guide.
Today, do example 2 from a blank page and check your peak at 2R/3.



