This is a complete collection of classes that allows you to easily use polynomials in your programs. The polynomials can be parsed from a string or entered manually as coefficients. Once the polynomial object is constructed, you can do just about anything with it. I have overloaded all the operators I could think of, allowing you to add a string representation of a polynomial to an existing one in the easiest way possible. There are even methods that allow you to draw a polynomial onto graphics or a bitmap (This does mean you will need to reference System. Drawing if you intend to use it in a console app).

Thanks to the simplicity of. Net's xml comments and NDoc3. There is also a help file that can be viewed online, and an offline version is included in the downloads. For additional help, just email me: at [email protected]. It is also highly likely that there will be bugs. If so, please email me. The only thing currently missing is full-length examples (or any example) for the members. I am working on it though, in addition to a few larger projects based around the classes. If you write something that uses this, then please email me with a link so I can have a look.

Contained in the download are the following files.

  • Polynomials.dll (the assembly)
  • Documentation.chm (the help file)
  • ClassLibrary.cs (source code)


using System;
using Polynomials;
namespace PolynomialTester
    class Program
        static void Main(string[] args)
            // Parse polynomials from strings:
            Polynomial p = new Polynomial("x^2+4x-3");
            Console.WriteLine("Polynomial: " + p.ToString());
            // Operators have been overloaded:
            Console.WriteLine(p.ToString() + " + x^3-3x+4 = " + (p + "x^3-2x+4").ToString());
            // Assignments as well as standard operators:
            p += "x^3-2x+4";
            // Access coefficients by their letter:
            p['a'] = 3;
            // Setting the top value to zero shortens the array by 1.
            Console.Write("Before: " + p.MaxIndex.ToString() + ", After: ");
            p['a'] = 0;
            // Solve for real roots
            PolynomialPoint[] array = p.Solve();
            Console.WriteLine("Real roots of '" + p.ToString() + "' are:");
            foreach (PolynomialPoint point in array)
                Console.WriteLine(" * " + point.ToString());

Similar Articles