README.txt 8.26 KB
Newer Older
Frederic HAN's avatar
Frederic HAN committed
1
2

=============
Frederic HAN's avatar
Frederic HAN committed
3
Giacpy (Sage version)
Frederic HAN's avatar
Frederic HAN committed
4
5
=============

Frederic HAN's avatar
Frederic HAN committed
6
:Name: giacpy_sage
Frederic HAN's avatar
Frederic HAN committed
7
8
9
10
11
12
13
14
:Summary: A Cython frontend to the c++ library giac. (Computer Algebra System)
:Author: Frederic Han
:Author-email: frederic.han@imj-prg.fr
:Copyright: 2012 Frederic Han
:License:  GPL v2 or above
:Home-page: http://www.math.jussieu.fr/~han/xcas/giacpy/


Frederic HAN's avatar
Frederic HAN committed
15
This is the sage version of giacpy. Since 0.6 it is named giacpy_sage to avoid confusions
Frederic HAN's avatar
Frederic HAN committed
16

Frederic HAN's avatar
Frederic HAN committed
17
- Giacpy is an interface to the c++ giac library. This interface is built with cython, and the resulting speed is similar to giac's one.
Frederic HAN's avatar
Frederic HAN committed
18

Frederic HAN's avatar
Frederic HAN committed
19
- Giac is a general purpose Computer algebra system by Bernard Parisse released under GPLv3.
Frederic HAN's avatar
Frederic HAN committed
20

Frederic HAN's avatar
Frederic HAN committed
21
22
      * http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
      * It is build on C and C++ libraries:
Frederic HAN's avatar
Frederic HAN committed
23
        NTL (arithmetic), GSL (numerics), GMP (big integers), MPFR (bigfloats)
Frederic HAN's avatar
Frederic HAN committed
24
25
26
      * It  provides fast  algorithms  for multivariate polynomial operations (product, GCD, factorisation) and
      * symbolic  computations: solver, simplifications, limits/series, integration, summation...
      * Linear Algebra with numerical or symbolic coefficients.
Frederic HAN's avatar
Frederic HAN committed
27
28
29
30
31
32
33
34
35


AUTHORS:

- Frederic Han (2013-09-23): initial version


EXAMPLES:

Frederic HAN's avatar
Frederic HAN committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
- The class Pygen is the main tool to interact from python/sage with the c++ library giac via cython.

  The initialisation of a Pygen just create an object in giac, but the mathematical computation  is not done. This class is mainly for cython users.


  Here A is a Pygen element, and it is ready for any giac function.

  ::

        sage: from giacpy_sage import *    # random
        //...
        sage: A=Pygen('2+2');A
        2+2
        sage: A.eval()
        4
Frederic HAN's avatar
Frederic HAN committed
51

Frederic HAN's avatar
Frederic HAN committed
52
  In general, you may prefer to directly create a Pygen and execute the evaluation in giac. This is exactly  the meaning of the libgiac() function.
Frederic HAN's avatar
Frederic HAN committed
53

Frederic HAN's avatar
Frederic HAN committed
54
  ::
Frederic HAN's avatar
Frederic HAN committed
55

Frederic HAN's avatar
Frederic HAN committed
56
57
58
59
60
61
62
63
64
        sage: a=libgiac('2+2');a;isinstance(a,Pygen)
        4
        True

- Most common usage of this package in sage will be with the libgiac() function. This function is just the composition of the Pygen initialisation and the evaluation of this object in giac.

  ::

        sage: from giacpy_sage import libgiac,giacsettings
Frederic HAN's avatar
Frederic HAN committed
65
66
67
68
69
70
71
        sage: x,y,z=libgiac('x,y,z');  # add some giac objects
        sage: f=(x+3*y)/(x+z+1)^2 -(x+z+1)^2/(x+3*y)
        sage: f.factor()
        (3*y-x^2-2*x*z-x-z^2-2*z-1)*(3*y+x^2+2*x*z+3*x+z^2+2*z+1)/((x+z+1)^2*(3*y+x))
        sage: f.normal()
        (-x^4-4*x^3*z-4*x^3-6*x^2*z^2-12*x^2*z-5*x^2+6*x*y-4*x*z^3-12*x*z^2-12*x*z-4*x+9*y^2-z^4-4*z^3-6*z^2-4*z-1)/(x^3+3*x^2*y+2*x^2*z+2*x^2+6*x*y*z+6*x*y+x*z^2+2*x*z+x+3*y*z^2+6*y*z+3*y)

Frederic HAN's avatar
Frederic HAN committed
72
- To obtain more hints on giacpy_sage consider the help of the :func:`libgiac<_giac>` function.
Frederic HAN's avatar
Frederic HAN committed
73

Frederic HAN's avatar
Frederic HAN committed
74
  ::
Frederic HAN's avatar
Frederic HAN committed
75
76
77

        sage: libgiac?             # doctest: +SKIP

Frederic HAN's avatar
Frederic HAN committed
78
- Some settings of giac are available via the ``giacsettings`` element. (Ex: maximal number of threads in computations, allowing probabilistic algorithms or not...
Frederic HAN's avatar
Frederic HAN committed
79

Frederic HAN's avatar
Frederic HAN committed
80
  ::
Frederic HAN's avatar
Frederic HAN committed
81
82
83
84
85
86
87
88
89
90
91
92
93

        sage: R=PolynomialRing(QQ,8,'x')
        sage: I=sage.rings.ideal.Katsura(R,8)
        sage: giacsettings.proba_epsilon=1e-15;
        sage: Igiac=libgiac(I.gens());
        sage: time Bgiac=Igiac.gbasis([R.gens()],'revlex')  # doctest: +SKIP
        Running a probabilistic check for the reconstructed Groebner basis. If successfull, error probability is less than 1e-15 and is estimated to be less than 10^-109. Use proba_epsilon:=0 to certify (this takes more time).
        Time: CPU 0.46 s, Wall: 0.50 s
        sage: giacsettings.proba_epsilon=0;
        sage: Igiac=libgiac(I.gens());
        sage: time Bgiac=Igiac.gbasis([R.gens()],'revlex') # doctest: +SKIP
        Time: CPU 2.74 s, Wall: 2.75 s

Frederic HAN's avatar
Frederic HAN committed
94
  ::
Frederic HAN's avatar
Frederic HAN committed
95

Frederic HAN's avatar
Frederic HAN committed
96
        sage: from giacpy_sage import *
Frederic HAN's avatar
Frederic HAN committed
97
98
99
100
101
102
103
104
105
        sage: x=libgiac('x');f=1/(2+sin(5*x))
        sage: f.int()
        2/5/sqrt(3)*(atan((2*tan(5*x/2)+1)/sqrt(3))+pi*floor(5*x/2/pi+1/2))
        sage: f.series(x,0,3)
        1/2-5/4*x+25/8*x^2-125/48*x^3+x^4*order_size(x)
        sage: libgiac(sqrt(5)+pi).approx(100)
        5.377660631089582934871817052010779119637787758986631545245841837718337331924013898042449233720899343


Frederic HAN's avatar
Frederic HAN committed
106
SEEALSO:
Frederic HAN's avatar
Frederic HAN committed
107

Frederic HAN's avatar
Frederic HAN committed
108
    ``libgiac``, ``giacsettings``, ``Pygen``,``loadgiacgen``
Frederic HAN's avatar
Frederic HAN committed
109
110
111



Frederic HAN's avatar
Frederic HAN committed
112
GETTING HELP:
Frederic HAN's avatar
Frederic HAN committed
113

Frederic HAN's avatar
Frederic HAN committed
114
- To obtain some help on a giac keyword use the help() method. In sage the htmlhelp() method for Pygen element is disabled. Just use the ? or .help() method.
Frederic HAN's avatar
Frederic HAN committed
115

Frederic HAN's avatar
Frederic HAN committed
116
  ::
Frederic HAN's avatar
Frederic HAN committed
117

Frederic HAN's avatar
Frederic HAN committed
118
119
120
121
122
        sage: libgiac.gcd?             # doctest: +SKIP
        "Returns the greatest common divisor of 2 polynomials of several variables or of 2 integers or of 2 rationals.
        (Intg or Poly),(Intg or Poly)
        gcd(45,75);gcd(15/7,50/9);gcd(x^2-2*x+1,x^3-1);gcd(t^2-2*t+1,t^2+t-2);gcd((x^2-1)*(y^2-1)*z^2,x^3*y^3*z+(-(y^3))*z+x^3*z-z)
        lcm,euler,modgcd,ezgcd,psrgcd,heugcd,Gcd"
Frederic HAN's avatar
Frederic HAN committed
123

Frederic HAN's avatar
Frederic HAN committed
124
- You can find full html documentation about the **giac** functions  at:
Frederic HAN's avatar
Frederic HAN committed
125

Frederic HAN's avatar
Frederic HAN committed
126
      * http://www-fourier.ujf-grenoble.fr/~parisse/giac/doc/en/cascmd_en/
Frederic HAN's avatar
Frederic HAN committed
127

Frederic HAN's avatar
Frederic HAN committed
128
      * http://www-fourier.ujf-grenoble.fr/~parisse/giac/doc/fr/cascmd_fr/
Frederic HAN's avatar
Frederic HAN committed
129

Frederic HAN's avatar
Frederic HAN committed
130
      * http://www-fourier.ujf-grenoble.fr/~parisse/giac/doc/el/cascmd_el/
Frederic HAN's avatar
Frederic HAN committed
131

Frederic HAN's avatar
Frederic HAN committed
132
      * or in :doc:`$SAGE_LOCAL/share/giac/doc/en/cascmd_en/index.html`
Frederic HAN's avatar
Frederic HAN committed
133
134
135



Frederic HAN's avatar
Frederic HAN committed
136
REMARK:
Frederic HAN's avatar
Frederic HAN committed
137

Frederic HAN's avatar
Frederic HAN committed
138
- Graphics 2D Output via qcas (the qt frontend to giac) is removed in the sage version of giacpy.
Frederic HAN's avatar
Frederic HAN committed
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201





---------
Changelog
---------


   * Version 0.2: 
      - Add a comparison function to Pygen. (with coersion) 
      - Add a basic definition for most giac functions.
      - Add some help.

   * Version 0.2.1: 
      - Add __neg__ and __pos__ support for Pygen. (Ex: -pi)
      - Change __repr__ to hide too long outputs.
      - Make ** be the default printing for powers in giac.

   * Version 0.2.2: 
      - Change Pygen() to Pygen('NULL'). (Ex: rand())
      - Add direct acces to the python double value of a Pygen: a._double
      - Add  conversion to giac modulars via the operator %
      - Add  ctrl-c support during list initialisation and iteration
      - Modification of __getitem__ to allow formal variables with indexes.
      - Add htmlhelp method for Pygen objects.
      - Improve the giac initialisation of Python long integers. (basic Horner method instead of strings)
      - Improve  help(giac) and doctests
      - Add support for the slice notation with giac lists

   * Version 0.2.3: 
      - Fix Pygen() None initialisation. Add crash test and improve speed in _wrap_gen
      - Add a small Makefile
      - Add a GiacSettings class with some frontends to the cas settings.
      - Add French keywords

   * Version 0.2.4:
      - Update giac 1.1 keywords.

   * Version 0.3:
      - Add a qt output for 2d graphics via qcas.
      - Fixes for giac 1.1

   * Version 0.4:
      - Fixes for Python 3 compatibility
      - Qt/qcas can be disabled at compilation. (cf setup.py)
      - 0.4.1:
	  + add some giac keywords.
      	  + add proba_epsilon in GiacSetting. 
	  + test if the html doc is present locally, otherwise open the web doc.
      - 0.4.2:
          + add sqrtflag and complexflag in GiacSettings.
          + add methods for going back to sage: _latex_, _matrix_, _vector_, _integer_, _rational_
          + add tuple support in indexes. Ex A[1,2]
      - 0.4.3:
	  + add methods: sage, _symbolic_ (current status: ZZ, QQ, ZZ/nZZ, string. Else try raw
            string evaluation in SR) 
	  + add a giac memento in docstring
      - 0.4.4:
          + add a pari_unlock after interruptions
      - 0.4.5:
          + Fixes some try/sig_on positions due to some  giac errors returned.
Frederic HAN's avatar
0.4.8    
Frederic HAN committed
202
203
      - 0.4.8:
          + Fixes to build with sage 6.8
204
205
      - 0.4.9:
          + Fix a sig_on() pb in Pygen __iter__
Frederic HAN's avatar
0.4.9    
Frederic HAN committed
206
          + Fix evaluation PB with some symbols. (sqrt(3)/libgiac('x')).factor()
Frederic HAN's avatar
0.5.0    
Frederic HAN committed
207
208
      - 0.5.0:
          + Fix a memory leak in _wrap_gen
Frederic HAN's avatar
0.5.1    
Frederic HAN committed
209
210
      - 0.5.1:
          + remove __init__.py (gives pb with cython 0.22.p5)
Frederic HAN's avatar
0.5.2    
Frederic HAN committed
211
212
      - 0.5.2:
          + add giac keywords. (ex: eliminate ...)
Frederic HAN's avatar
Frederic HAN committed
213
214
      - 0.5.3:
          + use cythonize in setup.py for recent cython.
Frederic HAN's avatar
Frederic HAN committed
215
216
      - 0.5.4:
          + Doctest fixes because matrix(M,ring) is deprecated
Frederic HAN's avatar
0.5.5    
Frederic HAN committed
217
218
      - 0.5.5:
          + use cysignals instead of interrupt.pxi
219
220
      - 0.5.6:
          + use of GIAC_neg to fix a broken built with cython 0.24
Frederic HAN's avatar
Frederic HAN committed
221
222
      - 0.6:
          + Change the module name from giacpy to giacpy_sage
223
224
      - 0.6.8:
          + add c++11 flag in extra_compil_args of setup.py to follow sagelib behaviour.
Frederic HAN's avatar
0.7.0    
Frederic HAN committed
225
      - 0.7.0:
226
227
228
          + 2 doctest fixes for python3 compatibility.
      - 0.7.1:
          + Fix missing include with giac 1.5.0.75 and later versions.