You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB

2 months ago
  1. ****************************
  2. Getting Started
  3. ****************************
  4. Before starting with this guide, one should follow the instructions for :doc:`installation`.
  5. A Quick Tour through pycarl
  6. ===========================
  7. We start by launching the python 3 interpreter::
  8. $ python3
  9. First we import pycarl::
  10. >>> import pycarl
  11. Pycarl can use two different number types: ``gmp`` and ``cln``.
  12. In this example we will use ``gmp`` numbers and therefore import the corresponding module::
  13. >>> import pycarl.gmp
  14. Simple arithmetic operations
  15. ----------------------------
  16. .. seealso:: `01-getting-started.py <https://github.com/moves-rwth/pycarl/blob/master/examples/01-getting-started.py>`_
  17. We start by doing some simple arithmetic operations.
  18. First we create two variables ``x`` and ``y``::
  19. >>> pycarl.clear_variable_pool()
  20. >>> x = pycarl.Variable("x")
  21. >>> y = pycarl.Variable("y")
  22. We perform some operations on polynomials by using the common arithmetic operations of python::
  23. >>> pol1 = x * x + pycarl.gmp.Integer(2)
  24. >>> pol2 = y + pycarl.gmp.Integer(1)
  25. >>> result = pol1 * pol2
  26. >>> print("({}) * ({}) = {}".format(pol1, pol2, result))
  27. (x^2+2) * (y+1) = x^2*y+2*y+x^2+2