exemple-giac
last edited on October 27, 2011 05:12 PM by admin
 Typeset
evaluate
       
evaluate
       

 

#
Si l'interface giac est perdue, (cela peut arriver par exemple apres
une interruption si giac a quitte) On peut faire quitter l'interface
pour qu'elle redemarre proprement a la prochaine utilisation de giac.
(On perd alors ce qui a ete defini dans et avec giac avant).

Si l'interface giac est perdue, (cela peut arriver par exemple apresune interruption si giac a quitte) On peut faire quitter l'interface pour qu'elle redemarre proprement a la prochaine utilisation de giac.

(On perd alors ce qui a ete defini dans et avec giac avant).

 

evaluate
       
3
2
b
Traceback (click to the left of this block for traceback)
...
ValueError: The giac session in which this object was defined is no
longer running.
3
2
b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_8.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("Yz1naWFjKDMpO2M7Z2lhYy5zZXQoJ2InLDIpO2dpYWMoJ2InKTtnaWFjLnF1aXQoKTtnaWFjKCdiJyk7YztnaWFjKDExKTs="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpzw3spP/___code___.py", line 3, in <module>
    exec compile(u"c=giac(_sage_const_3 );c;giac.set('b',_sage_const_2 );giac('b');giac.quit();giac('b');c;giac(_sage_const_11 );" + '\n', '', 'single')
  File "", line 1, in <module>
    
  File "/usr/local/sage/local/lib/python2.6/site-packages/sage/misc/displayhook.py", line 174, in displayhook
    print_obj(sys.stdout, obj)
  File "/usr/local/sage/local/lib/python2.6/site-packages/sage/misc/displayhook.py", line 142, in print_obj
    print >>out_stream, `obj`
  File "/usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/giac.py", line 976, in __repr__
    self._check_valid()
  File "/usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1136, in _check_valid
    raise ValueError, "The %s session in which this object was defined is no longer running."%P.name()
ValueError: The giac session in which this object was defined is no longer running.
evaluate
       

On peut travailler directement dans giac. Par exemple pour y definir une fonction:

evaluate
       
// Attention: x, declaree(s) comme variable(s) globale(s)
// End defining f
// Attention: x,y, declaree(s) comme variable(s) globale(s)
// End defining g
 (a,b)->if (a<b) x[a,b];; else if (a>b) -(x[b,a]); ;; ,
(k,l)->x^k-y^l
// Attention: x, declaree(s) comme variable(s) globale(s)
// End defining f
// Attention: x,y, declaree(s) comme variable(s) globale(s)
// End defining g
 (a,b)->if (a<b) x[a,b];; else if (a>b) -(x[b,a]); ;; , (k,l)->x^k-y^l
evaluate
       
evaluate
       
<class 'sage.interfaces.giac.GiacElement'>
<class 'sage.interfaces.giac.GiacElement'>
evaluate
       
(x[0,1]*x[2,3]*x[4,5]-x[0,1]*x[2,4]*x[3,5]+x[0,1]*x[2,5]*x[3,4]+x[2,3]*x\
[1,4]*x[0,5]-x[2,3]*x[1,5]*x[0,4]-x[4,5]*x[0,2]*x[1,3]+x[4,5]*x[0,3]*x[1\
,2]-x[2,4]*x[1,3]*x[0,5]+x[2,4]*x[1,5]*x[0,3]+x[3,5]*x[0,2]*x[1,4]-x[3,5\
]*x[1,2]*x[0,4]+x[2,5]*x[1,3]*x[0,4]-x[2,5]*x[1,4]*x[0,3]-x[3,4]*x[0,2]*\
x[1,5]+x[3,4]*x[1,2]*x[0,5])^2
(x[0,1]*x[2,3]*x[4,5]-x[0,1]*x[2,4]*x[3,5]+x[0,1]*x[2,5]*x[3,4]+x[2,3]*x[1,4]*x[0,5]-x[2,3]*x[1,5]*x[0,4]-x[4,5]*x[0,2]*x[1,3]+x[4,5]*x[0,3]*x[1,2]-x[2,4]*x[1,3]*x[0,5]+x[2,4]*x[1,5]*x[0,3]+x[3,5]*x[0,2]*x[1,4]-x[3,5]*x[1,2]*x[0,4]+x[2,5]*x[1,3]*x[0,4]-x[2,5]*x[1,4]*x[0,3]-x[3,4]*x[0,2]*x[1,5]+x[3,4]*x[1,2]*x[0,5])^2
evaluate
       
matrix[[0,1-y,1-y^2,1-y^3],[x-1,x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3 + x]
[   x^2 - 1    x^2 - y  x^2 - y^2 -y^3 + x^2]
[   x^3 - 1    x^3 - y  x^3 - y^2  x^3 - y^3]
<type
'sage.matrix.matrix_mpolynomial_dense.Matrix_mpolynomial_dense'>
[         0     -y + 1   -y^2 + 1   -y^3 + 1]
[     x - 1      x - y   -y^2 + x   -y^3 + x]
[   x^2 - 1    x^2 - y  x^2 - y^2 -y^3 + x^2]
[   x^3 - 1    x^3 - y  x^3 - y^2  x^3 - y^3]
<type 'sage.matrix.matrix_mpolynomial_dense.Matrix_mpolynomial_dense'>
evaluate
       
[[0, -y + 1, -y^2 + 1, -y^3 + 1], [x - 1, x - y, -y^2 + x, -y^3 + x],
[x^2 - 1, x^2 - y, x^2 - y^2, x^2 - y^3], [x^3 - 1, x^3 - y, x^3 - y^2,
x^3 - y^3]]
[[0, -y + 1, -y^2 + 1, -y^3 + 1], [x - 1, x - y, -y^2 + x, -y^3 + x], [x^2 - 1, x^2 - y, x^2 - y^2, x^2 - y^3], [x^3 - 1, x^3 - y, x^3 - y^2, x^3 - y^3]]
evaluate
       
[        0    -y + 1  -y^2 + 1  -y^3 + 1]
[    x - 1     x - y  -y^2 + x  -y^3 + x]
[  x^2 - 1   x^2 - y x^2 - y^2 x^2 - y^3]
[  x^3 - 1   x^3 - y x^3 - y^2 x^3 - y^3]
<type 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense'>
[        0    -y + 1  -y^2 + 1  -y^3 + 1]
[    x - 1     x - y  -y^2 + x  -y^3 + x]
[  x^2 - 1   x^2 - y x^2 - y^2 x^2 - y^3]
[  x^3 - 1   x^3 - y x^3 - y^2 x^3 - y^3]
<type 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense'>
evaluate
       
evaluate
       
// Giac share root-directory:/usr/share/giac/

File: /usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/giac.py

Type: <class 'sage.interfaces.giac.GiacFunction'>

Definition: giac.sum(*args, **kwds)

Docstring:


Help for sum:
sum(Expr,Var,VarMin(a),VarMax(b),[VarStep(p)])
Discret sum (with 2 or 4 arguments return then sum from a to b if a<=b or of the opposite of the sum from b+1 to a-1 if a>b+1 or 0 if a=b+1) or the discret primitive or sum of the elements of a list or a sequence
See also: 1/ + 
Ex1:sum(1/n^2,n,1,17)
Ex2:sum(1/n^2,n=1..17)
Ex3:sum(1/n^2,n,17,1)
Ex4:sum(1/n^2,n=17..1)
Ex5:sum(1/n^2,n,17,1,1)
Ex6:sum(1/n^2,n,1,17,2)
Ex7:sum(1,2,3,4)
Ex8:sum([[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9]]) 
Ex9:sum(1/(x*(x+1)),x)
Ex10:sum(cos(n*x),n)
// Giac share root-directory:/usr/share/giac/

File: /usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/giac.py

Type: <class 'sage.interfaces.giac.GiacFunction'>

Definition: giac.sum(*args, **kwds)

Docstring:


Help for sum:
sum(Expr,Var,VarMin(a),VarMax(b),[VarStep(p)])
Discret sum (with 2 or 4 arguments return then sum from a to b if a<=b or of the opposite of the sum from b+1 to a-1 if a>b+1 or 0 if a=b+1) or the discret primitive or sum of the elements of a list or a sequence
See also: 1/ + 
Ex1:sum(1/n^2,n,1,17)
Ex2:sum(1/n^2,n=1..17)
Ex3:sum(1/n^2,n,17,1)
Ex4:sum(1/n^2,n=17..1)
Ex5:sum(1/n^2,n,17,1,1)
Ex6:sum(1/n^2,n,1,17,2)
Ex7:sum(1,2,3,4)
Ex8:sum([[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9]]) 
Ex9:sum(1/(x*(x+1)),x)
Ex10:sum(cos(n*x),n)
evaluate
       
(pi*exp(pi)^2+pi+exp(pi)^2-1)/(2*exp(pi)^2-2)
(pi*exp(pi)^2+pi+exp(pi)^2-1)/(2*exp(pi)^2-2)
evaluate
       
evaluate
       
evaluate
       
(((((x-95)*(x-4)-1615)*(x-3)-6315)*(x-2)-5954)*(x-1)-734)*x
(((((x-95)*(x-4)-1615)*(x-3)-6315)*(x-2)-5954)*(x-1)-734)*x
evaluate
       
evaluate
       
 
 Pour utiliser unapply avec plusieurs arguments il faut mettre des ' ' pour qu'il n'y ait qu'un seul argument de transmis.
evaluate
       
evaluate
       
sqrt(5)+1-y
sqrt(5)+1
sqrt(5)+1-y
sqrt(5)+1
evaluate
       
evaluate
       

Lorsque l'on travaille avec des objets giac des le debut, il n'y a pas beaucoup de temps perdu dans l'interface.

evaluate
       
0.29798007011413574
0.29798007011413574
evaluate
       
57155
57155
evaluate
       
3
4.138059139251709
3
4.138059139251709
evaluate