Summations
Richard B. Kreckel
kreckel at thep.physik.uni-mainz.de
Sat Nov 17 17:18:30 CET 2001
Hi,
On Mon, 12 Nov 2001, Brandon Barker wrote:
> I've mailed this list before and have taken the advice obtained from it to
> write a numerical integration program for some of my needs, and GiNaC seems
> to be the best way for me to accomplish this. First of all, I have only had
> Calculus 2, and am just now taking the equivalent of a first semester in
> Computer Science course using C++ (self study - my high school doesn't offer
> Comp Science, and I don't know any programmers in my area, so I have to rely
> on on-line resources - like you people, sorry :-/ ) so this may explain why
> I found latter parts of the GiNaC tutorial harder to comprehend and also the
> fact that I'm somewhat new to C/C++ (though I've done a lot of reading, w/o
> much coding and hacking one tends to forget).
>
> I'm actually attempting to write my first C++ program to do Numerical
> Integration, but I'm having trouble doing this and I wanted to know if
> someone could show me the source to a simple program using GiNaC to find the
> summation (for example) of f(x)=x^2 on the interval [1,2] with n=4 (where n
> == number of intervals).
> Of course, a=1, b=2, n=4, and integrand=x^2 should all be variables excepted
> by the summation function.
>
> Once I find out how to implement something simple like this, I think I'll be
> well on my way to writing the program. Once I get it finished, I'll put it
> up on SourceForge (by finished I mean something that works and isn't too
> embarrassing).
Do you have a good reason why you want to do numerical integration in
GiNaC? GiNaC's types are meant for symbolic manipulation and much slower
than e.g. the builtin double precision. If you are aiming for higher
precision I recommend one of the many quadruple precision libraries to be
found out there. If that is still not enough, you might consider working
directly with CLN. There is a vast amount of literature on the
subject. For a start, I would recommend having a look into Numerical
Recipes by Press, Teukolsky, Vetterling and Flannery.
May I also point you to the other list where something similar was
discussed recently? The thread started with this message by Stefan:
<http://www.ginac.de/lists/ginac-devel/msg00265.html>.
But maybe your real question was misunderstood?
Regards
-richy.
--
Richard B. Kreckel
<Richard.Kreckel at Uni-Mainz.DE>
<http://wwwthep.physik.uni-mainz.de/~kreckel/>
More information about the GiNaC-list
mailing list