Without knowing the viewing capacity of the eye, the only answer you can give is a function of the optimal viewing distance as the maximal viewing angle changes.
let be the angle of elevation from eye level to the bottom of the painting.
let be the angle from the bottom of the painting to the top of the painting, i.e. the viewing angle.
let x be the horizontal distance to the wall in meters.
then ...
so ...
setting = 0 yields the equation ...
solve for x ...
meters