Z-shaped lever balance The goal is to find out whether a Z-shaped lever will fall over due to gravity.
See diagram below (sorry for MS Paint):

The bottom edge $x$ is resting on a flat surface. All three edges, $x$, $y$, and $z$, have uniform density per unit length ($\lambda_x$, $\lambda_y$, and $\lambda_z$), given in $\frac{kg}{m}$. This is a completely rigid/ideal structure with no friction.
My initial observation is the lever falls to the left when there is a non-zero torque about the bottom-left corner. Let's assume we don't have to worry about falling to the right.
The clockwise torque due to $x$ is:
$$\tau_x = F_gr$$
$$d\tau_x = (\lambda_x dr) * g * r$$
$$\tau_x = g\lambda_x\int_{0}^{|x|}rdr = \frac{1}{2}g\lambda_x|x|^2$$
The clockwise torque due to $y$ is similar but has $cos\theta$ to ignore the non-normal forces:
$$\tau_y = \frac{1}{2}g\lambda_y|y|^2cos\theta$$
The torque due to $z$ is where I'm having trouble. When $|z| > ycos\theta$, there seems to be both a clockwise and counterclockwise torque contribution. Also, the torque is transmitted "through" $y$, so I'm not sure how to account for that. I found a Wikipedia article on compound levers, but I couldn't figure out how to leverage it.
Once I figure out how compute the torque due to $z$, the following inequality should hold for stable levers:
$$\tau_x + \tau_y + \tau_z^{clockwise} > \tau_z^{counterclockwise}$$
But I'm not sure how to compute the $\tau_z$. Sorry if the question is kind of long. I couldn't find a shorter way to ask it.
 A: 

This is  a static problem.
sum of the torques about the z axis at point $A$ is zero.
$$\sum_{\tau_z}=
-\xi_{{1}}M_{{1}}-\xi_{{2}}\cos \left( \Theta \right) M_{{2}}- \left( 
-\xi_{{3}}+L_{{2}}\cos \left( \Theta \right)  \right) M_{{3}}
=0
\tag 1
$$ 
Where 
$M_i$ are the parts mass and 
$\xi_i$ are the center of masses in local coordinates 
With:
$$M_i=\int_0^{L_i} \lambda_i(x)\,dx$$
$$\xi_i=\frac{1}{M_i}\int_0^{L_i} \lambda_i(x)\,x\,dx$$
and $L_i$ are the parts length.
If you know the density per unit length $\lambda_i(x)$ then with equation (1)  you can calculate for a given $L_1\,,L_2$ and $\Theta$ the length of part three $L_3$  for a static equilibrium .
Example 
$\lambda_i(x)= x$
$L_1=1\,,L_2=2$ and $\Theta=\pi/3$
you get:   $L_3=2.32$ for a static equilibrium $\sum\tau=0$. 
thus: If $L_3$ is greater then 2.32 the Z-shaped lever will fall over.
A: You can simplify the question by splitting $z$ in two parts. The rightmost symmetric portion perfectly centered over the $xy$ corner (fulcrum), and then any excess to the left of that.
The former has length $L=2y\cos(\theta)$, contributes no net torque around $xy$ (It’s “perfectly balanced”) and thus can be ignored. The latter has length $z-L$, and contributes the full torque from $z$ (That is, $1/2z(z-L)\lambda_zg)$ counterclockwise - if I didn’t mess up the calculation in my head again). This works even if $z$ is “too short”, as long as you keep the signs straight.
This approach effectively transforms what you see as a problem of determining integral limits into a trivial problem of geometry. It yields the same formula, but it’s a lot easier to visualize.

An extra word of advice. To be honest, bringing up an explicit integral to approach the problem is overkill since the density of each segment (and g) is uniform. You can just work with a simple formula $\tau_n = \lambda_ng \times [\textit{horiz. distance from fulcrum to the center of n}]$ applied to each segment.
Even if you feel you need to use integrals (maybe your instructor requires you to), the use of absolute value makes the problem unnecessarily harder because you have to manually determine what’s on the right and what’s on the left of the fulcrum, and you have to get it right. Instead of viewing the integration limit as a “length” which is the strict physical sense, it can be viewed as a coordinate. Put the origin at the fulcrum at $xy$, suppress the absolute value - let it be negative if it needs to. Make an assumption where needed (and it doesn’t matter if the assumption is correct as long as you stay consistent), set signs according to those assumptions from the beginning, and let the algebra take its course. The integral will take care of sign changes in the middle which represent reversals of torque direction. That’s essentially what we did when saying “don’t worry if $z$ is too short the signs will take care of it”: if $z$ is too short, the segment will have negative “length” and the torque will automatically be reversed so it points in the correct direction. 
But it’s still overkill to use integrals with elements of constant density.
With practice you work out how to use the simplest tool available for the job, and to take advantage of symmetries to get rid of excess complications like we did with $z$ here.
A: Starting to calculate torques is complete overkill when answering this question. Just calculate the x coordinate of the center of mass $x_{cog}$, relative to the lower angle point. The result can fall into a total of five cases:


*

*$x_{cog}<0$ : It topples over to the left.

*$x_{cog}=0$ : Perfectly balanced in a semi-stable state.

*$0<x_{cog}<x$: The Z-shaped object stands stable.

*$x_{cog}=x$: Perfectly balanced in a semi-stable state.

*$x<x_{cog}$: It topples over to the right.
