Ramanujan's number is $1729$ which is the least natural number which can be expressed as the sum of two perfect cubes in two different ways. But can we find a number which can be expressed as the sum of two perfect squares in two different ways. One example I got is $50$ which is $49+1$ and $25+25$. But here second pair contains same numbers. Does any one have other examples ?
[Math] Natural number which can be expressed as sum of two perfect squares in two different ways
elementary-number-theorynumber theorysums-of-squares
Related Solutions
In the paper Characterizing the Sum of Two Cubes, Kevin Broughan gives the relevant theorem,
Theorem: Let $N$ be a positive integer. Then the equation $N = x^3 + y^3$ has a solution in positive integers $x,y$ if and only if the following conditions are satisfied:
There exists a divisor $m|N$ with $N^{1/3}\leq m \leq (4N)^{1/3}.$
And $\sqrt{m^2-4\frac{m^2-N/m}{3}}$ is an integer.
The sequence of integers $F(n)$,
$$\begin{aligned} F(n) &= a^3+b^3 = (2 n + 6 n^2 + 6 n^3 + n^4)^3 + (n + 3 n^2 + 3 n^3 + 2 n^4)^3\\ &= c^3+d^3 = (1 + 4 n + 6 n^2 + 5 n^3 + 2 n^4)^3 + (-1 - 4 n - 6 n^2 - 2 n^3 + n^4)^3 \end{aligned}$$
for integer $n>3$ apparently is expressible as a sum of two positive integer cubes in exactly and only two ways.
$$\begin{aligned} F(4) &= 744^3+756^3 = 945^3+15^3\\ F(5) &= 1535^3+1705^3 = 2046^3+204^3\\ &\;\vdots\\ F(60) &=14277720^3+26578860^3 = 27021841^3+12506159^3 \end{aligned}$$
Using Broughan's theorem, I have tested $F(n)$ from $n=4-60$ and, per $n$, it has only two solutions $m$, implying in that range it is a sum of two cubes in only two ways. Can somebody with a faster computer and better code test it for a higher range and see when (if ever) the proposed statement breaks down? Incidentally, we have the nice relations,
$$a+b = 3n(n+1)^3$$
$$c+d = 3n^3(n+1)$$
Note: $F(60)$ is already much beyond the range of taxicab $T_3$ which is the smallest number that is the sum of two positive integer cubes in three ways.
$$T_3 \approx 444.01^3 = 167^3+436^3 = 228^3+423^3 = 255^3+414^3$$
(Using the theorem, this yields 3 values for $m$.)
Much depends on whether you want just the count of such arrangements or to list all of them.
If you were to "neglect" the arrangement of summands, as your example $4=3+1=1+3$ and $4=2+2$ suggests, then you are asking about integer partitions.
Efficient ways to count these are known, and it can even be said there exists an exact formula. The book The Theory of Partitions by George Andrews (1976) has the details. See the section Approximation formulas of the Wikipedia article for the convergent series called the Hardy–Ramanujan–Rademacher formula.
If instead you want to (say) write a program to list all the possible integer partitions, then this is an easier task (although such a program might run a long time for all but the smallest inputs). With the limitation of the largest summand to be allowed, one can express the task recursively:
If $M$ is the largest summand allowed to express $N$, choose some multiple $k$ of those summands $M$ to be used (descending from $\lfloor N/M \rfloor$ to 0).
For each such choice $k \ge 0$, recursively list all the possible integer partitions of $N - kM$ allowing summands at most $M-1$ to be used, prefixed by $k$ copies of summand $M$.
Best Answer
Note that $a^2 + b^2 = c^2 + d^2$ is equivalent to $a^2 - c^2 = d^2 - b^2$, i.e. $(a-c)(a+c) = (d-b)(d+b)$. If we factor any odd number $m$ as $m = uv$, where $u$ and $v$ are both odd and $u < v$, we can write this as $m = (a-c)(a+c)$ where $a = (u+v)/2$ and $c = (v-u)/2$. So any odd number with more than one factorization of this type gives an example.
Thus from $m = 15 = 1 \cdot 15 = 3 \cdot 5$, we get $8^2 - 7^2 = 4^2 - 1^2$, or $1^2 + 8^2 = 4^2 + 7^2$.
From $m = 21 = 1 \cdot 21 = 3 \cdot 7$ we get $11^2 - 10^2 = 5^2 - 2^2$, or $2^2 + 11^2 = 5^2 + 10^2$.