Boundary value problems for Hamilton-Jacobi equations with discontinuous lagrangian

We consider a class of Hamilton-Jacobi equations with discontinuous coefficients that contains as examples the eikonal equation with discontinuous refraction index and the Hamilton-Jacobi equation of shape-from-shading with discontinuous intensity function. We prove optimality principles for viscosity solutions and apply them to obtain necessary and sufficient conditions for uniqueness of the solution of the boundary value problem, and to characterize the minimal and the maximal solutions when uniqueness fails. Explicit uniqueness results are also given and we discuss existence of almost everywhere solutions.