# Speeding up symbolic nested loops

Is there a way to speed up the following nested loop?

```
reset()
mylimit=100
R = PolynomialRing(RR, 'a', mylimit)
a = R.gens()
func=0
for n in range(mylimit):
for i in range(n+1):
term1=(x^i)/(i+2)
for j in range(i+1):
term2=(x^(j+1))/(2*j+1)
for k in range(n-i-j+1):
term3=a[k]*(x^k)
term4=x^((n-k-i-j))/(2*(n-k-i)+1)
func=func+term1*term2*term3*term4
```

Using declarations

and replacing divisions by integers by divisions by RDF(integers) one can finish in 3 minutes

How

`x`

is defined?@achrzesz: This really speeds up the code. Thank you!

@Max Alekseyev:

`x`

is a symbolic variable.