Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This should do the job.

f=var('f')
ans=var('ans')
def T(f,n,x): 
    ans=0
    for v in range(0,n):
        ans=ans+binomial(n,v)*f(v+1)*(x)^v
    return ans

print T(f,4,x)
click to hide/show revision 2
declare f as a symbolic function, remove redundant var('ans')

This should do the job.

f=var('f')
ans=var('ans')
f=function('f')
def T(f,n,x): 
    ans=0
    for v in range(0,n):
range(n+1):
        ans=ans+binomial(n,v)*f(v+1)*(x)^v
    return ans

print T(f,4,x)