  We study the connection between the magnetization profiles of models
described by a scalar field with marginal interaction term in a bounded domain
and the solutions of the so-called Yamabe problem in the same domain, which
amounts to finding a metric having constant curvature. Taking the slab as a
reference domain, we first study the magnetization profiles at the upper
critical dimensions $d=3$, $4$, $6$ for different (scale invariant) boundary
conditions. By studying the saddle-point equations for the magnetization, we
find general formulas in terms of Weierstrass elliptic functions, extending
exact results known in literature and finding new ones for the case of
percolation. The zeros and poles of the Weierstrass elliptic solutions can be
put in direct connection with the boundary conditions. We then show that, for
any dimension $d$, the magnetization profiles are solution of the corresponding
integer Yamabe equation at the same $d$ and with the same boundary conditions.
The magnetization profiles in the specific case of the $4$-dimensional Ising
model with fixed boundary conditions are compared with Monte Carlo simulations,
finding good agreement. These results explicitly confirm at the upper critical
dimension recent results presented in [1].
