X = [0.6, 0.7, 0.8, 1] f(x) = sin(e^(x) - 2) Y = [0,0,0,0] for j in(0..3): Y[j] = round(f(X[j]),8) L0(x) = (x-X[1])*(x-X[2])*(x-X[3])/((X[0] - X[1])*(X[0]-X[2])*(X[0] -X[3])) L1(x) = (x-X[0])*(x-X[2])*(x-X[3])/((X[1] - X[0])*(X[1]-X[2])*(X[1] -X[3])) L2(x) = (x-X[0])*(x-X[1])*(x-X[3])/((X[2] - X[0])*(X[2]-X[1])*(X[2] -X[3])) L3(x) = (x-X[0])*(x-X[1])*(x-X[2])/((X[3] - X[0])*(X[3]-X[1])*(X[3] -X[2])) P(x) = Y[0]*L0(x) + Y[1]*L1(x) + Y[2]*L2(x) + Y[3]*L3(x) p = plot(P(x), 0.5,1.1,x,color = 'red') q = plot(f(x),0.5,1.1,x,color = 'blue') show(expand(P(x))) show(p+q)
−1.78574124999995x3+4.70928062499987x2−1.94720472499990x−0.318242680000020
show(P(0.9)) show(f(0.9)) abserror = abs(P(0.9) - f(0.9)) relerror = abserror/abs(f(0.9)) show(abserror) show(relerror)
0.441985002500000
0.443592438770281
0.00160743627028176
0.00362367824559378
f4(x) = diff(f(x),x,4) show(f4(x))
−6cos(ex−2)e(3x)+cos(ex−2)ex+e(4x)sin(ex−2)−7e(2x)sin(ex−2)
P = plot(f4(x),0.5,1.1,x) show(P) round(f4(1),8)
-86.80037916
90*(0.9 - 0.6)*(0.9-0.7)*(0.9-0.8)*(0.9-1)/24
-0.00225000000000000