Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28494 views
License: GPL3
ubuntu2004
Function: content
Section: number_theoretical
C-Name: content0
Prototype: GDG
Help: content(x,{D}): gcd of all the components of x, when this makes sense.
Doc: computes the gcd of all the coefficients of $x$,
 when this gcd makes sense. This is the natural definition
 if $x$ is a polynomial (and by extension a power series) or a
 vector/matrix. This is in general a weaker notion than the \emph{ideal}
 generated by the coefficients:
 \bprog
 ? content(2*x+y)
 %1 = 1            \\ = gcd(2,y) over Q[y]
 @eprog

 If $x$ is a scalar, this simply returns the absolute value of $x$ if $x$ is
 rational (\typ{INT} or \typ{FRAC}), and either $1$ (inexact input) or $x$
 (exact input) otherwise; the result should be identical to \kbd{gcd(x, 0)}.

 The content of a rational function is the ratio of the contents of the
 numerator and the denominator. In recursive structures, if a
 matrix or vector \emph{coefficient} $x$ appears, the gcd is taken
 not with $x$, but with its content:
 \bprog
 ? content([ [2], 4*matid(3) ])
 %1 = 2
 @eprog\noindent The content of a \typ{VECSMALL} is computed assuming the
 entries are signed integers.

 The optional argument $D$ allows to control over which ring we compute
 and get a more predictable behaviour:

 \item $1$: we only consider the underlying $\Q$-structure and the
 denominator is a (positive) rational number

 \item a simple variable, say \kbd{'x}: all entries are considered as
 rational functions in $K(x)$ for some field $K$ and the content is an
 element of $K$.

 \bprog
 ? f = x + 1/y + 1/2;
 ? content(f) \\ as a t_POL in x
 %2 = 1/(2*y)
 ? content(f, 1) \\ Q-content
 %3 = 1/2
 ? content(f, y) \\ as a rational function in y
 %4 = 1/2
 ? g = x^2*y + y^2*x;
 ? content(g, x)
 %6 = y
 ? content(g, y)
 %7 = x
 @eprog