| Home | Trees | Indices | Help |
|---|
|
|
object --+
|
structure.sage_object.SageObject --+
|
structure.element.Element --+
|
structure.element.ModuleElement --+
|
structure.element.RingElement --+
|
SymbolicExpression --+
|
CallableSymbolicExpression
A callable symbolic expression that knows the ordered list of
variables on which it depends.
EXAMPLES:
sage: var('a, x, y, z')
(a, x, y, z)
sage: f(x,y) = a + 2*x + 3*y + z
sage: f
(x, y) |--> z + 3*y + 2*x + a
sage: f(1,2)
z + a + 8
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from Inherited from |
|||
|
|||
|
Inherited from |
|||
|
|||
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
|
EXAMPLES:
sage: a = var('a')
sage: g(x) = sin(x) + a
sage: g.variables()
(a, x)
sage: g.args()
(x,)
sage: g(y,x,z) = sin(x) + a - a
sage: g
(y, x, z) |--> sin(x)
sage: g.args()
(y, x, z)
|
Returns an integral of \code{self}.
|
Returns an integral of \code{self}.
|
Returns the arguments of \code{self}. The order that the
variables appear in \code{self.arguments()} is the order that
is used in \code{self.__call__}.
EXAMPLES:
sage: x,y = var('x,y')
sage: f(x,y) = 2*x+y
sage: f.arguments()
(x, y)
sage: f(2)
y + 4
sage: f(2, 1)
5
sage: f(y,x) = 2*x+y
sage: f.arguments()
(y, x)
sage: f(2)
2*x + 2
sage: f(2, 1)
4
|
Returns the number of arguments of \code{self}.
EXAMPLES:
sage: a = var('a')
sage: g(x) = sin(x) + a
sage: g.number_of_arguments()
1
sage: g(x,y,z) = sin(x) - a + a
sage: g.number_of_arguments()
3
|
|
EXAMPLES:
sage: x,y,z = var('x,y,z')
sage: f = 1 + sin(x)/x + sqrt(z^2+y^2)/cosh(x)
sage: ff = f._fast_float_('x', 'y', 'z')
sage: f(1.0,2.0,3.0)
4.1780638977866...
sage: ff(1.0,2.0,3.0)
4.17806389778660...
|
Coerce to a multiprecision real number.
EXAMPLES:
sage: RealField(100)(SR(10))
10.000000000000000000000000000
|
|
|
|
|
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)
|
File: sage/structure/element.pyx (starting at line 291)
|
Finds the LaTeX representation of this expression.
EXAMPLES:
sage: f(A, t, omega, psi) = A*cos(omega*t - psi)
sage: f._latex_()
'\left(A, t, \omega, \psi \right)\ {\mapsto}\ {\cos \left( {\omega t} - \psi \right) A}'
sage: f(mu) = mu^3
sage: f._latex_()
'\mu \ {\mapsto}\ {\mu}^{3} '
|
Return the formal negative of \code{self}.
EXAMPLES:
sage: var('a,x,y')
(a, x, y)
sage: -a
-a
sage: -(x+y)
-y - x
|
EXAMPLES:
sage: var('x y z n m')
(x, y, z, n, m)
sage: f(x,n,y) = x^n + y^m; g(x,n,m,z) = x^n +z^m
sage: f + g
(x, n, m, y, z) |--> z^m + y^m + 2*x^n
sage: g + f
(x, n, m, y, z) |--> z^m + y^m + 2*x^n
sage: f(x) = x^2
sage: f+sin
x |--> sin(x) + x^2
sage: g(y) = y^2
sage: g+sin
y |--> sin(y) + y^2
sage: h = g+sin
sage: h(2)
sin(2) + 4
|
EXAMPLES:
sage: var('x,y')
(x, y)
sage: x + y
y + x
sage: x._add_(y)
y + x
|
EXAMPLES:
sage: var('x y z n m')
(x, y, z, n, m)
sage: f(x,n,y) = x^n + y^m; g(x,n,m,z) = x^n +z^m
sage: f - g
(x, n, m, y, z) |--> y^m - z^m
sage: g - f
(x, n, m, y, z) |--> z^m - y^m
|
EXAMPLES:
sage: var('x,y')
(x, y)
sage: x - y
x - y
|
EXAMPLES:
sage: var('x y z a b c n m')
(x, y, z, a, b, c, n, m)
sage: f(x) = x+2*y; g(y) = y+3*x
sage: f*(2/3)
x |--> 2*(2*y + x)/3
sage: f*g
(x, y) |--> (y + 3*x)*(2*y + x)
sage: (2/3)*f
x |--> 2*(2*y + x)/3
sage: f(x,y,z,a,b) = x+y+z-a-b; f
(x, y, z, a, b) |--> z + y + x - b - a
sage: f * (b*c)
(x, y, z, a, b) |--> b*c*(z + y + x - b - a)
sage: g(x,y,w,t) = x*y*w*t
sage: f*g
(x, y, a, b, t, w, z) |--> t*w*x*y*(z + y + x - b - a)
sage: (f*g)(2,3)
6*t*w*(z - b - a + 5)
sage: f(x,n,y) = x^n + y^m; g(x,n,m,z) = x^n +z^m
sage: f * g
(x, n, m, y, z) |--> (y^m + x^n)*(z^m + x^n)
sage: g * f
(x, n, m, y, z) |--> (y^m + x^n)*(z^m + x^n)
|
EXAMPLES:
sage: var('x,y')
(x, y)
sage: x * y
x*y
|
EXAMPLES:
sage: var('x,y,z,m,n')
(x, y, z, m, n)
sage: f(x,n,y) = x^n + y^m; g(x,n,m,z) = x^n +z^m
sage: f / g
(x, n, m, y, z) |--> (y^m + x^n)/(z^m + x^n)
sage: g / f
(x, n, m, y, z) |--> (z^m + x^n)/(y^m + x^n)
|
EXAMPLES:
sage: var('x,y')
(x, y)
sage: x / y
x/y
|
EXAMPLES:
sage: var('x,n')
(x, n)
sage: x^(n+1)
x^(n + 1)
|
Takes the variable list from another \class{CallableSymbolicExpression} object and
compares it with the current \class{CallableSymbolicExpression} object's variable list,
combining them according to the following rules:
Let \code{a} be \code{self}'s variable list, let \code{b} be
\code{y}'s variable list.
\begin{enumerate}
\item If \code{a == b}, then the variable lists are identical,
so return that variable list.
\item If \code{a} $\neq$ \code{b}, then check if the first $n$
items in \code{a} are the first $n$ items in \code{b},
or vice-versa. If so, return a list with these $n$
items, followed by the remaining items in \code{a} and
\code{b} sorted together in alphabetical order.
\end{enumerate}
Note: When used for arithmetic between \class{CallableSymbolicExpression}s,
these rules ensure that the set of \class{CallableSymbolicExpression}s will have
certain properties. In particular, it ensures that the set is
a \emph{commutative} ring, i.e., the order of the input
variables is the same no matter in which order arithmetic is
done.
INPUT:
x -- A CallableSymbolicExpression
OUTPUT:
A tuple of variables.
EXAMPLES:
sage: f(x, y, z) = sin(x+y+z)
sage: f
(x, y, z) |--> sin(z + y + x)
sage: g(x, y) = y + 2*x
sage: g
(x, y) |--> y + 2*x
sage: f._unify_args(g)
(x, y, z)
sage: g._unify_args(f)
(x, y, z)
sage: f(x, y, z) = sin(x+y+z)
sage: g(w, t) = cos(w - t)
sage: g
(w, t) |--> cos(w - t)
sage: f._unify_args(g)
(t, w, x, y, z)
sage: f(x, y, t) = y*(x^2-t)
sage: f
(x, y, t) |--> (x^2 - t)*y
sage: g(x, y, w) = x + y - cos(w)
sage: f._unify_args(g)
(x, y, t, w)
sage: g._unify_args(f)
(x, y, t, w)
sage: f*g
(x, y, t, w) |--> (x^2 - t)*y*(y + x - cos(w))
sage: f(x,y, t) = x+y
sage: g(x, y, w) = w + t
sage: f._unify_args(g)
(x, y, t, w)
sage: g._unify_args(f)
(x, y, t, w)
sage: f + g
(x, y, t, w) |--> y + x + w + t
AUTHORS:
-- Bobby Moretti, thanks to William Stein for the rules
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Thu Jul 17 04:23:30 2008 | http://epydoc.sourceforge.net |