# Minimax Optimization Over and Interesting Function

n=2;
(i_1,i_2)= i mod 2  for example (0,1)=1 mod 2 or (1,1)=3 mod 2


$$f_i(s_0,s_1)={s_0}^{i_1}{s_1}^{i_2}{(1-s_0)}^{1-i_1}{(1-s_1)}^{1-i_2}$$ $$r(s_0,s_1,x_1,k_1)=\sum_{i=0}^{2^n-1} \min(f_i(s_0,s_1),f_{2^n-i-1}(y(s_0;x_1,k_1),y(s_1;x_1,k_1)))$$ $$y(x;x_1,k_1)=\begin{cases}\frac{-1+k_1(1-x_1)}{x_1}x+1,\quad x\in[0,x_1]\\k_1(-x+1),\,\quad\quad\quad x\in[x_1,1]\end{cases}$$ and $$\begin{cases}y\in[k_1,1],\quad\quad\quad\quad x_1=0\\x\in[x_1,1],\quad\quad\quad\quad k_1=0\end{cases}$$

I want to solve

$$\max_{(x_1,k_1)\in[0,1]}\left[\min_{(s_0,s_1)\in[0,1]\\s_0=s_1}r(s_0,s_1,x_1,k_1)-\min_{(s_0,s_1)\in[0,1]}r(s_0,s_1,x_1,k_1)\right]$$

Please excuse me that I have no codes because I dont know too many things:

$1.$ Defining the function $y$ properly in Mathematica

$2.$ To make a minimax type optimization

$3.$ To obtain binary expansion of a number

• If you want to define y you can potentially use Piecewise. Dunno if that will be best, though. – b3m2a1 Jul 25 '18 at 21:44
• @b3m2a1 I have used that a few times.. Here the point is that the function takes all values from $k_1$ to $1$ if $x_1$ is zero. Similarly if $k_1=0$ then $x$ takes all values in $[x_1,1]$. So for all other values it is just a simple convex function but for $x_1=0$ and $k_1=0$ there are multiple values. – Seyhmus Güngören Jul 25 '18 at 22:35

BaseForm[58, 2]