Home » Blog » Calculate the values of an integral of a step function

Calculate the values of an integral of a step function

For p \in \mathbb{Z}_{>0} define a step function on the interval [0,p] by

    \[ s(x) = \begin{cases} (-1)^n \cdot n & \text{if } n \leq x < n+1, \ n=0,1, \ldots, p-1 \\ 0 & \text{if } x =p. \end{cases} \]

Then, define

    \[ f(p) = \int_0^p s(x) \, dx. \]

  1. Calculate f(3), f(4), f(f(3)).
  2. Find all values of p such that |f(p)| = 7.

  1. We calculuate:

        \begin{align*} f(3) &= \int_0^3 s(x) \, dx = (-1)^0 0 (1-0) + (-1)^1 (1) (2-1) + (-1)^2 (2)(3-2) = 0 - 1 + 2 &= \phantom{-}1.\\ f(4) &= \int_0^4 s(x) \, dx = \int_0^3 s(x) \, dx + \int_3^4 s(x) \, dx = 1 + (-1)^3 (3) (4-3) &= -2. \\ f(f(3)) &= f(1) = \int_0^1 s(x) \, dx = (-1)^0 0 (1-0) &= \phantom{-}0. \end{align*}

  2. p = 14,15.

Note: There is an error in the book. The answers in the back of the book claim that f(4) = -1, which is incorrect.

4 comments

    • Anonymous says:

      You can solve it pretty fast just by a little inspection, you can see pretty fast for witch value of p, the sum -1 + 2 -3 + …… + s(p-1) = 7 (absolute value)

    • From the integrals you can observe that this formula follows a recursive pattern, which is f(n) = f(n - 1) + (-1)^{(n - 1)} (n - 1). Then you can code this function in your favourite programming language and enter a while loop to find out for which p‘s you get f(p) = 7 or f(p) = -7.

Point out an error, ask a question, offer an alternative solution (to use Latex type [latexpage] at the top of your comment):