Max Utility Function and Finding associated demand curve I have a max utility function, therefore;
U(x,y)= max(2x,y)
and I am trying to find the demand function x = x(x , y , ), note this function cannot be differentiated. I am familiar that the utility function states that it is best to have x=0 and all of the good y, or vice versa. So I've been trying to solve with the budget line making one x=0 and then again y=0 but I am unsure what to do from this point?

Working so far:
p1x+p2y=M
when y=0
x=m/p1
U= 2m/p1

&amp;
when x=0
y=m/p2
U= m/p2

So now I have two equations in terms of U
From your formula for $x$ when $y=0$, you should be able to find $U$ in terms of $M$ and $p_x$ when $y=0$.  Similarly, $U$ in terms of $M$ and $p_y$ when $x=0$.  The key then is to find the critical price ratio at which, to maximise $U$, the switch needs to occur from $y=0$ to $x=0$.

Can you take it from there?