10.1 SAGE Functions Class

Module: sage.functions.functions

SAGE Functions Class

Author Log:

Module-level Functions

maxima_function( var, defn, repr, latex, doc)

var( s)

Class: Function

class Function
Function( self, [conversions=])

Functions: integral,$ \,$ str

str( self, [bits=None])

Return a string representation of self as a decimal number to at least the given bits of precision.

Special Functions: __abs__,$ \,$ __call__,$ \,$ __cmp__,$ \,$ __float__,$ \,$ __init__,$ \,$ __pow__,$ \,$ _add_,$ \,$ _axiom_init_,$ \,$ _div_,$ \,$ _gap_init_,$ \,$ _interface_init_,$ \,$ _kash_init_,$ \,$ _maple_init_,$ \,$ _mathematica_init_,$ \,$ _maxima_init_,$ \,$ _mpfr_,$ \,$ _mul_,$ \,$ _octave_init_,$ \,$ _pari_init_,$ \,$ _singular_init_,$ \,$ _sub_

__cmp__( self, right)

sage: s = e + pi
sage: bool(s == 0)
False
sage: t = e^2  +pi
sage: bool(s == t)
False
sage: bool(s == s)
True
sage: bool(t == t)
True
sage: bool(s < t)
True
sage: bool(t < s)
False

_interface_init_( self)

Default init string for interfaces.

_singular_init_( self)

sage: s = singular(e); s
2.71828182845905

Class: Function_arith

class Function_arith
Generic arithmetic with functions is supported.

sage: s = (pi + pi) * e + e
sage: s
2*e*pi + e
sage: RR(s)
19.7977502738062
sage: maxima(s)
2*%e*%pi+%e

sage: t = e^2 + pi + 2/3; t
pi + e^2 + 2/3
sage: RR(t)
11.1973154191871
sage: maxima(t)
%pi+%e^2+2/3
sage: t^e
(pi + e^2 + 2/3)^e
sage: RR(t^e)
710.865247688858
Function_arith( self, x, y, op)

Special Functions: __init__,$ \,$ _axiom_,$ \,$ _call_,$ \,$ _gap_init_,$ \,$ _gp_,$ \,$ _kash_,$ \,$ _latex_,$ \,$ _maple_,$ \,$ _mathematica_,$ \,$ _maxima_,$ \,$ _maxima_init_,$ \,$ _mpfr_,$ \,$ _octave_,$ \,$ _pari_,$ \,$ _real_rqdf_,$ \,$ _repr_,$ \,$ _singular_init_

_gap_init_( self)

sage: gap(e + pi)
pi + e

_gp_( self, gp)

sage: gp(e + pi)
5.859874482048838473822930855             # 32-bit
5.8598744820488384738229308546321653819   # 64-bit

_kash_( self, kash)

sage: kash(e + pi)                        # optional
5.85987448204883847382293085463

_latex_( self)

sage: latex(log2 * e + pi^2/2)
{e \log \left( 2 \right)} + \frac{{\pi}^{2} }{2}
sage: latex(NaN^3 + 1/golden_ratio)
{\text{NaN}}^{3}  + \frac{2}{\sqrt{ 5 } + 1}
sage: latex(log2 + euler_gamma + catalan + khinchin + twinprime + merten + brun)
\text{twinprime} + \text{merten} + \text{khinchin} + \gamma +
\text{catalan} + \text{brun} + \log \left( 2 \right)

_maple_( self, maple)

sage: maple(e + pi)              # optional
exp(1)+Pi

_mathematica_( self, mathematica)

sage: mathematica(e + pi)        # optional
E + Pi

_maxima_( self, maxima)

sage: maxima(e + pi)
%pi+%e

_mpfr_( self, R)

sage: RealField(100)(e + pi)
5.8598744820488384738229308546

_octave_( self, octave)

sage: octave(e + pi)                     # optional
5.85987

_pari_( self)

sage: pari(e + pi)
5.859874482048838473822930855             # 32-bit
5.8598744820488384738229308546321653819   # 64-bit

_repr_( self)

sage: log2 * e + pi^2/2
e*log(2) + pi^2/2

_singular_init_( self)

sage: singular(e + pi)
pi + e

Class: Function_at

class Function_at
Function_at( self, f, x)

Special Functions: __init__,$ \,$ _maxima_init_,$ \,$ _mpfr_,$ \,$ _real_rqdf_,$ \,$ _repr_

Class: Function_composition

class Function_composition
Function_composition( self, f, g)

Special Functions: __init__,$ \,$ _axiom_,$ \,$ _call_,$ \,$ _latex_,$ \,$ _mathematica_,$ \,$ _maxima_,$ \,$ _mpfr_,$ \,$ _repr_

Class: Function_constant

class Function_constant
Function_constant( self, x)

Special Functions: __init__,$ \,$ _call_,$ \,$ _latex_,$ \,$ _repr_

Class: Function_cos

class Function_cos
The cosine function.

sage: z = 1+2*I
sage: theta = arg(z)
sage: cos(theta)*abs(z)         # slightly random output on cygwin
1.00000000000000
sage: cos(3.141592)
-0.999999999999786
Function_cos( self)

Functions: integral

Special Functions: __init__,$ \,$ _call_,$ \,$ _latex_,$ \,$ _mpfr_,$ \,$ _repr_

Class: Function_exp

class Function_exp
Function_exp( self)

Functions: integral

Special Functions: __init__,$ \,$ _call_,$ \,$ _latex_,$ \,$ _mpfr_,$ \,$ _repr_

Class: Function_gamma

class Function_gamma
Function_gamma( self)

Functions: integral

Special Functions: __init__,$ \,$ _call_,$ \,$ _latex_,$ \,$ _mpfr_,$ \,$ _repr_

Class: Function_gen

class Function_gen
Function defined by a generic SAGE object. This makes possible symbolic expressions like the following:

sage: a = pi/2 + e
sage: a
pi/2 + e
sage: maxima(a)
%pi/2+%e
sage: RR(a)
4.28907815525394
sage: RealField(200)(a)
4.2890781552539418545916091629924139398558317933875124854544

sage: b = e + 5/7
sage: maxima(b)
%e+5/7
sage: RR(b)
3.43256754274476
Function_gen( self, x)

Functions: obj,$ \,$ str

Special Functions: __init__,$ \,$ _axiom_,$ \,$ _gap_,$ \,$ _gp_,$ \,$ _kash_,$ \,$ _latex_,$ \,$ _maple_,$ \,$ _mathematica_,$ \,$ _maxima_,$ \,$ _mpfr_,$ \,$ _octave_,$ \,$ _pari_,$ \,$ _real_rqdf_,$ \,$ _repr_,$ \,$ _singular_

Class: Function_maxima

class Function_maxima
Function_maxima( self, var, defn, repr, latex)

Functions: integral

Special Functions: __init__,$ \,$ _call_,$ \,$ _latex_,$ \,$ _mpfr_,$ \,$ _repr_,$ \,$ _x

Class: Function_polynomial

class Function_polynomial
Function_polynomial( self, f)

Special Functions: __init__,$ \,$ _call_,$ \,$ _latex_,$ \,$ _repr_

Class: Function_sin

class Function_sin
The sine function.
Function_sin( self)

Functions: integral

Special Functions: __init__,$ \,$ _call_,$ \,$ _latex_,$ \,$ _mpfr_,$ \,$ _repr_

Class: Function_var

class Function_var
Formal indeterminant.
Function_var( self, name)

Special Functions: __init__,$ \,$ _integral,$ \,$ _latex_,$ \,$ _mpfr_,$ \,$ _repr_,$ \,$ _subs

_subs( self, v)

v dictionary function_var:object

Class: FunctionRing_class

class FunctionRing_class
FunctionRing_class( self)

Functions: characteristic,$ \,$ default_precision,$ \,$ set_precision

default_precision( self)

Get the precision of the default real field used for coercing functions.

set_precision( self, prec)

Change the precision of the default real field used for coercing functions.

sage: old_prec = FunctionRing.set_precision(200)
sage: pi.str()
'3.1415926535897932384626433832795028841971693993751058209749'
sage: gap(pi)
3.1415926535897932384626433832795028841971693993751058209749
sage: _ = FunctionRing.set_precision(old_prec)
sage: pi.str()
'3.14159265358979'

Note that there seems to be no real numbers in GAP, which is why that coercion returns a GAP string.

The precision is only used when there is no way to describe the function to higher precision (or exactly) to the interface:

sage: maxima(pi)      
%pi

If we coerce into a GP/PARI session, then the resulting number will have precision the precision of that session irregardless of the default precision of FunctionRing. Note that GP/PARI precision is set in decimal digits, whereas in SAGE precisions are always in binary.

sage: gp = Gp()  # new session so as not to affect overwrite global gp session
sage: gp(pi)
3.141592653589793238462643383             # 32-bit
3.1415926535897932384626433832795028842   # 64-bit
sage: gp.eval('\p 100')
'   realprecision = 105 significant digits (100 digits displayed)'      #
32-bit
'   realprecision = 115 significant digits (100 digits displayed)'      #
64-bit
sage: gp(pi)
3.1415926535897932384626433832795028841971693993751058209749445923078164062
86208998628034825342117068
sage: _ = FunctionRing.set_precision(5)   # has no affect on gp(pi)
sage: gp(pi)
3.1415926535897932384626433832795028841971693993751058209749445923078164062
86208998628034825342117068
sage: _ = FunctionRing.set_precision(old_prec)

Special Functions: __call__,$ \,$ __init__,$ \,$ _coerce_impl,$ \,$ _latex_,$ \,$ _repr_

See About this document... for information on suggesting changes.