Ask your own question, for FREE!
Mathematics 22 Online
OpenStudy (kainui):

Sum of squares question.

OpenStudy (kainui):

For \(a,b,c \in \mathbb{N}^*\) (a,b,c are positive integers not including 0) We've got this function here: \[f(a,b,c) = a^2+b^2+c^2\] The first and smallest value it can take is \(f(1,1,1)=3\). What's the 14th largest value it can take?

ganeshie8 (ganeshie8):

don't you mean 14th smallest value ?

OpenStudy (kainui):

Yeah haha

ganeshie8 (ganeshie8):

presumably (a, b, c) is an ordered pair so (1, 2, 2) is different from (2, 2, 1)

OpenStudy (welshfella):

I guess you can do this by just incrementing

OpenStudy (kainui):

f(1,2,2)=f(2,2,1) so it will be indistinguishable

Parth (parthkohli):

yeah you're just looking for the values it can take

OpenStudy (kainui):

I think there's a way with complex numbers to extract the terms from this generating function of the partition function: \[\left(\sum_{a=1}^\infty x^{a^2} \right)\left(\sum_{b=1}^\infty x^{b^2} \right)\left(\sum_{c=1}^\infty x^{c^2} \right) =\sum_{a=1}^\infty \sum_{b=1}^\infty \sum_{c=1}^\infty x^{a^2+b^2+c^2} \] Since \(f=a^2+b^2+c^2\), \[=\sum_{f=3}^\infty P(f) x^f\] The 14th nonzero P(f) means f is the answer. :X

OpenStudy (kainui):

This is by no means the answer, but it's as far as I can get :o

ganeshie8 (ganeshie8):

n+n*((n-1) choose 2)+ n*(n-1)*(n-2)

Miracrown (miracrown):

:)

ganeshie8 (ganeshie8):

i think solving `n+n*((n-1) choose 2)+ n*(n-1)*(n-2) = k` gives the max(a,b,c) in the kth term

Miracrown (miracrown):

Yea

OpenStudy (kainui):

Oh, how come?

OpenStudy (shadowlegendx):

The sum of two squares is 2square

ganeshie8 (ganeshie8):

scratch that, doesn' twork...

Miracrown (miracrown):

Why did we have to go through with the partition function etc? Cant we just generate the first 14 values easily? Is it that difficult?

OpenStudy (kainui):

Nah we didn't have to I just thought it might have ended up with a closed form for fun.

OpenStudy (christos):

couldn't that be any permutation of a,b,c = 1,2,2

OpenStudy (christos):

ah the 14th

jhonyy9 (jhonyy9):

1. 1-1-1 2. 1-1-2^2 3. 1-2^2 -1 4. 2^2 -1-1 5. 2^2 -2^2 -1 6. ------- this is the way till 14th term ?

OpenStudy (kainui):

No, the way to the 14th term is like: 1: (1,1,1) 2: (1,1,2), (1,2,1), (2,1,1) 3: (1,2,2), (2,1,2), (2,2,1) 4: (1,1,3), (1,3,1), (3,1,1) ...

OpenStudy (christos):

1 1 1 1 1 2 1 2 2 2 2 2 1 2 3 2 2 3 2 3 3 3 3 3 2 3 4 3 3 4 3 4 4 4 4 4 3 4 5 4 4 5 so it's any permutation of a,b,c = 4,4,5 :D

OpenStudy (kainui):

Maybe I've not been clear enough in asking the question, sorry! What I mean is that I am only looking for increasing values of \(f(a,b,c)\) regardless of the permutations of values of a,b, and c. @Christos you've skipped the (1,1,3) term and some others too I think. It's sorta hard cause the order gets lost, it's not exactly clear without evaluating what's larger, for instance, \(f(1,1,3)\) or \(f(2,2,2)\).

OpenStudy (christos):

nah its wrong

OpenStudy (kainui):

It turns out the answer is that the 14th smallest one is when f=27. It's interesting because it's the first value that can be expressed as a sum of 3 squares in more than 1 way, \[f(3,3,3)=f(1,1,5)\]

OpenStudy (christos):

from itertools import combinations_with_replacement a = list(combinations_with_replacement(range(1,5),3)) b = [] for i in range(len(a)): b.append(a[i][0]**2 + a[i][1]**2 + a[i][2]**2) g = map(None,a,b) g = sorted(g, key=itemgetter(1)) answer = g[13] >>> print answer ((3, 3, 3), 27)

OpenStudy (christos):

for a^3 b^3 c^3 ---> ((1, 3, 4), 92)

OpenStudy (kainui):

Oooh cool :D You might like this site https://repl.it/ you can use it to send code to people with the program ready to compile. I did something similar to you to brute force my answer, but I used Java.

OpenStudy (christos):

((2, 3, 3), 3) ((1, 4, 4), 9) ((3, 3, 3), 27) ((1, 3, 4), 92) ((1, 3, 4), 338) ((1, 3, 4), 1268) ((1, 3, 4), 4826) ((1, 3, 4), 18572) ((1, 3, 4), 72098) ((1, 3, 4), 281828)

OpenStudy (christos):

oh I see :D:D

OpenStudy (christos):

https://repl.it/CBoh

OpenStudy (christos):

first result is buggy

OpenStudy (christos):

actually first and second since first ---> 0 second --->1

OpenStudy (christos):

not sure about the fourth and onwards

OpenStudy (kainui):

my approach is sorta less cool as yours since you're using a map, so I am not able to use it to do as much as you, but here it is, hit run https://repl.it/CBom

OpenStudy (christos):

i see

OpenStudy (kainui):

hey do you do project euler?

OpenStudy (christos):

Yea I used to solve problems there, what's your username ?

OpenStudy (kainui):

https://projecteuler.net/progress=Kainui Friend key 515695_59af051bf075df0d0763d75d3df7cf69

OpenStudy (christos):

funny thing I remember I solved a lot of those first problems last year , may be in other accounts bah

OpenStudy (kainui):

Yeah I've solve a handful of them but didn't get around to programming the thing, I really just like the math part more haha

OpenStudy (christos):

xd

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!