Weierstrass Function in Python-List index out of range error -


I am trying to plot the code and the Weierstrass function in Python.

F (x) = a ± sin (Ï ?? k ^ (a) x) / (Ï ?? k ^ (a)) from k = 1? ???

I'm having some difficulty because I'm out of the "list index" in line = yar = yer = wer (a, (xl [i]), e)

I am not sure where I am being wrong, or if my thought process is wrong, any help would be very commendable! Thanks!

Here is the code:

  import math, pialab x0 = float (input (Enter the beginning of 'interval:')) #interval xf = float start (input (Enter the end point of the interval: ')) #interval = a = float (Enter a value for' (input ':)) #x = float (input (' Enter a value for x: ')) = Float (Enter the desired error tolerance: ')) n = int (input (' enter the number of iterations: ')) def wer (a, x, e): # is a givin number, e error Mutation is Sum1 = 0 Sum2 = 0 k = 1 while (True): #sine for PE Times of PE Times, an equation for pi times = math.sin (math.pi) * P (K, A) * (X)) / ((math.pi) * (p (k, a))) Sum2 = Sum1 + math.sin (math.pi) * pow ((k + 1), a) * (x)) / ((Math.pi) * pow ((kk11), a)) If (abdominal (Sum2-Sum1)): Break Other: K + 1 Return Sum1 def Apand (x0, xf, n): Xl = [] # Value x = yl = [] x = (xf-x0) / n # length y values ​​of each subinterval (0, (n + 1)) for y for the class = xval = x0 + ( I * dx) yval = wer (a, (xl [i]), e) # error xl.append (xval) yl.append (yval) #print i, ':', xl return xl, yl append (x , a XF, N) YellowB.Pl (XL, YL)    

Each instance Xl at the beginning of i -th element is not yet, because you add it to the loop at the end; You should execute xl.append immediately after the calculation of xvl , or simply xl [i] xv Should use> yval in the formula.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -