How to write a function (piecewise) with bracket outside?

This situation is exactly what the cases environment from the amsmath package was designed for. If you put

\usepackage{amsmath}

in your preamble then you can wite

\[ \begin{cases} 
      0 & x\leq 0 \\
      \frac{100-x}{100} & 0\leq x\leq 100 \\
      0 & 100\leq x 
   \end{cases}
\]

to adapt your example with the correct size bracket.


As for not being able to use TeX-like syntax to write equations on this site: this is a deliberate choice. Most of the time we actually want to talk about the TeX source here rather than the equations (or whatever) it produces; and there are times when it could be actively confusing to have a TeX-like process to produce images that isn't actually TeX (in its full, Turing-complete, confusing glory...)

(See the discussion on meta for more on this, if you're interested.)


I generally prefer using the cases environment of the amsmath package for such cases (pun intended). However, it's also possible to achieve the result you're after by changing the MWE you provide fairly minimally -- mainly by changing \{ to \left\{ and adding a \right. instruction at the end of the array environment. Note that it's only necessary to have one array, rather than two nested array environments.

\documentclass{article}
\begin{document}
\[   \left\{
\begin{array}{ll}
      0 & x\leq a \\
      \frac{x-a}{b-a} & a\leq x\leq b \\
      \frac{c-x}{c-b} & b\leq x\leq c \\
      1 & c\leq x \\
\end{array} 
\right. \]
\end{document}

enter image description here

(Note that I've also changed the alignment indicator for each of the array's columns from c to l.)

As you can tell from the image, the spacing between lines is rather tight, because of the fraction terms in the first column. If you think this is a problem, you can always add a bit of extra vertical space by appending [0.5ex] to the first and third \\ commands, and [1ex] to the second. (These options to the "newline" commands instruct TeX how much extra space to insert.) The result of adding the extra vertical spacing will look like this:

enter image description here


I think that in this case also the use of dcases can be recommended. It can be found in the mathtools package. Someone may prefer to have the arguments of the cases environment to be typeset in display style.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
    \begin{dcases}
        0 & x\leq a \\
        \frac{x-a}{b-a} & a\leq x\leq b \\
        \frac{c-x}{c-b} & b\leq x\leq c \\
        1 & c\leq x \\
    \end{dcases}
\]
\end{document}

Here's the difference between the two (top:dcases, bottom:cases):

enter image description here