Re: SumOfSquaresRepresentations
- To: mathgroup at smc.vnet.net
- Subject: [mg103486] Re: [mg103475] SumOfSquaresRepresentations
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Thu, 24 Sep 2009 07:50:50 -0400 (EDT)
- References: <200909240351.XAA13419@smc.vnet.net>
First of all, you do not need to define yourself a function that does this, since one already exists: PowersRepresentations[15, 3, 2] {} Now, this also tells you the solution to your problem! The solution is that there are no solutions and you have written your program assuming that there always are going to be any. Really, to see that all you needed was to look at the output of: With[{a = Array[x, 3]}, Reduce[a.a == 15, a, Integers]] False Actually, your program will also not work correctly in other cases when there are no solutions. Here are the numbers of ways of representing the first 10 integers as sum of squares SquaresR[3, Range[10]] {6,12,8,6,24,24,0,12,30,24} We can see that for n = 7 there are no solutions and your code will produce: Module[{x, a}, (a = Array[x, 3]) /. {ToRules[Reduce[a.a == 7, a, Integers]]}] {x$2267(1),x$2267(2),x$2267(3)} So how come you claim that 15 is the only integer between 1 and 200 for which this happens?? Andrzej Kozlowski On 24 Sep 2009, at 12:51, janos wrote: > To be on the safe side: > ClearAll[d, n, x, a, SumOfSquaresRepresentations]; > > Take this from the help: > SumOfSquaresRepresentations[d_, n_] := > Module[{x, > a}, (a = Array[x, d]) /. {ToRules[Reduce[a.a == n, a, Integers]]}] > > Let's apply it: > SumOfSquaresRepresentations[3, 15] > {x$110[1], x$110[2], x$110[3]} > > And this is the only case that you get this funny result > writing any integer between 1 and 200 in the place of 15. > > Any idea? > > Thank you. > > J=E1nos >
- References:
- SumOfSquaresRepresentations
- From: janos <janostothmeister@gmail.com>
- SumOfSquaresRepresentations