︠e40926e9-be02-426d-ba2b-0a5517cfd987s︠
# Turn on typeset mode
%typeset_mode True
︡342529ab-99bf-46f1-a84e-d903b57e2768︡{"done":true}︡
︠7bdf8f41-6476-4c57-bc0a-ce3603e51fcbs︠
# Define a power series
a(n) = x^n/2^n
︡efc05c22-fb40-410a-b03e-48692b2b2460︡{"done":true}︡
︠927397eb-0cfb-43ca-88fb-3207d432657e︠
# Define partial sums - note the 0!!!
def s(k):
return sum([a(i) for i in [0..k]])
︡29d86035-e0d9-4f63-b291-4c6ecb35d5c5︡{"done":true}︡
︠23b997d6-0f83-452a-a7b3-06ed51b14402s︠
s(5)
︡abeac0be-b57c-432c-a4fc-8231498e755d︡{"html":"
$\\displaystyle \\frac{1}{32} \\, x^{5} + \\frac{1}{16} \\, x^{4} + \\frac{1}{8} \\, x^{3} + \\frac{1}{4} \\, x^{2} + \\frac{1}{2} \\, x + 1$
"}︡{"done":true}︡
︠bec85632-17c8-4cba-b269-e355c21f92das︠
# Plot s(5) from -5 to 5
plot(s(5), (-5,5))
︡39b3b130-f5d3-40bf-857c-50e5469e87d7︡{"file":{"filename":"/home/user/.sage/temp/project-b77609be-996b-4af3-9755-045b7590854d/127/tmp_I894U8.svg","show":true,"text":null,"uuid":"9cd48f2b-d87b-46a1-b5b3-85fd6482ea27"},"once":false}︡{"done":true}︡
︠6c3307c0-2a2d-457d-91fd-f9ee529470b4s︠
# Plot a bunch of partial sums
plot(s(0))+plot(s(1))+plot(s(2))
︡6b356da2-268f-4410-94dc-990a07584269︡{"file":{"filename":"/home/user/.sage/temp/project-b77609be-996b-4af3-9755-045b7590854d/127/tmp_8Cp5zf.svg","show":true,"text":null,"uuid":"229eb27e-3562-47ca-8e81-56eb02230f4c"},"once":false}︡{"done":true}︡
︠e090c177-e109-4a1f-93d3-8ad6b780d54es︠
# Quicker method
sum([plot(s(i),(-5,5)) for i in range(0,5)])
︡57df68d8-9823-4724-bee4-6e6d60542ee7︡{"file":{"filename":"/home/user/.sage/temp/project-b77609be-996b-4af3-9755-045b7590854d/127/tmp_evi5zC.svg","show":true,"text":null,"uuid":"18f7f285-b7ee-4983-9c82-03d41985aa1a"},"once":false}︡{"done":true}︡
︠a698f5c2-a4d8-4dde-8936-15942fce3c1a︠