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
[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
Not in the complex field.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
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.
That's plane wrong.
--
Eric Sosman
eso...@acm-dot.org.invalid
> 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.
> 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.
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.
>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.
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
>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
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
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
> actan
atan
--
pete
achoo!
--
"C has its problems, but a language designed from scratch would have some too,
and we know C's problems."
--Bjarne Stroustrup
That will never work.
Sorry, header files are NOT portable
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
>> 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
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.
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*
exp(1.0)
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.
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
They are up to service pack 7 within one week of the OS coming on market?
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" <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?
>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
> 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
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
> 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
> "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
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.
Use long double, then. And atanl, cexpl.
--
Hallvard
> 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
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/
Aren't M_PI and M_E defined in math.h?
--
Fred L. Kleinschmidt
<snip>
> Aren't M_PI and M_E defined in math.h?
No.
Yes, but unfortunately not on systems conforming only to the C
standard.
> 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.
>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.
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
No.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
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
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>.
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).
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 -
>> 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
>
>> 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.
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>
>> 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.
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.
> For fun, try 23.140693 ^ i.
For even more fun, try computing i ^ i. Betcha didn't see that
coming!
Glenn
>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.>
>
>> 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
>>
>> 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
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.
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".
<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.
>
> 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.
> > 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.
Well duh. But my point is, what do you think the answer will be?
Glenn
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"?
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.
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).
>>> 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
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/
Dominant? The cockroach population of NYC exceeds the human
population. Does that make them dominant?
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.
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.
[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" <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>
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.
You're right, I missed that.
> 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?
>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.
>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! + ...
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
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
>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
>> 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.
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
> 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
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++.
Numerically they are. There're many possible definitions of dominant.
Such decisions are usually subjective and hence not authoritative.
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.
>> >> 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