Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

e to the i pi

12 views
Skip to first unread message

Lane Straatman

unread,
Feb 4, 2007, 3:19:15 AM2/4/07
to
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <complex.h>
/*
double complex z1, z2, z3;
bool flag;
z1 = .4 + .7I;
z2 = cpow(z1, 2.0);
z3 = z1 * z1;
flag = false;
flag = true;
if (flag)
{
printf("%lf %lf\n", creal(z1), cimag(z1));
printf("%lf %lf\n", creal(z2), cimag(z2));
printf("%lf %lf\n", creal(z3), cimag(z3));
printf("%d\n", N);
}
*/

int main(int argc, char *argv[])
{
double complex z1, z2, z3, z4, z5;
z1=5 +7I;
z2=cpow(z1, 1I);
printf("%lf %lf\n", creal(z1), cimag(z1));
printf("%lf %lf\n", creal(z2), cimag(z2));
z5= 0 + I*(3.14159);

z3=2.54 + 0*I;
z4=cpow(z5,z3);
printf("%lf %lf\n", creal(z4), cimag(z4));

system("PAUSE");
return 0;
}
Why doesn't e^(i *pi) equal what most folks think it does? LS


Malcolm McLean

unread,
Feb 4, 2007, 3:50:12 AM2/4/07
to

"Lane Straatman" <inv...@invalid.net> wrote in message

>
> Why doesn't e^(i *pi) equal what most folks think it does? LS
>
Most folks would say that if you try to multiply a number by itself an
imaginary number of times, that is impossible.

Dave Vandervies

unread,
Feb 4, 2007, 3:56:44 AM2/4/07
to
In article <44Sdndn_q4iVCljY...@comcast.com>,
Lane Straatman <inv...@invalid.net> wrote:

[much snippage]

>z5= 0 + I*(3.14159);
>
>z3=2.54 + 0*I;

If I understand your post correctly, this should be
z3=2.718281828459045 + 0*I;

>z4=cpow(z5,z3);
>printf("%lf %lf\n", creal(z4), cimag(z4));

>Why doesn't e^(i *pi) equal what most folks think it does? LS

'Tmight come closer if e were what most people think it is.


dave

--
Dave Vandervies dj3v...@csclub.uwaterloo.ca
This means that, if I break into a slowish run, then according to the
Lorentz-Fitzgerald equations I acquire imaginary mass, and can only decelerate
by running harder. --Richard Heathfield in comp.programming

Lane Straatman

unread,
Feb 4, 2007, 4:05:15 AM2/4/07
to

"Malcolm McLean" <regn...@btinternet.com> wrote in message
news:9OSdnYdqKqymA1jY...@bt.com...
e is the first transcendental (Louisville, I believe). pi is the second.
They are not equal. LS


CBFalconer

unread,
Feb 4, 2007, 9:01:13 AM2/4/07
to
Malcolm McLean wrote:
> "Lane Straatman" <inv...@invalid.net> wrote in message
>>
>> Why doesn't e^(i *pi) equal what most folks think it does?
>
> Most folks would say that if you try to multiply a number by
> itself an imaginary number of times, that is impossible.

Not in the complex field.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>


CBFalconer

unread,
Feb 4, 2007, 9:12:52 AM2/4/07
to
Lane Straatman wrote:
> "Malcolm McLean" <regn...@btinternet.com> wrote in message
>> "Lane Straatman" <inv...@invalid.net> wrote in message
>>>
>>> Why doesn't e^(i *pi) equal what most folks think it does?
>>>
>> Most folks would say that if you try to multiply a number by
>> itself an imaginary number of times, that is impossible.
>
> e is the first transcendental (Louisville, I believe). pi is
> the second. They are not equal.

No such thing as 'first' or 'second' transcendental. Between any
two rational numbers, there are an infinity of transcendentals.
Look up the various alephs. Also Cantor, Dedekind, Wierstrass. C
floating point representation ignores this fundamental fact and
represents all values by a limited set of rationals. Note the sly
maintenance of topicality.

Eric Sosman

unread,
Feb 4, 2007, 9:53:12 AM2/4/07
to

That's plane wrong.

--
Eric Sosman
eso...@acm-dot.org.invalid

Richard Heathfield

unread,
Feb 4, 2007, 10:18:10 AM2/4/07
to
CBFalconer said:

> Malcolm McLean wrote:
>> "Lane Straatman" <inv...@invalid.net> wrote in message
>>>
>>> Why doesn't e^(i *pi) equal what most folks think it does?
>>
>> Most folks would say that if you try to multiply a number by
>> itself an imaginary number of times, that is impossible.
>
> Not in the complex field.

Read again, more carefully. Malcolm is not talking about imaginary
arithmetic, but about what "most folks would say" about it. Most folks
don't know spit about mathematics.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.

Richard Heathfield

unread,
Feb 4, 2007, 10:23:05 AM2/4/07
to
Eric Sosman said:

> Malcolm McLean wrote:
>> "Lane Straatman" <inv...@invalid.net> wrote in message
>>> Why doesn't e^(i *pi) equal what most folks think it does? LS
>>>
>> Most folks would say that if you try to multiply a number by itself an
>> imaginary number of times, that is impossible.
>
> That's plane wrong.

Either you have a couple of axes to grind, or you're misreading what Malcolm
wrote, which rings true.

Malcolm McLean

unread,
Feb 4, 2007, 10:28:34 AM2/4/07
to

"Richard Heathfield" <r...@see.sig.invalid> wrote in message

> CBFalconer said:
>
>> Malcolm McLean wrote:
>>> "Lane Straatman" <inv...@invalid.net> wrote in message
>>>>
>>>> Why doesn't e^(i *pi) equal what most folks think it does?
>>>
>>> Most folks would say that if you try to multiply a number by
>>> itself an imaginary number of times, that is impossible.
>>
>> Not in the complex field.
>
> Read again, more carefully. Malcolm is not talking about imaginary
> arithmetic, but about what "most folks would say" about it. Most folks
> don't know spit about mathematics.
>
If we multiply an imaginary number by itself an imaginary number of times,
maybe that would be real, on the analogy that a negative number multiplied
by itself is a positive.

Let's try it

int main(void)
{
int unity = 1;
int test1;

test1 = 0 - unity;

printf("%d * %d = %d\n", test1, test1, test1 * test1);
printf("Now a bit more complex %f\n", pow( sqrt(test1), sqrt(test1) );

return 0;
}

Nope.


Richard Tobin

unread,
Feb 4, 2007, 1:49:28 PM2/4/07
to
In article <44Sdndn_q4iVCljY...@comcast.com>,
Lane Straatman <inv...@invalid.net> wrote:

>z5= 0 + I*(3.14159);
>
>z3=2.54 + 0*I;

If this is meant to be e, it's wrong. e is 2.718281828+

>z4=cpow(z5,z3);

If this is meant to be approximately e ^ (i*pi), it should be
cpow(z3,z5).

> system("PAUSE");

What is the point of this?

For fun, try 23.140693 ^ i.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.

Lane Straatman

unread,
Feb 4, 2007, 2:27:06 PM2/4/07
to

"Richard Tobin" <ric...@cogsci.ed.ac.uk> wrote in message
news:eq59ro$m0u$3...@pc-news.cogsci.ed.ac.uk...

> In article <44Sdndn_q4iVCljY...@comcast.com>,
> Lane Straatman <inv...@invalid.net> wrote:
>
>>z5= 0 + I*(3.14159);
>>
>>z3=2.54 + 0*I;
>
> If this is meant to be e, it's wrong. e is 2.718281828+
>
>>z4=cpow(z5,z3);
>
> If this is meant to be approximately e ^ (i*pi), it should be
> cpow(z3,z5).
>
>> system("PAUSE");
>
> What is the point of this?
>
> For fun, try 23.140693 ^ i.
#include <stdio.h>
#include <stdbool.h>
#include <complex.h>

int main(void)
{
double complex z3, z4, z5;
z5= 0 + I*(3.14159);
z3=2.71828 + 0*I;
z4=cpow(z3,z5);


printf("%lf %lf\n", creal(z4), cimag(z4));

return 0;
}
Thanks for replies. e is now set closer to what Dr. Kelly has listed for
it, and I've got the right order on cpow().

For kicks and giggles, I'd like to see how precise one can get with this
using these predefined types. arctan of 1.0 will improve pi. Is there an
easy way to adduce e in C to the full width of a double? LS


Dave Vandervies

unread,
Feb 4, 2007, 2:57:33 PM2/4/07
to
In article <jY6dnWqvLLwMrlvY...@comcast.com>,
Lane Straatman <inv...@invalid.net> wrote:

>For kicks and giggles, I'd like to see how precise one can get with this
>using these predefined types. arctan of 1.0 will improve pi. Is there an
>easy way to adduce e in C to the full width of a double? LS

exp(1.0)?

And for pi you probably want 4*actan(1.0).


dave

--
Dave Vandervies dj3v...@csclub.uwaterloo.ca
It's like saying "Hello, look here, I made a program that only works on
the GizmoStation 9500. Please ignore it.".
--Joona I Palaste in comp.lang.c

Lane Straatman

unread,
Feb 4, 2007, 3:06:51 PM2/4/07
to

"Malcolm McLean" <regn...@btinternet.com> wrote in message
news:MKidneaEIdcFZljY...@bt.com...
[...]

> If we multiply an imaginary number by itself an imaginary number of times,
> maybe that would be real, on the analogy that a negative number multiplied
> by itself is a positive.
>
> Let's try it
>[commented out, below]
> Nope.
I'm not sure what Malcolm is trying to do here. Without the overloading of
functions in tgmath.h, I doubt that sqrt() and pow() are going to cover the
complex cases. I couldn't get sqrt() to work on an imaginary.

Devcpp doesn't even have tgmath.h . I copied it out of lcc and put it in
the include file and got a cool 300 errors:
#include <stdio.h>
#include <stdlib.h>
#include <complex.h>
#include <tgmath.h>


int main(int argc, char *argv[])
{

double complex z1, z2;
z1 = 0 + 1*I;
z2 = sqrt(z1);


printf("%lf %lf\n", creal(z1), cimag(z1));
printf("%lf %lf\n", creal(z2), cimag(z2));

system("PAUSE");
return 0;
}
/*

int main(void)
{
int unity = 1;
int test1;

test1 = 0 - unity;

printf("%d * %d = %d\n", test1, test1, test1 * test1);
printf("Now a bit more complex %f\n", pow( sqrt(test1), sqrt(test1) );

return 0;
}
*/
Is there something about tgmath.h that makes its inclusion here ill-advised?
LS


Eric Sosman

unread,
Feb 4, 2007, 3:13:38 PM2/4/07
to

No. To "adduce" is to "offer as example, reason, or proof
in discussion or analysis." It is not easy to carry on discussion
or analysis in C (*about* C is another matter).

(Aren't you the guy who used "vernacular" to mean its opposite
just a couple weeks ago? Googles ... Yes! I hypothesize that
"Lane Straatman" is really a nom du Net for "Humpty Dumpty.")

If you had asked for an easy way to get a good approximation
to e, I'd have suggested exp(1) -- but since you didn't, I won't.

--
Eric Sosman
eso...@acm-dot-org.invalid

pete

unread,
Feb 4, 2007, 3:18:13 PM2/4/07
to
Dave Vandervies wrote:
>
> In article <jY6dnWqvLLwMrlvY...@comcast.com>,
> Lane Straatman <inv...@invalid.net> wrote:
>
> > arctan

> actan

atan

--
pete

Ben Pfaff

unread,
Feb 4, 2007, 3:29:16 PM2/4/07
to
pete <pfi...@mindspring.com> writes:

achoo!
--
"C has its problems, but a language designed from scratch would have some too,
and we know C's problems."
--Bjarne Stroustrup

jacob navia

unread,
Feb 4, 2007, 3:34:23 PM2/4/07
to
Lane Straatman a écrit :

> "Malcolm McLean" <regn...@btinternet.com> wrote in message
> news:MKidneaEIdcFZljY...@bt.com...
> [...]
>
>>If we multiply an imaginary number by itself an imaginary number of times,
>>maybe that would be real, on the analogy that a negative number multiplied
>>by itself is a positive.
>>
>>Let's try it
>>[commented out, below]
>>Nope.
>
> I'm not sure what Malcolm is trying to do here. Without the overloading of
> functions in tgmath.h, I doubt that sqrt() and pow() are going to cover the
> complex cases. I couldn't get sqrt() to work on an imaginary.
>
> Devcpp doesn't even have tgmath.h . I copied it out of lcc and put it in
> the include file and got a cool 300 errors:

That will never work.

Sorry, header files are NOT portable

Dave Vandervies

unread,
Feb 4, 2007, 3:34:57 PM2/4/07
to

Gah. I wrote "arctan" at first, but I thought I deleted both of the
extra characters...


dave

--
Dave Vandervies dj3v...@csclub.uwaterloo.ca

Dysfunctional programming seems to be so much more popular these days.
--James Riden in the scary devil monastery

Lane Straatman

unread,
Feb 4, 2007, 4:20:09 PM2/4/07
to

"CBFalconer" <cbfal...@yahoo.com> wrote in message
news:45C5E9E4...@yahoo.com...
> Lane Straatman wrote:

>> e is the first transcendental (Louisville, I believe). pi is
>> the second. They are not equal.
>
> No such thing as 'first' or 'second' transcendental. Between any
> two rational numbers, there are an infinity of transcendentals.
> Look up the various alephs. Also Cantor, Dedekind, Wierstrass. C
> floating point representation ignores this fundamental fact and
> represents all values by a limited set of rationals. Note the sly
> maintenance of topicality.

It is over the field of rationals that Joseph Liouville showed the existence
of the transcendentals in 1844. Charles Hermite showed the transcendental
nature of e in 1873, the first of its kind. Lindemann's corrolarry (sp?)
proved that pi was also not algebraic over Q. Since we have a bunch of
rationals in C, we have a bunch of transcendentals as the arctan's of these
numbers. LS


Lane Straatman

unread,
Feb 4, 2007, 4:29:31 PM2/4/07
to

"Eric Sosman" <eso...@acm-dot-org.invalid> wrote in message
news:_8OdncAyKq7BbljY...@comcast.com...

> Malcolm McLean wrote:
>> "Lane Straatman" <inv...@invalid.net> wrote in message
>>> Why doesn't e^(i *pi) equal what most folks think it does? LS
>>>
>> Most folks would say that if you try to multiply a number by itself an
>> imaginary number of times, that is impossible.
>
> That's plane wrong.
You're plain funny. LS


Keith Thompson

unread,
Feb 4, 2007, 4:39:39 PM2/4/07
to
"Malcolm McLean" <regn...@btinternet.com> writes:
> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
> > CBFalconer said:
> >
> >> Malcolm McLean wrote:
> >>> "Lane Straatman" <inv...@invalid.net> wrote in message
> >>>>
> >>>> Why doesn't e^(i *pi) equal what most folks think it does?
> >>>
> >>> Most folks would say that if you try to multiply a number by
> >>> itself an imaginary number of times, that is impossible.
> >>
> >> Not in the complex field.
> >
> > Read again, more carefully. Malcolm is not talking about imaginary
> > arithmetic, but about what "most folks would say" about it. Most folks
> > don't know spit about mathematics.
> >
> If we multiply an imaginary number by itself an imaginary number of times,
> maybe that would be real, on the analogy that a negative number multiplied
> by itself is a positive.

No, that's not how it works. Operations on imaginary and complex
numbers are well defined mathematically, and well supported in C99.

> Let's try it
>
> int main(void)
> {
> int unity = 1;
> int test1;
>
> test1 = 0 - unity;
>
> printf("%d * %d = %d\n", test1, test1, test1 * test1);
> printf("Now a bit more complex %f\n", pow( sqrt(test1), sqrt(test1) );
>
> return 0;
> }
>
> Nope.

Let me guess, you were so certain you were right that you didn't
bother to try it. There's a missing ')' on the second printf. You're
missing the required "#include <stdio.h>", which you can probably get
away with on many implementations. You're also missing the required
"#include <math.h>", which will probably cause the double results of
pow() and sqrt() to be interpreted as type int.

The sqrt() function takes a double argument and returns a double
result. In mathematical terms, it applies only to real numbers; it
can't give you a valid result for sqrt(-1). C99 supports imaginary
and complex numbers, as we've been discussing in this very thread.

Let's try it again:

#include <complex.h>
#include <math.h>
#include <stdio.h>
int main(void)
{
const double pi = 4 * atan(1.0);
const double complex result = cexp(I * pi);
printf("pi = %.10g\n", pi);
printf("result = %.10g + %.10g * I\n",
creal(result), cimag(result));
return 0;
}

Here's the output I get:

pi = 3.141592654
result = -1 + 1.224606354e-16 * I

It's not surprising that the result is inexact, since the value of pi
cannot be represented exactly.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.

Keith Thompson

unread,
Feb 4, 2007, 4:45:33 PM2/4/07
to
Richard Heathfield <r...@see.sig.invalid> writes:
> Eric Sosman said:
> > Malcolm McLean wrote:
> >> "Lane Straatman" <inv...@invalid.net> wrote in message
> >>> Why doesn't e^(i *pi) equal what most folks think it does? LS
> >>>
> >> Most folks would say that if you try to multiply a number by itself an
> >> imaginary number of times, that is impossible.
> >
> > That's plane wrong.
>
> Either you have a couple of axes to grind, or you're misreading what
> Malcolm wrote, which rings true.

Yes, what Malcolm wrote about "what most folks think" is at least
plausible (though I suspect that most people who would ask what
e^(i*pi) is in the first place are likely to know the answer). It
wasn't entirely clear to me that Malcolm understands the issue
himself.

On the other hand, perhaps Malcolm's subtlety just escaped me, in
which case I'm duly embarrassed to have missed it.

The fact that I wrote the above *before* I got the "couple of axes"
joke makes this more likely. *Sigh*

Keith Thompson

unread,
Feb 4, 2007, 4:51:20 PM2/4/07
to
"Lane Straatman" <inv...@invalid.net> writes:
[...]

> For kicks and giggles, I'd like to see how precise one can get with this
> using these predefined types. arctan of 1.0 will improve pi. Is there an
> easy way to adduce e in C to the full width of a double? LS

exp(1.0)

Malcolm McLean

unread,
Feb 4, 2007, 5:00:28 PM2/4/07
to

"Keith Thompson" <ks...@mib.org> wrote in message

> Let me guess, you were so certain you were right that you didn't
> bother to try it.
>
Microsoft have taken away my compiler. I bought a brand new Windows Vista
machine, installed my copy of Visual Studio and - no executable.


Richard Heathfield

unread,
Feb 4, 2007, 5:07:58 PM2/4/07
to
Malcolm McLean said:

You need Service Pack 7. Admittedly, Visual Studio won't work with that
either (possibly modulo emulators), but you get a perfectly capable C
compiler as part of the bundle. And of course it's completely free.

Lane Straatman

unread,
Feb 4, 2007, 5:14:48 PM2/4/07
to

"jacob navia" <ja...@jacob.remcomp.fr> wrote in message
news:45c64350$0$27374$ba4a...@news.orange.fr...
A lot of them are, but this is exactly the type that would not be: filled
with type definitions that ordinary mortals can't remember. sqrt() looks
like this in tgmath.h at the dinkumware site:
sqrt
double sqrt(double x);
float sqrt(float x);
long double sqrt(long double x);
double _Complex sqrt(double _Complex x);
float _Complex sqrt(float _Complex x);
long double _Complex sqrt(long double _Complex x);The function returns the
real square root of x, x^(1/2).

I would think double _Complex sqrt(double _Complex x) gives the root in the
complex plane we're looking for.

--

LS

center: "All the King's Men", perennial intramural basketball champs


Malcolm McLean

unread,
Feb 4, 2007, 5:37:51 PM2/4/07
to

"Richard Heathfield" <r...@see.sig.invalid> wrote in message
>> Microsoft have taken away my compiler. I bought a brand new Windows Vista
>> machine, installed my copy of Visual Studio and - no executable.
>
> You need Service Pack 7. Admittedly, Visual Studio won't work with that
> either (possibly modulo emulators), but you get a perfectly capable C
> compiler as part of the bundle. And of course it's completely free.
>
Seriously?
I need a Windows library to compile my games and BASICdraw, but not for
scientific stuff. At the moment I'm just glad I didn't throw my old PC away.
However I did put the old cathode ray monitor to one side, so now I have to
unplug and replug monitors every time I use my compiler.

They are up to service pack 7 within one week of the OS coming on market?


Keith Thompson

unread,
Feb 4, 2007, 5:51:44 PM2/4/07
to
"Lane Straatman" <inv...@invalid.net> writes:
[...]
> Is there something about tgmath.h that makes its inclusion here ill-advised?

Yes, it's not supported my many compilers, and you don't need it.
<tgmath.h> just lets you use simple names for math functions that work
with any real type. The declarations in <tgmath.h> are "type-generic
macros" that simply invoke the appropriate function for the argument
type. For example, to compute the square root of a "double complex"
value, just use the csqrt() function in <complex.h> (or csqrtf() for
"float complex", or csqrtl for "long double complex").

Richard Heathfield

unread,
Feb 4, 2007, 6:23:23 PM2/4/07
to
Malcolm McLean said:

>
> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
>>> Microsoft have taken away my compiler. I bought a brand new Windows Vista
>>> machine, installed my copy of Visual Studio and - no executable.
>>
>> You need Service Pack 7. Admittedly, Visual Studio won't work with that
>> either (possibly modulo emulators), but you get a perfectly capable C
>> compiler as part of the bundle. And of course it's completely free.
>>
> Seriously?

Er, no. Sorry, Malcolm, I thought you knew - "Service Pack 7" is the traditional
name for Linux when being recommended as a fix for a Windows-specific problem.

> I need a Windows library to compile my games and BASICdraw,

You have just discovered that Microsoft aren't all that interested in supporting
"legacy software" (e.g. their own two-year-old compiler, if your account is
anything to go by). Have you considered porting your stuff to a more stable
platform?

JimS

unread,
Feb 4, 2007, 7:23:32 PM2/4/07
to
On Sun, 04 Feb 2007 22:07:58 +0000, Richard Heathfield
<r...@see.sig.invalid> wrote:

>Malcolm McLean said:
>
>>
>> "Keith Thompson" <ks...@mib.org> wrote in message
>>> Let me guess, you were so certain you were right that you didn't
>>> bother to try it.
>>>
>> Microsoft have taken away my compiler. I bought a brand new Windows Vista
>> machine, installed my copy of Visual Studio and - no executable.
>
>You need Service Pack 7. Admittedly, Visual Studio won't work with that
>either (possibly modulo emulators), but you get a perfectly capable C
>compiler as part of the bundle. And of course it's completely free.

Vista supports Visual Studio 2005 only, as far as I can tell, and VS
needs a service pack to do that properly AND it has to be run as
Administrator.

Jim

Lane Straatman

unread,
Feb 4, 2007, 8:17:15 PM2/4/07
to

"Keith Thompson" <ks...@mib.org> wrote in message
news:lnsldlp...@nuthaus.mib.org...

> Richard Heathfield <r...@see.sig.invalid> writes:
>> Eric Sosman said:
>> > Malcolm McLean wrote:
>> >> "Lane Straatman" <inv...@invalid.net> wrote in message
>> >>> Why doesn't e^(i *pi) equal what most folks think it does? LS
>> >>>
>> >> Most folks would say that if you try to multiply a number by itself an
>> >> imaginary number of times, that is impossible.
>> >
>> > That's plane wrong.
>>
>> Either you have a couple of axes to grind, or you're misreading what
>> Malcolm wrote, which rings true.
>
> Yes, what Malcolm wrote about "what most folks think" is at least
> plausible (though I suspect that most people who would ask what
> e^(i*pi) is in the first place are likely to know the answer). It
> wasn't entirely clear to me that Malcolm understands the issue
> himself.
I hope he takes from this a means to further his adducation.

> On the other hand, perhaps Malcolm's subtlety just escaped me, in
> which case I'm duly embarrassed to have missed it.

He's got me after complex roots, now, and I've thought about it enough to
want to write it from scratch.

> The fact that I wrote the above *before* I got the "couple of axes"
> joke makes this more likely. *Sigh*

Axis is correct, as one of them is Joshu's. LS


Tim Prince

unread,
Feb 4, 2007, 8:42:39 PM2/4/07
to
Lane Straatman wrote:
Since we have a bunch of
> rationals in C, we have a bunch of transcendentals as the arctan's of these
> numbers. LS
>
>
In C, the atan() functions are a bunch of rationals. Ideally, in
certain ranges, with something resembling IEEE754 compliance, the
quality is measurable in ULPS difference between the actual result and
the mathematically correct one. It looks like you jumped from C to
something else in mid-sentence.

Lane Straatman

unread,
Feb 4, 2007, 9:13:55 PM2/4/07
to

"Richard Heathfield" <r...@see.sig.invalid> wrote in message
news:taydnayTGY1_91vY...@bt.com...

> Malcolm McLean said:
>
>>
>> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
>>>> Microsoft have taken away my compiler. I bought a brand new Windows
>>>> Vista
>>>> machine, installed my copy of Visual Studio and - no executable.
>>>
>>> You need Service Pack 7. Admittedly, Visual Studio won't work with that
>>> either (possibly modulo emulators), but you get a perfectly capable C
>>> compiler as part of the bundle. And of course it's completely free.
>>>
>> Seriously?
>
> Er, no. Sorry, Malcolm, I thought you knew - "Service Pack 7" is the
> traditional
> name for Linux when being recommended as a fix for a Windows-specific
> problem.
>
>> I need a Windows library to compile my games and BASICdraw,
>
> You have just discovered that Microsoft aren't all that interested in
> supporting
> "legacy software" (e.g. their own two-year-old compiler, if your account
> is
> anything to go by). Have you considered porting your stuff to a more
> stable
> platform?
I don't want you to think that I would tea up on you for your lack of
proximity to the evil empire.* I have a linux disk, somewhere. I think it
had to do with a penguin; I can't quite remember the file. And that's what
happens every time with linux for people like me, who get knocked out every
couple of years: we forget that maze of files and switches and did I see
curses.h? LS
*it occurs to me that I made a spoonerism last night when I called you
"C-3pio."


CBFalconer

unread,
Feb 4, 2007, 8:31:56 PM2/4/07
to
Lane Straatman wrote:
>
... snip ...

>
> #include <stdio.h>
> #include <stdbool.h>
> #include <complex.h>
>
> int main(void)
> {
> double complex z3, z4, z5;
> z5= 0 + I*(3.14159);
> z3=2.71828 + 0*I;
> z4=cpow(z3,z5);
> printf("%lf %lf\n", creal(z4), cimag(z4));
> return 0;
> }
> Thanks for replies. e is now set closer to what Dr. Kelly has
> listed for it, and I've got the right order on cpow().
>
> For kicks and giggles, I'd like to see how precise one can get
> with this using these predefined types. arctan of 1.0 will
> improve pi. Is there an easy way to adduce e in C to the full
> width of a double? LS

How about "exp(1.0);".

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews


Lane Straatman

unread,
Feb 4, 2007, 10:16:39 PM2/4/07
to

"Tim Prince" <tpr...@nospamcomputer.org> wrote in message
news:kYvxh.3394$MN....@newssvr23.news.prodigy.net...
You couldn't be more wrong. I had a conversation with C_Dreamer about this.
LS


Richard Bos

unread,
Feb 5, 2007, 2:49:01 AM2/5/07
to
"Lane Straatman" <inv...@invalid.net> wrote:

> Devcpp doesn't even have tgmath.h .

Of course it doesn't. It's a C89 implementation, not a C99 one.

> I copied it out of lcc

Bad idea, as you'd have known if you'd read the FAQ.

> Is there something about tgmath.h that makes its inclusion here ill-advised?

<http://c-faq.com/cpp/missinghdr.html>

Richard

Richard Bos

unread,
Feb 5, 2007, 2:55:16 AM2/5/07
to
"Malcolm McLean" <regn...@btinternet.com> wrote:

> "Keith Thompson" <ks...@mib.org> wrote in message
> > Let me guess, you were so certain you were right that you didn't
> > bother to try it.
> >
> Microsoft have taken away my compiler. I bought a brand new Windows Vista
> machine,

More fool you.

<http://www.theregister.co.uk/2006/11/22/vista_eula_worries/>
<http://www.securityfocus.com/columnists/423>
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.html>

Richard

Richard Heathfield

unread,
Feb 5, 2007, 3:29:48 AM2/5/07
to
Lane Straatman said:

Tim is right - atan() returns a double, and doubles have a finite number
of bits, so they literally *cannot* store irrational numbers. The best
they can do is store the closest rational approximation one can find
within the bits available.

Hallvard B Furuseth

unread,
Feb 5, 2007, 5:54:17 AM2/5/07
to
Lane Straatman writes:
> For kicks and giggles, I'd like to see how precise one can get with
> this using these predefined types.

Use long double, then. And atanl, cexpl.

--
Hallvard

Richard Bos

unread,
Feb 5, 2007, 6:22:37 AM2/5/07
to
JimS <so...@not.com> wrote:

> Vista supports Visual Studio 2005 only, as far as I can tell, and VS
> needs a service pack to do that properly AND it has to be run as
> Administrator.

*Wow*. That's... amazing. Just amazing. The _wisdom_ that flows out of
Redmond, the attention to _security_, the great sense of _solid
build_... it's to be found nowhere else.

Richard

Dik T. Winter

unread,
Feb 5, 2007, 7:03:56 AM2/5/07
to
In article <eq474c$1v5$1...@rumours.uwaterloo.ca> dj3v...@caffeine.csclub.uwaterloo.ca (Dave Vandervies) writes:
> In article <44Sdndn_q4iVCljY...@comcast.com>,
> Lane Straatman <inv...@invalid.net> wrote:
...
> >z5= 0 + I*(3.14159);
> >
> >z3=2.54 + 0*I;
>
> If I understand your post correctly, this should be
> z3=2.718281828459045 + 0*I;
>
> >z4=cpow(z5,z3);

> >printf("%lf %lf\n", creal(z4), cimag(z4));
>
> >Why doesn't e^(i *pi) equal what most folks think it does? LS
>
> 'Tmight come closer if e were what most people think it is.

It might also come closer if the arguments to cpow were in the
proper order.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/

Fred Kleinschmidt

unread,
Feb 5, 2007, 10:38:41 AM2/5/07
to

"Richard Tobin" <ric...@cogsci.ed.ac.uk> wrote in message
news:eq59ro$m0u$3...@pc-news.cogsci.ed.ac.uk...

> In article <44Sdndn_q4iVCljY...@comcast.com>,
> Lane Straatman <inv...@invalid.net> wrote:
>
>>z5= 0 + I*(3.14159);
>>
>>z3=2.54 + 0*I;
>
> If this is meant to be e, it's wrong. e is 2.718281828+
>
>>z4=cpow(z5,z3);
>
> If this is meant to be approximately e ^ (i*pi), it should be
> cpow(z3,z5).
>
>> system("PAUSE");
>
> What is the point of this?
>
> For fun, try 23.140693 ^ i.
>
> -- Richard
> --
> "Consideration shall be given to the need for as many as 32 characters
> in some alphabets" - X3.4, 1963.

Aren't M_PI and M_E defined in math.h?

--
Fred L. Kleinschmidt


Richard Heathfield

unread,
Feb 5, 2007, 11:17:02 AM2/5/07
to
Fred Kleinschmidt said:

<snip>



> Aren't M_PI and M_E defined in math.h?

No.

Richard Tobin

unread,
Feb 5, 2007, 11:42:52 AM2/5/07
to
In article <JCzy4...@news.boeing.com>,

Fred Kleinschmidt <fred.l.kle...@boeing.com> wrote:
>Aren't M_PI and M_E defined in math.h?

Yes, but unfortunately not on systems conforming only to the C
standard.

osmium

unread,
Feb 5, 2007, 1:10:31 PM2/5/07
to
"Fred Kleinschmidt" writes:

> Aren't M_PI and M_E defined in math.h?

Thankfully, no. Only in grotesque extensions to the language made by
certain vendors.

Definitions of constants have no proper place in a programming language, it
just leads to two sets of constants, a private set, for M_AVOGADRO and the
like, and the set that came with the compiler, M_PI. and friends.


Richard Tobin

unread,
Feb 5, 2007, 1:50:39 PM2/5/07
to
In article <52pa8oF...@mid.individual.net>,
osmium <r124c...@comast.net> wrote:

>Definitions of constants have no proper place in a programming language, it
>just leads to two sets of constants, a private set, for M_AVOGADRO and the
>like, and the set that came with the compiler, M_PI. and friends.

Definitions of functions have no proper place in a programming
language, it just leads to two sets of functions, a private set, for
print_bank_balance and the like, and the set that came with the
compiler, strlen and friends.

jacob navia

unread,
Feb 5, 2007, 1:50:35 PM2/5/07
to
lcc-win32 defines M_PI if not in conforming mode, as gcc does, for
instance.
They are not standard C but are POSIX. I do not see the point
in defining PI again and again...

Fred Kleinschmidt

unread,
Feb 5, 2007, 2:22:14 PM2/5/07
to

"osmium" <r124c...@comcast.net> wrote in message
news:52pa8oF...@mid.individual.net...

And thus we should get rid of defined constants like INT_MAX, INT_MIN, etc.,
since they have no place in a programming language.
--
Fred L. Kleinschmidt


CBFalconer

unread,
Feb 5, 2007, 11:18:29 AM2/5/07
to
Fred Kleinschmidt wrote:
>
... snip ...

>
> Aren't M_PI and M_E defined in math.h?

No.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

user923005

unread,
Feb 5, 2007, 3:47:57 PM2/5/07
to
On Feb 4, 7:23 am, Richard Heathfield <r...@see.sig.invalid> wrote:
> Eric Sosman said:
>
> > Malcolm McLean wrote:
> >> "Lane Straatman" <inva...@invalid.net> wrote in message

> >>> Why doesn't e^(i *pi) equal what most folks think it does? LS
>
> >> Most folks would say that if you try to multiply a number by itself an
> >> imaginary number of times, that is impossible.
>
> > That's plane wrong.
>
> Either you have a couple of axes to grind, or you're misreading what Malcolm
> wrote, which rings true.

Actually, it's hilarious (if you consider the deliberate misspelling).
IMO-YMMV.

This is referring to the famous equation e^(i*pi) - 1 = 0
which is certainly true in the complex plane.

> --
> Richard Heathfield
> "Usenet is a strange place" - dmr 29/7/1999http://www.cpax.org.uk

Keith Thompson

unread,
Feb 5, 2007, 4:08:09 PM2/5/07
to

No, gcc doesn't define M_PI. <math.h> is part of the C library, not
part of the compiler. gcc uses whatever <math.h> file is provided by
the system (that's glibc on some, but by no means all, systems).
(Minor detail: the "fixincludes" program creates a modified version of
<math.h> when gcc is installed, but that doesn't affect M_PI.)

If we're going to discuss specific implementations, we need to know
what we're talking about. gcc is a compiler, not a full
implementation.

The point is that any program that depends on M_PI is non-portable.
A conforming C implementation *may not* define M_PI in <math.h>.

Keith Thompson

unread,
Feb 5, 2007, 4:10:24 PM2/5/07
to
"user923005" <dco...@connx.com> writes:
> On Feb 4, 7:23 am, Richard Heathfield <r...@see.sig.invalid> wrote:
> > Eric Sosman said:
> >
> > > Malcolm McLean wrote:
> > >> "Lane Straatman" <inva...@invalid.net> wrote in message
> > >>> Why doesn't e^(i *pi) equal what most folks think it does? LS
> >
> > >> Most folks would say that if you try to multiply a number by itself an
> > >> imaginary number of times, that is impossible.
> >
> > > That's plane wrong.
> >
> > Either you have a couple of axes to grind, or you're misreading
> > what Malcolm wrote, which rings true.
>
> Actually, it's hilarious (if you consider the deliberate misspelling).
> IMO-YMMV.

You missed something. Hint: What is the singular of "axes"? (There
are two correct answers.)

> This is referring to the famous equation e^(i*pi) - 1 = 0
> which is certainly true in the complex plane.

Or perhaps to the even more famous equation e^(i*pi) + 1 = 0
(which I used to have on a t-shirt).

user923005

unread,
Feb 5, 2007, 4:20:53 PM2/5/07
to
On Feb 5, 1:10 pm, Keith Thompson <k...@mib.org> wrote:

> "user923005" <dcor...@connx.com> writes:
> > On Feb 4, 7:23 am, Richard Heathfield <r...@see.sig.invalid> wrote:
> > > Eric Sosman said:
>
> > > > Malcolm McLean wrote:
> > > >> "Lane Straatman" <inva...@invalid.net> wrote in message
> > > >>> Why doesn't e^(i *pi) equal what most folks think it does? LS
>
> > > >> Most folks would say that if you try to multiply a number by itself an
> > > >> imaginary number of times, that is impossible.
>
> > > > That's plane wrong.
>
> > > Either you have a couple of axes to grind, or you're misreading
> > > what Malcolm wrote, which rings true.
>
> > Actually, it's hilarious (if you consider the deliberate misspelling).
> > IMO-YMMV.
>
> You missed something. Hint: What is the singular of "axes"? (There
> are two correct answers.)

Is there anything more ironic than ironically missing the irony?

> > This is referring to the famous equation e^(i*pi) - 1 = 0
> > which is certainly true in the complex plane.
>
> Or perhaps to the even more famous equation e^(i*pi) + 1 = 0
> (which I used to have on a t-shirt).

Do I have to turn in my "math major" badge now?
:-(

> --
> Keith Thompson (The_Other_Keith) k...@mib.org <http://www.ghoti.net/~kst>


> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>

> We must do something. This is something. Therefore, we must do this.- Hide quoted text -
>
> - Show quoted text -


Lane Straatman

unread,
Feb 5, 2007, 8:15:56 PM2/5/07
to

"Lane Straatman" <inv...@invalid.net> wrote in message
news:kY2dnYD9mLc8GFvY...@comcast.com...

>
> "Keith Thompson" <ks...@mib.org> wrote in message

>> On the other hand, perhaps Malcolm's subtlety just escaped me, in


>> which case I'm duly embarrassed to have missed it.
> He's got me after complex roots, now, and I've thought about it enough to
> want to write it from scratch.

#include <stdio.h>
#include <stdlib.h>
#include <complex.h>
#include <math.h>
int main(void)
{
double complex z1, z3, z4, z5;
double mod, phi, a, b, c, d;
z1 = .4 + .7I;
a = creal(z1);
b = cimag(z1);
mod = sqrt(pow(a, 2) + pow(b, 2));
phi = atan(b/a);
c = ( (sqrt(mod)) * cos( .5 * phi ) );
d = ( (sqrt(mod)) * sin( .5 * phi ) );
z4 = c + d*I;
z5 = cpow(z1, .5);
z3 = cpow(z4, 2.0);
printf("The square root of %lf %lfi\n", creal(z1), cimag(z1));
printf("is : %lf %lfi\n", creal(z4), cimag(z4));
printf("using cpow to get the root: %lf %lfi\n", creal(z5), cimag(z5));
printf("using cpow to check the square: %lf %lfi\n", creal(z3),
cimag(z3));
system("PAUSE");
return 0;
}
Am I going to get in trouble with atan as I've got it? LS


Lane Straatman

unread,
Feb 5, 2007, 8:38:13 PM2/5/07
to

"Richard Heathfield" <r...@see.sig.invalid> wrote in message
news:jdGdnYiTEaY...@bt.com...

> Lane Straatman said:
>
>>
>> "Tim Prince" <tpr...@nospamcomputer.org> wrote in message
>> news:kYvxh.3394$MN....@newssvr23.news.prodigy.net...
>>> Lane Straatman wrote:
>>> Since we have a bunch of
>>>> rationals in C, we have a bunch of transcendentals as the arctan's
>>>> of
>>>> these numbers. LS
>>> In C, the atan() functions are a bunch of rationals. Ideally, in
>>> certain ranges, with something resembling IEEE754 compliance, the
>>> quality is measurable in ULPS difference between the actual result
>>> and the
>>> mathematically correct one. It looks like you jumped from C to
>>> something else in mid-sentence.
>> You couldn't be more wrong.
>
> Tim is right - atan() returns a double, and doubles have a finite number
> of bits, so they literally *cannot* store irrational numbers. The best
> they can do is store the closest rational approximation one can find
> within the bits available.
The point is that if you have arctan of a rational then the *next* digit in
its expansion is not something that algebraic methods can get a hold of.
Where Dr. Kelly at the end of chp 24 of _Unleashed_ expands e to a page and
a half then has 99860 , do you have a bet what the next number would be? If
you expand one third for a page and a half, I could get that digit. LS


Lane Straatman

unread,
Feb 5, 2007, 9:07:58 PM2/5/07
to

"Richard Bos" <r...@hoekstra-uitgeverij.nl> wrote in message
news:45c6e006.2405049489@news.xs4all.nl...

> "Lane Straatman" <inv...@invalid.net> wrote:
>
>> Devcpp doesn't even have tgmath.h .
>
> Of course it doesn't. It's a C89 implementation, not a C99 one.
"It" refers to what? ^^

>
>> I copied it out of lcc
>
> Bad idea, as you'd have known if you'd read the FAQ.

It's certainly not jacob's fault that I sniped his header and got errors by
the hundred.

>> Is there something about tgmath.h that makes its inclusion here
>> ill-advised?
>
> <http://c-faq.com/cpp/missinghdr.html>

I've never seen a stdbool.h that differed at all.
--
LS
"Hoekstra" is as common a name as "Jones" here in dutch Michigan. Pete
Hoekstra is the house representative from nearby Holland.


Keith Thompson

unread,
Feb 6, 2007, 1:23:45 AM2/6/07
to
"Lane Straatman" <inv...@invalid.net> writes:
> "Richard Bos" <r...@hoekstra-uitgeverij.nl> wrote in message
> news:45c6e006.2405049489@news.xs4all.nl...
> > "Lane Straatman" <inv...@invalid.net> wrote:
> >
> >> Devcpp doesn't even have tgmath.h .
> >
> > Of course it doesn't. It's a C89 implementation, not a C99 one.
> "It" refers to what? ^^

Um, devcpp? What else would it refer to?

> >> I copied it out of lcc
> >
> > Bad idea, as you'd have known if you'd read the FAQ.
> It's certainly not jacob's fault that I sniped his header and got errors by
> the hundred.

Nobody said it was jacob's fault.

> >> Is there something about tgmath.h that makes its inclusion here
> >> ill-advised?
> >
> > <http://c-faq.com/cpp/missinghdr.html>
> I've never seen a stdbool.h that differed at all.

That differed from what?

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>

Richard Heathfield

unread,
Feb 6, 2007, 2:15:42 AM2/6/07
to
Lane Straatman said:
> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
> news:jdGdnYiTEaY...@bt.com...
<snip>

>> Tim is right - atan() returns a double, and doubles have a finite
>> number of bits, so they literally *cannot* store irrational numbers.
>> The best they can do is store the closest rational approximation one
>> can find within the bits available.
> The point is that if you have arctan of a rational then the *next*
> digit in its expansion is not something that algebraic methods can get
> a hold of. Where Dr. Kelly

Actually, Ian is a very very very clever man, a fine fellow, an
excellent host, a talented musician, a superb programmer, and a quite
astounding linguist, but it has to be said, when all's said and done,
that he's not a doctor. I know the book says he is - at least three
times - but the book is wrong. That's probably my fault, because I
think I just kind of assumed he had a doctorate when I was setting up
the team, and it turns out he hasn't. If ever there were a failure of
the British education system, it is this: that it does not regard Ian
as a doctor. Having said that, I'm now going to stop making a fuss
about it. Instead, I would like to award Ian an honorary doctorate from
the University of Common Sense.

> at the end of chp 24 of _Unleashed_ expands e to a page and
> a half then has 99860 , do you have a bet what the next number would
> be? If you expand one third for a page and a half, I could get that
> digit.

Ian's expansion of e, however, was not done via calls to atan(), which
is what Tim Prince was talking about. atan() returns a double, and a
double cannot store an irrational number precisely. A circle can, but a
double can't.

Malcolm McLean

unread,
Feb 6, 2007, 2:49:07 AM2/6/07
to

"Richard Heathfield" <r...@see.sig.invalid> wrote in message
> Malcolm McLean said:
>
>>
>> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
>>>> Microsoft have taken away my compiler. I bought a brand new Windows
>>>> Vista
>>>> machine, installed my copy of Visual Studio and - no executable.
>>>
>>> You need Service Pack 7. Admittedly, Visual Studio won't work with that
>>> either (possibly modulo emulators), but you get a perfectly capable C
>>> compiler as part of the bundle. And of course it's completely free.
>>>
>> Seriously?
>
> Er, no. Sorry, Malcolm, I thought you knew - "Service Pack 7" is the
> traditional
> name for Linux when being recommended as a fix for a Windows-specific
> problem.
>
>> I need a Windows library to compile my games and BASICdraw,
>
> You have just discovered that Microsoft aren't all that interested in
> supporting
> "legacy software" (e.g. their own two-year-old compiler, if your account
> is
> anything to go by). Have you considered porting your stuff to a more
> stable
> platform?
>
They do offer a free compiler. It looks pretty horrid, but at least it
compiled "Hello World" - not without five minutes tweaking to get rid of a
file called stdafx.h it insisted on adding.

Anyway I have registered and agreed not to distribute any programs compiled
with it as open source, etc, etc, etc. I've no real choice. A computer isn't
a computer without a programming environment - it's just a glorified
typewriter.


Glenn Hutchings

unread,
Feb 6, 2007, 2:59:54 AM2/6/07
to
On 4 Feb, 18:49, rich...@cogsci.ed.ac.uk (Richard Tobin) wrote:

> For fun, try 23.140693 ^ i.

For even more fun, try computing i ^ i. Betcha didn't see that
coming!

Glenn

CBFalconer

unread,
Feb 6, 2007, 3:10:47 AM2/6/07
to
Keith Thompson wrote:
> "Lane Straatman" <inv...@invalid.net> writes:
>
... snip ...

>
>> I've never seen a stdbool.h that differed at all.
>
> That differed from what?

>From any other stdbool.h, I assume. This is probably connected
with the fact that stdbool.h is completely described in N869,
leaving nothing to the imagination. <Append something about female
garments here.>

Lane Straatman

unread,
Feb 6, 2007, 4:37:48 AM2/6/07
to

"Glenn Hutchings" <zon...@googlemail.com> wrote in message
news:1170748794....@a75g2000cwd.googlegroups.com...
We know that it exists as a complex that C can calculate from first
principles. LS


Lane Straatman

unread,
Feb 6, 2007, 5:33:22 AM2/6/07
to

"Richard Heathfield" <r...@see.sig.invalid> wrote in message
news:JfGdnSFcC-g2t1XY...@bt.com...

> Lane Straatman said:
>> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
>> news:jdGdnYiTEaY...@bt.com...
> <snip>
>
>>> Tim is right - atan() returns a double, and doubles have a finite
>>> number of bits, so they literally *cannot* store irrational numbers.
>>> The best they can do is store the closest rational approximation one
>>> can find within the bits available.
>> The point is that if you have arctan of a rational then the *next*
>> digit in its expansion is not something that algebraic methods can get
>> a hold of. Where Dr. Kelly
>
> Actually, Ian is a very very very clever man, a fine fellow, an
> excellent host, a talented musician, a superb programmer, and a quite
> astounding linguist, but it has to be said, when all's said and done,
> that he's not a doctor. I know the book says he is - at least three
> times - but the book is wrong. That's probably my fault, because I
> think I just kind of assumed he had a doctorate when I was setting up
> the team, and it turns out he hasn't. If ever there were a failure of
> the British education system, it is this: that it does not regard Ian
> as a doctor. Having said that, I'm now going to stop making a fuss
> about it. Instead, I would like to award Ian an honorary doctorate from
> the University of Common Sense.
ABD is a common affliction in the US (All But Disseration). If you make it
sound really serious,

>
>> at the end of chp 24 of _Unleashed_ expands e to a page and
>> a half then has 99860 , do you have a bet what the next number would
>> be? If you expand one third for a page and a half, I could get that
>> digit.
>
> Ian's expansion of e, however, was not done via calls to atan(), which
> is what Tim Prince was talking about. atan() returns a double, and a
> double cannot store an irrational number precisely. A circle can, but a
> double can't.

You can re-topologize and get a line from whatever circle you created* **, a
line in which, you claim, "almost all" numbers are absent. If you think
almost all numbers are absent in C's ability to work with, say, the segment
[-1.01, -.99], you're a different kind of cat than I.

Do you honestly believe that 42 * arctan(1.0) is in Q?
--
LS
*with the same set-theoretic properties
**give or take a point with Riemannian steriographic projection


Lane Straatman

unread,
Feb 6, 2007, 5:42:00 AM2/6/07
to

"CBFalconer" <cbfal...@yahoo.com> wrote in message
news:45C83807...@yahoo.com...

> Keith Thompson wrote:
>> "Lane Straatman" <inv...@invalid.net> writes:
>>
> ... snip ...
>>
>>> I've never seen a stdbool.h that differed at all.
I meant to differ from itself. Another example of this is iso646.h .

>>
>> That differed from what?
>
>>From any other stdbool.h, I assume. This is probably connected
> with the fact that stdbool.h is completely described in N869,
> leaving nothing to the imagination. <Append something about female
> garments here.>

Carla left her purse.
The heel on Jenn's boot was 4 inches.
Misty was outlaw. LS


Keith Thompson

unread,
Feb 6, 2007, 5:43:38 AM2/6/07
to
CBFalconer <cbfal...@yahoo.com> writes:
> Keith Thompson wrote:
> > "Lane Straatman" <inv...@invalid.net> writes:
> >
> ... snip ...
> >
> >> I've never seen a stdbool.h that differed at all.
> >
> > That differed from what?
>
> >From any other stdbool.h, I assume. This is probably connected
> with the fact that stdbool.h is completely described in N869,
> leaving nothing to the imagination. <Append something about female
> garments here.>

The standard completely describes the visible declarations, but not
the whole file. For example, the version provided on one Linux system
I use has a large comment block, include guards using the symbol
"_STDBOOL_H", and a test for __cplusplus (supporting <stdbool.h> in
C++ is a gcc extension).

But it's true that copying <stdbool.h> from one implementation to
another is less likely to cause problems than most other predefined
headers.

Keith Thompson

unread,
Feb 6, 2007, 5:54:22 AM2/6/07
to
"Lane Straatman" <inv...@invalid.net> writes:
> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
> news:JfGdnSFcC-g2t1XY...@bt.com...
[...]

> > Ian's expansion of e, however, was not done via calls to atan(), which
> > is what Tim Prince was talking about. atan() returns a double, and a
> > double cannot store an irrational number precisely. A circle can, but a
> > double can't.
> You can re-topologize and get a line from whatever circle you created* **, a
> line in which, you claim, "almost all" numbers are absent. If you think
> almost all numbers are absent in C's ability to work with, say, the segment
> [-1.01, -.99], you're a different kind of cat than I.

Different in that he knows what he's talking about.

A double is typically 64 bits. That means it can represent at most
2**64 distinct values. Some small subset of those values will be in
the range [-1.01, -.99], a range that includes infinitely many real
numbers. Yes, almost all numbers are absent in C's ability to work
with, say, the segment [-1.01, -.99].

> Do you honestly believe that 42 * arctan(1.0) is in Q?

Q is the set of rational numbers, yes? (Please don't assume everone
here is familiar with that particular mathematical notation.)

If by "42 * arctan(1.0)" you mean the result of the mathematical
formula over real numbers, then no, the result is not rational; in
fact, it's trancendental (10.5 * pi).

If instead you're referring to the result of the C expression
"42 * atan(1.0)" (the function declared in <math.h> is "atan", not
"arctan"), then yes, that result is rational. It is a value of type
double, which is a floating-point type whose representation is a
finite number of bits. It can *only* represent rational numbers. In
fact, it can only represent a tiny subset of the rational numbers.
(In a typical implementation, all representable numbers are integer
multiples of a power of 2.)

C floating-point types cannot represent irrational numbers. They are
not mathematical real numbers; they are only a discrete approximation,
good enough for many purposes.

You might want to look up Goldberg's "What Every Computer Scientist
Should Know About Floating-Point Arithmetic".

Richard Heathfield

unread,
Feb 6, 2007, 10:17:11 AM2/6/07
to
Malcolm McLean said:

<snip>

> [MS] do offer a free compiler. It looks pretty horrid, but at least it


> compiled "Hello World" - not without five minutes tweaking to get rid
> of a file called stdafx.h it insisted on adding.
>
> Anyway I have registered and agreed not to distribute any programs
> compiled with it as open source, etc, etc, etc. I've no real choice.

Yes, you do. Your original problem - software you purchased failing to
run on your new machine - was caused by Microsoft. Your fix, supplied
by Microsoft, is unsatisfactorily restrictive. You have no reasonable
assurance that Microsoft isn't going to cause you even more problems in
the future. It seems to me that the obvious thing to do is knock
Microsoft out of the loop, even if that means spending some time
porting your stuff to a more sensible platform.

> A computer isn't a computer without a programming environment - it's
> just a glorified typewriter.

A compiler whose licence agreement requires you not to allow your users
access to source code is not a compiler - it's a prison.

Richard Heathfield

unread,
Feb 6, 2007, 10:26:23 AM2/6/07
to
Lane Straatman said:

>
> If you
> think almost all numbers are absent in C's ability to work with, say,
> the segment
> [-1.01, -.99], you're a different kind of cat than I.

Miaow. C programs are capable of representing almost none of the numbers
in the that range.

> Do you honestly believe that 42 * arctan(1.0) is in Q?

If you mean 42 * atan(1.0), then yes, I do.

santosh

unread,
Feb 6, 2007, 1:37:19 PM2/6/07
to
Malcolm McLean wrote:
> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
<snip>

> > You have just discovered that Microsoft aren't all that interested in
> > supporting "legacy software" (e.g. their own two-year-old compiler, if your account
> > is anything to go by). Have you considered porting your stuff to a more
> > stable platform?
> >
> They do offer a free compiler. It looks pretty horrid, but at least it
> compiled "Hello World" - not without five minutes tweaking to get rid of a
> file called stdafx.h it insisted on adding.
>
> Anyway I have registered and agreed not to distribute any programs compiled
> with it as open source, etc, etc, etc. I've no real choice. A computer isn't
> a computer without a programming environment - it's just a glorified
> typewriter.

Why don't you purchase a copy of Visual Studio (TM)? Then you can
distribute your applications with source.

Glenn Hutchings

unread,
Feb 6, 2007, 1:57:13 PM2/6/07
to
On 6 Feb, 09:37, "Lane Straatman" <inva...@invalid.net> wrote:
> "Glenn Hutchings" <zond...@googlemail.com> wrote in message

> > For even more fun, try computing i ^ i. Betcha didn't see that
> > coming!
>
> We know that it exists as a complex that C can calculate from first
> principles. LS

Well duh. But my point is, what do you think the answer will be?

Glenn

Richard Heathfield

unread,
Feb 6, 2007, 2:08:26 PM2/6/07
to
santosh said:

Let's get this straight. He spent money on a Microsoft product (Visual
C++). He then spent some more money on another Microsoft product
(Vista), as a result of which his first product stopped working. Are
you really suggesting that he gives *even more* money to Microsoft, to
get back the functionality that he has *already paid for*?

Have you ever heard of the expression "throwing good money after bad"?

sjde...@yahoo.com

unread,
Feb 6, 2007, 2:45:43 PM2/6/07
to

Is mingw working on Vista? I've had no problems with using it on
various older Windows versions, it's free, and you can distribute open
source and other software compiled with it.

Keith Thompson

unread,
Feb 6, 2007, 6:04:38 PM2/6/07
to
"Malcolm McLean" <regn...@btinternet.com> writes:
[...]

> Anyway I have registered and agreed not to distribute any programs compiled
> with it as open source, etc, etc, etc. I've no real choice. A computer isn't
> a computer without a programming environment - it's just a glorified
> typewriter.

Do they *really* require you to agree to that? How can they enforce a
restriction like that? If you distribute your own source code, how
can the fact that you've fed it to their compiler affect your rights?
I suspect the situation isn't that simple.

You can always install Cygwin, which includes gcc (I'm not sure how
much support it has for Windows-specific programming, though).

Lane Straatman

unread,
Feb 6, 2007, 7:10:09 PM2/6/07
to

"Richard Heathfield" <r...@see.sig.invalid> wrote in message
news:ncSdnet7J-AoTFXY...@bt.com...

> santosh said:
>
>> Malcolm McLean wrote:
>>> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
>> <snip>
>>
>>> > You have just discovered that Microsoft aren't all that interested
>>> > in supporting "legacy software" (e.g. their own two-year-old
>>> > compiler, if your account is anything to go by). Have you
>>> > considered porting your stuff to a more stable platform?
>>> >
>>> They do offer a free compiler. It looks pretty horrid, but at least
>>> it compiled "Hello World" - not without five minutes tweaking to get
>>> rid of a file called stdafx.h it insisted on adding.
You asked it to do that.

>>> Anyway I have registered and agreed not to distribute any programs
>>> compiled with it as open source, etc, etc, etc. I've no real choice.
>>> A computer isn't a computer without a programming environment - it's
>>> just a glorified typewriter.
>>
>> Why don't you purchase a copy of Visual Studio (TM)? Then you can
>> distribute your applications with source.
>
> Let's get this straight. He spent money on a Microsoft product (Visual
> C++). He then spent some more money on another Microsoft product
> (Vista), as a result of which his first product stopped working. Are
> you really suggesting that he gives *even more* money to Microsoft, to
> get back the functionality that he has *already paid for*?
>
> Have you ever heard of the expression "throwing good money after bad"?

The money I spent to buy MVC++4 I saved from my mouth. I'm just now
retiring it after -I dunno-a decade? of service. He has no business near a
keyboard if he doesn't know how to uninstall and reinstall. And if the
registry's forked then deltree C: and move on with a re-install that every
prudent user marks well for himself. Twenty bucks a year was good money for
me. I think spending any money on a computer for this guy is bad money. He
has no real choice about distributing software, as he lacks the ability to
manipulate the dominant OS. LS


Dik T. Winter

unread,
Feb 6, 2007, 7:50:58 PM2/6/07
to

An interesting first question is: is it real, imaginary or neither.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/

Lane Straatman

unread,
Feb 6, 2007, 8:32:34 PM2/6/07
to

"Glenn Hutchings" <zon...@googlemail.com> wrote in message
news:1170788233.2...@l53g2000cwa.googlegroups.com...
#include <stdio.h>
#include <complex.h>
int main() {
long double complex z1;
z1= I;
z1 = cpow(z1, z1);
printf("%lf %lf ", z1);
return 0;}
--
LS


Lane Straatman

unread,
Feb 6, 2007, 8:44:16 PM2/6/07
to

"Glenn Hutchings" <zon...@googlemail.com> wrote in message
news:1170748794....@a75g2000cwd.googlegroups.com...
I stated in this thread that I wanted to take e to the i pi and get as close
as I could with it using pre-defined types. I think i^i better suits this
purpose. LS


CBFalconer

unread,
Feb 6, 2007, 8:20:16 PM2/6/07
to
Lane Straatman wrote:
>
... snip ...

>
> I think spending any money on a computer for this guy is bad money.
> He has no real choice about distributing software, as he lacks the
> ability to manipulate the dominant OS.

Dominant? The cockroach population of NYC exceeds the human
population. Does that make them dominant?

Keith Thompson

unread,
Feb 6, 2007, 9:26:55 PM2/6/07
to

The "%lf" format specifier is invalid. The format for double is "%f";
the format for long double is "%Lf". Some implementations may support
"%lf" as an extension.

The "%Lf" format specifier requires an argument of type long double;
two such specifiers don't magically consume a single argument of type
long double complex. (I think I've mentioned this to you before.)

Even for a short program, *please* indent your code properly; it makes
it much easier to read.

Here's a corrected and simplified version of your program:

#include <stdio.h>
#include <complex.h>
int main(void)
{
const long double complex z1 = cpowl(I, I);
printf("%Lf %Lf\n", creall(z1), cimagl(z1));
return 0;
}

and its output:

0.207880 0.000000

You can get more digits by tweaking the format specifiers.

Apparently i^i (where i is the imaginary square root of -1 and "^"
denotes exponentiation) is a real number. I'm sure there's a simple
mathematical proof of this, but I'm too lazy to track it down or
reconstruct it.

Keith Thompson

unread,
Feb 6, 2007, 9:29:44 PM2/6/07
to

That makes no sense. e^(i*pi) is -1; i^i is a completely different
real value, approximately 0.20788. I won't waste my time trying to
figure out what you really meant.

Dave Vandervies

unread,
Feb 6, 2007, 9:47:57 PM2/6/07
to
In article <ln4ppyg...@nuthaus.mib.org>,
Keith Thompson <ks...@mib.org> wrote:

[Snip everything C-related]

>Apparently i^i (where i is the imaginary square root of -1 and "^"
>denotes exponentiation) is a real number. I'm sure there's a simple
>mathematical proof of this, but I'm too lazy to track it down or
>reconstruct it.

Note that e^(i*pi/2) = i (this follows from the theorem that says
e^(i*x)=cos x + i*sin x). This tells us that ln(i) = i*pi/2.

So:
i = e^(ln i)
i^i = (e^(ln i))^i
= e^(ln i * i)

Completing the proof is left as an exercise for the reader.


dave

--
Dave Vandervies dj3v...@csclub.uwaterloo.ca
I wonder if it has something to do with being able to accurately handle
an excruciating amount of detail without checking yourself into a mental
institution. --Logan Shaw in the scary devil monastery

Lane Straatman

unread,
Feb 7, 2007, 1:07:41 AM2/7/07
to

"CBFalconer" <cbfal...@yahoo.com> wrote in message
news:45C92950...@yahoo.com...

> Lane Straatman wrote:
>>
> ... snip ...
>>
>> I think spending any money on a computer for this guy is bad money.
>> He has no real choice about distributing software, as he lacks the
>> ability to manipulate the dominant OS.
>
> Dominant? The cockroach population of NYC exceeds the human
> population. Does that make them dominant?
Sitting here as I do on Martin Luther King blvd., you need to know that the
only answer I have to that is *yes.* LS


Lane Straatman

unread,
Feb 7, 2007, 1:11:35 AM2/7/07
to

"Dave Vandervies" <dj3v...@caffeine.csclub.uwaterloo.ca> wrote in message
news:eqbekt$k68$1...@rumours.uwaterloo.ca...

> In article <ln4ppyg...@nuthaus.mib.org>,
> Keith Thompson <ks...@mib.org> wrote:
>
> [Snip everything C-related]
>
>>Apparently i^i (where i is the imaginary square root of -1 and "^"
>>denotes exponentiation) is a real number. I'm sure there's a simple
>>mathematical proof of this, but I'm too lazy to track it down or
>>reconstruct it.
>
> Note that e^(i*pi/2) = i (this follows from the theorem that says
> e^(i*x)=cos x + i*sin x). This tells us that ln(i) = i*pi/2.
>
> So:
> i = e^(ln i)
> i^i = (e^(ln i))^i
> = e^(ln i * i)
>
> Completing the proof is left as an exercise for the reader.
That's a nice touch. LS


Richard Heathfield

unread,
Feb 7, 2007, 2:31:24 AM2/7/07
to
Keith Thompson said:

> "Lane Straatman" <inv...@invalid.net> writes:

<snip>

>> z1 = cpow(z1, z1);
>> printf("%lf %lf ", z1);
>> return 0;}
>
> The "%lf" format specifier is invalid.

Tiny nit time. That is not true in C99, which the above program clearly
must be. See 7.19.6.1(7): "l (ell) [...] has no effect on a following
a, A, e, E, f, F, g, or G conversion specifier."

So "%lf" is equivalent to "%f". So that has nothing to do with his bug
(which, as you noted elsewhere, is probably more to do with the fact
that he has two format specifiers but only one datum, and that being of
the wrong type!).

<snip>

Malcolm McLean

unread,
Feb 7, 2007, 3:07:22 AM2/7/07
to
"Keith Thompson" <ks...@mib.org> wrote in message

> "Malcolm McLean" <regn...@btinternet.com> writes:
> [...]
>> Anyway I have registered and agreed not to distribute any programs
>> compiled
>> with it as open source, etc, etc, etc. I've no real choice. A computer
>> isn't
>> a computer without a programming environment - it's just a glorified
>> typewriter.
>
> Do they *really* require you to agree to that? How can they enforce a
> restriction like that? If you distribute your own source code, how
> can the fact that you've fed it to their compiler affect your rights?
> I suspect the situation isn't that simple.
>
> You can always install Cygwin, which includes gcc (I'm not sure how
> much support it has for Windows-specific programming, though).
>
I think actually the open source restriction applies to anything based on
their samples.
Since the API is so intricate the only sensible way to to take a working
program and modify it, this could be very broad. They are obviously scared
of GNU.

I didn't read the agreement very carefully. I doubt the thing has any legal
force because you are logging into a computer, not signing a binding
contract.

The saga continues. I installed the free C compiler. It compiles "hello
world". But it won't do a Windows program. I didn't buy Vista for its
command shell capabilities, so I download the SDK. Fair enough. The compiler
won't recognise it. After about two hour rooting about on the web, I find a
Microsoft page telling me how to edit various configuration files to get it
to work - two of them, plus paths. Meanwhile the OS merrily throws threats
at every edit. Of course I make a typing mistake. At 1.00 in the morning, I
finally get a "Hello World" - in C++, I haven't figiured out how to get C
mode yet.

I am a programmer not a hacker. Some people might see this as an interesting
challenge. Personally I just see it as a total nuisance which takes times
from what I should be doing, like adding subroutines to BASICdraw. Two days
wasted. This sort of thing is often rationalised as "teething troubles". In
fact it is a constant situation. At work I am struggling with two new
programming environments - R and a new Lisp compiler. In computing, you are
very frequently using software for the first time.


Keith Thompson

unread,
Feb 7, 2007, 3:07:54 AM2/7/07
to
Richard Heathfield <r...@see.sig.invalid> writes:
> Keith Thompson said:
>
>> "Lane Straatman" <inv...@invalid.net> writes:
>
> <snip>
>
>>> z1 = cpow(z1, z1);
>>> printf("%lf %lf ", z1);
>>> return 0;}
>>
>> The "%lf" format specifier is invalid.
>
> Tiny nit time. That is not true in C99, which the above program clearly
> must be. See 7.19.6.1(7): "l (ell) [...] has no effect on a following
> a, A, e, E, f, F, g, or G conversion specifier."

You're right, I missed that.

Malcolm McLean

unread,
Feb 7, 2007, 3:17:25 AM2/7/07
to

"Dave Vandervies" <dj3v...@caffeine.csclub.uwaterloo.ca> wrote in message
>
> So:
> i = e^(ln i)
> i^i = (e^(ln i))^i
> = e^(ln i * i)
>
Wow.That's clever.

> Note that e^(i*pi/2) = i (this follows from the theorem that says
> e^(i*x)=cos x + i*sin x). This tells us that ln(i) = i*pi/2.
>

Can't say this bit about e^(i*x) = cos x + i * sin x is too convincing
though. Do you think he's trying to pull a fast one on us?


Richard Tobin

unread,
Feb 7, 2007, 6:15:34 AM2/7/07
to
In article <ln4ppyg...@nuthaus.mib.org>,
Keith Thompson <ks...@mib.org> wrote:

>Apparently i^i (where i is the imaginary square root of -1 and "^"
>denotes exponentiation) is a real number. I'm sure there's a simple
>mathematical proof of this, but I'm too lazy to track it down or
>reconstruct it.

It's exp(-pi/2). Someone else showed the proof, but you can just type
"i^i" into Google to see the numerical value.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.

Richard Tobin

unread,
Feb 7, 2007, 6:17:07 AM2/7/07
to
In article <eLGdnXXltK2aFlTY...@bt.com>,
Malcolm McLean <regn...@btinternet.com> wrote:

>Can't say this bit about e^(i*x) = cos x + i * sin x is too convincing
>though.

Consider the polynomial expansion e^x = 1 + x + x^2/2! + x^3/3! + ...

Hallvard B Furuseth

unread,
Feb 7, 2007, 8:32:11 AM2/7/07
to
Dave Vandervies writes:
> Note that e^(i*pi/2) = i (this follows from the theorem that says
> e^(i*x)=cos x + i*sin x).

It also follows from e^(i*pi) + 1 = 0: e^(i*pi)^(1/2) = (-1)^(1/2).

> This tells us that ln(i) = i*pi/2.
> So:
> i = e^(ln i)
> i^i = (e^(ln i))^i
> = e^(ln i * i)

--
Hallvard

Lane Straatman

unread,
Feb 7, 2007, 11:37:37 AM2/7/07
to

"Richard Tobin" <ric...@cogsci.ed.ac.uk> wrote in message
news:eqcccm$185m$1...@pc-news.cogsci.ed.ac.uk...

> In article <ln4ppyg...@nuthaus.mib.org>,
> Keith Thompson <ks...@mib.org> wrote:
>
>>Apparently i^i (where i is the imaginary square root of -1 and "^"
>>denotes exponentiation) is a real number. I'm sure there's a simple
>>mathematical proof of this, but I'm too lazy to track it down or
>>reconstruct it.
>
> It's exp(-pi/2). Someone else showed the proof, but you can just type
> "i^i" into Google to see the numerical value.
http://www.billfordx.net/screendumps/cstuff_7.htm

Clearly, this latest version is off. Heathfield says I have two specifiers
for one datum. Is it not a datum with a real and a complex part, both of
which need attention in the conversion specifiers?

How many decimal places can we squeeze from a long double? LS


Walter Roberson

unread,
Feb 7, 2007, 11:51:04 AM2/7/07
to
In article <g7KdnYYqcflFYlTY...@comcast.com>,
Lane Straatman <inv...@invalid.net> wrote:

>How many decimal places can we squeeze from a long double? LS

C99 defines minimums for that, but not maximums -- an implementation
could in theory have a long double that was a kilobyte long (or more.)
--
Prototypes are supertypes of their clones. -- maplesoft

Lane Straatman

unread,
Feb 7, 2007, 12:06:04 PM2/7/07
to

"Walter Roberson" <robe...@ibd.nrc-cnrc.gc.ca> wrote in message
news:eqd01o$j6h$1...@canopus.cc.umanitoba.ca...

> In article <g7KdnYYqcflFYlTY...@comcast.com>,
> Lane Straatman <inv...@invalid.net> wrote:
>
>>How many decimal places can we squeeze from a long double? LS
>
> C99 defines minimums for that, but not maximums -- an implementation
> could in theory have a long double that was a kilobyte long (or more.)
Right, what is the minimum maximum? LS

Walter Roberson

unread,
Feb 7, 2007, 12:15:02 PM2/7/07
to
In article <cOydnaFhIIUem1fY...@comcast.com>,
Lane Straatman <inv...@invalid.net> wrote:

>> In article <g7KdnYYqcflFYlTY...@comcast.com>,
>> Lane Straatman <inv...@invalid.net> wrote:

>>>How many decimal places can we squeeze from a long double? LS

>Right, what is the minimum maximum? LS

Looks like 31 significant digits.

http://64.233.167.104/search?q=cache:WcAVDnIJNk4J:publib.boulder.ibm.com/infocenter/pseries/v5r3/topic/com.ibm.aix.genprogc/doc/genprogc/128bit_long_double_floating-point_datatype.htm

Hmmm, odd representation method...

A 128-bit long double number consists of an ordered pair of 64-bit
double-precision numbers. The first member of the ordered pair contains
the high-order part of the number, and the second member contains the
low-order part. The value of the long double quantity is the sum of the
two 64-bit numbers.

Is that the standard mechanism??
--
All is vanity. -- Ecclesiastes

Lane Straatman

unread,
Feb 7, 2007, 12:25:19 PM2/7/07
to

"Lane Straatman" <inv...@invalid.net> wrote in message
news:12sflmi...@corp.supernews.com...
> "Lane Straatman" <inv...@invalid.net> wrote in message

> Am I going to get in trouble with atan as I've got it? LS
de.sci.mathematik identified a possible division by zero and a fix:

#include <stdio.h>
#include <stdlib.h>
#include <complex.h>
#include <math.h>
int main(void)
{
long double complex z1, z3, z4, z5;
long double mod, phi, a, b, c, d;
z1 = .4 + .7I;
a = creal(z1);
b = cimag(z1);
// mod = sqrt(pow(a, 2) + pow(b, 2));
mod = cabs(z1);
// phi = atan(b/a);
phi = carg(z1);
c = ( (sqrt(mod)) * cos( .5 * phi ) );
d = ( (sqrt(mod)) * sin( .5 * phi ) );
z4 = c + d*I;
z5 = cpow(z1, .5);
z3 = cpow(z4, 2.0);
printf("The square root of %lf %lfi\n", creal(z1), cimag(z1));
printf("is : %lf %lfi\n", creal(z4), cimag(z4));
printf("using cpow to get the root: %15lf %15lfi\n", creal(z5),
cimag(z5));
printf("using cpow to check the square: %lf %lfi\n", creal(z3),
cimag(z3));
system("PAUSE");
return 0;
}
/*
Lane Straatman wrote:
Es wird zwar leicht OT, aber seisdrum:

> double complex z1, z3, z4, z5;
> double mod, phi, a, b, c, d;
> a = creal(z1);
> b = cimag(z1);
> mod = sqrt(pow(a, 2) + pow(b, 2));
mod = cabs(z1);
> phi = atan(b/a);
phi = carg(z1);
(Erschlägt auch das Quadranten- und DIV0-Problem.)
> system("PAUSE");

Nett.

Viele Grüße
Steffen
*/
Is six digits all I'm going to get out of a long double? LS


santosh

unread,
Feb 7, 2007, 1:14:58 PM2/7/07
to

Okay, I thought he used the freely available Visual C++ Express
Edition, which, I think, prohibits commercial use. If he did buy a
full fleged version of Visual Studio and it's now broken by upgrade to
Vista, then that's indeed a shame. MS does recommend a clean install
instead of an upgrade.

Well, seeing as he's unwilling to move to a better platform, I guess
he has little choice but to reinstall the Latest and Greatest version
of Visual Studio. It was an advice specific to the context. Generally,
I'm not a fan of Microsoft's products, primarily because of their
inflated pricing and general elitism. I haven't used a Windows version
in two years. However some people are tied to it, for one reason or
another and simply telling them to move to Linux, or whatever, doesn't
work.

The bigger question is why Malcolm doesn't use a free development
system like MinGW. Combined with the Platform SDK, you can do nearly
everything with it, that you'd do with MSVC++.

santosh

unread,
Feb 7, 2007, 1:18:09 PM2/7/07
to
CBFalconer wrote:
> Lane Straatman wrote:
> >
> ... snip ...
> >
> > I think spending any money on a computer for this guy is bad money.
> > He has no real choice about distributing software, as he lacks the
> > ability to manipulate the dominant OS.
>
> Dominant? The cockroach population of NYC exceeds the human
> population. Does that make them dominant?

Numerically they are. There're many possible definitions of dominant.
Such decisions are usually subjective and hence not authoritative.

santosh

unread,
Feb 7, 2007, 1:24:27 PM2/7/07
to

Yes.

Tools are now so complex that they tend to create more problems than
they purport to solve. These problems are typically solved by yet more
tools and the vicious cycle continues, feeding the growth of software
engineering and quality assurance.

Standard C is a breath of fresh air in all this quagmire of complexity.

Lane Straatman

unread,
Feb 7, 2007, 1:43:00 PM2/7/07
to

"santosh" <santo...@gmail.com> wrote in message
news:1170872098.6...@l53g2000cwa.googlegroups.com...

> Richard Heathfield wrote:
>> santosh said:
>> > Malcolm McLean wrote:
>> >> "Richard Heathfield" <r...@see.sig.invalid> wrote in message
>> > <snip>
>> >
>> >> > You have just discovered that Microsoft aren't all that interested
>> >> > in supporting "legacy software" (e.g. their own two-year-old
>> >> > compiler, if your account is anything to go by). Have you
>> >> > considered porting your stuff to a more stable platform?
>> >> >
>> >> They do offer a free compiler. It looks pretty horrid, but at least
>> >> it compiled "Hello World" - not without five minutes tweaking to get
>> >> rid of a file called stdafx.h it insisted on adding.
It looks slick as all get out. Looks don't count for much though. I can't
find a run button or pull-down and don't want to have to step outside the
IDE to run the executable:
http://www.billfordx.net/screendumps/cstuff_8.htm

>> >> Anyway I have registered and agreed not to distribute any programs
>> >> compiled with it as open source, etc, etc, etc. I've no real choice.
>> >> A computer isn't a computer without a programming environment - it's
>> >> just a glorified typewriter.
>> >
>> > Why don't you purchase a copy of Visual Studio (TM)? Then you can
>> > distribute your applications with source.
>>
>> Let's get this straight. He spent money on a Microsoft product (Visual
>> C++). He then spent some more money on another Microsoft product
>> (Vista), as a result of which his first product stopped working. Are
>> you really suggesting that he gives *even more* money to Microsoft, to
>> get back the functionality that he has *already paid for*?
>>
>> Have you ever heard of the expression "throwing good money after bad"?
>
> Okay, I thought he used the freely available Visual C++ Express
> Edition, which, I think, prohibits commercial use. If he did buy a
> full fleged version of Visual Studio and it's now broken by upgrade to
> Vista, then that's indeed a shame. MS does recommend a clean install
> instead of an upgrade.

MS thought that it was fiscally irresponsible to do otherwise. I would try
to use the word "fiduciary" in a sentence with "stockholders," but Eric
Sosman is just waiting to zing me again.

> Well, seeing as he's unwilling to move to a better platform, I guess
> he has little choice but to reinstall the Latest and Greatest version
> of Visual Studio. It was an advice specific to the context. Generally,
> I'm not a fan of Microsoft's products, primarily because of their
> inflated pricing and general elitism. I haven't used a Windows version
> in two years. However some people are tied to it, for one reason or
> another and simply telling them to move to Linux, or whatever, doesn't
> work.

A person needs to ante up if he wants to get into dotnet.

> The bigger question is why Malcolm doesn't use a free development
> system like MinGW. Combined with the Platform SDK, you can do nearly
> everything with it, that you'd do with MSVC++.

I've had a very good experience this last week with Devcpp. Up and running
immediately. I'll post the above link in an ng with MS in the name and see
what comes. LS


It is loading more messages.
0 new messages