e to the i pi

R

Richard Bos

JimS said:
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
 
D

Dik T. Winter

> In article <[email protected]>,

>
> If I understand your post correctly, this should be
> z3=2.718281828459045 + 0*I;
>
>
> '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.
 
F

Fred Kleinschmidt

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.

-- Richard

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

osmium

Fred Kleinschmidt said:
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.
 
J

jacob navia

osmium said:
:




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

Richard Tobin

osmium said:
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
 
F

Fred Kleinschmidt

osmium said:
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.
 
U

user923005

Eric Sosman said:



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

Keith Thompson

jacob navia said:
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...

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

Keith Thompson

user923005 said:
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).
 
U

user923005

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?
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?
:-(
 
L

Lane Straatman

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

Lane Straatman

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

Richard Heathfield

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

Malcolm McLean

Richard Heathfield said:
Malcolm McLean said:


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.


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.
 

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,777
Messages
2,569,604
Members
45,217
Latest member
topweb3twitterchannels

Latest Threads

Top