We want a real image on the wall. We keep the lens in between the two walls, horizontally at level with the bulb.

let u is -ve as per sign convention, v is positive. and f is positive. Let u = - U.

=> v + U = 3 meters

=> v and U are between 0 and 3 meters.

1/f = 1/v - 1/u = 1/v + 1/U = (v+U)/ (vU) = 3 / ( v U )

f = U v / 3 = U (3 - U) / 3 = U - U²/3

f is maximum or minimum when d f / dU = 0,

=> df/dU = 1 - 2/3 U = 0 => U = 3/2 meter = 1.5 meters.

Since df/dU > 0 for U < 3/2 and df/dU < 0 for U > 3/2 m, focal length f is maximum for u = - 1.5 meters. That is when the focal length is half the distance between the screen and the object.