0
$\begingroup$

Suppose I have functions which depends on the symbols $c[I]$, where $I$ is some subset of $\{1,2,...,n\}$. For example, $$f = c[1] + c[1,2,3] + c[1,2],$$ $$g = c[2] + c[2,1],$$

Code:

f = c[1] + c[1, 2] + c[1, 2, 3];
g = c[2] + c[2, 1];

and I want to find the maximum between f and g, assuming that the c's are positive and moreover monotonically decreasing with respect to the lexycographical order of their arguments:

so for example $$c[1] > c[2] > \dots,$$ $$c[1,2] > c[2,1] > c[2,2] > \dots$$

so that $$f - g = (c[1]-c[2]) + (c[1,2]-c[2,1]) + c[1,2,3] > 0.$$

How can I define in a clever way this assumption so that Max[{f, g}, assumption] does the job for me?

$\endgroup$
  • 3
    $\begingroup$ People here generally like users to post code and examples as Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful $\endgroup$ – Michael E2 Oct 9 '18 at 12:17
2
$\begingroup$

Perhaps this:

mymax[f_, g_] := With[{vars = Union@Cases[{f, g}, _c, Infinity]},
  PiecewiseExpand[Max[{f, g}], 
   And @@ (Greater @@ Append[#, 0] & /@ SplitBy[vars, Length])]
  ]

mymax[c[1] + c[1, 2] + c[1, 2, 3], c[2] + c[2, 1]]
(*  c[1] + c[1, 2] + c[1, 2, 3]  *)
$\endgroup$

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.