diff options
Diffstat (limited to 'lib/Numeric/GSL/Root.hs')
-rw-r--r-- | lib/Numeric/GSL/Root.hs | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/lib/Numeric/GSL/Root.hs b/lib/Numeric/GSL/Root.hs index 6da15e5..9d561c4 100644 --- a/lib/Numeric/GSL/Root.hs +++ b/lib/Numeric/GSL/Root.hs | |||
@@ -13,33 +13,23 @@ Multidimensional root finding. | |||
13 | 13 | ||
14 | The example in the GSL manual: | 14 | The example in the GSL manual: |
15 | 15 | ||
16 | @import Numeric.GSL | 16 | >>> let rosenbrock a b [x,y] = [ a*(1-x), b*(y-x^2) ] |
17 | import Numeric.LinearAlgebra(format) | 17 | >>> let (sol,path) = root Hybrids 1E-7 30 (rosenbrock 1 10) [-10,-5] |
18 | import Text.Printf(printf) | 18 | >>> sol |
19 | |||
20 | rosenbrock a b [x,y] = [ a*(1-x), b*(y-x^2) ] | ||
21 | |||
22 | disp = putStrLn . format \" \" (printf \"%.3f\") | ||
23 | |||
24 | main = do | ||
25 | let (sol,path) = root Hybrids 1E-7 30 (rosenbrock 1 10) [-10,-5] | ||
26 | print sol | ||
27 | disp path | ||
28 | |||
29 | \> main | ||
30 | [1.0,1.0] | 19 | [1.0,1.0] |
31 | 0.000 -10.000 -5.000 11.000 -1050.000 | 20 | >>> disp 3 path |
32 | 1.000 -3.976 24.827 4.976 90.203 | 21 | 11x5 |
22 | 1.000 -10.000 -5.000 11.000 -1050.000 | ||
33 | 2.000 -3.976 24.827 4.976 90.203 | 23 | 2.000 -3.976 24.827 4.976 90.203 |
34 | 3.000 -3.976 24.827 4.976 90.203 | 24 | 3.000 -3.976 24.827 4.976 90.203 |
35 | 4.000 -1.274 -5.680 2.274 -73.018 | 25 | 4.000 -3.976 24.827 4.976 90.203 |
36 | 5.000 -1.274 -5.680 2.274 -73.018 | 26 | 5.000 -1.274 -5.680 2.274 -73.018 |
37 | 6.000 0.249 0.298 0.751 2.359 | 27 | 6.000 -1.274 -5.680 2.274 -73.018 |
38 | 7.000 0.249 0.298 0.751 2.359 | 28 | 7.000 0.249 0.298 0.751 2.359 |
39 | 8.000 1.000 0.878 -0.000 -1.218 | 29 | 8.000 0.249 0.298 0.751 2.359 |
40 | 9.000 1.000 0.989 -0.000 -0.108 | 30 | 9.000 1.000 0.878 -0.000 -1.218 |
41 | 10.000 1.000 1.000 0.000 0.000 | 31 | 10.000 1.000 0.989 -0.000 -0.108 |
42 | @ | 32 | 11.000 1.000 1.000 0.000 0.000 |
43 | 33 | ||
44 | -} | 34 | -} |
45 | ----------------------------------------------------------------------------- | 35 | ----------------------------------------------------------------------------- |