4

I am looking for a C++-compatible package that can do arithmetic with algebraic numbers. (Note: an algebraic number means a number that is a root of a polynomial with integer coefficients, so it is not given as a decimal or rational expression).

Mathematica handles algebraic numbers as "root objects", which are represented by polynomials with a choice of root. Then two such root objects can be added, multiplied, etc, and then reduced, to get a new root object.

Is there some software that does the same thing in C++? I have seen some fancy number theory packages that do various things with number field extensions, but I would prefer something simple than can just do basic arithmetic with algebraic numbers, i.e. addition, subtraction, multipication, division, reducing, testing for equality. .

Paul
  • 41
  • 1

2 Answers2

1

Givaro: C++ library for arithmetic and algebraic computations

BenH
  • 2,100
  • 2
  • 22
  • 33
0

Mathematica has a way of interfacing with C++. If this could work for you, I would recommend this method, as your needs may be too localized to find a package which already has everything you need and not much else.

http://reference.wolfram.com/mathematica/guide/CLanguageInterface.html

Zéychin
  • 4,135
  • 2
  • 28
  • 27
  • Thanks, interfacing with Mathematica may indeed be the best approach. I'm a bit worried about the speed, if the program has to call Mathematica for every algebraic operation, but maybe it won't be too bad. – Paul Sep 21 '11 at 16:41
  • If you check out the page I linked, then you'll notice that you can export a Mathematica function to C source code. You can then place this code in your project. Thus, this won't be calling external executables and will not have that overhead. – Zéychin Sep 21 '11 at 17:41