I am trying to put a restriction on the limit of integration. I tried "Assumptions->" and Assuming[(){Refine[]}], but it doesn't work.. The integral I have is the following:


which gives $-0.0638021+0.765625p-1.91406p^2+1.78646p^3-0.574219p^4$. It is also true that $0<p<v<1$. My problem here is that $1.75p-0.75v$ is a straight line and if I were to construct it on domain $[1,1]$ then it would cross the horizontal v-axis at point $[1,0]$ when $1.75p-0.75=0$ or $p=0.43$. So when I integrate and $p>0.43$ there is no problem because it does not cross the v-axis. However, when $p<0.43$ it does cross it and since it is bounded by zero from below the function right to the $v$ value at which it crosses the v-axis just becomes a straight line on top of the v-axis. So when I integrate I have to consider this segment as well which adds another integral. So I guess my ultimate question is this: is it possible to place a restriction on $p$ ? Say if $p>0.43$ then my function is of this form, because if $p<0.43$ I will actually have another function...

Would appreciate any help! Thanks.

  • 1
    $\begingroup$ I am pretty sure that Mathematica can give you a general result valid for all $p$ and $v$. You can then plug in appropriate values. By the way, in your notation it is a bit ambiguous which integration variable belongs to which integration boundary. Additionally, you should post your question in Mathematica notation. That would allow others to copy paste it more quickly to look at it in Mathematica. That would increase the probability to get an answer. $\endgroup$
    – Kagaratsch
    Apr 30, 2017 at 19:43
  • $\begingroup$ Thanks for the suggestion, I have redone it, it's my first question about Mathematica :) The problem with general solution is that if you integrate it you will see that the first term is negative and does not depend on either $v$ or $p$...So I am wondering how legit would it be to just cut the function based on, say, if I want my $p>0.5$ ? $\endgroup$
    – Kvadich
    Apr 30, 2017 at 20:06
  • $\begingroup$ You could use Boole perhaps $\endgroup$ Apr 30, 2017 at 20:18
  • $\begingroup$ You may get better results with 7/4 and 3/4 instead of 1.75 and 0.75. If you know what the region of integration looks like, you can check your limits with ImplicitRegion and RegionPlot3D. When the visualization looks right, you can use the region directly in Integrate[], instead of individual limits. $\endgroup$
    – LouisB
    Apr 30, 2017 at 21:00

1 Answer 1


The expression you want to consider under a condition is

cnd = 7/4 p - 3/4 v;

Also, currently your integration in v is from p to 1, so I assume that p<1. In case if p<0 and v>0 we have cnd<0, so this region may not contribute. Similarly, if p<0 and v<0 we still have Abs[p]>Abs[v] so that cnd<0 and this region may not contribute either. What remains is the region 1>p>0. In this case cnd>0 only as long as v<7/3 p, which means that in order to restrict to the region where cnd>0, all we need to do is reduce the upper integration border for v such that

result = Integrate[y, {v, p, Min[7/3 p, 1]}, {x, 7/4 p - 3/4 v, v}, {y, 7/4 p - 3/4 v, x}]

-(49/768) (p - Min[1, (7 p)/3])^3 (9 p - Min[1, (7 p)/3])

which is valid for any 1>p>0. It does look kind of interesting when you plot it:

Plot[result, {p, 0, 1}]

enter image description here

The kink happens at p=3/7, where the integral has its maximal value




If you don't feel like doing all the work to consider the different regions yourself, you can of course add a HeavisideTheta step function to the integrand, which will set the integrand to zero whenever cnd<0:

result2 = Assuming[p \[Element] Reals, 
                y HeavisideTheta[cnd]
             , {v, p, 1}, {x, 7/4 p - 3/4 v, v}, {y, 7/4 p - 3/4 v, x}]

(1/62208)49 (-81 (-1 + p)^3 (-1 + 9 p) HeavisideTheta[-1 + p] + HeavisideTheta[1 - p] HeavisideTheta[p] (1280 p^4 - (-3 + 7 p) (-27 + p (261 + p (-201 + 287 p))) HeavisideTheta[-1 + (7 p)/3]))

The result now looks a bit more complicated, but you can i.e. plot it and see that it describes exactly the same function as the previous one.


OK, if I understood your question correctly now, you want to actually set 7/4 p - 3/4 v to 0 whenever it gets negative. For this consider first integrating out x and y:

intv = Integrate[ y, {x, Max[7/4 p - 3/4 v, 0], v}, {y, Max[7/4 p - 3/4 v, 0], x}]

1/6 (v - Max[0, (7 p)/4 - (3 v)/4])^2 (v + 2 Max[0, (7 p)/4 - (3 v)/4])

Now only integration in v remains. We can split it into two subregions of integration:

intv1 = Assuming[v < 7/3 p, intv // FullSimplify]

49/192 (p - v)^2 (7 p - v)


intv2 = Assuming[v > 7/3 p, intv // FullSimplify]


Integrating the two subregions separately and summing the result:

result3 = Integrate[intv1, {v, p, Min[7/3 p, 1]}] + Integrate[intv2, {v, Min[7/3 p, 1], 1}]

-((147 p^4)/256) + 343/192 p^3 Min[1, (7 p)/3] - 245/128 p^2 Min[1, (7 p)/3]^2 + 49/64 p Min[1, (7 p)/3]^3 - 49/768 Min[1, (7 p)/3]^4 + 1/6 (1/4 - 1/4 Min[1, (7 p)/3]^4)

This time the plot of the function looks as follows


enter image description here

With maximum at p=0:



I hope now this is what you had in mind.

  • $\begingroup$ Actually you are right, $0<p<1$ and also $p<v<1$. I will add it. The problem with this magic number $\frac{3}{7}$ is that it actually splits the function in a sense, that if $p<\frac{3}{7}$ then it is one function that describes behaviour and I do not seem to have problems with it. The problem is with another function which describes behaviour when $p>\frac{3}{7}$. In this case this function cannot be negative and I want to find value $p$ which would maximise it. I am not sure, can I do it with answers that include "Min" and "heavisideTheta" ? $\endgroup$
    – Kvadich
    Apr 30, 2017 at 21:18
  • $\begingroup$ As you can see from the plot, for 0<p<3/7 the function is monotonously increasing, while for 3/7<p<1 it is monotonously decreasing. Since at p=0 and p=1 the function has the same value, its maximum must be exactly where it stops increasing and starts decreasing, namely at p=3/7. And as I pointed out in the answer, the value at the maximum is 5/147. $\endgroup$
    – Kagaratsch
    Apr 30, 2017 at 21:24
  • $\begingroup$ Thanks for your help. I know it is confusing, even for me, but I have reformulated my question, could you please take a look and see if it makes sense? $\endgroup$
    – Kvadich
    Apr 30, 2017 at 23:41
  • $\begingroup$ @Kvadich See update 2. Is this what you have in mind? $\endgroup$
    – Kagaratsch
    May 1, 2017 at 14:33
  • 1
    $\begingroup$ Thanks, Kagaratsch. I think it answers it, I should still think it over though. At least you gave me the tools to work with (I didn't know about the possibility of using min and max in integration), which seems to be exactly the way to solve it. $\endgroup$
    – Kvadich
    May 1, 2017 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.