COMPLEX.LOG 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. REDUCE 3.6, 15-Jul-95, patched to 6 Mar 96 ...
  2. % Test of Complex Number mode in REDUCE.
  3. on complex;
  4. (31+i)/74;
  5. 31 + i
  6. --------
  7. 74
  8. ws/(b+1);
  9. 31 + i
  10. ------------
  11. 74*(b + 1)
  12. % this now comes out right!
  13. w:=(x+3*i)**2;
  14. 2
  15. w := x + 6*i*x - 9
  16. on gcd;
  17. (x**3-7*x**2+x-7)/(x**2+(3+i)*x+3*i);
  18. 2
  19. x - (7 + i)*x + 7*i
  20. ----------------------
  21. x + 3
  22. off gcd;
  23. sqrt(x**4+14*i*x**3-51*x**2-14*i*x+1);
  24. 2
  25. abs(x + 7*i*x - 1)
  26. % All rounded tests are done twice: first, they are done at the default
  27. % precision, in which all rounded operations use standard floating point
  28. % logic. Then precision is increased, causing all rounded operations to
  29. % use extended precision bigfloat arithmetic. This is necessary to
  30. % exercise and test the bigfloat-based arithmetic functions.
  31. prec0 := precision 0;
  32. prec0 := 12
  33. % to determine the nominal default precision.
  34. % Tests using default precision:
  35. on rounded;
  36. *** Domain mode complex changed to complex-rounded
  37. (3.25 + 8.5i) + (6.75 - 8.5i);
  38. 10.0
  39. (3.25 + 8.5i) - (6.0 - 9.5i);
  40. - 2.75 + 18.0*i
  41. (1.0 + 10.0*i)*(-6.5 + 2.5*i);
  42. - 31.5 - 62.5*i
  43. (1.2 - 3.4*i)*(-5.6 + 7.8*i);
  44. 19.8 + 28.4*i
  45. (19.8 + 28.4*i)/(-5.6 + 7.8*i);
  46. 1.2 - 3.4*i
  47. e;
  48. 2.71828182846
  49. pi;
  50. 3.14159265359
  51. 17*i**2;
  52. -17
  53. (-7.0 + 24.0*i)**(1/2);
  54. 3.0 + 4.0*i
  55. sqrt(-7.0 + 24.0*i);
  56. 3.0 + 4.0*i
  57. sqrt(-10.12 - 8.16*i);
  58. 1.2 - 3.4*i
  59. sin(0.0 + 0.0*i);
  60. 0
  61. sin(1.0 + 0.0*i);
  62. 0.841470984808
  63. sin(1.0 + 1.0*i);
  64. 1.29845758142 + 0.634963914785*i
  65. cos(0.0 + 0.0*i);
  66. 1
  67. cos(1.0 - 0.0*i);
  68. 0.540302305868
  69. cos(1.0 + 1.0*i);
  70. 0.833730025131 - 0.988897705763*i
  71. tan(0.0 + 0.0*i);
  72. 0
  73. tan(1.0 + 0.0*i);
  74. 1.55740772465
  75. tan(1.0 + 1.0*i);
  76. 0.27175258532 + 1.08392332734*i
  77. asin(1.0 + 1.0*i);
  78. 0.666239432493 + 1.06127506191*i
  79. acos(1.0 + 1.0*i);
  80. 0.904556894302 - 1.06127506191*i
  81. atan(1.0 + 1.0*i);
  82. 1.0172219679 + 0.402359478109*i
  83. log(1.0 + 1.0*i);
  84. 0.34657359028 + 0.785398163397*i
  85. asin 2;
  86. 1.57079632679 - 1.31695789692*i
  87. sin ws;
  88. 2.0 - 1.25983163303e-15*i
  89. acos 2;
  90. 1.31695789692*i
  91. cos ws;
  92. 2.0
  93. atan(1+i);
  94. 1.0172219679 + 0.402359478109*i
  95. tan ws;
  96. 1 + i
  97. log(2+i);
  98. 0.804718956217 + 0.463647609001*i
  99. exp ws;
  100. 2.0 + i
  101. e**(i*pi);
  102. - 1 + 1.22460635382e-16*i
  103. e**i;
  104. 0.540302305868 + 0.841470984808*i
  105. z := sqrt i;
  106. z := 0.707106781187 + 0.707106781187*i
  107. z**2;
  108. i
  109. off rounded;
  110. *** Domain mode complex-rounded changed to complex
  111. %-----------------end of normal floating point tests--------------------
  112. precision(prec0+6);
  113. 12
  114. % arbitrary precision increase -> bigfloat functions
  115. %----------------------start of bigfloat tests--------------------------
  116. on rounded;
  117. *** Domain mode complex changed to complex-rounded
  118. (3.25 + 8.5i) + (6.75 - 8.5i);
  119. 10.0
  120. (3.25 + 8.5i) - (6.0 - 9.5i);
  121. - 2.75 + 18.0*i
  122. (1.0 + 10.0*i)*(-6.5 + 2.5*i);
  123. - 31.5 - 62.5*i
  124. (1.2 - 3.4*i)*(-5.6 + 7.8*i);
  125. 19.8 + 28.4*i
  126. (19.8 + 28.4*i)/(-5.6 + 7.8*i);
  127. 1.2 - 3.4*i
  128. e;
  129. 2.71828182845904524
  130. pi;
  131. 3.14159265358979324
  132. 17*i**2;
  133. -17
  134. (-7.0 + 24.0*i)**(1/2);
  135. 3.0 + 4.0*i
  136. sqrt(-7.0 + 24.0*i);
  137. 3.0 + 4.0*i
  138. sqrt(-10.12 - 8.16*i);
  139. 1.2 - 3.4*i
  140. sin(0.0 + 0.0*i);
  141. 0
  142. sin(1.0 + 0.0*i);
  143. 0.841470984807896507
  144. sin(1.0 + 1.0*i);
  145. 1.29845758141597729 + 0.634963914784736108*i
  146. cos(0.0 + 0.0*i);
  147. 1
  148. cos(1.0 - 0.0*i);
  149. 0.540302305868139717
  150. cos(1.0 + 1.0*i);
  151. 0.833730025131149049 - 0.988897705762865096*i
  152. tan(0.0 + 0.0*i);
  153. 0
  154. tan(1.0 + 0.0*i);
  155. 1.55740772465490223
  156. tan(1.0 + 1.0*i);
  157. 0.271752585319511717 + 1.08392332733869454*i
  158. asin(1.0 + 1.0*i);
  159. 0.666239432492515255 + 1.06127506190503565*i
  160. acos(1.0 + 1.0*i);
  161. 0.904556894302381364 - 1.06127506190503565*i
  162. atan(1.0 + 1.0*i);
  163. 1.01722196789785137 + 0.402359478108525094*i
  164. log(1.0 + 1.0*i);
  165. 0.346573590279972655 + 0.78539816339744831*i
  166. asin 2;
  167. 1.57079632679489662 - 1.31695789692481671*i
  168. sin ws;
  169. 2.0
  170. acos 2;
  171. 1.31695789692481671*i
  172. cos ws;
  173. 2.0
  174. atan(1+i);
  175. 1.01722196789785137 + 0.402359478108525094*i
  176. tan ws;
  177. 1 + i
  178. log(2+i);
  179. 0.804718956217050187 + 0.463647609000806116*i
  180. exp ws;
  181. 2.0 + i
  182. e**(i*pi);
  183. - 1
  184. e**i;
  185. 0.540302305868139717 + 0.841470984807896507*i
  186. z := sqrt i;
  187. z := 0.707106781186547524 + 0.707106781186547524*i
  188. z**2;
  189. i
  190. off rounded;
  191. *** Domain mode complex-rounded changed to complex
  192. % ---------------------------------------------------------------------
  193. % The following examples are independent of precision.
  194. precision prec0;
  195. 18
  196. % restores default precision.
  197. % on rationalize; % no longer needed, since it doesn't affect complex.
  198. s:= 1.1+2.3i;
  199. 11 + 23*i
  200. s := -----------
  201. 10
  202. s/4;
  203. 11 + 23*i
  204. -----------
  205. 40
  206. % this would have had a common factor of 4.
  207. x:= a+1.1+2.3i;
  208. 10*a + 11 + 23*i
  209. x := ------------------
  210. 10
  211. y:= b+1.2+1.3i;
  212. 10*b + 12 + 13*i
  213. y := ------------------
  214. 10
  215. z:= x/y;
  216. 100*a*b + (120 - 130*i)*a + (110 + 230*i)*b + 431 + 133*i
  217. z := -----------------------------------------------------------
  218. 2
  219. 100*b + 240*b + 313
  220. z/4;
  221. 100*a*b + (120 - 130*i)*a + (110 + 230*i)*b + 431 + 133*i
  222. -----------------------------------------------------------
  223. 2
  224. 4*(100*b + 240*b + 313)
  225. % this would have had a common polynomial factor b^2 + ...
  226. z*7/4;
  227. 7*(100*a*b + (120 - 130*i)*a + (110 + 230*i)*b + 431 + 133*i)
  228. ---------------------------------------------------------------
  229. 2
  230. 4*(100*b + 240*b + 313)
  231. s/(c^2+c+1);
  232. 11 + 23*i
  233. -----------------
  234. 2
  235. 10*(c + c + 1)
  236. % this would have had a common factor of c^2+c+1
  237. clear x;
  238. zz:= x^2+(1.1+2.3i)*x+1.2+1.3i;
  239. 2
  240. 10*x + (11 + 23*i)*x + 12 + 13*i
  241. zz := -----------------------------------
  242. 10
  243. ss:=1.23456789x^2+1.3579i*x+5.6789;
  244. 2
  245. 123456789*x + 135790000*i*x + 567890000
  246. ss := ------------------------------------------
  247. 100000000
  248. % off rationalize; % not needed now.
  249. z:= x+1.1+2.3i;
  250. 10*x + 11 + 23*i
  251. z := ------------------
  252. 10
  253. on rationalize;
  254. z;
  255. 10*x + 11 + 23*i
  256. ------------------
  257. 10
  258. % same as previous answer.
  259. off rationalize;
  260. 1.23456789x^2+2.3456i*x+7.89;
  261. 2
  262. 123456789*x + 234560000*i*x + 789000000
  263. ------------------------------------------
  264. 100000000
  265. on factor;
  266. x**2+1;
  267. (x + i)*(x - i)
  268. x**4-1;
  269. (x + i)*(x - i)*(x + 1)*(x - 1)
  270. x**4+(i+2)*x**3+(2*i+5)*x**2+(2*i+6)*x+6;
  271. 2
  272. (x + i*x + 3)*(x + 1 + i)*(x + 1 - i)
  273. (2*i+3)*x**4+(3*i-2)*x**3-2*(i+1)*x**2+i*x-1;
  274. 2 2
  275. i*((2 - 3*i)*x - i)*(x + i*x - 1)
  276. % Multivariate examples:
  277. x**2+y**2;
  278. (10*b + 10*i*x + 12 + 13*i)*(10*b - 10*i*x + 12 + 13*i)
  279. ---------------------------------------------------------
  280. 100
  281. off factor;
  282. factorize(x**2+1);
  283. {x - i,x + i}
  284. end;
  285. (TIME: complex 810 850)