Sum of squares question.
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?
don't you mean 14th smallest value ?
Yeah haha
presumably (a, b, c) is an ordered pair so (1, 2, 2) is different from (2, 2, 1)
I guess you can do this by just incrementing
f(1,2,2)=f(2,2,1) so it will be indistinguishable
yeah you're just looking for the values it can take
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
This is by no means the answer, but it's as far as I can get :o
n+n*((n-1) choose 2)+ n*(n-1)*(n-2)
:)
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
Yea
Oh, how come?
The sum of two squares is 2square
scratch that, doesn' twork...
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?
Nah we didn't have to I just thought it might have ended up with a closed form for fun.
couldn't that be any permutation of a,b,c = 1,2,2
ah the 14th
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 ?
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) ...
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
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)\).
nah its wrong
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)\]
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)
for a^3 b^3 c^3 ---> ((1, 3, 4), 92)
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.
((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)
oh I see :D:D
first result is buggy
actually first and second since first ---> 0 second --->1
not sure about the fourth and onwards
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
i see
hey do you do project euler?
Yea I used to solve problems there, what's your username ?
https://projecteuler.net/progress=Kainui Friend key 515695_59af051bf075df0d0763d75d3df7cf69
funny thing I remember I solved a lot of those first problems last year , may be in other accounts bah
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
xd
Join our real-time social learning platform and learn together with your friends!