Ask Your Question

TypeError: non-integral exponents not supported

Being new to Sage, I can't understand this error "TypeError: non-integral exponents not supported". This is raised by "find_root" in the following code snippet:

R.<x>=RR[]
n=1000
betas=[0.01,0.03,0.05,0.07,0.99,0.91]
#for beta in betas:
#for beta in srange(0.01,0.09,0.02):
for beta in srange(0.91,0.99,0.02):
f=x^n - 3*x^(n-1)+x^(n-2)+x^(n-3)-2*x^(n-beta*n-1)-3^(beta*n)
find_root(f, 1,4);


But what is strange for me is that if I replace the "for" line with one of the commented line, then it works well. So I think there must be some Sage concepts that I haven't been aware of.

Thanks for your help!

edit retag close merge delete

2 answers

Sort by » oldest newest most voted

You declare R.<x>=RR[] but this invokes the normal polynomial ring with positive integer exponents. You should use symbolics for your numeric purposes, as tmonteil has shown to you.

In fact, in mathematics there exist polynomial rings with other type of exponents:

more

Does the following help (if not, ask for more) ?

sage: for beta in srange(0.91,0.99,0.02):
....:     print n-beta*n-1
....:
89.0000000000000
69.0000000000000
48.9999999999999
28.9999999999999


a numerical noise that can be fixed as follows:

sage: for beta in srange(0.91,0.99,0.02):
....:     print round(n-beta*n-1)
89
69
49
29

more

Your Answer

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

Add Answer

Stats

Asked: 2015-05-05 04:47:27 -0600

Seen: 418 times

Last updated: May 05 '15