  Knowledge of the structure of the coronal magnetic field is important for our
understanding of many solar activity phenomena, e.g. flares and CMEs. However,
the direct measurement of coronal magnetic fields is not possible with present
methods, and therefore the coronal field has to be extrapolated from
photospheric measurements. Due to the low plasma beta the coronal magnetic
field can usually be assumed to be approximately force free, with electric
currents flowing along the magnetic field lines. There are both observational
and theoretical reasons which suggest that at least prior to an eruption the
coronal magnetic field is in a nonlinear force free state. Unfortunately the
computation of nonlinear force free fields is way more difficult than potential
or linear force free fields and analytic solutions are not generally available.
We discuss several methods which have been proposed to compute nonlinear force
free fields and focus particularly on an optimization method which has been
suggested recently. We compare the numerical performance of a newly developed
numerical code based on the optimization method with the performance of another
code based on an MHD relaxation method if both codes are applied to the
reconstruction of a semi-analytic nonlinear force-free solution. The
optimization method has also been tested for cases where we add random noise to
the perfect boundary conditions of the analytic solution, in this way mimicking
the more realistic case where the boundary conditions are given by vector
magnetogram data. We find that the convergence properties of the optimization
method are affected by adding noise to the boundary data and we discuss
possibilities to overcome this difficulty.
