2

enter image description here

\documentclass{article}


\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb}

\usepackage{soul}
\usepackage[dvipsnames]{xcolor}
\newcommand{\mathcolorbox}[2]{\colorbox{#1}{$\displaystyle #2$}}


\begin{document}

    \begin{align*}
        \binom n i p^i ( 1 - p )^{ n - i }
        & = \frac{ n! }{ i! ( n - i )! } \, p^i \, ( 1 - p )^{ n - i } \\
        & = \frac{ n! }{ \mathcolorbox{ProcessBlue}{ i! } ( n - i )! }
            \left ( \frac \lambda n \right )^i
            \left ( 1 - \frac \lambda n \right )^{ n - i } \\
        & = \mathcolorbox{YellowGreen}{ \frac{ n! }{  n^i ( n - i )! } }
            \frac{ \lambda^i }{ \mathcolorbox{ProcessBlue}{ i! } }
            \frac{ \mathcolorbox{Yellow}{ \left ( 1 - \frac \lambda n \right )^n }
            \to e^{ -\lambda } \text{ when } n \to +\infty }{
                \left \{ \left ( 1 - \dfrac \lambda n \right )^i \right \}
                \to 1 \text{ when } n \to +\infty } \\
        & = \mathcolorbox{Yellow}{ e^{ -\lambda } }
            \frac{ \lambda^i }{ i! }
            \mathcolorbox{YellowGreen}{
                \frac{ n ( n - 1 ) \cdots ( n - i + 1 ) }{ n^i } } \to 1
                \text{ when } n \to +\infty \\
        & = \frac{ \lambda^i }{ i! } e^{ -\lambda }
    \end{align*}

\end{document}

-Edit-

First off, coloring does not mean anything in particular. Only the right-most fraction inside the red box is relevant.

As you can see, the fraction line also spans over the \to e^{ -\lambda } \text{ when } n \to +\infty and \to 1 \text{ when } n \to +\infty comments; instead, I only want it to cover \left ( 1 - \frac \lambda n \right )^n and \left ( 1 - \frac \lambda n \right )^i

4
  • Welcome to TeX.SE. Both arguments of \frac are centered horizontally by default. Do please clarify what you mean by "shorten the fraction line so as to include only the two of them". And, please clarify what the significance of coloring some expressions in yellow, gree, and blue may be.
    – Mico
    Apr 15 at 16:15
  • 1
    The fraction line also spans over the comments to the right of the numerator and denominator, since they are included in the \frac argument. I want to keep the comments in more or less the same position, but outside the \frac command: these comments are the only thing that's different between numerator and denominator, so I guess taking care of them would also center the fraction arguments Other than the red box (of which you can ignore anything but the right-most fraction), coloring is not relevant
    – SkullHex2
    Apr 15 at 19:13
  • 1
    I'd start by putting only the actual fractions into the \frac component, and use \genfrac (from amsmath; see the user manual) for the comments. You'll have to adjust the vertical position of the comments; that can be done with \vphantom. Apr 15 at 19:40
  • @barbarabeeton This is probably what I'm looking for, unfortunately I can't get a satisfying result. The user manual says delimiters are optional, but without specifying them I get an error; also, the output of \genfrac is not (height-wise) aligned with either numerator or denominator (maybe because of coloring, which makes \frac higher than it actually is). No matter though, I can settle for @Mico's solution
    – SkullHex2
    Apr 15 at 22:16

1 Answer 1

1

Here's a solution with \overbrace and \underbrace directives.

enter image description here

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{mathtools, amssymb}

\begin{document}
\begin{align*}
\binom{n}{i} p^i ( 1-p )^{ n-i }
&= \frac{ n! }{ i! ( n-i )! } \, p^i \, ( 1-p )^{ n-i }\\
&= \frac{ n! }{  i  ( n-i )! }
            \left(   \frac{\lambda}{n}\right)^{\!i}
            \left( 1-\frac{\lambda}{n}\right)^{\!n-i} \\[\jot]
&=  \frac{ n! }{  n^i ( n-i )! } \,
    \frac{ \lambda^i }{  i! } \,
    \frac{ \overbrace{\left( 1 - \frac{\lambda}{n} \right)^{\!\!n}}%
            ^{\mathclap{\to e^{-\lambda} \text{ as } n\to\infty}} 
           }{
           \underbrace{\left( 1 - \frac{\lambda}{n} \right)^{\!\!i}}%
            _{\mathclap{\to 1 \text{ as } n\to\infty}}
                 } \\[\jot]
&=  e^{ -\lambda } \,
    \frac{ \lambda^i }{ i! } \,
    {\underbrace{\frac{ n (n-1) \dotsb(n-i+1) }{ n^i }}%
     _{\to 1\text{ as } n \to \infty}} \\
&= \frac{ \lambda^i }{ i! }\, e^{-\lambda }
\end{align*}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .