Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i am trying to plot the maclaurin series.but my suspison is on line 28. 13 def atan_series3(x, n): 14 xpower = x #variables 15 mySum

i am trying to plot the maclaurin series.but my suspison is on line 28.

image text in transcribedimage text in transcribed
13 def atan_series3(x, n): 14 xpower = x #variables 15 mySum = X 16 sign = 1 17 for i in range (1, n) : 18 xpower = xpower * x X 19 sign = -1 * sign 20 21 term = sign * xpower / (2*i + 1) mySum = mySum + term 22 return mySum 23 24 n = 10 25 26 X5 = 27 #empty list aka to help generate points ys = #empty list 28 29 dx = mySum/(n-1) #increments even spacing, since u have 10 points, there 9 spaces for i in range(n) : #aka the limit is 10-1=9 31 xs . append (i*dx) #what is append: it adds pts to the empty list 32 ys . append (atan_series3(xs [-1], n, )) #-1 is the aka end point 33 #print(f"i={i}: x={xs[-1]]") #the -1 does the last thing in the list -2 is the second one 34 import pylab 35 pylab. plot (xs, ys) 36 37 pylab. xlabel("x") 38 pylab. ylabel("y") 39 pylab. title(f"arctan Maclaurin series") 40def atan_series3(x, n) : xpower = x #variables mySum = x sign = 1 for i in range (1, n) : xpower = xpower * x sign = -1 * sign term = sign * xpower / (2*i + 1) mySum = mySum + term return mySum n = 10 X5 = #empty list aka to help generate points ys = : #empty list dx = mySum/(n-1) #increments even spacing, since u have 10 points, there 9 spaces for i in range(n) : #aka the limit is 10-1=9 xs . append(i*dx) #what is append: it adds npts to the empty list ys . append (atan_series3(xs[-1], n, )) #-1 is the aka end point #print(f"i={i]: x={xs[-1]]") #the -1 does the last thing in the list -2 is the second one import pylab pylab . plot(xs, ys) pylab. xlabel("x") pylab. ylabel("y") pylab. title(f"arctan Maclaurin series")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions