# Sum of two numbers as sum of two squares

Given a number $$X$$ , we need to find a number $$Y$$ such that $$X+Y$$ can be expressed as sum of two squares (say $$a^2+b^2$$).

It can be observed that number of $$Y$$ are infinite (and can be generated by plugging value of a and b in $$a²+b²-X$$).

But, how can we find $$Y$$ for given number $$X$$ so X+Y² can be expressed as sum of two squares?

Edit : for example if $$X=32$$ is given, than $$Y$$ can be $$3$$ such that $$32 + 3² = 41$$ and $$41$$ can be split into sum of squares of $$4$$ and $$5$$ ($$4² + 5² = 41$$).

• $y = 0$ should do for the vast majority of cases (Wikipedia). Jun 1, 2020 at 6:29
• But $X$ may not satisfies $X+Y² =a²+b²$ if $Y=0$ ( for example when $X$ is given 7 or 12) Jun 1, 2020 at 7:14
• If $X+Y^2=a^2+b^2$, then $X-a^2=(b+Y)(b-Y)$. Hence you can factorise $X-a^2$ and solve for $Y$. Jun 1, 2020 at 7:37
• Can't we just get $Y=a^2+b^2-X$ for $a>b>X$? Jun 1, 2020 at 8:24

Choose an $$a$$ so that $$X-a^2$$ is odd: $$X-a^2=2Y+1=(Y+1)^2-Y^2,$$and that implies $$X+Y^2=a^2+(Y+1)^2.$$

If $$X$$ is even number, we can get a solution below.
$$(a-b)^2+2ab=a^2+b^2$$
Hence $$Y=a-b, X=2ab$$.