summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2012-02-25 12:36:30 +0100
committerAlberto Ruiz <aruiz@um.es>2012-02-25 12:36:30 +0100
commit47ea0f25eed9ab4a9bcdb4da2cf573a26883f9d4 (patch)
treeb91e101621e6a352bfeef68a1fe0a31df8684065 /examples
parentb67148cf9e97a259c398280493829fc3cbed6582 (diff)
odeSolveV with safe method interface
Diffstat (limited to 'examples')
-rw-r--r--examples/ode.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/ode.hs b/examples/ode.hs
index 060d4c2..dc6e0ec 100644
--- a/examples/ode.hs
+++ b/examples/ode.hs
@@ -35,13 +35,16 @@ main = do
35 harmonic 1 0.1 35 harmonic 1 0.1
36 kepler 0.3 60 36 kepler 0.3 60
37 kepler 0.4 70 37 kepler 0.4 70
38 vanderpol' 2
38 39
40-- example of odeSolveV with jacobian
39vanderpol' mu = do 41vanderpol' mu = do
40 let xdot mu t (toList->[x,v]) = fromList [v, -x + mu * v * (1-x^2)] 42 let xdot mu t (toList->[x,v]) = fromList [v, -x + mu * v * (1-x^2)]
41 jac t (toList->[x,v]) = debug $ (2><2) [ 0 , 1 43 jac t (toList->[x,v]) = (2><2) [ 0 , 1
42 , -1-2*x*v*mu, mu*(1-x**2) ] 44 , -1-2*x*v*mu, mu*(1-x**2) ]
43 ts = linspace 1000 (0,50) 45 ts = linspace 1000 (0,50)
44 hi = (ts@>1 - ts@>0)/100 46 hi = (ts@>1 - ts@>0)/100
45 sol = toColumns $ odeSolveV BSimp hi 1E-8 1E-8 (xdot mu) (Just jac) (fromList [1,0]) ts 47 sol = toColumns $ odeSolveV (MSBDF jac) hi 1E-8 1E-8 (xdot mu) (fromList [1,0]) ts
46 mplot sol 48 mplot sol
47 49
50