Commit bc1a4e77 authored by Han-Miru Kim's avatar Han-Miru Kim
Browse files

2 questions

parent 203168bf
......@@ -2,6 +2,70 @@
#+AUTHOR: Han-Miru Kim
#+PROPERTY: header-args :tangle ./bqf.hs
* Overview
** Features
We can calculate the discrimant of a form, or if a form is reduced:
#+BEGIN_SRC haskell :tangle no
ghci> f = (BQF (1,-6,3))
ghci> discriminant f
24
ghci> isReduced f
False
#+END_SRC
do a single reduction step
#+BEGIN_SRC haskell :tangle no
ghci> reduceStep f
(3,6,1)
#+END_SRC
or calculate the entire cycle
#+BEGIN_SRC haskell :tangle no
ghci> reduction f
[(1,-6,3),(3,6,1),(1,6,3),(3,6,1)]
ghci> g = BQF (-1,6,-3)
ghci> reduction g
[(-1,6,-3),(2,4,-1),(5,8,2),(6,12,5),(5,12,6),(2,8,5),(5,8,2)]
#+END_SRC
** Interesting stuff
*** How many are reduced?
This question obviously not well-defined, but I wanted to know "how many bqfs are reduced and how many are not?"
#+BEGIN_SRC haskell :tangle no
ghci> limit = 5
ghci> forms = [BQF (a,b,c) | a <- [- limit .. limit], b <- [- limit .. limit], c <- [- limit .. limit]]
ghci> length forms
1331
ghci> length $ filter isReduced forms
61
ghci> 61 / 1331
4.583e-2
-- and with limit = 10
ghci> length forms
9261
ghci> length $ filter isReduced forms
396
ghci> 396/9261
4.27e-2
-- limit = 200
ghci> 2686901/64481201
4.166e-2
#+END_SRC
So it looks like the ratio is decreasing as the range of coeffcients gets larger, but does not appear to decrease very quickly.
Does it converge to some value?
*** How long does it take to reduce?
#+BEGIN_SRC haskell :tangle no
-- with limit = 4
ghci> uforms = filter (not . isReduced) forms
ghci> times = map ((subtract 2) . length . reduction) uforms
ghci> length times
694
ghci> [(length . filter (== x)) times | x <- [1 .. 22]]
[323,130,84,42,42,22,9,4,4,10,10,4,0,0,0,0,0,0,0,0,2,2]
#+END_SRC
so 329 of them take 1 step, 130 take 2, etc.
* Binary Quadratic Forms
** Data
A binary quadratic form ~ax^2 + bxy + cy^2~ is represented as a tuple ~(a,b,c)~.
......@@ -64,13 +128,8 @@ Reduction is done by first finding the ~n~ for which ~n > (b + sqrt D)/2a > n-1~
| otherwise = aux xs (y ++ [x])
unreducedness :: BQF -> Int
unreducedness = (length . (takeWhile (not isReduced)) . reduction)
unreducedness = (length . (takeWhile (not . isReduced)) . reduction)
#+END_SRC
** Playground
#+BEGIN_SRC haskell
limit = 5
forms = [BQF (a,b,c) | a <- [- limit .. limit], b <- [- limit .. limit], c <- [- limit, limit]]
#+END_SRC
......@@ -45,7 +45,4 @@ reduction f = aux (iterate reduceStep f) []
| otherwise = aux xs (y ++ [x])
unreducedness :: BQF -> Int
unreducedness = (length . (takeWhile (not isReduced)) . reduction)
limit = 5
forms = [BQF (a,b,c) | a <- [- limit .. limit], b <- [- limit .. limit], c <- [- limit, limit]]
unreducedness = (length . (takeWhile (not . isReduced)) . reduction)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment