1
$\begingroup$

I'm trying to maximize the following function $f$ with respect to $r$ and $k$:

$f=\frac{d^3+3 d^2 (k (r-1)-s)+3 d \left(k^2 ((r-3) r+1)+2 k r s-2 (r-1) s^2\right)+k^3 (r ((r-1) r+3)-1)-3 k^2 r^2 s+3 (r-1) s^3}{6 (r-1) s^2}$

under the conditions of $0<d<1,2d<s,d\leq k\leq s, 0\leq r \leq \frac{d}{k} $.

My Mathematica code is:

Maximize[{1/(6 (-1 + r) s^2) (d^3 + k^3 (-1 + r (3 + (-1 + r) r)) + 3 d^2 (k (-1 + r) - s) - 3 k^2 r^2 s + 3 (-1 + r) s^3 + 3 d (k^2 (1 + (-3 + r) r) + 2 k r s - 2 (-1 + r) s^2)), 0 < d < 1, 2 d < s, d <= k <= s, 0<=r<= d/k}, {r, k}]

And it is running forever. Can anyone help please?

$\endgroup$
  • $\begingroup$ Try $s=1,2,\frac 1 3,\dots$ $\endgroup$ – user64494 Jul 5 at 20:00
  • $\begingroup$ s = 1/3; Maximize[{. }, {r, k}] // ToRadicals // TeXForm performs $$\left\{ \begin{array}{cc} \{ & \begin{array}{cc} \frac{1}{18} \left(-27 d^3+54 d^2-27 d+4\right) & 0<d<\frac{1}{6} \\ -\infty & \text{True} \\ \end{array} \\ \end{array} ,\left\{r\to \begin{array}{cc} \{ & \begin{array}{cc} 0 & 0<d<\frac{1}{6} \\ \text{Indeterminate} & \text{True} \\ \end{array} \\ \end{array} ,k\to \begin{array}{cc} \{ & \begin{array}{cc} \frac{1}{3} & 0<d<\frac{1}{6} \\ \text{Indeterminate} & \text{True} \\ \end{array} \\ \end{array} \right\}\right\} $$ $\endgroup$ – user64494 Jul 5 at 20:24
  • $\begingroup$ s=2 and the above command performs $$\left\{ \begin{array}{cc} \{ & \begin{array}{cc} \frac{1}{24} \left(-d^3+12 d^2-36 d+32\right) & 0<d<1 \\ -\infty & \text{True} \\ \end{array} \\ \end{array} ,\left\{r\to \begin{array}{cc} \{ & \begin{array}{cc} 0 & 0<d<1 \\ \text{Indeterminate} & \text{True} \\ \end{array} \\ \end{array} ,k\to \begin{array}{cc} \{ & \begin{array}{cc} 2 & 0<d<1 \\ \text{Indeterminate} & \text{True} \\ \end{array} \\ \end{array} \right\}\right\} $$ $\endgroup$ – user64494 Jul 5 at 20:26
  • $\begingroup$ Thanks, user64494. Do you know we can solve this without assigning a specific value to s? Why wouldn't Mathematica solve my original code? $\endgroup$ – ppp Jul 6 at 13:59
  • $\begingroup$ No, I don't know it. My experiment suggests that the (finite) optimal solution is reached at $r=0,k=s$. I think Mma has problems with a complex nonlinear target function and a nonlinear constraint and two parameters. Don't hesitate to ask for further explanation in need. $\endgroup$ – user64494 Jul 6 at 17:39
2
$\begingroup$

One way to find the maxima is to calculate the derivatives and set them equal to zero. Here f[ ] is your function:

f[r_, k_] := 
  1/(6 (-1 + r) s^2) (d^3 + k^3 (-1 + r (3 + (-1 + r) r)) + 
     3 d^2 (k (-1 + r) - s) - 3 k^2 r^2 s + 3 (-1 + r) s^3 + 
     3 d (k^2 (1 + (-3 + r) r) + 2 k r s - 2 (-1 + r) s^2));
dfdr = D[f[r, k], r];
dfdk = D[f[r, k], k];
Solve[dfdr == 0 && dfdk == 0 && 0 < d < 1 && 2 d < s && d <= k <= s &&
   0 <= r <= d/k, {r, k}]

This seems to work, and gives a fairly long set of ConditionalExpressions in terms of Root objects. You should probably also check that the solution is a max and not a min or saddle point.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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