

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Trapezoid rule for numerical analysis
Typology: Study Guides, Projects, Research
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Practical-11 Trapezoidal rule.wxmx 1 / 2
Ques1. Integrate the following function f(x)=1/x by Trapezoidal rule on the interval [1,2]. ➔ kill(all)$a:^1.^0 ; b: 2. 0 ; f(x):= 1 /x; h:(b−a)$ 'integrate( 1 /x,x, 1 , 2 )=I:h/ 2 ·(f(a) +f(b)); 'Exact−value=exact: (integrate( 1 /x,x, 1 , 2 )); exact:float(exact); 'err=err:abs(I−exact);
(%o3) f ( x) := 1 x (%o5) (^2 ) = 0. x 1 (%o6) Exact−value=log ( 2 ) (exact) (^) 0. (%o8) err= 0. ➔ kill(all); (%o0) done
Z Practical-11 Trapezoidal rule.wxmx 2 / 2 ➔ x0:^1 ; x1: 5 / 4 ; x2: 3 / 2 ; x3: 7 / 4 ; x4: 2 ; h:(x4−x0)/ 4 ; f(x):= 1 /x; 'integrate( 1 /x,x, 1 , 2 )=I:h/ 2 ·(f(x0)+ 2 ·f(x1)+ 2 ·f(x2)+ 2 ·f(x3)+f(x4)); 'Exact−value=exact:(integrate( 1 /x,x, 1 , 2 )); exact:float(exact); 'err=err:abs(I−exact);
5
4 3
(^27)
4
1
4 (%o7) f ( x) := 1 x (%o8) 2 1 = x 1 1171 1680 (%o9) Exact−value=log ( 2 ) (exact) (^) 0. (%o11) (^) err= 0. Ques2. Integrate the following function f(x)=1/(1+x^2) by Trapezoidal rule on the interval [0,1].