0
$\begingroup$

I want to minimize this function $f(x, y)=\left(n_{1}\right)\left(1-x(1-x)^{k_{1}}(1-y)^{k_{2}}\right)^{T}+\left(n_{2}\right)\left(1-y(1-x)^{k_{1}}(1-y)^{k_{2}}\right)^{T}$

Though it is a function in 2 variables, I know that

$k_{1}\left(\frac{x}{1-x}\right)+k_{2}\left(\frac{y}{1-y}\right)=1$

Domain for $x$ and $y$ are (0,1).

Thus, it is essentially a function of one variable. How can I use Mathematica to minimize this function?

Mathematica notations of the function: Minimize

n[1] (1 - x (1 - x)^k[1] (1 - y)^k[2])^T +
  n[2] (1 - y (1 - x)^k[1] (1 - y)^k[2])^T

subject to the constraint

k[1] (x/(1 - x)) + k[2] (y/(1 - y)) == 1

over the domain (0,1) x (0,1).

$\endgroup$
  • $\begingroup$ Please include the input in copy-and-pastable format. $\endgroup$ – Daniel Lichtblau Jan 4 at 20:54
  • $\begingroup$ Also it appears that there are several variables other than x and y. $\endgroup$ – Daniel Lichtblau Jan 4 at 20:55
  • $\begingroup$ @DanielLichtblau, The only variables are $x$ and $y$. The others are generic (symbolic) constants. Also, I don't understand what is meant by 'copy-and-pastable' format. $\endgroup$ – Jyotish Robin Jan 4 at 20:57
  • $\begingroup$ A format that one can copy/paste into a Mathematica session. $\endgroup$ – Daniel Lichtblau Jan 4 at 20:58
  • $\begingroup$ @DanielLichtblau, I am not sure how to do that. I am totally new to mathematica.But I was of the understanding that mathematica supports tex commands too. $\endgroup$ – Jyotish Robin Jan 4 at 21:27
4
$\begingroup$

This is a way to set up your problem as I understood it:

Minimize[{
   n[1] (1 - x (1 - x)^k[1] (1 - y)^k[2])^T +  (* objective function *)
    n[2] (1 - y (1 - x)^k[1] (1 - y)^k[2])^T, 
   0 < x < 1 && 0 < y < 1 &&                   (* constraints *)
    k[1] x/(1 - x) + k[2] y/(1 - y) == 1},
 {x, y}]                                       (* free variables *)

If you execute, it might finish someday. I didn't wait long enough. The problem is the parameters in the exponents. They make the problem look like a transcendental function, and the methods for dealing with them are less powerful.

It can be of help to reduce the number of free variables. Methods for univariate problem are considerably more robust. We can use the constraint to replace y in terms of x:

cons = First@Solve[k[1] x/(1 - x) + k[2] y/(1 - y) == 1, y]
(*  {y -> (-1 + x + x k[1])/(-1 + x + x k[1] - k[2] + x k[2])}  *)

Minimize[{
   n[1] (1 - x (1 - x)^k[1] (1 - y)^k[2])^T +  (* objective function *)
    n[2] (1 - y (1 - x)^k[1] (1 - y)^k[2])^T, 
   0 < x < 1 && 0 < y < 1                      (* domain *)
   } /. cons,                                  (* substitute constraint *)
 {x}]                                          (* free variables *)

This returns immediately without an answer (the output is the same as the input). That means Mathematica (quickly) decided it could not solve it but gave no reason.

Finally, you could address the issue of parameters in the exponents. One could substitute definite numbers for them. That may or may not be helpful to you. The following returns a very long answer.

Minimize[{
    n[1] (1 - x (1 - x)^k[1] (1 - y)^k[2])^T + 
     n[2] (1 - y (1 - x)^k[1] (1 - y)^k[2])^T, 
    0 < x < 1 && 0 < y < 1
    } /. cons /.
     {(*n[1]->6,n[2]->5,*) k[1] -> 1, k[2] -> 1, T -> 2},
   {x}]

Well, all is not lost, maybe, but the solutions to the setting the derivative equal to zero are somewhat problematic:

xsols = Solve[
  Numerator@
    Factor@D[
      n[1] (1 - x (1 - x)^k[1] (1 - y)^k[2])^T + 
        n[2] (1 - y (1 - x)^k[1] (1 - y)^k[2])^T /. cons,
      x] == 0, x]
Solve::ifun: Inverse functions are being used by Solve, 
so some solutions may not be found; use Reduce for 
complete solution information.
(*
{{x -> 1 - 0^(1/k[1])},
 {x -> (0^(1/k[2]) - k[2] + 0^(1/k[2]) k[2])/(
   0^(1/k[2]) + 0^(1/k[2]) k[1] - k[2] + 0^(1/k[2]) k[2])},
 {x -> (
   1 + k[1] + k[2] - Sqrt[-k[1] k[2] - k[1]^2 k[2] - k[1] k[2]^2])/(
   1 + 2 k[1] + k[1]^2 + k[2] + k[1] k[2])},
 {x -> (
   1 + k[1] + k[2] + Sqrt[-k[1] k[2] - k[1]^2 k[2] - k[1] k[2]^2])/(
   1 + 2 k[1] + k[1]^2 + k[2] + k[1] k[2])}}
*)

You can get the solutions for y and put them together as follows:

ysols = cons /. xsols;
fullsols = Join[xsols, ysols, 2] // Simplify

Two of the four become Indeterminate during simplification. You probably need to take a Limit. The other two often evaluate to complex numbers (not always) when numbers are substituted for the parameters.

$\endgroup$
  • $\begingroup$ Thanks a lot for the detailed explanation. As you suggested, the form of the equation maybe too complicated to solve it with the symbolic constants. Unfortunately, I can't substitute numbers for the parameter as I am looking for an analytic expression. $\endgroup$ – Jyotish Robin Jan 4 at 23:40
  • $\begingroup$ @JyotishRobin You're welcome. Maybe someone else will have an idea. The expression for your function looks somewhat symmetric algebraically, and there may be a way to solve it. $\endgroup$ – Michael E2 Jan 4 at 23:43
2
$\begingroup$

Some hints, not a full answer: conditions force y to be a function of x for given k1,k2. Minimize can't solve the resulting function of x and parameters as also mentioned by @Michael M2, but get an impression at which x and corresponding y (curve in red) function (curve in blue) is minimal due to varying parameters. If parameter ranges are known, FindMinimum can be applied.

ysol[x_, k1_, k2_] = 
  y /. First@
  Solve[0 < x < 1 && 0 < y < 1 && k1 x/(1 - x) + k2 y/(1 - y) == 1, 
y, Reals]

f[k1_, k2_, n1_, n2_, T_, x_] = 
  n1 (1 - x (1 - x)^k1 (1 - y)^k2)^T + 
  n2 (1 - y (1 - x)^k1 (1 - y)^k2)^T /. y -> ysol[x, k1, k2] // Simplify

Manipulate[
  Plot[{ysol[x, k1, k2], f[k1, k2, n1, n2, T, x]}, {x, 0, 1}, 
  PlotRange -> All, PlotStyle -> {Red, Blue}], {{n1, 1}, -3, 
  3}, {{n2, 1}, -4, 4}, {{T, 1}, -2, 5}, {{k1, 1}, -3, 
   3}, {{k2, 1}, -4, 4}]

enter image description here

$\endgroup$
  • $\begingroup$ I didn't quite understand what are the red and blue curves. Are both representing y values ? The X-axis correspond to x values? $\endgroup$ – Jyotish Robin Jan 5 at 10:38
  • $\begingroup$ As described and can be seen from the code, the blue curve is your function f[x,y] with eliminated y. X-axis is x. Red curve is the y value depending on x,k1 and k2. Try to read the code. $\endgroup$ – Akku14 Jan 5 at 11:13

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.