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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
\documentclass{article}
\usepackage{axiom}
\begin{document}
\title{\$SPAD/src/interp nag-c05.boot}
\author{The Axiom Team}
\maketitle
\begin{abstract}
\end{abstract}
\eject
\tableofcontents
\eject
\section{License}
<<license>>=
-- Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are
-- met:
--
-- - Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
--
-- - Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in
-- the documentation and/or other materials provided with the
-- distribution.
--
-- - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-- names of its contributors may be used to endorse or promote products
-- derived from this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@
<<*>>=
<<license>>
)package "BOOT"
c05adf() ==
htInitPage('"C05ADF - Zero of continuous function in given interval, Bus and Dekker algorithm",nil)
htMakePage '(
(domainConditions
(isDomain EM $EmptyMode)
(isDomain F (Float)))
(text . "\windowlink{Manual Page}{manpageXXc05adf} for this routine ")
(text . "\newline ")
(text . "\lispwindowlink{Browser operation page}{(|oPageFrom| '|c05adf| '|NagRootFindingPackage|)} for this routine")
(text . "\newline \horizontalline ")
(text . "\newline ")
(text . "C05ADF locates a zero of a continuous function in a ")
(text . "interval by a combination of the methods of linear ")
(text . "interpolation, extrapolation and bisection. ")
(text . "\blankline")
(text . "\newline ")
(text . "\menuitemstyle{}\tab{2} ")
(text . "Enter the function whose zero is to be determined ")
(text . "as a function of X, {\it f}: ")
(text . "\newline\tab{2} ")
(bcStrings (55 "exp(-X)-X" expression EM))
(text . "\blankline ")
(text . "\newline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "\newline Lower bound of the interval {\it a}:")
(text . "\tab{32} \menuitemstyle{}\tab{34}")
(text . "Upper bound {\it b}: ")
(text . "\newline\tab{2} ")
(bcStrings (10 "0.0" a F))
(text . "\tab{34} ")
(bcStrings (10 "1.0" b F))
(text . "\blankline ")
(text . "\newline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "\newline Absolute tolerance {\it eps}:")
(text . "\tab{32} \menuitemstyle{}\tab{34}")
(text . "Value tolerance {\it eta}:")
(text . "\newline\tab{2} ")
(bcStrings (10 "1.0e-5" eps F))
(text . "\tab{34} ")
(bcStrings (10 "0.0" eta F))
(text . "\blankline ")
(text . "\newline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "\newline Ifail value:")
(radioButtons ifail
("" " -1, Print error messages" minusOne)
("" " 1, Suppress error messages" one)))
htMakeDoneButton('"Continue", 'c05adfGen)
htShowPage()
c05adfGen htPage ==
a := htpLabelInputString(htPage,'a)
b := htpLabelInputString(htPage,'b)
eps := htpLabelInputString(htPage,'eps)
eta := htpLabelInputString(htPage,'eta)
temp := READ_-FROM_-STRING(eps)
error := htpButtonValue(htPage,'ifail)
ifail :=
error = 'one => 1
-1
temp1 :=
temp > 0.0 => eps
'"1.0e-5"
expression := htpLabelInputString(htPage, 'expression)
prefix := STRCONC('"c05adf(",a,",",b,",",temp1,",",eta,",",STRINGIMAGE ifail)
linkGen STRCONC (prefix,",(",expression,")::ASP1(F))")
c05nbf() ==
htInitPage('"C05NBF - Solution of system of nonlinear equations using function values only",nil)
htMakePage '(
(domainConditions
(isDomain PI (PositiveInteger)))
(text . "\windowlink{Manual Page}{manpageXXc05nbf} for this routine ")
(text . "\newline ")
(text . "\lispwindowlink{Browser operation page}{(|oPageFrom| '|c05nbf| '|NagRootFindingPackage|)} for this routine")
(text . "\newline \horizontalline ")
(text . "\newline ")
(text . "C05NBF finds a solution of a system of nonlinear equations ")
(text . "by a modification of the Powell hybrid method. ")
(text . "\blankline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Enter the number of equations in the system {\it n}:")
(text . "\newline\tab{2} ")
(bcStrings (5 9 n PI))
(text . "\newline ")
(text . "\blankline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Accuracy required {\it xtol}:")
(text . "\newline\tab{2} ")
-- should be sqrt(machine precision)
(bcStrings (10 "1.0e-9" xtol F))
(text . "\blankline ")
(text . "\newline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Ifail value:")
(radioButtons ifail
("" " -1, Print error messages" minusOne)
("" " 1, Suppress error messages" one)))
htMakeDoneButton('"Continue", 'c05nbfSolve)
htShowPage()
c05nbfSolve htPage ==
n :=
$bcParseOnly => PARSE_-INTEGER htpLabelInputString(htPage, 'n)
objValUnwrap htpLabelSpadValue(htPage, 'n)
xtol := htpLabelInputString(htPage,'xtol)
error := htpButtonValue(htPage,'ifail)
ifail :=
error = 'one => '1
'-1
n = '9 => c05nbfDefaultSolve(htPage,ifail,xtol)
funcList :=
"append"/[fa(i) for i in 1..n] where fa(i) ==
prefix := ('"\newline {\em Function ")
prefix := STRCONC(prefix,STRINGIMAGE i,'":} \space{1}")
funct := STRCONC ('"X[",STRINGIMAGE i ,"] + 1")
nam := INTERN STRCONC ('"n",STRINGIMAGE i)
[['text,:prefix],['bcStrings,[42, funct, nam, 'EM]]]
middle := ('"\blankline \menuitemstyle{}\tab{2} Enter initial guess ")
middle := STRCONC(middle,'"of the solution vector {\it x}: \newline ")
middle := cons('text,middle)
vecList :=
[fb(i) for i in 1..n] where fb(i) ==
xnam := INTERN STRCONC ('"x",STRINGIMAGE i)
['bcStrings,[4, -1.0, xnam, 'F]]
funcList := [:funcList,middle,:vecList]
equationPart := [
'(domainConditions
(isDomain EM $EmptyMode)
(isDomain F (Float))
(isDomain I (Integer))),
:funcList]
page := htInitPage("C05NBF - Solution of system of nonlinear equations using function values only", htpPropertyList htPage)
htSay '"\menuitemstyle{}\tab{2} "
htSay '"Enter the functions \htbitmap{fi} below in terms of X[1]...X[n]: "
htSay '"\newline "
htMakePage equationPart
htMakeDoneButton('"Continue",'c05nbfGen)
htpSetProperty(page,'n,n)
htpSetProperty(page,'ifail,ifail)
htpSetProperty(page,'xtol,xtol)
htpSetProperty(page,'inputArea, htpInputAreaAlist htPage)
htShowPage()
c05nbfDefaultSolve (htPage,ifail,xtol) ==
n := '9
page := htInitPage("C05NBF - Solution of system of nonlinear equations using function values only", nil)
htMakePage '(
(domainConditions
(isDomain EM $EmptyMode)
(isDomain F (Float))
(isDomain I (Integer)))
(text . "\newline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Enter the functions \htbitmap{fi} below in terms of X[1]...X[n]; ")
(text . " \newline ")
(text . "\newline {\em Function 1:} \space{1}")
(bcStrings (42 "3*X[1] - 2*X[1]**2 - 2*X[2] + 1" n1 EM))
(text . "\newline {\em Function 2:} \space{1}")
(bcStrings (42 "-X[1] + 3*X[2] - 2*X[2]**2 - 2*X[3] + 1" n2 EM))
(text . "\newline {\em Function 3:} \space{1}")
(bcStrings (42 "-X[2] + 3*X[3] - 2*X[3]**2 - 2*X[4] + 1" n3 EM))
(text . "\newline {\em Function 4:} \space{1}")
(bcStrings (42 "-X[3] + 3*X[4] - 2*X[4]**2 - 2*X[5] + 1" n4 EM))
(text . "\newline {\em Function 5:} \space{1}")
(bcStrings (42 "-X[4] + 3*X[5] - 2*X[5]**2 - 2*X[6] + 1" n5 EM))
(text . "\newline {\em Function 6:} \space{1}")
(bcStrings (42 "-X[5] + 3*X[6] - 2*X[6]**2 - 2*X[7] + 1" n6 EM))
(text . "\newline {\em Function 7:} \space{1}")
(bcStrings (42 "-X[6] + 3*X[7] - 2*X[7]**2 - 2*X[8] + 1" n7 EM))
(text . "\newline {\em Function 8:} \space{1}")
(bcStrings (42 "-X[7] + 3*X[8] - 2*X[8]**2 - 2*X[9] + 1" n8 EM))
(text . "\newline {\em Function 9:} \space{1}")
(bcStrings (42 "-X[8] + 3*X[9] - 2*X[9]**2 + 1" n9 EM))
(text . "\blankline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Enter initial guess of the solution vector {\it x}: \newline ")
(bcStrings (4 "-1.0" x1 F))
(bcStrings (4 "-1.0" x2 F))
(bcStrings (4 "-1.0" x3 F))
(bcStrings (4 "-1.0" x4 F))
(bcStrings (4 "-1.0" x5 F))
(bcStrings (4 "-1.0" x6 F))
(bcStrings (4 "-1.0" x7 F))
(bcStrings (4 "-1.0" x8 F))
(bcStrings (4 "-1.0" x9 F)))
htMakeDoneButton('"Continue",'c05nbfGen)
htpSetProperty(page,'n,n)
htpSetProperty(page,'ifail,ifail)
htpSetProperty(page,'xtol,xtol)
htpSetProperty(page,'inputArea, htpInputAreaAlist htPage)
htShowPage()
c05nbfGen htPage ==
n := htpProperty(htPage, 'n)
ifail := htpProperty(htPage,'ifail)
xtol := htpProperty(htPage,'xtol)
alist := htpInputAreaAlist htPage
y := alist
i := 1
while y repeat
if i < (n+1) then
temp1 := STRCONC ((first y).1," ")
temp1list := [temp1,:temp1list]
else
temp2 := (first y).1
temp2list := [temp2,:temp2list]
y := rest y
i := i + 1
string1 := bcwords2liststring temp1list
string2 := bcwords2liststring temp2list
lwa := n*(3*n+13)/2
prefix := STRCONC ("c05nbf(",STRINGIMAGE n,",",STRINGIMAGE lwa,",[",string1,"],")
middle := STRCONC (xtol,",",STRINGIMAGE ifail,",")
linkGen STRCONC (prefix,middle,"(",string2,"::Vector Expression(Float))::ASP6(FCN))")
c05pbf() ==
htInitPage('"C05PBF - Solution of system of nonlinear equations using first derivatives",nil)
htMakePage '(
(domainConditions
(isDomain PI (PositiveInteger)))
(text . "\windowlink{Manual Page}{manpageXXc05pbf} for this routine ")
(text . "\newline ")
(text . "\lispwindowlink{Browser operation page}{(|oPageFrom| '|c05pbf| '|NagRootFindingPackage|)} for this routine")
(text . "\newline \horizontalline ")
(text . "\newline ")
(text . "C05PBF finds a solution of a system of nonlinear equations ")
(text . "by a modification of the Powell hybrid method. ")
(text . "\blankline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Enter the number of equations in the system {\it n}:")
(text . "\newline\tab{2} ")
(bcStrings (5 9 n PI))
(text . "\newline ")
(text . "\blankline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Accuracy required {\it xtol}:")
(text . "\newline\tab{2} ")
-- should be sqrt(machine precision)
(bcStrings (10 "1.0e-9" xtol F))
(text . "\blankline ")
(text . "\newline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Ifail value:")
(radioButtons ifail
("" " -1, Print error messages" minusOne)
("" " 1, Suppress error messages" one)))
htMakeDoneButton('"Continue", 'c05pbfSolve)
htShowPage()
c05pbfSolve htPage ==
n :=
$bcParseOnly => PARSE_-INTEGER htpLabelInputString(htPage, 'n)
objValUnwrap htpLabelSpadValue(htPage, 'n)
xtol := htpLabelInputString(htPage,'xtol)
error := htpButtonValue(htPage,'ifail)
ifail :=
error = 'one => '1
'-1
n = '9 => c05pbfDefaultSolve(htPage,ifail,xtol)
funcList :=
"append"/[fa(i) for i in 1..n] where fa(i) ==
prefix := ('"\newline {\em Function ")
prefix := STRCONC(prefix,STRINGIMAGE i,'":} \space{1}")
funct := STRCONC ('"X[",STRINGIMAGE i ,"] + 1")
nam := INTERN STRCONC ('"n",STRINGIMAGE i)
[['text,:prefix],['bcStrings,[42, funct, nam, 'EM]]]
middle := ('"\blankline \menuitemstyle{}\tab{2} Enter initial guess ")
middle := STRCONC(middle,'"of the solution vector {\it x}: \newline ")
middle := cons('text,middle)
vecList :=
[fb(i) for i in 1..n] where fb(i) ==
xnam := INTERN STRCONC ('"x",STRINGIMAGE i)
['bcStrings,[4, -1.0, xnam, 'F]]
funcList := [:funcList,middle,:vecList]
equationPart := [
'(domainConditions
(isDomain EM $EmptyMode)
(isDomain F (Float))
(isDomain I (Integer))),
:funcList]
page := htInitPage('"C05PBF - Solution of system of nonlinear equations using first derivatives",htpPropertyList htPage)
htSay '"\menuitemstyle{}\tab{2} "
htSay '"Enter the functions \htbitmap{fi} below in terms of X[1]...X[n]: "
htSay '"\newline "
htMakePage equationPart
htMakeDoneButton('"Continue",'c05pbfGen)
htpSetProperty(page,'n,n)
htpSetProperty(page,'ifail,ifail)
htpSetProperty(page,'xtol,xtol)
htpSetProperty(page,'inputArea, htpInputAreaAlist htPage)
htShowPage()
c05pbfDefaultSolve (htPage,ifail,xtol) ==
n := '9
page := htInitPage('"C05PBF - Solution of system of nonlinear equations using first derivatives",nil)
htMakePage '(
(domainConditions
(isDomain EM $EmptyMode)
(isDomain F (Float))
(isDomain I (Integer)))
(text . "\newline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Enter the functions \htbitmap{fi} below in terms of X[1]...X[n]: ")
(text . "\newline ")
(text . "\newline {\em Function 1:} \space{1}")
(bcStrings (42 "3*X[1] - 2*X[1]**2 - 2*X[2] + 1" n1 EM))
(text . "\newline {\em Function 2:} \space{1}")
(bcStrings (42 "-X[1] + 3*X[2] - 2*X[2]**2 - 2*X[3] + 1" n2 EM))
(text . "\newline {\em Function 3:} \space{1}")
(bcStrings (42 "-X[2] + 3*X[3] - 2*X[3]**2 - 2*X[4] + 1" n3 EM))
(text . "\newline {\em Function 4:} \space{1}")
(bcStrings (42 "-X[3] + 3*X[4] - 2*X[4]**2 - 2*X[5] + 1" n4 EM))
(text . "\newline {\em Function 5:} \space{1}")
(bcStrings (42 "-X[4] + 3*X[5] - 2*X[5]**2 - 2*X[6] + 1" n5 EM))
(text . "\newline {\em Function 6:} \space{1}")
(bcStrings (42 "-X[5] + 3*X[6] - 2*X[6]**2 - 2*X[7] + 1" n6 EM))
(text . "\newline {\em Function 7:} \space{1}")
(bcStrings (42 "-X[6] + 3*X[7] - 2*X[7]**2 - 2*X[8] + 1" n7 EM))
(text . "\newline {\em Function 8:} \space{1}")
(bcStrings (42 "-X[7] + 3*X[8] - 2*X[8]**2 - 2*X[9] + 1" n8 EM))
(text . "\newline {\em Function 9:} \space{1}")
(bcStrings (42 "-X[8] + 3*X[9] - 2*X[9]**2 + 1" n9 EM))
(text . "\blankline ")
(text . "\menuitemstyle{}\tab{2}")
(text . "Enter initial guess of the solution vector {\it x}: \newline ")
(bcStrings (4 "-1.0" x1 F))
(bcStrings (4 "-1.0" x2 F))
(bcStrings (4 "-1.0" x3 F))
(bcStrings (4 "-1.0" x4 F))
(bcStrings (4 "-1.0" x5 F))
(bcStrings (4 "-1.0" x6 F))
(bcStrings (4 "-1.0" x7 F))
(bcStrings (4 "-1.0" x8 F))
(bcStrings (4 "-1.0" x9 F)))
htMakeDoneButton('"Continue",'c05pbfGen)
htpSetProperty(page,'n,n)
htpSetProperty(page,'ifail,ifail)
htpSetProperty(page,'xtol,xtol)
htpSetProperty(page,'inputArea, htpInputAreaAlist htPage)
htShowPage()
c05pbfGen htPage ==
n := htpProperty(htPage, 'n)
ifail := htpProperty(htPage,'ifail)
xtol := htpProperty(htPage,'xtol)
alist := htpInputAreaAlist htPage
y := alist
i := 1
while y repeat
if i < (n+1) then
temp1 := STRCONC ((first y).1," ")
temp1list := [temp1,:temp1list]
else
temp2 := (first y).1
temp2list := [temp2,:temp2list]
y := rest y
i := i + 1
string1 := bcwords2liststring temp1list
string2 := bcwords2liststring temp2list
lwa := n*(n+13)/2
prefix := STRCONC("c05pbf(",STRINGIMAGE n,",",STRINGIMAGE n)
middle := STRCONC(",",STRINGIMAGE lwa,",[",string1,"],")
middle := STRCONC (middle,xtol,",",STRINGIMAGE ifail,",")
linkGen STRCONC (prefix,middle,"(",string2,"::Vector Expression(Float))::ASP35(FCN))")
@
\eject
\begin{thebibliography}{99}
\bibitem{1} nothing
\end{thebibliography}
\end{document}
|