Skip to content

A simple and functional polynomial calculator written in Haskell. It supports normalization, addition, multiplication, and derivation of polynomials represented as algebraic expressions.

Notifications You must be signed in to change notification settings

andrebarbosa02/haskell-polynomial-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Haskell Polynomial Calculator

A functional and menu-driven polynomial calculator written in Haskell.
It supports normalization, addition, multiplication, and derivation of polynomials written in standard algebraic form (e.g. 2x + 5x^2 + 3).


Features

1. Normalize

Simplifies a polynomial by combining like terms and ordering them by degree.

Examples

Input: 2x + 5x^2 + 3 + 4x^2 + x
Output: 9x^2 + 3x + 3
Input: x^3 + 2x^3 - x + 4 - 4
Output: 3x^3 - x

2. Add

Sums two polynomials.

Examples

Input:
First polynomial: 2x^2 + 3x + 1
Second polynomial: x^2 + 5
Output: 3x^2 + 3x + 6
Input:
First polynomial: 4x^3 + x
Second polynomial: 2x^3 + 3x^2 + 5
Output: 6x^3 + 3x^2 + x + 5

3. Multiply

Multiplies two polynomials.

Examples

Input:
First polynomial: x + 1
Second polynomial: x + 2
Output: x^2 + 3x + 2
Input:
First polynomial: 2x^2 + 3
Second polynomial: x + 4
Output: 2x^3 + 8x^2 + 3x + 12

4. Derivate

Computes the derivative of a polynomial.

Examples

Input: 3x^3 + 2x + 1
Output: 9x^2 + 2
Input: 5x^4 + x^2 + 7x
Output: 20x^3 + 2x + 7

Menu Options

When you run the program, a text menu appears:

What operation do you want to do?
1) Normalize
2) Add
3) Multiply
4) Derivate

0) Exit

Enter the number corresponding to the operation you want to perform, then provide the polynomial(s) as prompted.


Usage

Compile and run using GHC:

runghc main.hs

About

A simple and functional polynomial calculator written in Haskell. It supports normalization, addition, multiplication, and derivation of polynomials represented as algebraic expressions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published