done * get it to work with a union
done * make type and value private
done * move all definition code into cpp file
done * add an int type
done * create a coercion model
done * make everything actually work with these two types
done * get rid of ginsh and other crap from distro.
done * change verbose logging stuff to be macros
done * figure out how to properly check for and raise a Python exception
done * implement stub functions:
done * use gmp to implement binomial on ui's
@deftypefunx void mpz_bin_uiui (mpz_t @var{rop}, unsigned long int @var{n}, @w{unsigned long int @var{k}})
done * fix the binomial expand memory leak
done  * Need to print with parenthesis, e.g.:
sage: K.<alpha> = NumberField(x^5 + x^2 + x -1)
sage: var('x,y,z,w',ns=1); P=x.parent();
sage: x^(alpha+1)
x^alpha + 1
done * fix symbol order (done by changing hashing and compare_same_type in symbol.cpp)
mostly done/changed -- above fix made all this change. replaced by new todo * Fix printing order.
sage: x^2 + x^4 + x^3
x^4 + x^2 + x^3
sage: var('a,x,y')
(a, x, y)
sage: a+x+y
y + x + a
sage: a+y+x
y + x + a
sage: y+x+a
y + x + a

* print degree order:
Now,
sage: x^2 + x^4 + x^3
x^2 + x^3 + x^4
sage: a^3*x^10 + x^12 - a^15
x^12 + a^3*x^10 - a^15

So it is printing from lowest to highest degree, like mathematica (or power series),
but unlike the standard sage convention (or maple, singular, MATH, etc.):
sage: R.<a,x> = QQ[]
sage: a^3*x^10 + x^12 - a^15
-a^15 + a^3*x^10 + x^12
sage: singular(a^3*x^10 + x^12 - a^15)
-a^15+a^3*x^10+x^12
done * switch everything to use except+.
done * doctest all existing functions
done * add copyright headers
done * wrap differentiation
done * integrate in burcin's new code
done * put sig_on()/ sig_off() back so control-c works.
done (?) * printing sums is still out of wack and non-deterministic
done * implement isqrt, etc. and other stubs in pynac.pyx
done * BUG:
get gcd to work
sage: from sage.all import *; x,y= var('x,y',ns=1); (x**2-y**2).gcd(x-y)
boom!

done * Bug...
sage: var('x',ns=1); k.<a> = GF(9); k(2)*x
x
with 9 replaced by 25 it works fine...

done * wrap basic pattern matching

done * wrap basic polynomial functions

done * wrap substituting expressions

done * {{{id=27|
var('x,y',ns=1)
S = x.parent()
pi = sage.symbolic.ring.pi
def hermite(n,y):
  if n == 1:
      return 2*y
  if n == 0:
      return 1
  return 2*y*hermite(n-1,y) - 2*(n-1)*hermite(n-2,y)

def phi(n,y):
  return 1/(sqrt(S(2^n*factorial(n)))*pi^(1/4))*exp(-y^2/2)*hermite(n,y)

time a = phi(25,4)
///
** Hit STUB**: irem -- need to compute r!!!
PYTHON ERROR! error calling function
}}}

DONE * Control-c --> SIGBUS:
sage: R.<u,v> = QQ[]
sage: var('a,b,c', ns=1)
(a, b, c)
sage: expand((u + v + a + b + c)^2)
u^2 + 2*u*v + v^2 + a^2 + 2*b*a + (2*u + 2*v)*b + b^2 + 2*b*c + (2*u + 2*v)*a + c^2 + (2*u + 2*v)*c + 2*a*c
sage: time z = expand((u + v + a + b + c)^10)
CPU times: user 0.01 s, sys: 0.00 s, total: 0.01 s
Wall time: 0.05 s
sage: time z = expand((u + v + a + b + c)^100)
^C^C^C
------------------------------------------------------------
Unhandled SIGBUS: A bus error occured in SAGE.

done * pretty serious todo -- all predefined constants in utils.cpp get made wrong:
    // TODO: BECAUSE of Floor divsion, this gives the wrong answer!!
    // However, it gets called at ginac startup, so I don't yet
    // know how to change it to make a Sage Rational. Argh.
    value = Number_T(numer) / Number_T(denom);

done * wrap taylor series
done    * power series print wrong -- no spaces around operators

done * figure out how to check for true or false-ness of inequalities in ginac manual.
   sage: var('x,y,z,w',ns=1); P=x.parent();
   sage: bool(P(2)== P(2))

done-ish * implement conversion to RealField, and more general coercions...

done * BUG:
sage: S(0.5).arccosh()
1.12762596520638  # very wrong!
Notes
(1) sage: (0.5).arccosh()
NaN
(2) but however it seems the code in pynac.pyx isn't even called.

done * make it so "make install" actually works without manual intervention, especially on osx

------------------------------------------------------------------


******************************************************************************
For PHASE II: LATER  (Hopefully Burcin)
******************************************************************************

* genuine coercions to real field, etc.

* optimize is_even in numeric.cpp

* Support pickle via the "archive" print mode.

done * CRASH:
sage: f = (Mod(2,7)*x^2 + Mod(2,7))^7
------------------------------------------------------------
Unhandled SIGBUS: A bus error occured in SAGE.

It works fine with leading coefficient Mod(1,7)

done * Weird wrong answers:
sage: k = GF(7)
sage: f = expand((k(1)*x^5 + k(1)*x^2 + k(2))^7); f
2 + 35*x^26 + 21*x^29 + 7*x^17 + 21*x^20 + 35*x^23 + x^14 + 7*x^32 + x^35
sage: f * k(-1) * k(-1)
2

* need to be able to do this (from ginsh):
> collect_common_factors(x/(x^2 + x));
(1+x)^(-1)


* Maybe change SAGE's Ginac to make a call to a cython gcd function, then use
singular, since singular's gcd over QQ is much better than ginac's, I think,
and ginac *only* does GCD over QQ.  Actually, just make everything in normal.cpp
be implemented via Singular, probably...

done * Make it so these work the same way, i.e., in second case below the Mod(1,7)
should also reduce.  Probably in some cases ginac just doesn't bother to do
the multiply because Mod(1,7) == 1 is true.
sage: a.expand()*Mod(2,7)
5 + (5)*x + (2)*x^3 + (4)*x^2
sage: a.expand()*Mod(1,7)
1000 + 300*x + x^3 + 30*x^2
