Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | jacob navia <jacob@spamsink.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Euler's constant |
| Date | 2011-11-21 15:36 +0100 |
| Organization | lccwin |
| Message-ID | <jadnll$9mr$1@speranza.aioe.org> (permalink) |
| References | <24357587.77.1321816326271.JavaMail.geo-discussion-forums@prnv30> <jaddl0$eb6$1@speranza.aioe.org> <38vpp8-qf8.ln1@voyager.wichi.de.vu> |
Le 21/11/11 14:10, Markus Wichmann a écrit :
> On 21.11.2011 12:45, jacob navia wrote:
>> Le 20/11/11 20:12, 88888 Dihedral a écrit :
>>> PROBLEM 1: COMPUTE THE EULER'S NUMBER UP TO 30 DIGITS AFTER 1.
>>> THE DIGIT REQUIRED SHOULD BE PARAMETER BY THE CALLER!
>>
>> Euler's constant is the limit of the sum when N goes to infinity of:
>>
>> 1 + 1/2 + 1/3 + 1/4 + ... 1/N - ln(n)
>>
>
> Nope., but nearly. Perhaps you want to research the "harmonic series"
> (or whatever name they gave it in english...). That series is divergent,
> the reason being: For any natural number n there is a natural number m
> so that Sum(i=0..m, 1/(n+i))> 1. So the harmonic series adds up an
> infinite number of ones and thus goes straight to Infinity. (Or rather,
> any number you care to name gets exceeded by that series eventually.)
>
> Euler's number is actually
>
> 1+ 1 + 1/2! + 1/3! + 1/4! + ...
>
> So... to calculate the Euler number you'd actually need to keep track of
> the current addend. Dunno, something like
>
> e = 2;
> factorial = 1;
> fact_arg = 2;
>
> for(;;) {
> factorial *= fact_arg++;
> addend = 1/factorial;
> e += addend;
> }
>
> Filling in the blanks and propably finding a decent library to code the
> stuff with (or writing the library yourself... it is not hard if all you
> want to do is multiplying and adding and you can wait a bit) is left as
> an excercise to the reader.
>
>> This is related to the PSI function (digamma) by
>>
>> Euler constant = -psi(1)
>>
>> This can be calculated in C with this program:
>> (Using lcc-win. Other compilers will be able to do this too
>> but in a different way)
>>
>
> So... basically you say this cannot be done in ISO C?
No, as yo say, you can write your own exteded precision floats in C.
The core of lcc-win's qfloat library is written in assembler however.
> Or is it just to
> hard?
It depends of your budget/motivation if it is too hard. In any case it
was hard for me, but I did finish it.
> Or do you want to promote yourself?
I am doing exactly that: promoting the solutions I have built in
lcc-win.
> And what the hell is psi()
> meant to be?
Well, I gave the definition above. You can also look it up in wikipedia
or in Wolfram's site if you are interested.
> My man page collection doesn't know it and it knows stuff
> like bessel functions...
>
Yes, in your machine there is no hint at psi. How bad!
HINT: Get better software for it.
Note: The technical report ISO/IEC IS 14882:1998(E) proposes a
series of mathematical functions to be added to the standard library
in an optional statistics package.
Since I am a compiler writer I follow attentively those meetings and
I have implemented most of that proposal's functions. Among them
<quote>
double digamma(double x); // psi or digamma function.
<end quote>
At the beginning the proposal was designed only for C++ but later
it was extended for C also, and much reworked.
> Basically, I think we can all agree on the fact that a normal float or
> double won't yield enough precision for thirty decimal places.
Yes. I showed 95 decimal places.
> On a
> machine using IEEE 754 floating point types, a double has fifty two
> binary places. That's 52*lg(2)~~ 15.6 decimal places. So we'd actually
> have to write a multiprecision integer (for the factorial stuff) and
> floating point library.
Yes. That is what lcc-win has done already for you.
>
>> d:\lcc\mc79\test>type teuler.c
>> #include<qfloat.h>
>> #include<specialfns.h>
>> #include<stdio.h>
>> int main(void)
>> {
>> qfloat e=psiq(1.0q);
>> printf("Euler constant is:\n%.95qf\n",-e);
>> }
>>
>
> So, not only does this program feature strange types, it also has
> unknown suffixes to literals and extensions to printf().
>
Yes.
> I don't know exactly, but I'd file this code under "Not C"!
This is only a product of your *ignorance*. If you would care to
read the ISO C standard, you would notice that there is a section
called "Common extensions" where the standard EXPLICITELY mentions:
<begin quote>
J.5 Common extensions
1 The following extensions are widely used in many systems, but are not
portable to all implementations.
[snip]
J.5.6 Other arithmetic types
1 Additional arithmetic types, such as __int128 or double double, and
their appropriate conversions are defined (6.2.5, 6.3.1). Additional
floating types may have more range or precision than long double, may be
used for evaluating expressions of other floating types, and may be used
to define float_t or double_t.
<end quote>
You do not know (or haven't read) what are you talking about.
Your only motivation is to make believe that my work is not standards
conforming, or otherwise impossible to use because of your
ideological "gut feelings"...
Like most people that attack me in this group.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-20 11:12 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Ian Collins <ian-news@hotmail.com> - 2011-11-21 08:18 +1300
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-11-20 20:22 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-20 11:23 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-20 15:03 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kaz Kylheku <kaz@kylheku.com> - 2011-11-20 20:06 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-20 12:13 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Ian Collins <ian-news@hotmail.com> - 2011-11-21 09:16 +1300
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-20 15:37 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-11-20 14:15 -0700
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-20 13:45 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-21 00:44 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-21 12:44 +0200
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-21 10:41 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 00:53 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! "io_x" <a@b.c.invalid> - 2011-11-24 19:08 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Martin Ambuhl <mambuhl@earthlink.net> - 2011-11-20 17:32 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-20 14:55 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-20 16:54 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-20 19:35 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-22 00:39 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-22 13:18 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-24 01:50 -0800
Re: Euler's constant jacob navia <jacob@spamsink.net> - 2011-11-21 12:45 +0100
Re: Euler's constant Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-11-21 13:54 +0100
Re: Euler's constant jacob navia <jacob@spamsink.net> - 2011-11-21 14:48 +0100
Re: Euler's constant Vincenzo Mercuri <vincenzo.mercuri@yahoo.it> - 2011-11-21 18:58 +0100
Re: Euler's constant Markus Wichmann <nullplan@gmx.net> - 2011-11-21 14:10 +0100
Re: Euler's constant jacob navia <jacob@spamsink.net> - 2011-11-21 15:36 +0100
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 07:08 -0800
Re: Euler's constant jacob navia <jacob@spamsink.net> - 2011-11-21 16:16 +0100
Re: Euler's constant Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-22 00:44 -0800
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-21 15:33 +0000
Re: Euler's constant Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-21 08:50 -0800
Re: Euler's constant "BartC" <bc@freeuk.com> - 2011-11-21 17:13 +0000
Re: Euler's constant James Kuyper <jameskuyper@verizon.net> - 2011-11-21 12:29 -0500
Re: Euler's constant Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-21 09:28 -0800
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-21 23:07 +0000
Re: Euler's constant Kaz Kylheku <kaz@kylheku.com> - 2011-11-21 17:29 +0000
Re: Euler's constant James Kuyper <jameskuyper@verizon.net> - 2011-11-21 12:36 -0500
Re: Euler's constant Keith Thompson <kst-u@mib.org> - 2011-11-21 13:46 -0800
Re: Euler's constant "io_x" <a@b.c.invalid> - 2011-11-24 19:08 +0100
Re: Euler's constant Markus Wichmann <nullplan@gmx.net> - 2011-11-24 20:31 +0100
Re: Euler's constant "io_x" <a@b.c.invalid> - 2011-11-27 11:24 +0100
Re: Euler's constant Markus Wichmann <nullplan@gmx.net> - 2011-11-27 12:09 +0100
Re: Euler's constant "io_x" <a@b.c.invalid> - 2011-11-27 13:33 +0100
Re: Euler's constant Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-21 10:44 -0800
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-21 22:53 +0000
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-21 23:51 +0000
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-22 04:17 -0800
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-27 17:50 -0800
Re: Euler's constant Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-28 03:09 +0000
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-28 02:52 -0800
Re: Euler's constant Seebs <usenet-nospam@seebs.net> - 2011-12-28 18:17 +0000
Re: Euler's constant Dr Nick <3-nospam@temporary-address.org.uk> - 2011-12-28 18:49 +0000
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-04 04:44 -0800
Re: Euler's constant Robert Wessel <robertwessel2@yahoo.com> - 2012-01-04 12:33 -0600
Re: Euler's constant 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 15:07 -0800
Re: Euler's constant "io_x" <a@b.c.invalid> - 2011-11-24 19:08 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 04:00 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-11-21 12:37 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-21 04:45 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-11-21 13:35 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-22 00:01 +0200
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuskes & Moos <kleuske@somewhere.else.net> - 2011-11-22 11:53 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-22 13:21 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuske <kleuske@nowhere.net> - 2011-11-24 14:50 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! "io_x" <a@b.c.invalid> - 2011-11-24 14:08 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! "io_x" <a@b.c.invalid> - 2011-11-24 18:02 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-25 15:31 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-25 17:40 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-25 22:03 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-25 22:43 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Joe Wright <joewwright@comcast.net> - 2011-11-26 02:13 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-26 19:40 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-27 15:35 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Ian Collins <ian-news@hotmail.com> - 2011-11-26 20:22 +1300
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-26 10:55 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Seebs <usenet-nospam@seebs.net> - 2011-11-28 08:32 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! superpollo <superpollo@tznvy.pbz> - 2011-11-26 12:11 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-26 10:37 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! superpollo <superpollo@tznvy.pbz> - 2011-11-26 21:48 +0100
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-28 01:56 -0800
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-28 13:34 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! James Kuyper <jameskuyper@verizon.net> - 2011-11-28 13:45 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-28 13:50 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! James Kuyper <jameskuyper@verizon.net> - 2011-11-28 14:32 -0500
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Kleuske <kleuske@nowhere.net> - 2011-11-28 21:16 +0000
Re: OK. LETS START REAL PROGRAMMING IN C FOR PROBLEMS!!! Keith Thompson <kst-u@mib.org> - 2011-11-28 14:59 -0800
csiph-web