File: rtestparser_continuations_cr.mac

package info (click to toggle)
maxima-sage 5.45.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 113,788 kB
  • sloc: lisp: 440,833; fortran: 14,665; perl: 14,369; tcl: 10,997; sh: 4,475; makefile: 2,520; ansic: 447; python: 262; xml: 59; awk: 37; sed: 17
file content (174 lines) | stat: -rw-r--r-- 4,147 bytes parent folder | download | duplicates (10)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
prederror : false;
false;

\f\o\o\b\a\r;
foobar;

"\f\o\o\b\a\r";
"foobar";

"foo\
\
\
\
\
bar";
"foobar";

"foo\\\
\
bar";
"foo\\bar";

"foo\"\
bar\"\
baz";
"foo\"bar\"baz";

"\?foo\ bar";
"?foo bar";

1\
2\
3\
4\
5\
6;
123456;

"a\ \ \ \ b";
"a    b";

"a\\\ \\\b";
"a\\ \\b";

125\
125e-3;
125125e-3;

125125\
e-3;
125125e-3;

125125e\
-3;
125125e-3;

125125e-\
3;
125125e-3;

si\
n(1);
sin(1);

cos(\
1);
cos(1);

12!\
!;
12!!;

(infix("blurfle"), 0);
0;

a blurf\
le b;
a blurfle b;

(mnewton(FuncList,VarList,GuessList):=block(
        [nfunc,NewtonMatrix,det,Solutions,Increments,numdet,solved:false,i,j,k,
         keepfloat:true,ratprint:false],GuessList:float(GuessList),
        nfunc:length(FuncList),
        if length(VarList) # nfunc
            then (print("mnewton: incorrect number of variable names (",nfunc,
                        "functions but",length(VarList),"variable names)."),
                  return(false)),
        if length(GuessList) # nfunc
            then (print("mnewton: incorrect number of approach values (",nfunc,
                        "variables but",length(GuessList),
                        "approximation values)."),return(false)),
        apply(kill,VarList),NewtonMatrix:zeromatrix(nfunc,nfunc),
        for i thru nfunc do
            (for j thru nfunc do
                 NewtonMatrix[i][j]:diff(FuncList[i],VarList[j])),
        det:determinant(NewtonMatrix),NewtonMatrix:adjoint(NewtonMatrix),
        NewtonMatrix:NewtonMatrix . FuncList,
        for k thru NEWTONMAXITER do
            (Solutions:map("=",VarList,GuessList),
             numdet:float(sublis(Solutions,det)),
             if abs(numdet) < NEWTONEPSILON then return(0),
             Increments:float(rectform(expand(
                                        sublis(Solutions,
                                               NewtonMatrix/numdet)))),
             if atom(Increments) then Increments:matrix([Increments]),
             GuessList:GuessList-makelist(Increments[i][1],i,1,nfunc),
             solved:true,
             for i thru nfunc do
                 solved:solved and abs(Increments[i][1]) < NEWTONEPSILON,
             if solved then return(0)),
        if solved = false
            then (print("mnewton: the process doesn't converge or it converges too slowly."),
                  return([])),Solutions:map("=",VarList,GuessList),
        return([Solutions])),
mnewton_defn1: fundef (mnewton), 0);
0;

/* following is the result of (linel : 32, string (fundef (mnewton))) given the above definition. */

(mnewton(FuncList,VarList,\
GuessList):=block([nfunc,Newton\
Matrix,det,Solutions,Increments\
,numdet,solved:false,i,j,k,keep\
float:true,ratprint:false],Gues\
sList:float(GuessList),nfunc:le\
ngth(FuncList),if length(VarLis\
t) # nfunc then (print("mnewton\
: incorrect number of variable \
names (",nfunc,"functions but",\
length(VarList),"variable names\
)."),return(false)),if length(G\
uessList) # nfunc then (print("\
mnewton: incorrect number of ap\
proach values (",nfunc,"variabl\
es but",length(GuessList),"appr\
oximation values)."),return(fal\
se)),apply(kill,VarList),Newton\
Matrix:zeromatrix(nfunc,nfunc),\
for i thru nfunc do (for j thru\
 nfunc do NewtonMatrix[i][j]:di\
ff(FuncList[i],VarList[j])),det\
:determinant(NewtonMatrix),Newt\
onMatrix:adjoint(NewtonMatrix),\
NewtonMatrix:NewtonMatrix . Fun\
cList,for k thru NEWTONMAXITER \
do (Solutions:map("=",VarList,G\
uessList),numdet:float(sublis(S\
olutions,det)),if abs(numdet) <\
 NEWTONEPSILON then return(0),I\
ncrements:float(rectform(expand\
(sublis(Solutions,NewtonMatrix/\
numdet)))),if atom(Increments) \
then Increments:matrix([Increme\
nts]),GuessList:GuessList-makel\
ist(Increments[i][1],i,1,nfunc)\
,solved:true,for i thru nfunc d\
o solved:solved and abs(Increme\
nts[i][1]) < NEWTONEPSILON,if s\
olved then return(0)),if solved\
 = false then (print("mnewton: \
the process doesn't converge or\
 it converges too slowly."),ret\
urn([])),Solutions:map("=",VarL\
ist,GuessList),return([Solution\
s])),
mnewton_defn2: fundef (mnewton), 0);
0;

is (equal (mnewton_defn1, mnewton_defn2));
true;

prederror : true;
true;