I'm assuming a perfect right angle. The other piece of information needed is the radius of the outside curve of the bend in the rod. Here is a picture of the situation that limits the length of the tube:
View attachment 9795
I won't go into the specifics of the geometry, but the length that will fit is minimum at this 45 degree orientation, so any length greater than this (4.41 as shown) will not fit around the bend. (My drawing uses units of eighths of an inch, so my diameter is 3/8 and my length is 4.41/8 = .55125"; I supposed the bend radius to be 3/16" for the drawing. The thickness of the tube and the inside radius of the bend don't matter, so they aren't shown.)
Taking L = tube length, D = tube I.D., d = rod O.D., and r = bend radius, it is not hard to determine that
\(\displaystyle D = L/2 + d\sqrt{2} - (\sqrt{2}-1)r\)
and solving for L gives
\(\displaystyle L = 2D - 2d\sqrt{2} + 2(\sqrt{2}-1)r\)
which is the formula you want. (Of course, practical matters may require increasing this a little to make sure it can't squeeze by because edges are a little rounded or something.)
For our example, with D = 3/8, d = 1/8, and r = 3/16, the formula gives
\(\displaystyle L = 2(3/8) - 2(1/8)\sqrt{2} + 2(\sqrt{2}-1)(3/16) = 0.55178\)
agreeing with my picture.