Open Happypig375 opened 3 years ago
This problem of representing an integer as sum of two perfect square dates back to Diophantus of Alexandria. Later in 17t century Fermat noted it in his notebook but without a proof. A complete proof was first produced by Euler. Many more proofs followed after that.
From an algorithmic perspective we have many methods of doing it in exponential time when c is composite. In case c is prime there is a method by Stan Wagon to calculate it in polynomial time. (https://www.jstor.org/stable/2323912). We can combine this with an approach as shown here http://nonagon.org/ExLibris/fermat-sum-two-squares-calculator to build a desired solution.
I would love to contribute if you can give me some more detailed specification.
@upam00 we currently do not support solving over multiple variables (we only have Solve
over one variable), so I'm not sure yet how we're going to address alike issues.
On the other hand, it doesn't mean you can't contribute. You are very much welcome to add a algorithm of solving this problem outside of the Entity
class, but as a separate function. Let me show where and how.
Here you can see a subclass which accumulates our number theory functions. This is the public API where you will add your function.
This folder is where you add a internal static class
with your algorithm.
The class to work with is Entity.Number.Integer
, but you can address it with Integer
thanks to C# 10's global usings.
Feel free to ask more questions! You can also join our Discord chat and/or ask your questiosn after opening a draft PR.
Thanks.
Thanks for the info. I guess we don't need an equation solver. Will built the solution using prime factorization. Which is available I guess. I am joining the discord server and discuss details there. Cheers.
The package I want to suggest the idea to: AngouriMath Solve
a^2 + b^2 = c provided a in ZZ and b in ZZ and c in { 16, 25, 36, 49 } and 0 < a < c and 0 < b < c
:a = 3, b = 4, c = 25
https://www.youtube.com/watch?v=jLSDWgIWXh8