limits.rlg 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  1. Tue Feb 10 12:28:30 2004 run on Linux
  2. % Tests of limits package.
  3. limit(sin(x)/x,x,0);
  4. 1
  5. % 1
  6. limit(sin(x)^2/x,x,0);
  7. 0
  8. % 0
  9. limit(sin(x)/x,x,1);
  10. sin(1)
  11. % sin(1)
  12. limit(1/x,x,0);
  13. infinity
  14. % infinity
  15. limit(-1/x,x,0);
  16. - infinity
  17. % - infinity
  18. limit((sin(x)-x)/x^3,x,0);
  19. - 1
  20. ------
  21. 6
  22. % -1/6
  23. limit(x*sin(1/x),x,infinity);
  24. 1
  25. % 1
  26. limit(sin x/x^2,x,0);
  27. infinity
  28. % infinity
  29. limit(x^2*sin(1/x),x,infinity);
  30. infinity
  31. % infinity
  32. % Simple examples from Schaum's Theory & Problems of Advanced Calculus
  33. limit(x^2-6x+4,x,2);
  34. -4
  35. % -4
  36. limit((x+3)*(2x-1)/(x^2+3x-2),x,-1);
  37. 3
  38. ---
  39. 2
  40. % 3/2
  41. limit((sqrt(4+h)-2)/h,h,0);
  42. 1
  43. ---
  44. 4
  45. % 1/4
  46. limit((sqrt(x)-2)/(4-x),x,4);
  47. - 1
  48. ------
  49. 4
  50. % -1/4
  51. limit((x^2-4)/(x-2),x,2);
  52. 4
  53. % 4
  54. limit(1/(2x-5),x,-1);
  55. - 1
  56. ------
  57. 7
  58. % -1/7
  59. limit(sqrt(x)/(x+1),x,1);
  60. 1
  61. ---
  62. 2
  63. % 1/2
  64. limit((2x+5)/(3x-2),x,infinity);
  65. 2
  66. ---
  67. 3
  68. % 2/3
  69. limit((1/(x+3)-2/(3x+5))/(x-1),x,1);
  70. 1
  71. ----
  72. 32
  73. % 1/32
  74. limit(sin(3x)/x,x,0);
  75. 3
  76. % 3
  77. limit((1-cos(x))/x^2,x,0);
  78. 1
  79. ---
  80. 2
  81. % 1/2
  82. limit((6x-sin(2x))/(2x+3*sin(4x)),x,0);
  83. 2
  84. ---
  85. 7
  86. % 2/7
  87. limit((1-2*cos(x)+cos(2x))/x^2,x,0);
  88. -1
  89. % -1
  90. limit((3*sin(pi*x) - sin(3*pi*x))/x^3,x,0);
  91. 3
  92. 4*pi
  93. % 4*pi^3
  94. limit((cos(a*x)-cos(b*x))/x^2,x,0);
  95. 2 2
  96. - a + b
  97. ------------
  98. 2
  99. % (-a^2 + b^2)/2
  100. limit((e^x-1)/x,x,0);
  101. 1
  102. % 1
  103. limit((a^x-b^x)/x,x,0);
  104. log(a) - log(b)
  105. % log(a) - log(b)
  106. % Examples taken from Hyslop's Real Variable
  107. limit(sinh(2x)^2/log(1+x^2),x,0);
  108. 4
  109. % 4
  110. limit(x^2*(e^(1/x)-1)*(log(x+2)-log(x)),x,infinity);
  111. 2
  112. % 2
  113. limit(x^alpha*log(x+1)^2/log(x),x,infinity);
  114. 2
  115. alpha log(x + 1)
  116. limit(x *-------------,x,infinity)
  117. log(x)
  118. %% if repart alpha < 0 then 0 else infinity.
  119. %% fails because answer depends in essential way on parameter.
  120. limit((2*cosh(x)-2-x^2)/log(1+x^2)^2,x,0);
  121. 1
  122. ----
  123. 12
  124. % 1/12
  125. limit((x*sinh(x)-2+2*cosh(x))/(x^4+2*x^2),x,0);
  126. 1
  127. % 1
  128. limit((2*sinh(x)-tanh(x))/(e^x-1),x,0);
  129. 1
  130. % 1
  131. limit(x*tanh(x)/(sqrt(1-x^2)-1),x,0);
  132. -2
  133. % -2
  134. limit((2*log(1+x)+x^2-2*x)/x^3,x,0);
  135. 2
  136. ---
  137. 3
  138. % 2/3
  139. limit((e^(5*x)-2*x)^(1/x),x,0);
  140. 3
  141. e
  142. % e^3
  143. limit(log(log(x))/log(x)^2,x,infinity);
  144. 0
  145. % 0
  146. % These are adapted from Lession 4 from Stoutmyer
  147. limit((e^x-1)/x, x, 0);
  148. 1
  149. % 1
  150. limit(((1-x)/log(x))**2, x, 1);
  151. 1
  152. % 1
  153. limit(x/(e**x-1), x, 0);
  154. 1
  155. % 1
  156. %% One sided limits
  157. limit!+(sin(x)/sqrt(x),x,0);
  158. 0
  159. % 0
  160. limit!-(sin(x)/sqrt(x),x,0);
  161. 0
  162. % 0
  163. limit(x/log x,x,0);
  164. 0
  165. % 0
  166. limit(log(1 + x)/log x,x,infinity);
  167. 1
  168. % 1
  169. limit(log x/sqrt x,x,infinity);
  170. 0
  171. % 0
  172. limit!+(sqrt x/sin x,x,0);
  173. infinity
  174. % infinity
  175. limit(log x,x,0);
  176. - infinity
  177. % - infinity
  178. limit(x*log x,x,0);
  179. 0
  180. % 0
  181. limit(log x/log(2x),x,0);
  182. 1
  183. % 1
  184. limit(log x*log(1+x)*(1+x),x,0);
  185. 0
  186. % 0
  187. limit(log x/x,x,infinity);
  188. 0
  189. % 0
  190. limit(log x/sqrt x,x,infinity);
  191. 0
  192. % 0
  193. limit(log x,x,infinity);
  194. infinity
  195. % infinity
  196. limit(log(x+1)/sin x,x,0);
  197. 1
  198. % 1
  199. limit(log(1+1/x)*sin x,x,0);
  200. 0
  201. % 0
  202. limit(-log(1+x)*(x+2)/sin x,x,0);
  203. -2
  204. % -2
  205. limit(-log x*(3+x)/log(2x),x,0);
  206. -3
  207. % -3
  208. limit(log(x+1)^2/sqrt x,x,infinity);
  209. 0
  210. % 0
  211. limit(log(x + 1) - log x,x,infinity);
  212. 0
  213. % 0
  214. limit(-(log x)^2/log log x,x,infinity);
  215. - infinity
  216. % - infinity
  217. limit(log(x-1)/sin x,x,0);
  218. sign(log(-1))*infinity
  219. % infinity
  220. limit!-(sqrt x/sin x,x,0);
  221. - sign(i)*infinity
  222. % infinity
  223. limit(log x-log(2x),x,0);
  224. - log(2)
  225. % - log(2)
  226. limit(sqrt x-sqrt(x+1),x,infinity);
  227. 0
  228. % 0
  229. limit(sin sin x/x,x,0);
  230. 1
  231. % 1
  232. limit!-(sin x/cos x,x,pi/2);
  233. infinity
  234. % infinity % this works!
  235. limit!+(sin x/cos x,x,pi/2);
  236. - infinity
  237. % - infinity % so does this!
  238. limit(sin x/cosh x,x,infinity);
  239. 0
  240. % 0
  241. limit(sin x/x,x,infinity);
  242. 0
  243. % 0
  244. limit(x*sin(1/x),x,0);
  245. 0
  246. % 0
  247. limit(exp x/((exp x + exp(-x))/2),x,infinity);
  248. 2
  249. % 2
  250. % limit(exp x/cosh x,x,infinity); % fails in this form, but if cosh is
  251. %defined using let, then it works.
  252. limit((sin(x^2)/(x*sinh x)),x,0);
  253. 1
  254. % 1
  255. limit(log x*sin(x^2)/(x*sinh x),x,0);
  256. - infinity
  257. % - infinity
  258. limit(sin(x^2)/(x*sinh x*log x),x,0);
  259. 0
  260. % 0
  261. limit(log x/log(x^2),x,0);
  262. 1
  263. ---
  264. 2
  265. % 1/2
  266. limit(log(x^2)-log(x^2+8x),x,0);
  267. - infinity
  268. % - infinity
  269. limit(log(x^2)-log(x^2+8x),x,infinity);
  270. 0
  271. % 0
  272. limit(sqrt(x+5)-sqrt x,x,infinity);
  273. 0
  274. % 0
  275. limit(2^(log x),x,0);
  276. 0
  277. % 0
  278. % Additional examples
  279. limit((sin tan x-tan sin x)/(asin atan x-atan asin x),x,0);
  280. 1
  281. % 1
  282. % This one has the value infinity, but fails with de L'Hospital's rule:
  283. limit((e+1)^(x^2)/e^x,x,infinity);
  284. 2
  285. x
  286. (e + 1)
  287. limit(-----------,x,infinity)
  288. x
  289. e
  290. % infinity % fails
  291. comment
  292. The following examples were not in the previous set$
  293. % Simon test examples:
  294. limit(log(x-a)/((a-b)*(a-c)) + log(2(x-b))/((b-c)*(b-a))
  295. + log(x-c)/((c-a)*(c-b)),x,infinity);
  296. - log(2)
  297. ----------------------
  298. 2
  299. a*b - a*c - b + b*c
  300. % log(1/2)/((a-b)*(b-c))
  301. limit(1/(e^x-e^(x-1/x^2)),x,infinity);
  302. 1
  303. limit(----------------,x,infinity)
  304. 2
  305. x x - 1/x
  306. e - e
  307. % infinity % fails
  308. % new capabilities: branch points at the origin, needed for definite
  309. % integration.
  310. limit(x+sqrt x,x,0);
  311. 0
  312. % 0
  313. limit!+(sqrt x/(x+1),x,0);
  314. 0
  315. % 0
  316. limit!+(x^(1/3)/(x+1),x,0);
  317. 0
  318. % 0
  319. limit(log(x)^2/x^(1/3),x,0);
  320. infinity
  321. % infinity
  322. limit(log x/x^(1/3),x,0);
  323. - infinity
  324. % - infinity
  325. h := (X^(1/3) + 3*X**(1/4))/(7*(SQRT(X + 9) - 3)**(1/4));
  326. 1/4 1/3
  327. 3*x + x
  328. h := ------------------------
  329. 1/4
  330. 7*(sqrt(x + 9) - 3)
  331. limit(h,x,0);
  332. 1/4
  333. 3*6
  334. --------
  335. 7
  336. % 3/7*6^(1/4)
  337. % Examples from Paul S. Wang's thesis:
  338. limit(x^log(1/x),x,infinity);
  339. 0
  340. % 0
  341. limit(cos x - 1/(e^x^2 - 1),x,0);
  342. - infinity
  343. % - infinity
  344. limit((1+a*x)^(1/x),x,infinity);
  345. 1
  346. % 1
  347. limit(x^2*sqrt(4*x^4+5)-2*x^4,x,infinity);
  348. 5
  349. ---
  350. 4
  351. % 5/4
  352. limit!+(1/x-1/sin x,x,0);
  353. 0
  354. % 0
  355. limit(e^(x*sqrt(x^2+1))-e^(x^2),x,infinity);
  356. 2 2
  357. x*sqrt(x + 1) x
  358. limit(e - e ,x,infinity)
  359. % 0 fails
  360. limit((e^x+x*log x)/(log(x^4+x+1)+e^sqrt(x^3+1)),x,infinity);
  361. x
  362. e + x*log(x)
  363. limit(---------------------------------,x,infinity)
  364. 3
  365. 4 sqrt(x + 1)
  366. log(x + x + 1) + e
  367. %0 % fails
  368. limit!-(1/(x^3-6*x+11*x-6),x,2);
  369. 1
  370. ----
  371. 12
  372. % 1/12
  373. limit((x*sqrt(x+5))/(sqrt(4*x^3+1)+x),x,infinity);
  374. 1
  375. ---
  376. 2
  377. % 1/2
  378. limit!-(tan x/log cos x,x,pi/2);
  379. - infinity
  380. % - infinity
  381. z0 := z*(z-2*pi*i)*(z-pi*i/2)/(sinh z - i);
  382. 2 2
  383. z*( - 5*i*pi*z - 2*pi + 2*z )
  384. z0 := --------------------------------
  385. 2*(sinh(z) - i)
  386. limit(df(z0,z),z,pi*i/2);
  387. sign(i)*infinity
  388. % infinity
  389. z1 := z0*(z-pi*i/2);
  390. 3 2 2 3
  391. z*(2*i*pi - 12*i*pi*z - 9*pi *z + 4*z )
  392. z1 := -------------------------------------------
  393. 4*(sinh(z) - i)
  394. limit(df(z1,z),z,pi*i/2);
  395. - 2*pi
  396. % -2*pi
  397. % and the analogous problem:
  398. z2 := z*(z-2*pi)*(z-pi/2)/(sin z - 1);
  399. 2 2
  400. z*(2*pi - 5*pi*z + 2*z )
  401. z2 := ---------------------------
  402. 2*(sin(z) - 1)
  403. limit(df(z2,z),z,pi/2);
  404. - infinity
  405. % infinity
  406. z3 := z2*(z-pi/2);
  407. 3 2 2 3
  408. z*( - 2*pi + 9*pi *z - 12*pi*z + 4*z )
  409. z3 := ------------------------------------------
  410. 4*(sin(z) - 1)
  411. limit(df(z3,z),z,pi/2);
  412. 2*pi
  413. % 2*pi
  414. % A test by Wolfram Koepf.
  415. f:=x^2/(3*(-27*x^2 - 2*x^3 + 3^(3/2)*(27*x^4 + 4*x^5)^(1/2))^(1/3));
  416. 2
  417. x
  418. f := --------------------------------------------------------
  419. 2 3 2 1/3
  420. 3*(3*sqrt(4*x + 27)*sqrt(3)*abs(x) - 2*x - 27*x )
  421. L0:=limit(f,x,0);
  422. l0 := 0
  423. % L0 := 0
  424. f1:=((f-L0)/x^(1/3))$
  425. L1:=limit(f1,x,0);
  426. l1 := 0
  427. % L1 := 0
  428. f2:=((f1-L1)/x^(1/3))$
  429. L2:=limit(f2,x,0);
  430. - 1
  431. l2 := ------
  432. 1/3
  433. 2
  434. % L2 := -1/2^(1/3)
  435. f3:=((f2-L2)/x^(1/3))$
  436. L3:=limit(f3,x,0);
  437. l3 := 0
  438. % L3 := 0
  439. f4:=((f3-L3)/x^(1/3))$
  440. L4:=limit(f4,x,0);
  441. l4 := 0
  442. % L4 := 0
  443. f5:=((f4-L4)/x^(1/3))$
  444. L5:=limit(f5,x,0);
  445. 2/3
  446. - 2
  447. l5 := ---------
  448. 81
  449. % L5 = -2^(2/3)/81
  450. f6:=((f5-L5)/x^(1/3))$
  451. L6:=limit(f6,x,0);
  452. l6 := 0
  453. % L6 := 0
  454. f7:=((f6-L6)/x^(1/3))$
  455. L7:=limit(f7,x,0);
  456. l7 := 0
  457. % L7 := 0
  458. f8:=((f7-L7)/x^(1/3))$
  459. L8:=limit(f8,x,0);
  460. 7
  461. l8 := -----------
  462. 1/3
  463. 6561*2
  464. % L8 := 7/(6561*2^(1/3))
  465. limit(log(1+x)^2/x^(1/3),x,infinity);
  466. 0
  467. % 0
  468. limit(e^(log(1+x)^2/x^(1/3)),x,infinity);
  469. 1
  470. % 1
  471. ss := (sqrt(x^(2/5) +1) - x^(1/3)-1)/x^(1/3);
  472. 2/5 1/3
  473. sqrt(x + 1) - x - 1
  474. ss := ---------------------------
  475. 1/3
  476. x
  477. limit(ss,x,0);
  478. -1
  479. % -1
  480. limit(exp(ss),x,0);
  481. 1
  482. ---
  483. e
  484. % 1/e
  485. limit(log x,x,-1);
  486. log(-1)
  487. % log(-1)
  488. limit(log(ss),x,0);
  489. log(-1)
  490. % log(-1)
  491. ss := ((x^(1/2) - 1)^(1/3) + (x^(1/5) + 1)^2)/x^(1/5);
  492. 1/3 2/5 1/5
  493. (sqrt(x) - 1) + x + 2*x + 1
  494. ss := --------------------------------------
  495. 1/5
  496. x
  497. limit(ss,x,0);
  498. 2
  499. % 2
  500. h := (X^(1/5) + 3*X**(1/4))^2/(7*(SQRT(X + 9) - 3 - x/6))**(1/5);
  501. 1/5 9/20 2/5
  502. 6 *(6*x + x + 9*sqrt(x))
  503. h := -----------------------------------
  504. 1/5 1/5
  505. (6*sqrt(x + 9) - x - 18) *7
  506. limit(h,x,0);
  507. 3/5
  508. - 6
  509. ---------
  510. 1/5
  511. 7
  512. % -6^(3/5)/7^(1/5)
  513. end;
  514. Time for test: 1470 ms, plus GC time: 20 ms