complx.red 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. module complx;
  2. % Wed Dec. 17, 1986 by F. Kako;
  3. %********************************************************************;
  4. %******************************************************************
  5. %******* SPLIT REAL AND IMAGINARY PART ******************
  6. %******************************************************************
  7. symbolic procedure real!-imag!-sq u;
  8. %U is a standard quotient,
  9. %Value is the standard quotient real part and imaginary part of U.
  10. begin scalar x,y;
  11. x := real!-imag!-f numr u;
  12. y := real!-imag!-f denr u;
  13. u := addf(multf(car y, car y),
  14. multf(cdr y, cdr y)); % Re Y **2 + Im Y **2;
  15. return (cancel(addf(multf(car x, car y),
  16. multf(cdr x, cdr y))
  17. ./ u) .
  18. cancel(addf(multf(car y, cdr x),
  19. negf multf(car x, cdr y))
  20. ./ u))
  21. end;
  22. symbolic procedure real!-imag!-f u;
  23. %U is a standard form.
  24. %Value is the standard form real and imag part of U.
  25. begin scalar x;
  26. if domainp u then return u . nil;
  27. x := setkorder list 'i;
  28. u := reorder u;
  29. u := if mvar u eq 'i and ldeg u = 1 then red u . lc u
  30. else u . nil;
  31. setkorder x;
  32. return (reorder car u . reorder cdr u)
  33. end;
  34. %*****************************************************************
  35. % hyperbolic functions
  36. %*****************************************************************;
  37. symbolic procedure real!-imag!-sincos u;
  38. begin scalar v,w,z;
  39. v := real!-imag!-sq u;
  40. if null cadr v then <<
  41. u := prepsq u;
  42. return simp!* list('sinh,u)
  43. . simp!* list('cosh,u)>>
  44. else if null caar v then <<
  45. u := prepsq cdr v;
  46. return (multsq(!*k2q 'i, simp!* list('sin,u))
  47. . simp!* list('cos,u))>>;
  48. u := prepsq cdr v;
  49. v := prepsq car v;
  50. w := simp!* list('cos,u);
  51. u := simp!* list('sin,u);
  52. u := multsq(!*k2q 'i,u);
  53. z := simp!* list('cosh,v);
  54. v := simp!* list('sinh,v);
  55. return (addsq (multsq(w, v), multsq(u,z)))
  56. . (addsq (multsq(w,z),multsq(u,v)))
  57. end;
  58. % xxxxxxxxxxxxxxxxxxxxxxxx
  59. %*********************************************************************
  60. % log and exponential term splitting for summation and product
  61. %********************************************************************;
  62. symbolic procedure sum!-split!-log(u,v);
  63. begin scalar x,y,z,lst,llst,mlst;
  64. lst := sum!-term!-split(u,v);
  65. a:
  66. if null lst then return (llst. mlst);
  67. u := car lst;
  68. lst := cdr lst;
  69. z := numr u;
  70. if domainp z or red z or not (tdeg (z := lt z) = 1) or
  71. atom tvar z or not ((car tvar z) eq 'log)
  72. or depend!-f(tc z,v) or depend!-f(denr u,v)
  73. then <<mlst := u . mlst;go to a>>;
  74. y := reorder tc z ./ reorder denr u;
  75. z := simp!* cadr tvar z;
  76. if x := assoc(y,llst) then rplacd(x,multsq(cdr x,z))
  77. else if x := assoc(negsq y,llst)
  78. then rplacd(x,multsq(cdr x,invsq z))
  79. else llst := (y . z) . llst;
  80. go to a
  81. end;
  82. symbolic procedure prod!-split!-exp(u,v);
  83. begin scalar x,y,z,w,klst,lst;
  84. % lst := kernels(numr u,nil);
  85. lst := kernels numr u;
  86. % lst := kernels1denr u,lst);
  87. lst := kernels1(denr u,lst);
  88. a:
  89. if null lst then go to b;
  90. z := car lst;
  91. if not atom z and car z eq 'expt and
  92. not depend!-p(cadr z,v) and depend!-p(caddr z,v)
  93. then klst := z . klst;
  94. lst := cdr lst;
  95. go to a;
  96. b:
  97. if null klst then return (nil . list u);
  98. x := setkorder klst;
  99. z := reorder numr u;
  100. y := reorder denr u;
  101. c:
  102. if domainp z or red z or not memq(w := mvar z,klst)
  103. then go to d;
  104. v := multsq(tdeg lt z ./ 1,simp!* caddr w);
  105. w := cadr w;
  106. if u := assoc(w,lst) then rplacd(u,addsq(cdr u,v))
  107. else lst := (w . v) . lst;
  108. z := tc lt z;
  109. go to c;
  110. d:
  111. if domainp y or red y or not memq(w := mvar y,klst)
  112. then go to e;
  113. v := multsq(tdeg lt y ./ 1,negsq simp!* caddr w);
  114. w := cadr w;
  115. if u := assoc(w,lst) then rplacd(u,addsq(cdr u,v))
  116. else lst := (w . v) . lst;
  117. y := tc lt y;
  118. go to d;
  119. e:
  120. setkorder x;
  121. u := reorder z ./ reorder y;
  122. return (lst . list u)
  123. end;
  124. endmodule;
  125. end;