Flint2-0.1.0.5: Haskell bindings for the flint library for number theory

Data.Number.Flint.Calcium.Ca

Description

## Exact real and complex numbers

A Ca represents a real or complex number in a form suitable for exact field arithmetic or comparison. Exceptionally, a Ca may represent a special nonnumerical value, such as an infinity.

## Introduction: numbers

A Calcium number is a real or complex number represented as an element of a formal field $$K = \mathbb{Q}(a_1, \ldots, a_n)$$ where the symbols $$a_k$$ denote fixed algebraic or transcendental numbers called extension numbers. For example, $$e^{\,- 2 \pi} - 3i$$ may be represented as $$(1 - 3 a_2^2 a_1) / a_2^2$$ in the field $$\mathbb{Q}(a_1,a_2)$$ with $$a_1 = i, a_2 = e^{\pi}$$. Extension numbers and fields are documented in the following separate modules:

The user does not need to construct extension numbers or formal extension fields explicitly: each Ca contains an internal pointer to its formal field, and operations on Calcium numbers generate and cache fields automatically as needed to express the results.

This representation is not canonical (in general). A given complex number can be represented in different ways depending on the choice of formal field K. Even within a fixed field K, a number can have different representations if there are algebraic relations between the extension numbers. Two numbers x and y can be tested for inequality using numerical evaluation; to test for equality, it may be necessary to eliminate dependencies between extension numbers. One of the central goals of Calcium will be to implement heuristics for such elimination.

Together with each formal field K, Calcium stores a reduction ideal $$I = \{g_1,\ldots,g_m\}$$ with $$g_i \in \mathbb{Z}[a_1,\ldots,a_n]$$, defining a set of algebraic relations $$g_i(a_1,\ldots,a_n) = 0$$. Relations can be absolute, say $$g_i = a_j^2 + 1$$, or relative, say $$g_i = 2 a_j - 4 a_k - a_l a_m$$. The reduction ideal effectively partitions $$K$$ into equivalence classes of complex numbers (e.g. $$i^2 = -1$$ or $$2 \log(\pi i) = 4 \log(\sqrt{\pi}) + \pi i$$), enabling simplifications and equality proving.

Extension numbers are always sorted $$a_1 \succ a_2 \succ \ldots \succ a_n$$ where $$\succ$$ denotes a structural ordering (see ca_cmp_repr). If the reduction ideal is triangular and the multivariate polynomial arithmetic uses lexicographic ordering, reduction by I eliminates numbers $$a_i$$ with higher complexity in the sense of $$\succ$$.

The reduction ideal is an imperfect computational crutch: it is not guaranteed to capture all algebraic relations, and reduction is not guaranteed to produce uniquely defined representatives. However, in the specific case of an absolute number field $$K = \mathbb{Q}(a)$$ where a is a qqbar_t extension, the reduction ideal (consisting of a single minimal polynomial) is canonical and field elements of K can be chosen canonically.

## Introduction: special values

In order to provide a closed arithmetic system and express limiting cases of operators and special functions, a Ca can hold any of the following special values besides ordinary numbers:

The distinction between Calcium numbers (which must represent elements of $$\mathbb{C}$$) and the different kinds of nonnumerical values (infinities, Undefined or Unknown) is essential. Nonnumerical values may not be used as field extension numbers $$a_k$$, and the denominator of a formal field element must always represent a nonzero complex number. Accordingly, for any given Calcium value x that is not Unknown, it is exactly known whether x represents A) a number, B) unsigned infinity, C) a signed infinity, or D) Undefined.

Synopsis

# Exact Numbers

data Ca Source #

Constructors

 Ca !(ForeignPtr CCa)

#### Instances

Instances details
 Source # Instance detailsDefined in Data.Number.Flint.Calcium.Ca.FFI MethodssizeOf :: CCa -> Int #alignment :: CCa -> Int #pokeElemOff :: Ptr CCa -> Int -> CCa -> IO () #peekByteOff :: Ptr b -> Int -> IO CCa #pokeByteOff :: Ptr b -> Int -> CCa -> IO () #peek :: Ptr CCa -> IO CCa #poke :: Ptr CCa -> CCa -> IO () #

data CaCtx Source #

Constructors

 CaCtx !(ForeignPtr CCaCtx)

#### Instances

Instances details
 Source # Instance detailsDefined in Data.Number.Flint.Calcium.Ca.FFI MethodssizeOf :: CCaCtx -> Int #pokeElemOff :: Ptr CCaCtx -> Int -> CCaCtx -> IO () #peekByteOff :: Ptr b -> Int -> IO CCaCtx #pokeByteOff :: Ptr b -> Int -> CCaCtx -> IO () #poke :: Ptr CCaCtx -> CCaCtx -> IO () #

withCa :: Ca -> (Ptr CCa -> IO a) -> IO (Ca, a) Source #

withNewCa :: CaCtx -> (Ptr CCa -> IO a) -> IO (Ca, a) Source #

withCaCtx :: CaCtx -> (Ptr CCaCtx -> IO a) -> IO (CaCtx, a) Source #

# Context objects

ca_ctx_init ctx

Initializes the context object ctx for use. Any evaluation options stored in the context object are set to default values.

ca_ctx_clear ctx

Clears the context object ctx, freeing any memory allocated internally. This function should only be called after all ca_t instances referring to this context have been cleared.

ca_ctx_print ctx

Prints a description of the context ctx to standard output. This will give a complete listing of the cached fields in ctx.

ca_ctx_get_options ctx i

ca_ctx_set_option ctx i value

# Memory management for numbers

ca_init :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_init x ctx

Initializes the variable x for use, associating it with the context object ctx. The value of x is set to the rational number 0.

ca_clear :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_clear x ctx

Clears the variable x.

ca_swap :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_swap x y ctx

Efficiently swaps the variables x and y.

# Symbolic expressions

ca_get_fexpr res x flags ctx

Sets res to a symbolic expression representing x.

ca_set_fexpr res expr ctx

Sets res to the value represented by the symbolic expression expr. Returns 1 on success and 0 on failure. This function essentially just traverses the expression tree using ca arithmetic; it does not provide advanced symbolic evaluation. It is guaranteed to at least be able to parse the output of ca_get_fexpr.

# Print flags

The style of printed output is controlled a flag which can be set to any combination of the following flags:

ca_print_n

Print a decimal approximation of the number. The approximation is guaranteed to be correctly rounded to within one unit in the last place.

If combined with ca_print_repr, numbers appearing within the symbolic representation will also be printed with decimal approximations.

Warning: printing a decimal approximation requires a computation, which can be expensive. It can also mutate cached data (numerical enclosures of extension numbers), affecting subsequent computations.

ca_print_repr

Print the symbolic representation of the number (including its recursive elements). If used together with ca_print_n, field elements will print as decimal {symbolic} while extension numbers will print as decimal [symbolic].

All extension numbers appearing in the field defining x and in the inner constructions of those extension numbers will be given local labels a, b, etc. for this printing.

ca_print_field

For each field element, explicitly print its formal field along with its reduction ideal if present, e.g. QQ or QQ(a,b,c) / c^2+1.

ca_print_digits

Multiplied by a positive integer, specifies the number of decimal digits to show with ca_print_n. If not given, the default precision is six digits.

ca_print_default

The default print style. Equivalent to ca_print_n | ca_print_repr.

ca_print_debug

Verbose print style for debugging. Equivalent to ca_print_n | ca_print_repr | ca_print_field.

## Example for print flags

As a special case, small integers are always printed as simple literals.

As illustration, here are the numbers -7, $$2/3$$, $$(\sqrt{3}+5)/2$$ and $$\sqrt{2} (\log(\pi) + \pi i)$$ printed in various styles:

> ca_print_default
• 7 0.666667 {2/3} 3.36603 {(a+5)/2 where a = 1.73205 [a^2-3=0]} 1.61889 + 4.44288*I {a*c+b*c*d where a = 1.14473 [Log(3.14159 {b})], b = 3.14159 [Pi], c = 1.41421 [c^2-2=0], d = I [d^2+1=0]}
> ca_print_n
• 7 0.666667 3.36603 1.61889 + 4.44288*I
> ca_print_n .|. (ca_print_digits * 20)
• 7 0.66666666666666666667 3.3660254037844386468 1.6188925298220266685 + 4.4428829381583662470*I
> ca_print_repr
• 7 2/3 (a+5)/2 where a = [a^2-3=0] a*c+b*c*d where a = Log(b), b = Pi, c = [c^2-2=0], d = [d^2+1=0]
> ca_print_debug
• 7 0.666667 {2/3 in QQ} 3.36603 {(a+5)2 in QQ(a)a^2-3 where a = 1.73205 [a^2-3=0]} 1.61889 + 4.44288*I {a*c+b*c*d in QQ(a,b,c,d)/d^2+1 where a = 1.14473 [Log(3.14159 {b in QQ(b)})], b = 3.14159 [Pi], c = 1.41421 [c^2-2=0], d = I [d^2+1=0]}

# Print

ca_print :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_print x ctx

Prints x to standard output.

ca_fprint fp x ctx

Prints x to the file fp.

ca_get_str x ctx

Prints x to a string which is returned. The user should free this string by calling flint_free.

ca_printn :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #

ca_printn x n ctx

Prints an n-digit numerical representation of x to standard output.

# Special values

ca_zero :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_zero res ctx

ca_one :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_one res ctx

ca_neg_one res ctx

Sets res to the integer 0, 1 or -1. This creates a canonical representation of this number as an element of the trivial field $$\mathbb{Q}$$.

ca_i :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_i res ctx

ca_neg_i :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_neg_i res ctx

Sets res to the imaginary unit $$i = \sqrt{-1}$$, or its negation $$-i$$. This creates a canonical representation of $$i$$ as the generator of the algebraic number field $$\mathbb{Q}(i)$$.

ca_pi :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_pi res ctx

Sets res to the constant $$\pi$$. This creates an element of the transcendental number field $$\mathbb{Q}(\pi)$$.

ca_pi_i :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_pi_i res ctx

Sets res to the constant $$\pi i$$. This creates an element of the composite field $$\mathbb{Q}(i,\pi)$$ rather than representing $$\pi i$$ (or even $$2 \pi i$$, which for some purposes would be more elegant) as an atomic quantity.

ca_euler :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_euler res ctx

Sets res to Euler's constant $$\gamma$$. This creates an element of the (transcendental?) number field $$\mathbb{Q}(\gamma)$$.

ca_unknown res ctx

Sets res to the meta-value Unknown.

ca_undefined res ctx

Sets res to Undefined.

ca_uinf :: Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_uinf res ctx

Sets res to unsigned infinity $${\tilde \infty}$$.

ca_pos_inf res ctx

ca_neg_inf res ctx

ca_pos_i_inf res ctx

ca_neg_i_inf res ctx

Sets res to the signed infinity $$+\infty$$, $$-\infty$$, $$+i \infty$$ or $$-i \infty$$.

# Assignment and conversion

ca_set :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_set res x ctx

Sets res to a copy of x.

ca_set_si :: Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #

ca_set_si res v ctx

ca_set_ui :: Ptr CCa -> CULong -> Ptr CCaCtx -> IO () Source #

ca_set_ui res v ctx

ca_set_fmpz res v ctx

ca_set_fmpq res v ctx

Sets res to the integer or rational number v. This creates a canonical representation of this number as an element of the trivial field $$\mathbb{Q}$$.

ca_set_d :: Ptr CCa -> CDouble -> Ptr CCaCtx -> IO () Source #

ca_set_d res x ctx

ca_set_d_d :: Ptr CCa -> CDouble -> CDouble -> Ptr CCaCtx -> IO () Source #

ca_set_d_d res x y ctx

Sets res to the value of x, or the complex value $$x + yi$$. NaN is interpreted as Unknown (not Undefined).

ca_transfer res res_ctx src src_ctx

Sets res to src where the corresponding context objects res_ctx and src_ctx may be different.

This operation preserves the mathematical value represented by src, but may result in a different internal representation depending on the settings of the context objects.

# Conversion of algebraic numbers

ca_set_qqbar res x ctx

Sets res to the algebraic number x.

If x is rational, res is set to the canonical representation as an element in the trivial field $$\mathbb{Q}$$.

If x is irrational, this function always sets res to an element of a univariate number field $$\mathbb{Q}(a)$$. It will not, for example, identify $$\sqrt{2} + \sqrt{3}$$ as an element of $$\mathbb{Q}(\sqrt{2}, \sqrt{3})$$. However, it may attempt to find a simpler number field than that generated by x itself. For example:

• If x is quadratic, it will be expressed as an element of $$\mathbb{Q}(\sqrt{N})$$ where N has no small repeated factors (obtained by performing a smooth factorization of the discriminant).
• TODO: if possible, coerce x to a low-degree cyclotomic field.

ca_get_fmpz res x ctx

ca_get_fmpq res x ctx

ca_get_qqbar res x ctx

Attempts to evaluate x to an explicit integer, rational or algebraic number. If successful, sets res to this number and returns 1. If unsuccessful, returns 0.

The conversion certainly fails if x does not represent an integer, rational or algebraic number (respectively), but can also fail if x is too expensive to compute under the current evaluation limits. In particular, the evaluation will be aborted if an intermediate algebraic number (or more precisely, the resultant polynomial prior to factorization) exceeds CA_OPT_QQBAR_DEG_LIMIT or the coefficients exceed some multiple of CA_OPT_PREC_LIMIT. Note that evaluation may hit those limits even if the minimal polynomial for x itself is small. The conversion can also fail if no algorithm has been implemented for the functions appearing in the construction of x.

ca_can_evaluate_qqbar x ctx

Checks if ca_get_qqbar has a chance to succeed. In effect, this checks if all extension numbers are manifestly algebraic numbers (without doing any evaluation).

# Random generation

ca_randtest_rational res state bits ctx

Sets res to a random rational number with numerator and denominator up to bits bits in size.

ca_randtest res state depth bits ctx

Sets res to a random number generated by evaluating a random expression. The algorithm randomly selects between generating a "simple" number (a random rational number or quadratic field element with coefficients up to bits in size, or a random builtin constant), or if depth is nonzero, applying a random arithmetic operation or function to operands produced through recursive calls with depth - 1. The output is guaranteed to be a number, not a special value.

ca_randtest_special res state depth bits ctx

Randomly generates either a special value or a number.

ca_randtest_same_nf res state x bits den_bits ctx

Sets res to a random element in the same number field as x, with numerator coefficients up to bits in size and denominator up to den_bits in size. This function requires that x is an element of an absolute number field.

# Representation properties

The following functions deal with the representation of a Ca and hence can always be decided quickly and unambiguously. The return value for predicates is 0 for false and 1 for true.

ca_equal_repr x y ctx

Returns whether x and y have identical representation. For field elements, this checks if x and y belong to the same formal field (with generators having identical representation) and are represented by the same rational function within that field.

For special values, this tests equality of the special values, with Unknown handled as if it were a value rather than a meta-value: that is, Unknown = Unknown gives 1, and Unknown = y gives 0 for any other kind of value y. If neither x nor y is Unknown, then representation equality implies that x and y describe to the same mathematical value, but if either operand is Unknown, the result is meaningless for mathematical comparison.

ca_cmp_repr x y ctx

Compares the representations of x and y in a canonical sort order, returning -1, 0 or 1. This only performs a lexicographic comparison of the representations of x and y; the return value does not say anything meaningful about the numbers represented by x and y.

ca_hash_repr x ctx

Hashes the representation of x.

ca_is_unknown x ctx

Returns whether x is Unknown.

ca_is_special x ctx

Returns whether x is a special value or metavalue (not a field element).

ca_is_qq_elem x ctx

Returns whether x is represented as an element of the rational field $$\mathbb{Q}$$.

ca_is_qq_elem_zero x ctx

ca_is_qq_elem_one x ctx

ca_is_qq_elem_integer x ctx

Returns whether x is represented as the element 0, 1 or any integer in the rational field $$\mathbb{Q}$$.

ca_is_nf_elem x ctx

Returns whether x is represented as an element of a univariate algebraic number field $$\mathbb{Q}(a)$$.

ca_is_cyclotomic_nf_elem p q x ctx

Returns whether x is represented as an element of a univariate cyclotomic field, i.e. $$\mathbb{Q}(a)$$ where a is a root of unity. If p and q are not NULL and x is represented as an element of a cyclotomic field, this also sets p and q to the minimal integers with $$0 \le p < q$$ such that the generating root of unity is $$a = e^{2 \pi i p / q}$$. Note that the answer 0 does not prove that x is not a cyclotomic number, and the order q is also not necessarily the generator of the smallest cyclotomic field containing x. For the purposes of this function, only nontrivial cyclotomic fields count; the return value is 0 if x is represented as a rational number.

ca_is_generic_elem x ctx

Returns whether x is represented as a generic field element; i.e. it is not a special value, not represented as an element of the rational field, and not represented as an element of a univariate algebraic number field.

# Value predicates

ca_check_is_number x ctx

Tests if x is a number. The result is T_TRUE is x is a field element (and hence a complex number), T_FALSE if x is an infinity or Undefined, and T_UNKNOWN if x is Unknown.

ca_check_is_zero x ctx

ca_check_is_one x ctx

ca_check_is_neg_one x ctx

ca_check_is_i x ctx

ca_check_is_neg_i x ctx

Tests if x is equal to the number $$0$$, $$1$$, $$-1$$, $$i$$, or $$-i$$.

ca_check_is_algebraic x ctx

ca_check_is_rational x ctx

ca_check_is_integer x ctx

Tests if x is respectively an algebraic number, a rational number, or an integer.

ca_check_is_real x ctx

Tests if x is a real number. Warning: this returns T_FALSE if x is an infinity with real sign.

ca_check_is_negative_real x ctx

Tests if x is a negative real number. Warning: this returns T_FALSE if x is negative infinity.

ca_check_is_imaginary x ctx

Tests if x is an imaginary number. Warning: this returns T_FALSE if x is an infinity with imaginary sign.

ca_check_is_undefined x ctx

Tests if x is the special value Undefined.

ca_check_is_infinity x ctx

Tests if x is any infinity (unsigned or signed).

ca_check_is_uinf x ctx

Tests if x is unsigned infinity $${\tilde \infty}$$.

ca_check_is_signed_inf x ctx

Tests if x is any signed infinity.

ca_check_is_pos_inf x ctx

ca_check_is_neg_inf x ctx

ca_check_is_pos_i_inf x ctx

ca_check_is_neg_i_inf x ctx

Tests if x is equal to the signed infinity $$+\infty$$, $$-\infty$$, $$+i \infty$$, $$-i \infty$$, respectively.

# Comparisons

ca_check_equal x y ctx

Tests $$x = y$$ as a mathematical equality. The result is T_UNKNOWN if either operand is Unknown. The result may also be T_UNKNOWN if x and y are numerically indistinguishable and cannot be proved equal or unequal by an exact computation.

ca_check_lt x y ctx

ca_check_le x y ctx

ca_check_gt x y ctx

ca_check_ge x y ctx

Compares x and y, implementing the respective operations $$x < y$$, $$x \le y$$, $$x > y$$, $$x \ge y$$. Only real numbers and $$-\infty$$ and $$+\infty$$ are considered comparable. The result is T_FALSE (not T_UNKNOWN) if either operand is not comparable (being a nonreal complex number, unsigned infinity, or undefined).

# Field structure operations

ca_merge_fields resx resy x y ctx

Sets resx and resy to copies of x and y coerced to a common field. Both x and y must be field elements (not special values).

In the present implementation, this simply merges the lists of generators, avoiding duplication. In the future, it will be able to eliminate generators satisfying algebraic relations.

ca_condense_field res ctx

Attempts to demote the value of res to a trivial subfield of its current field by removing unused generators. In particular, this demotes any obviously rational value to the trivial field $$\mathbb{Q}$$.

This function is applied automatically in most operations (arithmetic operations, etc.).

ca_is_gen_as_ext x ctx

If x is a generator of its formal field, $$x = a_k \in \mathbb{Q}(a_1,\ldots,a_n)$$, returns a pointer to the extension number defining $$a_k$$. If x is not a generator, returns NULL.

# Arithmetic

ca_neg :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_neg res x ctx

Sets res to the negation of x. For numbers, this operation amounts to a direct negation within the formal field. For a signed infinity $$c \infty$$, negation gives $$(-c) \infty$$; all other special values are unchanged.

ca_add_ui :: Ptr CCa -> Ptr CCa -> CULong -> Ptr CCaCtx -> IO () Source #

ca_add_si :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #

ca_add :: Ptr CCa -> Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

Sets res to the sum of x and y. For special values, the following rules apply (c infty denotes a signed infinity, $$|c| = 1$$):

• $$c \infty + d \infty = c \infty$$ if $$c = d$$
• $$c \infty + d \infty = \text{Undefined}$$ if $$c \ne d$$
• $$\tilde \infty + c \infty = \tilde \infty + \tilde \infty = \text{Undefined}$$
• $$c \infty + z = c \infty$$ if $$z \in \mathbb{C}$$
• $$\tilde \infty + z = \tilde \infty$$ if $$z \in \mathbb{C}$$
• $$z + \text{Undefined} = \text{Undefined}$$ for any value z (including Unknown)

In any other case involving special values, or if the specific case cannot be distinguished, the result is Unknown.

ca_sub_fmpq res x y ctx

ca_sub_fmpz res x y ctx

ca_sub_ui :: Ptr CCa -> Ptr CCa -> CULong -> Ptr CCaCtx -> IO () Source #

ca_sub_ui res x y ctx

ca_sub_si :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #

ca_sub_si res x y ctx

ca_fmpq_sub res x y ctx

ca_fmpz_sub res x y ctx

ca_ui_sub :: Ptr CCa -> CULong -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_ui_sub res x y ctx

ca_si_sub :: Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_si_sub res x y ctx

ca_sub :: Ptr CCa -> Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_sub res x y ctx

Sets res to the difference of x and y. This is equivalent to computing $$x + (-y)$$.

ca_mul_fmpq res x y ctx

ca_mul_fmpz res x y ctx

ca_mul_ui :: Ptr CCa -> Ptr CCa -> CULong -> Ptr CCaCtx -> IO () Source #

ca_mul_ui res x y ctx

ca_mul_si :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #

ca_mul_si res x y ctx

ca_mul :: Ptr CCa -> Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_mul res x y ctx

Sets res to the product of x and y. For special values, the following rules apply (c infty denotes a signed infinity, $$|c| = 1$$):

• $$c \infty \cdot d \infty = c d \infty$$
• $$c \infty \cdot \tilde \infty = \tilde \infty$$
• $$\tilde \infty \cdot \tilde \infty = \tilde \infty$$
• $$c \infty \cdot z = \operatorname{sgn}(z) c \infty$$ if $$z \in \mathbb{C} \setminus \{0\}$$
• $$c \infty \cdot 0 = \text{Undefined}$$
• $$\tilde \infty \cdot 0 = \text{Undefined}$$
• $$z \cdot \text{Undefined} = \text{Undefined}$$ for any value z (including Unknown)

In any other case involving special values, or if the specific case cannot be distinguished, the result is Unknown.

ca_inv :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_inv res x ctx

Sets res to the multiplicative inverse of x. In a univariate algebraic number field, this always produces a rational denominator, but the denominator might not be rationalized in a multivariate field. For special values and zero, the following rules apply:

• $$1 / (c \infty) = 1 / \tilde \infty = 0$$
• $$1 / 0 = \tilde \infty$$
• $$1 / \text{Undefined} = \text{Undefined}$$
• $$1 / \text{Unknown} = \text{Unknown}$$

If it cannot be determined whether x is zero or nonzero, the result is Unknown.

ca_fmpq_div res x y ctx

ca_fmpz_div res x y ctx

ca_ui_div :: Ptr CCa -> CULong -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_ui_div res x y ctx

ca_si_div :: Ptr CCa -> CLong -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_si_div res x y ctx

ca_div_fmpq res x y ctx

ca_div_fmpz res x y ctx

ca_div_ui :: Ptr CCa -> Ptr CCa -> CULong -> Ptr CCaCtx -> IO () Source #

ca_div_ui res x y ctx

ca_div_si :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #

ca_div_si res x y ctx

ca_div :: Ptr CCa -> Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_div res x y ctx

Sets res to the quotient of x and y. This is equivalent to computing $$x \cdot (1 / y)$$. For special values and division by zero, this implies the following rules (c infty denotes a signed infinity, $$|c| = 1$$):

• $$(c \infty) / (d \infty) = (c \infty) / \tilde \infty = \tilde \infty / (c \infty) = \tilde \infty / \tilde \infty = \text{Undefined}$$
• $$c \infty / z = (c / \operatorname{sgn}(z)) \infty$$ if $$z \in \mathbb{C} \setminus \{0\}$$
• $$c \infty / 0 = \tilde \infty / 0 = \tilde \infty$$
• $$z / (c \infty) = z / \tilde \infty = 0$$ if $$z \in \mathbb{C}$$
• $$z / 0 = \tilde \infty$$ if $$z \in \mathbb{C} \setminus \{0\}$$
• $$0 / 0 = \text{Undefined}$$
• $$z / \text{Undefined} = \text{Undefined}$$ for any value z (including Unknown)
• $$\text{Undefined} / z = \text{Undefined}$$ for any value z (including Unknown)

In any other case involving special values, or if the specific case cannot be distinguished, the result is Unknown.

ca_dot :: Ptr CCa -> Ptr CCa -> CInt -> Ptr CCa -> CLong -> Ptr CCa -> CLong -> CLong -> Ptr CCaCtx -> IO () Source #

ca_dot res initial subtract x xstep y ystep len ctx

Computes the dot product of the vectors x and y, setting res to $$s + (-1)^{subtract} \sum_{i=0}^{len-1} x_i y_i$$.

The initial term s is optional and can be omitted by passing NULL (equivalently, $$s = 0$$). The parameter subtract must be 0 or 1. The length len is allowed to be negative, which is equivalent to a length of zero. The parameters xstep or ystep specify a step length for traversing subsequences of the vectors x and y; either can be negative to step in the reverse direction starting from the initial pointer. Aliasing is allowed between res and s but not between res and the entries of x and y.

ca_fmpz_poly_evaluate res poly x ctx

ca_fmpq_poly_evaluate res poly x ctx

Sets res to the polynomial poly evaluated at x.

ca_fmpz_mpoly_evaluate_horner res f x mctx ctx

ca_fmpz_mpoly_evaluate res f x mctx ctx

Sets res to the multivariate polynomial f evaluated at the vector of arguments x.

ca_fmpz_mpoly_q_evaluate res f x mctx ctx

Sets res to the multivariate rational function f evaluated at the vector of arguments x.

ca_fmpz_mpoly_q_evaluate_no_division_by_zero res f x mctx ctx

ca_inv_no_division_by_zero res x ctx

These functions behave like the normal arithmetic functions, but assume (and do not check) that division by zero cannot occur. Division by zero will result in undefined behavior.

# Powers and roots

ca_sqr :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_sqr res x ctx

Sets res to the square of x.

ca_pow_fmpq res x y ctx

ca_pow_fmpz res x y ctx

ca_pow_ui :: Ptr CCa -> Ptr CCa -> CULong -> Ptr CCaCtx -> IO () Source #

ca_pow_ui res x y ctx

ca_pow_si :: Ptr CCa -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #

ca_pow_si res x y ctx

ca_pow :: Ptr CCa -> Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_pow res x y ctx

Sets res to x raised to the power y. Handling of special values is not yet implemented.

ca_pow_si_arithmetic res x n ctx

Sets res to x raised to the power n. Whereas ca_pow, ca_pow_si etc. may create $$x^n$$ as an extension number if n is large, this function always perform the exponentiation using field arithmetic.

ca_sqrt_inert res x ctx

ca_sqrt_nofactor res x ctx

ca_sqrt_factor res x flags ctx

ca_sqrt :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_sqrt res x ctx

Sets res to the principal square root of x.

For special values, the following definitions apply:

• $$\sqrt{c \infty} = \sqrt{c} \infty$$
• $$\sqrt{\tilde \infty} = \tilde \infty$$.
• Both Undefined and Unknown map to themselves.

The inert version outputs the generator in the formal field $$\mathbb{Q}(\sqrt{x})$$ without simplifying.

The factor version writes $$x = A^2 B$$ in $$K$$ where $$K$$ is the field of x, and outputs $$A \sqrt{B}$$ or $$-A \sqrt{B}$$ (whichever gives the correct sign) as an element of $$K(\sqrt{B})$$ or some subfield thereof. This factorization is only a heuristic and is not guaranteed to make $$B$$ minimal. Factorization options can be passed through to flags: see ca_factor for details.

The nofactor version will not perform a general factorization, but may still perform other simplifications. It may in particular attempt to simplify $$\sqrt{x}$$ to a single element in $$\overline{\mathbb{Q}}$$.

ca_sqrt_ui :: Ptr CCa -> CULong -> Ptr CCaCtx -> IO () Source #

ca_sqrt_ui res n ctx

Sets res to the principal square root of n.

# Complex parts

ca_abs :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_abs res x ctx

Sets res to the absolute value of x.

For special values, the following definitions apply:

• $$|c \infty| = |\tilde \infty| = +\infty$$.
• Both Undefined and Unknown map to themselves.

This function will attempt to simplify its argument through an exact computation. It may in particular attempt to simplify $$|x|$$ to a single element in $$\overline{\mathbb{Q}}$$.

In the generic case, this function outputs an element of the formal field $$\mathbb{Q}(|x|)$$.

ca_sgn :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_sgn res x ctx

Sets res to the sign of x, defined by

$$ \begin{aligned} \operatorname{sgn}(x) = \begin{cases} 0 & x = 0 \\ \frac{x}{|x|} & x \ne 0 \end{cases} \end{aligned}

for numbers. For special values, the following definitions apply:

• $$\operatorname{sgn}(c \infty) = c$$.
• $$\operatorname{sgn}(\tilde \infty) = \operatorname{Undefined}$$.
• Both Undefined and Unknown map to themselves.

This function will attempt to simplify its argument through an exact computation. It may in particular attempt to simplify $$\operatorname{sgn}(x)$$ to a single element in $$\overline{\mathbb{Q}}$$.

In the generic case, this function outputs an element of the formal field $$\mathbb{Q}(\operatorname{sgn}(x))$$.

ca_csgn :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_csgn res x ctx

Sets res to the extension of the real sign function taking the value 1 for z strictly in the right half plane, -1 for z strictly in the left half plane, and the sign of the imaginary part when z is on the imaginary axis. Equivalently, $$\operatorname{csgn}(z) = z / \sqrt{z^2}$$ except that the value is 0 when z is exactly zero. This function gives Undefined for unsigned infinity and $$\operatorname{csgn}(\operatorname{sgn}(c \infty)) = \operatorname{csgn}(c)$$ for signed infinities.

ca_arg :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_arg res x ctx

Sets res to the complex argument (phase) of x, normalized to the range $$(-\pi, +\pi]$$. The argument of 0 is defined as 0. For special values, the following definitions apply:

• $$\operatorname{arg}(c \infty) = \operatorname{arg}(c)$$.
• $$\operatorname{arg}(\tilde \infty) = \operatorname{Undefined}$$.
• Both Undefined and Unknown map to themselves.

ca_re :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_re res x ctx

Sets res to the real part of x. The result is Undefined if x is any infinity (including a real infinity).

ca_im :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_im res x ctx

Sets res to the imaginary part of x. The result is Undefined if x is any infinity (including an imaginary infinity).

ca_conj_deep res x ctx

ca_conj_shallow res x ctx

ca_conj :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_conj res x ctx

Sets res to the complex conjugate of x. The shallow version creates a new extension element $$\overline{x}$$ unless x can be trivially conjugated in-place in the existing field. The deep version recursively conjugates the extension numbers in the field of x.

ca_floor :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_floor res x ctx

Sets res to the floor function of x. The result is Undefined if x is any infinity (including a real infinity). For complex numbers, this is presently defined to take the floor of the real part.

ca_ceil :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_ceil res x ctx

Sets res to the ceiling function of x. The result is Undefined if x is any infinity (including a real infinity). For complex numbers, this is presently defined to take the ceiling of the real part.

# Exponentials and logarithms

ca_exp :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_exp res x ctx

Sets res to the exponential function of x.

For special values, the following definitions apply:

• $$e^{+\infty} = +\infty$$
• $$e^{c \infty} = \tilde \infty$$ if $$0 < \operatorname{Re}(c) < 1$$.
• $$e^{c \infty} = 0$$ if $$\operatorname{Re}(c) < 0$$.
• $$e^{c \infty} = \text{Undefined}$$ if $$\operatorname{Re}(c) = 0$$.
• $$e^{\tilde \infty} = \text{Undefined}$$.
• Both Undefined and Unknown map to themselves.

The following symbolic simplifications are performed automatically:

• $$e^0 = 1$$
• $$e^{\log(z)} = z$$
• $$e^{(p/q) \log(z)} = z^{p/q}$$ (for rational $$p/q$$)
• $$e^{(p/q) \pi i}$$ = algebraic root of unity (for small rational $$p/q$$)

In the generic case, this function outputs an element of the formal field $$\mathbb{Q}(e^x)$$.

ca_log :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_log res x ctx

Sets res to the natural logarithm of x.

For special values and at the origin, the following definitions apply:

• For any infinity, $$\log(c\infty) = \log(\tilde \infty) = +\infty$$.
• $$\log(0) = -\infty$$. The result is Unknown if deciding $$x = 0$$ fails.
• Both Undefined and Unknown map to themselves.

The following symbolic simplifications are performed automatically:

• $$\log(1) = 0$$
• $$\log\left(e^z\right) = z + 2 \pi i k$$
• $$\log\left(\sqrt{z}\right) = \tfrac{1}{2} \log(z) + 2 \pi i k$$
• $$\log\left(z^a\right) = a \log(z) + 2 \pi i k$$
• $$\log(x) = \log(-x) + \pi i$$ for negative real x

In the generic case, this function outputs an element of the formal field $$\mathbb{Q}(\log(x))$$.

# Trigonometric functions

ca_sin_cos_exponential res1 res2 x ctx

ca_sin_cos_direct res1 res2 x ctx

ca_sin_cos_tangent res1 res2 x ctx

ca_sin_cos :: Ptr CCa -> Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_sin_cos res1 res2 x ctx

Sets res1 to the sine of x and res2 to the cosine of x. Either res1 or res2 can be NULL to compute only the other function. Various representations are implemented:

• The exponential version expresses the sine and cosine in terms of complex exponentials. Simple algebraic values will simplify to rational numbers or elements of cyclotomic fields.
• The direct method expresses the sine and cosine in terms of the original functions (perhaps after applying some symmetry transformations, which may interchange sin and cos). Extremely simple algebraic values will automatically simplify to elements of real algebraic number fields.
• The tangent version expresses the sine and cosine in terms of $$\tan(x/2)$$, perhaps after applying some symmetry transformations. Extremely simple algebraic values will automatically simplify to elements of real algebraic number fields.

By default, the standard function uses the exponential representation as this typically works best for field arithmetic and simplifications, although it has the disadvantage of introducing complex numbers where real numbers would be sufficient. The behavior of the standard function can be changed using the ca_opt_trigformM context setting.

For special values, the following definitions apply:

• $$\sin(\pm i \infty) = \pm i \infty$$
• $$\cos(\pm i \infty) = +\infty$$
• All other infinities give $$\operatorname{Undefined}$$

ca_sin :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_sin res x ctx

ca_cos :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_cos res x ctx

Sets res to the sine or cosine of x. These functions are shortcuts for ca_sin_cos.

ca_tan_sine_cosine res x ctx

ca_tan_exponential res x ctx

ca_tan_direct res x ctx

ca_tan :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_tan res x ctx

Sets res to the tangent of x. The sine_cosine version evaluates the tangent as a quotient of a sine and cosine, the direct version evaluates it directly as a tangent (possibly after transforming the variable), and the exponential version evaluates it in terms of complex exponentials. Simple algebraic values will automatically simplify to elements of trigonometric or cyclotomic number fields.

By default, the standard function uses the exponential representation as this typically works best for field arithmetic and simplifications, although it has the disadvantage of introducing complex numbers where real numbers would be sufficient. The behavior of the standard function can be changed using the CA_OPT_TRIG_FORM context setting.

For special values, the following definitions apply:

• At poles, $$\tan((n+\tfrac{1}{2}) \pi) = \tilde \infty$$
• $$\tan(e^{i \theta} \infty) = +i, \quad 0 < \theta < \pi$$
• $$\tan(e^{i \theta} \infty) = -i, \quad -\pi < \theta < 0$$
• $$\tan(\pm \infty) = \tan(\tilde \infty) = \operatorname{Undefined}$$

ca_cot :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_cot res x ctx

Sets res to the cotangent x. This is equivalent to computing the reciprocal of the tangent.

ca_atan_logarithm res x ctx

ca_atan_direct res x ctx

ca_atan :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_atan res x ctx

Sets res to the inverse tangent of x.

The direct version expresses the result as an inverse tangent (possibly after transforming the variable). The logarithm version expresses it in terms of complex logarithms. Simple algebraic inputs will automatically simplify to rational multiples of $$\pi$$.

By default, the standard function uses the logarithm representation as this typically works best for field arithmetic and simplifications, although it has the disadvantage of introducing complex numbers where real numbers would be sufficient. The behavior of the standard function can be changed using the CA_OPT_TRIG_FORM context setting (exponential mode results in logarithmic forms).

For special values, the following definitions apply:

• $$\operatorname{atan}(\pm i) = \pm i \infty$$
• $$\operatorname{atan}(c \infty) = \operatorname{csgn}(c) \pi / 2$$
• $$\operatorname{atan}(\tilde \infty) = \operatorname{Undefined}$$

ca_asin_logarithm res x ctx

ca_acos_logarithm res x ctx

ca_asin_direct res x ctx

ca_acos_direct res x ctx

ca_asin :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_asin res x ctx

ca_acos :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_acos res x ctx

Sets res to the inverse sine (respectively, cosine) of x.

The direct version expresses the result as an inverse sine or cosine (possibly after transforming the variable). The logarithm version expresses it in terms of complex logarithms. Simple algebraic inputs will automatically simplify to rational multiples of $$\pi$$.

By default, the standard function uses the logarithm representation as this typically works best for field arithmetic and simplifications, although it has the disadvantage of introducing complex numbers where real numbers would be sufficient. The behavior of the standard function can be changed using the CA_OPT_TRIG_FORM context setting (exponential mode results in logarithmic forms).

The inverse cosine is presently implemented as $$\operatorname{acos}(x) = \pi/2 - \operatorname{asin}(x)$$.

# Special functions

ca_gamma :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_gamma res x ctx

Sets res to the gamma function of x.

ca_erf :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_erf res x ctx

Sets res to the error function of x.

ca_erfc :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_erfc res x ctx

Sets res to the complementary error function of x.

ca_erfi :: Ptr CCa -> Ptr CCa -> Ptr CCaCtx -> IO () Source #

ca_erfi res x ctx

Sets res to the imaginary error function of x.

# Numerical evaluation

ca_get_acb_raw res x prec ctx

Sets res to an enclosure of the numerical value of x. A working precision of prec bits is used internally for the evaluation, without adaptive refinement. If x is any special value, res is set to acb_indeterminate.

ca_get_acb :: Ptr CAcb -> Ptr CCa -> CLong -> Ptr CCaCtx -> IO () Source #

ca_get_acb res x prec ctx

ca_get_acb_accurate_parts res x prec ctx

Sets res to an enclosure of the numerical value of x. The working precision is increased adaptively to try to ensure prec accurate bits in the output. The accurate_parts version tries to ensure prec accurate bits for both the real and imaginary part separately.

The refinement is stopped if the working precision exceeds CA_OPT_PREC_LIMIT (or twice the initial precision, if this is larger). The user may call acb_rel_accuracy_bits to check is the calculation was successful.

The output is not rounded down to prec bits (to avoid unnecessary double rounding); the user may call acb_set_round when rounding is desired.

ca_get_decimal_str x digits flags ctx

Returns a decimal approximation of x with precision up to digits. The output is guaranteed to be correct within 1 ulp in the returned digits, but the number of returned digits may be smaller than digits if the numerical evaluation does not succeed.

If flags is set to 1, attempts to achieve full accuracy for both the real and imaginary parts separately.

If x is not finite or a finite enclosure cannot be produced, returns the string "?".

The user should free the returned string with flint_free.

# Rewriting and simplification

ca_rewrite_complex_normal_form res x deep ctx

Sets res to x rewritten using standardizing transformations over the complex numbers:

• Elementary functions are rewritten in terms of (complex) exponentials, roots and logarithms
• Complex parts are rewritten using logarithms, square roots, and (deep) complex conjugates
• Algebraic numbers are rewritten in terms of cyclotomic fields where applicable

If deep is set, the rewriting is applied recursively to the tower of extension numbers; otherwise, the rewriting is only applied to the top-level extension numbers.

The result is not a normal form in the strong sense (the same number can have many possible representations even after applying this transformation), but in practice this is a powerful heuristic for simplification.

# Factorization

data CaFactor Source #

Constructors

 CaFactor !(ForeignPtr CCaFactor)

#### Instances

Instances details
 Source # Instance detailsDefined in Data.Number.Flint.Calcium.Ca.FFI MethodspokeElemOff :: Ptr CCaFactor -> Int -> CCaFactor -> IO () #peekByteOff :: Ptr b -> Int -> IO CCaFactor #pokeByteOff :: Ptr b -> Int -> CCaFactor -> IO () #poke :: Ptr CCaFactor -> CCaFactor -> IO () #

ca_factor_init fac ctx

Initializes fac and sets it to the empty factorization (equivalent to the number 1).

ca_factor_clear fac ctx

Clears the factorization structure fac.

ca_factor_one fac ctx

Sets fac to the empty factorization (equivalent to the number 1).

ca_factor_print fac ctx

Prints a description of fac to standard output.

ca_factor_insert fac base exp ctx

Inserts $$b^e$$ into fac where b is given by base and e is given by exp. If a base element structurally identical to base already exists in fac, the corresponding exponent is incremented by exp; otherwise, this factor is appended.

ca_factor_get_ca res fac ctx

Expands fac back to a single ca_t by evaluating the powers and multiplying out the result.

ca_factor res x flags ctx

Sets res to a factorization of x of the form $$x = b_1^{e_1} b_2^{e_2} \cdots b_n^{e_n}$$. Requires that x is not a special value. The type of factorization is controlled by flags, which can be set to a combination of constants in the following section.

# Factorization options

The following flags select the structural polynomial factorization to perform over formal fields $$\mathbb{Q}(a_1,\ldots,a_n)$$. Each flag in the list strictly encompasses the factorization power of the preceding flag, so it is unnecessary to pass more than one flag.

ca_factor_poly_none :: CaFactorOption Source #

ca_factor_poly_none

No polynomial factorization at all.

ca_factor_poly_content :: CaFactorOption Source #

ca_factor_poly_content

Only extract the rational content.

ca_factor_poly_sqf :: CaFactorOption Source #

ca_factor_poly_sqf

Perform a squarefree factorization in addition to extracting the rational content.

ca_factor_poly_full :: CaFactorOption Source #

ca_factor_poly_full

Perform a full multivariate polynomial factorization.

The following flags select the factorization to perform over mathbb{Z}. Integer factorization is applied if *x* is an element of mathbb{Q}, and to the extracted rational content of polynomials. Each flag in the list strictly encompasses the factorization power of the preceding flag, so it is unnecessary to pass more than one flag.

ca_factor_zz_none :: CaFactorOption Source #

ca_factor_zz_none

No integer factorization at all.

ca_factor_zz_smooth :: CaFactorOption Source #

ca_factor_zz_smooth

Perform a smooth factorization to extract small prime factors (heuristically up to CA_OPT_SMOOTH_LIMIT bits) in addition to identifying perfect powers.

ca_factor_zz_full :: CaFactorOption Source #

ca_factor_zz_full

Perform a complete integer factorization into prime numbers. This is prohibitively slow for general integers exceeding 70-80 digits.

# Context options

The options member of a CaCtx object is an array of slong values controlling simplification behavior and various other settings. The values of the array at the following indices can be changed by the user (example: ctx->options[CA_OPT_PREC_LIMIT] = 65536).

It is recommended to set options controlling evaluation only at the time when a context object is created. Changing such options later should normally be harmless, but since the update will not apply retroactively to objects that have already been computed and cached, one might not see the expected behavior. Superficial options (printing) can be changed at any time.

ca_opt_verbose :: CaOption Source #

ca_opt_verbose

Whether to print debug information. Default value: 0.

ca_opt_print_flags :: CaOption Source #

ca_opt_print_flags

Printing style. See :ref:ca-printing for details. Default value: CA_PRINT_DEFAULT.

ca_opt_mpoly_ord :: CaOption Source #

ca_opt_mpoly_ord

Monomial ordering to use for multivariate polynomials. Possible values are ORD_LEX, ORD_DEGLEX and ORD_DEGREVLEX. Default value: ORD_LEX. This option must be set before doing any computations.

ca_opt_prec_limit :: CaOption Source #

ca_opt_prec_limit

Maximum precision to use internally for numerical evaluation with Arb, and in some cases for the magntiude of exact coefficients. This parameter affects the possibility to prove inequalities and find simplifications between related extension numbers. This is not a strict limit; some calculations may use higher precision when there is a good reason to do so. Default value: 4096.

ca_opt_qqbar_deg_limit :: CaOption Source #

ca_opt_qqbar_deg_limit

Maximum degree of :type:qqbar_t elements allowed internally during simplification of algebraic numbers. This limit may be exceeded when the user provides explicit :type:qqbar_t input of higher degree. Default value: 120.

ca_opt_low_prec :: CaOption Source #

ca_opt_low_prec

Numerical precision to use for fast checks (typically, before attempting more expensive operations). Default value: 64.

ca_opt_smooth_limit :: CaOption Source #

ca_opt_smooth_limit

Size in bits for factors in smooth integer factorization. Default value: 32.

ca_opt_lll_prec :: CaOption Source #

ca_opt_lll_prec

Precision to use to find integer relations using LLL. Default value: 128.

ca_opt_pow_limit :: CaOption Source #

ca_opt_pow_limit

Largest exponent to expand powers automatically. This only applies in multivariate and transcendental fields: in number fields, CA_OPT_PREC_LIMIT applies instead. Default value: 20.

ca_opt_use_groebner :: CaOption Source #

ca_opt_use_groebner

Boolean flag for whether to use Gröbner basis computation. This flag and the following limits affect the ability to prove multivariate identities. Default value: 1.

ca_opt_groebner_length_limit :: CaOption Source #

ca_opt_groebner_length_limit

Maximum length of ideal basis allowed in Buchberger's algorithm. Default value: 100.

ca_opt_groebner_poly_length_limit :: CaOption Source #

ca_opt_groebner_poly_length_limit

Maximum length of polynomials allowed in Buchberger's algorithm. Default value: 1000.

ca_opt_groebner_poly_bits_limit :: CaOption Source #

ca_opt_groebner_poly_bits_limit

Maximum coefficient size in bits of polynomials allowed in Buchberger's algorithm. Default value: 10000.

ca_opt_vieta_limit :: CaOption Source #

ca_opt_vieta_limit

Maximum degree *n* of algebraic numbers for which to add Vieta's formulas to the reduction ideal. This must be set relatively low since the number of terms in Vieta's formulas is O(2^n) and the resulting Gröbner basis computations can be expensive. Default value: 6.

ca_opt_trig_form :: CaOption Source #

ca_opt_trig_form

Default representation of trigonometric functions.

Default value: ca_trig_exponential`.

The *exponential* representation is currently used by default as typically works best for field arithmetic and simplifications, although it has the disadvantage of introducing complex numbers where real numbers would be sufficient. This may change in the future.

The following values are possible:

ca_trig_direct :: CaOption Source #

ca_trig_direct

Use the direct functions (with some exceptions).

ca_trig_exponential :: CaOption Source #

ca_trig_exponential

Use complex exponentials.

ca_trig_sine_cosine :: CaOption Source #

ca_trig_sine_cosine

Use sines and cosines.

ca_trig_tangent :: CaOption Source #

ca_trig_tangent

Use tangents.

# Internal representation

_ca_make_field_element x new_index ctx

Changes the internal representation of x to that of an element of the field with index new_index in the context object ctx. This may destroy the value of x.

_ca_make_fmpq x ctx

Changes the internal representation of x to that of an element of the trivial field $$\mathbb{Q}$$. This may destroy the value of x.