Function: quadunit
Section: number_theoretical
C-Name: quadunit0
Prototype: GDn
Help: quadunit(D,{v = 'w}): fundamental unit u of the quadratic field of
 discriminant D where D must be positive.
 If v is given, the variable name is used to display u, else 'w' is used.
Doc: fundamental unit\sidx{fundamental units} $u$ of the
 real quadratic field $\Q(\sqrt D)$ where  $D$ is the positive discriminant
 of the field. If $D$ is not a fundamental discriminant, this probably
 gives the fundamental unit of the corresponding order. $D$ must be an
 integer congruent to 0 or 1 modulo 4, which is not a square; the result
 is a quadratic number (see \secref{se:quadgen}).
 If \var{v} is given, the variable name is used to display $u$
 else 'w' is used. The algorithm computes the continued fraction
 of $(1 + \sqrt{D}) / 2$ or $\sqrt{D}/2$ (see GTM 138, algorithm 5.7.2).
 Although the continued fraction length is only $O(\sqrt{D})$,
 the function still runs in time $\tilde{O}(D)$, in part because the
 output size is not polynomially bounded in terms of $\log D$.
 See \kbd{bnfinit} and \kbd{bnfunits} for a better alternative for large
 $D$, running in time subexponential in $\log D$ and returning the
 fundamental units in compact form (as a short list of $S$-units of size
 $O(\log D)^3$ raised to possibly large exponents).
Variant:
 When \var{v} does not matter, the function
 \fun{GEN}{quadunit}{GEN D} is also available.
