Module: sage.misc.functional
These are function so that you can write foo(x) instead of x.foo() in certain common cases.
Author Log:
Module-level Functions
x) |
Return the arc cosine of x.
sage: acos(0.5) 1.0471975511965979 sage: acos(1 + I*1.0) 0.90455689430238140 - 1.0612750619050357*I
x) |
Return the additive order of
.
x) |
Return the argument of a complex number
.
sage: z = CC(1+2*i) sage: theta = arg(z) sage: cos(theta)*abs(z) 1.0000000000000002 sage: sin(theta)*abs(z) 2.0000000000000000
x) |
Return the arc sine of x.
sage: asin(0.5) 0.52359877559829893 sage: asin(1 + I*1.0) 0.66623943249251527 + 1.0612750619050357*I
x) |
Return the arc tangent of x.
sage: atan(1/2) 0.46364760900080609 sage: atan(1 + I) 1.0172219678978514 + 0.40235947810852507*I
x) |
Return the base field over which x is defined.
x) |
Return the base ring over which x is defined.
sage: R = PolynomialRing(GF(7)) sage: base_ring(R) Finite Field of size 7
x) |
Return the fixed basis of x.
sage: V = VectorSpace(QQ,3) sage: S = V.subspace([[1,2,0],[2,2,-1]]) sage: basis(S) [ (1, 0, -1), (0, 1, 1/2) ]
x) |
Return the category of x.
sage: V = VectorSpace(QQ,3) sage: category(V) Category of vector spaces over Rational Field
x) |
Return the ceiling of x.
x) |
Return the ceiling of x.
x) |
Return the characteristic polynomial of x.
sage: M = MatrixSpace(QQ,3,3) sage: A = M([1,2,3,4,5,6,7,8,9]) sage: charpoly(A) x^3 - 15*x^2 - 18*x
x) |
Return the cosine of x.
sage: z = CC(1+2*i) sage: theta = arg(z) sage: cos(theta)*abs(z) 1.0000000000000002 sage: cos(3.141592) -0.99999999999978639
n) |
sage: cyclotomic_polynomial(3) x^2 + x + 1 sage: cyclotomic_polynomial(4) x^2 + 1 sage: cyclotomic_polynomial(9) x^6 + x^3 + 1 sage: cyclotomic_polynomial(10) x^4 - x^3 + x^2 - x + 1 sage: cyclotomic_polynomial(11) x^10 + x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 + x + 1
x) |
Return the decomposition of x.
x) |
Return the numerator of x.
sage: denominator(17/11111) 11111 sage: R = PolynomialRing(RationalField(), 'x') sage: F = FractionField(R) sage: r = (x+1)/(x-1) sage: denominator(r) x - 1
x) |
Return the derivative of a polynomial x.
sage: f = cyclotomic_polynomial(10) sage: derivative(f) 4*x^3 - 3*x^2 + 2*x - 1 sage: R = PolynomialRing(GF(7)) sage: gen = R.gen(); x = gen; f = x^7 + x sage: derivative(f) 1
x) |
Return the determinant of x.
sage: M = MatrixSpace(QQ,3,3) sage: A = M([1,2,3,4,5,6,7,8,9]) sage: det(A) 0
x) |
Return the dimension of x.
sage: V = VectorSpace(QQ,3) sage: S = V.subspace([[1,2,0],[2,2,-1]]) sage: dimension(S) 2
x) |
Return the dimension of x.
sage: V = VectorSpace(QQ,3) sage: S = V.subspace([[1,2,0],[2,2,-1]]) sage: dimension(S) 2
x) |
sage: R = PolynomialRing(RationalField(), 'x'); x = R.gen() sage: S = R.quotient(x**29-17*x-1, 'alpha') sage: K = S.number_field() sage: discriminant(K) -15975100446626038280218213241591829458737190477345113376757479850566957249 523
x) |
sage: R = PolynomialRing(RationalField(), 'x'); x = R.gen() sage: S = R.quotient(x**29-17*x-1, 'alpha') sage: K = S.number_field() sage: discriminant(K) -15975100446626038280218213241591829458737190477345113376757479850566957249 523
x) |
Return the value of the exponentation function at x.
x) |
Return the prime factorization of x.
sage: factor(factorial(10)) 2^8 * 3^4 * 5^2 * 7 sage: n = next_prime(10^6); n 1000003 sage: factor(n) 1000003
x) |
Return the prime factorization of x.
sage: factor(factorial(10)) 2^8 * 3^4 * 5^2 * 7 sage: n = next_prime(10^6); n 1000003 sage: factor(n) 1000003
x) |
Return the prime factorization of x.
sage: factor(factorial(10)) 2^8 * 3^4 * 5^2 * 7 sage: n = next_prime(10^6); n 1000003 sage: factor(n) 1000003
x) |
Return the factorization of the characteristic polynomial of x.
sage: M = MatrixSpace(QQ,3,3) sage: A = M([1,2,3,4,5,6,7,8,9]) sage: fcp(A) x * (x^2 - 15*x - 18)
x) |
Return the largest integer
.
INPUT: x -- an object that has a floor method or is coercible to int OUTPUT: an Integer
sage: floor(5.4) 5 sage: floor(float(5.4)) 5
x) |
Return the generator of x.
x) |
Return the generators of x.
x, n) |
Return the n-th Hecke operator T_n acting on x.
sage: M = ModularSymbols(1,12) sage: hecke_operator(M,5) Hecke operator T_5 on Modular Symbols space of dimension 3 for Gamma_0(1) of weight 12 with sign 0 over Rational Field
) |
Return the ideal generated by x where x is an element or list.
sage: ideal(x^2-2*x+1, x^2-1) Principal ideal (x - 1) of Univariate Polynomial Ring in x over Rational Field sage: ideal([x^2-2*x+1, x^2-1]) Principal ideal (x - 1) of Univariate Polynomial Ring in x over Rational Field
x) |
Return the imaginary part of x.
x) |
Return the image of x.
sage: M = MatrixSpace(QQ,3,3) sage: A = M([1,2,3,4,5,6,7,8,9]) sage: image(A) Vector space of degree 3 and dimension 2 over Rational Field Basis matrix: [ 1 0 -1] [ 0 1 2]
x) |
Return the imaginary part of a complex number.
sage: z = CC(1+2*i) sage: imaginary(z) 2.0000000000000000 sage: imag(z) 2.0000000000000000
x, [var=maxima], [algorithm=None]) |
Return an indefinite integral of an object x.
First call x.integrate() and if that fails make an object and integrate it using maxima, maple, etc, as specified by algorithm.
sage: f = cyclotomic_polynomial(10) sage: integral(f) 1/5*x^5 - 1/4*x^4 + 1/3*x^3 - 1/2*x^2 + x
x) |
a, b) |
Integers between a and b inclusive (a and b integers).
sage: I = interval(1,3) sage: 2 in I True sage: 1 in I True sage: 4 in I False
x) |
sage: R = PolynomialRing(RationalField(), 'x') sage: is_commutative(R) True
x) |
Return whether or not an integer x is even, e.g., divisible by 2.
sage: is_even(-1) False sage: is_even(4) True sage: is_even(-2) True
x) |
sage: R = PolynomialRing(RationalField(), 'x') sage: F = FractionField(R) sage: is_field(F) True
x) |
x) |
x) |
Return whether or not x is odd. This is by definition the complement of is_even.
sage: is_odd(-2) False sage: is_odd(-3) True sage: is_odd(0) False sage: is_odd(1) True
x) |
Return an integer square root, i.e., the floor of a square root.
sage: isqrt(10) 3
x) |
Return the kernel of x.
sage: M = MatrixSpace(QQ,3,3) sage: A = M([1,2,3,4,5,6,7,8,9]) sage: kernel(A) Vector space of degree 3 and dimension 1 over Rational Field Basis matrix: [ 1 -2 1]
x) |
x, [b=None]) |
Return the log of x to the base b. The default base is e.
INPUT: x -- number b -- base (default: None, which means natural log) OUTPUT: number
Note: In Magma, the order of arguments is reversed from in SAGE, i.e., the base is given first. We use the opposite ordering, so the base can be viewed as an optional second argument.
sage: log(10,2) 3.3219280948873626 sage: log(8,2) 3.0000000000000000 sage: log(10) 2.3025850929940459 sage: log(2.718) 0.99989631572895199
x, R) |
Return the SAGE matrix over
obtained from x, if possible.
x) |
Return the minimal polynomial of x.
x) |
Return the multiplicative order of self, if self is a unit, or raise
ArithmeticError
otherwise.
x) |
Return the number of generators of x.
x) |
Return the norm of x.
sage: z = CC(1+2*i) sage: norm(z) 5.0000000000000000
x) |
Return the numerator of x.
sage: R = PolynomialRing(RationalField(), 'x') sage: F = FractionField(R) sage: r = (x+1)/(x-1) sage: numerator(r) x + 1 sage: numerator(17/11111) 17
x, [names=None]) |
sage: R, x = objgen(FractionField(Q['x'])) sage: R Fraction Field of Univariate Polynomial Ring in x over Rational Field sage: x x
x, [names=None]) |
sage: R, x = objgens(MPolynomialRing(Q,3)) sage: R Polynomial Ring in x0, x1, x2 over Rational Field sage: x (x0, x1, x2)
R) |
Return the one element of the ring R.
sage: R = PolynomialRing(RationalField(), 'x') sage: one(R)*x == x True sage: one(R) in R True
x) |
Return the order of x. If x is a ring or module element, this is the additive order of x.
sage: C = CyclicPermutationGroup(10) sage: order(C) 10 sage: F = GF(7) sage: order(F) 7
x) |
Return x.parent() if defined, or type(x) if not.
sage: Z = parent(int(5)) sage: Z(17) 17 sage: Z <type 'int'>
x, y, [var=None]) |
Return the quotient object x/y, e.g., a quotient of numbers or of a polynomial ring x by the ideal generated by y, etc.
x, y, [var=None]) |
Return the quotient object x/y, e.g., a quotient of numbers or of a polynomial ring x by the ideal generated by y, etc.
x) |
Return the rank of x.
sage: M = MatrixSpace(QQ,3,3) sage: A = M([1,2,3,4,5,6,7,8,9]) sage: rank(A) 2
x) |
Return the real part of x.
sage: z = CC(1+2*i) sage: real(z) 1.0000000000000000
x) |
Return the regulator of x.
x) |
Return the sin of x.
x) |
Return a square root of x.
sage: sqrt(10.1) 3.1780497164141406 sage: sqrt(9) 3
x) |
Return the square free part of
, i.e., a divisor
such that
,
for a perfect square
.
sage: square_free_part(100) 1 sage: square_free_part(12) 3 sage: square_free_part(10) 10
sage: x = Q['x'].0 sage: S = square_free_part(-9*x*(x-6)^7*(x-3)^2); S -9*x^2 + 54*x sage: S.factor() (-9) * (x - 6) * x
sage: f = (x^3 + x + 1)^3*(x-1); f x^10 - x^9 + 3*x^8 + 3*x^5 - 2*x^4 - x^3 - 2*x - 1 sage: g = square_free_part(f); g x^4 - x^3 + x^2 - 1 sage: g.factor() (x - 1) * (x^3 + x + 1)
x) |
Return a square root of x with the same parent as x, if possible, otherwise raise a ValueError.
sage: square_root(9) 3 sage: square_root(100) 10
x) |
Return the tangent of x.
sage: tan(3.1415) -0.000092653590058191322 sage: tan(3.1415/4) 0.99995367427815629
x) |
sage: M = MatrixSpace(QQ,3,3) sage: A = M([1,2,3,4,5,6,7,8,9]) sage: transpose(A) [1 4 7] [2 5 8] [3 6 9]
x, R) |
Return the SAGE vector over
obtained from x, if possible.
a, b) |
Iterator over the integers between a and b, inclusive.
R) |
Return the zero element of the ring R.
sage: R = PolynomialRing(RationalField(), 'x') sage: zero(R) in R True sage: zero(R)*x == zero(R) True
See About this document... for information on suggesting changes.