Struggling with uncompensated/compensated demand

I'm working on a problem set for my intermediate microeconomics course, but I'm having trouble deriving the compensated and uncompensated demand functions. This is the utility function:

$U(x, y, z) = aln(x) + bln(y) + z$, with goods $x$, $y$, $z$ and income $I$. I found the following optimal values:

$x = (P_z/P_x)a$, $y = (P_z/P_y)b$, $z = (I/P_z) - a - b$

Even though I followed the steps, I'm not completely sure this is right. Moreover, I have to find cross price effects and both the compensated and uncompensated demand functions, but I'm having some serious trouble solving this problem.

First, we want to find the optimal good baskets, ie how much to buy of goods $x$,$y$ and $z$ to get the maximum value of U out of it.

Let's write down the $MRS$ for $x$ and $y$ against $z$. For this we need to differentiate the utility function for each of the variables: $d_xU(x,y,z)=a/x$ , $d_yU(x,y,z)=b/y$,$d_zU(z,y,z)=1$. We hence deduce the rates of substitution to be $-1a/x$ and $-b/y$ respectively.

So we have: $p_x/p_z=a/x$ and $p_y/p_z=b/y$

The budget constraint is $p_xx+p_yy+p_zz=I$ which we rewrite $p_x(ap_z/p_x)+p_y(bp_z/p_y)+p_zz=I$, which simplfies in $ap_z+bp_z+zp_z=I$

$z^*=(I/p_z)-a-b$

$(x^*,y^*,z^*)=(ap_z/p_x, bp_z/p_y,(I/p_z)-a-b)$

Good news, you were right :).

The cross price effect is the rise of demand in good $x$ following a rise in the price of good $z$. Just calculate the difference between $x^*$ for $p_z$ and $x^*$ for $p_z'=p_z+\epsilon$ (using $x^*=ap_z/p_x$).

Finally, the six curves asked are how demand change when price change holding income ($I$) constant, or utility ($U$) constant. Draw same by taking two prices fixed for each situation.

Hi don't forget that there is a possibility of corner solution as consumer's problem is: \begin{matrix} max_{x,y,z}U(x,y,z)=aln(x)+bln(y)+z &\text{subject to} & xp_x+yp_y+zp_z=I, & x,y>0, & z\geq 0 \end{matrix}. With FOCs, \begin{matrix} \frac{ay}{bx}=\frac{p_x}{p_y}, &\frac{a}{x}=\frac{p_x}{p_z}, &\frac{b}{y} =\frac{p_y}{p_z}. \end{matrix} Now this condition is valid iff $$\frac{I}{p_z}\geq (a+b)$$ otherwise the consumer"s problem reduces to optimal choice between good x and good y i.e. \begin{matrix} max_{x,y}U(x,y)=aln(x)+bln(y) &\text{subject to} & xp_x+yp_y=I, & x,y>0 \end{matrix}. With FOCs, $$\frac{ay}{bx}=\frac{p_x}{p_y}$$ By the above info the demand function (Uncompensated demand function) of this consumer is: $$(x,y,z)(p_x,p_y,p_z,I)=\begin{cases} \left ( \frac{ap_z}{p_x},\frac{bp_z}{p_y},\frac{I}{p_z}-a-b \right ), & \text{ if } \frac{I}{p_z}\geq (a+b), \\ \left ( \frac{Ia}{(a+b)p_x},\frac{Ib}{(a+b)p_y},0 \right )& \text{ otherwise. } \end{cases}$$