Merge pull request #4 from diogogithub/add_polynomial
Implement add_polynomial
This commit is contained in:
commit
63473ec912
14
polimani.pl
14
polimani.pl
@ -581,3 +581,17 @@ scale_polynomial(P, C, S) :-
|
||||
%% Tests:
|
||||
%% ?- scale_polynomial(3*x^2, 2, S).
|
||||
%@ S = 2*3*x^2.
|
||||
|
||||
%% add_polynomial(+P1:polynomial,+P2:polynomial,-S:polynomial) is det
|
||||
%
|
||||
% S = P1 + P2
|
||||
%
|
||||
add_polynomial(P1, P2, S) :-
|
||||
polynomial_to_list(P1, L1),
|
||||
polynomial_to_list(P2, L2),
|
||||
append(L1, L2, LA),
|
||||
join_like_terms(LA,LJ),
|
||||
list_to_polynomial(LJ, P),
|
||||
simplify_polynomial(P, S).
|
||||
%% Tests:
|
||||
%
|
||||
|
Reference in New Issue
Block a user