Anda di halaman 1dari 2

polynomial calculator

with implementation in c language using borland


c++ builder 6.0

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.

Anda mungkin juga menyukai