home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / sci / math / symbolic / 3299 < prev    next >
Encoding:
Text File  |  1992-12-16  |  3.2 KB  |  108 lines

  1. Newsgroups: sci.math.symbolic
  2. Path: sparky!uunet!spool.mu.edu!umn.edu!umeecs!zip!bagchi
  3. From: bagchi@eecs.umich.edu (Ranjan Drzzzzt!  Bagchi)
  4. Subject: dumb maple question -- differential equations
  5. Message-ID: <BAGCHI.92Dec16184006@quip.eecs.umich.edu>
  6. Sender: news@zip.eecs.umich.edu (Mr. News)
  7. Organization: Recreational Creationists, Inc.
  8. Date: Wed, 16 Dec 1992 23:40:06 GMT
  9. Lines: 97
  10.  
  11. Hi folk --
  12.  
  13.     I'm playing (for lack of a better word) with a system of
  14. ODE's, and having fed them to maple for a numeric solution, I'd like
  15. to do something with this solution.
  16.  
  17.     |\^/|     Maple V Release 2 (University of Michigan)
  18. ._|\|   |/|_. Copyright (c) 1981-1992 by the University of Waterloo.
  19.  \  MAPLE  /  All rights reserved. MAPLE is a registered trademark of
  20.  <____ ____>  Waterloo Maple Software.
  21.       |       Type ? for help.
  22. > sys := {
  23. > f> (v1(        diff(v1(t),t) = a1*v1(t) - b1*v1(t)*pr(t),
  24. >         diff(v2(t),t) = a2*v2(t) - b2*v2(t)*pr(t),
  25. >         diff(pr(t),t) = -c*pr(t) + d * pr(t) * v1(t) + e *pr(t)*v2(t)
  26. > };
  27.  
  28.                     d
  29.           sys := {---- v1(t) = a1 v1(t) - b1 v1(t) pr(t),
  30.                    dt
  31.  
  32.                 d
  33.               ---- v2(t) = a2 v2(t) - b2 v2(t) pr(t),
  34.                dt
  35.  
  36.                 d
  37.               ---- pr(t) = - c pr(t) + d pr(t) v1(t) + e pr(t) v2(t)}
  38.                dt
  39.  
  40. > params := {a1 = 1, b1 = .3,a2 = 2, b2 = .6, c = 3, d = .7, e = .5};
  41.  
  42.       params := {a1 = 1, b1 = .3, a2 = 2, b2 = .6, c = 3, d = .7, e = .5}
  43.  
  44. >
  45.  union sysinit);
  46.  
  47. >  :> = dsolve(eqns,{v1(t),vsysinit := { v1(0) = 5, v2(0) = 5, pr(0) = 4};
  48.  
  49.                   sysinit := {v1(0) = 5, v2(0) = 5, pr(0) = 4}
  50.  
  51. >
  52. > eqns := subs(params,sys union sysinit);
  53.  
  54.                                             d
  55. eqns := {v1(0) = 5, v2(0) = 5, pr(0) = 4, ---- v1(t) = v1(t) - .3 v1(t) pr(t),
  56.                                            dt
  57.  
  58.       d
  59.     ---- v2(t) = 2 v2(t) - .6 v2(t) pr(t),
  60.      dt
  61.  
  62.       d
  63.     ---- pr(t) = - 3 pr(t) + .7 v1(t) pr(t) + .5 v2(t) pr(t)}
  64.      dt
  65.  
  66. >
  67. > pv := dsolve(eqns,{v1(t),v2(t),pr(t)},numeric);
  68. bytes used=302868, alloc=262096, time=0.72
  69. bytes used=309476, alloc=262096, time=0.78
  70. pv := proc(t) `dsolve/numeric/result2`(t,895108,[1,1,1]) end
  71.  
  72. >> pv(1);
  73.  
  74.     {t = 1., v1(t) = 1.599162730, pr(t) = 5.059208376, v2(t) = .5114643376}
  75.  
  76.  
  77. ----------- end of session ------------
  78.  
  79. There are several things I'd like to do with this data which 
  80. I haven't had much luck with:
  81.  
  82. 1)  I'd like to break v1(t), v2(t), pr(t) into separate functions.  While
  83. this sounds trivial, the only way I've been able to do it is with 
  84.  
  85. V1 proc(t) op(2,op(2,pv(t))) end;
  86.  
  87. which looks fairly inelegant.
  88.  
  89. 2)  I'd like to collect a large (say 10000 point) array of data from each
  90. of the functions.  Any attempt at this has taken what seems to be
  91. an unbearably long time.  I've been using a do loop and putting data
  92. in each array bucket.
  93.  
  94. 3) I'd like to plot these derived function.  In the V1 I defined above, 
  95. I get the following errors:
  96.  
  97. > plot(V1,0..10);
  98. bytes used=1491904, alloc=1048384, time=5.58
  99. Error, (in f) wrong number (or type) of parameters in function type;
  100.  
  101.  
  102. help??
  103.  
  104.     -rj
  105. --
  106. Ranjan Bagchi                           Ranjan.Bagchi@umich.edu
  107. oo   oooo  o oo   ooo oo oo   oo       o o  oooo ooo o       o        oooooooo
  108.