The corresponding source code is as follows. The first one is used to write formulas that are part of a text. If an equation is longer than one line or several formulas must be grouped together the eqnarray environment could be used.
It is therefore up to you to format the equation appropriately if they overrun the margin This typically requires some creative use of an eqnarrayto get elements shifted to a new line to align nicely.
L a T e X allows two writing modes for mathematical expressions. We can surpass these difficulties with amsmath. As you see the way the equations are displayed depends on the delimiter in this case and. You can force it by adding a minuscule amount of glue in-between the letters.