# Finding the maximum of a symbolic piecewise function

I have the function:

coded as:

f[x_, y_, z_, \[Alpha]_, \[Beta]_, \[Gamma]_] := (x - \[Beta]*y - \[Gamma]*z)*
Piecewise[{{1 - (x - z)/(\[Alpha]*(y - z + x)),
y >= (x - z)*(1/\[Alpha] - 1) && x - z >= 0},
{1, y >= (x - z)*(1/\[Alpha] - 1) && x - z < 0},
{0, y < (x - z)*(1/\[Alpha] - 1) && x - z >= 0},
{(z - x)/(\[Alpha]*(z - x - y)), y < (x - z)*(1/\[Alpha] - 1) &&
x - z < 0}}]


I would like to compute its maximum with respect to $$x\geq 0$$ (as well as the corresponding argument), depending on the parameters $$y \in \mathbb{R}$$, $$z\in \mathbb{R}$$, $$\alpha \in ]0;1[$$, $$\beta>0$$ and $$\gamma>0$$.

In practice, I would like to have a decomposition of the 5-dimensional space of $$(y,z,\alpha,\beta,\gamma)$$ into different zones and the formula for the maximum of the function and its argument in each zone.

Is it something I can get Mathematica to do? The functions "Maximize", "MaxValue", "FindMaxValue" and "ArgMax" simply return the input... I tried, for example:

 Maximize[{f[x,y,z,\[Alpha],\[Beta],\[Gamma]],x>=0&&\[Alpha]>0&&\[Alpha]<1&&\[Beta]>0&&\[Gamma]>0},x]


If it is not possible to solve this integrally with Mathematica, is there a way to use Mathematica to make the hand calculations less cumbersome or is there another software that could do it ?

• I think no chance because of 5 parameters. Look at the results of Plot[f[x, 1, 2, 1/2, 2, 4], {x, 0, 15}], Plot[f[x, -2, 1, 1/3, 4, 2], {x, 0, 15}], and Plot[f[x, -10, -11, 1/3, 4, 2], {x, 0, 15}]. Sep 15, 2023 at 16:29

You have to evaluate all parameters. For example,

Maximize[{f[x, -2, 1, 1/3, 4, 2], x >= 0}, x]


{6, {x -> 0}}

It should be noticed, that

Maximize[{f[x, -2, z, 1/3, 4, 2], x >= 0 && z \[Element] Reals}, x]


fails. However,

Maximize[{f[x, -2, 1, \[Alpha], 4, 2],  x >= 0 && \[Alpha] > 0 && \[Alpha] < 1}, x]


{Piecewise[{{3, \[Alpha] == 2/3}, {2/\[Alpha], Inequality[1/3, Less, \[Alpha], Less, 2/3] || Inequality[2/3, Less, \[Alpha], Less, 1]}, {(-7 + 9*\[Alpha])/(-1 + \[Alpha]), Inequality[0, Less, \[Alpha], LessEqual, 1/3]}}, -Infinity], {x -> Piecewise[ {{(-1 + 3*\[Alpha])/(-1 + \[Alpha]), Inequality[0, Less, \[Alpha], LessEqual, 1/3]}, {0, \[Alpha] == 2/3 || Inequality[1/3, Less, \[Alpha], Less, 2/3] || Inequality[2/3, Less, \[Alpha], Less, 1]}}, Indeterminate]}}

works.