  This paper is concerned with the two--phase obstacle problem, a type of a
variational free boundary problem. We recall the basic estimates of Repin and
Valdman (2015) and verify them numerically on two examples in two space
dimensions. A solution algorithm is proposed for the construction of the finite
element approximation to the two--phase obstacle problem. The algorithm is not
based on the primal (convex and nondifferentiable) energy minimization problem
but on a dual maximization problem formulated for Lagrange multipliers. The
dual problem is equivalent to a quadratic programming problem with box
constraints. The quality of approximations is measured by a functional a
posteriori error estimate which provides a guaranteed upper bound of the
difference of approximated and exact energies of the primal minimization
problem. The majorant functional in the upper bound contains auxiliary
variables and it is optimized with respect to them to provide a sharp upper
bound. A space density of the nonlinear related part of the majorant functional
serves as an indicator of the free boundary.
