By sum of squares is meant the representation of an integer as a sum of 4 squares ( or five in some special cases ). By difference of squares is meant the usual $$x^2-y^2=(x-y)\cdot (x+y)$$ Here we consider the case of numbers that are products $$N=pq$$ of two primes of the form $$r=6k+1$$ In this case we can write $$p=q+6k$$ since the difference between p and q is always a multiple of 6. We can then write $$N=pq=(q+6k)\cdot q= q^2 + 6kq$$ This is a classic quadratic equation that has integer solutions if the discriminant $$36k^2 + 4N = m^2$$ or equivalently if $$N + 9k^2 = m^2$$ Clearly the term $$9k^2$$ represents $$((p-q)/2)^2$$ and $$m^2$$ represents $$((p+q)/2)^2$$ So we are looking for integer solutions of $$N + 9k^2 = m^2$$ by asking which square of a very particular form should be added to N to get another square of a very particular but different form. For numbers that are products of two primes of the form $$r=6k+1$$ m is of the form $$m^2 = (10+3j)^2$$ We know that N can be written as a sum of 3 or 4 squares ( Lagrange theorem ) so we are in a position to write $$N = a^2 +b^2 +c^2 +d^2$$ So the final form of our equation for the discriminant is $$a^2 +b^2 +c^2 +d^2 + 9k^2 = (10 + 3j)^2$$ There are two cases to consider. If N is a sum of 3 squares, then this equation says to add another square of the special form $$9k^2$$ to get yet another square that is a sum of 4 squares of the special form $$m^2 = (10 + 3j)^2$$ And if N is a sum of 4 squares, none of which is 0, then the equation tells us to add another square $$9k^2$$ to get yet another square $$m^2$$ that is the sum of 5 squares.
We know there is always a solution if N is composite and we also know that the factorization is unique so there is only one possible square $$9k^2$$ that, when added to N, will produce a square $$m^2$$ as a sum of either 4 or 5 squares.
Usually we are given a number and asked to find its representation as a sum of 2 or 3 or 4 or 5 squares. In this case, we have a partial representation of an unknown square $$m^2$$ and are asked to find the missing square $$9k^2$$ to get its full representation as a sum of 4 or 5 squares.
So the question simply is:
Is it possible to use the partial information provided by N as a sum of 3 or 4 squares to construct a representation of a square $$m^2$$ as a sum of 4 or 5 squares in an efficient way? By working backward so to speak.
Trying every value of k starting with $$k=1$$ is certainly not an efficient way. It may work fine for small numbers but will not work for large numbers. It is easy to see that this method, if in fact it is proven to work, can be extended to numbers that are product of primes that are of the form $$(6k-1)$$ or products of the form $$(6i+1)\cdot (6j-1)$$
edit-1-
Let's take the example of $$N=7*13=91$$ N can be written as $$N=91= 9^2 + 3^2 + 1^2 $$ And the equation become $$ (9^2 + 3^2 + 1^2) + 9k^2 = (10 +3j)^2$$ In this simple case, we can see that k=1 is the solution and the right hand side becomes $$rhs= 9^2 +3^2 + 1^2 +3^2 = 100$$ Once we have found the representation of the rhs as a sum of 4 squares, we can then use the equation $$N= 10^2 -3^2 = 7*13 $$
This is very interesting post. I have worked with this method in the past to solve $n=p*q$ problem. Fermat's theorem works well for all odd numbers. The only difference is that I was working with two squares. I have tried re-balance L-shapes from the square to a semiprime, and the numbers of steps would indicate distance needed to calculate size of smaller square - example:
$21=9+7+5$
To form a square based on Fermat's theorem which is $25$ you need another square: $4$
Now add random square to arithmetic progression ($21$), let say $49$.
$49=13+11+...+3+1$
You end up with a shape of area equal to $21+49=70$
$49-13=36...-11=25...(-9)<21$
$21+13=34...+11=45...(+9)>49$
In the case of random square for example $81$ it would be $25$ and $77$ accordingly, but in case of $49$ which is $7*7$ two steps of operations will cut this to $5*5$ from where you subtract semiprime to have $4$ - exactly the difference between $25$,$21$ and $45$,$49$.
This works perfectly for $n$ and $q$ relatively close to each other. $33$ is the good example where the problem of distance appears.
I still believe that this method might still work for all odd numbers, therefore for all prime numbers. I have spent 7 years based on this method looking for a solution, but not for nothing. I have found pattern in prime numbers, thus I have stopped working using above approach. I can only tell you that you are on the good way to discover some amazing things. Good luck!