2

I would appreciate it if somebody could help me with the following problem:

Q: To find the number of ordered pairs of natural numbers in the following equation $$a+b+c+d=13$$ we want to add the condition that $\frac{a+b+c}{d}$ is an integer. What should I do? Please advise.

My Try:

{a,b,c,d} /. Solve[ a+b+c+d==13  &&1<={a,b,c,d}<=12,
                    IntegerQ[(a+b+c)/d]==True, {a,b,c,d}, Integers]
Artes
  • 57,212
  • 12
  • 157
  • 245
Young
  • 259
  • 1
  • 6

4 Answers4

7

The approach with Solve in the original question is syntactically incorrect and mathematically not quite correct. The natural numbers start with zero not one.

This might be reformulated as e.g.

{a, b, c, d} /. Normal @ Solve[ a + b + c + d == 13 &&
                                0 <= {a, b, c, d} && (a + b + c)/d == k,
                               {a, b, c, d, k}, Integers]

However this solution is not especially elegant and efficient.

Since $a+b+c= k\;d$ we have $13=a+b+c+d = k\; d+ d=(k+1)\; d$, and since $13$ is a prime number this means that $k =12$ and $d=1$ or $k=0$ and $d=13$.

The second case is trivial $\{a,b,c\}=\{0,0,0\}$. Possible solutions in the first case one can find with FrobeniusSolve, e.g.

FrobeniusSolve[{1, 1, 1}, 12]

and the number of solutions is simiply

FrobeniusSolve[{1, 1, 1}, 12] // Length
91

plus $1$ solution of the second case, i.e. $92$ solutions.

If we are looking only for positive solutions there are only

DeleteCases[FrobeniusSolve[{1, 1, 1}, 12], {___, 0, ___}] // Length
55

solutions. FrobeniusSolve is a better approach than Solve because of it efficiency for such problems, see e.g. Finding the number of solutions to a diophantine equation.

Artes
  • 57,212
  • 12
  • 157
  • 245
  • 2
    "The natural numbers start with zero not one." I'm going to disagree there. There really is no common agreement on this. Computer scientists tend to start N with 0; mathematicians start them with 0 or 1 depending on who you ask. I learned that they start with 1 in my courses, but whatever. You just have to specify because there simply is no consensus about it. – Sjoerd Smit Oct 12 '22 at 09:43
  • @SjoerdSmit I find your arguments quite weak, the only one is compatibility of common numerators: first - one, second - two and so on. I guess those mathematicians meant only this one without deepper reasoning. Without $0$ natural numbers are not even a monoid with respect to addition. – Artes Oct 12 '22 at 12:22
  • 1
    Wikipedia confirms Sjoerd: "Some definitions, including the standard ISO 80000-2, begin the natural numbers with 0, corresponding to the non-negative integers 0, 1, 2, 3, ..., whereas others start with 1, corresponding to the positive integers 1, 2, 3, ... Texts that exclude zero from the natural numbers sometimes refer to the natural numbers together with zero as the whole numbers, while in other writings, that term is used instead for the integers (including negative integers)." I also learned to distinguish $\mathbb{N}$ and $\mathbb{N}_0$. – Roman Oct 12 '22 at 13:22
  • @Roman Mathematics is not a democratic forum, I don't mind what some individuals say. It is quite common that for various reasons mathematicians say "natural numbers $1,2,3, \dots$". This should be regarded as a common useful restriction, nonetheless we should consider natural numbers from a structural point of view and in general we cannot exculde zero from $\mathbb{N}$ because mathematical structures become too narrow and restritive. There is a well known sentence by Kronecker "God created natural numbers and everyting else is made by man". I don't agree and I guess so do you. – Artes Oct 12 '22 at 15:40
  • @Roman I'm not not criticizing distinguished mathematicians, we know more than they did in $19$-th century, and It is clear that continuum and countable sets belong to different worlds. See e.g. continuum hypothesis. – Artes Oct 12 '22 at 15:40
  • Actually ISO 80000-2 mentiones that N star starts with 1. All books here do not include 0. – Валерий Заподовников Oct 13 '22 at 18:32
  • @Artes You can complain all you want; the fact is that both definitions are common enough to cause confusion if you don't clarify on the issue when you use the term. A century ago, all definitions of N started with 1. Things change across time, space and disciplines. You can't just declare your own definition as law; mathematics is about communicating clearly; not about dogmatically declaring your own preferences law. – Sjoerd Smit Oct 14 '22 at 07:59
  • @SjoerdSmit It's natural that if one says "the set of natural nambers" it should be considered with zero included, otherwise one should state it clearly. Definitions may appear different, but in general it is better to restrict the set, than to create new entities. This discussion is unproductive, beside production of common nonsense. – Artes Oct 14 '22 at 08:37
  • 'It's natural that if one says "the set of natural nambers" it should be considered with zero included, otherwise one should state it clearly'. I know plenty of people who hold the exact opposite opinion. You can't just assert things as universally true by yourself. – Sjoerd Smit Oct 14 '22 at 09:03
  • @SjoerdSmit You are a really poor man wasting so much time on discussion which has nothing to add to the original issue since I provided solutions to the both possibilities. – Artes Oct 14 '22 at 09:08
  • Out of curiosity, where's the documentation for 0 <= {a, b, c, d} working on equation solving as it does? I tried to look for it, and didn't immediately find anything, and statements such as 0 < {1, 2} don't really work outside this specific domain. – kirma Nov 07 '22 at 10:51
4
Solve[{a + b + c + d == 13, a + b + c == d*k, 
   {a, b, c, d}>=0}, {a, b, c, d}, {k}, Integers]
{a, b, c, d} /. %
Solve[{a + b + c + d == 13, a + b + c == d*k, 
   {a, b, c, d} >=0}, {a, b, c, d}, Integers]
cvgmt
  • 72,231
  • 4
  • 75
  • 133
4

IntegerPartition can give you all partitions of 13 with 4 summands. You then only need to check, if the last summand divides the sum of the former summands, what can be done using: Select:

Select[IntegerPartitions[13, {4}],  IntegerQ[ Total[#[[;; 3]]]/#[[4]]] &]

(* {{10, 1, 1, 1}, {9, 2, 1, 1}, {8, 3, 1, 1}, {8, 2, 2, 1}, {7, 4, 1, 1}, {7, 3, 2, 1}, {6, 5, 1, 1}, {6, 4, 2, 1}, {6, 3, 3, 1}, {5, 5, 2, 1}, {5, 4, 3, 1}, {4, 4, 4, 1}} *)

Daniel Huber
  • 51,463
  • 1
  • 23
  • 57
  • Divisible is faster than actually dividing and checking for integer-ness. Something like Select[IntegerPartitions[13, {4}], Divisible[Total[Most[#]], Last[#]] &] – Roman Oct 12 '22 at 17:33
0

$a+b+c+d=13\implies a+b+c=13-d\implies\dfrac{a+b+c}{d}=\dfrac{13-d}{d}=\dfrac{13}{d}-1$ is integer. So $d=1$ or $d=13$. If $d=13$, $\{a,b,c\}=\{0,0,0\}$ (OP assumes zero is not as natural number).

If $d=1$, problem boils down to finding number of solution of $a+b+c=12$ in natural number.

sol=SolveValues[a + b + c == 12, {a, b, c}, PositiveIntegers]

{{1, 1, 10}, {1, 2, 9}, {1, 3, 8}, {1, 4, 7}, {1, 5, 6}, {1, 6, 5}, {1, 7, 4}, {1, 8, 3}, {1, 9, 2}, {1, 10, 1}, {2, 1, 9}, {2, 2, 8}, {2, 3, 7}, {2, 4, 6}, {2, 5, 5}, {2, 6, 4}, {2, 7, 3}, {2, 8, 2}, {2, 9, 1}, {3, 1, 8}, {3, 2, 7}, {3, 3, 6}, {3, 4, 5}, {3, 5, 4}, {3, 6, 3}, {3, 7, 2}, {3, 8, 1}, {4, 1, 7}, {4, 2, 6}, {4, 3, 5}, {4, 4, 4}, {4, 5, 3}, {4, 6, 2}, {4, 7, 1}, {5, 1, 6}, {5, 2, 5}, {5, 3, 4}, {5, 4, 3}, {5, 5, 2}, {5, 6, 1}, {6, 1, 5}, {6, 2, 4}, {6, 3, 3}, {6, 4, 2}, {6, 5, 1}, {7, 1, 4}, {7, 2, 3}, {7, 3, 2}, {7, 4, 1}, {8, 1, 3}, {8, 2, 2}, {8, 3, 1}, {9, 1, 2}, {9, 2, 1}, {10, 1, 1}}

Length@sol

55

Alternatively one can use generating functions.

enter image description here

OkkesDulgerci
  • 10,716
  • 1
  • 19
  • 38