home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / DERIVE.ZIP / ODE2.MTH < prev    next >
Encoding:
Text File  |  1990-01-22  |  4.7 KB  |  140 lines

  1. "File:    ODE2.MTH  (c)         01/22/90          Soft Warehouse, Inc."
  2.  
  3. "ELEMENTARY METHODS FOR 2ND-ORDER ORDINARY DIFFERENTIAL EQUATIONS:"
  4.  
  5. "To avoid confusion, linear eqns of form y''+p(x)y'+q(x)y=r(x) are here"
  6.  
  7. " called REDUCED if r=0 or COMPLETE if r/=0.  HOMOGENEOUS is reserved for"
  8.  
  9. " eqns invariant under x->tx, y->ty."
  10.  
  11. "Returns discriminant for soln to y'' + p y' + q y = 0 with p & q const:"
  12.  
  13. LIN2_RED_CCF_DISC(p_,q_):=p_^2-4*q_
  14.  
  15. "Returns soln to  y'' + p y' + q y = 0    with p & q constant & disc > 0:"
  16.  
  17. LIN2_RED_CCF_POS(p_,q_,x):=@1*#e^((SQRT(p_^2-4*q_)-p_)*x/2)+@2*#e^((-p_-SQRT(p~
  18. _^2-4*q_))*x/2)
  19.  
  20. "Returns soln to  y'' + p y' + q y = 0    with p & q constant & disc < 0:"
  21.  
  22. LIN2_RED_CCF_NEG(p_,q_,x):=#e^(-p_*x/2)*(@1*SIN(x*SQRT(4*q_-p_^2)/2)+@2*COS(x*~
  23. SQRT(4*q_-p_^2)/2))
  24.  
  25. "Returns soln to  y'' + p y' + q y = 0    with p & q constant & disc = 0:"
  26.  
  27. LIN2_RED_CCF_0(p_,x):=#e^(-p_*x/2)*(@1+@2*x)
  28.  
  29. "Helper for LIN2_COMPLETE:"
  30.  
  31. WRONSKIAN(ux,vx,x):=DET([[ux, vx], [DIF(ux,x), DIF(vx,x)]])
  32.  
  33. "Retrns partic soln to y''+p(x)y'+q(x)=r(x) given partic solns u&v for r=0:"
  34.  
  35. "Eg: To solve y'' + 2y' + y = #e^-x LN x, LIN2_RED_CCF_DISC(2,1) gives 0,"
  36.  
  37. "  then LIN_2_RED_CCF_0 (2,x)  gives  (@2 x + @1)#e^-x, then this result"
  38.  
  39. "  + LIN2_COMPLETE (x #e^-x, #e^-x, #e^-x LN x, x) gives the gen soln."
  40.  
  41. LIN2_COMPLETE(ux,vx,rx,x):=vx*INT(ux*rx/WRONSKIAN(ux,vx,x),x)-ux*INT(vx*rx/WRO~
  42. NSKIAN(ux,vx,x),x)
  43.  
  44. "Given 1 soln u(x) to y''+p(x)y'+q(x)=0, returns another independent one:"
  45.  
  46. SECOND_RED_PARTIC(px,ux,x):=ux*INT(#e^INT(px,x)/ux^2,x)
  47.  
  48. "Returns solution to y''=q(y), y(x0)=y0, y'(x0)=v0:"
  49.  
  50. AUTONOMOUS_CONSERVATIVE(qy,x,y_,x0,y0,v0):=x=x0+INT((2*INT(qy,y_,y0,y_)+v0^2)^~
  51. (-1/2),y_,y0,y_)
  52.  
  53. "Reduces ODE of form d2y/dx2=r(v,y) with v=dy/dx to 1st ord dv/dy=result."
  54.  
  55. "If you can solve it for v(y), then solve the separable eqn y'=v(y) for y:"
  56.  
  57. "eg: To solve y''=(1-2y)y', AUTONOMOUS((1-2y)v,v,y) gives 2y+1 for dv/dy,"
  58.  
  59. " then using file ODE1, SEPARABLE(1,1/(2y+1),v,y,v0,y0) & solving for v"
  60.  
  61. " gives y^2+y+v0-y0^2-y0, then use SEPARABLE(1,y^2+y+v0-y0^2-y0,x,y,x0,y0)"
  62.  
  63. AUTONOMOUS(rvy,v_):=rvy/v_
  64.  
  65. "Given y(x,@1,@2) and y(x1)=y1, y(x2)=x2, determines @1 and @2:"
  66.  
  67. IMPOSE_BV2(x,y_,x1,y1,x2,y2):=SOLVE([LIM(y_,x,x1)=y1, LIM(y_,x,x2)=y2],[@1, @2~
  68. ])
  69.  
  70. "Given y(x,@1,@2) and y(x0)=y0, y'(x0)=v0, determines @1 and @2:"
  71.  
  72. IMPOSE_IC2(x,y_,x0,y0,v0):=SOLVE([LIM(y_,x,x0)=y0, LIM(DIF(y_,x),x,x0)=v0],[@1~
  73. , @2])
  74.  
  75. "ADVANCED METHODS FOR 2ND-ORDER ORDINARY DIFFERENTIAL EQUATIONS:"
  76.  
  77. "Returns gen solution to  y'' + p(x) y' + q(y) (y')^2 = 0"
  78.  
  79. LIOUVILLE(px,qy,x,y_):=INT(#e^INT(qy,y_),y_)=@1+@2*INT(#e^INT(-px,x),x)
  80.  
  81. "Returns [0,0] if f(x,y,v)y''+g(x,y,v)=0 is exact, where v denotes y':"
  82.  
  83. EXACT2_IF_ZEROS(f_,g_,x,y_,v_):=[(v_*DIF(f_,y_,2)+2*DIF(DIF(f_,x),y_)-DIF(DIF(~
  84. g_,y_),v_))*v_+DIF(f_,x,2)-DIF(DIF(g_,x),v_)+DIF(g_,y_), v_*DIF(DIF(f_,y_),v_)~
  85. +DIF(DIF(f_,x),v_)+2*DIF(f_,y_)-DIF(g_,v_,2)]
  86.  
  87. "Returns a 1st integral to the exact eqn f(x,y,v)y''+g(x,y,v)=0:"
  88.  
  89. EXACT2_AUX3(s_,h_,x):=s_+INT(h_-DIF(s_,x),x)
  90.  
  91. EXACT2_AUX2(r_,x,y_,v_):=EXACT2_AUX3(INT(DIF(r_,v_),y_),LIM(r_,v_,0),x)
  92.  
  93. EXACT2_AUX1(p_,g_,x,y_,v_):=p_+EXACT2_AUX2(g_-DIF(p_,x)-v_*DIF(p_,y_),x,y_,v_)
  94.  
  95. EXACT2(f_,g_,x,y_,v_):=EXACT2_AUX1(INT(f_,v_),g_,x,y_,v_)=@1
  96.  
  97. "ax+b->#e^t converts y''+p y'/(ax+b)+qy/(ax+b)^2 to d^2y/dt^2 +c dy/dt +ky"
  98.  
  99. "EULER(p,q,b) -> [c,k].  Solve that lin-red-ccf eqn then let t->ln(ax+b):"
  100.  
  101. EULER(p_,q_,b_):=[p/b-1, q/b^2]
  102.  
  103. "Using v for y', y''=r(x,y,v) is equidimensional in y if result free of y:"
  104.  
  105. EQUIDIMENSIONAL_IF_FREE_OF_Y(rxyv,y_,v_):=LIM(rxyv,v_,y_*v_)/y_
  106.  
  107. "For equidimensional-in-y y''=r(x,y,v) gives dv/dx for transformed y & v."
  108.  
  109. "Solve this 1st-ord ODE for a relation between v and x, then subst v->v/y,"
  110.  
  111. " to get a 1st-order eqn in the orig. x, y and v:"
  112.  
  113. EQUIDIMENSIONAL_Y(rxyv,y_,v_):=LIM(rxyv,y_,1)-v_^2
  114.  
  115. "Using v for y', y''=r(x,y,v) is equidimensional in x if result free of x:"
  116.  
  117. EQUIDIMENSIONAL_IF_FREE_OF_X(rxyv,x,v_):=x^2*LIM(rxyv,v_,v_/x)
  118.  
  119. "For equidimensional-in-x y''=r(x,y,v) gives dv/dy for transformed y & v."
  120.  
  121. "Solve this 1st-ord ODE for a relation between v and y, then subst v->x v,"
  122.  
  123. " to get a 1st-order eqn in the orig. x, y and v:"
  124.  
  125. EQUIDIMENSIONAL_X(rxyv,x,v_):=(v_+LIM(rxyv,x,1))/v_
  126.  
  127. "Using var v for y', y''=r(x,y,v) is homogeneous if result is free of x:"
  128.  
  129. HOMOGENEOUS2_IF_FREE_OF_X(rxyv,x,y_):=x*LIM(rxyv,y_,x*y_)
  130.  
  131. "For v=y' & homogeneous y''=r(x,y,v) gives dv/dy for transformed x,y & v."
  132.  
  133. "Solve this 1st-ord ODE for a relation between v and y, then subst v->v-y,"
  134.  
  135. " then y->y/LN x to get a 1st-order eqn in the orig. x, y and v:"
  136.  
  137. HOMOGENEOUS2(rxyv,x,y_,v_):=(LIM(LIM(rxyv,x,1),v_,v_+y_)-v_)/v_
  138.  
  139. HOMOGENEOUS2((y-x*v)^2/(n*x^3),x,y,v)
  140.