1 | initial version |
When you write:
sage: f = 1
You define f
as the integer 1
:
sage: f.parent()
Integer Ring
So, it is unlikely that we will define a .integral()
method for this, otherwise there will be too much methods for such a universal object. See
sage: f.<TAB>
to see how many methods there exist already for the integer 1
. So i guess there should not be a .integral()
method for integers (or Python should have a mechanism to understand that it should try the integrate
function, or something like that).
Note that x
is a symbolic expression (and an element of the symbolic ring), hence it has an .integral()
method:
sage: x.parent()
Symbolic Ring
sage: type(x)
<type 'sage.symbolic.expression.Expression'>
Now, when you write:
sage: f = 1 + x - x
There is a coercion mechanism that transforms the integer 1
as an element of the symbolic ring so that it can be added to x
, hence here f
is a symbolic expression, not an integer:
sage: f.parent()
Symbolic Ring
This is why you can apply the .integral()
method.
So, there are two ways to integrate 1
easily. First, you can use the integrate()
function:
sage: integrate(1,x,0,1)
1
Second, you can transform the integer 1 as an element of the symbolic ring:
sage: f = SR(1)
sage: f.integrate(x,0,1)
1
2 | No.2 Revision |
When you write:
sage: f = 1
You define f
as the integer 1
:
sage: f.parent()
Integer Ring
So, it is unlikely that we will define a
method for this, otherwise there will be too much methods for such a universal object. See .integral().integrate()
sage: f.<TAB>
to see how many methods there exist already for the integer 1
. So i guess there should not be a
method for integers (or Python should have a mechanism to understand that it should try the .integral().integrate()integrate
function, or something like that).
Note that x
is a symbolic expression (and an element of the symbolic ring), hence it has an
method:.integral().integrate()
sage: x.parent()
Symbolic Ring
sage: type(x)
<type 'sage.symbolic.expression.Expression'>
Now, when you write:
sage: f = 1 + x - x
There is a coercion mechanism that transforms the integer 1
as an element of the symbolic ring so that it can be added to x
, hence here f
is a symbolic expression, not an integer:
sage: f.parent()
Symbolic Ring
This is why you can apply the
method..integral().integrate()
So, there are two ways to integrate 1
easily. First, you can use the integrate()
function:
sage: integrate(1,x,0,1)
1
Second, you can transform the integer 1 as an element of the symbolic ring:
sage: f = SR(1)
sage: f.integrate(x,0,1)
1