www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Docs: std.math.conj wrong

reply Daniel Keep <daniel.keep.lists gmail.com> writes:
The documentation for std.math.conj states:

 `` Note that z * conj(z) = z.re^2 - z.im^2 is always a real number ''

This *should* say:

 `` Note that z * conj(z) = z.re^2 + z.im^2 is always a real number ''

Proof:

given
        z = x + iy
  conj(z) = x - iy

then
z*conj(z) = (x + iy)(x - iy)
          = x^2 - ixy + ixy - (i^2 y^2)  -- Two ixy's cancel out
          = x^2 - ((-1)y^2)  -- i^2 = (-1)
          = x^2 - (-y^2)
          = x^2 + y^2
            QED

As far as I can tell, this is purely a documentation issue, not a code one.

	-- Daniel

-- 
int getRandomNumber()
{
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

http://xkcd.com/

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/
Apr 08 2007
parent Don Clugston <dac nospam.com.au> writes:
Daniel Keep wrote:
 The documentation for std.math.conj states:
 
  `` Note that z * conj(z) = z.re^2 - z.im^2 is always a real number ''
 
 This *should* say:
 
  `` Note that z * conj(z) = z.re^2 + z.im^2 is always a real number ''
 
 Proof:
 
 given
         z = x + iy
   conj(z) = x - iy
 
 then
 z*conj(z) = (x + iy)(x - iy)
           = x^2 - ixy + ixy - (i^2 y^2)  -- Two ixy's cancel out
           = x^2 - ((-1)y^2)  -- i^2 = (-1)
           = x^2 - (-y^2)
           = x^2 + y^2
             QED
 
 As far as I can tell, this is purely a documentation issue, not a code one.
 
 	-- Daniel
 
This also applied to Tango -- it's now been fixed there.
Apr 11 2007