March 09, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to Mike Wynn | > I think the point was that the usual (an accepted) name of the functions you > call abs > is magnitude, modulus or norm depending on the item and if your a mathmation > or engineer (j not i) > is there a mathmatical 'abs' for a complex number, quaternion, vector, > matrix ? > I though it was just reals that had an abs; a vector abs I would expect to > abs the elements not return magnitude. > > does D have a conjugate property for complex ? > > magnitude ::= a * a.conjugate; // (a+ib)*(a-ib) = a*a + b*b; > True, the engineering notation for 'i' is actually 'j'. But it really makes no difference other than convention.. I'm not an expert on these matters, but I do use the features of complex numbers in my electronics studies. The "abs" moniker was not my choice. It was just the convention I noticed that is used for getting the magnitude of a complex number (Python uses it too). As far as I see, abs is fairly standard use for deriving this value when it comes to complex numbers. So my point is that "abs" IS the usual and accepted name for this funciton no matter what it's meaning or name is in other number sets or systems. This is actually the standard mathematical definition of the "absolute value of the complex number": "The modulus or absolute value of a complex number a + bi is | a + bi | = sqrt( a*a + b*b) from A Second Course in Calculus, ISBN 0-12-259662-5 Now this may be a fairly basic "length" expression as Sean mentioned, but it seems that people got confused over the use of the term "absolute value" in complex speech. Sean's tone appeared slightly belittling, thus my response. I really hate to beat this topic to death, but I just wanted to verify that abs is actually very much the correct mathematical term for this value. As for use of "abs" for quaternion's, 3D vectors or whatnot, I'm not sure if they share the idea of "abs" for obtaining the magnitude. I'm sure there's a few such experts in this group anyway so I needn't speculate. A conjugate property would be another useful addition; I agree. But I don't understand your use of the term magnitude here. Later, John |

March 09, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to John Reimer | ```
John Reimer wrote:
>>It's syntactually correct, but better is:
>>
>> real abs(creal c) {
>> return math2.hypot(c.re, c.im);
>> }
>>
>>As sqrt uses double, and hypot can do some overflow/underflow
>
> minimisation.
>
> That does look good :-). But I've never seen a math2 module before. Is it
> now part of phobos?
Yeah, it's a large set of routines that Pavel Minayev wrote. It should probably be merged with math. For your later concern, this is how Python implements complex abs.
``` |

March 09, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to John Reimer | > > > > magnitude ::= a * a.conjugate; // (a+ib)*(a-ib) = a*a + b*b; > > > > A conjugate property would be another useful addition; I agree. But I don't > understand your use of the term magnitude here. that's me not thinking forgot the root. got confused should have been if n = (a+ib) |n| = sqrt(a^2 +b^2) => |n| = sqrt( n * conjugate(n) ) if vector v = {a,b} ||v|| = sqrt(a^2 +b^2) => ||v|| = sqrt( v dot v ) I was reading something on 3d vectors that used |v| to mean v.v and ||v|| to mean sqrt(v.v) last week. anyway what about polar form of complex ? n = (a +ib) = r * (e to_the_power (i*arg)) = |n| (e to_the_power (i*arc_tan(y/x))) isn't that as important a part of complex maths as the a+ib form so creal should have a .magnitude and .arg property anyway. |

March 09, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to Mike Wynn | "Mike Wynn" <mike.wynn@l8night.co.uk> wrote in message news:b4ecf8$12f7$1@digitaldaemon.com... > > > > > > > magnitude ::= a * a.conjugate; // (a+ib)*(a-ib) = a*a + b*b; > > > > > > > > A conjugate property would be another useful addition; I agree. But I > don't > > understand your use of the term magnitude here. > > that's me not thinking forgot the root. got confused should have been Ah, I see now. > > if n = (a+ib) > |n| = sqrt(a^2 +b^2) => |n| = sqrt( n * conjugate(n) ) > > if vector v = {a,b} > ||v|| = sqrt(a^2 +b^2) => ||v|| = sqrt( v dot v ) > > I was reading something on 3d vectors that used > |v| to mean v.v and ||v|| to mean sqrt(v.v) > last week. I haven't investigate 3D vectors to deeply, but natrually 2D vector math and complex phasor math are understandably similar. They're just mapped to different "spaces.", and have there own associated rules. To be honest, I'm not familiar with the double bar notation with vectors. Interesting. > anyway what about polar form of complex ? > n = (a +ib) = r * (e to_the_power (i*arg)) = |n| (e to_the_power > (i*arc_tan(y/x))) > isn't that as important a part of complex maths as the a+ib form > so creal should have a .magnitude and .arg property anyway. Yes, you bet; polar form is just as important. Polar form a la Euler , 'abs' and 'arg' properties, should be available to make the complex type more complete. Later, John |

March 09, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to John Reimer | Eh, don't I feel stupid, seems like something a young math major should know doesn't it? That's what I get for trying to be too clever I guess. :-) "John Reimer" <jjreimer@telus.net> wrote in message news:b4ch6i$5o6$1@digitaldaemon.com... > > > Ok, thanks for the tip, Jon. I only wish it were that simple. I assumed that since the language provided complex numbers that everything would be ready to go as far as manipulating them was concerned. I guess not quite yet or maybe I just don't know how it's supposed to work. > > But I think your solution is not quite what I was getting at. The "abs" as > in absolute value is not the typical mathematical absolute value when complex numbers are concerned. Perhaps you were thinking that I wanted the > non-negative values of both real and imaginary parts? . > > Not so I'm afraid... I'm looking for the resultant magnitude of a complex pair (also referred as the absolute value in complex math for some weird reason) which is the pythagorean sum of the real and imaginary parts, or the > squareroot of the sum of the squares of the magnitudes of the real and imaginary parts (phew, what a mouthful). Complex numbers are used in electronics AC analysis and are often called phasors. They are also represented in polar form in which case the complex parts are converted to a > magnitude (abs) and a relative phase angle. It becomes necessary to convert > between formats now and again. > > As far as the lowlevel optimization goes, that's not really my concern yet... I just want it to work :-P. The implementor of the language's complex numbers should do those optimizations for me, I think :-). > > I guess I still have to figure out how to do all this in D. Python does it > seamlessly and provides all the necessary methods out of the box. D must not be there yet... :-) Oh well, it's a neat language, still. > > Thanks for the suggestion though; that's some pretty slick D hacking. :-) > > Later, > > John. > > > |

March 09, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to Jon Allen | "Jon Allen" <jallen@minotstateu.edu> wrote in message news:b4f0j5$1d4u$1@digitaldaemon.com... > Eh, don't I feel stupid, seems like something a young math major should know > doesn't it? That's what I get for trying to be too clever I guess. :-) > :-D No problem. That just happened to be one of the very few areas that I knew something of what I was talking about :-). Later, John |

March 09, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to John Reimer | Sorry I came off as "belittling". Not my intention. I was mainly pointing out the lack of such basic vector algebra functions in D, and the limiting focus on complex numbers to the exclusion of the more general case of arbitrary dimension vectors. I've seen the term "abs" used before to describe vector norm, and in fact it makes perfect sense (mapping functions of reals over higher-order vectors); just in my line of work most people use the word "norm" or "magnitude". I either want A) quaternions and 3d vectors included as basic types in D or B) complex to be removed to the standard library and applications programmers given the ability to do everything that complex does now. This is very close to being implemented already; the one thing lacking is that we cannot make new types such as "imaginary". Also there's no way we can do so with the same performance characteristics (especially in builds without inlining) that builtin types have. I think I've beat this horse to death already. My words seem to be falling on deaf ears. Sean "John Reimer" <jjreimer@telus.net> wrote in message news:b4e743$vuj$1@digitaldaemon.com... > > I think the point was that the usual (an accepted) name of the functions > you > > call abs > > is magnitude, modulus or norm depending on the item and if your a > mathmation > > or engineer (j not i) > > is there a mathmatical 'abs' for a complex number, quaternion, vector, > > matrix ? > > I though it was just reals that had an abs; a vector abs I would expect > to > > abs the elements not return magnitude. > > > > does D have a conjugate property for complex ? > > > > magnitude ::= a * a.conjugate; // (a+ib)*(a-ib) = a*a + b*b; > > > > True, the engineering notation for 'i' is actually 'j'. But it really makes > no difference other than convention.. I'm not an expert on these matters, but I do use the features of complex numbers in my electronics studies. The > "abs" moniker was not my choice. It was just the convention I noticed that > is used for getting the magnitude of a complex number (Python uses it too). > As far as I see, abs is fairly standard use for deriving this value when it > comes to complex numbers. So my point is that "abs" IS the usual and accepted name for this funciton no matter what it's meaning or name is in other number sets or systems. > > This is actually the standard mathematical definition of the "absolute value of the complex number": > > "The modulus or absolute value of a complex number a + bi is > > | a + bi | = sqrt( a*a + b*b) > > from A Second Course in Calculus, ISBN 0-12-259662-5 > > Now this may be a fairly basic "length" expression as Sean mentioned, but it > seems that people got confused over the use of the term "absolute value" in > complex speech. Sean's tone appeared slightly belittling, thus my response. > > I really hate to beat this topic to death, but I just wanted to verify that > abs is actually very much the correct mathematical term for this value. > > As for use of "abs" for quaternion's, 3D vectors or whatnot, I'm not sure if > they share the idea of "abs" for obtaining the magnitude. I'm sure there's > a few such experts in this group anyway so I needn't speculate. > > A conjugate property would be another useful addition; I agree. But I don't > understand your use of the term magnitude here. > > Later, > > John > > |

March 10, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to Sean L. Palmer | ```
Sean L. Palmer wrote:
> Sorry I came off as "belittling". Not my intention. I was mainly pointing
> out the lack of such basic vector algebra functions in D, and the limiting
> focus on complex numbers to the exclusion of the more general case of
> arbitrary dimension vectors.
>
> I've seen the term "abs" used before to describe vector norm, and in fact it
> makes perfect sense (mapping functions of reals over higher-order vectors);
> just in my line of work most people use the word "norm" or "magnitude".
>
> I either want
>
> A) quaternions and 3d vectors included as basic types in D
>
> or
>
> B) complex to be removed to the standard library and applications
> programmers given the ability to do everything that complex does now. This
> is very close to being implemented already; the one thing lacking is that
> we cannot make new types such as "imaginary". Also there's no way we can do
> so with the same performance characteristics (especially in builds without
> inlining) that builtin types have.
>
> I think I've beat this horse to death already. My words seem to be falling
> on deaf ears.
>
> Sean
If it helps, I think you've got a reasonable point of view. I'm a bit more of a minimalist than Walter. I would have kept out many of the features he's incorporated, including support for complex numbers, even though I sometimes use them in programming. I fault C++ for wasting years of the industry's time while compiler writers worked on implementing the standard.
I don't yet have the D compiler on my Linux system (I'm waiting for the GNU tie-in), but from the spec, it seems able to support both complex numbers and vectors in standard libraries. However, there will always be a speed penalty for add-ons like this. Also, you wont get any cool custom syntax for it. What can you do? No language can be all things to all people.
Bill
``` |

March 10, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to Burton Radons | Burton Radons wrote: > Yes, and it should be in. Feedback on what users of complex need is valuable, as there aren't many serious users of it here. Don't expect Hello Burton, First of all, a little rant. When thinking about complex numbers, please don't confuse them with vectors. You can't multply vectors*, but you CAN multiply complex numbers. As a physisist I am permanently using complex numbers. There is nothing complex or imaginary about them. They are just numbers, but numbers where you don't need to care when taking roots. Here is what I would like to see: 1) I don't see much use for a purely imaginary type, drop it! 2) I don't see much use for integer complex types, don't include it! 3) Properties: z := re + im*I, and x a real number z.abs() sqrt(re*re+im*im) z.abs2() re*re+im*im z.arg() atan2(re, im) z.phase() z/z.abs() z.re() re z.im() im*I z.rim() im z.conj() re-im*I z.I() z*I = -im + re*I I don't care about the given names, as long as they are short :-). 4) Functions on complex: Basic builtin: +, -, *, /, sqr := z*z, inv := 1/z, scalar(z1, z2) := z1.conj()*z2 Library: exp, cos, sin, tan, cosh, sinh, tanh ln, acos, asin, atan, acosh, asinh, atanh, pow(z1, z2), log(z1, z2), sqrt 5) Constructors: z = creal(re, im); z = creal.polar(modulus, argument); The distinction between properties and functions is somewhat arbitrary. In my eyes, a property shall return some known information about the variable, but what is known depends on the implementation of that variable (e.g., wether the compiler stores complex numbers in cartesian or polar format). One can argue with good reasons to move some of the above properties to the functions section. I have no objections against doing so. Greetings, Olaf *) At least, if you don't think of them as elements of a Clifford algebra. -- +----------------------------------------------------------------------+ I Dr. Olaf Rogalsky Institut f. Theo. Physik I I I Tel.: 09131 8528440 Univ. Erlangen-Nuernberg I I Fax.: 09131 8528444 Staudtstrasse 7 B3 I I rogalsky@theorie1.physik.uni-erlangen.de D-91058 Erlangen I +----------------------------------------------------------------------+ |

March 10, 2003 Re: abs property for creal? | ||||
---|---|---|---|---|

| ||||

Posted in reply to Olaf Rogalsky | > > First of all, a little rant. When thinking about complex numbers, please don't confuse them with vectors. You can't multply vectors*, but you CAN multiply complex numbers. As a physisist I am permanently using complex numbers. There is nothing complex or imaginary about them. They are just numbers, but numbers where you don't need to care when taking roots. Did someone confuse vectors with complex numbers? I didn't notice... In another response, I think we were just talking about the similarities. > Here is what I would like to see: > 1) I don't see much use for a purely imaginary type, drop it! > 2) I don't see much use for integer complex types, don't include it! > 3) Properties: z := re + im*I, and x a real number > z.abs() sqrt(re*re+im*im) > z.abs2() re*re+im*im > z.arg() atan2(re, im) > z.phase() z/z.abs() > z.re() re > z.im() im*I > z.rim() im > z.conj() re-im*I > z.I() z*I = -im + re*I > I don't care about the given names, as long as they are short :-). > 4) Functions on complex: > Basic builtin: > +, -, *, /, > sqr := z*z, inv := 1/z, scalar(z1, z2) := z1.conj()*z2 > Library: > exp, cos, sin, tan, cosh, sinh, tanh > ln, acos, asin, atan, acosh, asinh, atanh, > pow(z1, z2), log(z1, z2), sqrt > 5) Constructors: > z = creal(re, im); > z = creal.polar(modulus, argument); > > The distinction between properties and functions is somewhat arbitrary. In my eyes, a property shall return some known information about the variable, but what is known depends on the implementation of that variable (e.g., wether the compiler stores complex numbers in cartesian or polar format). One can argue with good reasons to move some of the above properties to the functions section. I have no objections against doing so. > Well, that sums up the needs quite nicely :-). Nice to have an expert give an opinion. Thanks. Later, John PS Apologies to Olaf. I sent email direct to him by mistake -- hit the wrong button, darn:-P |

Copyright © 1999-2016 by Digital Mars ®, All Rights Reserved