Page 1 of 2 12 LastLast
Results 1 to 15 of 17
Like Tree2Thanks

Math Help - Sums of integers are squares

  1. #1
    Newbie
    Joined
    Apr 2012
    From
    Minsk
    Posts
    2

    Sums of integers are squares

    How can I find the set of distinct positive integers S={a,b,c,d,e,f,g,h,i} such that:

    1. a+b, b+c, a+c are squares,
    2. d+e, e+f, d+f are squares,
    3. g+h, h+i, g+i are squares,
    4. a+b+c=d+e+f=g+h+i is square?

    If there are several solutions then choose with minimal a+b+c.
    Last edited by eigenein; April 5th 2012 at 01:03 PM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member Sylvia104's Avatar
    Joined
    Mar 2012
    From
    London, UK
    Posts
    107
    Thanks
    37

    Re: Sums of integers are squares

    One possibility is a=17, b=c=32, giving a+b=c+a=49, b+c=64, and a+b+c=81. I'm not sure if this is the mininum possible for a+b+c though.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Apr 2012
    From
    Minsk
    Posts
    2

    Re: Sums of integers are squares

    Sorry. I've forgotten to mention I want a set of distinct integers. The question is edited.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Joined
    Dec 2007
    From
    Ottawa, Canada
    Posts
    3,098
    Thanks
    67

    Re: Sums of integers are squares

    97 192 2112 ; 376 465 1560 ; 720 801 880
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Senior Member
    Joined
    Nov 2011
    From
    Crna Gora
    Posts
    420
    Thanks
    64

    Re: Sums of integers are squares

    Quote Originally Posted by eigenein View Post
    How can I find the set of distinct positive integers S={a,b,c,d,e,f,g,h,i} such that:

    1. a+b, b+c, a+c are squares,
    2. d+e, e+f, d+f are squares,
    3. g+h, h+i, g+i are squares,
    4. a+b+c=d+e+f=g+h+i is square?

    If there are several solutions then choose with minimal a+b+c.
    You can use following Maple program :

    Code:
    for a from 1 to 5000 do
    for b from 1 to 5000 do
    for c from 1 to 5000 do
    for d from 1 to 5000 do
    for e from 1 to 5000 do
    for f from 1 to 5000 do
    for g from 1 to 5000 do
    for h from 1 to 5000 do
    for i from 1 to 5000 do
    if not(a=b) and not(a=c) and not(a=d) and 
    not(a=e) and not(a=f) and not(a=g) and 
    not(a=h) and not(a=i) and not(b=c) and 
    not(b=d) and not(b=e) and not(b=f) and 
    not(b=g) and not(b=h) and not(b=i) and 
    not(c=d) and not(c=e) and not(c=f) and 
    not(c=g) and not(c=h) and not(c=i) and
    not(d=e) and not(d=f) and not(d=g) and
    not(d=h) and not(d=i) and not(e=f) and 
    not(e=g) and not(e=h) and not(e=i) and 
    not(f=g) and not(f=h) and not(f=i) and
    not(g=h) and not(g=i) and not(h=i) then
    if type(sqrt(a+b+c+d+e+f+g+h+i),integer) then
    print(a,b,c,d,e,f,g,h,i);
    break;
    end if;
    end if;
    end do;
    end do;
    end do;
    end do;
    end do;
    end do;
    end do;
    end do;
    end do;
    Thanks from anonimnystefy
    Follow Math Help Forum on Facebook and Google+

  6. #6
    MHF Contributor
    Joined
    Dec 2007
    From
    Ottawa, Canada
    Posts
    3,098
    Thanks
    67

    Re: Sums of integers are squares

    No Princeps; you have:
    "if type(sqrt(a+b+c+d+e+f+g+h+i),integer)"
    but problem is:
    "4. a+b+c = d+e+f = g+h+i is a square"

    Plus I'm flabbergasted that Maple would "suggest" such a program;
    make it only 50 instead of 5000 as limit for the 9 variables:
    50^9 / (32 000 000 * 1 000 000) = ~61 years !
    (32 million = seconds in 1 year rounded up; computer speed:1 million = number per second)

    With 5000, that becomes: 61 035 156 250 000 000 000 years.

    Ways to drastically reduce "the search" are required; as example:
    a < b < c ; d > a and d < e < f ; g > d and g < h < i (prevents duplicates).

    Another is to eliminate 2 full loops by calculating f and i:
    f = a + b + c - d - e ; i = a + b + c - g - h
    and completely get out of the current loop if above results in f =< e or i =< h

    I got "lucky!" by assigning 1000 as limit to a, d, g; 2000 to b, e, h; 3000 to c, f, i.
    Thanks from princeps
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Senior Member
    Joined
    Nov 2011
    From
    Crna Gora
    Posts
    420
    Thanks
    64

    Re: Sums of integers are squares

    Code:
    for a from 1 to 3000 do
    for b from 1 to 3000 do
    for c from 1 to 3000 do
    for d from 1 to 3000 do
    for e from 1 to 3000 do
    for f from 1 to 3000 do
    for g from 1 to 3000 do
    for h from 1 to 3000 do
    for i from 1 to 3000 do
    if not(a=b) and not(a=c) and not(a=d) and 
    not(a=e) and not(a=f) and not(a=g) and 
    not(a=h) and not(a=i) and not(b=c) and 
    not(b=d) and not(b=e) and not(b=f) and 
    not(b=g) and not(b=h) and not(b=i) and 
    not(c=d) and not(c=e) and not(c=f) and 
    not(c=g) and not(c=h) and not(c=i) and
    not(d=e) and not(d=f) and not(d=g) and
    not(d=h) and not(d=i) and not(e=f) and 
    not(e=g) and not(e=h) and not(e=i) and 
    not(f=g) and not(f=h) and not(f=i) and
    not(g=h) and not(g=i) and not(h=i) then
    if a+b+c=d+e+f and a+b+c=g+h+i then
    if type(sqrt(a+b+c),integer) then
    print(a,b,c,d,e,f,g,h,i);
    break;
    end if;
    end if;
    end if;
    end do;
    end do;
    end do;
    end do;
    end do;
    end do;
    end do;
    end do;
    end do;
    Follow Math Help Forum on Facebook and Google+

  8. #8
    MHF Contributor
    Joined
    Dec 2007
    From
    Ottawa, Canada
    Posts
    3,098
    Thanks
    67

    Re: Sums of integers are squares

    Still a big mess, Princeps...did you try and run that?

    Anyway, you're missing that these must be squares: a+b, a+c, b+c, d+e, d+f, e+f, g+h, g+i, h+i.

    Mine, in UBasic, looks like:

    k = 3000
    for a = 1 to k-2
    for b = a+1 to k-1
    if sqrt(a+b) <> integer then next b
    for c = b+1 to k
    if sqrt(a+c) <> integer or sqrt(b+c) <> integer or sqrt(a+b+c) <> integer then next c

    for d = a+1 to k-2
    for e = d+1 to k-1
    if sqrt(d+e) <> integer or e=b or e=c then next e
    f = a+b+c-d-e
    if f=<e then cancel loop e : next d
    if f=b or f=c then next e
    if sqrt(d+f) <> integer or sqrt(e+f) <> integer then next e

    for g = d+1 to k-2
    for h = g+1 to k-1
    if sqrt(g+h) <> integer or h=b or h=c or h=e or h=f then next h
    i = a+b+c-g-h
    if i=<h then cancel loop h : next g
    if i=b or i=c or i=e or i=f then next h
    if sqrt(g+i) <> integer or sqrt(h+i) <> integer then next h

    print a,b,c,d,e,f,g,h,i

    next a
    next b
    next c
    next d
    next e
    next g
    next h
    next h
    Follow Math Help Forum on Facebook and Google+

  9. #9
    MHF Contributor
    Joined
    Dec 2007
    From
    Ottawa, Canada
    Posts
    3,098
    Thanks
    67

    Re: Sums of integers are squares

    Found a quicker way: calculate and stay as squares instead of full loops;
    like, if a=3, then b = 6, 13, 22, 33...

    Came across this interest case, a = 209:

    Code:
     209 2000 8816    416 4625 5984    824 1025 9176
     209 2000 8816    416 4625 5984    824 3800 6401
     209 2000 8816    416 4625 5984   1224 2376 7425
     209 2000 8816    824 1025 9176   1224 2376 7425
     209 2000 8816    824 3800 6401   1224 2376 7425
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Newbie
    Joined
    Nov 2010
    Posts
    21

    Re: Sums of integers are squares

    This is interesting. No one has the solution yet? I'll definitely take a shot at it. I'm getting 77 integer triplets below 10,000 that meet the conditions a+b, a+c, b+c, a+b+c are all square. If that is correct then the full solution could involve some very large numbers. The algorithm will probably need to be fairly efficient.
    Edit: Oh, I didn't realize Wilmer gave solutions. It obviously isn't generating all triplets either.
    Perhaps we can come up with a more difficult, but similar problem?
    Last edited by browni3141; April 9th 2012 at 08:37 PM.
    Follow Math Help Forum on Facebook and Google+

  11. #11
    MHF Contributor
    Joined
    Dec 2007
    From
    Ottawa, Canada
    Posts
    3,098
    Thanks
    67

    Re: Sums of integers are squares

    Quote Originally Posted by browni3141 View Post
    This is interesting. No one has the solution yet? I'll definitely take a shot at it. I'm getting 77 integer triplets below 10,000 that meet the conditions a+b, a+c, b+c, a+b+c are all square. If that is correct then the full solution could involve some very large numbers. The algorithm will probably need to be fairly efficient.
    Edit: Oh, I didn't realize Wilmer gave solutions. It obviously isn't generating all triplets either.
    Perhaps we can come up with a more difficult, but similar problem?
    Thanks for stepping in, Mr.B; I was feeling "lonely"!

    Agree with your 77 integer triplets below 10,000; and I get 996 integer triplets below 100,000.
    My program gets the 77 in 6 seconds; the 996 in 10 minutes, 33 seconds.
    I'm curious: are your times faster?

    The OP asked only for the minimum case; I gave him that already:
    minimum case = 2401: a=97 b=192 c=2112 ; d=376 e=465 f=1560 ; g=720 h=801 i=880

    Not sure what you mean with this:
    "Edit: Oh, I didn't realize Wilmer gave solutions. It obviously isn't generating all triplets either."
    I do generate ALL triplets; I don't want to type them all!

    Like, under 10,000, there are 9 cases; the minimum is the one I show above; the maximum is:
    maximum case = 9604: a=388 b=768 c=8448 ; d=1504 e=1860 f=6240 ; g=2880 h=3204 i=3520
    Follow Math Help Forum on Facebook and Google+

  12. #12
    Newbie
    Joined
    Nov 2010
    Posts
    21

    Re: Sums of integers are squares

    Quote Originally Posted by Wilmer View Post
    Thanks for stepping in, Mr.B; I was feeling "lonely"!

    Agree with your 77 integer triplets below 10,000; and I get 996 integer triplets below 100,000.
    My program gets the 77 in 6 seconds; the 996 in 10 minutes, 33 seconds.
    I'm curious: are your times faster?

    The OP asked only for the minimum case; I gave him that already:
    minimum case = 2401: a=97 b=192 c=2112 ; d=376 e=465 f=1560 ; g=720 h=801 i=880

    Not sure what you mean with this:
    "Edit: Oh, I didn't realize Wilmer gave solutions. It obviously isn't generating all triplets either."
    I do generate ALL triplets; I don't want to type them all!

    Like, under 10,000, there are 9 cases; the minimum is the one I show above; the maximum is:
    maximum case = 9604: a=388 b=768 c=8448 ; d=1504 e=1860 f=6240 ; g=2880 h=3204 i=3520
    Sorry, there are a couple lot of things wrong with my last post. When I said "It obviously isn't generating all triplets either.", I was talking about my program, but I didn't realize when I said it how out of context it was. It appears that my program actually does generate all of them. I thought that since my program didn't generate the ones you gave, it was wrong, but I forgot that my program had only generated triplets for a+b+c < 10,000.

    My times are much slower, but I didn't try to optimize the algorithm at all. I'm sure I can make them much faster. Generating all triplets a+b+c < 10,000 takes about 5 minutes right now.
    Follow Math Help Forum on Facebook and Google+

  13. #13
    MHF Contributor
    Joined
    Dec 2007
    From
    Ottawa, Canada
    Posts
    3,098
    Thanks
    67

    Re: Sums of integers are squares

    I see. Here's my "way", triplets under 10,000:

    For u = 8 to 99 : v = u^2 [since we're dealing with squares, get the square first]

    For a = 1 to INT(v/3) - 1 [since a<b<c, a has to be < 1/3 of the square]

    For w = CEILING(SQRT(2*a + 1)) to HIGH [in order to calculate b, since a+b = a square]

    b = w^2 - a

    c = v - a - b

    If c =< b then end loop: next a

    If (a + c) and (b + c) are squares then print a;b;c;v

    Next w
    Next a
    Next u

    So mainly:
    get the square first
    calculate b
    default c
    Follow Math Help Forum on Facebook and Google+

  14. #14
    Newbie
    Joined
    Nov 2010
    Posts
    21

    Re: Sums of integers are squares

    For a+b+c < 1,000,000 I'm getting an answer in about half a second, and although all of the solutions are valid, I'm definitely not getting a full set of solutions this time (for a+b+c < 10,000 I'm getting 69 triplets in about 0 ms). I'll post my algorithm here when I've worked out the bugs. There is actually still a lot more optimizing that may be possible as well.
    Follow Math Help Forum on Facebook and Google+

  15. #15
    MHF Contributor
    Joined
    Dec 2007
    From
    Ottawa, Canada
    Posts
    3,098
    Thanks
    67

    Re: Sums of integers are squares

    Quote Originally Posted by browni3141 View Post
    For a+b+c < 1,000,000 I'm getting an answer in about half a second, and although all of the solutions are valid, I'm definitely not getting a full set of solutions this time (for a+b+c < 10,000 I'm getting 69 triplets in about 0 ms). I'll post my algorithm here when I've worked out the bugs. There is actually still a lot more optimizing that may be possible as well.
    Not sure what you're doing...what does "getting an answer" mean?
    Also, are you getting all 9 variables? Getting triplets is not what's asked for.
    Follow Math Help Forum on Facebook and Google+

Page 1 of 2 12 LastLast

Similar Math Help Forum Discussions

  1. Sums of squares
    Posted in the Number Theory Forum
    Replies: 13
    Last Post: January 7th 2010, 03:17 PM
  2. Sums of squares exercise
    Posted in the Number Theory Forum
    Replies: 2
    Last Post: December 19th 2009, 01:15 PM
  3. Sums of squares of positive integers prime to n
    Posted in the Number Theory Forum
    Replies: 1
    Last Post: November 23rd 2009, 11:15 PM
  4. Help with sums of integers please.
    Posted in the Algebra Forum
    Replies: 3
    Last Post: May 2nd 2009, 09:55 AM
  5. Sums of Squares problem.
    Posted in the Number Theory Forum
    Replies: 5
    Last Post: April 7th 2008, 01:22 AM

Search Tags


/mathhelpforum @mathhelpforum