Some simple algebra functions in C#