in

.NET Opensource

Community for opensource projects by Christoph Rüegg

Complex : NaturalLogarithm()

Last post 12-21-2007 11:30 by Christoph Rüegg. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 12-05-2007 9:59

    Complex : NaturalLogarithm()

    Currently the code to take the NaturalLogarithm of a Complex number is as follows :

            public Complex NaturalLogarithm()
            {
                if(IsReal)
                    return new Complex(Math.Log(real), 0d);
                return new Complex(0.5d * Math.Log(ModulusSquared), Argument);
            }

    The exception for IsReal makes this function fail for real negative numbers. For example : the natural logarithm of -exp(1) should be 1 + i*PI . This is a complex number, so ofcourse the standard Math.Log(-exp(1)) fails, but the NaturalLogarithm() function in your complex class should not fail.

    Why not just remove the "special case" ?

  • 12-13-2007 23:09 In reply to

    Re: Complex : NaturalLogarithm()

    Answer

    I just checked the sources; they look like the following right now:

    public Complex NaturalLogarithm()
    {
       if(IsRealNonNegative)
          return new Complex(Math.Log(real), 0d);
       return new Complex(0.5d * Math.Log(ModulusSquared), Argument);
    }
    

    Apparently the actual problem seems to have been solved already some time ago. Unfortunately there was no official release since that date, but you may want to check out the sources from our subversion repository and build it yourself. (Note to myself: I should really release more often...)

    hth,
    Chris

    Filed under: , ,
  • 12-14-2007 15:23 In reply to

    Re: Complex : NaturalLogarithm()

    I tried to, but the subversion protocol is blocked here and I couldn't connect to your SVN server using the http protocol.

  • 12-21-2007 11:30 In reply to

    Re: Complex : NaturalLogarithm()

    Yes, the http protocol is not enabled. If you're interested I can send you the current source to the mail address you've used to register here on this forum. Let me know.

    Btw, I plan to release a new official version in the next two weeks.

    Filed under: ,
Page 1 of 1 (4 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems