Pour mémoriser une fonction comme celle définie par f(x)=x^2+1 voici le code que j'utilise dans giac.in :
Code : Tout sélectionner
unarchive("giac.sav");
Resultat:=(f(x):=x^2+1);
Sortie:=fopen("giac.var");
for j in VARS do
  si eval(j,1)!='Resultat' et eval(j,1)!='Sortie' et eval(j,1)!='j' alors
    print(eval(j,1),type(j));
    si type(j)==DOM_FUNC  et eval(j,1)!='Resultat' alors
       fprint(Sortie,Unquoted,eval(j,1));
       fprint(Sortie,Unquoted,"(x):=");
       fprint(Sortie,Unquoted,j[3]);
    sinon
       fprint(Sortie,Unquoted,eval(j,1));
       fprint(Sortie,Unquoted,"=");
       fprint(Sortie,Unquoted,j);
    fsi;
    fprint(Sortie,Unquoted,"\n");
  fsi;
od;
fclose(Sortie);
archive("giac.sav");Code : Tout sélectionner
Resultat(x):=x**2+1
Sortie=pointer(0x7f6234000fb0,0)
f(x):=x**2+1
2) comment faire pour définir des fonctions écrites en langage Python comme ?
Code : Tout sélectionner
def g(x):
	if x>0:
		return 2*x
	else:
		return 0
Cordialement.