.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

integration differentiation functions

Posted By: Chandranshu Awasthi     Posted Date: January 17, 2011    Points:2   Category :C#
Can anyone help me to find the code to calculate integration and differentiation function in .net

Responses
Author: Shweta             
Posted Date: January 17, 2011     Points: 5   

u can use the following technique for definite integrals:


using System;

namespace SimpsonMethod
{
public class Simpson
{
public static void Main()
{
int iterations = 100000;
double x, start, end, dist, sum = 0, sumT = 0;
Console.Write("Input range start: ");
start = double.Parse(Console.ReadLine());
Console.Write("Input range end: ");
end = double.Parse(Console.ReadLine());
dist = (end - start)/iterations;
for (int i = 1; i <= iterations; i++)
{
x = start + i * dist;
sumT += f(x - dist / 2);
if (i < iterations)
{
sum += f(x);
}
}
sum = (dist / 6) * (f(start) + f(end) + 2 * sum + 4 * sumT);
Console.WriteLine("Value on range [{0}, {1}] is around: {2:0.00000}", start, end, sum);
}

private static double f(double x)
{
return x*x+2*x;
}
}
}

Shweta Agashe
.Net Developer,Global Infobase Solutions.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend