e to the i pi

L

Lane Straatman

#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
 
M

Malcolm McLean

Lane Straatman said:
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.
 
D

Dave Vandervies

[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
 
L

Lane Straatman

Malcolm McLean said:
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
 
C

CBFalconer

Malcolm said:
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.
 
C

CBFalconer

Lane said:
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.
 
E

Eric Sosman

Malcolm said:
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.
 
R

Richard Heathfield

CBFalconer said:
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.
 
R

Richard Heathfield

Eric Sosman said:
That's plane wrong.

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

Malcolm McLean

Richard Heathfield said:
CBFalconer said:


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.
 
L

Lane Straatman

Richard Tobin said:
If this is meant to be e, it's wrong. e is 2.718281828+


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


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
 
D

Dave Vandervies

Lane Straatman said:
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
 
L

Lane Straatman

[...]
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
 
E

Eric Sosman

Lane said:
#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.
 
J

jacob navia

Lane Straatman a écrit :
[...]
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
 
L

Lane Straatman

CBFalconer said:
Lane Straatman wrote:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top