This paper discusses the discrete analogue of the gradient of a function an
d shows how discrete gradients can be used in the numerical integration of
ordinary differential equations (ODEs). Given an ODE and one or more first
integrals (i.e. constants of the motion) and/or Lyapunov functions, it is s
hown that the ODE can be rewritten as a 'linear-gradient system'. Discrete
gradients are used to construct discrete approximations to the ODE which pr
eserve the first integrals and Lyapunov functions exactly. The method appli
es to all Hamiltonian, Poisson and gradient systems, and also to many dissi
pative systems (those with a known first integral or Lyapunov function).