Hi all,

Can anybody tale me that how do i use integration in .net is there any built in facility ....if not is there kind of solution anyone have ???.... because i have resolve an equation that equation is

PT = (A/T)(1 – e-T/k2) + 1/T ∫[BMR + (MAP –BMR)(1-e-t/k1)]dt

In .net Or Sql Server 2005

I am not asking for providing code, but if anyone can post approach for it then it will be highly appreciated.

Thanks and Regards

Mayank Sharma

# Integral Calculus in .net?

Page 1 of 1## 5 Replies - 29864 Views - Last Post: 17 August 2007 - 02:11 PM

##
**Replies To:** Integral Calculus in .net?

### #3

## Re: Integral Calculus in .net?

Posted 16 August 2007 - 06:34 AM

The approach I would take to solve this problem is to write it in c# which is a .net language............, but I think you already knew that.

### #4

## Re: Integral Calculus in .net?

Posted 16 August 2007 - 06:51 PM

I assume you need to approximate the result to the nth degree.

First you need a method that will calculate the value of your integration function for any given value t. Then we need to run very fine increments of t through it to get the total area.

I was gonna write a quick snippet but it turned into a complete example with comments and everything. Sorry if any of this was already obvious!

--serializer

First you need a method that will calculate the value of your integration function for any given value t. Then we need to run very fine increments of t through it to get the total area.

I was gonna write a quick snippet but it turned into a complete example with comments and everything. Sorry if any of this was already obvious!

using System; using System.Collections.Generic; using System.Text; namespace IntegralCalculus { class Integration { // What are BMR, MAP, k1? Store their values here so they can be accessed in all your functions double k1 = 0; string BMR = "foo"; // etc. public double Function(double t) { double result = /* BMR + (MAP –BMR)(1-e-t/k1) */; return result; } public double Integrate(double start, double end, long intervals) { // Loop through values of t to call our function double value = 0; // Note: it would be more optimal to store the *increment* value here, and reuse it at every step of the loop double increment = (end - start) / (double)intervals; for (long n = 0; n < intervals; n++) { // Calculate t, interpolating linearly between start and end values // Note: it would be more computationally optimal to reuse the increment value we have already stored, // however this could be less *accurate* mathematically than recalculating it every time, because on very // large values of intervals this method could improve precision ... at least, I think! // Also notice the use of (casting) needed to allow us to combine double precision values with integer ones double t = start + ((end - start) * (double)n) / (double)intervals; // Now we call the function and fetch the result double result = Function(); // Multiply the result by the increment and add it to our value value += result * increment; } // Return the value } public double GetPT(double tStart, double tEnd, long intervals) { double finalResult = /* (A/T)(1 – e-T/k2) + Integrate(tStart,tEnd,intervals) */; return finalResult; } public void Run() { // Run the entire function for t[0,1] at 1000000000 precision and output to console Console.WriteLine(0,1,GetPT(1000000000).ToString()); } } }

--serializer

### #5

## Re: Integral Calculus in .net?

Posted 17 August 2007 - 07:45 AM

i checked out illaca's suggestion,are using the numeric integration library with the code written?

### #6

## Re: Integral Calculus in .net?

Posted 17 August 2007 - 02:11 PM

gogole, on 17 Aug, 2007 - 07:45 AM, said:

i checked out illaca's suggestion,are using the numeric integration library with the code written?

Nope it's just a structure of a program using basic C# code, that will approximate an integration. The key parts of the algorithm are /* commented */ and need to be filled in with proper math calls. I couldn't make any pointers toward that because I don't know what the different variables *are*. (I'm guessing BMR and MAP could be the areas of a polygon but I'm sure they could be plenty of other things...).

The wikipedia article seemed to suggest some alternate methods to the linear interpolation of t that I've used, but I didn't have time to read it in so much depth. It might also be possible to build in some additional compensation for losses in precision; I've seen writings on such subjects elsewhere.

What makTSPL seemed to be after was an *approach* so I thought I'd outline the framework

*I'd*use to solve such a problem.

It's a long while since I've looked at calculus so it was a good refresher ...

--serializer

Page 1 of 1