specplot.tst 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. % Test file for plots of special functions.
  2. % Kerry Gaskell, Konrad-Zuse-Zentrum Berlin, 1993.
  3. % This file runs with ON DEMO;
  4. load_package gnuplot;
  5. load_package specfn;
  6. on demo;
  7. %Mathematica - page 112
  8. plot(sin(x^2),title="sin(x^2)");
  9. plot(sin(1/x),x=(-1 .. 1),title="sin(1/x)");
  10. %Mathematica - page 112
  11. plot(sin(x^2),x=(0 ..3),title="sin(x^2)");
  12. plot(cos(1/x),x=(-1 .. 1),title="cos(1/x)");
  13. plot(cos(x^2),title="cos(x^2)");
  14. plot(cos(x^2),x=(-3 .. 3),title="cos(x^2)");
  15. %Handbook of Mathematical Functions - page 778
  16. plot(chebyshevt(1,x),chebyshevt(2,x),chebyshevt(3,x),chebyshevt(4,x),
  17. chebyshevt(5,x),x=(-1 .. 1),title="Chebyshev t Polynomials");
  18. %Handbook of Mathematical Functions - page 779
  19. plot(chebyshevu(1,x),chebyshevu(2,x),chebyshevu(3,x),chebyshevu(4,x),
  20. chebyshevu(5,x),x=(-1 .. 1),y=(-6 .. 6),
  21. title="Chebyshev u Polynomials");
  22. %Handbook of Mathematical Functions - page 776
  23. plot(gegenbauerp(2,1/2,x),gegenbauerp(3,1/2,x),gegenbauerp(4,1/2,x),
  24. gegenbauerp(5,1/2,x),x=(-1 .. 1),y=(-1 .. 1),
  25. title="Gegenbauer Polynomials");
  26. %Handbook of Mathematical Functions - page 777
  27. plot(gegenbauerp(5,0.2,x),gegenbauerp(5,0.4,x),gegenbauerp(5,0.6,x),
  28. gegenbauerp(5,0.8,x),gegenbauerp(5,1,x),x=(-1 .. 1),y=(-1.5 .. 1.5),
  29. title="Gegenbauer Polynomials");
  30. %Handbook of Mathematical Functions - page 780
  31. plot(laguerrep(2,x),laguerrep(3,x),laguerrep(4,x),laguerrep(5,x),
  32. x=(0 .. 6),y=(-2 .. 4),title="Laguerre Polynomials");
  33. %Handbook of Mathematical Functions - page 780
  34. plot(legendrep(2,x),legendrep(3,x),legendrep(4,x),legendrep(5,x),
  35. x=(-1 .. 1),y=(-1 .. 1),title="Legendre Polynomials");
  36. %Handbook of Mathematical Functions - page 496
  37. plot(struveh(0,x),struveh(1,x),struveh(2,x),struveh(3,x),
  38. x=(0 .. 12),y=(-0.5 .. 2),title="Struve Functions");
  39. %Handbook of Mathematical Functions - page 496
  40. plot(struveh(-1,x),struveh(-2,x),struveh(-3,x),
  41. x=(0 .. 16),y=(-1 .. 1),title="Struve Functions");
  42. %Handbook of Mathematical Functions - page 776
  43. plot(jacobip(5,1.5,0,x),jacobip(5,1.5,-0.2,x),jacobip(5,1.5,-0.4,x),
  44. jacobip(5,1.5,-0.6,x),jacobip(5,1.5,-0.8,x),x=(-1 .. 1),
  45. y=(-1.5 .. 1.5),title="Jacobi Polynomials");
  46. %Handbook of Mathematical Functions - page 776
  47. plot(jacobip(5,1.0,-0.5,x),jacobip(5,1.2,-0.5,x),jacobip(5,1.4,-0.5,x),
  48. jacobip(5,1.6,-0.5,x),jacobip(5,1.8,-0.5,x),jacobip(5,2.0,-0.5,x),
  49. x=(-1 .. 1),y=(-1.5 .. 1.5),title="Jacobi Polynomials");
  50. %Handbook of Mathematical Functions - page 773
  51. plot(jacobip(1,1.5,-0.5,x),jacobip(2,1.5,-0.5,x),jacobip(3,1.5,-0.5,x),
  52. jacobip(4,1.5,-0.5,x),jacobip(5,1.5,-0.5,x),x=(-1 .. 1),
  53. y=(-1.5 .. 3),title="Jacobi Polynomials");
  54. %Handbook of Mathematical Functions - page 780
  55. <<
  56. algebraic procedure hermite_base(x,n);
  57. hermite_base1(x,n,{2*x,1},1);
  58. plot(hermitep(2,x)/8,hermitep(3,x)/27,hermitep(4,x)/64,
  59. hermitep(5,x)/125,x=(0 .. 4),y=(-2 .. 8),
  60. title="Hermite Polynomials/n^3");
  61. >>;
  62. %Mathematica - page 115
  63. plot(besselj(0,x),besselj(1,x),besselj(2,x),besselj(4,x),x=(0 .. 10),
  64. y=(-2 .. 2),title="Bessel functions of 1st kind");
  65. %Handbook of Mathematical Functions - page 359
  66. plot(bessely(0,x),bessely(1,x),bessely(2,x),x=(0.1 .. 10),y=(-1 .. 1),
  67. title="Bessel functions of 2nd kind");
  68. %bessely(2,x),bessely(4,x)
  69. plot(besseli(0,x),besseli(1,x),besseli(2,x),x=(-4 .. 4),y=(-10 .. 15),
  70. title="Bessel functions of 3rd kind");
  71. %Evolutionstheorie und dynamische Systeme - page 93
  72. %A function to calculate a given number of consecutive points on a
  73. %curve when given a small value h and then to plot the curve.
  74. on comp;
  75. <<
  76. symbolic procedure vera(h,x,y,n);
  77. begin scalar result_i, old, lst;
  78. lst := {{'list,x,y}};
  79. lst := append(lst,{result_i := bambam(0,x,y)});
  80. lst := append(lst,
  81. for i:= 2 :n collect
  82. <<result_i:= rest result_i;
  83. old := result_i;
  84. result_i :=
  85. bambam(h,first(result_i),second(result_i));
  86. result_i
  87. >>);
  88. return ('list . lst);
  89. end;
  90. symbolic operator vera;
  91. symbolic procedure bambam(h,x,y);
  92. begin scalar result_x, result_y, temp, new_x, new_y;
  93. temp := frank(h,x,y);
  94. new_x := car temp;
  95. new_y := cadr temp;
  96. result_x := x+h*new_x;
  97. result_y := y+h*new_y;
  98. return {'list,result_x,result_y};
  99. end;
  100. symbolic procedure frank(h,x,y),
  101. begin scalar result, temp, temp2, new_x, new_y;
  102. temp := bob(x,y);
  103. new_x :=x + h*car temp;
  104. new_y :=y + h*cadr temp;
  105. temp2 :=bob(new_x,new_y);
  106. result := {(car temp+car temp2)*0.5,
  107. (cadr temp+cadr temp2)*0.5};
  108. return result;
  109. end;
  110. % A function to calculate the values of dx/dt and dy/dt from given
  111. %equations.
  112. symbolic procedure bob(x,y);
  113. begin scalar result_x, result_y;
  114. if numberp x and numberp y
  115. then <<result_x := x*((1+x)*(3-x)-y);
  116. result_y := y*(x-2)>>
  117. else << printlist ("Try again with numbers next time!") >>;
  118. return {result_x,result_y};
  119. end;
  120. plot({symbolic vera(0.02,6,1,30),symbolic vera(0.03,6,3,80),
  121. symbolic vera(0.03,6,5,75), symbolic vera(0.03,0.5,7,160)},
  122. title="dx/dt=x((1+x)(3-x)-y), dy/dt=y(x-2)");
  123. >>;
  124. <<
  125. %Evolutionstheorie und dynamische Systeme - page 92
  126. %A function to calculate a given number of consecutive points on a
  127. %curve when given a small value h and then to plot the curve.
  128. symbolic procedure joan(h,x,y,n);
  129. begin scalar result_i, old, lst;
  130. lst := {{'list,x,y}};
  131. lst := append(lst,{result_i := pebbles(0,x,y)});
  132. lst := append(lst,
  133. for i:= 2 :n collect
  134. <<result_i:= rest result_i;
  135. old := result_i;
  136. result_i := pebbles(h,first(result_i),second(result_i));
  137. result_i
  138. >>);
  139. return ('list . lst);
  140. end;
  141. symbolic operator joan;
  142. symbolic procedure pebbles(h,x,y);
  143. begin scalar result_x, result_y, temp, new_x, new_y;
  144. temp := wilma(x,y);
  145. new_x := car temp;
  146. new_y := cadr temp;
  147. result_x := x+h*new_x;
  148. result_y := y+h*new_y;;
  149. return {'list,result_x,result_y};
  150. end;
  151. % A function to calculate the values of dx/dt and dy/dt from given
  152. %equations.
  153. symbolic procedure wilma(x,y);
  154. begin scalar result_x, result_y;
  155. if numberp x and numberp y
  156. then <<result_x := x*((1+x)*(3-x)-y);
  157. result_y := y*(x-4)>>
  158. else << printlist ("Try again with numbers next time!") >>;
  159. return {result_x,result_y};
  160. end;
  161. plot({symbolic joan(0.02,6,1,75),symbolic joan(0.02,6,3,65),
  162. symbolic joan(0.02,6,5,65),symbolic joan(0.02,4,7,65),
  163. symbolic joan(0.02,1.5,7,55),symbolic joan(0.02,0.5,7,100)},
  164. title="dx/dt=x((1+x)(3-x)-y), dy/dt=y(x-4)");
  165. >>;
  166. <<
  167. %Evolutionstheorie und dynamische Systeme - page 83
  168. %A function to calculate a given number of consecutive points on a
  169. %curve when given a small value h and then to plot the curve.
  170. symbolic procedure betty(h,x,y,n);
  171. begin scalar result_i, old, lst;
  172. lst := {{'list,x,y}};
  173. lst := append(lst,{result_i := barney(0,x,y)});
  174. lst := append(lst,
  175. for i:= 2 :n collect
  176. <<result_i:= rest result_i;
  177. old := result_i;
  178. result_i :=
  179. barney(h,first(result_i),second(result_i));
  180. result_i
  181. >>);
  182. return ('list . lst);
  183. end;
  184. symbolic operator betty;
  185. symbolic procedure barney(h,x,y);
  186. begin scalar result_x, result_y, temp, new_x, new_y;
  187. temp := fred(x,y);
  188. new_x := car temp;
  189. new_y := cadr temp;
  190. result_x := x+h*new_x;
  191. result_y := y+h*new_y;
  192. return {'list,result_x,result_y};
  193. end;
  194. % A function to calculate the values of dx/dt and dy/dt from given
  195. %equations.
  196. symbolic procedure fred(x,y);
  197. begin scalar result_x, result_y;
  198. if numberp x and numberp y
  199. then <<result_x := x-y-x*(x^2+y^2);
  200. result_y := x+y-y*(x^2+y^2)>>
  201. else << printlist ("Try again with numbers next time!") >>;
  202. return {result_x,result_y};
  203. end;
  204. plot({symbolic betty(0.05,-2,0,25),symbolic betty(0.05,1,-2,25),
  205. symbolic betty(0.05,1.25,1.75,25),symbolic betty(0.1,0.01,0.01,65),
  206. symbolic betty(0.1,-0.01,0.005,65),symbolic betty(0.1,0.005,-0.01,65),
  207. symbolic betty(0.1,0,1,65)},
  208. title="dx/dt=x-y-x(x^2+y^2), dy/dt=x+y-y(x^2+y^2)");
  209. >>;
  210. plot(repart(lambert_w(x)));
  211. plot(Jacobisn(u,1/2),Jacobicn(u,1/2),Jacobidn(u,1/2), u=(0 .. 4*EllipticK
  212. (1/2)), y = (-1 .. 1),title="sn , cn and dn for m=1/2");
  213. plot(Jacobins(u,1/2),Jacobinc(u,1/2),Jacobind(u,1/2), u=(0 .. 4*EllipticK
  214. (1/2)), y = (-2 .. 2.5),title="ns , nc and nd for m=1/2");
  215. plot(Jacobics(u,1/2),Jacobisc(u,1/2),Jacobicd(u,1/2), Jacobidc(u,1/2), u=
  216. (0 .. 4*EllipticK(1/2)),y = (-1.5 .. 1.5)
  217. ,title="cs, sc, cd and dc for m=1/2");
  218. end;