Question
Please I need plot this python code # imports y(h) la xale import math x=0.1 h=0.1 # f1(x) def f1(x): # breaking the eq. into
Please I need plot this python code
# imports y(h) la xale import math x=0.1 h=0.1 # f1(x) def f1(x): # breaking the eq. into variables a = x**4 b = (1/2)*x**3 # forming the eq. return a - b # main if __name__ == '__main__': # printing f(h) values for different h values print(f"h =x f1(x) = {f1(x)}") # imports y^1/2 import math
# f2(x) def f2(x): # breaking the eq. into variables a = (384*x**(7/2))/(105*(math.pi ** 0.5)) b = (24*x**(5/2))/(15*(math.pi ** 0.5)) # forming the eq. return a - b # main if __name__ == '__main__': # printing f(h) values for different h values print(f"h = x f2(x) = {f2(x)}") # imports y' import math
# f3(x) def f3(x): # breaking the eq. into variables a = 4*x**3 b =(3/2)*x**2 # forming the eq. return a - b # main if __name__ == '__main__': # printing f(h) values for different h values print(f"h = x f3(x) = {f3(x)}") # imports y'' import math
# f4(h) def f4(x): # breaking the eq. into variables a = 12*x**2 b =3*x # forming the eq. return a - b # main if __name__ == '__main__': # printing f(h) values for different h values print(f"h = x f4(x) = {f4(x)}") # imports y^5/2 import math
# f5(x) def f5(x): # breaking the eq. into variables a = (32*x**(3/2))/((math.pi ** 0.5)) b = (6*x**(1/2))/((math.pi ** 0.5)) # forming the eq. return a - b # main if __name__ == '__main__': # printing f(h) values for different h values print(f"h = x f5(x) = {f5(x)}") # imports si=? la xale 0.01 equation(1) import math
# f(h) def f(h): lmda = 1 # lambda value is 1 (given) # breaking the eq. into variables a = ((12 * (math.pi ** 0.5) - 6 * (math.pi **1) * (h ** 2.5) * (lmda ** 1.5)) / ((12 * (math.pi ** 0.5)) - 6 * (math.pi ** 1) * (h ** 2.5) * (lmda ** 1.5) + 16 *(h ** 3) * (lmda ** 1.5))) * (f1(x)) b = ((3 * (math.pi ** 1) * (h ** 1.5)) / ((6 * (math.pi ** 0.5)) - 3 * (math.pi ** 1) * (h ** 2.5) * (lmda ** 1.5) + 8 *(h ** 3) * (lmda ** 1.5)))* (f2(x)) c = ((6 * (h ** 2) * (math.pi ** 0.5)) / ((6 * (math.pi ** 1.5)) - 3 * (math.pi ** 2) * (h ** 2.5) * (lmda ** 1.5) + 8 *(h ** 3) * (lmda ** 1.5))) * (f3(x)) d = ((6* (math.pi ** 1.5) *(h ** 3) - 16 * (math.pi ** 0.5) * (h ** 3.5) + 3 * (math.pi ** 1.5) *(h ** 4)) / ((6 * (math.pi ** 1.5)) - 3 * (math.pi ** 2) * (h ** 2.5) * (lmda ** 1.5) + 8 * (math.pi ** 1) * (h ** 3) * (lmda ** 1.5))) * (f4(x)) e = ((280 * (math.pi ** 1)*(h ** 3.5) + 1120 *(math.pi ** 1) *(h ** 4) - 2240 *(h ** 4) + 420*(math.pi ** 1)*(h**4.5) - 1120 *(math.pi ** 1)*(h**5)+ 384*(math.pi ** 1)*(h**6)))/ ((420 * (math.pi ** 1.5) - 210 * (math.pi ** 2) * (h ** 2.5) * (lmda ** 1.5) + 560 *(math.pi ** 1) *(h ** 3) * (lmda ** 1.5))) * (f5(x)) # forming the eq. return a + b + c + d + e # main 0000 if __name__ == '__main__': # printing f(h) values for different h values print(f"h = h f(h) = {f(h)}") #value of h naxshay hsi^1/2 equation(2) l=1 #value of lambda p=22/7 #value of pi g=((-3)*pow(h,2)*pow(l,1.5)*pow(p,0.5)+3*pow(p,0.5)*pow(h,2.5)*pow(l,1.5)+4*pow(h,3.5)*pow(l,3)-4*pow(h,4)*pow(l,3))/(3*pow(h,1)*pow(p,0.5))*f1(x) + ((-2)*pow(h,2.5)*pow(l,1.5)+2*pow(h,3)*pow(l,1.5))/(pow(h,1)*pow(p,0.5))*f2(x) + ((-1)*pow(h,3)*pow(l,1.5)+(1)*pow(h,3.5)*pow(l,1.5))/(pow(h,1))*f3(x) + ((-1)*3*pow(p,1.5)*pow(h,4)*pow(l,1.5)+3*pow(h,4.5)*pow(p,1.5)*pow(l,1.5)-4*pow(p,1)*pow(h,2.5)+12*pow(p,1)*pow(h,3)-8*pow(p,1)*pow(h,3.5))/(6*pow(p,1.5)*pow(h,1))*f4(x) + ((-1)*48*pow(h,4.5)*pow(p,1)+48*pow(h,5)*pow(p,1)+45*pow(h,3)*pow(p,1.5)-120*pow(p,0.5)*pow(h,3)-180*pow(h,3.5)*pow(p,1.5)+360*pow(h,3.5)*pow(p,0.5)-240*pow(p,0.5)*pow(h,4)+225*pow(p,1.5)*pow(h,4.5)-90*pow(p,1.5)*pow(h,5.5))/(90*pow(p,1.5)*pow(h,1))*f5(x) print("g(h) at lambda = 1 is equal to = ",g) #value of h naxshay hsi^1/2 equation(3) l=1 #value of lambda p=22/7 #value of pi i=((-1)*3*pow(h,1.5)*pow(l,1.5)*pow(p,1.5)-12*pow(p,0.5)*pow(h,2)*pow(l,1.5)+4*pow(p,1)*pow(h,3)*pow(l,1.5)-16*pow(h,3.5)*pow(l,1.5)-3*pow(p,1.5)*pow(h,1.5))/(6*pow(p,1)*pow(h,1)+3*pow(p,1.5)*pow(h,2.5)*pow(l,1.5)-12*pow(p,0.5)*pow(h,3)*pow(l,1.5))*f1(x) + ((-1)*2*pow(h,2)*pow(p,1)+8*pow(h,2.5)*pow(l,1.5)-pow(p,1.5)*pow(h,0.5))/(2*pow(p,1)*pow(h,1)+pow(p,1.5)*pow(h,2.5)*pow(l,1.5)-4*pow(p,0.5)*pow(h,3)*pow(l,1.5))* f2(x) +((-1)*3*pow(h,3.5)*pow(p,1.5)*pow(l,1.5)+12*pow(p,0.5)*pow(h,4)*pow(l,1.5)-8*pow(p,1)*pow(h,2)+4*pow(p,1)*pow(h,2)-48*pow(h,2.5)+12*pow(p,1)*pow(h,3))/(12*pow(p,1)*pow(h,1)+6*pow(p,1.5)*pow(h,2.5)*pow(l,1.5)-24*pow(p,1)*pow(h,3)*pow(l,1.5))*f4(x)+((-1)*16*pow(p,2)*pow(h,4)*pow(l,1.5)+64*pow(h,4.5)*pow(l,1.5)*pow(p,1)-40*pow(p,1.5)*pow(h,2.5)+24*pow(p,1.5)*pow(h,3)+480*pow(p,0.5)*pow(h,3)-120*pow(p,1.5)*pow(h,3.5)+400*pow(p,1.5)*pow(h,4)-192*pow(p,1.5)*pow(h,5))/(60*pow(p,2)*pow(h,1)+30*pow(p,2.5)*pow(h,2.5)*pow(l,1.5)-120*pow(p,1.5)*pow(h,3)*pow(l,1.5))*f5(x) print("i(h) at lambda = 1 is equal to = ",i) #value of h naxshay h''si'' equation(4) p=22/7 #value of pi j=(((-1)*3*pow(h,2.5)+2*pow(h,3.5))/(pow(h,2)-3*pow(h,2.5)+2*pow(h,3.5))*f4(x) - ((-1)*4*pow(h,3)+ 4*pow(h,4))/(pow(p,0.5)*pow(h,2)-3*pow(p,0.5)*pow(h,2.5)+2*pow(p,0.5)*pow(h,3.5)))*f5(x) print("j(h) is equal to = ",j) #value of h naxshay h^5/2si^5/2 equation(5) l=1 #value of lambda p=22/7 #value of pi k=((6)*pow(p,0.5)*pow(h,2.5) - 6*pow(p,0.5)*pow(h,3.5))/(6*pow(h,3.5)*pow(p,0.5) - 4*pow(p,0.5)*pow(h,2.5))*f5(h) print("k(h) at lambda = 1 is equal to = ",k) exact = f1(x) ## exact and spline Spline = f(h) error1 = abs(exact - Spline) print("error1:", error1) exact1 = f2(x) ## exact^1/2 and spline^1/2 Spline1 = g error2 = abs(exact1 - Spline1) print("error2:", error2) exact2 = f3(x) ## exact' and spline' Spline2 = i error3 = abs(exact2 - Spline2) print("error3:", error3) exact3 = f4(x) ## exacth'' and splinesi'' Spline3 = j error4 = abs(exact3 - Spline3) print("error4:", error4) exact4 = f5(x) ## h^5/2si^5/2 Spline4 = k error5 = abs(exact4 - Spline4) print("error5:", error5)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started