> # INPUT and OUTPUT with Maple > > # for debugging a Maple program --set the printlevel to a higher value > ?integrate -------------------------------------------------------------------------------- > int( (ln(x))^3, x); 3 2 ln(x) x - 3 x ln(x) + 6 x ln(x) - 6 x -------------------------------------------------------------------------------- > printlevel:= 5; printlevel := 5 -------------------------------------------------------------------------------- > int( (ln(x))^3, x); {--> enter int, args = ln(x)^3, x _Envsignum0 := _Envsignum0 surds := false 3 g := ln(_X) 3 2 r := ln(_X) _X - 3 _X ln(_X) + 6 _X ln(_X) - 6 _X fcns := {ln(_X)} expargs := {} Eiargs := {} 3 2 r := ln(x) x - 3 x ln(x) + 6 x ln(x) - 6 x <-- exit int (now at top level) = ln(x)^3*x-3*x*ln(x)^2+6*x*ln(x)-6*x} 3 2 ln(x) x - 3 x ln(x) + 6 x ln(x) - 6 x -------------------------------------------------------------------------------- > # it gives you info about parameters, local variables, precise statement if a run-time error occurs > > printlevel:=1; printlevel := 1 -------------------------------------------------------------------------------- > interface( prettyprint = false ); > (1-x) / (1+x); (1-x)/(1+x) > # the output is left-adjusted and in one-dimensional format > interface( prettyprint = true); -------------------------------------------------------------------------------- > (1-x) / (1+x); 1 - x ----- 1 + x -------------------------------------------------------------------------------- > info -------------------------------------------------------------------------------- > interface( prettyprint = 100); -------------------------------------------------------------------------------- > (1-x) / (1+x); 1 - x ----- 1 + x -------------------------------------------------------------------------------- > eqn:= x^3 -5*a*x^2 =1; sols:=solve(eqn, x); interface(labeling = false); solve(eqn, x); interface(labeling=true); 3 2 eqn := x - 5 a x = 1 2 1/3 a sols := %1 + 25/9 ----- + 5/3 a, 1/3 %1 2 / 2 \ 1/3 25 a 1/2 | 1/3 a | - 1/2 %1 - ---- ----- + 5/3 a + 1/2 I 3 |%1 - 25/9 -----|, 18 1/3 | 1/3| %1 \ %1 / 2 / 2 \ 1/3 25 a 1/2 | 1/3 a | - 1/2 %1 - ---- ----- + 5/3 a - 1/2 I 3 |%1 - 25/9 -----| 18 1/3 | 1/3| %1 \ %1 / 125 3 3 1/2 %1 := 1/2 + --- a + 1/18 (81 + 1500 a ) 27 2 1/3 a %1 + 25/9 ----- + 5/3 a, 1/3 %1 2 / 2 \ 1/3 25 a 1/2 | 1/3 a | - 1/2 %1 - ---- ----- + 5/3 a + 1/2 I 3 |%1 - 25/9 -----|, 18 1/3 | 1/3| %1 \ %1 / 2 / 2 \ 1/3 25 a 1/2 | 1/3 a | - 1/2 %1 - ---- ----- + 5/3 a - 1/2 I 3 |%1 - 25/9 -----| 18 1/3 | 1/3| %1 \ %1 / 125 3 3 1/2 %1 := 1/2 + --- a + 1/18 (81 + 1500 a ) 27 > # Maple Library (4 modules) > # standard lib --- the requested procedure is loaded automatically > # miscellaneous lib --- functions must be explicitly loaded from the external mem to main (readlib) > ?randpoly -------------------------------------------------------------------------------- > # many lib functions are readlib defined ::: gcd:= 'readlib('gcd')' or randpoly(x); > randpoly(x); 5 4 3 2 - 85 x - 55 - 37 x - 35 x + 97 x + 50 x -------------------------------------------------------------------------------- > residue(exp(x), x=1); residue(exp(x), x = 1) -------------------------------------------------------------------------------- > readlib(residue); proc(f,a) ... end -------------------------------------------------------------------------------- > # the algebraic residue of expr. f for the var x around point x. > # it is defined as the coeff of (x-a)^(-1) in the Laurent series expansion of f > > residue(exp(x), x=1); 0 -------------------------------------------------------------------------------- > # packages -- with(package); > draw(random(10, 20)); draw(random(10, 20)) -------------------------------------------------------------------------------- > with(networks); [acycpoly, addedge, addvertex, adjacency, allpairs, ancestor, arrivals, bicomponents, charpoly, chrompoly, complement, complete, components, connect, connectivity, contract, countcuts, counttrees, cube, cycle, cyclebase, daughter, degreeseq, delete, departures, diameter, dinic, djspantree, dodecahedron, draw, duplicate, edges, ends, eweight, flow, flowpoly, fundcyc, getlabel, girth, graph, graphical, gsimp, gunion, head, icosahedron, incidence, incident, indegree, induce, isplanar, maxdegree, mincut, mindegree, neighbors, new, octahedron, outdegree, path, petersen, random, rank, rankpoly, shortpathtree, show, shrink, span, spanpoly, spantree, tail, tetrahedron, tuttepoly, vdegree, vertices, void, vweight] -------------------------------------------------------------------------------- > draw(random(10, 20)); -------------------------------------------------------------------------------- > # share library --- contains user-developed Maple procedures and packages > ? share[contents] -------------------------------------------------------------------------------- > with(share): See ?share and ?share,contents for information about the share library -------------------------------------------------------------------------------- > > # Reading and Writing files > > #files containing results of Maple calculations (that cannot be used as input for further calculations) > writeto( ofile); # or appendto -------------------------------------------------------------------------------- > poly:= x^2 + 1; -------------------------------------------------------------------------------- > subs( x= 3, poly); -------------------------------------------------------------------------------- > writeto(terminal); -------------------------------------------------------------------------------- > > > # files containing Maple code in user readable or non-user readable foramt > > #use the menu ---- save as , import, export as text, LaTeX (.ms or not --- speed and silence) -------------------------------------------------------------------------------- > # .mapleinit file in your hme directory ---- toload library packages which you alwyas want -------------------------------------------------------------------------------- > > read maximum; -------------------------------------------------------------------------------- > maximum(2,4,5,1,89,9); 89 -------------------------------------------------------------------------------- > # be careful when you want to specify a whole path using the /; use `` backquotes > > readlib(unload) (maximum); maximum -------------------------------------------------------------------------------- > maximum(2,4,5,1,89,9); maximum(2, 4, 5, 1, 89, 9) -------------------------------------------------------------------------------- > # or for system routines > print(igcd); proc() options builtin; 90 end -------------------------------------------------------------------------------- > igcd(30, 18); 6 -------------------------------------------------------------------------------- > readlib(unload)(igcd); igcd -------------------------------------------------------------------------------- > igcd(30,18); igcd(30, 18) -------------------------------------------------------------------------------- > #redefine it > ?readlib -------------------------------------------------------------------------------- > igcd:= proc() options builtin; 90 end: -------------------------------------------------------------------------------- > igcd(30,18); 6 -------------------------------------------------------------------------------- > > > # FORMATTED I / O > printf( ` x=%d y=%4.2f`, 12, 34.3); x=12 y=34.30 -------------------------------------------------------------------------------- > sscanf(`x=123.45`, `x=%f`); [123.4500000000000] -------------------------------------------------------------------------------- > # difference to C's sscanf > > # readdata, readline > readlib(readdata); proc(fname) ... end -------------------------------------------------------------------------------- > readdata(data, 3); # read 3 columns of data [[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]] -------------------------------------------------------------------------------- > readdata(data, 2); # read 2 columns of data [[1., 2.], [4., 5.], [7., 8.]] -------------------------------------------------------------------------------- > readline(data); 1 2 3 -------------------------------------------------------------------------------- > readline(data); 4 5 6 -------------------------------------------------------------------------------- > readline(data); 7 8 9 -------------------------------------------------------------------------------- > readline(data); 0 -------------------------------------------------------------------------------- > > > > > # files containing fromatted I/O > # LaTeX > #generate fortran or C code > sol1:= sols[1]; / 125 3 3 1/2\1/3 sol1 := |1/2 + --- a + 1/18 (81 + 1500 a ) | \ 27 / 2 a + 25/9 ------------------------------------------ + 5/3 a / 125 3 3 1/2\1/3 |1/2 + --- a + 1/18 (81 + 1500 a ) | \ 27 / -------------------------------------------------------------------------------- > fortran(sol1, 'optimized'); t1 = a**2 t2 = t1*a t6 = (1.E0/2.E0+125.E0/27.E0*t2+sqrt(81+1500*t2)/18)**(1.E0/3.E0) t9 = t6+25.E0/9.E0*t1/t6+5.E0/3.E0*a -------------------------------------------------------------------------------- > readlib(C): C(sol1, filename = `file.c`); C(sol1); t0 = pow(1.0/2.0+125.0/27.0*a*a*a+sqrt(81.0+1500.0*a*a*a)/18,1.0/3.0)+ 25.0/9.0*a*a/pow(1.0/2.0+125.0/27.0*a*a*a+sqrt(81.0+1500.0*a*a*a)/18,1.0/3.0)+ 5.0/3.0*a; -------------------------------------------------------------------------------- > gc(); -------------------------------------------------------------------------------- >