def tabulate(potential, parameters, cutoff='c', rc=2.5, npoints=10000, rmin
    =0.5, fmt='lammps', metadata='', fileout=None, precision=14):
    """Tabulate a potential."""
    from atooms.core.utils import tipify
    from atooms.interaction.potential import PairPotential
    from atooms.interaction.cutoff import CutOff
    if isinstance(parameters, dict):
        param_dict = parameters
    else:
        param_dict = {}
        for param in parameters.split(','):
            key, value = param.split('=')
            param_dict[key] = tipify(value)
    potential = PairPotential(potential, param_dict, (1, 1))
    if cutoff is not None:
        potential.cutoff = CutOff(cutoff, rc)
    rsq, u0, u1, u2 = potential.tabulate(npoints, rmin=rmin, what='uwh')
    r = rsq ** 0.5
    if fmt == 'lammps':
        u1 *= r
        txt = '\n\nPOTENTIAL\nN {}\n\n'.format(len(rsq))
        i = 1
        for x, y, z in zip(r, u0, u1):
            txt += '{} {} {} {}\n'.format(i, x, y, z)
            i += 1
    elif fmt == 'uwh':
        txt = '# {} columns: r, u, w, h\n'.format(metadata)
        for x, y, z, w in zip(r, u0, u1, u2):
            txt += '{:.14g} {:.14g} {:.14g} {:.14g}\n'.format(x, y, z, w)
    else:
        u1 *= r
        txt = '# {} columns: r, u, f\n'.format(metadata)
        for x, y, z in zip(r, u0, u1):
            txt += '{} {} {}\n'.format(x, y, z)
    if fileout is None:
        return txt
    else:
        with open(fileout, 'w') as fh:
            fh.write(txt)
