Solutions of numerous equations of mathematical physics such as elliptic, weakly singular, singular, hypersingular integral equations belong to functional classes \(\bar Q^u_{r \gamma}(\Omega,1)\) and \(Q^u_{r \gamma}(\Omega,1)\) defined over \(l-\)dimensional hypercube \(\Omega=[-1,1]^l, l=1,2,....\) The derivatives of classes' representatives grow indefinitely when the argument approaches the boundary \(\delta \Omega\). In this paper we estimate the Kolmogorov and Babenko widths of two functional classes \(\bar Q^u_{r \gamma}(\Omega,1)\) and \(Q^u_{r \gamma}(\Omega,1).\) We construct local splines belonging to those classes, such that the errors of approximation are of the same order as that of the estimated widths. Thus we construct optimal with respect to order methods for approximating the functional classes \(\bar Q^u_{r \gamma}(\Omega,1)\) and \(Q^u_{r \gamma}(\Omega,1).\) One can use these results for constructing methods optimal with respect to order for approximating a unit ball of the Sobolev spaces with logarithmic and polynomial weights.