changevr.tex 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. \newcommand{\definedas}{\stackrel{\triangle}{=}}
  2. \newcommand{\spc}{\;\;\;\;\;}
  3. \newcommand{\mspc}{\;\;\;\;\;\;\;\;\;\;}
  4. \newcommand{\lspc}{\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;}
  5. \documentstyle[fleqn,11pt]{article}
  6. \renewcommand{\baselinestretch}{1.1}
  7. \newcommand{\eg}[1]{\begin{quote}{\tt #1} \end{quote}}
  8. \setlength{\textwidth}{15cm}
  9. \addtolength{\oddsidemargin}{-1cm}
  10. \title{ CHANGEVAR, \\
  11. A REDUCE Facility \\
  12. to \\
  13. Perform Change of Independent Variable(s)\\
  14. in \\
  15. Differential Equations\\[2cm]
  16. }
  17. \author{
  18. G. \"{U}\c{c}oluk
  19. \thanks{Email address: A07917 @ TRMETU.BITNET}
  20. \\
  21. Department of Physics \\
  22. Middle East Technical University \\
  23. Ankara, Turkey
  24. }
  25. \date{October 1989}
  26. \begin{document}
  27. \maketitle
  28. \newpage
  29. \section{Introduction}
  30. The mathematics behind the change of independent variable(s) in differential
  31. equations is quite straightforward. It is basically the application of the chain
  32. rule. If the dependent variable of the differential equation is $F$, the
  33. independent variables are $x_{i}$ and the new independent variables are
  34. $u_{i}$ (where ${\scriptstyle i=1\ldots n}$) then the first derivatives are:
  35. \[
  36. \frac{\partial F}{\partial x_{i}} = \frac{\partial F}{\partial u_{j}}
  37. \frac{\partial u_{j}}{\partial x_{i}}
  38. \]
  39. We assumed Einstein's summation convention. Here the problem is to
  40. calculate the $\partial u_{j}/\partial x_{i}$ terms if the change of variables
  41. is given by
  42. \[
  43. x_{i} = f_{i}(u_{1},\ldots,u_{n})
  44. \]
  45. The first thought might be solving the above given equations for $u_{j}$ and
  46. then differentiating them with respect to $x_{i}$, then again making use of the
  47. equations above, substituting new variables for the old ones in the calculated
  48. derivatives. This is not always a preferable way to proceed. Mainly because
  49. the functions $f_{i}$ may not always be easily invertible. Another approach
  50. that makes use of the Jacobian is better. Consider the above given equations
  51. which relate the old variables to the new ones. Let us differentiate them:
  52. \begin{eqnarray*}
  53. \frac{\partial x_{j}}{\partial x_{i}} & = &
  54. \frac{\partial f_{j}}{\partial x_{i}} \\
  55. \delta_{ij} & = &
  56. \frac{\partial f_{j}}{\partial u_{k}}
  57. \frac{\partial u_{k}}{\partial x_{i}}
  58. \end{eqnarray*}
  59. The first derivative is nothing but the $(j,k)$ th entry of the Jacobian matrix.
  60. So if we speak in matrix language
  61. \[ {\bf 1 = J \cdot D} \]
  62. where we defined the Jacobian
  63. \[ {\bf J}_{ij} \definedas \frac{\partial f_{i}}{\partial u_{j}} \]
  64. and the matrix of the derivatives we wanted to obtain as
  65. \[ {\bf D}_{ij} \definedas \frac{\partial u_{i}}{\partial x_{j}}. \]
  66. If the Jacobian has a non-vanishing determinant then it is invertible and
  67. we are able to write from the matrix equation above:
  68. \[ {\bf D = J^{-1}} \]
  69. so finally we have what we want
  70. \[
  71. \frac{\partial u_{i}}{\partial x_{j}} = \left[{\bf J^{-1}}\right]_{ij}
  72. \]
  73. The higher derivatives are obtained by the successive application of the chain
  74. rule and using the definitions of the old variables in terms of the new ones. It
  75. can be easily verified that the only derivatives that are needed to be
  76. calculated are the first order ones which are obtained above.
  77. \section{How to Use CHANGEVAR}
  78. {\bf This facility requires the matrix package to be present in the session}.
  79. So if it is not autoloaded in your REDUCE implementation, {\bf load it}.
  80. On the PC version of REDUCE 3.3 this is done by:
  81. \eg{LOAD MATR;}
  82. in the REDUCE environment. Then simply read in the file {\tt CHVAR} by a
  83. {\tt IN} statement:
  84. \eg{IN CHVAR\$}
  85. Now the REDUCE function {\tt CHANGEVAR} is ready to use.
  86. {\bf Note: The file is named CHVAR, but the function has the name CHANGEVAR}.
  87. The function {\tt CHANGEVAR} has (at least) four different arguments.
  88. Here we give a list them:
  89. \begin{itemize}
  90. \item {\bf FIRST ARGUMENT} \\
  91. Is a list of the dependent variables of the differential equation.
  92. They shall be enclosed in a pair of curly braces and separated by commas.
  93. If there is only one dependent variable there is no need for the curly
  94. braces.
  95. \item {\bf SECOND ARGUMENT} \\
  96. Is a list of the {\bf new} independent variables. Similar to what is said
  97. for the first argument, these shall also be separated by commas,
  98. enclosed in curly braces and the curly braces can be omitted if there is
  99. only one new variable.
  100. \item {\bf THIRD ARGUMENT} \\
  101. Is a list of equations separated by commas, where each of the equation
  102. is of the form
  103. \eg{{\em old variable} = {\em a function in new variables}}
  104. The left hand side cannot be a non-kernel structure. In this argument
  105. the functions which give the old variables in terms of the new ones are
  106. introduced. It is possible to omit totally the curly braces which enclose
  107. the list. {\bf Please note that only for this argument it is allowed to
  108. omit the curly braces even if the list has \underline{more than one}
  109. items}.
  110. \item {\bf LAST ARGUMENT} \\
  111. Is a list of algebraic expressions which evaluates to differential
  112. equations, separated by commas, enclosed in curly braces.
  113. So, variables in which differential equations are already stored may be
  114. used freely. Again it is possible to omit the curly braces if there is
  115. only {\bf one} differential equation.
  116. \end{itemize}
  117. If the last argument is a list then the result of {\tt CHANGEVAR} is a list too.
  118. It is possible to display the entries of the inverse Jacobian, explained in the
  119. introduction. To do so, turn {\tt ON} the flag {DISPJACOBIAN} by a statement:
  120. \eg{ON DISPJACOBIAN;}
  121. \section{AN EXAMPLE\ldots\ldots The 2-dim. Laplace Equation}
  122. The 2-dimensional Laplace equation in cartesian coordinates is:
  123. \[
  124. \frac{\partial^{2} u}{\partial x^{2}} +
  125. \frac{\partial^{2} u}{\partial y^{2}} = 0
  126. \]
  127. Now assume we want to obtain the polar coordinate form of Laplace equation.
  128. The change of variables is:
  129. \[
  130. x = r \cos \theta, \mspc y = r \sin \theta
  131. \]
  132. The solution using {\tt CHANGEVAR} (of course after it is properly loaded)
  133. is as follows
  134. \eg{CHANGEVAR(\{u\},\{r,theta\},\{x=r*cos theta,y=r*sin theta\}, \\
  135. \hspace*{2cm} \{df(u(x,y),x,2)+df(u(x,y),y,2)\} )}
  136. Here we could omit the curly braces in the first and last arguments (because
  137. those lists have only one member) and the curly braces in the third argument
  138. (because they are optional), but you cannot leave off the curly braces in the
  139. second argument. So one could equivalently write
  140. \eg{CHANGEVAR(u,\{r,theta\},x=r*cos theta,y=r*sin theta, \\
  141. \hspace*{2cm} df(u(x,y),x,2)+df(u(x,y),y,2) )}
  142. If you have tried out the above example, you will notice that the denominator
  143. contains a $\cos^{2} \theta + \sin^{2} \theta$ which is actually equal to $1$.
  144. This has of course nothing to do with the {\tt CHANGEVAR} facility introduced
  145. here. One has to be overcome these pattern matching problems by the conventional
  146. methods REDUCE provides (a {\tt LET} statement, for example, will fix it).
  147. Secondly you will notice that your {\tt u(x,y)} operator has changed to
  148. {\tt u(r,theta)} in the result. Nothing magical about this. That is just what
  149. we do with pencil and paper. {\tt u(r,theta)} represents the the transformed
  150. dependent variable.
  151. \section{ANOTHER EXAMPLE\ldots\ldots An Euler Equation}
  152. Consider a differential equation which is of Euler type, for instance:
  153. \[
  154. x^{3}y''' - 3 x^{2}y'' + 6 x y' - 6 y = 0
  155. \]
  156. Where prime denotes differentiation with respect to $x$.
  157. As it is well known Euler type of equations are solved by a change of variable:
  158. \[
  159. x = e^{u}
  160. \]
  161. So our {\tt CHANGEVAR} call reads as follows:
  162. \eg{CHANGEVAR(y, u, x=e**u, x**3*df(y(x),x,3)- \\
  163. \hspace*{2cm} 3*x**2*df(y(x),x,2)+6*x*df(y(x),x)-6*y(x))}
  164. \end{document}