Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is faster:

mylimit=100
x=var('x')
a=var('a',n=mylimit)

fun1=sum(
 [sum(
  [sum(
   [sum([a[k]*x^(n+1)/RDF(((i+2)*(2*j+1)*(2*(n-k-i)+1))) for k in range(n-i-j+1)])
    for j in range(i+1)])
     for i in range(n+1)])
      for n in range(mylimit)])

with numerically negligible differences (I hope)

This is faster:

mylimit=100
x=var('x')
a=var('a',n=mylimit)

fun1=sum(
 [sum(
  [sum(
   [sum([a[k]*x^(n+1)/RDF(((i+2)*(2*j+1)*(2*(n-k-i)+1))) for k in range(n-i-j+1)])
    for j in range(i+1)])
     for i in range(n+1)])
      for n in range(mylimit)])

with numerically negligible differences (I hope)

For those who don't like SR:

mylimit=100
R = PolynomialRing(QQ,'a',mylimit)
a = R.variable_names()
P = PolynomialRing(QQ,list(a)+['x'])
a = P.gens()[:mylimit]
x = P.gens()[mylimit]
fun1=sum(
 [sum(
  [sum(
   [sum([a[k]*x^(n+1)/((i+2)*(2*j+1)*(2*(n-k-i)+1)) for k in range(n-i-j+1)])
    for j in range(i+1)])
     for i in range(n+1)])
      for n in range(mylimit)])

This is faster:

mylimit=100
x=var('x')
a=var('a',n=mylimit)

fun1=sum(
 [sum(
  [sum(
   [sum([a[k]*x^(n+1)/RDF(((i+2)*(2*j+1)*(2*(n-k-i)+1))) for k in range(n-i-j+1)])
    for j in range(i+1)])
     for i in range(n+1)])
      for n in range(mylimit)])

with numerically negligible differences (I hope)

For those who don't like SR:

mylimit=100
R = PolynomialRing(QQ,'a',mylimit)
a = R.variable_names()
P = PolynomialRing(QQ,list(a)+['x'])
PolynomialRing(QQ,[f'a{i}' for i in range(mylimit)]+['x'])
a = P.gens()[:mylimit]
x = P.gens()[mylimit]
fun1=sum(
 [sum(
  [sum(
   [sum([a[k]*x^(n+1)/((i+2)*(2*j+1)*(2*(n-k-i)+1)) for k in range(n-i-j+1)])
    for j in range(i+1)])
     for i in range(n+1)])
      for n in range(mylimit)])