MATH CHALLENGE

Posted by Glen on Sept. 1, 2010, 8:08 p.m.

So uh.

a^2 + b^2 + c^2 = 2009

What's a,b,c. There's more than one possibility. My professor asked this question today. No one got it. (Including me. idk the answer).

Comments

Killpill28 14 years, 10 months ago

sqrt(2009/3) = 25.87791851

a, b, and c are these.

I couldn't make the fraction.

As long as a, b and c add up to 2009/3, it works. Right?

DesertFox 14 years, 10 months ago

One answer is:

8, 24, 37

and so is:

22, 25, 30

Edit: Meh, I was shh-ing these to Glen but since _Player_ spoiled…

All possible integer answers (excluding answers with 0 as a number):

(2, 18, 41)

(2, 22, 39)

(3, 8, 44)

(3, 20, 40)

(4, 12, 43)

(6, 23, 38)

(7, 14, 42)

(8, 24, 37)

(9, 22, 38)

(12, 29, 32)

(16, 27, 32)

(18, 23, 34)

(21, 28, 28)

(22, 25, 30)

noshenim 14 years, 10 months ago

Here's my solution xD:

Quote:

#include <cstdlib>

#include <iostream>

#include <fstream>

#include <math.h>

using namespace std;

#define PREC 256

#define EPSILON 0.0000000001

#define rt2009 44.821869662029940805417523722353

int main(int argc, char *argv[])

{

ofstream thefile;

thefile.open("result.txt");

double a,b,c;

for(a=0;a<=rt2009;a+=rt2009/PREC){

for(b=0;b<=sqrt(2009-a*a);b+=sqrt(2009-a*a)/PREC){

if(a*a+b*b<=2009){

c = sqrt( 2009-a*a-b*b );

if( fabs(a*a+b*b+c*c-2009.0f) <= EPSILON ){

printf("A: %0.0f, B: %0.0f, C: %0.0f; \n",a,b,c);

thefile << "A: " << a << ",B: " << b << ",C: " << c << "\n";}}}}

thefile.close();

while(1){ /* lololol */ }

return EXIT_SUCCESS;

}

(warning – 2mb) http://64digits.com/users/_Player_/result.txt

I don't know the algebraic solution though, although there is probably none…

Integer solutions:

A: 0,B: 28,C: 35

A: 0,B: 35,C: 28

A: 2,B: 18,C: 41

A: 2,B: 22,C: 39

A: 2,B: 39,C: 22

A: 2,B: 41,C: 18

A: 3,B: 8,C: 44

A: 3,B: 20,C: 40

A: 3,B: 40,C: 20

A: 3,B: 44,C: 8

A: 4,B: 12,C: 43

A: 4,B: 43,C: 12

A: 6,B: 23,C: 38

A: 6,B: 38,C: 23

A: 7,B: 14,C: 42

A: 7,B: 42,C: 14

A: 8,B: 3,C: 44

A: 8,B: 24,C: 37

A: 8,B: 37,C: 24

A: 8,B: 44,C: 3

A: 9,B: 22,C: 38

A: 9,B: 38,C: 22

A: 12,B: 4,C: 43

A: 12,B: 29,C: 32

A: 12,B: 32,C: 29

A: 12,B: 43,C: 4

A: 14,B: 7,C: 42

A: 14,B: 42,C: 7

A: 16,B: 27,C: 32

A: 16,B: 32,C: 27

A: 18,B: 2,C: 41

A: 18,B: 23,C: 34

A: 18,B: 34,C: 23

A: 18,B: 41,C: 2

A: 20,B: 3,C: 40

A: 20,B: 40,C: 3

A: 21,B: 28,C: 28

A: 22,B: 2,C: 39

A: 22,B: 9,C: 38

A: 22,B: 25,C: 30

A: 22,B: 30,C: 25

A: 22,B: 38,C: 9

A: 22,B: 39,C: 2

A: 23,B: 6,C: 38

A: 23,B: 18,C: 34

A: 23,B: 34,C: 18

A: 23,B: 38,C: 6

A: 24,B: 8,C: 37

A: 24,B: 37,C: 8

A: 25,B: 22,C: 30

A: 25,B: 30,C: 22

A: 27,B: 16,C: 32

A: 27,B: 32,C: 16

A: 28,B: 0,C: 35

A: 28,B: 21,C: 28

A: 28,B: 28,C: 21

A: 28,B: 35,C: 0

A: 29,B: 12,C: 32

A: 29,B: 32,C: 12

A: 30,B: 22,C: 25

A: 30,B: 25,C: 22

A: 32,B: 12,C: 29

A: 32,B: 16,C: 27

A: 32,B: 27,C: 16

A: 32,B: 29,C: 12

A: 34,B: 18,C: 23

A: 34,B: 23,C: 18

A: 35,B: 0,C: 28

A: 35,B: 28,C: 0

A: 37,B: 8,C: 24

A: 37,B: 24,C: 8

A: 38,B: 6,C: 23

A: 38,B: 9,C: 22

A: 38,B: 22,C: 9

A: 38,B: 23,C: 6

A: 39,B: 2,C: 22

A: 39,B: 22,C: 2

A: 40,B: 3,C: 20

A: 40,B: 20,C: 3

A: 41,B: 2,C: 18

A: 41,B: 18,C: 2

A: 42,B: 7,C: 14

A: 42,B: 14,C: 7

A: 43,B: 4,C: 12

A: 43,B: 12,C: 4

A: 44,B: 3,C: 8

A: 44,B: 8,C: 3

DesertFox 14 years, 10 months ago

@Player - I'm assuming that he means integers only. Also, there's a much simpler way to do it:

int max_val=ceil(sqrt(2009));//maximum viable number (0^2 + 0^2 + max_val^2)

for(int x = 1; x <= max_val; x++)
{
[tab]for(int y = x; y <= max_val; y++)
[tab]{
[tab][tab]for(int z = y; z <= max_val; z++)
[tab][tab]{
[tab][tab][tab]if(x*x + y*y + z*z == 2009)
[tab][tab][tab][tab]cout << x << "," << y << "," << z << "\n";
[tab][tab]}
[tab]}
}

Not only will this code run faster, it also removes duplicate entries like (A: 44,B: 8,C: 3) and (A: 3,B: 8,C: 44)

Josea 14 years, 10 months ago

Also, you can consider that as the sphere centered on (0,0,0) with radius sqrt(2009), and then you would have infinite real solutions.

sirxemic 14 years, 10 months ago

Yeah, that is the answer: the sphere with center point (0,0,0) with radius sqrt(2009). The perfect representation of the infinite number of answers :D

Scott_AW 14 years, 10 months ago

a=3

b=20

c=40

Mordi 14 years, 10 months ago

Wouldn't be too hard to write a small program that could "brute force" it, but that's probably considered cheating.

noshenim 14 years, 10 months ago

@Mordi

Desert fox and I have each done that and posted the codes >_>

Glen 14 years, 10 months ago

Thanks :D