ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 05 May 2015 18:09:02 +0200TypeError: non-integral exponents not supportedhttps://ask.sagemath.org/question/26718/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!Tue, 05 May 2015 11:47:27 +0200https://ask.sagemath.org/question/26718/typeerror-non-integral-exponents-not-supported/Answer by tmonteil for <p>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:</p>
<pre><code>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);
</code></pre>
<p>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.</p>
<p>Thanks for your help!</p>
https://ask.sagemath.org/question/26718/typeerror-non-integral-exponents-not-supported/?answer=26719#post-id-26719Does 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
Tue, 05 May 2015 12:20:42 +0200https://ask.sagemath.org/question/26718/typeerror-non-integral-exponents-not-supported/?answer=26719#post-id-26719Answer by rws for <p>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:</p>
<pre><code>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);
</code></pre>
<p>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.</p>
<p>Thanks for your help!</p>
https://ask.sagemath.org/question/26718/typeerror-non-integral-exponents-not-supported/?answer=26725#post-id-26725You 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:
- from ZZ: Laurent polynomials
- from QQ: Puiseux polynomials
- https://en.wikipedia.org/wiki/Polynomial_ring
- https://en.wikipedia.org/wiki/Laurent_polynomialTue, 05 May 2015 18:09:02 +0200https://ask.sagemath.org/question/26718/typeerror-non-integral-exponents-not-supported/?answer=26725#post-id-26725