Ask Your Question
1

How plot methods?

asked 2020-12-07 13:04:50 +0100

Andr gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-12-07 13:11:40 +0100

tmonteil gravatar image

updated 2020-12-07 13:15:43 +0100

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'
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2020-12-07 13:04:50 +0100

Seen: 567 times

Last updated: Dec 07 '20