No Description

Hugo Sales f3efa7cbf0 Merge branch 'nlp' of github.com:diogogithub/polynomialmani.pl 5 years ago
.gitignore 43340345d6 Some small improvements. while on the bus 5 years ago
COPYING 7a22fe136b Add COPYING 5 years ago
algumas_observacoes_suplementares.md 07f341b5fa Update algumas_observacoes_suplementares.md 5 years ago
assignment.pdf 9f6c972ea9 Add assignment to repo 5 years ago
polymani.pl f3efa7cbf0 Merge branch 'nlp' of github.com:diogogithub/polynomialmani.pl 5 years ago

# POLYnomial MANI.PuLation

A symbolic polynomial calculator in Prolog.

## How to run

In a terminal, run

``````\$ swipl
``````

Inside the REPl, load the file

``````?- ["polymani.pl"].
``````

Note: Don't forget the dot at the end of the line.

The user available predicates are: 1) poly2list/2 2) simpoly_list/2 3) simpoly/2 4) scalepoly/3 5) addpoly/3

`poly2list/2` - transforms a list representing a polynomial (second argument) into a polynomial represented as an expression (first argument) and vice-versa.

`simpolylist/2` - simplifies a polynomial represented as a list into another polynomial as a list.

`simpoly/2` - simplifies a polynomial represented as an expression as another polynomial as an expression.

`scalepoly/3` - multiplies a polynomial represented as an expression by a scalar resulting in a second polynomial. The two first arguments are assumed to be ground. The polynomial resulting from the sum is in simplified form.

`addpoly/3` - adds two polynomials as expressions resulting in a third one. The two first arguments are assumed to be ground. The polynomial resulting from the sum is in simplified form.

Note: `foo/N` means the funciton `foo` has `N` parameters (this is known as arity). These names are the ones requested in the assignment.

## Tests

``````:- ["polymani.pl"].
%@ true.

?- poly2list(2*x^2+3*x+5*x^17-7*x^21+3*x^3+25*x^5-4.3, S).
%@ S = [-4.3, 25*x^5, 3*x^3, -7*x^21, 5*x^17, 3*x, 2*x^2].

?- simpoly_list([x*x*x, x^3, 5*x^3, 4.2*z, 2, 42.6, 42*y, 5*z, z^7, z*y^1337, 0], L).
%@ L = [44.6, 7*x^3, 9.2*z, 42*y, y^1337*z, z^7].

?- simpoly(1+x+1+x+1+x+1+x^3+5*x^3+42*x^1337+0, S).
%@ S = 42*x^1337+6*x^3+3*x+4.

?- scalepoly(2*x^2+3*x+5*x^17-7*x^21+3*x^3-23*x^4+25*x^5-4.3, 42, S).
%@ S = 1050*x^5+210*x^17+126*x^3+126*x+84*x^2-294*x^21-966*x^4-180.6.

%@ S = 42*x^1337+25*x^5+5*x^17+3*x+2*x^2-1*x^4-9.3.
``````

## Authors

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program, in the file "COPYING". If not, see http://www.gnu.org/licenses/.

``````IMPORTANT NOTE: The GNU Affero General Public License (AGPL) has
*different requirements* from the "regular" GPL. In particular, if
you make modifications to the POLYnomial MANI.PuLation source code on your server,
you *MUST MAKE AVAILABLE* the modified version of the source code
to your users under the same license. This is a legal requirement
of using the software, and if you do not wish to share your
modifications, *YOU MAY NOT INSTALL POLYNOMIAL MANI.PULATION*.
``````

Additional library software has been made available (and were referenced in the "Built With" section. All of it is Free Software and can be distributed under liberal terms, but those terms may differ in detail from the AGPL's particulars. See each package's license file in their official repository for additional terms.