OFFSET
2,1
COMMENTS
This sequence was suggested to me by Moshe Shmuel Newman.
This is A135998 with the exponent 4 replacing 3.
From M. F. Hasler, Feb 03 2024: (Start)
Can it happen that (x,y) and (x',y') yield the same minimal absolute difference, but with opposite signs? If so, how is a(n) defined in this case?
Without the condition y < n, the trivial "solution" (x, y) = (1, n) would always yield a(n) = -1. With the condition, there is no admissible pair (x,y) for n = 1, whence a(1) is undefined. (End)
EXAMPLE
Here are the calculations for the first few values.
For 2, the only possible values for x and y are 1,1, so we have
a(2) = 2^4 - 1^4 - 1^4 = 16 - 2 = 14.
For 3, y can be 1 or 2. if y is 1, x is 1 as well, and if y=2, then x can be 1 or 2.
3^4 - 1^4 - 1^4 = 79
3^4 - 1^4 - 2^4 = 64
3^4 - 2^4 - 2^4 = 49.
The smallest absolute value is in the last case, so a(3) = 49.
MATHEMATICA
nend = 100; For[n = 2, n <= nend, n++, a[n] = 0]; For[n = 2, n <= nend, n++, min = n^4; For[y = 1, y <= n - 1, y++, For [x = y, x <= n - 1, x++, changed = False; sol = n^4 - x^4 - y^4; If[(sol < min) && (sol > 0), min = sol; changed = True]; If[(Abs[sol] < min) && (sol < 0), min = -sol; changed = True]; If[changed, a[n] = sol]]]]; Print[t = Table[a[i], {i, 2, nend}]] (* or *)
a[n_] := SortBy[n^4 - Flatten[Table[x^4 + y^4, {x, n-1}, {y, x}]], Abs][[1]]; Array[a, 99, 2] (* Giovanni Resta, Jul 05 2019 *)
PROG
(PARI) A308834(n, p=4) = { my(np=n^p, m=np); for(y=max(sqrtnint(np\2, p), 1), n-1, my(x = sqrtnint(np - y^p, p), dy = np-y^p, d = if(dy-x^p > (x+1)^p-dy && x < n-1, dy-(x+1)^p, dy-x^p)); abs(d) < abs(m) && abs(m=d) < 2 && break); m} \\ M. F. Hasler, Feb 03 2024
CROSSREFS
KEYWORD
sign
AUTHOR
David S. Newman, Jun 27 2019
STATUS
approved