What's the fundamental difference between Diffie-Hellman and RSA? What is the difference in the purpose of DH and RSA?  Aren't they both public-key encryption?
The difference is subtle.
DH is used to generate a shared secret in public for later symmetric ("private-key") encryption:


  Diffie-Hellman:
  
  
  Creates a shared secret between two (or more) parties, for symmetric cryptography
  Key identity: (gens1)s2 = (gens2)s1 = shared secret  &nbsp; (mod prime)
  Where:
  
  
  gen is an integer whose powers generate all integer in [1, prime)  &nbsp; (mod prime)
  s1 and s2 are the individuals' "secrets", only used to generate the symmetric key
  
  


RSA is used to come up with a public/private key pair for asymmetric ("public-key") encryption:


  RSA:
  
  
  Used to perform "true" public-key cryptography
  Key identity: (me)d = m  &nbsp;&nbsp;(mod n)  &nbsp;&nbsp;(lets you recover the encrypted message)
  Where:
  
  
  n = prime1 × prime2  &nbsp;&nbsp; (n is publicly used for encryption)
  φ = (prime1 - 1) × (prime2 - 1)   &nbsp;&nbsp;(Euler's totient function)
  e is such that 1 &lt; e &lt; φ, and (e, φ) are coprime  &nbsp;&nbsp;&nbsp;(e is publicly used for encryption)
  d × e = 1  &nbsp; (mod φ)  &nbsp;&nbsp;&nbsp;(the modular inverse d is privately used for decryption)
  
  


It just so happens that -- in practice -- RSA's results are subsequently used to generate a symmetric key.
Furthermore, it also happens that you can also modify DH to be used for public-key encryption.
But they are fundamentally different, even though both of them have "public" and "private" components.