0
$\begingroup$

I would like to maximize the following definite double integral with respect to $0<r<\frac{1}{2}$:

$\int _0^{\frac{d}{1-r}}\int _{\frac{d+r x-x}{r}}^s [(1-r) x+r y -d]dydx$

under the constraints: $0\leq d \leq 1$, $2d < s \leq 4$, $0 < r < \frac{1}{2}$, $0 \leq x \leq s$, $0\leq y \leq s$.

Note that the variables of integration, i.e. $x$ and $y$, are both bounded by $0$ and $s$; for this reason, I have to be careful in my code regarding the limits of integration regions.

Here is my code:

maxR = Flatten[Table[{d, s, r /. Last@Maximize[{Integrate[(1 - r)*x + r*y - d, {x, 0, Min[s, d/(1 - r)]}, {y, Max[0, Min[s, (d + r*x - x)/r]], s}], 0 <= d <= 1, 2 d < s, 0 < r < 1/2}, {r}]}, {d, 0, 1, .1}, {s, 1, 4, .1}], 1];
ListPlot3D[maxR, PlotRange -> {0, 1}, AxesLabel -> {"d", "s", "r"}]  

And this is running forever. Can anyone help please?

By the way, this is an extension of Ulich's answer to this question. While the latter shows how to get the solution of the integral, my question here regards a maximization of the integral.

$\endgroup$
4
  • 3
    $\begingroup$ Possible duplicate of Solving a definite integral with constraints on the limits $\endgroup$ Commented Jul 27, 2019 at 2:17
  • $\begingroup$ In 202468 we elaborated the integral numerically. Why didn't you use this result? $\endgroup$ Commented Jul 27, 2019 at 12:14
  • $\begingroup$ @AccidentalFourier Transform, I have added an explanation that this post is not a duplicate of that post. $\endgroup$
    – ppp
    Commented Jul 27, 2019 at 20:58
  • $\begingroup$ @Ulrich, since my code in this post is part of a larger context, I utilized your suggestion about modifying the integration limits to my current code. Thanks so much! $\endgroup$
    – ppp
    Commented Jul 27, 2019 at 21:01

1 Answer 1

1
$\begingroup$

With Integrate[...] substituded by the result from question 202534

int[s_?NumericQ, d_?NumericQ, r_?NumericQ] :=NIntegrate[(1 - r)*x + r*y - d, {x, 0, Min[s, d/(1 - r)]}, {y,Max[0, Min[s, (d + r*x - x)/r]], s}]

the solution can be obtained numerically:

Table[NMaximize[{int[s, d, r], 0 < r < 1/2}, { r}], {d, 0,1, .1}, {s, 1, 4, .1 }]
$\endgroup$
1
  • $\begingroup$ Thanks so much, Ulrich! It was very helpful! $\endgroup$
    – ppp
    Commented Jul 28, 2019 at 2:28

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.