Abstract The aim of this work is to analyze the possibility of optimizing an abstract, symmetrical with respect to the north–south axis form of a building with vertical walls and windows, and constant volume and height. The external south partitions of the building are walls with whole windowpanes. The heat losses through walls, floors, roof and the gain of solar radiation through transparent partitions with respect to their direct correlation with the shape of building form are next taken into consideration. The gain of solar energy for the north part of the building have been disregarded. The optimization problem of the form of the building on an oval base is examined by variational methods taking into account two opposite criteria: • minimum construction costs including the cost of materials and erection, • minimum seasonal demand for heat energy. The obtained solution is composed of the semicircular bounding of the northern part of the building and a curve of the southern part described by a parametrical function. The design is also compared with the buildings on square and circular bases. The calculations have been performed using specially prepared computer program and illustrated by a numerical example.