Trapezoid rule for number, Study Guides, Projects, Research of Physics

Trapezoid rule for numerical analysis

Typology: Study Guides, Projects, Research

2023/2024

Uploaded on 11/27/2025

akshansh-dsc
akshansh-dsc 🇮🇳

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Practical-11 Trapezoidal rule.wxmx 1 / 2
Z
Practical-11
Trapezoidal rule
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:(ba)$ 'integrate(1/x,x,1,2)=I:h/2·(f(a)
+f(b)); 'Exactvalue=exact:
(integrate(1/x,x,1,2));
exact:float(exact);
'err=err:abs(Iexact);
(a) 1.0
(b) 2.0
(%o3) f ( x):=
1
x
(%o5)
2
1
= 0.75
x
1
(%o6)
Exact−value=log ( 2 )
(exact) 0.6931471805599453
(%o8) err= 0.05685281944005471
kill(all);
(%o0) done
For n=4
pf2

Partial preview of the text

Download Trapezoid rule for number and more Study Guides, Projects, Research Physics in PDF only on Docsity!

Practical-11 Trapezoidal rule.wxmx 1 / 2

Z

Practical-

Trapezoidal rule

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);

(a) 1.

(b) 2.

(%o3) f ( x) := 1 x (%o5) (^2 ) = 0. x 1 (%o6) Exact−value=log ( 2 ) (exact) (^) 0. (%o8) err= 0. ➔ kill(all); (%o0) done

For n=

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);

(x0) 1

5

(x1)

4 3

(x2)

(^27)

(x3)

4

(x4) 2

1

(h)

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].