Enter the Lower Limit Value : 1 Enter the Upper Limit Value : 10 Enter the Number of Intervals : 100 Integral Value : 0.6845199
Users Online
· Guests Online: 118
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
C# Program to Find the Value of 1/(1+x2) using Simpson?s 1/3 Rule
C# Program to Find the Value of 1/(1+x2) using Simpson’s 1/3 Rule
This C# Program Finds Value of 1/(1+x2) using Simpsons 1/3 Rule. Here Simpson’s 1/3 Rule Numerical Integration is used to estimate the value of a definite integral. It works by creating an even number of intervals and fitting a parabola in each pair of intervals.
Here is source code of the C# Program to Find Value of 1/(1+x2) using Simpsons 1/3 Rule. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
-
/*
-
* C# Program to Find Value of 1/(1+x2) using Simpsons 1/3 Rule
-
*/
-
using System;
-
-
class simpson
-
{
-
float a, b;
-
int n;
-
public void readdata()
-
{
-
Console.WriteLine("Enter the Lower Limit Value : ");
-
a = Convert.ToSingle(Console.ReadLine());
-
Console.WriteLine("Enter the Upper Limit Value : ");
-
b = Convert.ToSingle(Console.ReadLine());
-
Console.WriteLine("Enter the Number of Intervals : ");
-
n = Convert.ToInt32(Console.ReadLine());
-
}
-
public void simp()
-
{
-
int i;
-
float x, sum = 0.0f, h;
-
float[] y = new float[n + 1];
-
h = (b - a) / n;
-
x = a;
-
for (i = 0; i <= n; i++)
-
{
-
y[i] = 1.0f / (1 + x * x);
-
x = x + h;
-
}
-
sum = y[0] + y[n];
-
for (i = 1; i < n - 1; i += 2)
-
{
-
sum += 4 * y[i]+2* y[i + 1];
-
-
}
-
sum = sum * h / 3.0f;
-
Console.WriteLine("Integral Value : {0} ", sum);
-
Console.ReadLine();
-
}
-
public static void Main()
-
{
-
simpson obj = new simpson();
-
obj.readdata();
-
obj.simp();
-
}
-
}
Here is the output of the C# Program:
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.