MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Module[ ... ] anomoly??

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3666] Module[ ... ] anomoly??
  • From: "Stephen L. McConnell" <scawa at intersurf.com>
  • Date: Tue, 2 Apr 1996 21:56:44 -0500
  • Organization: Louisiana State University Dept of Chem
  • Sender: owner-wri-mathgroup at wolfram.com

I have written a series of instructions which plot the vector field of a 
differential equation and then plot solution curves over that vector 
field.  I am attempting to put it in a Module with the hope of creating 
a Differential Equations package for use with C.H. Edwards and David 
Penney's book on Differential Equations and Boundary Value Problems.

I appear to have an anomoly when I try to modularize the solution.

The first few lines which create the vector field are

      f[x_,y_]=-y-Sin[x]
      p1=PlotVectorField[{1,f[x,y]},
                         {x,-3,3},
                         {y,-3,3},
                          Frame->True,
                          Axes->True]

These lines use the PlotVectorField package from Wickham-Jones 
"Mathematica Graphics" book.  The vector field works just as advertised 
and my solution curves when I solve the Diffeq are right on.

However when I modularize it and use the following lines:


      Needs["Graphics`PlotField`"]
      test[fun_,xmin_,xmax_,ymax_,ymin_]:=
      Module[{p1,x,y,i,a},
   	     p1=PlotVectorField[{1,fun[x,y]},
                                {x,xmin,xmax},
                                {y,ymin,ymax},
                                 Frame->True,
                                 Axes->True];
      ]

      g[x_,y_]:=-y-Sin[x]

      test[g,-3,3,-3,3]

The arrows on the vector field are exactly the opposite direction, and 
within the module, NDSolve cannot solve the diffeq... Interpolating 
fuction says the value is larger than can be represented.

Why is the vector field oposite in direction?
How can I write a general module or fuction which will allow me to use 
as a calling parameter my function ei:

      test[-y-Sin[x],-3,3,-3,3]

Thanks for the help in advance.
-- 
                       \\|//
//===================  (0-0)  ======================================//
//          ____/___oOO_(_)_OOo__       scawa at chrs1.chem.lsu.edu    //
//         (   / /_ \  / /_             scawa at intersurf.com         //
// _________) / /__  \/ /__                                         //
// If you are not part of the solution,      "Phase diagrams are    //
// you are part of the problem (or maybe      your friend"          //
// a colloidal suspension or a                  --Brian Hales Ph.D. //
// precipitant).                                                    //  
//==================================================================//

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: How can I change the format of plot labels?
  • Next by Date: Expl. form of Interpolation[] ?
  • Previous by thread: Re: How can I change the format of plot labels?
  • Next by thread: Expl. form of Interpolation[] ?