473,408 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

e to the i pi

#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
Feb 4 '07 #1
123 4165

"Lane Straatman" <in*****@invalid.netwrote 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.

Feb 4 '07 #2
In article <44******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:

[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 dj******@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
Feb 4 '07 #3

"Malcolm McLean" <re*******@btinternet.comwrote in message
news:9O******************************@bt.com...
>
"Lane Straatman" <in*****@invalid.netwrote 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.
e is the first transcendental (Louisville, I believe). pi is the second.
They are not equal. LS
Feb 4 '07 #4
Malcolm McLean wrote:
"Lane Straatman" <in*****@invalid.netwrote 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>
Feb 4 '07 #5
Lane Straatman wrote:
"Malcolm McLean" <re*******@btinternet.comwrote in message
>"Lane Straatman" <in*****@invalid.netwrote 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.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Feb 4 '07 #6
Malcolm McLean wrote:
"Lane Straatman" <in*****@invalid.netwrote 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.

--
Eric Sosman
es*****@acm-dot.org.invalid
Feb 4 '07 #7
CBFalconer said:
Malcolm McLean wrote:
>"Lane Straatman" <in*****@invalid.netwrote 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.
Feb 4 '07 #8
Eric Sosman said:
Malcolm McLean wrote:
>"Lane Straatman" <in*****@invalid.netwrote 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.

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

"Richard Heathfield" <rj*@see.sig.invalidwrote in message
CBFalconer said:
>Malcolm McLean wrote:
>>"Lane Straatman" <in*****@invalid.netwrote 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.
Feb 4 '07 #10
In article <44******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:
>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.
Feb 4 '07 #11

"Richard Tobin" <ri*****@cogsci.ed.ac.ukwrote in message
news:eq**********@pc-news.cogsci.ed.ac.uk...
In article <44******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:
>>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
Feb 4 '07 #12
In article <jY******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:
>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 dj******@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
Feb 4 '07 #13

"Malcolm McLean" <re*******@btinternet.comwrote in message
news:MK******************************@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
Feb 4 '07 #14
Lane Straatman wrote:
"Richard Tobin" <ri*****@cogsci.ed.ac.ukwrote in message
news:eq**********@pc-news.cogsci.ed.ac.uk...
>In article <44******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:
>>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
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
es*****@acm-dot-org.invalid
Feb 4 '07 #15
Dave Vandervies wrote:
>
In article <jY******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:
arctan
actan
atan

--
pete
Feb 4 '07 #16
pete <pf*****@mindspring.comwrites:
Dave Vandervies wrote:
>>
In article <jY******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:
arctan
>actan

atan
achoo!
--
"C has its problems, but a language designed from scratch would have some too,
and we know C's problems."
--Bjarne Stroustrup
Feb 4 '07 #17
Lane Straatman a écrit :
"Malcolm McLean" <re*******@btinternet.comwrote in message
news:MK******************************@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
Feb 4 '07 #18
In article <45**********@mindspring.com>, pete <pf*****@mindspring.comwrote:
>Dave Vandervies wrote:
>>
In article <jY******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:
arctan
>actan

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

--
Dave Vandervies dj******@csclub.uwaterloo.ca

Dysfunctional programming seems to be so much more popular these days.
--James Riden in the scary devil monastery
Feb 4 '07 #19

"CBFalconer" <cb********@yahoo.comwrote in message
news:45***************@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
Feb 4 '07 #20

"Eric Sosman" <es*****@acm-dot-org.invalidwrote in message
news:_8******************************@comcast.com. ..
Malcolm McLean wrote:
>"Lane Straatman" <in*****@invalid.netwrote 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
Feb 4 '07 #21
"Malcolm McLean" <re*******@btinternet.comwrites:
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
CBFalconer said:
Malcolm McLean wrote:
"Lane Straatman" <in*****@invalid.netwrote 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.
Feb 4 '07 #22
Richard Heathfield <rj*@see.sig.invalidwrites:
Eric Sosman said:
Malcolm McLean wrote:
"Lane Straatman" <in*****@invalid.netwrote 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 (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.
Feb 4 '07 #23
"Lane Straatman" <in*****@invalid.netwrites:
[...]
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)

--
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.
Feb 4 '07 #24

"Keith Thompson" <ks***@mib.orgwrote 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.
Feb 4 '07 #25
Malcolm McLean said:
>
"Keith Thompson" <ks***@mib.orgwrote 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.

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

"jacob navia" <ja***@jacob.remcomp.frwrote in message
news:45***********************@news.orange.fr...
Lane Straatman a écrit :
>"Malcolm McLean" <re*******@btinternet.comwrote in message
news:MK******************************@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
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
Feb 4 '07 #27

"Richard Heathfield" <rj*@see.sig.invalidwrote 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?
Feb 4 '07 #28
"Lane Straatman" <in*****@invalid.netwrites:
[...]
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.hjust lets you use simple names for math functions that work
with any real type. The declarations in <tgmath.hare "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").

--
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.
Feb 4 '07 #29
Malcolm McLean said:
>
"Richard Heathfield" <rj*@see.sig.invalidwrote 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?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 4 '07 #30
On Sun, 04 Feb 2007 22:07:58 +0000, Richard Heathfield
<rj*@see.sig.invalidwrote:
>Malcolm McLean said:
>>
"Keith Thompson" <ks***@mib.orgwrote 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
Feb 5 '07 #31

"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
Richard Heathfield <rj*@see.sig.invalidwrites:
>Eric Sosman said:
Malcolm McLean wrote:
"Lane Straatman" <in*****@invalid.netwrote 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
Feb 5 '07 #32
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.
Feb 5 '07 #33

"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:ta******************************@bt.com...
Malcolm McLean said:
>>
"Richard Heathfield" <rj*@see.sig.invalidwrote 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."
Feb 5 '07 #34
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
Feb 5 '07 #35

"Tim Prince" <tp*****@nospamcomputer.orgwrote in message
news:kY****************@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. I had a conversation with C_Dreamer about this.
LS
Feb 5 '07 #36
"Lane Straatman" <in*****@invalid.netwrote:
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
Feb 5 '07 #37
"Malcolm McLean" <re*******@btinternet.comwrote:
"Keith Thompson" <ks***@mib.orgwrote 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
Feb 5 '07 #38
Lane Straatman said:
>
"Tim Prince" <tp*****@nospamcomputer.orgwrote in message
news:kY****************@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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 5 '07 #39
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
Feb 5 '07 #40
JimS <so***@not.comwrote:
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
Feb 5 '07 #41
In article <eq**********@rumours.uwaterloo.cadj******@caffeine.csclub.uwaterloo.ca (Dave Vandervies) writes:
In article <44******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:
....
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/
Feb 5 '07 #42

"Richard Tobin" <ri*****@cogsci.ed.ac.ukwrote in message
news:eq**********@pc-news.cogsci.ed.ac.uk...
In article <44******************************@comcast.com>,
Lane Straatman <in*****@invalid.netwrote:
>>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
Feb 5 '07 #43
Fred Kleinschmidt said:

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

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Feb 5 '07 #44
In article <JC********@news.boeing.com>,
Fred Kleinschmidt <fr******************@boeing.comwrote:
>Aren't M_PI and M_E defined in math.h?
Yes, but unfortunately not on systems conforming only to the C
standard.

-- Richard

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Feb 5 '07 #45
"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.
Feb 5 '07 #46
In article <52*************@mid.individual.net>,
osmium <r1********@comast.netwrote:
>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.

-- Richard


--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Feb 5 '07 #47
osmium wrote:
"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.

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...
Feb 5 '07 #48

"osmium" <r1********@comcast.netwrote in message
news:52*************@mid.individual.net...
"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.
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
Feb 5 '07 #49
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>

"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

Feb 5 '07 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.