numeric.log 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382
  1. Codemist Standard Lisp 3.54 for DEC Alpha: May 23 1994
  2. Dump file created: Mon May 23 10:39:11 1994
  3. REDUCE 3.5, 15-Oct-93 ...
  4. Memory allocation: 6023424 bytes
  5. +++ About to read file ndotest.red
  6. on errcont;
  7. bounds (x,x=(1 .. 2));
  8. 1 .. 2
  9. bounds (2*x,x=(1 .. 2));
  10. 2 .. 4
  11. bounds (x**3,x=(1 .. 2));
  12. 1 .. 8
  13. bounds (x*y,x=(1 .. 2),y=(-1 .. 0));
  14. - 2 .. 0
  15. bounds (x**3+y,x=(1 .. 2),y=(-1 .. 0));
  16. 0 .. 8
  17. bounds (x**3/y,{x=(1 .. 2),y=(-1 .. -0.5)});
  18. - 16 .. -1
  19. bounds (x**3/y,x=(1 .. 2),y=(-1 .. -0.5));
  20. - 16 .. -1
  21. % unbounded expression (pole at y=0)
  22. bounds (x**3/y,x=(1 .. 2),y=(-1 .. 0.5));
  23. ***** unbounded in range
  24. on rounded;
  25. bounds(e**x,x=(1 .. 2));
  26. 2.71828182846 .. 7.38905609893
  27. bounds((1/2)**x,x=(1 .. 2));
  28. 0.25 .. 0.5
  29. off rounded;
  30. bounds(abs x,x=(1 .. 2));
  31. 1 .. 2
  32. bounds(abs x,x=(-3 .. 2));
  33. 0 .. 3
  34. bounds(abs x,x=(-3 .. -2));
  35. 2 .. 3
  36. bounds(sin x,x=(1 .. 2));
  37. - 1 .. 1
  38. on rounded;
  39. bounds(sin x,x=(1 .. 2));
  40. 0.841470984808 .. 1
  41. bounds(sin x,x=(1 .. 10));
  42. - 1 .. 1
  43. bounds(sin x,x=(1001 .. 1002));
  44. 0.167266541974 .. 0.919990597586
  45. bounds(log x,x=(1 .. 10));
  46. 0 .. 2.30258509299
  47. bounds(tan x,x=(1 .. 1.1));
  48. 1.55740772465 .. 1.96475965725
  49. bounds(cot x,x=(1 .. 1.1));
  50. 0.508968105239 .. 0.642092615934
  51. bounds(asin x,x=(-0.6 .. 0.6));
  52. - 0.643501108793 .. 0.643501108793
  53. bounds(acos x,x=(-0.6 .. 0.6));
  54. 0.927295218002 .. 2.21429743559
  55. bounds(sqrt(x),x=(1 .. 1.1));
  56. 1 .. 1.04880884817
  57. bounds(x**(7/3),x=(1 .. 1.1));
  58. 1 .. 1.2490589397
  59. bounds(x**y,x=(1 .. 1.1),y=(2 .. 4));
  60. 1 .. 1.4641
  61. off rounded;
  62. % MINIMA (steepest descent)
  63. % Rosenbrock function (minimum extremely hard to find).
  64. fktn := 100*(x1^2-x2)^2 + (1-x1)^2;
  65. 4 2 2 2
  66. fktn := 100*x1 - 200*x1 *x2 + x1 - 2*x1 + 100*x2 + 1
  67. num_min(fktn, x1=-1.2, x2=1, accuracy=6);
  68. {4.30709181812,{x1= - 1.01283672884,x2=1.0763931719}}
  69. % infinitely many local minima
  70. num_min(sin(x)+x/5, x=1);
  71. { - 1.31699384718,{x= - 1.96120922347}}
  72. % bivariate polynomial
  73. num_min(x^4 + 3 x^2 * y + 5 y^2 + x + y, x=0.1, y=0.2);
  74. { - 0.0682649733788,{x= - 0.027563873416,y= - 0.143877701468}}
  75. % ROOTS (non polynomial: damped Newton)
  76. num_solve (cos x -x, x=0,accuracy=6);
  77. {x=0.739085133215}
  78. % automatically randomized starting point
  79. num_solve (cos x -x,x, accuracy=6);
  80. {x=0.739085133215}
  81. % syntactical errors: forms do not evaluate to purely
  82. % numerical values
  83. num_solve (cos x -x, x=a);
  84. ***** a invalid as number
  85. num_solve (cos x -a, x=0);
  86. ***** a invalid as number
  87. ***** error during function evaluation (e.g. singularity)
  88. num_solve (sin x = 0, x=3);
  89. {x=3.14159265359}
  90. % blows up: no real solution exists
  91. num_solve(sin x = 2, x=1);
  92. ***** Newton method does not converge
  93. % solution in complex plane(only fond with complex starting point):
  94. on complex;
  95. *** Domain mode rounded changed to complex-rounded
  96. num_solve(sin x = 2, x=1+i);
  97. {x=1.57079632542 + 1.31695789681*i}
  98. off complex;
  99. *** Domain mode complex-rounded changed to rounded
  100. % blows up for derivative 0 in starting point
  101. num_solve(x^2-1, x=0);
  102. ***** error during function evaluation (e.g. singularity)
  103. % succeeds because of perturbed starting point
  104. num_solve(x^2-1, x=0.1);
  105. {x=1.00000000033}
  106. % bivariate equation system
  107. num_solve({sin x=cos y, x + y = 1},{x=1,y=2});
  108. {x= - 52.1216769476,y=53.1216769476}
  109. on rounded,evallhseqp;
  110. sub(ws,{sin x=cos y, x + y = 1});
  111. { - 0.959549629985= - 0.959549629985,1=1}
  112. off rounded,evallhseqp;
  113. % temporal member of the Barry Simon test sequence
  114. sys :={sin (x) + y^2 + log(z) = 7,
  115. 3*x + 2^y - z^3 = -90,
  116. x^2 + y^2 + z^(1/2) = 16};
  117. 2
  118. sys := {sin(x) + y + log(z)=7,
  119. y 3
  120. 3*x + 2 - z =-90,
  121. 2 2 1/2
  122. x + y + z =16}
  123. sol:=num_solve(sys,{x=1,y=1,z=1});
  124. sol := {x=2.93087675819,y= - 2.29328251176,z=4.62601269017}
  125. on rounded;
  126. for each s in sys collect sub(sol,lhs s-rhs s);
  127. {0,0,0}
  128. off rounded;
  129. clear sys,sol;
  130. % 2 examples taken from Nowak/Weimann (Tech.Rep TR91-10, ZIB Berlin)
  131. % #1: exp/sin combination
  132. on rounded;
  133. sys := {e**(x1**2 + x2**2)-3, x1 + x2 - sin(3(x1 + x2))};
  134. 2 2
  135. x1 + x2
  136. sys := {e - 3,
  137. - sin(3*x1 + 3*x2) + x1 + x2}
  138. num_solve(sys,x1=0.81, x2=0.82);
  139. *** precision increased to 14
  140. *** precision increased to 19
  141. *** precision increased to 20
  142. {x1= - 0.256625076922,x2=1.01624596361}
  143. sub(ws,sys);
  144. {0,0}
  145. % 2nd example (semiconductor simulation), here computed with
  146. % intermediate steps printed
  147. alpha := 38.683;
  148. alpha := 38.683
  149. ni := 1.22e10;
  150. ni := 1.22e+10
  151. v := 100;
  152. v := 100
  153. d := 1e17;
  154. d := 1.0e+17
  155. sys := { e**(alpha*(x3-x1)) - e**(alpha*(x1-x2)) - d/ni,
  156. x2,
  157. x3,
  158. e**(alpha*(x6-x4)) - e**(alpha*(x4-x5)) + d/ni,
  159. x5 - v,
  160. x6 - v};
  161. 77.366*x1 38.683*x1 + 38.683*x2
  162. sys := {( - e - 8.19672131148e+6*e
  163. 38.683*x2 + 38.683*x3 38.683*x1 + 38.683*x2
  164. + e )/e ,
  165. x2,
  166. x3,
  167. 77.366*x4 38.683*x4 + 38.683*x5
  168. ( - e + 8.19672131148e+6*e
  169. 38.683*x5 + 38.683*x6 38.683*x4 + 38.683*x5
  170. + e )/e ,
  171. x5 - 100,
  172. x6 - 100}
  173. on trnumeric;
  174. num_solve(sys,x1=1,x2=2,x3=3,x4=4,x5=5,x6=6,iterations=100);
  175. *** computing symbolic Jacobian
  176. *** inverting symbolic Jacobian
  177. *** starting Newton iteration
  178. 1. residue=(1.46329673989e+33 , 0 , 0 , 1.46329673989e+33 , 0.0 , 0.0
  179. ), step length=163.473870223
  180. at ( - 1.97414885092 , 0 , 0 , 98.0258511491 , 100.0 , 100.0)
  181. 2. residue=(5.38316786938e+32 , 0.0 , 0.0 , 5.38316786939e+32 , 0.0
  182. , 0.0), step length=0.0365590456369
  183. at ( - 1.94829770183 , 0.0 , 0.0 , 98.0517022982 , 100.0 , 100.0)
  184. 3. residue=(1.98035678752e+32 , 0 , 0 , 1.98035678752e+32 , 0.0 , 0.0
  185. ), step length=0.0365590456369
  186. at ( - 1.92244655275 , 0 , 0 , 98.0775534473 , 100.0 , 100.0)
  187. 4. residue=(7.28532548313e+31 , 0.0 , 0.0 , 7.28532548314e+31 , 0.0
  188. , 0.0), step length=0.0365590456369
  189. at ( - 1.89659540367 , 0.0 , 0.0 , 98.1034045963 , 100.0 , 100.0)
  190. 5. residue=(2.68012146749e+31 , 0 , 0 , 2.68012146749e+31 , 0.0 , 0.0
  191. ), step length=0.0365590456369
  192. at ( - 1.87074425458 , 0 , 0 , 98.1292557454 , 100.0 , 100.0)
  193. 6. residue=(9.8596158773e+30 , 0.0 , 0.0 , 9.85961587732e+30 , 0.0 ,
  194. 0.0), step length=0.0365590456369
  195. at ( - 1.8448931055 , 0.0 , 0.0 , 98.1551068945 , 100.0 , 100.0)
  196. 7. residue=(3.62714997911e+30 , 0 , 0 , 3.62714997911e+30 , 0.0 , 0.0
  197. ), step length=0.0365590456369
  198. at ( - 1.81904195641 , 0 , 0 , 98.1809580436 , 100.0 , 100.0)
  199. 8. residue=(1.33435390736e+30 , 0.0 , 0.0 , 1.33435390736e+30 , 0.0
  200. , 0.0), step length=0.0365590456369
  201. at ( - 1.79319080733 , 0.0 , 0.0 , 98.2068091927 , 100.0 , 100.0)
  202. 9. residue=(4.90881369764e+29 , 0 , 0 , 4.90881369765e+29 , 0.0 , 0.0
  203. ), step length=0.0365590456369
  204. at ( - 1.76733965825 , 0 , 0 , 98.2326603418 , 100.0 , 100.0)
  205. 10. residue=(1.8058516399e+29 , 0.0 , 0.0 , 1.80585163991e+29 , 0.0
  206. , 0.0), step length=0.0365590456369
  207. at ( - 1.74148850916 , 0.0 , 0.0 , 98.2585114908 , 100.0 , 100.0)
  208. 11. residue=(6.64335692126e+28 , 0 , 0 , 6.64335692127e+28 , 0.0 , 0.
  209. 0), step length=0.0365590456369
  210. at ( - 1.71563736008 , 0 , 0 , 98.2843626399 , 100.0 , 100.0)
  211. 12. residue=(2.4439544317e+28 , 0.0 , 0.0 , 2.4439544317e+28 , 0.0 ,
  212. 0.0), step length=0.0365590456369
  213. at ( - 1.689786211 , 0.0 , 0.0 , 98.310213789 , 100.0 , 100.0)
  214. 13. residue=(8.99080590581e+27 , 0 , 0 , 8.99080590582e+27 , 0.0 , 0.
  215. 0), step length=0.0365590456369
  216. at ( - 1.66393506191 , 0 , 0 , 98.3360649381 , 100.0 , 100.0)
  217. 14. residue=(3.30753265231e+27 , 0.0 , 0.0 , 3.30753265232e+27 , 0.0
  218. , 0.0), step length=0.0365590456369
  219. at ( - 1.63808391283 , 0.0 , 0.0 , 98.3619160872 , 100.0 , 100.0)
  220. 15. residue=(1.21677326379e+27 , 0 , 0 , 1.21677326379e+27 , 0.0 , 0.
  221. 0), step length=0.0365590456369
  222. at ( - 1.61223276375 , 0 , 0 , 98.3877672363 , 100.0 , 100.0)
  223. 16. residue=(4.47625868315e+26 , 0.0 , 0.0 , 4.47625868319e+26 , 0.0
  224. , 0.0), step length=0.0365590456369
  225. at ( - 1.58638161466 , 0.0 , 0.0 , 98.4136183853 , 100.0 , 100.0)
  226. 17. residue=(1.64672354289e+26 , 0 , 0 , 1.64672354291e+26 , 0.0 , 0.
  227. 0), step length=0.0365590456369
  228. at ( - 1.56053046558 , 0 , 0 , 98.4394695344 , 100.0 , 100.0)
  229. 18. residue=(6.05795736724e+25 , 0.0 , 0.0 , 6.0579573673e+25 , 0.0
  230. , 0.0), step length=0.0365590456369
  231. at ( - 1.5346793165 , 0.0 , 0.0 , 98.4653206835 , 100.0 , 100.0)
  232. 19. residue=(2.2285979709e+25 , 0 , 0 , 2.22859797092e+25 , 0.0 , 0.0
  233. ), step length=0.0365590456369
  234. at ( - 1.50882816741 , 0 , 0 , 98.4911718326 , 100.0 , 100.0)
  235. 20. residue=(8.19855376131e+24 , 0.0 , 0.0 , 8.19855376138e+24 , 0.0
  236. , 0.0), step length=0.0365590456369
  237. at ( - 1.48297701833 , 0.0 , 0.0 , 98.5170229817 , 100.0 , 100.0)
  238. 21. residue=(3.01607937612e+24 , 0 , 0 , 3.01607937615e+24 , 0.0 , 0.
  239. 0), step length=0.0365590456369
  240. at ( - 1.45712586924 , 0 , 0 , 98.5428741308 , 100.0 , 100.0)
  241. 22. residue=(1.10955359542e+24 , 0.0 , 0.0 , 1.10955359543e+24 , 0.0
  242. , 0.0), step length=0.0365590456369
  243. at ( - 1.43127472016 , 0.0 , 0.0 , 98.5687252798 , 100.0 , 100.0)
  244. 23. residue=(4.08181956632e+23 , 0 , 0 , 4.08181956636e+23 , 0.0 , 0.
  245. 0), step length=0.0365590456369
  246. at ( - 1.40542357108 , 0 , 0 , 98.5945764289 , 100.0 , 100.0)
  247. 24. residue=(1.50161750102e+23 , 0.0 , 0.0 , 1.50161750103e+23 , 0.0
  248. , 0.0), step length=0.0365590456369
  249. at ( - 1.37957242199 , 0.0 , 0.0 , 98.620427578 , 100.0 , 100.0)
  250. 25. residue=(5.52414207128e+22 , 0 , 0 , 5.52414207133e+22 , 0.0 , 0.
  251. 0), step length=0.0365590456369
  252. at ( - 1.35372127291 , 0 , 0 , 98.6462787271 , 100.0 , 100.0)
  253. 26. residue=(2.03221829814e+22 , 0.0 , 0.0 , 2.03221829815e+22 , 0.0
  254. , 0.0), step length=0.0365590456369
  255. at ( - 1.32787012383 , 0.0 , 0.0 , 98.6721298762 , 100.0 , 100.0)
  256. 27. residue=(7.47611331857e+21 , 0 , 0 , 7.47611331863e+21 , 0.0 , 0.
  257. 0), step length=0.0365590456369
  258. at ( - 1.30201897474 , 0 , 0 , 98.6979810253 , 100.0 , 100.0)
  259. 28. residue=(2.75030838977e+21 , 0.0 , 0.0 , 2.75030838979e+21 , 0.0
  260. , 0.0), step length=0.0365590456369
  261. at ( - 1.27616782566 , 0.0 , 0.0 , 98.7238321743 , 100.0 , 100.0)
  262. 29. residue=(1.01178191348e+21 , 0 , 0 , 1.01178191349e+21 , 0.0 , 0.
  263. 0), step length=0.0365590456369
  264. at ( - 1.25031667658 , 0 , 0 , 98.7496833234 , 100.0 , 100.0)
  265. 30. residue=(3.72213764917e+20 , 0.0 , 0.0 , 3.72213764921e+20 , 0.0
  266. , 0.0), step length=0.0365590456369
  267. at ( - 1.22446552749 , 0.0 , 0.0 , 98.7755344725 , 100.0 , 100.0)
  268. 31. residue=(1.36929791834e+20 , 0 , 0 , 1.36929791836e+20 , 0.0 , 0.
  269. 0), step length=0.0365590456369
  270. at ( - 1.19861437841 , 0 , 0 , 98.8013856216 , 100.0 , 100.0)
  271. 32. residue=(5.03736552996e+19 , 0.0 , 0.0 , 5.03736553005e+19 , 0.0
  272. , 0.0), step length=0.0365590456369
  273. at ( - 1.17276322933 , 0.0 , 0.0 , 98.8272367707 , 100.0 , 100.0)
  274. 33. residue=(1.85314321614e+19 , 0 , 0 , 1.85314321617e+19 , 0.0 , 0.
  275. 0), step length=0.0365590456369
  276. at ( - 1.14691208024 , 0 , 0 , 98.8530879198 , 100.0 , 100.0)
  277. 34. residue=(6.81733290764e+18 , 0.0 , 0.0 , 6.81733290776e+18 , 0.0
  278. , 0.0), step length=0.0365590456369
  279. at ( - 1.12106093116 , 0.0 , 0.0 , 98.8789390688 , 100.0 , 100.0)
  280. 35. residue=(2.50795662034e+18 , 0 , 0 , 2.50795662039e+18 , 0.0 , 0.
  281. 0), step length=0.0365590456369
  282. at ( - 1.09520978207 , 0 , 0 , 98.9047902179 , 100.0 , 100.0)
  283. 36. residue=(9.22625679971e+17 , 0.0 , 0.0 , 9.22625679991e+17 , 0.0
  284. , 0.0), step length=0.0365590456369
  285. at ( - 1.06935863299 , 0.0 , 0.0 , 98.930641367 , 100.0 , 100.0)
  286. 37. residue=(3.39415019556e+17 , 0 , 0 , 3.39415019568e+17 , 0.0 , 0.
  287. 0), step length=0.0365590456369
  288. at ( - 1.04350748391 , 0 , 0 , 98.9564925161 , 100.0 , 100.0)
  289. 38. residue=(1.24863807717e+17 , 0.0 , 0.0 , 1.24863807726e+17 , 0.0
  290. , 0.0), step length=0.0365590456369
  291. at ( - 1.01765633483 , 0.0 , 0.0 , 98.9823436652 , 100.0 , 100.0)
  292. 39. residue=(4.59348278034e+16 , 0 , 0 , 4.59348278111e+16 , 0.0 , 0.
  293. 0), step length=0.0365590456369
  294. at ( - 0.991805185743 , 0 , 0 , 99.0081948143 , 100.0 , 100.0)
  295. 40. residue=(1.68984787805e+16 , 0.0 , 0.0 , 1.68984787876e+16 , 0.0
  296. , 0.0), step length=0.0365590456369
  297. at ( - 0.965954036664 , 0.0 , 0.0 , 99.0340459633 , 100.0 , 100.0)
  298. 41. residue=(6.21660292823e+15 , 0 , 0 , 6.21660293516e+15 , 0.0 , 0.
  299. 0), step length=0.0365590456369
  300. at ( - 0.940102887593 , 0 , 0 , 99.0598971124 , 100.0 , 100.0)
  301. 42. residue=(2.28696040906e+15 , 0.0 , 0.0 , 2.28696041594e+15 , 0.0
  302. , 0.0), step length=0.0365590456369
  303. at ( - 0.914251738544 , 0.0 , 0.0 , 99.0857482616 , 100.0 , 100.0)
  304. 43. residue=(8.41325715099e+14 , 0 , 0 , 8.41325721968e+14 , 0.0 , 0.
  305. 0), step length=0.0365590456369
  306. at ( - 0.888400589553 , 0 , 0 , 99.1115994107 , 100.0 , 100.0)
  307. 44. residue=(3.09506431748e+14 , 0.0 , 0.0 , 3.09506438607e+14 , 0.0
  308. , 0.0), step length=0.0365590456369
  309. at ( - 0.862549440721 , 0.0 , 0.0 , 99.1374505601 , 100.0 , 100.0)
  310. 45. residue=(1.13861050985e+14 , 0 , 0 , 1.13861057839e+14 , 0.0 , 0.
  311. 0), step length=0.0365590456369
  312. at ( - 0.836698292322 , 0 , 0 , 99.1633017098 , 100.0 , 100.0)
  313. 46. residue=(4.18871376415e+13 , 0.0 , 0.0 , 4.1887144495e+13 , 0.0
  314. , 0.0), step length=0.0365590456369
  315. at ( - 0.8108471451 , 0.0 , 0.0 , 99.1891528608 , 100.0 , 100.0)
  316. 47. residue=(1.54094146219e+13 , 0 , 0 , 1.5409421475e+13 , 0.0 , 0.0
  317. ), step length=0.0365590456369
  318. at ( - 0.784996001075 , 0 , 0 , 99.2150040149 , 100.0 , 100.0)
  319. 48. residue=(5.66880467397e+12 , 0.0 , 0.0 , 5.6688115269e+12 , 0.0
  320. , 0.0), step length=0.0365590456369
  321. at ( - 0.759144865742 , 0.0 , 0.0 , 99.2408551778 , 100.0 , 100.0)
  322. 49. residue=(2.08543452966e+12 , 0 , 0 , 2.08544138253e+12 , 0.0 , 0.
  323. 0), step length=0.036559045637
  324. at ( - 0.733293754037 , 0 , 0 , 99.2667063642 , 100.0 , 100.0)
  325. 50. residue=(767186323467.0 , 0.0 , 0.0 , 767193176319.0 , 0.0 , 0.0)
  326. , step length=0.0365590456375
  327. at ( - 0.70744270656 , 0.0 , 0.0 , 99.2925576149 , 100.0 , 100.0)
  328. 51. residue=(282229910057.0 , 0 , 0 , 282236762903.0 , 0.0 , 0.0)
  329. , step length=0.0365590456414
  330. at ( - 0.681591833671 , 0 , 0 , 99.3184090402 , 100.0 , 100.0)
  331. 52. residue=(103824415727.0 , 0.0 , 0.0 , 103831268569.0 , 0.0 , 0.0)
  332. , step length=0.0365590456703
  333. at ( - 0.655741435353 , 0.0 , 0.0 , 99.3442609401 , 100.0 , 100.0)
  334. 53. residue=(3.81927022457e+10 , 0 , 0 , 3.81995550873e+10 , 0.0 , 0.
  335. 0), step length=0.0365590458835
  336. at ( - 0.629892327003 , 0 , 0 , 99.3701141301 , 100.0 , 100.0)
  337. 54. residue=(1.40481443717e+10 , 0.0 , 0.0 , 1.40549972129e+10 , 0.0
  338. , 0.0), step length=0.0365590474585
  339. at ( - 0.604046724769 , 0.0 , 0.0 , 99.3959708274 , 100.0 , 100.0)
  340. 55. residue=(5.16585846951e+9 , 0 , 0 , 5.17271131074e+9 , 0.0 , 0.0)
  341. , step length=0.0365590590969
  342. at ( - 0.578210650353 , 0 , 0 , 99.4218370614 , 100.0 , 100.0)
  343. 56. residue=(1.89824960589e+9 , 0.0 , 0.0 , 1.9051024488e+9 , 0.0 , 0
  344. .0), step length=0.0365591450932
  345. at ( - 0.552400454575 , 0.0 , 0.0 , 99.4477292394 , 100.0 , 100.0)
  346. 57. residue=(6.96167585052e+8 , 0 , 0 , 7.03020440599e+8 , 0.0 , 0.0)
  347. , step length=0.0365597805245
  348. at ( - 0.526660451901 , 0 , 0 , 99.4736920939 , 100.0 , 100.0)
  349. 58. residue=(2.53957444815e+8 , 0.0 , 0.0 , 2.60810394006e+8 , 0.0 ,
  350. 0.0), step length=0.0365644757288
  351. at ( - 0.501110133883 , 0.0 , 0.0 , 99.4998482048 , 100.0 , 100.0)
  352. 59. residue=(9.13074482936e+7 , 0 , 0 , 9.81610893499e+7 , 0.0 , 0.0)
  353. , step length=0.036599167075
  354. at ( - 0.476067267452 , 0 , 0 , 99.526538163 , 100.0 , 100.0)
  355. 60. residue=(3.15519019482e+7 , 0.0 , 0.0 , 3.84106468392e+7 , 0.0 ,
  356. 0.0), step length=0.0368554086395
  357. at ( - 0.452345623749 , 0.0 , 0.0 , 99.5547446298 , 100.0 , 100.0)
  358. 61. residue=(9.77481469302e+6 , 0 , 0 , 1.66708124709e+7 , 0.0 , 0.0)
  359. , step length=0.0387445972031
  360. at ( - 0.431825342687 , 0 , 0 , 99.5876089247 , 100.0 , 100.0)
  361. 62. residue=(2.23533931681e+6 , 0.0 , 0.0 , 9.38172386019e+6 , 0.0 ,
  362. 0.0), step length=0.0527640781991
  363. at ( - 0.417764764235 , 0.0 , 0.0 , 99.6384650755 , 100.0 , 100.0)
  364. 63. residue=(2.23262484734e+5 , 0 , 0 , 8.19715321429e+6 , 0.0 , 0.0)
  365. , step length=0.204739774362
  366. at ( - 0.41222548566 , 0 , 0 , 99.843129903 , 100.0 , 100.0)
  367. 64. residue=(2.23088062724e+5 , 0.0 , 0.0 , 8.19035290356e+6 , 0.0 ,
  368. 0.0), step length=0.383303021227
  369. at ( - 0.412224950141 , 0.0 , 0.0 , 100.226432924 , 100.0 , 100.0)
  370. 65. residue=(2.22216670074e+5 , 0 , 0 , 7.22880779685e+6 , 0.0 , 0.0)
  371. , step length=0.129870827278
  372. at ( - 0.412222274586 , 0 , 0 , 100.356303751 , 100.0 , 100.0)
  373. 66. residue=(1.66845393097e+5 , 0.0 , 0.0 , 1.93472873001e+6 , 0.0 ,
  374. 0.0), step length=0.048267265693
  375. at ( - 0.412051690235 , 0.0 , 0.0 , 100.404570716 , 100.0 , 100.0)
  376. 67. residue=(1653.19388834 , 0 , 0 , - 3.32193995967e+5 , 0.0 , 0.0)
  377. , step length=0.00800369971031
  378. at ( - 0.411535983805 , 0 , 0 , 100.412557784 , 100.0 , 100.0)
  379. 68. residue=(0.166671263061 , 0.0 , 0.0 , - 6386.15658432 , 0.0 , 0.
  380. 0), step length=0.00100689376012
  381. at ( - 0.411530770947 , 0.0 , 0.0 , 100.411550903 , 100.0 , 100.0)
  382. 69. residue=(0.0 , 0 , 0 , - 2.48519530414 , 0.0 , 0.0)
  383. , step length=0.0000201252374946
  384. at ( - 0.411530770421 , 0 , 0 , 100.411530778 , 100.0 , 100.0)
  385. {x1= - 0.411530770421,x2=0.0,x3=0.0,x4=100.41153077,x5=100.0,x6=100.0
  386. }
  387. off trnumeric;
  388. clear alpha,ni,v,d,sys;
  389. off rounded;
  390. % INTEGRALS
  391. num_int( x**2,x=(1 .. 2),accuracy=3);
  392. 7
  393. ---
  394. 3
  395. % 1st case: using formal integral
  396. needle := 1/(10**-4 + x**2);
  397. 10000
  398. needle := --------------
  399. 2
  400. 10000*x + 1
  401. num_int(needle,x=(-1 .. 1),accuracy=3);
  402. 312.159332022
  403. % 312.16
  404. % no formal integral, but easy Chebyshev fit
  405. num_int(sin x/x,x=(1 .. 10));
  406. 0.712264523852
  407. % using a Chebyshev fit of order 60
  408. num_int(exp(-x**2),x=(-10 .. 10),accuracy=3);
  409. 1.77245387654
  410. % 1.772
  411. % cases with singularities
  412. num_int(1/sqrt x ,x=(0 .. 1),accuracy=2);
  413. 1.99959014
  414. % 1.999
  415. num_int(1/sqrt abs x ,x=(-1 .. 1),iterations=50);
  416. 3.99999231465
  417. % 3.999
  418. % simple multidimensional integrals
  419. num_int(x+y,x=(0 .. 1),y=(2 .. 3));
  420. 3.0
  421. num_int(sin(x+y),x=(0 .. 1),y=(0 .. 1));
  422. 0.773147731572
  423. % APPROXIMATION
  424. %approximate sin x by a cubic polynomial
  425. num_fit(sin x,{1,x,x**2,x**3},x=for i:=0:20 collect 0.1*i);
  426. 3 2
  427. { - 0.0847539694988*x - 0.134641944765*x + 1.06263064633*x
  428. - 0.00519313406469,
  429. { - 0.00519313406469,1.06263064633, - 0.134641944765,
  430. - 0.0847539694988}}
  431. % approximate x**2 by a harmonic series in the interval [0,1]
  432. num_fit(x**2,1 . for i:=1:5 join {sin(i*x)},
  433. x=for i:=0:10 collect i/10);
  434. { - 1.30957812469*sin(5*x) + 7.16375589255*sin(4*x)
  435. - 18.5490188558*sin(3*x) + 26.5601718368*sin(2*x)
  436. - 19.449219292*sin(x) - 0.00197199699049,
  437. { - 0.00197199699049, - 19.449219292,26.5601718368, - 18.5490188558,
  438. 7.16375589255, - 1.30957812469}}
  439. % approximate a set of points by a polynomial
  440. pts:=for i:=1 step 0.1 until 3 collect i$
  441. vals:=for each p in pts collect (p+2)**3$
  442. num_fit(vals,{1,x,x**2,x**3},x=pts);
  443. 3 2
  444. {1.00000000002*x + 5.99999999987*x + 12.0000000003*x
  445. + 7.99999999985,{7.99999999985,12.0000000003,5.99999999987,1.000000
  446. 00002}}
  447. % compute the approximation error
  448. on rounded;
  449. first ws - (x+2)**3;
  450. 3 2
  451. 0.0000000000219859686013*x - 0.000000000133417721315*x
  452. + 0.000000000255498733281*x - 0.000000000152677870346
  453. off rounded;
  454. % ODE SOLUTION (Runge-Kutta)
  455. depend(y,x);
  456. % approximate y=y(x) with df(y,x)=2y in interval [0 : 5]
  457. num_odesolve(df(y,x)=y,y=2,x=(0 .. 5),iterations=20);
  458. {{x,y},
  459. {0.0,2.0},
  460. {0.25,2.56805083337},
  461. {0.5,3.2974425414},
  462. {0.75,4.23400003322},
  463. {1.0,5.43656365691},
  464. {1.25,6.98068591491},
  465. {1.5,8.96337814065},
  466. {1.75,11.509205352},
  467. {2.0,14.7781121978},
  468. {2.25,18.9754716726},
  469. {2.5,24.3649879213},
  470. {2.75,31.2852637682},
  471. {3.0,40.1710738461},
  472. {3.25,51.5806798341},
  473. {3.5,66.2309039169},
  474. {3.75,85.0421639995},
  475. {4.0,109.196300065},
  476. {4.25,140.210824692},
  477. {4.5,180.034262599},
  478. {4.75,231.168569052},
  479. {5.0,296.826318202}}
  480. % same with negative direction
  481. num_odesolve(df(y,x)=y,y=2,x=(0 .. -5),iterations=20);
  482. {{x,y},
  483. {0.0,2.0},
  484. {-0.25,1.55760156614},
  485. {-0.5,1.21306131943},
  486. {-0.75,0.944733105483},
  487. {-1.0,0.735758882344},
  488. {-1.25,0.573009593722},
  489. {-1.5,0.446260320298},
  490. {-1.75,0.347547886902},
  491. {-2.0,0.270670566474},
  492. {-2.25,0.210798449125},
  493. {-2.5,0.164169997249},
  494. {-2.75,0.127855722414},
  495. {-3.0,0.0995741367363},
  496. {-3.25,0.0775484156639},
  497. {-3.5,0.060394766845},
  498. {-3.75,0.0470354917124},
  499. {-4.0,0.0366312777778},
  500. {-4.25,0.0285284678182},
  501. {-4.5,0.0222179930767},
  502. {-4.75,0.0173033904064},
  503. {-5.0,0.0134758939983}}
  504. % giving a nice picture when plotted
  505. num_odesolve(df(y,x)=1- x*y**2 ,y=0,x=(0 .. 4),iterations=20);
  506. {{x,y},
  507. {0.0,0.0},
  508. {0.2,0.199600912188},
  509. {0.4,0.393714914166},
  510. {0.6,0.569482634406},
  511. {0.8,0.710657687564},
  512. {1.0,0.805480022354},
  513. {1.2,0.852604291055},
  514. {1.4,0.860563377356},
  515. {1.6,0.842333334456},
  516. {1.8,0.80999200878},
  517. {2.0,0.772211952811},
  518. {2.2,0.734163640068},
  519. {2.4,0.698433235122},
  520. {2.6,0.666019196492},
  521. {2.8,0.637070046905},
  522. {3.0,0.611341375657},
  523. {3.2,0.588447372601},
  524. {3.4,0.567985133759},
  525. {3.6,0.549587947292},
  526. {3.8,0.532942255624},
  527. {4.0,0.517787833735}}
  528. % system of ordinary differential equations
  529. depend(y,x);
  530. depend(z,x);
  531. num_odesolve(
  532. {df(z,x) = y, df(y,x)= y+x},
  533. {z=2, y=4},
  534. x=(0 .. 5),iterations=20);
  535. {{x,z,y},
  536. {0.0,2.0,4.0},
  537. {0.25,3.13887708344,5.17012708344},
  538. {0.5,4.61860635349,6.74360635349},
  539. {0.75,6.55375008305,8.83500008305},
  540. {1.0,9.09140914227,11.5914091423},
  541. {1.25,12.4204647873,15.2017147873},
  542. {1.5,16.7834453516,19.9084453516},
  543. {1.75,22.4917633799,26.0230133799},
  544. {2.0,29.9452804945,33.9452804945},
  545. {2.25,39.6574291816,44.1886791816},
  546. {2.5,52.2874698032,57.4124698032},
  547. {2.75,68.6819094205,74.4631594205},
  548. {3.0,89.9276846154,96.4276846154},
  549. {3.25,117.420449585,124.701699585},
  550. {3.5,152.952259792,161.077259792},
  551. {3.75,198.824159999,207.855409999},
  552. {4.0,257.990750164,267.990750164},
  553. {4.25,334.245811731,345.277061731},
  554. {4.5,432.460656499,444.585656499},
  555. {4.75,558.890172631,572.171422631},
  556. {5.0,721.565795506,736.065795506}}
  557. %----------------- Chebyshev fit -------------------------
  558. on rounded;
  559. func := x**2 * (x**2 - 2) * sin x;
  560. 2 2
  561. func := sin(x)*x *(x - 2)
  562. ord := 15;
  563. ord := 15
  564. cx:=chebyshev_fit(func,x=(0 .. 2),ord)$
  565. cp:=first cx;
  566. 13 12
  567. cp := 0.000000620105544057*x + 0.0000168737249552*x
  568. 11 10
  569. - 0.000269014301699*x + 0.000155645930929*x
  570. 9 8 7
  571. + 0.00848163780605*x + 0.000272748318878*x - 0.183540091626*x
  572. 6 5 4
  573. + 0.000106808218177*x + 1.33329694625*x + 0.0000077069025981*x
  574. 3 2
  575. - 2.00000091553*x + 0.0000000501510828421*x
  576. - 0.000000000784963205547*x - 4.86721773996e-13
  577. cc:=second cx;
  578. cc := {2.69320512829,
  579. 2.76751928466,
  580. 2.25642507569,
  581. 0.955452569949,
  582. 0.0509075944268,
  583. - 0.0868248678183,
  584. - 0.0170919216091,
  585. 0.00104527137626,
  586. 0.000349190502034,
  587. - 0.00000253521592327,
  588. - 0.0000028079884063,
  589. - 0.0000000157676042787,
  590. 0.0000000121753403457,
  591. 0.000000000118269897256,
  592. - 0.0000000000331230578364}
  593. for u:=0 step 0.2 until 2 do write
  594. "x:",u," true value:",sub(x=u,func),
  595. " Chebyshev eval:", chebyshev_eval(cc,x=(0 .. 2),x=u),
  596. " Chebyshev polynomial:",sub(x=u,cp);
  597. x:0 true value:0 Chebyshev eval: - 4.85611550971e-13
  598. Chebyshev polynomial: - 4.86721773996e-13
  599. x:0.2 true value: - 0.0155756755343 Chebyshev eval: - 0.0155756755339
  600. Chebyshev polynomial: - 0.015575675548
  601. x:0.4 true value: - 0.114644759976 Chebyshev eval: - 0.114644759976
  602. Chebyshev polynomial: - 0.114644759974
  603. x:0.6 true value: - 0.333364916292 Chebyshev eval: - 0.333364916292
  604. Chebyshev polynomial: - 0.333364916295
  605. x:0.8 true value: - 0.624386741519 Chebyshev eval: - 0.624386741519
  606. Chebyshev polynomial: - 0.624386741504
  607. x:1 true value: - 0.841470984808 Chebyshev eval: - 0.841470984808
  608. Chebyshev polynomial: - 0.841470984841
  609. x:1.2 true value: - 0.751596318924 Chebyshev eval: - 0.751596318924
  610. Chebyshev polynomial: - 0.751596318876
  611. x:1.4 true value: - 0.0772592588311 Chebyshev eval: - 0.0772592588311
  612. Chebyshev polynomial: - 0.0772592588864
  613. x:1.6 true value:1.43298871732 Chebyshev eval:1.43298871732
  614. Chebyshev polynomial:1.43298871738
  615. x:1.8 true value:3.91253024182 Chebyshev eval:3.91253024182
  616. Chebyshev polynomial:3.91253024177
  617. x:2.0 true value:7.27437941461 Chebyshev eval:7.27437941461
  618. Chebyshev polynomial:7.27437941467
  619. % integral
  620. % integrate coefficients
  621. ci := chebyshev_int(cc,x=(0 .. 2));
  622. ci := {0.0310113015322,
  623. 0.2183900263,
  624. 0.453016678678,
  625. 0.367586246877,
  626. 0.130284679721,
  627. 0.00679995160359,
  628. - 0.00732251159954,
  629. - 0.00124579372222,
  630. 0.0000654879120115,
  631. 0.0000195554716911,
  632. - 0.000000125972415949,
  633. - 0.000000128189261211,
  634. - 0.000000000661911423998,
  635. 0.000000000469556284751,
  636. 4.22392490199e-12}
  637. % compare with true values (normalized absolute term)
  638. ci0:=chebyshev_eval(ci,x=(0 .. 2),x=0)$
  639. ifunc := int(func,x)$
  640. if0 := sub(x=0,ifunc);
  641. if0 := - 28.0
  642. for u:=0 step 0.2 until 2 do write
  643. {u,sub(x=u,ifunc) - if0,
  644. chebyshev_eval(ci,x=(0 .. 2),x=u) - ci0};
  645. {0,0,0}
  646. {0.2, - 0.000785836355117, - 0.00078583635293}
  647. {0.4, - 0.0119047051867, - 0.0119047051858}
  648. {0.6, - 0.0548116700418, - 0.0548116700408}
  649. {0.8, - 0.150297976106, - 0.150297976105}
  650. {1, - 0.299838223412, - 0.29983822341}
  651. {1.2, - 0.466528961073, - 0.466528961072}
  652. {1.4, - 0.561460555384, - 0.561460555383}
  653. {1.6, - 0.441445769516, - 0.441445769514}
  654. {1.8,0.0768452822437,0.0768452822437}
  655. {2.0,1.18309971762,1.18309971762}
  656. % derivative
  657. % differentiate coefficients
  658. cd := chebyshev_df(cc,x=(0 .. 2))$
  659. % compute coefficients of derivative
  660. cds := second chebyshev_fit(df(func,x),x=(0 .. 2),ord)$
  661. % compare coefficients
  662. for i:=1:ord do write {part(cd,i),part(cds,i)};
  663. {10.4140931324,10.4140931324}
  664. {9.23338917839,9.2333891784}
  665. {4.87905456308,4.87905456307}
  666. {0.207688875651,0.207688875654}
  667. { - 0.853660856614, - 0.853660856625}
  668. { - 0.199571879764, - 0.19957187976}
  669. {0.0145878215688,0.0145878215579}
  670. {0.00553117954514,0.00553117954883}
  671. { - 0.0000459776988956, - 0.0000459777097762}
  672. { - 0.0000558684874034, - 0.0000558684837256}
  673. { - 0.000000343812276803, - 0.00000034382315262}
  674. {0.000000291280722677,0.000000291284408252}
  675. {0.00000000307501732865,0.00000000306414314461}
  676. { - 0.000000000927445619419, - 0.000000000923750237476}
  677. {0, - 0.0000000000109244878416}
  678. clear func,ord,cc,cx,cd,cds,ci,ci0;
  679. off rounded;
  680. end;
  681. (TIME: numeric 88746 93096)
  682. End of Lisp run after 88.77+5.01 seconds