FINT

Started by
5 comments, last by HappyCoder 16 years, 11 months ago
does anybody know of a realible and fast way of calculating a definate integral? It also needs to take into account abs(). the abs really messes things up.
My current game project Platform RPG
Advertisement
Numerically or analytically?

Analytic evaluation of an expression containing moduli is often, but not always, possible by separating the integrand into terms with known sign. After doing this, all the moduli may be ironed out.

Numerical integration, on the other hand, has no problems with such badly-behaved operators. A common term for definite numerical integration is 'quadrature' - people spend their lives researching this. The general problem is balancing accuracy, speed and simplicity.

Tell us which you're after, where the data came from and what resources you have at your disposal and we'll try to suggest a good approach.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Numerical Recipes in C (Free e-Book)
-> Chapter 4: "Integration of Functions".
Quote:Original post by TheAdmiral
The general problem is balancing accuracy, speed and simplicity.

Tell us which you're after, where the data came from and what resources you have at your disposal and we'll try to suggest a good approach.


I would be mostly after accuracy. The user enters in a function and I need to be able to integrate it.
My current game project Platform RPG
Okay, that's half an answer. I'll assume that you want to integrate numerically.

Perhaps the best all-round method out there is to use Romberg's method (a generalisation of Simpson's Rule) on abscissas derived and adapted from the Chebyshev Roots. This is probably overkill for your needs. If you need a one-off calculation of a reasonably tame curve, you'll probably get away with applying the Trapezium Rule on a mesh of paranoidly high resolution. All such situations will take good care of your absolute function.

Then again, you could just ask Maple or Matlab to do it for you. Again, tell us more.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Quote:Original post by HappyCoder
Quote:Original post by TheAdmiral
The general problem is balancing accuracy, speed and simplicity.

Tell us which you're after, where the data came from and what resources you have at your disposal and we'll try to suggest a good approach.


I would be mostly after accuracy. The user enters in a function and I need to be able to integrate it.


No, I think what he wants is to take the user input of "x2</sup + sin(2x)" and generate the output of "[2x + 2cos(2x)]dx" and so on.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Quote:Original post by TheAdmiral
Okay, that's half an answer. I'll assume that you want to integrate numerically.


Sorry, I'm not being clear. I do want it numerically.

Quote:Original post by erissian
No, I think what he wants is to take the user input of "x2</sup + sin(2x)" and generate the output of "[2x + 2cos(2x)]dx" and so on.


Though thats not what I want exactly, It still could be a bonus.

[Edited by - HappyCoder on May 9, 2007 9:55:19 PM]
My current game project Platform RPG

This topic is closed to new replies.

Advertisement