importnumpyasnpimportmatplotlib.pyplotasplt# Set parametersL=2r=L/2# Number of points and x valuesnpts=51x=np.linspace(0,L,npts)# Function definitionsf1=(1/4)*(5*(x/r)**4-3*(x/r)**5)z=(2*r-x)/rf2=-(1/4)*(5*z**4-3*z**5)+1f=np.where(x<=r,f1,f2)# First derivativedf1=(1/(4*r))*(20*(x/r)**3-15*(x/r)**4)df2=(1/(4*r))*(20*z**3-15*z**4)df=np.where(x<=r,df1,df2)# Second derivatived2f1=(1/(4*r**2))*(60*(x/r)**2-60*(x/r)**3)d2f2=-(1/(4*r**2))*(60*z**2-60*z**3)d2f=np.where(x<=r,d2f1,d2f2)# Third derivatived3f1=(1/(4*r**3))*(120*(x/r)-180*(x/r)**2)d3f2=(1/(4*r**3))*(120*z-180*z**2)d3f=np.where(x<=r,d3f1,d3f2)# Plottingplt.figure()plt.plot(x,f,'-o')plt.title('Function f')plt.figure()plt.plot(x,df,'-o')plt.title('First Derivative df')plt.figure()plt.plot(x,d2f,'-o')plt.title('Second Derivative d2f')plt.figure()plt.plot(x,d3f,'-o')plt.title('Third Derivative d3f')plt.show(block=False)# Save data to filesmooth=np.column_stack((x,f,df,d2f,d3f))np.savetxt('indscaled.dat',smooth,fmt='%f')