Polynomial Calculator

With implementation in C language using Borland C++ Builder 6.0
Click HERE to post your comments

Introduction

Polynomial arithmetic is a classic application of linked lists. Such polynomial operations are addition, subtraction, multiplication, division and the like. In this machine problem, we have only implemented addition, subtraction and differentiation operations using Single Linked Linear Lists.

Given a valid input polynomial as a function of x, y, and z, canonically ordered or not, the program is capable of performing polynomial operations described previously and output the results in non-canonical form.

Simple deletion and insertion are performed on linked list structure for the dynamic growth and shrink of the structure size.

Problem Statement

Given a polynomials as a function of x, y, and z, the program must be capable performing arithmetic calculations like subtraction, addition and differentiation.

Problem Solution

  1. Polynomial addition
    1. Input the polynomial f(x,z,y) and g(x,y,z) to linked structure fx and gx, respectively.
    2. Add the coefficient of each terms of gx whose variables are equal to fx.
    3. Linked the terms of gx to fx whose variables are not equal to fx
    4. Fx will now be the sum of the two polynomials.
  2. Polynomial subtraction
    1. Input the polynomial f(x,z,y) and g(x,y,z) to linked structure fx and gx, respectively.
    2. Multiply the coefficient of g(x,y,z) by –1.
    3. Add the coefficient of each terms of gx whose variables are equal to fx.
    4. Linked the terms of gx to fx whose variables are not equal to fx
    5. Fx will now be the difference of the two polynomials.
  3. Polynomial differentiation
    1. Input the polynomial f(x,y,z) to fx.
    2. Multiply the coefficient with the exponent and subtract the exponent by 1 of the variable of each term which is differentiated with respect to that variable.
    3. Do until fx points to NULL;
    4. Fx will now be the first derivative of the polynomial with respect to the that variable.

Implementation

The algorithm was implemented in C programming Language using Borland C++ Builder 6.0 Development Environment . The program was tested on the example given on the specification and it outputs the same result. Various examples was also tested and outputs a correct value.

Conclusion

Although linked list data structure is not easy to implement, it is quite more practical and or even necessary to use for polynomial operations where the size of the structure grow and shrink dynamically during the run time process.

Downloads

To download the following files, point your mouse, "right click" then "Save Target As" for Internet Explorer or "Save Link As" for Mozila Firefox
miras.zip - Contains the source code in C language, stand alone executable file, and Full documentation

Linkblog

Sponsored Links