/*-*-MACSYMA-*-*/ EVAL_WHEN(BATCH,TTYOFF:TRUE)$ /* Or use the BATCHLOAD command to load this with TTYOFF:TRUE */ /* NOTE: THE CURRENT VERSION OF VECT IS THE ONE DUE TO STOUTEMYER. IT WILL BE REPLACED SOON BY AN EXTENDED VERSION WHICH HANDLES BOTH VECTORS AND DYADICS. MICHAEL C. WIRTH (MCW) 12/18/78 Style changes made in order to TRANSLATE, 3/1/81 George Carrette (GJC) */ HERALD_PACKAGE('VECT)$ PUT('VECT,TRUE,'VERSION); EVAL_WHEN([TRANSLATE,batch,demo,load,loadfile], MATCHDECLARE([ETRUE,TTRUE,VTRUE], TRUE, LESSP, BEFORE, SCALARM, VSCALARP), TR_BOUND_FUNCTION_APPLYP:FALSE /* we do not want FOO(F):=F(1) to mean APPLY(F,[1]) */ )$ INFIX("~", 134, 133, EXPR, EXPR, EXPR) $ PREFIX("GRAD", 142, EXPR, EXPR) $ PREFIX("DIV", 142, EXPR, EXPR) $ PREFIX("CURL", 142, EXPR, EXPR) $ PREFIX("LAPLACIAN", 142, EXPR, EXPR) $ DECLARE([".",ORDER],COMMUTATIVE, ORDERN,NARY, ["GRAD","DIV","CURL","LAPLACIAN"],OUTATIVE, "CURL",NONSCALAR)$ TELLSIMPAFTER(0~ETRUE, 0) $ TELLSIMPAFTER(ETRUE~0, 0) $ TELLSIMPAFTER(ETRUE~ETRUE, 0)$ TELLSIMPAFTER(ETRUE~TTRUE.VTRUE, ETRUE.TTRUE~VTRUE)$ TELLSIMP(ETRUE~LESSP, -LESSP~ETRUE) $ TELLSIMPAFTER(DIV (CURL( ETRUE)), 0) $ TELLSIMPAFTER(CURL (GRAD( ETRUE)), 0) $ TELLSIMPAFTER(VECTORPOTENTIAL(ETRUE,TTRUE), (SCALEFACTORS(TTRUE), VPOT(ETRUE))) $ TELLSIMPAFTER(VECTORPOTENTIAL(ETRUE), VPOT(ETRUE)) $ TELLSIMPAFTER(EXPRESS(ETRUE), EXPRESS1(ETRUE)) $ TELLSIMPAFTER(EXPRESS(ETRUE,TTRUE), (SCALEFACTORS(TTRUE), EXPRESS(ETRUE))) $ TELLSIMPAFTER(POTENTIAL(ETRUE, TTRUE), (SCALEFACTORS(TTRUE), POTENTIAL1(ETRUE))) $ TELLSIMPAFTER(POTENTIAL(ETRUE), POTENTIAL1(ETRUE)) $ /* Variables and switches */ DEFINE_VARIABLE(COORDINATES, '[X, Y, Z],ANY)$ DEFINE_VARIABLE(DIMENSION,3,FIXNUM)$ DEFINE_VARIABLE(DIMENIMBED,1,FIXNUM)$ DEFINE_VARIABLE(TRYLENGTH,1,FIXNUM)$ DEFINE_VARIABLE(BESTLENGTH,1,FIXNUM)$ DEFINE_VARIABLE(sfprod,1,any)$ DEFINE_VARIABLE(sf,[1,1,1],list)$ DEFINE_VARIABLE(EXPANDALL,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDDOT,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDDOTPLUS,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDGRAD,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDPLUS,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDALL,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDGRADPLUS,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDDIV,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDDIVPLUS,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDCURL,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDCURLPLUS,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDLAPLACIAN,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDLAPLACIANPLUS,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDPROD,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDGRADPROD,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDDIVPROD,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDCURLCURL,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDLAPLACIANTODIVGRAD,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDLAPLACIANPROD,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDCROSS,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDCROSSCROSS,false,BOOLEAN)$ DEFINE_VARIABLE(EXPANDCROSSPLUS,false,BOOLEAN)$ DEFINE_VARIABLE(FIRSTCROSSSCALAR,false,BOOLEAN)$ EV_DIFF(X):=APPLY('EV,[X,'DIFF])$ declare(jacobian,special)$ SCALEFACTORS(TRANSFORMATION) := BLOCK( IF LISTP(FIRST(TRANSFORMATION)) THEN ( COORDINATES: REST(TRANSFORMATION), TRANSFORMATION: FIRST(TRANSFORMATION)) ELSE COORDINATES: LISTOFVARS(TRANSFORMATION), DIMENSION: LENGTH(COORDINATES), DIMENIMBED: LENGTH(TRANSFORMATION), FOR ROW:1 THRU DIMENSION DO FOR COL:1 THRU DIMENIMBED DO JACOBIAN[ROW,COL]: TRIGSIMP(RATSIMP(DIFF(TRANSFORMATION[COL], COORDINATES[ROW]))), SFPROD:1, FOR ROW:1 THRU DIMENSION DO ( FOR COL:1 THRU ROW-1 DO ( SF[ROW]: GCOV(ROW,COL), IF SF[ROW]#0 THEN PRINT("WARNING: COORDINATE SYSTEM IS NONORTHOGONAL UNLESS FOLLOWING SIMPLIFIES TO ZERO:", SF[ROW])), SF[ROW]: RADCAN(SQRT(GCOV(ROW,ROW))), SFPROD: SFPROD*SF[ROW])) $ GCOV(II,JJ) := TRIGSIMP(RATSIMP(SUM( JACOBIAN[II,KK]*JACOBIAN[JJ,KK], KK, 1, DIMENIMBED))) $ EXPRESS1(EXPN) := BLOCK( [ANS], IF MAPATOM(EXPN) THEN IF NONSCALARP(EXPN) THEN (ANS:[], FOR JJ: DIMENSION STEP -1 THRU 1 DO ANS: CONS(EXPN[COORDINATES[JJ]], ANS), RETURN(ANS)) ELSE RETURN(EXPN), EXPN: MAP('EXPRESS1, EXPN), IF MAPATOM(EXPN) OR LISTP(EXPN) THEN RETURN(EXPN), IF INPART(EXPN,0)="GRAD" THEN (ANS:[], EXPN: INPART(EXPN,1), FOR JJ: DIMENSION STEP -1 THRU 1 DO ANS: CONS('DIFF(EXPN,COORDINATES[JJ])/SF[JJ], ANS), RETURN(ANS)), IF PIECE="DIV" THEN (EXPN: INPART(EXPN,1), IF NOT LISTP(EXPN) THEN ERROR("DIV CALLED ON SCALAR ARG:", EXPN), RETURN(SUM('DIFF(SFPROD*EXPN[JJ]/SF[JJ], COORDINATES[JJ]), JJ, 1, DIMENSION)/SFPROD)), IF PIECE="LAPLACIAN" THEN RETURN(SUM('DIFF(SFPROD*'DIFF( INPART(EXPN,1),COORDINATES[JJ])/SF[JJ]**2, COORDINATES[JJ]), JJ, 1, DIMENSION) / SFPROD), IF PIECE="CURL" THEN (EXPN:INPART(EXPN,1), IF LISTP(EXPN) THEN ( IF LENGTH(EXPN)=2 THEN RETURN(('DIFF(SF[2]*EXPN[2], COORDINATES[1])-'DIFF(SF[1]*EXPN[1], COORDINATES[2]))/ SF[1]/SF[2]), IF DIMENSION=3 THEN RETURN([ ('DIFF(SF[3]*EXPN[3],COORDINATES[2])- 'DIFF(SF[2]*EXPN[2],COORDINATES[3]))/ SF[2]/SF[3], ('DIFF(SF[1]*EXPN[1],COORDINATES[3])- 'DIFF(SF[3]*EXPN[3],COORDINATES[1]))/ SF[1]/SF[3], ('DIFF(SF[2]*EXPN[2],COORDINATES[1]) - 'DIFF(SF[1]*EXPN[1],COORDINATES[2]))/ SF[1]/SF[2]])), ERROR("CURL USED IN SPACE OF WRONG DIMENSION")), IF PIECE="~" THEN ( ANS: INPART(EXPN,1), EXPN:INPART(EXPN,2), IF LISTP(ANS) AND LISTP(EXPN) AND LENGTH(ANS)=LENGTH(EXPN) THEN (IF LENGTH(ANS)=2 THEN RETURN(ANS[1]*EXPN[2] -ANS[2]*EXPN[1]), IF LENGTH(ANS)=3 THEN RETURN([ANS[2]*EXPN[3]- ANS[3]*EXPN[2], ANS[3]*EXPN[1]-ANS[1]*EXPN[3], ANS[1]*EXPN[2]-ANS[2]*EXPN[1]])), ERROR("~ USED WITH IMPROPER ARGUMENTS:",ANS,EXPN)), EXPN) $ TRIGSIMP(EXPN) := RATSIMP(TRIGSIMP1(NUM(EXPN))/TRIGSIMP1(DENOM(EXPN))) $ TRIGSIMP1(EXPN) := BLOCK( [LISTOFTRIGSQ, BESTLENGTH, TRYLENGTH], LISTOFTRIGSQ: LISTOFTRIGSQ(EXPN), BESTLENGTH: 999999, IF LISTOFTRIGSQ#[] THEN IMPROVE(EXPN, LISTOFTRIGSQ), RETURN(EXPN)) $ IMPROVE(SUBSOFAR, LISTOFTRIGSQ) := IF LISTOFTRIGSQ=[] THEN ( TRYLENGTH:mode_identity(fixnum, EXPNLENGTH(SUBSOFAR)), IF TRYLENGTH4 OR LHS(ORIGIN[2])#COORDINATES[CYC(2)] OR LHS(ORIGIN[3])#COORDINATES[CYC(3)] THEN ERROR( "LEFT SIDES OF POTENTIALZEROLOC MUST BE A CYCLIC", "PERMUTATION OF COORDINATES"), ORIGIN: [(MYINT(SF[CYC(1)]*SF[CYC(3)]*KURL[CYC(2)], LHS(ORIGIN[3]),RHS(ORIGIN[3]),LHS(ORIGIN[3])) - MYINT( SF[CYC(1)]*SF[CYC(2)]*SUBST(ORIGIN[3],KURL[CYC(3)]), LHS(ORIGIN[2]),RHS(ORIGIN[2]),LHS(ORIGIN[2])))/SF[CYC(1)], -MYINT(SF[CYC(2)]*SF[CYC(3)]*KURL[CYC(1)], LHS(ORIGIN[3]),RHS(ORIGIN[3]),LHS(ORIGIN[3]))/SF[CYC(2)], 0], ORIGIN: [ORIGIN[CYC(CYC(1))], ORIGIN[CYC(CYC(2))], ORIGIN[CYC(CYC(3))]], KURL: KURL-EXPRESS1(CURL (ORIGIN)), KURL: EV_DIFF(KURL), KURL: TRIGSIMP(RADCAN(KURL)), FOR JJ:1 THRU 3 DO IF KURL[JJ]#0 THEN PRINT( "UNABLE TO PROVE THAT THE FOLLOWING DIFFERENCE BETWEEN A", "COMPONENT OF THE INPUT AND OF THE CURL OUTPUT IS ZERO", KURL[JJ]), ORIGIN) $ DISJUNCT(L1,L2) := APPEND(SETDIFF(L1,L2), SETDIFF(L2,L1)) $ SETDIFF(L1,L2) := IF L1=[] THEN [] ELSE IF MEMBER(FIRST(L1),L2) THEN SETDIFF(REST(L1),L2) ELSE CONS(FIRST(L1), SETDIFF(REST(L1),L2)) $ SUBLESS(KK,origin,grperm) := (MODE_DECLARE(KK,FIXNUM),BLOCK([ANS,%dum], ANS: RATSUBST(%DUM, LHS(ORIGIN[KK]), GRPERM[KK]), FOR L1:1 THRU KK-1 DO ANS: RATSUBST(RHS(ORIGIN[L1]), LHS(ORIGIN[L1]),ANS), ANS)) $ MYINT(FUN,VAR,LOW,HIGH):=BLOCK([RESULT,ATLOW,ATHIGH], RESULT:INTEGRATE(FUN,VAR), IF FREEOF(nounify('INTEGRATE),RESULT) THEN ( ATLOW:EVLIMIT(RESULT,VAR,LOW), IF ATLOW=FALSE THEN GO(NOGOOD), ATHIGH:EVLIMIT(RESULT,VAR,HIGH), IF ATHIGH=FALSE THEN GO(NOGOOD), RETURN(RADCAN(ATHIGH-ATLOW))), NOGOOD, DEFINT(FUN,VAR,LOW,HIGH))$ EVLIMIT(EXPR,VAR,LIM):=BLOCK([TEMP], IF LIM='MINF OR LIM='INF THEN GO(USELIMIT), TEMP:ERRCATCH(SUBST(LIM,VAR,EXPR)), IF TEMP#[] THEN RETURN(TEMP[1]), USELIMIT, TEMP:LIMIT(EXPR,VAR,LIM), IF MEMBER(TEMP,'[INF,MINF,UND,IND,INFINITY]) THEN RETURN(FALSE), IF FREEOF(nounify('LIMIT),TEMP) THEN TEMP)$ EVAL_WHEN(BATCH,TTYOFF:FALSE)$