Package sage :: Package calculus :: Module calculus :: Class PrimitiveFunction
[hide private]
[frames] | no frames]

Class PrimitiveFunction

source code

                      object --+                    
                               |                    
structure.sage_object.SageObject --+                
                                   |                
           structure.element.Element --+            
                                       |            
         structure.element.ModuleElement --+        
                                           |        
               structure.element.RingElement --+    
                                               |    
                              SymbolicExpression --+
                                                   |
                                                  PrimitiveFunction
Known Subclasses:
Function_abs, Function_arccos, Function_arccosh, Function_arccot, Function_arccoth, Function_arccsc, Function_arccsch, Function_arcsec, Function_arcsech, Function_arcsin, Function_arcsinh, Function_arctan, Function_arctanh, Function_ceil, Function_cos, Function_cosh, Function_cot, Function_coth, Function_csc, Function_csch, Function_erf, Function_exp, Function_floor, Function_log, Function_polylog, Function_sec, Function_sech, Function_sin, Function_sinh, Function_sqrt, Function_tan, Function_tanh, SymbolicFunction

Instance Methods [hide private]
 
__init__(self, needs_braces=False)
Create a symbolic expression.
source code
 
_recursive_sub(self, kwds) source code
 
_recursive_sub_over_ring(self, kwds, ring) source code
 
plot(self, *args, **kwds)
Plot a symbolic expression.
source code
 
_is_atomic(self)
File: sage/structure/element.pyx (starting at line 497) Return True if and only if parenthesis are not required when *printing* out any of $x - s$, $x + s$, $x^s$ and $x/s$.
source code
 
tex_needs_braces(self) source code
 
__call__(self, x, *args)
EXAMPLES: sage: x,y=var('x,y') sage: f = x+y sage: f.arguments() (x, y) sage: f() y + x sage: f(3) y + 3 sage: f(3,4) 7 sage: f(2,3,4) Traceback (most recent call last): ...
source code
 
_approx_(self, x) source code
 
_complex_approx_(self, x)
Given a Python complex $x$, evaluate self and return a complex value.
source code
 
number_of_arguments(self)
Returns the number of arguments of self.
source code

Inherited from SymbolicExpression: __abs__, __cmp__, __eq__, __ge__, __gt__, __hash__, __int__, __le__, __long__, __lt__, __ne__, __nonzero__, __pow__, __str__, _add_, _axiom_init_, _complex_double_, _complex_mpfr_field_, _div_, _fast_float_, _gap_init_, _gp_init_, _integer_, _kash_init_, _macaulay2_init_, _magma_init_, _maple_init_, _mathematica_init_, _maxima_, _maxima_init_, _mpfr_, _mul_, _neg_, _octave_init_, _pari_init_, _polynomial_, _rational_, _real_double_, _real_rqdf_, _richcmp_, _singular_init_, _sub_, _sys_init_, arguments, coeff, coefficient, coefficients, coeffs, combine, conjugate, default_variable, denominator, derivative, diff, differentiate, display2d, exp_simplify, expand, expand_rational, expand_trig, factor, factor_list, find_maximum_on_interval, find_minimum_on_interval, find_root, full_simplify, function, gradient, hessian, imag, integral, integrate, inverse_laplace, laplace, limit, log_simplify, minpoly, n, nintegral, nintegrate, norm, numerator, numerical_approx, partial_fraction, poly, polynomial, power_series, radical_simplify, rational_expand, rational_simplify, real, roots, show, simplify, simplify_exp, simplify_full, simplify_log, simplify_radical, simplify_rational, simplify_trig, solve, subs, subs_expr, substitute, substitute_over_ring, taylor, trig_expand, trig_simplify, variables

Inherited from structure.element.RingElement: __div__, __idiv__, __imul__, __invert__, __mul__, __new__, __pos__, __rdiv__, __rmul__, __rpow__, __rtruediv__, __truediv__, _idiv_, _imul_, abs, additive_order, is_nilpotent, is_one, is_unit, multiplicative_order, order

Inherited from structure.element.ModuleElement: __add__, __iadd__, __isub__, __neg__, __radd__, __rsub__, __sub__, _iadd_, _ilmul_, _isub_, _lmul_, _rmul_

Inherited from structure.element.Element: __reduce__, __rxor__, __xor__, _cmp_, _im_gens_, _repr_, base_base_extend, base_base_extend_canonical_sym, base_extend, base_extend_canonical, base_extend_canonical_sym, base_extend_recursive, base_ring, category, is_zero, parent

Inherited from structure.sage_object.SageObject: __repr__, _axiom_, _gap_, _gp_, _interface_, _interface_init_, _interface_is_cached_, _kash_, _macaulay2_, _magma_, _maple_, _mathematica_, _octave_, _pari_, _r_init_, _sage_, _singular_, db, dump, dumps, rename, reset_name, save, version

Inherited from object: __delattr__, __getattribute__, __reduce_ex__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, needs_braces=False)
(Constructor)

source code 

Create a symbolic expression.

EXAMPLES:
This example is mainly for testing purposes.

We explicitly import the SymbolicExpression class.
    sage: from sage.calculus.calculus import SymbolicExpression

Then we make an instance of it.  Note that it prints as a
``generic element'', since it doesn't even have a specific
value!
    sage: a = SymbolicExpression(); a
    Generic element of a structure

It's of the right type.
    sage: type(a)
    <class 'sage.calculus.calculus.SymbolicExpression'>

And it has the right parent. 
    sage: a.parent()
    Symbolic Ring        

Overrides: SymbolicExpression.__init__
(inherited documentation)

_recursive_sub(self, kwds)

source code 
Overrides: SymbolicExpression._recursive_sub

_recursive_sub_over_ring(self, kwds, ring)

source code 
Overrides: SymbolicExpression._recursive_sub_over_ring

plot(self, *args, **kwds)

source code 

Plot a symbolic expression.

All arguments are passed onto the standard plot command. 

EXAMPLES:
This displays a straight line:
    sage: sin(2).plot((x,0,3))

This draws a red oscillatory curve:
    sage: sin(x^2).plot((x,0,2*pi), rgbcolor=(1,0,0))

Another plot using the variable theta:
    sage: var('theta')
    theta
    sage: (cos(theta) - erf(theta)).plot((theta,-2*pi,2*pi))

A very thick green plot with a frame:
    sage: sin(x).plot((x,-4*pi, 4*pi), thickness=20, rgbcolor=(0,0.7,0)).show(frame=True)

You can embed 2d plots in 3d space as follows:
    sage: plot(sin(x^2), (x,-pi, pi), thickness=2).plot3d(z = 1)

A more complicated family:
    sage: G = sum([plot(sin(n*x), (x,-2*pi, 2*pi)).plot3d(z=n) for n in [0,0.1,..1]])
    sage: G.show(frame_aspect_ratio=[1,1,1/2])

A plot involving the floor function:
    sage: plot(1.0 - x * floor(1/x), (x,0.00001,1.0))

Overrides: SymbolicExpression.plot
(inherited documentation)

_is_atomic(self)

source code 
File: sage/structure/element.pyx (starting at line 497)

Return True if and only if parenthesis are not required when
*printing* out any of $x - s$, $x + s$, $x^s$ and $x/s$.

EXAMPLES:
    sage: n = 5; n._is_atomic()
    True
    sage: n = x+1; n._is_atomic()
    False

Overrides: structure.element.Element._is_atomic
(inherited documentation)

__call__(self, x, *args)
(Call operator)

source code 

EXAMPLES:
    sage: x,y=var('x,y')
    sage: f = x+y
    sage: f.arguments()
    (x, y)
    sage: f()
    y + x
    sage: f(3)
    y + 3
    sage: f(3,4)
    7
    sage: f(2,3,4)
    Traceback (most recent call last):
    ...
    ValueError: the number of arguments must be less than or equal to 2

    sage: f({x:3})
    y + 3
    sage: f({x:3,y:4})
    7
    sage: f(x=3)
    y + 3
    sage: f(x=3,y=4)
    7

    sage: a = (2^(8/9))
    sage: a(4)
    Traceback (most recent call last):
    ...
    ValueError: the number of arguments must be less than or equal to 0


    sage: f = function('Gamma', var('z'), var('w')); f
    Gamma(z, w)
    sage: f(2)
    Gamma(2, w)
    sage: f(2,5)
    Gamma(2, 5)

Overrides: SymbolicExpression.__call__
(inherited documentation)

_complex_approx_(self, x)

source code 

Given a Python complex $x$, evaluate self and return a complex value.

EXAMPLES:
    sage: complex(cos(3*I))
    (10.067661995777771+0j)

The following fails because we and Maxima haven't implemented
erf yet for complex values:
    sage: complex(erf(3*I))
    Traceback (most recent call last):
    ...
    TypeError: unable to simplify to complex approximation

number_of_arguments(self)

source code 

Returns the number of arguments of self.

EXAMPLES:
    sage: sin.variables()
    ()
    sage: sin.number_of_arguments()
    1

Overrides: SymbolicExpression.number_of_arguments