Symbolic algebra and Mathematics with Xcas

# Symbolic algebra and Mathematics with Xcas ### Renée De Graeve, Bernard Parisse University of Grenoble I Corrected by Jay Belanger Optimization section written by Luka Marohnić

© 2002, 2007 Renée De Graeve, Bernard Parisse
`renee.degraeve@wanadoo.fr`
`bernard.parisse@ujf-grenoble.fr`

# Contents

# Chapter 1 Index

# Index

, 5.2.3 ’, 5.12.3 ’*’, 5.16.1 ’+’, 5.11.1, 5.14.1, 5.16.1 ’-’, 5.11.1, 5.14.1, 5.16.1 ’/’, 5.16.1 (), 5.36.1 *, 5.16.1, 5.32.4, 5.39.7, 5.43.3 *=, 4.5.3 +, 5.4.9, 5.4.10, 5.11.1, 5.14.1, 5.16.1, 5.32.2, 5.36.7, 5.39.3, 5.43.2 +,-,*,/,^, 5.9.2 +=, 4.5.3 +infinity, 5.1 ,, 5.36.2 -, 5.11.1, 5.14.1, 5.16.1, 5.32.3, 5.39.4, 5.43.2 -=, 4.5.3 ->, 4.6.1, 5.15.1 -infinity, 5.1 .*, 5.39.5, 5.43.9 .+, 5.39.3, 5.43.2 .-, 5.39.4, 5.43.2 .., 5.35.1, 5.36.4 ./, 5.39.6, 5.43.10 .^, 5.43.11 /, 5.16.1, 5.32.8, 5.32.11, 5.44.2 //, 4.2 /=, 4.5.3 :;, 4.1 :=, 4.5.2, 4.6.1, 5.15.1 <, 5.2.2 <=, 5.2.2 ==, 5.2.2 =>, 4.5.2, 4.6.1 >, 5.2.2 >=, 5.2.2 ? :, 4.6.2 ?:, 4.6.2 [], 5.35.2, 5.36.3, 5.36.4, 5.36.6, 5.38, 5.38.12 5.14.2, 5.16.4 5.14.2, 5.16.5 $, 5.14.2, 5.17.5, 5.36.5 %, 5.6.11, 5.14.2, 5.32, 5.33 %{ %}, 5.37.1 &*, 5.43.3 &&, 5.2.3 &^, 5.43.7 ^, 5.11.1, 5.14.1, 5.32.9, 5.43.7 _, 8.1.1, 8.2.1 !, 5.7.1 !=, 5.2.2, 5.2.3 ", 5.4.1 Airy_Ai, 5.9.11 Airy_Bi, 5.9.11 a2q, 5.51.2 abcuv, 5.26.12 about, 4.5.6, 5.22.1 abs, 5.11.5, 5.16.2 acos, 5.16.2, 5.21.1 acos2asin, 5.21.7 acos2atan, 5.21.8 acosh, 5.16.2 acot, 5.21.1 acsc, 5.21.1 add, 5.38.29 additionally, 4.5.6 additionally, 4.5.6 adjoint_matrix, 5.48.9 algvar, 5.56.4 and, 4.5.6, 5.2.3 animate, 6.17.1 animate3d, 6.17.2 animation, 6.17.3 append, 5.38.16 apply, 5.38.32 approx, 7.2 arccos, 5.16.2, 5.21.1 arccosh, 5.16.2 archive, 4.5.4 arcLen, 5.17.2 arcsin, 5.16.2, 5.21.1 arcsinh, 5.16.2 arctan, 5.16.2, 5.21.1 arctanh, 5.16.2 areaplot, 6.7 arg, 5.11.6 as_function_of, 5.16.6 asc, 5.4.5 asec, 5.21.1 asin, 5.16.2, 5.21.1 asin2acos, 5.21.9 asin2atan, 5.21.10 asinh, 5.16.2 assume, 4.5.6, 5.22.1, 5.22.1 at, 5.38.2, 5.43.12 atan, 5.16.2, 5.21.1 atan2acos, 5.21.12 atan2asin, 5.21.11 atanh, 5.16.2 atrig2ln, 5.21.19 augment, 5.38.15, 5.43.23 Beta, 5.9.8 Binary, 5.14.3 BlockDiagonal, 5.42.4 barycentre, 5.11.10 base, 5.5 basis, 5.44.9 bernoulli, 5.8.9 binomial, 5.7.2 bisection_solver, 7.4.1 bitand, 5.3.1 bitor, 5.3.1 bitxor, 5.3.1 black, 6.1.1 blockmatrix, 5.43.21 blue, 6.1.1 border, 5.43.26 boxwhisker, 5.40, 5.43.31 brent_solverbrent_solver, 7.4.2 CopyVar, 4.5.5 c1oc2, 5.10.11 c1op2, 5.10.9 canonical_form, 5.12.6 cat, 5.4.8, 5.4.10 cd, 4.7.1 ceil, 5.16.2 ceiling, 5.16.2 center2interval, 5.35.4 cFactor, 5.12.10 changebase, 5.44.8 char, 5.4.6 charpoly, 5.48.6 chinrem, 5.26.13 cholesky, 5.50.1 chrem, 5.6.23 coeff, 5.25.3 coeffs, 5.25.3 col, 5.43.14 colDim, 5.43.34 coldim, 5.43.34 collect, 5.25.12 colNorm, 5.47.4 colnorm, 5.47.4 color, 6.1.1 , 7.4.2 colspace, 5.44.14 comb, 5.7.2 combine, 5.20.2 comDenom, 5.29.7 comment, 4.2 comments, 4.2 companion, 5.48.10 complexroot, 5.30.1 concat, 5.38.15, 5.43.23 confrac, 5.8.7 conique, 5.51.5 conique_reduite, 5.51.6 conj, 5.11.8 contains, 5.38.24 content, 5.25.10 contourplot, 6.8 convert, 5.5, 5.21.24, 5.25.22, 8.1.4 convertir, 5.21.24, 5.25.22 cos, 5.21.1 cos, 5.20.2, 5.21.24 cosh, 5.16.2, 5.16.2 cot, 5.21.1 count, 5.38.25, 5.43.27 count_eq, 5.38.26, 5.43.28 count_inf, 5.38.27, 5.43.29 count_sup, 5.38.28, 5.43.30 courbe_polaire, 6.12 crationalroot, 5.30.4 cross, 5.39.8 crossP, 5.39.8 crossproduct, 5.39.8 cSolve, 5.53.7 csc, 5.21.1 cumSum, 5.4.3, 5.38.30, 5.43.5 curl, 5.52.5 cyan, 6.1.1 cycle2perm, 5.10.4 cycleinv, 5.10.14 cycles2permu, 5.10.3 cyclotomic, 5.26.14 cZzeros, 5.12.12 Delete, 5.14.3 DelFold, 4.7.3 Det, 5.33.5 DIGITS, 5.9.1, 7.2 Digits, 5.9.1, 7.2 DrawFunc, 6.2 DrawParm, 6.11, 6.11.2 DrawPol, 6.12 DrwCtour, 6.8 degree, 5.25.4 delcols, 5.43.15 delrows, 5.43.15 deltalist, 5.38.37 denom, 5.8.4, 5.29.4 densityplot, 6.9 derive, 5.17.5, 5.52.1 deriver, 5.17.5, 5.52.1 deSolve, 5.55.1 desolve, 5.55.1 det, 5.32.15, 5.44.4 det_minor, 5.44.5 dfc, 5.8.7 dfc2f, 5.8.8 diag, 5.42.4 diff, 5.17.5, 5.52.1 dim, 5.43.32 directories, 4.7 display, 6.1.1 divergence, 5.52.4 divide, 5.26.6 divis, 5.26.1 divisors, 5.6.9 divpc, 5.34.1 dnewton_solverdnewton_solver, 7.5.1 dot, 5.39.7 dotP, 5.39.7 dotprod, 5.39.7 droit, 5.53.5 dsolve, 5.55.1 e, 5.1 e2r, 5.25.2 egcd, 5.26.11 egv, 5.48.3 egvl, 5.48.2 eigenvals, 5.48.1 eigenvalues, 5.48.2 eigenvectors, 5.48.3 eigenvects, 5.48.3 eigVc, 5.48.3 eigVl, 5.48.2 epsilon, 5.56.1 epsilon2zero, 5.56.1 equal, 5.53.1 equal2diff, 5.53.2 equal2list, 5.53.3 erf, 5.9.5 erfc, 5.9.6 euler, 5.6.25 eval, 5.12.1 evala, 5.12.2 evalb, 5.2.5 evalc, 5.11.4 evalf, 4.5.6, 5.8.1, 5.9.1, 5.56.6, 7.2 evalm, 5.43.1 even, 5.6.13 exact, 5.8.1, 5.56.7 exp, 5.16.2 exp, 5.20.2, 5.21.24 exp2list, 5.2.4 exp2pow, 5.24.8 exp2trig, 5.21.13 expand, 5.12.5 expexpand, 5.24.2 expln, 5.21.24 expr, 5.4.11 expression editor, 4.3.1 expression tree, 4.3.2 extrema, 5.46.2 ezgcd, 5.26.9 FALSE, 5.2.1 Factor, 5.33.4 f2nd, 5.8.5, 5.29.5 factor, 5.12.9, 5.25.13, 5.32.14, 5.32.19 factor_xn, 5.25.9 factorial, 5.6.1, 5.7.1 factoriser, 5.25.13, 5.32.14 factors, 5.25.15 false, 5.2.1 falsepos_solverfalsepos_solver, 7.4.3 fcoeff, 5.31.2 fdistrib, 5.12.5 feuille, 5.15.3, 5.35.2 fft, 5.22.3 fieldplot, 6.14 filled, 6.1.1 float2rational, 5.8.1, 5.56.7 floor, 5.16.2 fMax, 5.17.3 fMin, 5.17.3 fourier_an, 5.22.1 fourier_bn, 5.22.1 fourier_cn, 5.22.1 fPart, 5.16.2 frac, 5.16.2 fracmod, 5.32.12 frames, 6.17.1, 6.17.2 froot, 5.31.1 fsolve, 7.4, 7.5 fullparfrac, 5.21.24 funcplot, 6.2 function_diff, 5.17.1 fxnd, 5.8.5, 5.29.5 Gamma, 5.9.7 Gcd, 5.6.3, 5.26.8, 5.33.3 GetFold, 4.7.3 GF, 5.32.18 Graph, 6.2 gauche, 5.53.4 gauss, 5.51.3 gaussjord, 5.54.3 gbasis, 5.28.1 gcd, 5.6.2, 5.26.7, 5.32.13 gcdex, 5.26.11 genpoly, 5.28.3 getDenom, 5.8.4, 5.29.3 getNum, 5.8.3, 5.29.1 grad, 5.52.1 gramschmidt, 5.51.4 graphe_suite, 6.13 greduce, 5.28.2 green, 6.1.1 groupermu, 5.10.16 hadamard, 5.43.8 halftan, 5.21.17 halftan_hyp2exp, 5.21.18 hamdist, 5.3.2 has, 5.56.5 hasard, 5.7.4 head, 5.4.2, 5.38.4 hermite, 5.27.2 hessenberg, 5.48.11 hessian, 5.52.3 heugcd, 5.26.9 hilbert, 5.42.6 hold, 5.12.3 horner, 5.25.16 hybrid_solverhybrid_solver, 7.5.2 hybridj_solverhybridj_solver, 7.5.5 hybrids_solverhybrids_solver, 7.5.3 hybridsj_solverhybridsj_solver, 7.5.6 hyp2exp, 5.24.1 IFTE, 4.6.2 Int, 5.18.1 Inverse, 5.33.6 i, 5.1 iabcuv, 5.6.21 ibasis, 5.44.10 ibpdv, 5.18.4 ibpu, 5.18.4 ichinrem, 5.6.22 ichrem, 5.6.22 id, 5.16.2 identity, 5.42.1 idivis, 5.6.9 idn, 5.42.1 iegcd, 5.6.20 ifactor, 5.6.6 ifactors, 5.6.7 ifft, 5.22.4 ifte, 4.6.2 igcd, 5.6.2 igcdex, 5.6.20 ihermite, 5.48.12 ilaplace, 5.55.2 im, 5.11.3 imag, 5.11.3 image, 5.44.11 implicitplot, 6.10 indets, 5.56.2 inequationplot, 6.6 infinity, 5.1 inString, 5.4.7 int, 5.18.1 intDiv, 5.6.10 integer, 5.22.1 integer, 4.5.6 | integrate, 5.18.1 interactive_odeplot, 6.16 interactive_plotode, 6.16 internal directories, 4.7.3 interp, 5.25.26 intersect, 5.37.3 interval2center, 5.35.3 inv, 5.32.11, 5.32.16, 5.44.2 inverse, 5.32.16 iPart, 5.16.2 iquo, 5.6.10 iquorem, 5.6.12 irem, 5.6.11 is_cycle, 5.10.7 is_permu, 5.10.6 is_prime, 5.6.16 is_pseudoprime, 5.6.15 ismith, 5.48.13 isom, 5.49.1 ithprime, 5.6.19 JordanBlock, 5.42.5 jacobi_symbol, 5.6.27 jordan, 5.48.5 ker, 5.44.12 kernel, 5.44.12 LineHorz, 6.5.2 LineTan, 6.5.4 LineVert, 6.5.3 LU, 5.50.5 l1norm, 5.39.1 l2norm, 5.39.1, 5.47.1 lagrange, 5.25.26 laguerre, 5.27.3 laplace, 5.55.2 laplacian, 5.52.2 lcm, 5.6.5, 5.26.10 lcoeff, 5.25.6 ldegree, 5.25.5 left, 5.35.2, 5.53.4 legendre, 5.27.1 legendre_symbol, 5.6.26 length, 5.38.13 lgcd, 5.6.4 lhs, 5.53.4 limit, 5.19.1, 5.19.2, 5.19.2 lin, 5.24.4 line, 6.5.1 linsolve, 5.54.6 list2mat, 5.38.38 lll, 5.50.7 ln, 5.16.2 ln, 5.20.2, 5.21.24 lname, 5.56.2 lncollect, 5.24.5 lnexpand, 5.24.3 load, 4.7.2 log, 5.16.2 log, 5.20.2 log10, 5.16.2 logb, 5.16.2 lpsolve, 5.45.2 lu, 5.50.4 lvar, 5.56.3 magenta, 6.1.1 makelist, 5.38.35 makemat, 5.43.24 makesuite, 5.38.11 makevector, 5.38.12 map, 5.38.32 maple_ifactors, 5.6.8 mat2list, 5.38.39, 5.38.39 matrix, 5.43.25 matrix, 5.21.24 max, 5.16.2 maximize, 5.46.1 maxnorm, 5.39.1, 5.47.2 mean, 5.40, 5.43.31 median, 5.40, 5.43.31 member, 5.38.23 mid, 5.4.2, 5.38.3, 5.38.3 min, 5.16.2 minimax, 5.46.3 minimize, 5.46.1 minus, 5.37.4 mkisom, 5.49.2 mksa, 8.1.3 mod, 5.6.11, 5.33 modgcd, 5.26.9 mods, 5.6.11 mRow, 5.43.18 mRowAdd, 5.43.19 mul, 5.38.31 mult_c_conjugate, 5.11.9 mult_conjugate, 5.12.7 NewFold, 4.7.3 Nullspace, 5.44.13 nCr, 5.7.2 ncols, 5.43.34 nDeriv, 7.3.2 newList, 5.38.34 newMat, 5.42.2 newton, 7.3.1 newton_solvernewton_solver, 7.4.4 newtonj_solvernewtonj_solver, 7.5.4 nextprime, 5.6.17 nInt, 7.3.3 nlpsolve, 5.45.3 nodisp, 4.1 nop, 5.36.6 nops, 5.38.13 norm, 5.39.1, 5.47.1 normal, 5.12.13, 5.32.1, 5.32.2, 5.32.3, 5.32.4, 5.32.9 normalize, 5.11.7, 5.39.2 not, 5.2.3 nPr, 5.7.3 nrows, 5.43.33 nSolve, 7.4 nstep, 6.2 nullspace, 5.44.12 numer, 5.8.3, 5.29.2 odd, 5.6.14 odeplot, 6.15 odesolve, 7.3.4, 7.3.5 of, 5.38.32 op, 5.15.3, 5.35.2, 5.38.11 or, 4.5.6, 5.2.3 ord, 5.4.4 order_size, 5.34.2, 5.34.3 Psi, 5.9.9 p1oc2, 5.10.10 p1op2, 5.10.8 pa2b2, 5.6.24 pade, 5.34.5 paramplot, 6.11, 6.11.2 parfrac, 5.21.24 pari, 5.8.10 part, 5.12.19 partfrac, 5.29.9 partfrac, 5.21.24 pcar, 5.48.6 pcar_hessenberg, 5.48.7 pcoef, 5.25.20 pcoeff, 5.25.20 perm, 5.7.3 perminv, 5.10.13 permu2cycles, 5.10.2 permu2mat, 5.10.5, 5.50.4 permuorder, 5.10.15 peval, 5.25.8 phi, 5.6.25 pi, 5.1 piecewise, 4.6.2 piecewise defined functions, 4.6.2 pivot, 5.54.5 plot, 6.3 plot3d, 6.4 plotarea, 6.7 plotcontour, 6.8 plotdensity, 6.9 plotfield, 6.14 plotfunc, 5.17.4, 6.2 plotimplicit, 6.10 plotinequation, 6.6 plotode, 6.15 plotparam, 6.11, 6.11.2 plotpolar, 6.12 plotseq, 5.13.2, 6.13 pmin, 5.48.8 point_milieu, 6.7 polarplot, 6.12 poly2symb, 5.25.1 polyEval, 5.25.8 polynom, 5.21.24, 5.25.22 potential, 5.52.6 pow2exp, 5.24.7 powermod, 5.32.10 powexpand, 5.24.6 powmod, 5.32.10 prepend, 5.38.17 preval, 5.12.18 prevprime, 5.6.18 primpart, 5.25.11 product, 5.38.31, 5.43.6, 5.43.8 proot, 7.6 propFrac, 5.8.2 propfrac, 5.8.2, 5.29.8 psrgcd, 5.26.9 ptayl, 5.25.17 purge, 4.5.6, 4.5.7, 5.22.1 pwd, 4.7.1 QR, 5.50.3 Quo, 5.26.3, 5.33.1 q2a, 5.51.1 qr, 5.50.2 quadrique, 5.51.7 quadrique_reduite, 5.51.8 quantile, 5.40, 5.43.31 quartiles, 5.40, 5.43.31 quo, 5.26.2, 5.32.5 quorem, 5.26.6, 5.32.7 quote, 5.4.1, 5.12.3 Rem, 5.26.5, 5.33.2 Rref, 5.33.7 r2e, 5.25.1 rand, 5.7.4 randMat, 5.42.3 randmatrix, 5.42.3 randPoly, 5.25.23 randperm, 5.10.1 randpoly, 5.25.23 randvector, 5.38.36 rank, 5.44.6 ranm, 5.25.25, 5.42.3 rat_jordan, 5.48.4 rationalroot, 5.30.3 ratnormal, 5.12.15 rdiv, 5.9.3 re, 5.11.2 read, 4.7.2 real, 5.11.2 realroot, 5.30.2 rectangle_droit, 6.7 rectangle_gauche, 6.7 red, 6.1.1 ref, 5.54.2 rem, 5.26.4, 5.32.6 remain, 5.6.11 remove, 5.38.22 reorder, 5.25.24 residue, 5.34.4 resoudre, 5.12.9, 5.52.1, 6.5.6 restart, 4.5.7 resultant, 5.26.19 reverse_rsolve, 5.54.7 revlist, 5.38.7 rhs, 5.53.5 right, 5.35.2, 5.53.5 rm_all_vars, 4.5.7 romberg, 7.3.3 root, 5.9.4 rootof, 5.25.18 roots, 5.25.19 rotate, 5.38.8 round, 5.16.2 row, 5.43.14 rowAdd, 5.43.17 rowDim, 5.43.33 rowdim, 5.43.33 rowNorm, 5.47.3 rownorm, 5.47.3 rowSwap, 5.43.20 rowspace, 5.44.15 rref, 5.32.17, 5.54.3 SetFold, 4.7.3 SortA, 5.38.19 SortD, 5.38.20 Store, 4.5.2 scalar_product, 5.39.7 scalarProduct, 5.39.7 sec, 5.21.1 secant_solversecant_solver, 7.4.5 select, 5.38.21 semi_augment, 5.43.22 seq, 5.36.5 seq[], 5.36.1 seqplot, 6.13 series, 5.34.3 set[], 5.37.1 shift, 5.38.9 sign, 5.16.2 signature, 5.10.12 simp2, 5.8.6, 5.29.6 simplex_reduce, 5.45 simplify, 5.12.14, 5.21.5 simult, 5.54.4 sin, 5.16.2, 5.21.1 sin, 5.20.2, 5.21.24 sincos, 5.21.13 sincos, 5.21.24 sinh, 5.16.2 size, 5.38.13 sizes, 5.38.14 smod, 5.6.11 solve, 5.12.9, 5.52.1, 5.53.6, 6.5.6 sommet, 5.15.3, 5.35.2 sort, 5.38.18 spline, 5.25.28 split, 5.12.8 spreadsheet, 4.4 sq, 5.16.2 sqrfree, 5.25.14 sqrt, 5.16.2 stddev, 5.40, 5.43.31 stddevp, 5.40 steffenson_solversteffenson_solver, 7.4.6 sto, 4.5.2 string, 5.21.24 sturm, 5.26.15 sturmab, 5.26.16 sturmseq, 5.26.17 subexpression, 4.3.2 subexpressions, 4.3.2, 4.3.3 subMat, 5.43.16 subs, 5.12.17 subsop, 5.38.10, 5.43.13 subst, 5.12.16 sum, 5.18.2, 5.38.29, 5.43.4 sum_riemann, 5.18.3 supposons, 4.5.6 suppress, 5.38.5 svd, 5.50.6 sylvester, 5.26.18 symb2poly, 5.25.2 syst2mat, 5.54.1 TRUE, 5.2.1 table, 5.41 tablefunc, 5.13.1, 5.17.4 tableseq, 5.13.2 tail, 5.4.2, 5.38.6 tan, 5.16.2, 5.21.1 tan, 5.21.24 tan2cossin2, 5.21.16 tan2sincos, 5.21.14 tan2sincos2, 5.21.15 tangent, 6.5.5 tanh, 5.16.2 taylor, 5.34.2 tCollect, 5.21.4 tchebyshev1, 5.27.4 tchebyshev2, 5.27.5 tcoeff, 5.25.7 tcollect, 5.21.4 tExpand, 5.20.1 texpand, 5.20.1 thiele, 5.25.29 tlin, 5.21.3 tpsolve, 5.45.4 trace, 5.44.3 tran, 5.44.1 transpose, 5.44.1 trapeze, 6.7 trig, 5.20.2 trig2exp, 5.21.20 trigcos, 5.21.22 trigexpand, 5.21.2 trigsimplify, 5.21.6 trigsin, 5.21.21 trigtan, 5.21.23 trn, 5.44.7 true, 5.2.1 trunc, 5.16.2 truncate, 5.25.21 tsimplify, 5.24.9 ufactor, 8.1.5 unapply, 5.15.2 unarchive, 4.5.4, 4.5.4 unfactored, 6.10 union, 5.37.2 unitV, 5.11.7, 5.39.2 unquote, 5.12.4 user_operator, 5.14.3 usimplify, 8.1.6 VARS, 4.5.7, 4.7.3 valuation, 5.25.5 vandermonde, 5.42.7 variable, 4.5.1 variance, 5.40, 5.43.31 vpotential, 5.52.7 when, 4.6.2 white, 6.1.1 xor, 5.2.3 xstep, 6.2 yellow, 6.1.1 ystep, 6.2 zeros, 5.12.11 zeta, 5.9.10 zip, 5.38.33 zstep, 6.2

# Chapter 2 Introduction

## 2.1 Notations used in this manual

In this manual, the information that you enter will be typeset in typewriter font. User input typically takes one of three forms:

- Commands that you enter on the command line.
  For example, to compute the sin of π/4, you can type

  > sin(pi/4)

- Commands requiring a prefix key.
  These will be indicated by separating the prefix key and the standard key with a plus +. For example, to exit an Xcas session, you can type

  > Ctrl+Q

- Menu commands.
  When denoting menu items, submenus will be connected using ▸. For example, from within Xcas, you can choose the File menu, then choose the Open submenu, and then choose the File item. This will be indicated by

  > File ▸ Open ▸ File

## 2.2 Interfaces for the giac library

The giac library is a C++ mathematics library. It comes with two interfaces for users to use it directly; a graphical interface and a command-line interface.

The graphical interface is called Xcas, and is the most full-featured interface. As well being able to do symbolic and numeric calculations, it has its own programming language, it can draw graphs, it has a built-in spreadsheet, it can do dynamic geometry and turtle graphics.

The command-line interface can be run inside a terminal. It can also do symbolic and numeric calculations and works with the programming language. In a graphical environment, the command-line interface can also be used to draw graphs.

There is also a web version, which can be run through a browser, either over the internet or from local files. Other programs (for example, TeXmacs) have interfaces for the command-line version.

- The Xcas interface
- The command-line interface
- The Firefox interface
- The TeXmacs interface

# Chapter 3 The Xcas interface

## 3.1 The entry levels

The Xcas interface can run several independent calculation sessions, each session will be contained in a separate tab. Before you understand the Xcas interface, it would help to be familiar with the components of a session.

Each session can have any number of input levels. Each input level will have a number to the left of it; the number is used to identify the input level. Each level can have one of the following:

- A command line.
  This is the default; you can open a new command line with Alt+N.
  You can enter a giac command (or a series of commands separated by semicolons) on a command line and send it to be evaluated by hitting enter. You can also scroll through the command history with Shift+Up and Shift+Down.

  If the output is a number or an expression, then it will appear in blue text in a small area below the input region; this area is an expression editor. There will be a scrollbar and a small M to the right of this area; the M is a menu which gives you various options.

  If the output is a graphic, then it will appear in a graphing area below the input region. To the right of the graphic will be a control panel allowing you to manipulate the graphic.

- An expression editor.
  You can open an expression editor with Alt+E.
- A two-dimensional geometry screen.
  You can open up such a screen with Alt+G. This level will have a screen, as well as a control panel, menus and a command line to control the screen.
- A three-dimensional geometry screen.
  You can open up such a screen with Alt+H. This level will have a screen, as well as a control panel, menus and a command line to control the screen.
- A turtle graphics screen.
  You can open up such a screen with Alt+D. This level will have a screen, as well as a program editor and command line.
- A spreadsheet.
  You can open up a spreadsheet with Alt+T. A spreadsheet will be able to open a graphic screen.
- A program editor.
  You can open up a program editor with Alt+P.
- A comment line. You can open up a comment line with Alt+C.

Using commands discussed later, different types of levels can be combined to form a single hybrid level. Levels can also be moved up or down in a session, or even moved to a different session.

The level containing the cursor is the current level. The current level can be evaluated or re-evaluated by typing enter.

A level can be selected (for later operations) by clicking on the number in the white box to the left of the level. Once selected, the box containing the number will turn black. You can select a range of levels by clicking on the number for the beginning level, and then holding the shift key while you click on the number for the ending level.

## 3.2 The starting window

When you first start Xcas, you will be given a largely blank window.

The first row will be the main menus; you can save and load Xcas sessions, configure Xcas and its interface and run various commands with entries from these menus.

The second row will be tabs; one tab for each session that you are running in Xcas. The tabs will contain the name of the sessions, or Unnamed if a session has no name. The first time you start Xcas, there will be only one unnamed session.

The third row will contain various buttons.

- The first button, ?, will open the help index. (The same as the Help▸Index menu entry.) If there is a command on the command line, the help index (see help index ) will open at this command.
- The second button Save, will save the session in a file. The first time you click on it, you will be prompted for a file name ending in .xws to save the session in. The button will be pink if the session is not saved or if it has changed since the last change, it will be green once the session is saved. The name in the title will be the name of the file used to save the session.
- The third button, which in the picture above is
  Config : exact real RAD 12 xcas 6.2148M, is a status line indicating the current Xcas configuration. (See section 3.5.) If the session is unsaved, it will begin with Config :; if the session is saved in a file filename.xws, this button will begin with Config filename.xws :. Other information on this status line:
  - exact or approx. (See subsection 3.5.4.) This tells you whether Xcas will give you exact values, such as √2, when possible or to give you decimal approximations.
  - real, cplx or CPLX. (See subsections 3.5.5 and 3.5.6.) When this shows real, then (for example) Xcas will by default only find real solutions of equations. When this shows cplx, the Xcas will find complex solutions of equations. When this shows CPLX, then Xcas will regard variables as complex; for example, it won’t simplify re(z) (the real part of the variable z) to z.
  - RAD or DEG. (See subsection 3.5.3.) This tells you whether angles, as in trigonometric arguments, are measured in radians or degrees.
  - An integer. (See subsection 3.5.1, indicating how many significant digits will be used in floating point calculations.
  - xcas, maple, mupad or ti89. (See subsection 3.5.2.) This tells you what syntax Xcas will use. Xcas can be set to emulate the languages of Maple, MuPAD or the TI89 series of calculators.
  - The last item indicates how much memory Xcas is using.
  Clicking on this status line button will open a window where you can configure the settings shown on this line as well as some other settings; you can do the same with the menu item Cfg▸CAS Configuration. (See subsection 3.5.7.)
- The fourth button, STOP (in red), can be used to halt a computation which is running on too long.
- The fifth button, Kbd, can be used to toggle an on-screen scientific keyboard at the bottom of the window.
  Along the right hand side of the keyboard are some keys that can be used to change the keyboard.
  - The X key will hide the keyboard, just like pressing the Kbd button again.
  - The cmds key will toggle a menu bar at the bottom of the screen which can be used as an alternate menu or persistent submenu. This bar will contain buttons, home, <<, some menu titles, >>, var, cust and X.

    The << and >> buttons will scroll through menu items. Clicking on one of the menu buttons will perform the appropriate action or replace the menu items by submenu items. When submenu items appear, there will also be a BACK button to return to the previous menu. Clicking on the home button returns the menu buttons to the main menu.

    After the menu buttons is a var button. This will replace the menu buttons by buttons representing the variables that you have defined. After that is a cust button, which will display commands that you store in a list variable CST.

    The last button, X, will close the menu bar.

  - The msg key will bring up a message window at the bottom of the window which will give you helpful messages; for example, if you save a graphic, it will tell you the name of the file it is saved in and how to include it in a LATEX file.
  - The abc key will toggle the keyboard between the scientific keyboard and an alphabetic keyboard.
- The fifth button, X, will close the current session.

## 3.3 Getting help

Xcas is an extensive program, but you can get help in several different ways.

- - Tooltips
  - HTML help
  - The help index
  - findhelp

## 3.4 The menus

- The File menu
- The Edit menu
- The Cfg menu
- The Help menu
- The Toolbox menu
- The Expression menu
- The Cmds menu
- The Prg menu
- The Graphic menu
- The Geo menu
- The Spreadsheet menu
- The Phys menu
- The Highschool menu
- The Turtle menu

## 3.5 Configuring Xcas

- The number of significant digits
- The language mode
- The units for angles
- Exact or approximate values
- Complex numbers
- Complex variables
- Configuring the computations
- Configuring the graphics
- More configuration
- The configuration file

## 3.6 Printing and saving

- Saving a session
- Saving a spreadsheet
- Saving a program
- Printing a session

## 3.7 Translating to other computer languages

Xcas can translate a session, or parts of a session, to other computer languages; notably LATEX and MathML.

- Translating an expression to LATEX
- Translating the entire session to LATEX

# Chapter 4 Entry in Xcas

## 4.1 Suppressing output

If you enter a command into Xcas, the result will appear in the output box below the input. If you enter

> a := 2+2

then

> 4

will appear in the output box. You can evaluate the input and suppress the output with the nodisp command. If you enter

> nodisp(a := 2+2)

then a will still be set to 4, but the result will not appear in the output box. Instead,

> Done

will appear.

An alternate way of suppressing the output is to end the input with :;, if you enter

> b := 3+3:;

then b will be set to 6 but it won’t be displayed.

## 4.2 Entering comments

You can annotate an Xcas session by adding comments. You can enter a comment on the current line at any time by typing Alt+C. The line will appear in green text and conclude when you type Enter. Comments are not evaluated and so have no output. If you have begun entering a command when you begin a comment, the command line be pushed down so that you can finish it when you complete the comment.

You can open the browser in a comment line by entering the web address beginning with the @ sign. If you enter the comment line

> The Xcas homepage is at
> @www-fourier.ujf-grenoble.fr/~parisse/giac.html

then the browser will open to the Xcas home page.

To add a comment to a program, rather than a session, you can use the comment command, which takes a string as an argument. Alternatively, any part of a program between // and the end of the line is a comment. So both

> bs() := {comment("Hello"); return "Hi there!";}

and

> bs() := { // Hello
> return "Hi there!";}

are programs with the comment "Hello".

## 4.3 Editing expressions

You can enter expressions on the command line, but Xcas also has a built-in expression editor that you can use to enter expressions in two dimensions, the way they normally look when typeset. When you have an expression in the editor, you can also manipulate subexpressions apart from the entire expression.

- Entering expressions in the editor
- Subexpressions
- Manipulating subexpressions

## 4.4 Spreadsheet

- Opening a spreadsheet
- The spreadsheet window

## 4.5 Variables

- Variable names
- Assigning values
- Incrementing variables
- Storing and recalling variables and their values
- Copying variables
- Assumptions on variables
- Unassigning variables

## 4.6 Functions

- Defining functions
- Defining piecewise defined functions

## 4.7 Directories

- Working directories
- Reading files
- Internal directories

# Chapter 5 The CAS functions

## 5.1 Symbolic constants : e pi infinity i

e is the number exp(1);
pi is the number π.
infinity is unsigned ∞.
+infinity is +∞.
-infinity is −∞.
i is the complex number i.

## 5.2 Booleans

- The values of a boolean : true false
- Tests : ==, !=, >, >=, <, =<
- Boolean operators : or xor and not
- Transform a boolean expression to a list : exp2list
- Evaluate booleans : evalb

## 5.3 Bitwise operators

- Operators bitor, bitxor, bitand
- Bitwise Hamming distance : hamdist

## 5.4 Strings

- Character and string : "
- First character, middle and end of a string : head mid tail
- Concatenation of a sequence of words : cumSum
- ASCII code of a character : ord
- ASCII code of a string : asc
- String defined by the ASCII codes of its characters : char
- Find a character in a string : inString
- Concat objects into a string : cat
- Add an object to a string : +
- Transform an integer into a string : cat +
- Transform a string into a number : expr

## 5.5 Write an integer in base b: convert

convert or convertir can do different kind of conversions depending on the option given as the second argument.

To convert an integer n into the list of its coefficients in base b, the option is base. The arguments of convert or convertir are an integer n, base and b, the value of the basis.
convert or convertir returns the list of coefficients in a b basis of the integer n.
Input :

convert(123,base,8)

Output :

[3,7,1]

To check the answer, input expr("0173") or horner(revlist([3,7,1]),8) or convert([3,7,1],base,8), the output is 123
Input :

convert(142,base,12)

Output :

[10,11]

To convert the list of coefficients of an integer n in base b, the option is also base. convert or convertir returns the integer n.
Input :

convert([3,7,1],base,8)

or :

horner(revlist([3,7,1]),8)

Output :

123

Input :

convert([10,11],base,12)

or :

horner(revlist([10,11]),12)

Output :

142

## 5.6 Integers (and Gaussian Integers)

For all functions in this section, you can use Gaussian integers (numbers of the form a+ib, where a and b are in ℤ) in place of integers.

- The factorial : factorial
- GCD : gcd igcd
- GCD : Gcd
- GCD of a list of integers : lgcd
- The least common multiple : lcm
- Decomposition into prime factors : ifactor
- List of prime factors : ifactors
- Matrix of factors : maple_ifactors
- The divisors of a number : idivis divisors
- The integer Euclidean quotient : iquo intDiv
- The integer Euclidean remainder : irem remain smod mods mod %
- Euclidean quotient and euclidean remainder of two integers : iquorem
- Test of evenness : even
- Test of oddness : odd
- Test of pseudo-primality : is_pseudoprime
- Test of primality : is_prime isprime isPrime
- The smallest pseudo-prime greater than n : nextprime
- The greatest pseudo-prime less than n : prevprime
- The n-th prime number : ithprime
- Bézout’s Identity : iegcd igcdex
- Solving au+bv=c in ℤ: iabcuv
- Chinese remainders : ichinrem, ichrem
- Chinese remainders for lists of integers : chrem
- Solving a2+b2=p in ℤ : pa2b2
- The Euler indicatrix : euler phi
- Legendre symbol : legendre_symbol
- Jacobi symbol : jacobi_symbol

## 5.7 Combinatorial analysis

- Factorial : factorial !
- Binomial coefficients : binomial comb nCr
- Permutations : perm nPr
- Random integers : rand

## 5.8 Rationals

- Transform a floating point number into a rational : exact
  float2rational
- Integer and fractional part : propfrac propFrac
- Numerator of a fraction after simplification : numer
  getNum
- Denominator of a fraction after simplification : denom getDenom
- Numerator and denominator of a fraction : f2nd fxnd
- Simplification of a pair of integers : simp2
- Continued fraction representation of a real : dfc
- Transform a continued fraction representation into a real : dfc2f
- The n-th Bernoulli number : bernoulli
- Access to PARI/GP commands: pari

## 5.9 Real numbers

- Eval a real at a given precision : evalf and Digits, DIGITS
- Usual infixed functions on reals : +,-,*,/,^
- Usual prefixed functions on reals : rdiv
- n-th root : root
- Error function : erf
- Complementary error function: erfc
- The Γ function : Gamma
- The β function : Beta
- Derivatives of the DiGamma function : Psi
- The ζ function : Zeta
- Airy functions : Airy_Ai and Airy_Bi

## 5.10 Permutations

A permutation p of size n is a bijection from [0..n−1] on [0..n−1] and is represented by the list : [p(0),p(1),p(2)...p(n−1)].
For example, the permutation p represented by [1,3,2,0] is the application from [0,1,2,3] on [0,1,2,3] defined by :

p(0)=1, p(1)=3, p(2)=2, p(3)=0

A cycle c of size p is represented by the list [a0,...,ap−1] (0≤ ak≤ n−1) it is the permutation such that

c(ai)=ai+1 for (i=0..p−2), c(ap−1)=a0, c(k)=k otherwise

A cycle c is represented by a list and a cycle decomposition is represented by a list of lists.
For example, the cycle c represented by the list [3,2,1] is the permutation c defined by c(3)=2, c(2)=1, c(1)=3, c(0)=0 (i.e. the permutation represented by the list [0,3,1,2]).

- Random permutation : randperm
- Decomposition as a product of disjoint cycles :
  permu2cycles
- Product of disjoint cycles to permutation: cycles2permu
- Transform a cycle into permutation : cycle2perm
- Transform a permutation into a matrix : permu2mat
- Checking for a permutation : is_permu
- Checking for a cycle : is_cycle
- Product of two permutations : p1op2
- Composition of a cycle and a permutation : c1op2
- Composition of a permutation and a cycle : p1oc2
- Product of two cycles : c1oc2
- Signature of a permutation : signature
- Inverse of a permutation : perminv
- Inverse of a cycle : cycleinv
- Order of a permutation : permuorder
- Group generated by two permutations : groupermu

## 5.11 Complex numbers

Note that complex numbers are also used to represent a point in the plane or a 1-d function graph.

- Usual complex functions : +,-,*,/,^
- Real part of a complex number : re real
- Imaginary part of a complex number : im imag
- Write a complex as re(z)+i*im(z) : evalc
- Modulus of a complex number : abs
- Argument of a complex number : arg
- The normalized complex number : normalize unitV
- Conjugate of a complex number : conj
- Multiplication by the complex conjugate :
  mult_c_conjugate
- Barycenter of complex numbers : barycentre

## 5.12 Algebraic expressions

- Evaluate an expression : eval
- Evaluate algebraic expressions : evala
- Prevent evaluation : quote hold ’
- Force evaluation : unquote
- Distribution : expand fdistrib
- Canonical form : canonical_form
- Multiplication by the conjugate quantity :
  mult_conjugate
- Separation of variables : split
- Factorization : factor
- Complex factorization : cFactor
- Zeros of an expression : zeros
- Complex zeros of an expression : cZeros
- Normal form : normal
- Simplify : simplify
- Normal form for rational fractions : ratnormal
- Substitute a variable by a value : subst
- Substitute a variable by a value (Maple and Mupad compatibility) : subs
- Evaluate a primitive at boundaries: preval
- Sub-expression of an expression : part

## 5.13 Values of un

- Array of values of a sequence : tablefunc
- Table of values and graph of a recurrent sequence : tableseq and plotseq

## 5.14 Operators or infixed functions

An operator is an infixed function.

- Usual operators :+, -, *, /, ^
- Xcas operators
- Define an operator: user_operator

## 5.15 Functions and expressions with symbolic variables

- The difference between a function and an expression
- Transform an expression into a function : unapply
- Top and leaves of an expression : sommet feuille op

## 5.16 Functions

- Context-dependent functions.
  - Operators + and -
  - Operator *
  - Operator /
- Usual functions
- Defining algebraic functions
  - Defining a function from ℝp to ℝ
  - Defining a function from ℝp to ℝq
  - Defining families of function from ℝp−1 to ℝq using a function from ℝp to ℝq
- Composition of two functions: @
- Repeated function composition: @@
- Define a function with the history : as_function_of

## 5.17 Derivation and applications.

- Functional derivative : function_diff
- Length of an arc : arcLen
- Maximum and minimum of an expression: fMax fMin
- Table of values and graph : tablefunc and plotfunc
- Derivative and partial derivative
  - Derivative and first order partial derivative : diff derive deriver
  - Derivative and n-th order partial derivative : diff derive deriver

## 5.18 Integration

- Antiderivative and definite integral : integrate int Int
- Discrete summation: sum
- Riemann sum : sum_riemann
- Integration by parts : ibpdv and ibpu
  - ibpdv
  - ibpu
- Change of variables : subst

## 5.19 Limits

- Limits : limit
- Integral and limit

## 5.20 Rewriting transcendental and trigonometric expressions

- Expand a transcendental and trigonometric expression : texpand tExpand
- Combine terms of the same type : combine

## 5.21 Trigonometry

- Trigonometric functions
- Expand a trigonometric expression : trigexpand
- Linearize a trigonometric expression : tlin
- Put together sine and cosine of the same angle : tcollect tCollect
- Simplify : simplify
- Simplify trigonometric expressions : trigsimplify
- Transform arccos into arcsin : acos2asin
- Transform arccos into arctan : acos2atan
- Transform arcsin into arccos : asin2acos
- Transform arcsin into arctan : asin2atan
- Transform arctan into arcsin : atan2asin
- Transform arctan into arccos : atan2acos
- Transform complex exponentials into sin and cos : sincos exp2trig
- Transform tan(x) into sin(x)/cos(x) : tan2sincos
- Rewrite tan(x) with sin(2x) and cos(2x) : tan2sincos2
- Rewrite tan(x) with cos(2x) and sin(2x) : tan2cossin2
- Rewrite sin, cos, tan in terms of tan(x/2) : halftan
- Rewrite trigonometric functions as function of tan(x/2) and hyperbolic functions as function of exp(x):
  halftan_hyp2exp
- Transform inverse trigonometric functions into logarithms : atrig2ln
- Transform trigonometric functions into complex exponentials : trig2exp
- Simplify and express preferentially with sine : trigsin
- Simplify and express preferentially with cosine : trigcos
- Simplify and express preferentially with tangents : trigtan
- Rewrite an expression with different options : convert convertir

## 5.22 Fourier transformation

- Fourier coefficients : fourier_an and fourier_bn or fourier_cn
  - fourier_an
  - fourier_bn
  - fourier_cn
- Discrete Fourier Transform
  - The properties of the Discrete Fourier Transform
  - Applications
- Fast Fourier Transform : fft
- Inverse Fast Fourier Transform : ifft
- An exercise with fft

## 5.23 Signal Processing

- Cross-correlation of two signals : cross_correlation
- Auto-correlation of a signal : auto_correlation
- Convolution of two signals : convolution
- Low-pass filtering : lowpass
- High-pass filtering : highpass
- Perform thresholding operations on an array : threshold
- Bartlett-Hann window function : bartlett_hann_window
- Blackman-Harris window function : blackman_harris_window
- Blackman window function : blackman_window
- Bohman window function : bohman_window
- Cosine window function : cosine_window
- Gaussian window function : gaussian_window
- Hamming window function : hamming_window
- Hann-Poisson window function : hann_poisson_window
- Hann window function : hann_window
- Parzen window function : parzen_window
- Poisson window function : poisson_window
- Riemann window function : riemann_window
- Triangular window function : triangle_window
- Tukey window function : tukey_window
- Welch window function : welch_window

## 5.24 Exponentials and Logarithms

- Rewrite hyperbolic functions as exponentials : hyp2exp
- Expand exponentials : expexpand
- Expand logarithms : lnexpand
- Linearize exponentials : lin
- Collect logarithms : lncollect
- Expand powers : powexpand
- Rewrite a power as an exponential : pow2exp
- Rewrite exp(n*ln(x)) as a power : exp2pow
- Simplify complex exponentials : tsimplify

## 5.25 Polynomials

A polynomial of one variable is represented either by a symbolic expression or by the list of its coefficients in decreasing powers order (dense representation). In the latter case, to avoid confusion with other kinds of list

- use `poly1[...]` as delimiters in inputs
- check for in Xcas output.

Note that polynomials represented as lists of coefficients are always written in decreasing powers order even if increasing power is checked in cas configuration.

A polynomial of several variables is represented

- by a symbolic expression
- or by a dense recursive 1-d representation like above
- or by a sum of monomials with non-zero coefficients (distributed sparse representation).
  A monomial with several variables is represented by a coefficient and a list of integers (interpreted as powers of a variable list). The delimiters for monomials are %%%{ and %%%}, for example 3x2y is represented by %%%{3,[2,1]%%%} with respect to the variable list [x,y]).

- Convert to a symbolic polynomial : r2e poly2symb
- Convert from a symbolic polynomial : e2r symb2poly
- Coefficients of a polynomial: coeff coeffs
- Polynomial degree : degree
- Polynomial valuation : valuation ldegree
- Leading coefficient of a polynomial : lcoeff
- Trailing coefficient degree of a polynomial : tcoeff
- Evaluation of a polynomial : peval polyEval
- Factorize xn in a polynomial : factor_xn
- GCD of the coefficients of a polynomial : content
- Primitive part of a polynomial : primpart
- Factorization : collect
- Factorization : factor factoriser
- Square-free factorization : sqrfree
- List of factors : factors
- Evaluate a polynomial : horner
- Rewrite in terms of the powers of (x-a) : ptayl
- Compute with the exact root of a polynomial : rootof
- Exact roots of a polynomial : roots
- Coefficients of a polynomial defined by its roots : pcoeff pcoef
- Truncate of order n : truncate
- Convert a series expansion into a polynomial : convert convertir
- Random polynomial : randpoly randPoly
- Change the order of variables : reorder
- Random list : ranm
- Lagrange’s polynomial : lagrange interp
- Trigonometric interpolation : triginterp
- Natural splines: spline
  - Definition
  - Theorem
  - Interpolation with spline functions
- Rational interpolation : thiele
  - Examples

## 5.26 Arithmetic and polynomials

Polynomials are represented by expressions or by list of coefficients by decreasing power order. In the first case, for instructions requiring a main variable (like extended gcd computations), the variable used by default is x if not specified. For modular coefficients in ℤ/nℤ, use % n for each coefficient of the list or apply it to the expression defining the polynomial.

- The divisors of a polynomial : divis
- Euclidean quotient : quo
- Euclidean quotient : Quo
- Euclidean remainder : rem
- Euclidean remainder: Rem
- Quotient and remainder : quorem divide
- GCD of two polynomials with the Euclidean algorithm: gcd
- GCD of two polynomials with the Euclidean algorithm : Gcd
- Choosing the GCD algorithm of two polynomials : ezgcd heugcd modgcd psrgcd
- LCM of two polynomials : lcm
- Bézout’s Identity : egcd gcdex
- Solving au+bv=c over polynomials: abcuv
- Chinese remainders : chinrem
- Cyclotomic polynomial : cyclotomic
- Sturm sequences and number of sign changes of P on (a, b] : sturm
- Number of zeros in [a,b) : sturmab
- Sturm sequences : sturmseq
- Sylvester matrix of two polynomials : sylvester
- Resultant of two polynomials : resultant

## 5.27 Orthogonal polynomials

- Legendre polynomials: legendre
- Hermite polynomial : hermite
- Laguerre polynomials: laguerre
- Tchebychev polynomials of the first kind: tchebyshev1
- Tchebychev polynomial of the second kind: tchebyshev2

## 5.28 Gröbner basis and Gröbner reduction

- Gröbner basis : gbasis
- Gröbner reduction : greduce
- Build a polynomial from its evaluation : genpoly

## 5.29 Rational fractions

- Numerator : getNum
- Numerator after simplification : numer
- Denominator : getDenom
- Denominator after simplification : denom
- Numerator and denominator : f2nd fxnd
- Simplify : simp2
- Common denominator : comDenom
- Integer and fractional part : propfrac
- Partial fraction expansion : partfrac

## 5.30 Exact roots of a polynomial

- Exact bounds for complex roots of a polynomial :
  complexroot
- Exact bounds for real roots of a polynomial : realroot
- Exact values of rational roots of a polynomial :
  rationalroot
- Exact values of the complex rational roots of a polynomial : crationalroot

## 5.31 Exact roots and poles

- Roots and poles of a rational function : froot
- Rational function given by roots and poles : fcoeff

## 5.32 Computing in ℤ/pℤ or in ℤ/pℤ[x]

The way to compute over ℤ/pℤ or over ℤ/pℤ[x] depends on the syntax mode :

- In Xcas mode, an object n over ℤ/pℤ is written n % p. Some examples of input for
  - an integer n in ℤ/13ℤ
    n:=12%13.
  - a vector V in ℤ/13ℤ
    V:=[1,2,3]%13 or V:=[1%13,2%13,3%13].
  - a matrix A in ℤ/13ℤ
    A:=[[1,2,3],[2,3,4]]%13 or
    A:=[[1%13,2%13,3%13],[[2%13,3%13,4%13]].
  - a polynomial A in ℤ/13ℤ[x] in symbolic representation
    A:=(2*x`^`2+3*x-1)%13 or
    A:=2%13*x`^`2+3%13*x-1%13.
  - a polynomial A in ℤ/13ℤ[x] in list representation
    A:=poly1[1,2,3]%13 or A:=poly1[1%13,2%13,3%13].
  To recover an object o with integer coefficients instead of modular coefficients, input o % 0. For example, input o:=4%7 and o%0,then output is -3.
- In Maple mode, integers modulo p are represented like usual integers instead of using specific modular integers. To avoid confusion with normal commands, modular commands are written with a capital letter (inert form) and followed by the mod command (see also the next section).

Remark

- For some commands in ℤ/pℤ or in ℤ/pℤ[x], p must be a prime integer.
- The representation is the symmetric representation :
  11%13 returns -2%13.

- Expand and reduce : normal
- Addition in ℤ/pℤ or in ℤ/pℤ[x] : +
- Subtraction in ℤ/pℤ or in ℤ/pℤ[x] : -
- Multiplication in ℤ/pℤ or in ℤ/pℤ[x] : *
- Euclidean quotient : quo
- Euclidean remainder : rem
- Euclidean quotient and euclidean remainder : quorem
- Division in ℤ/pℤ or in ℤ/pℤ[x] : /
- Power in ℤ/pℤ and in ℤ/pℤ[x] : ^
- Compute an mod p : powmod powermod
- Inverse in ℤ/pℤ : inv inverse or /
- Rebuild a fraction from its value modulo p : fracmod
- GCD in ℤ/pℤ[x] : gcd
- Factorization over ℤ/pℤ[x] : factor factoriser
- Determinant of a matrix in ℤ/pℤ : det
- Inverse of a matrix with coefficients in ℤ/pℤ : inv inverse
- Row reduction to echelon form in ℤ/pℤ : rref
- Construction of a Galois field : GF
- Factorize a polynomial with coefficients in a Galois field : factor

## 5.33 Compute in ℤ/pℤ[x] using Maple syntax

- Euclidean quotient : Quo
- Euclidean remainder: Rem
- GCD in ℤ/pℤ[x] : Gcd
- Factorization in ℤ/pℤ[x] : Factor
- Determinant of a matrix with coefficients in ℤ/pℤ : Det
- Inverse of a matrix in ℤ/pℤ : Inverse
- Row reduction to echelon form in ℤ/pℤ : Rref

## 5.34 Taylor and asymptotic expansions

- Division by increasing power order : divpc
- Taylor expansion : taylor
- Series expansion : series
- The residue of an expression at a point : residue
- Padé expansion: pade

## 5.35 Intervals

- Definition of an interval : a1..a2
- Boundaries of an interval : left right
- Center of an interval : interval2center
- Intervals defined by their center : center2interval

## 5.36 Sequences

- Definition : seq[] ()
- Concat two sequences : ,
- Get an element of a sequence : []
- Sub-sequence of a sequence : []
- Make a sequence or a list : seq $
- Transform a sequence into a list : [] nop
- The + operator applied on sequences

## 5.37 Sets

- Definition : set[]
- Union of two sets or of two lists : union
- Intersection of two sets or of two lists : intersect
- Difference of two sets or of two lists : minus

## 5.38 Lists and vectors

- Definition
- Get an element or a sub-list of a list : at []
  - Get an element
  - Extract a sub-list
- Extract a sub-list : mid
- Get the first element of a list : head
- Remove an element in a list : suppress
- Remove the first element : tail
- Reverse order in a list : revlist
- Reverse a list starting from its n-th element : rotate
- Permuted list from its n-th element : shift
- Modify an element in a list : subsop
- Transform a list into a sequence : op makesuite
- Transform a sequence into a list : makevector []
- Length of a list : size nops length
- Sizes of a list of lists : sizes
- Concatenate two lists or a list and an element : concat augment
- Append an element at the end of a list : append
- Prepend an element at the beginning of a list : prepend
- Sort : sort
- Sort a list by increasing order : SortA
- Sort a list by decreasing order : SortD
- Select the elements of a list : select
- Remove elements of a list : remove
- Test if a value is in a list : member
- Test if a value is in a list : contains
- Sum of list (or matrix) elements transformed by a function : count
- Number of elements equal to a given value : count_eq
- Number of elements smaller than a given value : count_inf
- Number of elements greater than a given value : count_sup
- Sum of elements of a list : sum add
- Cumulated sum of the elements of a list : cumSum
- Product : product mul
  - Product of values of an expression : product
  - Product of elements of a list : product
- Apply a function of one variable to the elements of a list : map apply of
- Apply a bivariate function to the elements of two lists : zip
- Make a list with zeros : newList
- Make a list with a function : makelist
- Make a random vector or list : randvector
- List of differences of consecutive terms : deltalist
- Make a matrix with a list : list2mat
- Make a list with a matrix : mat2list

## 5.39 Functions for vectors

- Norms of a vector : maxnorm l1norm l2norm norm
- Normalize a vector : normalize unitV
- Term by term sum of two lists : + .+
- Term by term difference of two lists : - .-
- Term by term product of two lists : .*
- Term by term quotient of two lists : ./
- Scalar product : scalar_product * dotprod dot dotP scalar_Product
- Cross product : cross crossP crossproduct

## 5.40 Statistics functions : mean,variance,stddev, stddevp,median,quantile,quartiles,boxwhisker

The functions described here may be used if the statistics series is contained in a list. See also section 5.43.31 for matrices and chapter ?? for weighted lists.

- mean computes the arithmetic mean of a list
  Input :
  mean([3,4,2])
  Output :
  3
  Input :
  mean([1,0,1])
  Output
  2/3
- stddev computes the standard deviation of a population, if the argument is the population.
  Input :
  stddev([3,4,2])
  Output :
  sqrt(2/3)
- stddevp computes an unbiased estimate of the standard deviation of the population, if the argument is a sample. The following relation holds:
  stddevp(l)`^`2=size(l)*stddev(l)`^`2/(size(l)-1).
  Input :
  stddevp([3,4,2])
  Output :
  1
- variance computes the variance of a list, that is the square of stddevp
  Input :
  variance([3,4,2])
  Output :
  2/3
- median computes the median of a list.
  Input :
  median([0,1,3,4,2,5,6])
  Output :
  3.0
- quantile computes the deciles of a list given as first argument, where the decile is the second argument.
  Input :
  quantile([0,1,3,4,2,5,6],0.25)
  Output the first quartile :
  [1.0]
  Input :
  quantile([0,1,3,4,2,5,6],0.5)
  Output the median :
  [3.0]
  Input :
  quantile([0,1,3,4,2,5,6],0.75)
  Output the third quartile :
  [4.0]
- quartiles computes the minimum, the first quartile, the median, the third quartile and the maximum of a list.
  Input :
  quartiles([0,1,3,4,2,5,6])
  Output :
  [[0.0],[1.0],[3.0],[4.0],[6.0]]
- boxwhisker draws the whisker box of a statistics series stored in a list.
  Input :
  boxwhisker([0,1,3,4,2,5,6])
  Output
  the graph of the whisker box of this statistic list

Example
Define the list A by:

A:=[0,1,2,3,4,5,6,7,8,9,10,11]

Outputs :

1. 11/2 for mean(A)
2. sqrt(143/12) for stddev(A)
3. 0 for min(A)
4. [1.0] for quantile(A,0.1)
5. [2.0] for quantile(A,0.25)
6. [5.0] for median(A) or for quantile(A,0.5)
7. [8.0] for quantile(A,0.75)
8. [9.0] for quantile(A,0.9)
9. 11 for max(A)
10. [[0.0],[2.0],[5.0],[8.0],[11.0]] for quartiles(A)

## 5.41 Table with strings as indexes : table

A table is an associative container (or map), it is used to store information associated to indexes which are much more general than integers, like strings or sequences. It may be used for example to store a table of phone numbers indexed by names.
In Xcas, the indexes in a table may be any kind of Xcas objects. Access is done by a binary search algorithm, where the sorting function first sorts by type then uses an order for each type (e.g. < for numeric types, lexicographic order for strings, etc.)
table takes as argument a list or a sequence of equalities index_name=element_value.
table returns this table.
Input :

T:=table(3=-10,"a"=10,"b"=20,"c"=30,"d"=40)

Input :

T["b"]

Output :

20

Input :

T[3]

Output :

-10

Remark
If you assign T[n]:= ... where T is a variable name and n an integer

- if the variable name was assigned to a list or a sequence, then the n-th element of T is modified,
- if the variable name was not assigned, a table T is created with one entry (corresponding to the index n). Note that after the assignation T is not a list, despite the fact that n was an integer.

## 5.42 Usual matrix

A matrix is represented by a list of lists, all having the same size. In the Xcas answers, the matrix delimiters are [] (bold brackets). For example, [1,2,3] is the matrix [[1,2,3]] with only one row, unlike [1,2,3] (normal brackets) which is the list [1,2,3].
In this document, the input notation ([[1,2,3]]) will be used for input and output.

- Identity matrix : idn identity
- Zero matrix : newMat matrix
- Random matrix : ranm randMat randmatrix
- Diagonal of a matrix or matrix of a diagonal : BlockDiagonal diag
- Jordan block : JordanBlock
- Hilbert matrix : hilbert
- Vandermonde matrix : vandermonde

## 5.43 Arithmetic and matrix

- Evaluate a matrix : evalm
- Addition and subtraction of two matrices : + - .+ .-
- Multiplication of two matrices : * &*
- Addition of elements of a column of a matrix : sum
- Cumulated sum of elements of each column of a matrix : cumSum
- Multiplication of elements of each column of a matrix : product
- Power of a matrix : ^ &^
- Hadamard product : hadamard product
- Hadamard product (infixed version): .*
- Hadamard division (infixed version): ./
- Hadamard power (infixed version): .^
- Extracting element(s) of a matrix : [] at
- Modify an element or a row of a matrix : subsop
- Extract rows or columns of a matrix (Maple compatibility) : row col
- Remove rows or columns of a matrix : delrows delcols
- Extract a sub-matrix of a matrix (TI compatibility) : subMat
- Add a row to another row : rowAdd
- Multiply a row by an expression : mRow
- Add k times a row to an another row : mRowAdd
- Exchange two rows : rowSwap
- Make a matrix with a list of matrices : blockmatrix
- Make a matrix from two matrices : semi_augment
- Make a matrix from two matrices : augment concat
- Build a matrix with a function : makemat
- Define a matrix : matrix
- Append a column to a matrix : border
- Count the elements of a matrix verifying a property : count
- Count the elements equal to a given value : count_eq
- Count the elements smaller than a given value : count_inf
- Count the elements greater than a given value : count_sup
- Statistics functions acting on column matrices : mean, stddev, variance, median, quantile, quartiles, boxwhisker
- Dimension of a matrix : dim
- Number of rows : rowdim rowDim nrows
- Number of columns : coldim colDim ncols

## 5.44 Linear algebra

- Transpose of a matrix : tran transpose
- Inverse of a matrix : inv /
- Trace of a matrix : trace
- Determinant of a matrix : det
- Determinant of a sparse matrix : det_minor
- Rank of a matrix : rank
- Transconjugate of a matrix : trn
- Equivalent matrix : changebase
- Basis of a linear subspace : basis
- Basis of the intersection of two subspaces : ibasis
- Image of a linear function : image
- Kernel of a linear function : kernel nullspace ker
- Kernel of a linear function : Nullspace
- Subspace generated by the columns of a matrix : colspace
- Subspace generated by the rows of a matrix : rowspace

## 5.45 Linear Programmation

Linear programming problems are maximization problem of a linear functionals under linear equality or inequality constraints. The most simple case can be solved directly by the so-called simplex algorithm. Most cases require to solve an auxiliary linear programming problem to find an initial vertex for the simplex algorithm.

- Simplex algorithm: simplex_reduce
- Solving general linear programming problems: lpsolve
  - Solving LP problems
  - Entering problems in matrix form
  - Solving MIP (Mixed Integer Programming) problems
  - Solving problems in floating-point arithmetic
  - Loading problem from a file
- Nonlinear optimization: nlpsolve
  - Examples
- Solving transportation problems: tpsolve

## 5.46 Nonlinear optimization

- Global extrema: minimize maximize
  - Examples
- Local extrema: extrema
  - Examples
- Minimax polynomial approximation: minimax

## 5.47 Different matrix norm

- l2 matrix norm : norm l2norm
- l∞ matrix norm : maxnorm
- Matrix row norm : rownorm rowNorm
- Matrix column norm : colnorm colNorm

## 5.48 Matrix reduction

- Eigenvalues : eigenvals
- Eigenvalues : egvl eigenvalues eigVl
- Eigenvectors : egv eigenvectors eigenvects
  eigVc
- Rational Jordan matrix : rat_jordan
- Jordan normal form : jordan
- Characteristic polynomial : charpoly
- Characteristic polynomial using Hessenberg algorithm :
  pcar_hessenberg
- Minimal polynomial : pmin
- Adjoint matrix : adjoint_matrix
- Companion matrix of a polynomial : companion
- Hessenberg matrix reduction : hessenberg
- Hermite normal form : ihermite
- Smith normal form : ismith

## 5.49 Isometries

- Recognize an isometry : isom
- Find the matrix of an isometry : mkisom

## 5.50 Matrix factorizations

Note that most matrix factorization algorithms are implemented numerically, only a few of them will work symbolically.

- Cholesky decomposition : cholesky
- QR decomposition : qr
- QR decomposition (for TI compatibility) : QR
- LU decomposition : lu
- LU decomposition (for TI compatibility) : LU
- Singular value decomposition : svd
- Short basis of a lattice : lll

## 5.51 Quadratic forms

- Matrix of a quadratic form : q2a
- Transform a matrix into a quadratic form : a2q
- Reduction of a quadratic form : gauss
- Gram-Schmidt orthonormalization : gramschmidt
- Graph of a conic : conique
- Conic reduction : conique_reduite
- Graph of a quadric : quadrique
- Quadric reduction : quadrique_reduite

## 5.52 Multivariate calculus

- Gradient : derive deriver diff grad
- Laplacian : laplacian
- Hessian matrix : hessian
- Divergence : divergence
- Rotational : curl
- Potential : potential
- Conservative flux field : vpotential

## 5.53 Equations

- Define an equation : equal
- Transform an equation into a difference : equal2diff
- Transform an equation into a list : equal2list
- The left member of an equation : left gauche lhs
- The right member of an equation : right droit rhs
- Solving equation(s): solve
- Equation solving in ℂ : cSolve

## 5.54 Linear systems

In this paragraph, we call the "augmented matrix" of the system A · X=B (or matrix "representing" the system A · X=B), the matrix obtained by gluing the column vector B or −B to the right of the matrix A, as with border(A,tran(B)).

- Matrix of a system : syst2mat
- Gauss reduction of a matrix : ref
- Gauss-Jordan reduction: rref gaussjord
- Solving A*X=B : simult
- Step by step Gauss-Jordan reduction of a matrix : pivot
- Linear system solving: linsolve
- Finding linear recurrences : reverse_rsolve

## 5.55 Differential equations

This section is limited to symbolic (or exact) solutions of differential equations. For numeric solutions of differential equations, see odesolve. For graphic representation of solutions of differential equations, see plotfield, plotode and interactive_plotode.

- Solving differential equations : desolve deSolve
  dsolve
- Laplace transform and inverse Laplace transform : laplace ilaplace

## 5.56 Other functions

- Replace small values by 0: epsilon2zero
- List of variables : lname indets
- List of variables and of expressions : lvar
- List of variables of an algebraic expressions: algvar
- Test if a variable is in an expression : has
- Numeric evaluation : evalf
- Rational approximation : float2rational exact

# Chapter 6 Graphs

Most graph instructions take expressions as arguments. A few exceptions (mostly Maple-compatibility instructions) also accept functions. Some optional arguments, like color, thickness, can be used as optional attributes in all graphic instructions. They are described below.

## 6.1 Graph and geometric objects attributes

There are two kinds of attributes: global attributes of a graphic scene and individual attributes.

- Individual attributes
- Global attributes

## 6.2 Graph of a function : plotfunc funcplot DrawFunc Graph

- 2-d graph
- 3-d graph
- 3-d graph with rainbow colors
- 4-d graph.

## 6.3 2d graph for Maple compatibility : plot

plot(f(x),x) draws the graph of y=f(x). The second argument may specify the range of values x=xmin..xmax. One can also plot a function instead of an expression using the syntax plot(f,xmin..xmax). plot accepts an optional argument to specify the step used in x for the discretization with `xstep=` or the number of points of the discretization with `nstep=`.
Input :

plot(x`^`2-2,x)

Output :

the graph of y=x`^`2-2

Input :

plot(x`^`2-2,xstep=1)

or :

plot(x`^`2-2,x,xstep=1)

Output :

a polygonal line which is a bad representation of y=x`^`2-2

Input!

plot(x`^`2-2,x=-2..3,nstep=30)

## 6.4 3d surfaces for Maple compatibility plot3d

plot3d takes three arguments : a function of two variables or an expression of two variables or a list of three functions of two variables or a list of three expressions of two variables and the names of these two variables with an optional range (for expressions) or the ranges (for functions).
plot3d(f(x,y),x,y) (resp. plot3d([f(u,v),g(u,v),h(u,v)],u,v)) draws the surface z=f(x,y) (resp. x=f(u,v),y=g(u,v),z=h(u,v)). The syntax plot3d(f(x,y),x=x0..x1,y=y0..y1) or plot3d(f,x0..x1,y0..y1) specifies which part of surface will be computed (otherwise default values are taken from the graph configuration).
Input :

plot3d(x*y,x,y)

Output :

The surface z=x*y

Input :

plot3d([v*cos(u),v*sin(u),v],u,v)

Output :

The cone x=v*cos(u),y=v*sin(u),z=v

Input :

plot3d([v*cos(u),v*sin(u),v],u=0..pi,v=0..3)

Output :

A portion of the cone x=v*cos(u),y=v*sin(u),z=v

## 6.5 Graph of a line and tangent to a graph

- Draw a line : line
- Draw an 2D horizontal line : LineHorz
- Draw a 2D vertical line : LineVert
- Tangent to a 2D graph : LineTan
- Tangent to a 2D graph : tangent
- Intersection of a 2D graph with the axis

## 6.6 Graph of inequalities with 2 variables : plotinequation inequationplot

plotinequation([f1(x,y)<a1,...fk(x,y)<ak],[x=x1..x2,y=y1..y2]) draws the points of the plane whose coordinates satisfy the inequalities of 2 variables :

⎧ ⎪ ⎨ ⎪ ⎩ |
f1(x,y) | < | a1
| ... |
fk(x,y) | < | ak
| , x1≤ x ≤ x2, y1 ≤ y ≤ y2

Input :

plotinequation(x`^`2-y`^`2<3, [x=-2..2,y=-2..2],xstep=0.1,ystep=0.1)

Output :

the filled portion enclosing the origin and limited by the hyperbola x`^`2-y`^`2=3

Input :

plotinequation([x+y>3,x`^`2<y], [x-2..2,y=-1..10],xstep=0.2,ystep=0.2)

Output :

the filled portion of the plane defined by -2<x<2,y<10,x+y>3,y>x`^`2

Note that if the ranges for x and y are not specified, Xcas takes the default values of X-,X+,Y-,Y+ defined in the general graphic configuration (Cfg▸Graphic configuration).

## 6.7 Graph of the area below a curve : plotarea areaplot

- With two arguments, plotarea shades the area below a curve.
  plotarea(f(x),x=a..b) draws the area below the curve y=f(x) for a<x<b, i.e. the portion of the plane defined by the inequalities a<x<b and 0<y<f(x) or 0>y>f(x) according to the sign of f(x) .
  Input :
  plotarea(sin(x),x=0..2*pi)
  Output :
  the portion of plane locates in the two arches of sin(x)
- With four arguments, plotarea represents a numeric approximation of the area below a curve, according to a quadrature method from the following list:
  trapezoid,rectangle_left,rectangle_right,middle_point.
  For example plotarea(f(x),x=a..b,n,trapezoid) draws the area of n trapezoids : the third argument is an integer n, and the fourth argument is the name of the numeric method of integration when [a,b] is cut into n equal parts.
  Input :
  plotarea((x`^`2,x=0..1,5,trapezoid)
  If you want to display the graph of the curve in contrast (e.g. in bold red), input :
  plotarea(x`^`2,x=0..1,5,trapezoid); plot(x`^`2,x=0..1,display=red+line_width_3)
  Output :
  the 5 trapezoids used in the trapezoid method to approach the integral
  Input :
  plotarea((x`^`2,x=0..1,5,middle_point)
  Or with the graph of the curve in bold red, input :
  plotarea(x`^`2,x=0..1,5,middle_point); plot(x`^`2,x=0..1,display=red+line_width_3)
  Output :
  the 5 rectangles used in the middle_point method to approach the integral

## 6.8 Contour lines: plotcontour contourplot
DrwCtour

plotcontour(f(x,y),[x,y]) (or DrwCtour(f(x,y),[x,y]) or
contourplot(f(x,y),[x,y])) draws the contour lines of the surface defined by z=f(x,y) for z=−10, z=−8, .., z=0, z=2, .., z=10. You may specify the desired contour lines by a list of values of z given as third argument.
Input :

plotcontour(x`^`2+y`^`2,[x=-3..3,y=-3..3],[1,2,3], display=[green,red,black]+[filled$3])

Output :

the graph of the three ellipses x`^`2-y`^`2=n for n=1,2,3; the zones between these ellipses are filled with the color green,red or black

Input :

plotcontour(x`^`2-y`^`2,[x,y])

Output :

the graph of 11 hyperbolas x`^`2-y`^`2=n for n=-10,-8,..10

If you want to draw the surface in 3-d representation, input plotfunc(f(x,y),[x,y]), see 6.2.2):

plotfunc( x`^`2-y`^`2,[x,y])

Output :

A 3D representation of z=x`^`2+y`^`2

## 6.9 2-d graph of a 2-d function with colors : plotdensity densityplot

plotdensity(f(x,y),[x,y]) or densityplot(f(x,y),[x,y]) draws the graph of z=f(x,y) in the plane where the values of z are represented by the rainbow colors. The optional argument z=zmin..zmax specifies the range of z corresponding to the full rainbow, if it is not specified, it is deduced from the minimum and maximum value of f on the discretization. The discretization may be specified by optional xstep=... and ystep=... or nstep=... arguments.
Input :

plotdensity(x`^`2-y`^`2,[x=-2..2,y=-2..2], xstep=0.1,ystep=0.1)

Output :

A 2D graph where each hyperbola defined by x`^`2-y`^`2=z has a color from the rainbow

Remark : A rectangle representing the scale of colors is displayed below the graph.

## 6.10 Implicit graph: plotimplicit implicitplot

plotimplicit or implicitplot draws curves or surfaces defined by an implicit expression or equation. If the option unfactored is given as last argument, the original expression is taken unmodified. Otherwise, the expression is normalized, then replaced by the factorization of the numerator of its normalization.

Each factor of the expression corresponds to a component of the implicit curve or surface. For each factor, Xcas tests if it is of total degree less or equal to 2, in that case conic or quadric is called. Otherwise the numeric implicit solver is called.

Optional step and ranges arguments may be passed to the numeric implicit solver, note that they are dismissed for each component that is a conic or a quadric.

- 2D implicit curve
- 3D implicit surface
- Implicit differentiation : implicitdiff

## 6.11 Parametric curves and surfaces : plotparam paramplot DrawParm

- 2D parametric curve
- 3D parametric surface : plotparam paramplot DrawParm

## 6.12 Curve defined in polar coordinates : plotpolar polarplot DrawPol courbe_polaire

Let Et be an expression depending on the variable t.
plotpolar(Et,t) draws the polar representation of the curve defined by ρ=Et for θ=t, that is in cartesian coordinates the curve (Et cos(t),Et sin(t)). The range of the parameter may be specified by replacing the second argument by t=tmin..tmax. The discretization parameter may be specified by an optional tstep=... argument.
Input

plotpolar(t,t)

Output :

The spiral ρ=t is plotted

Input

plotpolar(t,t,tstep=1)

or :

plotpolar(t,t=0..10,tstep=1)

Output :

A polygon line approaching the spiral ρ=t is plotted

## 6.13 Graph of a recurrent sequence : plotseq seqplot graphe_suite

Let f(x) be an expression depending on the variable x (resp. f(t) an expression depending on the variable t).
plotseq(f(x),a,n) (resp. plotseq(f(t),t=a,n)) draws the line y=x, the graph of y=f(x) (resp. y=f(t)) and the n first terms of the recurrent sequence defined by : u0=a, un=f(un−1). The a value may be replaced by a list of 3 elements, [a,x−,x+] where x−..x+ will be passed as x range for the graph computation.
Input :

plotseq(sqrt(1+x),x=[3,0,5],5)

Output :

the graph of y=sqrt(1+x), of y=x and of the 5 first terms of the sequence u_0=3 and u_n=sqrt(1+u_(n-1))

## 6.14 Tangent field : plotfield fieldplot

- Let f(t,y) be an expression depending on two variables t and y, then :
  plotfield(f(t,y),[t,y])
  draws the tangent field of the differential equation y′=f(t,y) where y is a real variable and where t is the abscissa,
- Let V be a vector of two expressions depending on 2 variables x,y but independent of the time t, then
  plotfield(V,[x,y])
  draws the vector field V,
- The range of values of t,y or of x,y can be specified with
  t=tmin..tmax, x=xmin..xmax, y=ymin..ymax
  in place of the variable name.
- The discretization may be specified with optional arguments xstep=..., ystep=....

Input :

plotfield(4*sin(t*y),[t=0..2,y=-3..7])

Output :

Segments with slope 4*sin(t*y), representing tangents, are plotting in different points

With two variables x,y, input :

plotfield(5*[-y,x],[x=-1..1,y=-1..1])

## 6.15 Plotting a solution of a differential equation : plotode odeplot

Let f(t,y) be an expression depending on two variables t and y.

- plotode(f(t,y),[t,y],[t0,y0]) draws the solution of the differential equation y′=f(t,y) crossing through the point (t0,y0) (i.e. such that y(t0)=y0)
- By default, t goes in both directions. The range of value of t may be specified by the optional argument t=tmin..tmax.
- We can also represent, in the space or in the plane, the solution of a differential equation y′=f(t,y) where y=(X,Y) is a vector of size 2. Just replace y by the variable names X,Y and the initial value y0 by the two initial values of the variables at time t0.

Input :

plotode(sin(t*y),[t,y],[0,1])

Output :

The graph of the solution of y’=sin(t,y) crossing through the point (0,1)

Input :

S:=odeplot([h-0.3*h*p, 0.3*h*p-p], [t,h,p],[0,0.3,0.7])

Output, the graph in the space of the solution of :

[h,p]′=[h−0.3 h*p, 0.3 h*p−p] [h,p](0)=[0.3,0.7]

To have a 2-d graph (in the plane), use the option plane

S:=odeplot([h-0.3*h*p, 0.3*h*p-p], [t,h,p],[0,0.3,0.7],plane)

To compute the values of the solution, see the section ??.

## 6.16 Interactive plotting of solutions of a differential equation : interactive_plotode interactive_odeplot

Let f(t,y) be an expression depending on two variables t and y.
interactive_plotode(f(t,y),[t,y]) draws the tangent field of the differential equation y′=f(t,y) in a new window. In this window, one can click on a point to get the plot of the solution of y′=f(t,y) crossing through this point.
You can further click to display several solutions. To stop press the Esc key.
Input :

interactive_plotode(sin(t*y),[t,y])

Output :

The tangent field is plotted with the solutions of y’=sin(t,y) crossing through the points defined by mouse clicks

## 6.17 Animated graphs (2D, 3D or "4D")

Xcas can display animated 2D, 3D or "4D" graphs. This is done first by computing a sequence of graphic objects, then after completion, by displaying the sequence in a loop.

- To stop or start again the animation, click on the button ▸ ∣ (at the left of Menu).
- The display time of each graphic object is specified in animate of the graph configuration (cfg button). Put a small time, to have a fast animation.
- If animate is 0, the animation is frozen, you can move in the sequence of objects one by one by clicking on the mouse in the graphic scene.

- Animation of a 2D graph : animate
- Animation of a 3D graph : animate3d
- Animation of a sequence of graphic objects : animation

# Chapter 7 Numerical computations

Real numbers may have an exact representation (e.g. rationals, symbolic expressions involving square roots or constants like π, ...) or approximate representation, which means that the real is represented by a rational (with a denominator that is a power of the basis of the representation) close to the real. Inside Xcas, the standard scientific notation is used for approximate representation, that is a mantissa (with a point as decimal separator) optionally followed by the letter e and an integer exponent.

Note that the real number 10−4 is an exact number but 1e−4 is an approximate representation of this number.

## 7.1 Floating point representation.

In this section, we explain how real numbers are represented.

- Digits
- Representation by hardware floats
- Examples of representations of normalized floats
- Difference between the representation of (3.1-3) and of 0.1

## 7.2 Approx. evaluation : evalf approx and Digits

evalf or approx evaluates to a numeric approximation (if possible).
Input :

evalf(sqrt(2))

Output, if in the cas configuration (Cfg menu) Digits=7 (that is hardware floats are used, and 7 digits are displayed) :

1.414214

You can change the number of digits in a command line by assigning the variable DIGITS or Digits. Input :

DIGITS:=20
evalf(sqrt(2))

Output :

1.4142135623730950488

Input :

evalf(10`^`-5)

Output :

1e-05

Input :

evalf(10`^`15)

Output :

1e+15

Input :

evalf(sqrt(2))*10`^`-5

Output :

1.41421356237e-05

## 7.3 Numerical algorithms

- Approximate solution of an equation : newton
- Approximate computation of the derivative number : nDeriv
- Approximate computation of integrals : romberg nInt
- Approximate solution of y’=f(t,y) : odesolve
- Approximate solution of the system v’=f(t,v) : odesolve

## 7.4 Solve equations with fsolve nSolve

fsolve or nSolve solves numeric equations (unlike solve or proot, it is not limited to polynomial equations) of the form:

f(x)=0, x ∈ ]a,b[

fsolve or nSolve accepts a last optional argument, the name of an iterative algorithm to be used by the GSL solver. The different methods are explained in the following section.

- fsolve or nSolve with the option bisection_solver
- fsolve or nSolve with the option brent_solver
- fsolve or nSolve with the option falsepos_solver
- fsolve or nSolve with the option newton_solver
- fsolve or nSolve with the option secant_solver
- fsolve or nSolve with the option steffenson_solver

## 7.5 Solve systems with fsolve

Xcas provides six methods (inherited from the GSL) to solve numeric systems of equations of the form f(x)=0:

- Three methods use the jacobian matrix f′(x) and their names are terminated with j_solver.
- The three other methods use approximation for f′(x) and use only f.

All methods use an iteration of Newton kind

xn+1=xn−f′(xn)−1*f(xn)

The four methods hybrid*_solver use also a method of gradient descent when the Newton iteration would make a too large step. The length of the step is computed without scaling for hybrid_solver and hybridj_solver or with scaling (computed from f′(xn)) for hybrids_solver and hybridsj_solver.

- fsolve with the option dnewton_solver
- fsolve with the option hybrid_solver
- fsolve with the option hybrids_solver
- fsolve with the option newtonj_solver
- fsolve with the option hybridj_solver
- fsolve with the option hybridsj_solver

## 7.6 Numeric roots of a polynomial : proot

proot takes as argument a squarefree polynomial, either in symbolic form or as a list of polynomial coefficients (written by decreasing order).
proot returns a list of the numeric roots of this polynomial.
To find the numeric roots of P(x)=x3+1, input :

proot([1,0,0,1])

or :

proot(x`^`3+1)

Output :

[0.5+0.866025403784*i,0.5-0.866025403784*i,-1.0]

To find the numeric roots of x2−3, input :

proot([1,0,-3])

or :

proot(x`^`2-3)

Output :

[1.73205080757,-1.73205080757]

## 7.7 Numeric factorization of a matrix : cholesky qr lu svd

Matrix numeric factorizations of

- Cholesky,
- QR,
- LU,
- svd,

are described in section 5.50.

# Chapter 8 Unit objects and physical constants

The Phys menu contains:

- the physical constants (Constant sub-menu),
- the unit conversion functions (Unit_convert sub-menu),
- the unit prefixes (Unit_prefix sub-menu)
- the unit objects organized by subject

## 8.1 Unit objects

- Notation of unit objects
- Computing with units
- Convert units into MKSA units : mksa
- Convert units : convert
- Factorize a unit : ufactor
- Simplify a unit : usimplify
- Unit prefixes

## 8.2 Constants

- Notation of physical constants
- Constants Library

> This document was translated from LATEX by HEVEA.