-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
cliapps.mac
136 lines (114 loc) · 3.26 KB
/
cliapps.mac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
stringdisp :true;
declare(trigsimp, evfun);
if get('clifford,'version)=false then (
err:errcatch(
load("clifford.mac"),
load("cliffordan.mac"),
load("climoivre.mac")
),
if emptyp(err) then (
infix ("|", 130, 129),
infix("&", 130, 129)
)
);
if get('cliapps,'version)=false then (
remove("@", operator),
"inner product",
infix ("@", 130, 129),
"@"(a, b):= scprod(a,b),
print("warning: redefining @")
);
/*
coordinate functions - 3D
*/
sph_vect(vv):=block([r, theta, phi],
if length(vv) <3 or not listp(vv) then error("list with 3 symbols required"),
[r, theta, phi]:vv,
for i:1 thru length(vv) do
if not emptyp(vv[i]) then (
qq:subst(x=vv[i], buildq([x], declare(x, scalar))),
ev(qq, nouns)
),
asymbol[1]*r* sin(theta)*cos(phi)+asymbol[2]*r* sin(theta)*sin(phi)+ asymbol[3]*r* cos(theta)
);
cyl_vect(vv):=block([r, phi, z],
if length(vv) <3 or not listp(vv) then error("list with 3 symbols required"),
[r, theta, z]:vv,
for i:1 thru length(vv) do
if not emptyp(vv[i]) then (
qq:subst(x=vv[i], buildq([x], declare(x, scalar))),
ev(qq, nouns)
),
asymbol[1]*r* cos(phi)+asymbol[2]*r* sin(phi)+ asymbol[3]*z
);
pol_vect(vv):=block([r, phi],
if length(vv) <2 or not listp(vv) then error("list with 2 symbols required"),
[r, theta]:vv,
for i:1 thru length(vv) do
if not emptyp(vv[i]) then (
qq:subst(x=vv[i], buildq([x], declare(x, scalar))),
ev(qq, nouns)
),
asymbol[1]*r* cos(phi)+asymbol[2]*r* sin(phi)
);
/* substitution in differnetial equations*/
eqsubst(deq, yv, rr, eqs):=block([rs, qs, ret, lv],
rs:coordsubst(rr, eqs),
/*disp(rs),*/
/* dependent variable*/
ret:rs @ mvectdiff(yv, rr),
ret:trigsimp(ret),
ret:ratsimp(ret),
qs:cdirdiff(yv, rr, rs),
qs:subst(eqs, qs),
qs:trigsimp(qs),
qs:ratsimp(qs),
lv:listofvars(maplist(rhs, eqs)),
/*disp(lv),*/
lv:solve(eqs, lv),
ret:subst(lv, ret),
rs: ratsubst( qs, ret, deq),
[rs, ret=qs, lv]
);
/*diffsubst(deq, dvar, eq):=block([nn, zz, sop, sargs, u, ret, l, r, dsymb:nounify('derivative) ],
if numberp(deq) then return(deq),
sop:inop(deq),
if op(eq)="=" then zz:rhs(eq) else error("provide explicit equation"),
if inop(deq)="+" then
ret:map(lambda([u], diffsubst(u, dvar, eq)), deq)
else
if diffp(deq) then (
sargs:inargs(deq),
nn:sargs[3],
if lhs(eq)=sargs[2] then (
ret:subst(dsymb=lambda([ff, xx, nn], 'totdiff(ff, zz, [dvar])), deq),
ret:ev(ret, nouns),
if nn>1 then
for k:1 thru nn-1 do ret:totdiff(ret, zz, [dvar])
) else ret:deq
) else (
[l, r]: oppart(deq, lambda([u], freeof(dsymb, u))),
if r#nil then
r: diffsubst(r, dvar, eq)
else r:1,
l: subst(eq, l),
ret:l*r
),
ret
);
*/
/*
simp:false,
tellsimpafter(asymbol[kk] * asymbol[mm], if kk#mm then 0 else signature[kk]),
tellsimpafter(asymbol[kk] * asymbol[mm] *bb, if kk#mm then 0 else signature[kk]*bb),
tellsimpafter(aa[kk]^nn, if oddp(nn) then 0 else signature[kk] ),
simp:true
*/
put('cliapps, 'v1,'version);
put('cliapps, "Dimiter Prodanov", 'author);
put('cliapps, "(C) - Dimiter Prodanov, 2015- 2017", 'copyright);
print("package name: cliffordan.mac");
print("author: ", get('cliapps,'author));
print("version:", get('cliapps,'version));
print("Recommended location: share/contrib");
print("last update: 14 Aug 2017");