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

  1. "File:    RECUREQN.MTH  (c)    01/07/1990    Soft Warehouse Inc."
  2.  
  3. "    Methods for solving recurrence relations."
  4.  
  5. "METHODS FOR 1ST-ORDER RECURRENCE RELATIONS:"
  6.  
  7. "Soln to linear 1st-order difference eqn y(x+1)=p(x)y(x)+q(x), y(x0)=y0:"
  8.  
  9. LIN1_DIFFERENCE(px,qx,x,x0,y0):=PRODUCT(px,x,x0,x-1)*(y0+SUM(qx/PRODUCT(px,x,x~
  10. 0,x),x,x0,x-1))
  11.  
  12. "Returns soln to y(k x) = p(x) y(x) + q(x), y(x0)=y0:"
  13.  
  14. GEOMETRIC1(px,qx,k,x,x0,y0):=LIM(LIN1_DIFFERENCE(LIM(px,x,k^x_),LIM(qx,x,k^x_)~
  15. ,x_,LOG(x0,k),y0),x_,LOG(x,k))
  16.  
  17. "Returns gen solution to f(y(x)-x d)=g(d), where d represents y(x+1)-y(x):"
  18.  
  19. CLAIRAUT_DIF(f_,gd,d_):=LIM(f_=gd,d_,@1)
  20.  
  21. "METHODS FOR 2ND-ORDER DIFFERENCE EQUATIONS:"
  22.  
  23. "Methods for 2nd-order linear equations with constant coefficients:"
  24.  
  25. "Returns discriminant for soln to y(x+2)+py(x+1)+qy(x)=0 with p & q const:"
  26.  
  27. LIN2_RED_CCF_RECUR_DISC(p_,q_):=p_^2-4*q_
  28.  
  29. "Returns solution to y(x+2)+py(x+1)+qy=0 with p & q constant & disc > 0:"
  30.  
  31. LIN2_RED_CCF_RECUR_POS(p_,q_,x):=@1*((SQRT(p_^2-4*q_)-p_)/2)^x+@2*((-p_-SQRT(p~
  32. _^2-4*q_))/2)^x
  33.  
  34. "Returns solution to y(x+2)+py(x+1)+qy=0 with p & q constant & disc < 0:"
  35.  
  36. LIN2_RED_CCF_RECUR_NEG(p_,q_,x):=q_^(x/2)*(@1*SIN(x*ATAN(SQRT(4*q_-p_^2)/(-p_)~
  37. ))+@2*COS(x*ATAN(SQRT(4*q_-p_^2)/(-p_))))
  38.  
  39. "Returns solution to y(x+2)+py(x+1)+qy=0 with p & q constant & disc = 0:"
  40.  
  41. LIN2_RED_CCF_RECUR_0(p_,x):=(-p_/2)^x*(@1+@2*x)
  42.  
  43. "Methods for reduced 2nd-order linear equations:"
  44.  
  45. "Returns 0 if  p(x) y(x+2) + q(x) y(x+1) + r(x) y(x) = 0  is exact:"
  46.  
  47. EXACT2_IF_0(px,qx,rx,x):=px+LIM(qx,x,x+1)+LIM(rx,x,x+2)
  48.  
  49. "If p(x)y(x+2)+q(x)y(x+1)+r(x)y(x)=0 exact, -> s st s(x)y(x+1)+r(x)y(x)=c:"
  50.  
  51. EXACT2_RECUR(px,x):=LIM(px,x,x-1)
  52.  
  53. "Given a particular soln u to y(x+2)+p(x)y(x+1)+q(x)=0, returns another:"
  54.  
  55. LIN2_RED_GIVEN1(qx,ux,x):=ux*SUM(PRODUCT(qx,x)/(ux*LIM(ux,x,x+1)),x)
  56.  
  57. "A method for any reduced 2nd-order linear equation:"
  58.  
  59. "A helper function analogous to a Wronskian:"
  60.  
  61. CASORATIAN(ux,vx,x):=DET([[ux, vx], [LIM(ux,x,x+1), LIM(vx,x,x+1)]])
  62.  
  63. "Partic soln to y(x+2)+p(x)y(x)+q(x)y(x)=r(x) from partic solns u&v for r=0:"
  64.  
  65. LIN2_COMPLETE(ux,vx,rx,x):=vx*SUM(rx*LIM(ux/CASORATIAN(ux,vx,x),x,x+1),x)-ux*SUM(~
  66. rx*LIM(vx/CASORATIAN(ux,vx,x),x,x+1),x)
  67.  
  68. "Given y(x,@1,@2) and y(x1)=y1, y(x2)=x2, determines @1 and @2:"
  69.  
  70. IMPOSE_BV2(x,y_,x1,y1,x2,y2):=SOLVE([LIM(y_,x,x1)=y1, LIM(y_,x,x2)=y2],[@1, @2~
  71. ])
  72.