Deriving demand function in case of multivariable utility functions with min and max structures Suppose I have utility function like this: $u(x_1,x_2,x_3)=min\{x_1,a-x_1\}\times min\{x_2,b-x_2\}+x_3$ where a and b are real numbers and $x_1\in [0, a]$ and $x_2\in [0,b]$. What will be a procedure of finding, for example, Marshallian demand $x(p,w)$?

My confusion: In case of more simple function without minimum or maximum structures I would simply use Lagrangian to define the demand. However, given function is not differentiable. 

My question: can I apply Lagrangian here and, if so, how can I do it? If it is impossible to use Lagrangian in this case, what else sholud I do?
It is possible to use a Lagrangian to obtain your Marshallian demands, provided you break each min function up into two different pieces and remain wary of boundary solutions. So for example, if you impose the condition $x_1&lt;\frac{a}{2}, x_2&lt;\frac{b}{2}$ you can simplify your utility function to $x_1 x_2 + x_3$, and then solve for Marshallian demands that are valid when this condition holds. Once you've obtained your demand for this piece it's good practice to re-state your condition as a function of the parameters (a, b, w, and $\textbf{p}$) Then go back to your original utility function, impose an alternative condition and repeat to get a different piece of the demand. The demand function will be piecewise (and in this case it seems like it'll consist of quite a few different pieces). Good luck!