changevr.tex 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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{ CHANGEVR, \\
  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: UCOLUK@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
  32. chain rule. If the dependent variable of the differential equation is $F$,
  33. the 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 CHANGEVR}
  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, say
  80. \eg{LOAD\_PACKAGE MATRIX;}
  81. in the REDUCE environment. Then load {\tt CHANGEVR} by the statement:
  82. \eg{LOAD\_PACKAGE CHANGEVR\$}
  83. Now the REDUCE function {\tt CHANGEVAR} is ready to use. {\bf Note: The
  84. package is named CHANGEVR, but the function has the name CHANGEVAR}. The
  85. function {\tt CHANGEVAR} has (at least) four different arguments. Here we
  86. give a list them:
  87. \begin{itemize}
  88. \item {\bf FIRST ARGUMENT} \\
  89. Is a list of the dependent variables of the differential equation.
  90. They shall be enclosed in a pair of curly braces and separated by commas.
  91. If there is only one dependent variable there is no need for the curly
  92. braces.
  93. \item {\bf SECOND ARGUMENT} \\
  94. Is a list of the {\bf new} independent variables. Similar to what is said
  95. for the first argument, these shall also be separated by commas,
  96. enclosed in curly braces and the curly braces can be omitted if there is
  97. only one new variable.
  98. \item {\bf THIRD ARGUMENT} \\
  99. Is a list of equations separated by commas, where each of the equation
  100. is of the form
  101. \eg{{\em old variable} = {\em a function in new variables}}
  102. The left hand side cannot be a non-kernel structure. In this argument
  103. the functions which give the old variables in terms of the new ones are
  104. introduced. It is possible to omit totally the curly braces which enclose
  105. the list. {\bf Please note that only for this argument it is allowed to
  106. omit the curly braces even if the list has \underline{more than one}
  107. items}.
  108. \item {\bf LAST ARGUMENT} \\
  109. Is a list of algebraic expressions which evaluates to differential
  110. equations, separated by commas, enclosed in curly braces.
  111. So, variables in which differential equations are already stored may be
  112. used freely. Again it is possible to omit the curly braces if there is
  113. only {\bf one} differential equation.
  114. \end{itemize}
  115. If the last argument is a list then the result of {\tt CHANGEVAR} is also a
  116. list.
  117. It is possible to display the entries of the inverse Jacobian, explained
  118. in the introduction. To do so, turn {\tt ON} the flag {DISPJACOBIAN} by a
  119. statement: \eg{ON DISPJACOBIAN;}
  120. \section{AN EXAMPLE\ldots\ldots The 2-dim. Laplace Equation}
  121. The 2-dimensional Laplace equation in cartesian coordinates is:
  122. \[
  123. \frac{\partial^{2} u}{\partial x^{2}} +
  124. \frac{\partial^{2} u}{\partial y^{2}} = 0
  125. \]
  126. Now assume we want to obtain the polar coordinate form of Laplace equation.
  127. The change of variables is:
  128. \[
  129. x = r \cos \theta, \mspc y = r \sin \theta
  130. \]
  131. The solution using {\tt CHANGEVAR} (of course after it is properly loaded)
  132. is as follows
  133. \eg{CHANGEVAR(\{u\},\{r,theta\},\{x=r*cos theta,y=r*sin theta\}, \\
  134. \hspace*{2cm} \{df(u(x,y),x,2)+df(u(x,y),y,2)\} )}
  135. Here we could omit the curly braces in the first and last arguments (because
  136. those lists have only one member) and the curly braces in the third argument
  137. (because they are optional), but you cannot leave off the curly braces in the
  138. second argument. So one could equivalently write
  139. \eg{CHANGEVAR(u,\{r,theta\},x=r*cos theta,y=r*sin theta, \\
  140. \hspace*{2cm} df(u(x,y),x,2)+df(u(x,y),y,2) )}
  141. If you have tried out the above example, you will notice that the denominator
  142. contains a $\cos^{2} \theta + \sin^{2} \theta$ which is actually equal to $1$.
  143. This has of course nothing to do with the {\tt CHANGEVAR} facility introduced
  144. here. One has to be overcome these pattern matching problems by the
  145. conventional methods REDUCE provides (a {\tt LET} statement, for example,
  146. 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$. As is well known,
  157. 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}