OKlibrary  0.2.1.6
Quadratics.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 5.8.2009 (Swansea) */
00002 /* Copyright 2009 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00022 oklib_include("OKlib/ComputerAlgebra/DataStructures/Lisp/Lists.mac")$
00023 
00024 
00025 /* ******************************
00026    * Counting integer equations *
00027    ******************************
00028 */
00029 
00030 /* The number of pairs [p,q] with p,q in {a, ..., b} such that
00031    both roots of x^2+p*x+q=0 are integers.
00032    a and b are integers.
00033    For a = 1 and b = n this is sequence A091627 in the sequence library.
00034 */
00035 count_quadintsol_bydef(a,b) := block([count : 0],
00036   for p : a thru b do
00037     for q : a thru b do
00038       if every_s(integerp,map(rhs,solve(x^2 + p*x + q))) then 
00039         count : count + 1,
00040   count)$
00041 
00042