# Is it possible to minimize this function in Mathematica/wolframAlpha?

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 - x (1 - x)^k (1 - y)^k)^T +
n (1 - y (1 - x)^k (1 - y)^k)^T


subject to the constraint

k (x/(1 - x)) + k (y/(1 - y)) == 1


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

• Please include the input in copy-and-pastable format. – Daniel Lichtblau Jan 4 at 20:54
• Also it appears that there are several variables other than x and y. – Daniel Lichtblau Jan 4 at 20:55
• @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. – Jyotish Robin Jan 4 at 20:57
• A format that one can copy/paste into a Mathematica session. – Daniel Lichtblau Jan 4 at 20:58
• @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. – Jyotish Robin Jan 4 at 21:27

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

Minimize[{
n (1 - x (1 - x)^k (1 - y)^k)^T +  (* objective function *)
n (1 - y (1 - x)^k (1 - y)^k)^T,
0 < x < 1 && 0 < y < 1 &&                   (* constraints *)
k x/(1 - x) + k 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 x/(1 - x) + k y/(1 - y) == 1, y]
(*  {y -> (-1 + x + x k)/(-1 + x + x k - k + x k)}  *)

Minimize[{
n (1 - x (1 - x)^k (1 - y)^k)^T +  (* objective function *)
n (1 - y (1 - x)^k (1 - y)^k)^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 - x (1 - x)^k (1 - y)^k)^T +
n (1 - y (1 - x)^k (1 - y)^k)^T,
0 < x < 1 && 0 < y < 1
} /. cons /.
{(*n->6,n->5,*) k -> 1, k -> 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 - x (1 - x)^k (1 - y)^k)^T +
n (1 - y (1 - x)^k (1 - y)^k)^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)},
{x -> (0^(1/k) - k + 0^(1/k) k)/(
0^(1/k) + 0^(1/k) k - k + 0^(1/k) k)},
{x -> (
1 + k + k - Sqrt[-k k - k^2 k - k k^2])/(
1 + 2 k + k^2 + k + k k)},
{x -> (
1 + k + k + Sqrt[-k k - k^2 k - k k^2])/(
1 + 2 k + k^2 + k + k k)}}
*)


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.

• 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. – Jyotish Robin Jan 4 at 23:40
• @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. – Michael E2 Jan 4 at 23:43

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}] • I didn't quite understand what are the red and blue curves. Are both representing y values ? The X-axis correspond to x values? – Jyotish Robin Jan 5 at 10:38
• 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. – Akku14 Jan 5 at 11:13