Merge branch 'master' of ssh://git.code.sf.net/p/maxima/code
[maxima.git] / tests / rtestparser_continuations_nl.mac
blobc91be48900135787166662111c07320ef5d3201f
1 prederror : false;
2 false;
4 \f\o\o\b\a\r;
5 foobar;
7 "\f\o\o\b\a\r";
8 "foobar";
10 "foo\
15 bar";
16 "foobar";
18 "foo\\\
20 bar";
21 "foo\\bar";
23 "foo\"\
24 bar\"\
25 baz";
26 "foo\"bar\"baz";
28 "\?foo\ bar";
29 "?foo bar";
37 123456;
39 "a\ \ \ \ b";
40 "a    b";
42 "a\\\ \\\b";
43 "a\\ \\b";
45 125\
46 125e-3;
47 125125e-3;
49 125125\
50 e-3;
51 125125e-3;
53 125125e\
54 -3;
55 125125e-3;
57 125125e-\
59 125125e-3;
61 si\
62 n(1);
63 sin(1);
65 cos(\
66 1);
67 cos(1);
69 12!\
71 12!!;
73 (infix("blurfle"), 0);
76 a blurf\
77 le b;
78 a blurfle b;
80 (mnewton(FuncList,VarList,GuessList):=block(
81         [nfunc,NewtonMatrix,det,Solutions,Increments,numdet,solved:false,i,j,k,
82          keepfloat:true,ratprint:false],GuessList:float(GuessList),
83         nfunc:length(FuncList),
84         if length(VarList) # nfunc
85             then (print("mnewton: incorrect number of variable names (",nfunc,
86                         "functions but",length(VarList),"variable names)."),
87                   return(false)),
88         if length(GuessList) # nfunc
89             then (print("mnewton: incorrect number of approach values (",nfunc,
90                         "variables but",length(GuessList),
91                         "approximation values)."),return(false)),
92         apply(kill,VarList),NewtonMatrix:zeromatrix(nfunc,nfunc),
93         for i thru nfunc do
94             (for j thru nfunc do
95                  NewtonMatrix[i][j]:diff(FuncList[i],VarList[j])),
96         det:determinant(NewtonMatrix),NewtonMatrix:adjoint(NewtonMatrix),
97         NewtonMatrix:NewtonMatrix . FuncList,
98         for k thru NEWTONMAXITER do
99             (Solutions:map("=",VarList,GuessList),
100              numdet:float(sublis(Solutions,det)),
101              if abs(numdet) < NEWTONEPSILON then return(0),
102              Increments:float(rectform(expand(
103                                         sublis(Solutions,
104                                                NewtonMatrix/numdet)))),
105              if atom(Increments) then Increments:matrix([Increments]),
106              GuessList:GuessList-makelist(Increments[i][1],i,1,nfunc),
107              solved:true,
108              for i thru nfunc do
109                  solved:solved and abs(Increments[i][1]) < NEWTONEPSILON,
110              if solved then return(0)),
111         if solved = false
112             then (print("mnewton: the process doesn't converge or it converges too slowly."),
113                   return([])),Solutions:map("=",VarList,GuessList),
114         return([Solutions])),
115 mnewton_defn1: fundef (mnewton), 0);
118 /* following is the result of (linel : 32, string (fundef (mnewton))) given the above definition. */
120 (mnewton(FuncList,VarList,\
121 GuessList):=block([nfunc,Newton\
122 Matrix,det,Solutions,Increments\
123 ,numdet,solved:false,i,j,k,keep\
124 float:true,ratprint:false],Gues\
125 sList:float(GuessList),nfunc:le\
126 ngth(FuncList),if length(VarLis\
127 t) # nfunc then (print("mnewton\
128 : incorrect number of variable \
129 names (",nfunc,"functions but",\
130 length(VarList),"variable names\
131 )."),return(false)),if length(G\
132 uessList) # nfunc then (print("\
133 mnewton: incorrect number of ap\
134 proach values (",nfunc,"variabl\
135 es but",length(GuessList),"appr\
136 oximation values)."),return(fal\
137 se)),apply(kill,VarList),Newton\
138 Matrix:zeromatrix(nfunc,nfunc),\
139 for i thru nfunc do (for j thru\
140  nfunc do NewtonMatrix[i][j]:di\
141 ff(FuncList[i],VarList[j])),det\
142 :determinant(NewtonMatrix),Newt\
143 onMatrix:adjoint(NewtonMatrix),\
144 NewtonMatrix:NewtonMatrix . Fun\
145 cList,for k thru NEWTONMAXITER \
146 do (Solutions:map("=",VarList,G\
147 uessList),numdet:float(sublis(S\
148 olutions,det)),if abs(numdet) <\
149  NEWTONEPSILON then return(0),I\
150 ncrements:float(rectform(expand\
151 (sublis(Solutions,NewtonMatrix/\
152 numdet)))),if atom(Increments) \
153 then Increments:matrix([Increme\
154 nts]),GuessList:GuessList-makel\
155 ist(Increments[i][1],i,1,nfunc)\
156 ,solved:true,for i thru nfunc d\
157 o solved:solved and abs(Increme\
158 nts[i][1]) < NEWTONEPSILON,if s\
159 olved then return(0)),if solved\
160  = false then (print("mnewton: \
161 the process doesn't converge or\
162  it converges too slowly."),ret\
163 urn([])),Solutions:map("=",VarL\
164 ist,GuessList),return([Solution\
165 s])),
166 mnewton_defn2: fundef (mnewton), 0);
169 is (equal (mnewton_defn1, mnewton_defn2));
170 true;
172 prederror : true;
173 true;