73 (infix("blurfle"), 0);
\r
80 (mnewton(FuncList,VarList,GuessList):=block(
\r
81 [nfunc,NewtonMatrix,det,Solutions,Increments,numdet,solved:false,i,j,k,
\r
82 keepfloat:true,ratprint:false],GuessList:float(GuessList),
\r
83 nfunc:length(FuncList),
\r
84 if length(VarList) # nfunc
\r
85 then (print("mnewton: incorrect number of variable names (",nfunc,
\r
86 "functions but",length(VarList),"variable names)."),
\r
88 if length(GuessList) # nfunc
\r
89 then (print("mnewton: incorrect number of approach values (",nfunc,
\r
90 "variables but",length(GuessList),
\r
91 "approximation values)."),return(false)),
\r
92 apply(kill,VarList),NewtonMatrix:zeromatrix(nfunc,nfunc),
\r
94 (for j thru nfunc do
\r
95 NewtonMatrix[i][j]:diff(FuncList[i],VarList[j])),
\r
96 det:determinant(NewtonMatrix),NewtonMatrix:adjoint(NewtonMatrix),
\r
97 NewtonMatrix:NewtonMatrix . FuncList,
\r
98 for k thru NEWTONMAXITER do
\r
99 (Solutions:map("=",VarList,GuessList),
\r
100 numdet:float(sublis(Solutions,det)),
\r
101 if abs(numdet) < NEWTONEPSILON then return(0),
\r
102 Increments:float(rectform(expand(
\r
104 NewtonMatrix/numdet)))),
\r
105 if atom(Increments) then Increments:matrix([Increments]),
\r
106 GuessList:GuessList-makelist(Increments[i][1],i,1,nfunc),
\r
108 for i thru nfunc do
\r
109 solved:solved and abs(Increments[i][1]) < NEWTONEPSILON,
\r
110 if solved then return(0)),
\r
112 then (print("mnewton: the process doesn't converge or it converges too slowly."),
\r
113 return([])),Solutions:map("=",VarList,GuessList),
\r
114 return([Solutions])),
\r
115 mnewton_defn1: fundef (mnewton), 0);
\r
118 /* following is the result of (linel : 32, string (fundef (mnewton))) given the above definition. */
\r
120 (mnewton(FuncList,VarList,\
\r
121 GuessList):=block([nfunc,Newton\
\r
122 Matrix,det,Solutions,Increments\
\r
123 ,numdet,solved:false,i,j,k,keep\
\r
124 float:true,ratprint:false],Gues\
\r
125 sList:float(GuessList),nfunc:le\
\r
126 ngth(FuncList),if length(VarLis\
\r
127 t) # nfunc then (print("mnewton\
\r
128 : incorrect number of variable \
\r
129 names (",nfunc,"functions but",\
\r
130 length(VarList),"variable names\
\r
131 )."),return(false)),if length(G\
\r
132 uessList) # nfunc then (print("\
\r
133 mnewton: incorrect number of ap\
\r
134 proach values (",nfunc,"variabl\
\r
135 es but",length(GuessList),"appr\
\r
136 oximation values)."),return(fal\
\r
137 se)),apply(kill,VarList),Newton\
\r
138 Matrix:zeromatrix(nfunc,nfunc),\
\r
139 for i thru nfunc do (for j thru\
\r
140 nfunc do NewtonMatrix[i][j]:di\
\r
141 ff(FuncList[i],VarList[j])),det\
\r
142 :determinant(NewtonMatrix),Newt\
\r
143 onMatrix:adjoint(NewtonMatrix),\
\r
144 NewtonMatrix:NewtonMatrix . Fun\
\r
145 cList,for k thru NEWTONMAXITER \
\r
146 do (Solutions:map("=",VarList,G\
\r
147 uessList),numdet:float(sublis(S\
\r
148 olutions,det)),if abs(numdet) <\
\r
149 NEWTONEPSILON then return(0),I\
\r
150 ncrements:float(rectform(expand\
\r
151 (sublis(Solutions,NewtonMatrix/\
\r
152 numdet)))),if atom(Increments) \
\r
153 then Increments:matrix([Increme\
\r
154 nts]),GuessList:GuessList-makel\
\r
155 ist(Increments[i][1],i,1,nfunc)\
\r
156 ,solved:true,for i thru nfunc d\
\r
157 o solved:solved and abs(Increme\
\r
158 nts[i][1]) < NEWTONEPSILON,if s\
\r
159 olved then return(0)),if solved\
\r
160 = false then (print("mnewton: \
\r
161 the process doesn't converge or\
\r
162 it converges too slowly."),ret\
\r
163 urn([])),Solutions:map("=",VarL\
\r
164 ist,GuessList),return([Solution\
\r
166 mnewton_defn2: fundef (mnewton), 0);
\r
169 is (equal (mnewton_defn1, mnewton_defn2));
\r