  We derive a formalism of numerical relativity for higher-dimensional
spacetimes and develop numerical codes for simulating a wide variety of
five-dimensional (5D) spacetimes for the first time. First, the
Baumgarte-Shapiro-Shibata-Nakamura formalism is extended for arbitrary
spacetime dimensions $D \ge 4$, and then, the so-called cartoon method, which
was originally proposed as a robust method for simulating axisymmetric 4D
spacetimes, is described for 5D spacetimes of several types of symmetries.
Implementing 5D numerical relativity codes with the cartoon methods, we perform
test simulations by evolving a 5D Schwarzschild spacetime and a 5D spacetime
composed of a gravitational-wave packet of small amplitude. The numerical
simulations are stably performed for a sufficiently long time, as done in the
4D case, and the obtained numerical results agree well with the analytic
solutions: The numerical solutions are shown to converge at the correct order.
We also confirm that a longterm accurate evolution of the 5D Schwarzschild
spacetime is feasible using the so-called puncture approach. In addition, we
derive the Landau-Lifshitz pseudo tensor in arbitrary dimensions, and show that
it gives a robust tool for computing the energy flux of gravitational waves.
The formulations and methods developed in this paper provide a powerful tool
for studying nonlinear dynamics of higher-dimensional gravity.
