From: Cliff Yapp <starseeker@us...>  20030424 01:51:27

Update of /cvsroot/maxima/htdocs/docs/macref/share2 In directory sc8prcvs1:/tmp/cvsserv18594 Added Files: bffac.usg cartan.dem disol.html disol.usg gendif.usg lrats.dem lrats.usg ndiffq.dem ndiffq.usg powers.usg revert.html revert.usg set.usg Log Message: macref share2  NEW FILE: bffac.usg  SHARE2;BFFAC BFZETA contains cheap and dirty BFLOAT versions of the Factorial (shifted Gamma) and Riemann Zeta functions. Both BFFAC and BFZETA take a 2nd argument which is how many digits to retain and return, but it's a good idea to request a couple of extra. BFPSI(n,z,fpprec) gives polygammas of real arg and integer order. For digamma, BFPSI0(z,fpprec) is more direct. Note BFPSI0(1,fpprec) provides BFLOATed %GAMMA. There is also CBFAC(z,fpprec) for factorial of complex z, which is even slower! BURN(n) is a way to get isolated bernoulli numbers faster than BERN(n) when n > 105 or so. There is also the Hurwitz zeta fcn BHZETA(s,h,fpprec), which gives fpprec digits of sum((k+h)^s,k,0,inf). RWG  NEW FILE: cartan.dem  "THESE FILES CONTAIN PROGRAMS TO IMPLEMENT EXTERIOR CALCULUS. DIFFERENTIAL FORMS ARE HERE EXPRESSED IN TERMS OF NATURAL BASIS FORMS ASSOCIATED WITH THE COORDINATES OF THE MANIFOLD. THE COORDINATES TO BE USED MUST BE INPUT AS A LIST, E.G., [X,Y,Z] . THE DIMENSION OF THE MANIFOLD IS SPECIFIED BY 'DIM'. THE PROGRAM WILL CONSTRUCT THE CORRESPONDING LIST OF BASIS FORMS, [DX,DY,DZ]. 'DIM', 'BASIS', AND 'COORDS' ARE RESERVED NAMES. FOR DEMONSTRATION, INPUT THE COORDINATE LIST, [X,Y,Z] ."$ /* ("INPUT THE COORDINATE LIST.",COORDS:READ()); */ COORDS:READ("INPUT THE COORDINATE LIST."); DIM:EXTDIM:LENGTH(COORDS)$ BASIS:VR:EXTSUB[1]:EXTSUBB[1]:[]$ FOR I THRU DIM DO (CI:CONCAT(ZZZ,I),BASIS:ENDCONS(CI,BASIS), EXTSUB[I+1]:CONS(CI=CI,EXTSUB[I]), EXTSUBB[I]:CONS(CI=0,EXTSUB[I]),APPLY('ALIAS, [CONCAT(D,COORDS[I]),CI]),CI:CONCAT(V,I),VR:ENDCONS(CI,VR))$ ("THE BASIS FORM LIST IS",BASIS); ("A VECTOR IS REPRESENTED BY A LIST OF COMPONENTS",VR); DERIVABBREV:PARTSWITCH:TRUE$ /* if status(feature,its) then LOADFILE(CARTAN,lisp,DSK,SHARE2) else if status(feature,multics) then LOADFILE(">lib>macsyma>share>cartan.lisp") else error("Unknown operating system")$ */ load("cartan.lsp")$ ("AN EXAMPLE OF A 1FORM IS",F1:X*DY+Z*DZ); ("THE EXTERIOR PRODUCT OPERATION IS DENOTED BY THE AMPERSAND, & , WRITTEN AS AN INFIX OPERATOR BETWEEN DIFFERENTIAL FORMS. FOR EXAMPLE,",F2:DZ & F1); ("NOTE THAT NO SYMBOL IS PRINTED IN THE OUTPUT FOR THE EXTERIOR PRODUCT OF BASIS FORMS  IT IS IMPLICITLY UNDERSTOOD. THE ORDER IN WHICH BASIS FORMS APPEAR IN PRODUCTS IS DETERMINED BY 'BASIS'. THUS, DIFFERENTIAL FORMS CAN BE INPUT USING THE ORDINARY PRODUCT. FOR EXAMPLE, THE FOLLOWING INPUT COMMAND USING THE & OPERATOR ",F3:DX & DY+DZ & DY); ("IS EQUIVALENT TO",F3:DX*DYDY*DZ); ("CONTRACTION OF A VECTOR ON A FORM IS DENOTED BY THE INFIX OPERATOR,  , WITH THE VECTOR ON THE LEFT. FOR EXAMPLE", VR  F3); ("THE EXTERIOR DERIVATIVE IS WRITTEN AS THE FUNCTION, D(ARG) , WHERE 'ARG' IS ANY DIFFERENTIAL FORM. FOR EXAMPLE",D(F1)); ("MAKE VR A VECTOR FIELD",DEPENDENCIES(V1(X,Y,Z),V2(X,Y,Z),V3(X,Y,Z))); ("THE LIE DERIVATIVE WITH RESPECT TO A VECTOR OF A FORM IS THE FUNCTION, LF(VECTOR,FORM). FOR EXAMPLE",LF(VR,F2)); ("CREATE ANOTHER VECTOR FIELD",DEPENDENCIES(W1(X,Y,Z),W2(X,Y,Z),W3(X,Y,Z)), WR:[W1,W2,W3]); ("THE LIE DERIVATIVE WITH RESPECT TO A VECTOR(ARG1) OF ANOTHER VECTOR(ARG2) IS THE FUNCTION, LV(ARG1,ARG2). FOR EXAMPLE",LV(VR,WR)); "THE SYSTEM IS READY TO DO EXTERIOR CALCULUS IN THREE DIMENSIONS WITH THE COORDINATES [X,Y,Z] . TO OPERATE IN A DIFFERENT MANIFOLD, EXECUTE THE COMMANDS, KILL(ALL) FOLLOWED BY BATCH([CARTAN,START,DSK,SHARE2],0N,2,9) "$  NEW FILE: disol.html  <!DOCTYPE HTML PUBLIC "//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>404 Not Found</TITLE> </HEAD><BODY> <H1>Not Found</H1> The requested URL /crew/mike/maxima/html/macref/share2/disol.dem was not found on this server.<P> <HR> <ADDRESS>Apache/1.3.27 Server at starship.python.net Port 80</ADDRESS> </BODY></HTML>  NEW FILE: disol.usg  DISOLATE(exp, var1, var2, ..., varN) is similar to ISOLATE(exp, var) (see the MACSYMA manual p. 89) except that it enables the user to isolate more than one variable simultaneously. This might be useful, for ex ample, if one were attempting to change variables in a multiple inte gration, and that variable change involved two or more of the integra tion variables. For example, DISOLATE(A*(B*(C+D) + E*(F+G)), A, B, E); returns a form similar to A (B E1 + E E2) , where E1 is bound to C + D and E2 is bound to F + G. Author: ASB  NEW FILE: gendif.usg  RJF@... 12/31/76 01:42:26 SOMETIMES DIFF(E,X,N) CAN BE REDUCED EVEN THOUGH N IS "SYMBOLIC". BATCH(GENDIF,>,SHARE2)$ AND YOU CAN TRY, FOR EXAMPLE, DIFF(%E^(A*X),X,Q) BY USING GENDIFF RATHER THAN DIFF. UNEVALUABLE ITEMS COME OUT QUOTED. SOME ITEMS ARE IN TERMS OF "GENFACT", FOR WHICH, SEE MANUAL. COMMENTS AND SUGGESTIONS ARE SOLICITED.  NEW FILE: lrats.dem  LOAD('LRATS)$ /* LRATS FASL contains two functions related to MACSYMA's RATSUBST. The first is LRATSUBST(LIST_OF_EQUATIONS,EXP) which provides the user with a RATSUBST capability for multiple substitution similar to the existing capability of SUBST. Recall that SUBST can carry out multiple substi tutions: */ SUBST([A=B,C=D],A+C); /* LRATSUBST works in an analogous way: */ LRATSUBST([A^2=B,C^2=D],(A+E)*C*(A+C)); /* If only one substitution is desired, then a single equation may be given as first argument: */ LRATSUBST(A^2=B,A^3); /* Another function contained in LRATS FASL is FULLRATSUBST, which is equivalent to RATSUBST except that it recurses until its result stops changing. Note the difference between the two results: */ RATSUBST(B*A,A^2,A^3); FULLRATSUBST(B*A,A^2,A^3); /* FULLRATSUBST will also accept a list of equations or a single equation as first argument. */ FULLRATSUBST([A^2=B,B^2=C,C^2=A],A^3*B*C); FULLRATSUBST(A^2=B*A,A^3); /* FULLRATSUBST can be dangerous, so care must be taken to avoid infinite recursion. An example of the kind of difficulty that can arise is given below: */ /* runs out of core in DOE MACSYMA without GC */ ERRCATCH(FULLRATSUBST(B*A^2,A^2,A^3));  NEW FILE: lrats.usg  By loading the file SHARE2;LRATS FASL one gains access to the two functions described below: LRATSUBST(list_of_equations,exp) is analogous to SUBST(list_of_equations,exp) except that it uses RATSUBST instead of SUBST. The first argument of LRATSUBST must be an equation or a list of equations identical in format to the form accepted by SUBST (see the MACSYMA manual, p. 81). The substitutions are made in the order given by the list of equations, that is, from left to right. FULLRATSUBST(a,b,c) is the same as RATSUBST except that it calls itself recursively on its result until that result stops changing. This function is useful when the replacement expression and the replaced expression have one or more variables in common. FULLRATSUBST will also accept its arguments in the format of LRATSUBST. That is, the first argument may be a single substitution equation or a list of such equations, while the second argument is the expression being processed. A demo is available in SHARE2;LRATS DEMO. Author: ASB  NEW FILE: ndiffq.dem  /**Macsyma**/ /* 9:58pm Thursday, 25 February 1982 George Carrette. GJC@... */ /* The RUNGE_KUTTA function solves: * A single firstorder equation. * Simultaneous firstorder equations. * A single secordorder equation. */ /* SETUP_AUTOLOAD(NDIFFQ,RUNGE_KUTTA,INIT_FLOAT_ARRAY)$ */ load("ndiffq")$ /* The equations */ DEFINE_VARIABLE(K,1.0,FLOAT,"Spring constant")$ DEFINE_VARIABLE(M,1.0,FLOAT,"mass")$ FX(TIME,STATE):=(MODE_DECLARE([TIME,ARRAY(STATE)],FLOAT), STATE[1])$ FV(TIME,STATE):=(MODE_DECLARE([TIME,ARRAY(STATE)],FLOAT), K/M*STATE[0])$ ARRAY([T,X,V],FLOAT,10)$ /* Time step */ INIT_FLOAT_ARRAY(T,0.0,3.14159)$ /* Initial Condition */ (X[0]:0.0,V[0]:1.0)$ RUNGE_KUTTA([FX,FV],T,[X,V])$ GRAPH(T,[X,V],["*","+"])$ /* Another argument convention is to have a DELstate vector passed in. */ FXV(DEL_STATE,TIME,STATE):= (MODE_DECLARE([TIME,ARRAY(DEL_STATE),ARRAY(STATE)],FLOAT), DEL_STATE[0]:STATE[1], DEL_STATE[1]:K/M*STATE[0], 'DONE)$ RUNGE_KUTTA(FXV,T,[X,V])$ GRAPH(T,[X,V],["*","+"])$  NEW FILE: ndiffq.usg  GJC@... 09/21/81 13:04:55 To: BROM at MITMC CC: (FILE [SHARE2;NDIFFQ USAGE]) at MITMC I changed the argument conventions for RUNGE_KUTTA systems so that you can do things more efficiently. If you call RUNGE_KUTTA(F,T,[X0,X1,X2]) THEN F WILL GET ARGUMENTS, F(X_PRIME_VECTOR,T,X_VECTOR):= ....; And F should do X_PRIME_VECTOR[0]: ...X_VECTOR[0] ..., X_PRIME_VECTOR[1]: ................... etc. If you call RUNGE_KUTTA([F0,F1,F2],T,[X0,X1,X2]) then F will get arguments: F0(T,X_VECTOR), F1(T,X_VECTOR), F2(T,X_VECTOR). This kind of argument convention also generalizes properly to second_order systems. GJC@... 06/27/81 12:49:21 To: BROM at MITMC CC: BDB at MITMC, (FILE [SHARE2;NDIFFQ USAGE]) at MITMC See the file SHARE2;NDIFFQ USAGE. you can define FX(T,P):=(MODE_DECLARE(ARRAY(P),FLOAT),T+P[0]+P[1]...); FY(t,P):=.....; FZ(t,P):=....; create arrays: array([t,x,y,z],float,25); time step: init_float_array(t,0,1); initial conditions: x[0]:1.0; y[0]:2.0; z[0]:3.0; run the problem: runge_kutta([fx,fy,fz],t,[x,y,z]); plot the result: graph2(t,[x,y,z]); You could also define F(V,T,P):=(MODE_DECLARE(ARRAY(V,P),FLOAT), V[0]: ...., V[1]: ...., V[2]: ....); And use the call Runge_Kutta(F,t,[X,Y,Z]); GJC@... 06/07/81 15:44EDT To: INFOMACSYM I moved the numerical solution to differential equation routines to SHARE so that you can get them by doing LOAD("NDIFFQ"); and then e.g. Define_Variable(N,0.3,FLOAT); Define_Variable(H,0.175,FLOAT); F(X,E):=(Mode_Declare([X,E],FLOAT),N*EXP(X)/(E+X^(2*H)*EXP(H*X))); Compile(F); Array([X,E],FLOAT,35); Init_Float_Array(X,1.0E3,6.85); /* Fills X with the interval */ E[0]:5.0; /* Initial condition */ Runge_Kutta(F,X,E); /* Solve it */ Graph2(X,E); /* Graph the solution */ p.s. Runge_Kutta(F,X,E,E_Prime) would be the call for a secondorder equation. p.p.s Runge_Kutta([f1,f2,...fn],x,[y1,y2,..yn]) would be the call for n simultaneous firstorder equations. The functions are called 2 arguments, the first being X, and the second being a vector of values [y1,y2,...Yn], index from 0 to N1.  NEW FILE: powers.usg  POWERS(EXPR,VAR)  THIS FUNCTION IS A GENERALISATION OF "HIPOW" AND "LOPOW" IN THAT IT RETURNS A LIST OF ALL THE POWERS OF VAR OCCURING IN EXPR. IT IS STILL NECESSARY TO EXPAND EXPR BEFORE APPLYING POWERS (ON PAIN OF GETTING THE WRONG ANSWER). THIS FUNCTION HAS MANY USES, E.G. IF YOU WANT TO FIND ALL THE COEFFICIENTS OF X IN A POLYNOMIAL POLY YOU CAN USE MAP(LAMBDA([POW],COEFF(POLY,X,POW)),POWERS(POLY,X)); AND MANY OTHER SIMILAR USEFUL HACKS.   NEW FILE: revert.html  <!DOCTYPE HTML PUBLIC "//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>404 Not Found</TITLE> </HEAD><BODY> <H1>Not Found</H1> The requested URL /crew/mike/maxima/html/macref/share2/revert.dem was not found on this server.<P> <HR> <ADDRESS>Apache/1.3.27 Server at starship.python.net Port 80</ADDRESS> </BODY></HTML>  NEW FILE: revert.usg  Reversion of Taylor Series: Do LOADFILE(REVERT,LISP,SHARE2); . Try REVERT(expression,variable); or REVERT2(expression,variable,hipower); to see what they do. "variable" is the variable the original Taylor expansion is in. REVERT only works on expansions around 0.  NEW FILE: set.usg  a SET THEORY package for MACSYMA ================================ The file SET FASL DSK SHARE2 provides Macsyma with the basic primitives of set theory. For our purposes, we define a set to be a sorted irredundant list. Thus [2,3,x,1] is not a set since it isn't sorted and [2,3,x,x,y] is not a set since it has a redundancy, however [1,2,3,x] and [2,3,x,y] are sets. Here is a list of the functions provided: INTERSECT UNION COMPLEMENT SETDIFFERENCE SYMMDIFFERENCE POWERSET SETIFY SUBSET SETP SUBSETP DISJOINTP The functions above are mostly selfexplanatory, so the following brief descriptions should be sufficient: INTERSECT(A,B) returns the intersection of A and B. UNION(A,B) returns the union of A and B. COMPLEMENT(A,B) returns the relative complement of A in B, That is, the set of elements of B which are not in A. SETDIFFERENCE(A,B) returns the set of elements of A which are not in B. Note that SETDIFFERENCE(A,B) is just COMPLEMENT(B,A). SYMMDIFFERENCE(A,B) returns the symmetric differrence of A and B, which is equal to UNION(SETDIFFERENCE(A,B),SETDIFFERENCE(B,A)). POWERSET(S) returns the set of all subsets of S. SETIFY(L) converts the list L to a set. For example SETIFY([2,x,2,3,8,x]) yields [2,3,8,x]. SUBSET(A,F) returns the set of elements of A which satisfy the condition F. For example SUBSET([1,2,x,x+y,z,x+y+z],atom) yields [1,2,z]. The argument F should be a function of one argument which returns TRUE or FALSE. Another example: SUBSET([1,2,7,8,9,14],evenp) yields [2,8,14]. SETP(L) returns TRUE if L is a set, FALSE otherwise. SUBSETP(A,B) decides whether or not A is a subset of B and returns TRUE or FALSE accordingly. DISJOINTP(A,B) decides whether A and B are disjoint (have no common elements) and returns TRUE or FALSE accordingly. ============ Remarks: 1. We reemphasize that a set is a list. Thus the notation for both input and output is [ ... ] rather than { ... } . We feel that this ambiguity is desirable. It allows list processing on sets and set processing on lists without conversion. 2. However, not every list is a set. A set must satisfy two additional conditions. It must be (1) sorted (2) irredundant. Implied is a notion of order and a notion of equivalence. We choose order as the fundamental notion. The user can specify an order by resetting the value of CANONLT. Initially, CANONLT has the value ORDERLESSP which is Macsyma's canonical order. The value of CANONLT must be a strict total preorder (a function of 2 arguments which returns true or false and such that the associated relation is transitive an irreflexive). It need not be universally welldefined so long as it is welldefined for the arguments it receives. The notion of equivalence is derived from the order notion by the familiar law of trichotomy: Given objects a,b we require that exactly one of the following holds: (1) a is less than b (2) b is less than a (3) a and b are equivalent Note that equivalence is, in general, weaker than equality. 3. Consider the following example: In a Macsyma suppose we define a function h by: h(n):=for i do if n=(2^i)*ENTIER(n/(2^i)) then return(i1); Thus h returns the largest positive integer e such that n is divisible by 2^e (n is assumed to be a positive integer). Next define an order function f by: f(a,b):=is( h(a) < h(b) ); For example, with this order, 9 is less than 2 and 6 is equivalent to 10. Next we set CANONLT by: CANONLT:f; Then all functions in the SET package will return sort and eliminate redundancies (equivalences) using the function f. For example, SETIFY([6,20,2,9,8,12]) returns [9,2,12,8]. 4. As mentioned above the default value of CANONLT is ORDERLESSP. It follows that the default notion of equivalence is equality. 5. The functions UNION and INTERSECT can take any number of arguments. 6. The arguments to functions in the SET package need not be sets  arbitrary lists are OK (i.e. possibly unsorted and/or redundant). Thus, functions such as INTERSECT accept arbitrary lists but always return a set. For example, INTERSECT([2,3,2,y,x],[2,z,y,y]) yields [2,y]. =============  David A. Spear (DAS), (12178) 