0
$\begingroup$

These are toy examples intended to elicit general knowledge on indexed variables of undefined (symbolic) quantity; please feel free to offer better examples.

Suppose I wish to "solve" this: $2^{\sum _{j=1}^n q_j}=2^4$, for the $q_j$ subject to the constraint $\forall j, q_j \in \mathbb{Z} \land q_j \gt 0$?.

In this particular case, there can be no solutions for $n \ge 3$ (since for $n=3$ the minimum sum of the $q_j$ would be $\ge3$), and if I were using e.g. Reduce I would like a similar condition on n back.

I am 99% sure that using subscripted variables, like this, is the wrong way to go

Q[n_] := 2^Sum[Subscript[q, j], {j, 1, n}]

How can I solve, reduce etc. over e.g. Sum especially when I don't even want to specify a specific value of n?

In the most general case, how would I approach specifying and solving, reducing etc. $2^{\sum _{j=1}^n q_j}=2^n$, where $\forall j, q_j \in \mathbb{Z} \land q_j \ge0$? (allowing zeros this time)

UPDATE

Usually I give MMA info, but this time I forgot. I am using MMA 11.0.1.0 (Windows). This version of MMA does not seem to have PositiveIntegers as a domain.

Secondly, whilst @Bob Hanlon's answer is most welcome and informative, it highlighted the ambiguity of the question and the omission of the key word "symbolically" near solve, reduce, etc. Whilst I might use some specific argument values as a sanity check, I am really looking for approaches to specifying, etc. when the number of variables is indeterminate.

$\endgroup$
7
  • $\begingroup$ Are we trying to find n integers that sum to n? $\endgroup$
    – lericr
    Commented Oct 25, 2022 at 15:33
  • $\begingroup$ @lericr The LaTeX equations are examples of what we are trying to solve, reduce etc. 2^Sum(q_j) =... $\endgroup$ Commented Oct 25, 2022 at 17:44
  • $\begingroup$ On the left hand side, we have 2^Sum. On the right hand side, we have 2^N. So, I'm asking whether it's sufficient to just solve Sum == N. So, give 2^4, is it sufficient to find 4 integers that sum to 4 (given the non-negative or positive constraint)? $\endgroup$
    – lericr
    Commented Oct 25, 2022 at 22:59
  • $\begingroup$ I guess I'm just confused. What output do you want? Or frankly, what is even the input? We're solving some summation equation, but we also trying to determine "indexed variables of undefined quantity". $\endgroup$
    – lericr
    Commented Oct 25, 2022 at 23:06
  • $\begingroup$ Or to to put it another way, your stated goal is "general knowledge on indexed variables of undefined (symbolic) quantity", but I don't know what that would look like. Surely you don't mean mathematically--that's just notational convention. Presumably you mean some sort of Mathematica idiom or pattern or guideline. As for a guideline, dont use Subscript for anything that might become non-trivial. Use Part and lists/matrices instead. Next guideline: Indexed is often a better choice, so consider it. Indexed has a bit of semantics attached. $\endgroup$
    – lericr
    Commented Oct 25, 2022 at 23:11

1 Answer 1

2
$\begingroup$
$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" )

Clear["Global`*"]

Format[q[n_]] := Subscript[q, n]

Q[n_] := 2^Sum[q[j], {j, 1, n}]

solve[
  exponent_Integer?Positive,
  ordered : _?BooleanQ : True] :=
 Module[{m = 3, res = 1},
  Most@Reap[
     While[
      res =!= {},
      Sow[
       res = FindInstance[
         (Q[m] == 2^exponent) &&
          If[ordered,
           LessEqual @@ Array[q, m],
           True],
         Array[q, m],
         PositiveIntegers,
         10]];
      m++]][[2, 1]]]

Excluding permutations

solve[4] // TableForm

enter image description here

solve[5] // TableForm

enter image description here

Including permutations

solve[4, False] // TableForm

enter image description here

solve[5, False] // TableForm

enter image description here

$\endgroup$
1
  • $\begingroup$ The problem with standing on the shoulders of giants is that first one has to climb up to their level. Per the update clarification I just added, this is not quite what I had in mind, but I have already found lessons in it and will study it more shortly. I am now at ankle level. Should you feel inclined to add some pedagogical comment that would be most welcome. (It would also be interesting to know whether, in this particular case the problem could be set up so that MMA finds the solutions in terms of IntegerPartitions) $\endgroup$ Commented Oct 26, 2022 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.