Intertemporal consumption question This question is driving me nuts. 

Suppose, an individual lives for two periods. In each period she consumes only one good,which is rice. In period 2, she can costlessly produce 1 unit of rice, but inperiod 1 she produces nothing. However, in period 1 she can borrow rice at
an interest rate $r$ > 0. That is, if she borrows $z$ units of rice in period 1,
then in Period 2, she must return $z(1 + r)$ units of rice. Let $x_1$ and $x_2$ denote her consumption of rice in period 1 and period 2, respectively; $x_1$, $x_2$ ≥ 0. Her utility function is given by $$U(x_1, x_2) = x_1 + βx_2$$, where β is the discount factor, 0 &lt; β &lt; 1. Note that there are only two sources through which rice can be available; own production and borrowing.

Now suppose that there are N agents in the above two period
economy. The agents are identical (in terms of production and utility
function) except that they have different discount factors. Suppose that
β follows uniform distribution in the interval [ 1/2, 1]. Assuming r ≤ 1, what would be the demand function for rice in period 1?

My approach is integrating $\beta$ from 1/2 to $\frac{1}{1+r}$, and my answer comes out to be $\frac {N(1-r)} {1+r}$, but I dont think that's right.
Due to the linearity of the utility function the utility maximization problem for individual $i$ has either one of the two corner solutions, or it is indeterminate.  

The individual $i$ has to solve the following problem

$$\max_{x_{1i},x_{2i}}[ x_{1i} + \beta_i x_{2i}]$$

$$s.t. x_{2i} = 1-(1+r)x_{1i}, \;\;x_{1i} \geq 0,\;\;x_{2i} \geq 0 $$
Solvency is also imposed -i.e. the individual cannot borrow in the first period more than what he can repay in the second period (including interest).

One can deduce that

$$\text {"flatter" budget constraint:}\;\; -(1+r) &gt; -\beta_i^{-1}   \implies \{x_{1i}^* = (1+r)^{-1},\;\;x_{2i}^* = 0\} $$

$$\text {"steeper" budget constraint:}\;\; -(1+r) &lt; -\beta_i^{-1}  \implies  \{x_{1i}^* = 0,\;\;x_{2i}^* = 1\}$$

.."steeper" and "flatter" with respect to the utility (linear) indiference map, and with $x_{2i}$ in the vertical axis.



Working the implied inequalities we re-write the solution as

$$\beta_i &lt; \frac 1{1+r} \implies \{x_{1i}^* = (1+r)^{-1},\;\;x_{2i}^* = 0\}$$

$$\beta_i &gt; \frac 1{1+r} \implies \{x_{1i}^* = 0,\;\;x_{2i}^* = 1\}$$

In the $N$-identical individuals case, and with $\beta_i, i=1,...,N$ being a random variable we can only talk about expected demand in the first period, denote it $E(d_{1i})$ for the individual and $E(D_1) = N\cdot E(d_{1i})$ on aggregate.

We have

$$E(d_{1i}) = \frac 1{1+r} \cdot \Pr\left[\beta_i &lt; \frac 1{1+r}\right] + 0 \cdot \Pr\left[\beta_i &gt; \frac 1{1+r}\right] $$

The second term vanishes.

Given the assumptions on the distribution of the $\beta$'s its density function over the domain is $f(\beta_i) =2$ and so the remaining probability is (as long as $r \leq 1$)

$$\Pr\left[\beta_i \leq \frac 1{1+r}\right] = \int_{1/2}^{(1+r)^{-1}}2{\rm d}\beta_i = 2\left(\frac 1{1+r}-\frac 12\right) = \frac {1-r}{1+r}$$

and so we have

$$E(D_1) = \frac N{1+r}\cdot \frac {1-r}{1+r} = \frac {1-r}{(1+r)^2}N$$

which is decreasing in $r$.

If $r$ hits unity, expected demand will be zero -because
a) It would place a solvency ceiling to loan demand to be not higher than $1/2$ so that with interest rate $100\%$ all production of the second period would then be needed to repay the loans. This means that with $r=1$, maximum consumption (and utility) in the first period will not exceed $1/2$.
b) the discount factor being greater or equal than $1/2$, implies that by taking zero loan in the first period, one would enjoy the full unitary production of the second period, with utility higher than $1/2$. So for non-zero demand for loans in the first period, it must be the case that this demand can exceed $1/2$. When $r\geq 1$ it cannot, hence the zero expected demand. 

Note: if instead of a "stochastic distribution" of the $\beta$'s we think of a "uniform allocation" of them in the $[1/2,1]$ interval, then we can think of expected demand as deterministic demand.