Numerical Report
Numerical Report
Sanjida Sharmin
Lecturer,Dept of CSE
Submitted by:
Nilufar Yasmin
Id:C171271
Jannatul Ferdous Neela
Id:C171284R
Noora Jannat Sadia
Id:C181243
Project Tittle:
The velocity of a train which starts from rest is given by the following table, the time being reckoned in
minutes from the start and the speed in km/hour.
t(minutes) 2 4 6 8 10 12 14 16 18 20
v (km/hr) 16 28.8 40 46.4 51.2 32 17.6 8 3.2 0
Estimate approximately the total distance run in 20 minutes.
Method:
To solve this problem, we use Simpson’s 1/3 (one third) rule.
x 0+ 6 h
I3 = x 0+ 4 h
f (x) dx = h/3 (y4 + 4y5 + y6)
.
.
x 0 + nh
In/2 = x 0+ ( n − 2) h
f (x) dx = h/3 (yn-2 + 4yn-1 + yn)
The above formula is known as Simpson’s one-third rule on simply Simpson’s rule.
Mathematical Solution of given problem:
v =ds/dt ⇒ds= v.dt
⇒∫ds=∫ v.dt
20
s =∫ v.dt.
0
The train starts from rest, ∴ the velocity v = 0 when t = 0.
The given table of velocities can be written
t(minutes)/x 0 2 4 6 8 10 12 14 16 18 20
v (km/hr) 0 16 28.8 40 46.4 51.2 32 17.6 8 3.2 0
Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9 Y10
h = 2/60 hrs =1/30 hrs.
The Simpson’s 1/3 rule is given by
I = h/3[(y0 +y10) + 4(y1+y3+y5+y7+y9)+2(y2+y4+y6+y8)]
=1/30×3[(0+0)+4 (16+40+51.2+17.6+3.2)+2(28.8+46.4+32+8)]
=1/90[0+4×128+2×1152]
= 8.25 km.
∴ The distance run by the train in 20 minutes = 8.25 km.
Implementation:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
int a,b,n,i;
double h;
ll k=0,j=0;
cout<<"Enter the total number of the intervals : ";
cin>>n;
double x[n+5]= {0},y[n+5]= {0},e[n+5]= {0},o[n+5]= {0};
cout<<"Enter the data of the time: \n";
for(int i=1; i<=n; i++)
{
cout<<"x["<<i<<"] : ";
cin>>x[i]; // t
}
double oddsum=0,evensum=0,res=0;
for(i=0; i<j; i++)
{
oddsum +=o[i];
}
for(i=0; i<k; i++)
{
evensum +=e[i];
}
// cout<<y[n]<<endl;
cout<<"\nAfter putting values in Simpon's 1/3 rule...\n";
res= h/(3.0) *((y[0]+y[n])+ (4.0*oddsum)+ (2.0*evensum));
printf("The distance run by the train in 20 minutes,I = %.4f km\n(correct to 4 significant figures)\n",res);
return 0;
}
/*
10
2
4
6
8
10
12
14
16
18
20
16
28.8
40
46.4
51.2
32
17.6
8
3.2
0
*/
Screenshot of output:
Limitations of Simpson’s rule
1. It is obviously inaccurate, i.e. there will always be a difference between it and the actual integral (except
in some cases, such as the area under straight lines).
2. Integrals allow you to get exact answers in terms of fundamental constants, which Simpson’s method
does not allow.
3. To get a good approximation to the real integral, it is necessary (often) to use a large number of
ordinates.
Conclusion