\documentclass[12pt,a4paper]{article} \usepackage[latin1]{inputenc} \usepackage[frenchb]{babel} \usepackage[margin=2.5cm]{geometry} \usepackage[garamond]{mathdesign} \renewcommand{\ttdefault}{lmtt} \usepackage{graphicx} \usepackage{xcolor} \parindent0pt \newcommand{\xcas}{{\bfseries\texttt{Xcas}}} \title{Exemples d'utilisation de \texttt{Giac}} \author{Jean-Michel Sarlat} \newcommand{\MarqueCommandeGiac}[1]{% \color[HTML]{8B7500}$\rightarrow$} \newcommand{\MarqueLaTeXGiac}{% \color[HTML]{08868B}} \newcommand{\InscriptionFigureGiac}[1]{% \begin{center} \includegraphics[width=0.7\linewidth]{#1} \end{center}} \pagestyle{empty} \begin{document} \maketitle \thispagestyle{empty} La plupart des exemples qui apparaissent ici sont tirés du \emph{tutorial} de \xcas. \section{Premiers calculs} %@Commande-1 {\MarqueCommandeGiac{1} \verb| 1/3+1/4;|} {\MarqueLaTeXGiac{\[ \frac{7}{12} \]}} %@Commande-2 {\MarqueCommandeGiac{2} \verb| sqrt(2)^5;|} {\MarqueLaTeXGiac{\[ \sqrt{2}2^{2} \]}} %@Commande-3 {\MarqueCommandeGiac{3} \verb| solve(a*x^2+b*x+c,x);|} {\MarqueLaTeXGiac{\[ [\frac{(-b+\sqrt{-\left(4ac\right)+b^{2}})}{2a},\frac{(-b-\left(\sqrt{-\left(4ac\right)+b^{2}}\right))}{2a}] \]}} %@Commande-4 {\MarqueCommandeGiac{4} \verb| 50!|} {\MarqueLaTeXGiac{\[ 30414093201713378043612608166064768844377641568960512000000000000 \]}} %@Commande-5 {\MarqueCommandeGiac{5} \verb| 2*a+b;|} {\MarqueLaTeXGiac{\[ 2a+b \]}} %@Commande-6 {\MarqueCommandeGiac{6} \verb| a/2*b;|} {\MarqueLaTeXGiac{\[ \frac{a}{2} \times b \]}} %@Commande-7 {\MarqueCommandeGiac{7} \verb| a/2/b;|} {\MarqueLaTeXGiac{\[ \frac{a}{2b} \]}} %@Commande-8 {\MarqueCommandeGiac{8} \verb| a^2*b;|} {\MarqueLaTeXGiac{\[ a^{2}b \]}} %@Commande-9 {\MarqueCommandeGiac{9} \verb| sqrt(2);|} {\MarqueLaTeXGiac{\[ \sqrt{2} \]}} %@Commande-10 {\MarqueCommandeGiac{10} \verb| evalf(sqrt(2));|} {\MarqueLaTeXGiac{\[ 1.414214 \]}} %@Commande-11 {\MarqueCommandeGiac{11} \verb| sqrt(2)-evalf(sqrt(2));|} {\MarqueLaTeXGiac{\[ 0.000000 \]}} %@Commande-12 {\MarqueCommandeGiac{12} \verb| exact(evalf(sqrt(2)))*10^9;|} {\MarqueLaTeXGiac{\[ \frac{57121500000000}{40391} \]}} %@Commande-13 {\MarqueCommandeGiac{13} \verb| exact(evalf(sqrt(2)*10^9));|} {\MarqueLaTeXGiac{\[ \frac{86487644620489}{61156} \]}} %@Commande-14 {\MarqueCommandeGiac{14} \verb| evalf(sqrt(2),50);|} {\MarqueLaTeXGiac{\[ 1.41421356237309504880168872420969807856967187537695 \]}} %@Commande-15 {\MarqueCommandeGiac{15} \verb| evalf(pi,70);|} {\MarqueLaTeXGiac{\[ 3.1415926535897932384626433832795028841971693993751058209749445923078164 \]}} %@Commande-16 {\MarqueCommandeGiac{16} \verb| Digits:=50;|} {\MarqueLaTeXGiac{\[ [0,0,0,1,0, 0.000000,50,[1,50,0,25],0,0,0] \]}} %@Commande-17 {\MarqueCommandeGiac{17} \verb| evalf(pi);|} {\MarqueLaTeXGiac{\[ 3.14159265358979323846264338327950288419716939937510 \]}} %@Commande-18 {\MarqueCommandeGiac{18} \verb| evalf(exp(pi*sqrt(163)));|} {\MarqueLaTeXGiac{\[ 0.262537412640768743999999999999250072597198185688719e18 \]}} %@Commande-19 {\MarqueCommandeGiac{19} \verb| (1+2*i)^2;|} {\MarqueLaTeXGiac{\[ -3+4*i \]}} %@Commande-20 {\MarqueCommandeGiac{20} \verb| (1+2*i)/(1-2*i);|} {\MarqueLaTeXGiac{\[ \frac{-3+4*i}{5} \]}} %@Commande-21 {\MarqueCommandeGiac{21} \verb| e^(i*pi/3);|} {\MarqueLaTeXGiac{\[ \left(2\right)^{-1}+\frac{i\sqrt{3}}{2} \]}} %@Commande-22 {\MarqueCommandeGiac{22} \verb| 1/0; (1/0)^2; -(1/0)^2;|} {\MarqueLaTeXGiac{\[ \infty ,+\infty ,-\infty \]}} \section{Manipulation des chaînes de caractères} %@Commande-23 {\MarqueCommandeGiac{23} \verb| s:="azertyuiop";|} \begin{verbatim} azertyuiop\end{verbatim} %@Commande-24 {\MarqueCommandeGiac{24} \verb| size(s);|} {\MarqueLaTeXGiac{\[ 10 \]}} %@Commande-25 {\MarqueCommandeGiac{25} \verb| s[0]+s[3]+s[size(s)-1];|} \begin{verbatim} arp\end{verbatim} %@Commande-26 {\MarqueCommandeGiac{26} \verb| concat(s[0],concat(s[3],s[size(s)-1]));|} \begin{verbatim} arp\end{verbatim} %@Commande-27 {\MarqueCommandeGiac{27} \verb| head(s);|} \begin{verbatim} a\end{verbatim} %@Commande-28 {\MarqueCommandeGiac{28} \verb| tail(s);|} \begin{verbatim} zertyuiop\end{verbatim} %@Commande-29 {\MarqueCommandeGiac{29} \verb| mid(s,3,2);|} \begin{verbatim} rt\end{verbatim} %@Commande-30 {\MarqueCommandeGiac{30} \verb| l:=asc(s);|} {\MarqueLaTeXGiac{\[ [97,122,101,114,116,121,117,105,111,112] \]}} %@Commande-31 {\MarqueCommandeGiac{31} \verb| ss:=char(l);|} \begin{verbatim} azertyuiop\end{verbatim} %@Commande-32 {\MarqueCommandeGiac{32} \verb| string(123);|} \begin{verbatim} 123\end{verbatim} %@Commande-33 {\MarqueCommandeGiac{33} \verb| expr(123);|} {\MarqueLaTeXGiac{\[ \mbox{expr}\left(123\right) \]}} %@Commande-34 {\MarqueCommandeGiac{34} \verb| expr(0123);|} {\MarqueLaTeXGiac{\[ \mbox{expr}\left(83\right) \]}} \section{Les variables} %@Commande-35 {\MarqueCommandeGiac{35} \verb| a==b;|} {\MarqueLaTeXGiac{\[ 0 \]}} %@Commande-36 {\MarqueCommandeGiac{36} \verb| a:=b;|} {\MarqueLaTeXGiac{\[ b \]}} %@Commande-37 {\MarqueCommandeGiac{37} \verb| a==b;|} {\MarqueLaTeXGiac{\[ 1 \]}} %@Commande-38 {\MarqueCommandeGiac{38} \verb| solve(a=b,a);|} {\MarqueLaTeXGiac{\[ [b] \]}} %@Commande-39 {\MarqueCommandeGiac{39} \verb| solve(2*a=b+1,a);|} {\MarqueLaTeXGiac{\[ [1] \]}} %@Commande-40 {\MarqueCommandeGiac{40} \verb| sqrt(a^2);|} {\MarqueLaTeXGiac{\[ \mbox{abs}\left(b\right) \]}} %@Commande-41 {\MarqueCommandeGiac{41} \verb| assume(a<0);|} {\MarqueLaTeXGiac{\[ a \]}} %@Commande-42 {\MarqueCommandeGiac{42} \verb| sqrt(a^2);|} {\MarqueLaTeXGiac{\[ -a \]}} %@Commande-43 {\MarqueCommandeGiac{43} \verb| assume(n,integer);|} {\MarqueLaTeXGiac{\[ DOM_INT \]}} %@Commande-44 {\MarqueCommandeGiac{44} \verb| sin(n*pi);|} {\MarqueLaTeXGiac{\[ 0 \]}} %@Commande-45 {\MarqueCommandeGiac{45} \verb| subst(a^2+1,a=1);|} {\MarqueLaTeXGiac{\[ 2 \]}} %@Commande-46 {\MarqueCommandeGiac{46} \verb| subst(a^2+1,a=sqrt(b-1));|} {\MarqueLaTeXGiac{\[ b \]}} %@Commande-47 {\MarqueCommandeGiac{47} \verb| a^2+1;|} {\MarqueLaTeXGiac{\[ a^{2}+1 \]}} \end{document}