The Amplitude Equation for the Rosensweig Instability in Magnetic Fluids and Gels