Converting to decimal values from fractional values of terms of a sequence
I had tried this code. Please give some code so that the sequence values can be converted to its corresponding decimal values
var('n k')
f(n)=(-3*n)+(5/n)+(4/n^2)+(1/n^3)+2
start=2
@interact()
def _(n=slider(start,30,1,8)):
print "i\tterm\tpartial sum"
print "-------------------------------------"
for i in srange(start,n+1,1):
print i,"\t",f(i),"\t",sum(f(k),k,start,i).N(digits=20)
p1 = plot(f(x), (x, start, n), color="red", fill=True)
p2 = list_plot([(i,f(i)) for i in range(start, n, 1)], color="blue")
p3 = add( [ polygon2d( [[i-.5,0],[i-.5,f(i)],[i+.5,f(i)],[i+.5,0]], alpha=.2, color="green") for i in range(start,n)])
show(p1+p2+p3,aspect_ratio=n/2)
To display inline code, use backticks. To display blocks of code or error messages, separate them by a blank line from the rest of the text, and indent them with 4 spaces, or select code lines and click the "code" button (the icon with '101 010').
For instance, typing
will produce:
Can you edit your question to do that?