Re: SumOfSquaresRepresentations
- To: mathgroup at smc.vnet.net
- Subject: [mg103490] Re: [mg103475] SumOfSquaresRepresentations
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 24 Sep 2009 07:51:33 -0400 (EDT)
- Reply-to: hanlonr at cox.net
You just need to handle the case when there is no solution
SumOfSquaresRepresentations[d_, n_] :=
Module[{x, a, rules},
a = Array[x, d];
rules = {ToRules[Reduce[a.a == n, a, Integers]]};
If[rules == {}, {}, a /. rules]]
Bob Hanlon
---- janos <janostothmeister at gmail.com> 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