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.
|
|
****************************
Getting Started
****************************
Before starting with this guide, one should follow the instructions for :doc:`installation`.
A Quick Tour through pycarl
===========================
We start by launching the python 3 interpreter::
$ python3
First we import pycarl::
>>> import pycarl
Pycarl can use two different number types: ``gmp`` and ``cln``.
In this example we will use ``gmp`` numbers and therefore import the corresponding module::
>>> import pycarl.gmp
Simple arithmetic operations
----------------------------
.. seealso:: `01-getting-started.py <https://github.com/moves-rwth/pycarl/blob/master/examples/01-getting-started.py>`_
We start by doing some simple arithmetic operations.
First we create two variables ``x`` and ``y``::
>>> pycarl.clear_variable_pool()
>>> x = pycarl.Variable("x")
>>> y = pycarl.Variable("y")
We perform some operations on polynomials by using the common arithmetic operations of python::
>>> pol1 = x * x + pycarl.gmp.Integer(2)
>>> pol2 = y + pycarl.gmp.Integer(1)
>>> result = pol1 * pol2
>>> print("({}) * ({}) = {}".format(pol1, pol2, result))
(x^2+2) * (y+1) = x^2*y+2*y+x^2+2
|