# How plot methods?

I use

r = 1.1
r.eint().n(digits=10)


output 2.167378280

But

plot(x.eint(), x, [-1,1],frame=True)


causes error: AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'eint'

How can I plot also functions defined as methods?

edit retag close merge delete

Sort by » oldest newest most voted

The problem is that x is a symbolic expression, and it does not have a eint method. So, instead of plotting a smybolic expression, you should try to plot a Python function:

sage: def eint(x):
....:     return RR(x).eint()


Now, you can plot this function:

sage: plot(eint, [-1,1], frame=True)


Note that i had to transform x as an element of RR, because the plot function iterates over some elements of [-1,1] viewed as Pyhon floats which do not have a eint method either:

sage: float(1.1).eint()
AttributeError: 'float' object has no attribute 'eint'


You can see what happens if we omit to convert the float elements into RR:

sage: def eint_noconvert(x):
....:     return x.eint()

sage: plot(eint_noconvert, [-1,1], frame=True)
AttributeError: 'float' object has no attribute 'eint'

more