| Home | Trees | Indices | Help |
|---|
|
|
object --+
|
structure.sage_object.SageObject --+
|
structure.element.Element --+
|
structure.element.ModuleElement --+
|
structure.element.RingElement --+
|
SymbolicExpression --+
|
SymbolicOperation --+
|
SymbolicArithmetic
Represents the result of an arithmetic operation on $f$ and $g$.
|
|||
|
Inherited from |
|||
|
|||
|
Method for handling a function call.
EXAMPLES:
sage: x,y,z=var('x,y,z')
sage: h = sin + cos
sage: h(1)
sin(1) + cos(1)
sage: h(x)
sin(x) + cos(x)
sage: h = 3*sin
sage: h(1)
3*sin(1)
sage: h(x)
3*sin(x)
sage: (sin+cos)(1)
sin(1) + cos(1)
sage: (sin+1)(1)
sin(1) + 1
sage: (x+sin)(5)
sin(5) + 5
sage: (y+sin)(5)
sin(5) + 5
sage: (x+y+sin)(5)
y + sin(5) + 5
sage: f = x + 2*y + 3*z
sage: f(1)
3*z + 2*y + 1
sage: f(0,1)
3*z + 2
sage: f(0,0,1)
3
sage: (sqrt(2) + 17)(x+2)
Traceback (most recent call last):
...
ValueError: the number of arguments must be less than or equal to 0
sage: (I*17+3*5)(x+2)
Traceback (most recent call last):
...
ValueError: the number of arguments must be less than or equal to 0
|
EXAMPLES:
sage: var('x, y, z, w')
(x, y, z, w)
sage: f = (x - x) + y^2 - z/z + (w^2-1)/(w+1); f
y^2 + (w^2 - 1)/(w + 1) - 1
sage: f(y=10)
(w^2 - 1)/(w + 1) + 99
sage: f(w=1,y=10)
99
sage: f(y=w,w=y)
(y^2 - 1)/(y + 1) + w^2 - 1
sage: f = y^5 - sqrt(2)
sage: f(10)
100000 - sqrt(2)
sage: a = x^2; b = a(2); b
4
sage: type(b)
<class 'sage.calculus.calculus.SymbolicConstant'>
|
|
EXAMPLES:
sage: x,y = var('x,y')
sage: f = x*x-y
sage: ff = f._fast_float_('x','y')
sage: ff(2,3)
1.0
|
Convert self to the given type by converting each of the
operands to that type and doing the arithmetic.
EXAMPLES:
sage: f = sqrt(2) * cos(3); f
sqrt(2)*cos(3)
sage: f._convert(RDF)
-1.40006081534
sage: f._convert(float)
-1.4000608153399503
Converting to an int can have surprising consequences, since
Python int is ``floor'' and one individual factor can floor to 0
but the product doesn't:
sage: int(f)
-1
sage: f._convert(int)
0
sage: int(sqrt(2))
1
sage: int(cos(3))
0
TESTS:
This illustrates how the conversion works even when a type
exception is raised, since here one operand is still x (in the
unsimplified form):
sage: f = sin(0)*x
sage: f._convert(CDF)
0
|
TESTS:
sage: f=x*sin(0)
sage: float(f(x=1))
0.0
sage: w = I - I
sage: float(w)
0.0
|
EXAMPLES:
sage: complex((-2)^(1/4))
(0.840896415253714...+0.840896415253714...j)
TESTS:
sage: complex(I - I)
0j
sage: w = I-I; complex(w)
0j
sage: complex(w * x)
0j
|
EXAMPLES:
sage: RealField(200)(sqrt(2))
1.4142135623730950488016887242096980785696718753769480731767
TESTS:
sage: w = I-I; RR(w)
0.000000000000000
sage: w = I-I; RealField(200)(w)
0.00000000000000000000000000000000000000000000000000000000000
sage: RealField(200)(x*sin(0))
0.00000000000000000000000000000000000000000000000000000000000
|
EXAMPLES:
sage: CC(sqrt(2))
1.41421356237310
sage: a = sqrt(-2); a
sqrt(2)*I
sage: CC(a)
1.41421356237310*I
sage: ComplexField(200)(a)
1.4142135623730950488016887242096980785696718753769480731767*I
sage: ComplexField(100)((-1)^(1/10))
0.95105651629515357211643933338 + 0.30901699437494742410229341718*I
TESTS:
sage: CC(x*sin(0))
0
|
EXAMPLES:
sage: CDF((-1)^(1/3))
0.5 + 0.866025403784*I
Watch out -- right now Maxima algebraically simplifies the above to -1:
sage: (-1)^(1/3)
(-1)^(1/3)
So when doing this conversion it is the non-simplified form
that is converted, for efficiency purposes, which can result
in a different answer in some cases. You can always force
using the simplified form:
sage: a = (-1)^(1/3)
sage: CDF(a.simplify())
0.5 + 0.866025403784*I
TESTS:
sage: CDF(x*sin(0))
0
|
EXAMPLES:
sage: RDF(sqrt(2))
1.41421356237
TESTS:
sage: RDF(x*sin(0))
0.0
|
EXAMPLES:
sage: RQDF(sqrt(2))
1.414213562373095048801688724209698078569671875376948073176679738
TESTS:
sage: RQDF(x*sin(0))
0.000000000000000000000000000000000000000000000000000000000000000
|
Convert a symbolic expression to an algebraic number.
EXAMPLES:
sage: QQbar(sqrt(2) + sqrt(8))
[4.2426406871192847 .. 4.2426406871192857]
sage: AA(sqrt(2) ^ 4) == 4
True
sage: AA(-golden_ratio)
[-1.6180339887498950 .. -1.6180339887498946]
sage: QQbar((2*I)^(1/2))
[1.0000000000000000 .. 1.0000000000000000] + [1.0000000000000000 .. 1.0000000000000000]*I
TESTS:
sage: AA(x*sin(0))
0
sage: QQbar(x*sin(0))
0
|
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
|
TESTS:
sage: var('r')
r
sage: a = (1-1/r)^(-1); a
1/(1 - 1/r)
sage: a.derivative(r)
-1/((1 - 1/r)^2*r^2)
sage: var('a,b')
(a, b)
sage: s = 0*(1/a) + -b*(1/a)*(1 + -1*0*(1/a))*(1/(a*b + -1*b*(1/a)))
sage: s
-b/(a*(a*b - b/a))
sage: s(a=2,b=3)
-1/3
sage: -3/(2*(2*3-(3/2)))
-1/3
sage: (-1)^(1/4)
(-1)^(1/4)
sage: (-(x-1)/2)._latex_(simplify=False)
'\frac{-\left( x - 1 \right)}{2}'
|
EXAMPLES:
sage: var('x,y')
(x, y)
sage: f=(x+y)*(x-y)*(x^2-2)*(y^2-3)
sage: latex(f)
{{{\left( {x}^{2} - 2
ight) \left( x - y
ight)} \left( y + x
ight)} \left( {y}^{2} - 3
ight)}
sage: latex(cos*(x+1))
{\left( x + 1
ight) \cos}
|
|
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Thu Jul 17 04:23:30 2008 | http://epydoc.sourceforge.net |