0
$\begingroup$

I'm trying to indicate in my Plot3D diagram the minimum level of the dependent variable and the corresponding levels of two independent variables. More specifically, $i$ is a function of $k$ and $r$, i.e. $i=f(k,r;s,d,c,q)$ where $s$, $d$, $c$, and $q$ are given constant. Depending on the ranges of $k$ and $r$, there are eight different functions of $i$ as follows:

i1 = (3 d k^2 r + k^2 r (k r - 3 s) + 3 d^2 s + c (6 d^2 (-1 + q) + 3 k^2 (-1 + 2 q) r + 6 d s))/(6 d s^2);
i2 = 1/(6 d (-1 + r)^2 s^2) (3 c (d^2 (-3 + q (2 - 4 r) + 5 r) + 2 d (k - 2 k r + k (-1 + 2 q) r^2 + s - r s) + k (k (-1 - r + 2 q r) (1 + (-3 + r) r) + 2 (-1 + r) r s)) + (-1 + r) (d^3 + 3 d^2 (k (-1 + r) - s) + 3 d k (k + k (-3 + r) r + 2 r s) + k^2 (k (-1 + r (3 + (-1 + r) r)) - 3 r^2 s)));
i3 = 1/(6 d (-1 + r) s^2) (d^3 + 3 d^2 (k (-1 + r) - s) + 3 d k (k + k (-3 + r) r + 2 r s) + 
  k^2 (k (-1 + r (3 + (-1 + r) r)) - 3 r^2 s) + 3 c (d^2 + 2 d k (-1 + 2 q) (-1 + r) - 2 d s + 
     k (k (-1 + 2 q (-1 + r)^2 + r - r^2) + 2 r s)));
i4 = (k^2 r (-3 d + 2 k r) - 3 (d - k r)^2 s - 3 c (2 d^2 (-1 + q) + k r (k - 2 s) + 2 d s))/(6 d (-1 + r) s^2);
i5 = (k^2 r (-3 d + 2 k r) - 3 (d - k r)^2 s - 3 c (2 d^2 (-1 + q) + k r (k - 2 s) + 2 d s))/(6 d (-1 + r) s^2);
i6 = (d^3 + 3 d^2 k r + 3 d k^2 (-1 + r) r + k^3 (-1 + r)^2 r + 3 c (d^2 (-1 + 2 q) + 2 d k r + k^2 (-1 + r) r))/(6 d r s^2);
i7 = - (d (d + c (3 + 6 (-1 + q) r)))/(6 (-1 + r) r s^2);
i8 = (d^3 + 3 d^2 k r + 3 d k^2 (-1 + r) r + k^3 (-1 + r)^2 r + 3 c (d^2 (-1 + 2 q) + 2 d k r + k^2 (-1 + r) r))/(6 d r s^2);

My goal is to find the minimum value of $i$ and the corresponding $k$ and $r$ for the following values of the constants:

s = 4; d = 0.9; c = 0.15; q = 1.5; 

I used Piecewise and my Plot3D code is as follows:

Plot3D[Piecewise[{{i1, 0 <= k < d && 0 <= r <= 1}, {i2, d <= k < 2 d && 1/2 < r < (d/k)}, {i3, d <= k < 2 d && 1 - (d/k) < r <= 1/2}, {i4, d <= k < 2 d && 0 <= r <= 1 - (d/k)}, {i5, 2 d <= k <= s && 0 <= r < (d/k)}, {i6, d <= k < 2 d && (d/k) <= r <= 1}, {i7, 2 d <= k <= s && (d/k) <= r < 1/2}, {i8, 2 d <= k <= s && 1/2 <= r <= 1}}], {k, 0, s}, {r, 0, 1}, AxesLabel -> {k, r, i}]

which yields:

enter image description here

But, I would like to do two more things:

First, I would like to come up with concrete numbers, i.e. to find at which levels of $k$ and $r$, $i$ is minimized, and find that minimum value of $i$.

Second, I would like to indicate these in the diagram, i.e. the minimum $i$ and the corresponding levels of $k$ and $r$.

For the first task, I did the following without success:

Maximize[{Piecewise[{{i1, 0 <= k < d && 0 <= r <= 1}, {i2, d <= k < 2 d && 1/2 < r < (d/k)}, {i3, 
  d <= k < 2 d && 1 - (d/k) < r <= 1/2}, {i4, d <= k < 2 d && 0 <= r <= 1 - (d/k)}, {i5, 2 d <= k <= s && 0 <= r < (d/k)}, {i6, d <= k < 2 d && (d/k) <= r <= 1}, {i7, 2 d <= k <= s && (d/k) <= r < 1/2}, {i8, 2 d <= k <= s && 1/2 <= r <= 1}}] && 0 <= r <= 1 && 0 <= k <= 4}, {r, k}]

For the second task, I wasn't able to even start. Can anyone please help?

$\endgroup$
  • $\begingroup$ As a plotting tip: you might want to add the setting Exclusions -> None if you are sure your function is supposed to be continuous at the breaks. $\endgroup$ – J. M.'s discontentment Apr 24 at 0:37

Your Answer

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

Browse other questions tagged or ask your own question.