##### linspace not dividing equal intervals
 linspace not dividing equal intervals sheel Unladen Swallow Posts: 1 Threads: 1 Joined: Jan 2018 Reputation: Jan-16-2018, 04:28 PM (This post was last modified: Jan-16-2018, 06:51 PM by buran.) i have written a code to find out effect of order of accuracy on numerical differentiation but when i am trying to use linspace(1,epsilon,100) it is not dividing it into equal interval.here is the code and the plot for the error is also incorrect ```from numpy import * import sys import numpy as np x=1 epsilon=sys.float_info.epsilon/2.0 # machine epsilon h = np.linspace(1,epsilon,1000) e1= (((sin(x)- sin(x-h))/h-cos(x))/cos(x)) #realtive error in first order e2= (((sin(x-2*h)-4*sin(x-h)+3*sin(x))/(2*h)-cos(x))/cos(x)) #realtive error in second order e3= (((2*sin(x+h)+3*sin(x)-6*sin(x-h)+sin(x-2*h))/(6*h)-cos(x))/cos(x)) #realtive error in third order e4 = (((-sin(x-3*h)+6*sin(x-2*h)-18*sin(x-h)+10*sin(x)+3*sin(x+h))/(12*h)-cos(x))/cos(x)) print(h) import matplotlib.pyplot as plt plt.plot(h,e1,'-b',lw=3) plt.plot(h,e2,'-g',lw=3) plt.plot(h,e3,'-m',lw=3) plt.plot(h,e4,'-r',lw=3) plt.xscale('log') plt.yscale('log') plt.xlabel('h') plt.ylabel('Relative error') plt.legend(['first order','second order','third order','fourth order']) plt.title('Effect of order of accuracy on the numerical differentiation') plt.show()``` Reply

 Possibly Related Threads… Thread Author Replies Views Last Post Dividing a single column of dataframe into multiple columns based on char length darpInd 2 1,065 Mar-14-2020, 09:19 AM Last Post: scidam datetime intervals - dataframe selection (via plotted data) karlito 0 846 Nov-12-2019, 08:16 AM Last Post: karlito When dividing elements of matrix i would like the result 0 instead of inf? Koczkodan 4 1,562 Jul-22-2019, 11:40 AM Last Post: Koczkodan Confidence intervals over time with polynomial regression jjameson 0 1,803 May-16-2019, 02:22 PM Last Post: jjameson dividing by list not possible? SchroedingersLion 5 1,940 Oct-11-2018, 10:00 AM Last Post: volcano63 RNG; One variable must not be equal to another DavidRobinsons 12 3,404 Oct-10-2018, 02:43 AM Last Post: micseydel How to extract previous and current rows if their value is equal SriRajesh 5 2,453 Jun-18-2018, 08:09 PM Last Post: volcano63 Conditional If Statement: If value contains string then set another column equal to s Jack_Sparrow 2 3,415 Jun-15-2018, 03:33 PM Last Post: snippsat

Forum Jump:

### User Panel Messages ##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020