Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

A Integrating definite Heaviside function

  1. Oct 12, 2016 #1
    I am trying to integrate the following triple integral, which has a heaviside function in the inner most integral:

    $$ \frac{16}{c_{4}^{4}} \int_{0}^{c_{4}} c_{3}dc_{3} \int_{c_{3}}^{c_{4}} \frac{dc_{2}}{c_{2}} \int_{0}^{c_{2}}f(x)\left ( 1-H\left ( x-\left ( c_{4}-a \right ) \right ) \right )dx $$

    where f(x)=x. I know ##c_{2}>0, c_{3}>0 , c_{4}>0, x>0 , a>0 ,$c_{4}>a##

    I get the right answer (which I know already) using symbolic integration and the heaviside function in Matlab, which is:


    However, it is not clear to me how to do this manually? I would like to know because I need to integrate this numerically for cases where f(x) is a more complicated function.

    Many thanks in advance!
    Last edited by a moderator: Oct 12, 2016
  2. jcsd
  3. Oct 12, 2016 #2


    User Avatar
    Homework Helper

    As with any function defined by different formulae on different subdomains, you need to integrate over each subdomain separately. Thus [tex]
    \int_a^b f(x)~(1 - H(x - c))\,dx = \begin{cases}
    0 & c \leq a, \\
    \int_a^c f(x)\,dx & a < c \leq b, \\
    \int_a^b f(x)\,dx & b < c. \end{cases}[/tex]
  4. Oct 12, 2016 #3
    Thanks for the reply. Unfortunately, this still doesn't seem to be giving me the right answer...? It is always true that ## a<c \leq b ## .

    $$ \frac{16}{c_{4}^{4}} \int_{0}^{c_{4}} c_{3}dc_{3} \int_{c_{3}}^{c_{4}} \frac{dc_{2}}{c_{2}} \int_{0}^{c_{4}-a}f(x)dx $$

    This gives me, upon my attempt at integration,

    $$ 2 \frac{a^{2}}{{c_{4}}^2} - 4\frac{a}{c_{4}} + 2 $$

    which unfortunately is not the same as the literature answer.
  5. Oct 15, 2016 #4


    User Avatar
    Homework Helper

    You can, of course, do the entire thing numerically because your integrand is just [tex]
    f(x)(1 - H(x - (c_4 - a))) = \begin{cases} f(x), & 0 < x < c_4 - a \\
    0, & c_4 - a \leq x < c_2\end{cases}[/tex] which is no more difficult to evaluate numerically than [itex]f(x)[/itex] itself.

    Doing it manually requires us always to check where the limits of the integral fall in relation to [itex]c_4 - a[/itex], which given your constraints must lie between 0 and [itex]c_4[/itex], ie. within the limits of the outermost integral and therefore conceivably within the limits of the inner integrals.

    Thus for [itex]f(x) = x[/itex] we find that the innermost integral is [tex]
    \int_0^{c_2} x(1 - H(x - (c_4 - a)))\,dx = \frac12 \min\{(c_4 - a)^2, c_2^2\}.[/tex] The next integral out is then [tex]
    \int_{c_3}^{c_4} \frac{1}{2c_2} \min\{(c_4 - a)^2, c_2^2\}\,dc_2.[/tex] Hence if [itex]c_3 < c_4 - a[/itex] then [tex]
    \int_{c_3}^{c_4} \frac{1}{2c_2} \min\{(c_4 - a)^2, c_2^2\}\,dc_2 =
    \int_{c_3}^{c_4 - a} \frac{1}{2c_2} c_2^2\,dc_2 + \int_{c_4 - a}^{c_4} \frac{1}{2c_2} (c_4 - a)^2\,dc_2 \\ =
    \frac14 ((c_4 - a)^2 - c_3^2) + \frac{(c_4 - a)^2}{2} \log \left( \frac{c_4}{c_4 - a}\right)
    [/tex] but if [itex]c_4 - a < c_3[/itex] then [tex]
    \int_{c_3}^{c_4} \frac{1}{2c_2} \min\{(c_4 - a)^2, c_2^2\}\,dc_2 = \frac{(c_4 - a)^2}{2} \log \left( \frac{c_4}{c_3}\right).[/tex] Now we can do the outermost integral which is [tex]
    \frac{16}{c_4^4} \int_0^{c_4 - a} \frac{c_3}4 ((c_4 - a)^2 - c_3^2) + \frac{c_3(c_4 - a)^2}{2} \log \left( \frac{c_4}{c_4 - a}\right)\,dc_3 +
    \frac{16}{c_4^4} \int_{c_4 - a}^{c_4}\frac{c_3(c_4 - a)^2}{2} \log \left( \frac{c_4}{c_3}\right)\,dc_3.[/tex]
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted