  We present a conjugate gradient method for calculating the entanglement of
formation of arbitrary mixed quantum states of any dimension and with any
bipartite division of the Hilbert space. The development of the gradient used
by the algorithm, its implications for the number of states required in the
optimal decomposition, and the way that conjugate gradient minimization has
been adapted for this particular problem are outlined. We have found that the
algorithm exhibits linear convergence for general mixed states, and that it
correctly reproduces the known results for pairs of qubits and for isotropic
states. The results of an example application of the code are discussed:
calculating the entanglement of formation of a Psi+ Bell state of two qutrits
when one of those qutrits is subject to various decoherence channels. The
results for qutrits are contrasted with those for qubits: for the types of
decoherence considered here, qutrit entanglement appears to be more robust than
qubit entanglement.
