73 (infix("blurfle"), 0);
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)."),
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),
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(
104 NewtonMatrix/numdet)))),
105 if atom(Increments) then Increments:matrix([Increments]),
106 GuessList:GuessList-makelist(Increments[i][1],i,1,nfunc),
109 solved:solved and abs(Increments[i][1]) < NEWTONEPSILON,
110 if solved then return(0)),
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\
166 mnewton_defn2: fundef (mnewton), 0);
169 is (equal (mnewton_defn1, mnewton_defn2));