This sounds a lot like a homework problem, but I'll give you the following pointers:
- This is equivalent to finding the largest eigenvalue of D.
- A standard way of solving this problem is to use the "power method" which is documented here: wikipedia entry
- The perl module PDL is useful for performing matrix operations.