Topic: Nonunique complex functions
Author: Helmut Zeisel <zeisel@vai.co.at>
Date: 1997/02/13 Raw View
In article <fxt7mkl7iz1.fsf@isolde.mti.sgi.com>, Matt Austern <austern@isolde.mti.sgi.com> writes:
> Helmut Zeisel <zeisel@vai.co.at> writes:
>
> > Several complex functions are not mathematically unique defined
> > ...
> > Does the C++ standard define which solution to choose for
> >
>
> Yes. The branch cuts were specified at the Stockholm meeting, and
> they're basically the ones that you would expect. The relevant
> functions are sqrt, log, log10, and pow; all of them have branch cuts
> along the negative real axis. This means that log returns a number
> whose imaginary part is between -pi and pi; log10 and pow are defined
> in terms of log, so this suffices to describe the behavior of log10
> and pow precisely.
>
Fine to hear that.
I am sorry to say that I have no recent copy of the standard available, so
just one other point:
(How) is pow(zero1,zero2) defined
when zero1 und zero2 are zeros of various types (int, double, complex etc.)?
Good reasons to define it as 1 are given in the FAQ of sci.math.
As far as I know the Fortran Standard forgot to specify a definition.
Helmut Zeisel
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: Matt Austern <austern@isolde.mti.sgi.com>
Date: 1997/02/11 Raw View
Helmut Zeisel <zeisel@vai.co.at> writes:
> Several complex functions are not mathematically unique defined
> as functions from the complex numbers to the complex numbers,
>
> e.g., sqrt(-1) = +/- i;
>
> Does the C++ standard define which solution to choose for
>
> template<class T> complex<T> sqrt(const complex<T>& );
>
> (26.2.7 of Draft 28.4.95) and for similar functions
> (log, pow, ...)?
Yes. The branch cuts were specified at the Stockholm meeting, and
they're basically the ones that you would expect. The relevant
functions are sqrt, log, log10, and pow; all of them have branch cuts
along the negative real axis. This means that log returns a number
whose imaginary part is between -pi and pi; log10 and pow are defined
in terms of log, so this suffices to describe the behavior of log10
and pow precisely. Finally, sqrt returns a value in the right half
plane. The square root of a negative real number lies on the positive
imaginary axis.
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Pete Becker <pbecker@oec.com>
Date: 1997/02/11 Raw View
Helmut Zeisel wrote:
>
> > From James Kuyper <kuyper@wizard.net>
> >
> > Helmut Zeisel wrote:
> > >
> > > Several complex functions are not mathematically unique defined
> > > as functions from the complex numbers to the complex numbers,
> > >
> > > e.g., sqrt(-1) = +/- i;
> > >
> > > Does the C++ standard define which solution to choose for
> > >
> > > template<class T> complex<T> sqrt(const complex<T>& );
> > >
> > > (26.2.7 of Draft 28.4.95) and for similar functions
> > > (log, pow, ...)? Or is the result implementation dependent?
> >
> > I'll make the question more general - what branch cuts do these
> > functions use? Are there overloaded versions that allow you to specify
> > the location of branch cuts? Which side of the branch is used, for
> > points exactly on the branch cut?
>
> Since nobody stated that it is defined, I get the impression
> that it is still undefined in the current C++ draft standard.
Is is actually defined in the current working paper. There's no
overloading for selecting cuts. You'll have to look in the WP for the
details.
-- Pete
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: Pete Becker <pbecker@oec.com>
Date: 1997/02/11 Raw View
H. Peter Anvin wrote:
>
> Followup to: <5dnlv4$rpf@rap.SanDiegoCA.NCR.COM>
> By author: swf@elsegundoca.ncr.com
> In newsgroup: comp.std.c++
> >
> > In article <32FB4745.41C6@wizard.net>, James Kuyper
> > <kuyper@wizard.net> writes:
> > |> > (26.2.7 of Draft 28.4.95) and for similar functions
> > |> > (log, pow, ...)? Or is the result implementation dependent?
> > |>
> > |> I'll make the question more general - what branch cuts do these
> > |> functions use? Are there overloaded versions that allow you to specify
> > |> the location of branch cuts? Which side of the branch is used, for
> > |> points exactly on the branch cut?
> >
> > Don't hold your breath. I doubt many people on the committee would even
> > understand this question, as it is a rather specialized bit of mathematics.
> >
> > The only reason I have any idea what you are talking about is I have made
> > a couple of attempts to understand Quantum Mechanics, and ran across branch
> > cuts while doing so. (And I *still* don't understand QM).
> >
>
> This is unfortunate. I was hoping that the C++ committee would have
> at least one representative that was familiar with large-scale
> numerical computation, and it seems to me unfanthomable that such an
> individual would not know what the branch cut is of a complex
> function.
>
> Is there any representation on the C++ committee that might help
> wrestle scientific computation out of the death grip of FORTRAN?
The statement above is "I doubt many people on the committee would even
understand this question", not "nobody on the committee understands the
question". Please note the difference. The former is a guess, the latter
would be a statement of fact. The latter, however, is incorrect. All of
the complex functions have specifications of their branch cuts.
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: James Kuyper <kuyper@wizard.net>
Date: 1997/02/07 Raw View
Helmut Zeisel wrote:
>
> Several complex functions are not mathematically unique defined
> as functions from the complex numbers to the complex numbers,
>
> e.g., sqrt(-1) = +/- i;
>
> Does the C++ standard define which solution to choose for
>
> template<class T> complex<T> sqrt(const complex<T>& );
>
> (26.2.7 of Draft 28.4.95) and for similar functions
> (log, pow, ...)? Or is the result implementation dependent?
I'll make the question more general - what branch cuts do these
functions use? Are there overloaded versions that allow you to specify
the location of branch cuts? Which side of the branch is used, for
points exactly on the branch cut?
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Helmut Zeisel <zeisel@vai.co.at>
Date: 1997/02/10 Raw View
> From James Kuyper <kuyper@wizard.net>
>
> Helmut Zeisel wrote:
> >
> > Several complex functions are not mathematically unique defined
> > as functions from the complex numbers to the complex numbers,
> >
> > e.g., sqrt(-1) = +/- i;
> >
> > Does the C++ standard define which solution to choose for
> >
> > template<class T> complex<T> sqrt(const complex<T>& );
> >
> > (26.2.7 of Draft 28.4.95) and for similar functions
> > (log, pow, ...)? Or is the result implementation dependent?
>
> I'll make the question more general - what branch cuts do these
> functions use? Are there overloaded versions that allow you to specify
> the location of branch cuts? Which side of the branch is used, for
> points exactly on the branch cut?
Since nobody stated that it is defined, I get the impression
that it is still undefined in the current C++ draft standard.
Since I feel it is important to specify the results more precisely
I asked in comp.lang.fortran what solution they have chosen.
Below is the answer I got from James Giles
(he allowed me to forward it),
maybe this solution is a good stating point:
> From JGiles@cris.com Mon Feb 10 13:46 MET 1997
>
> Helmut Zeisel wrote:
> >
> > Thank you for your response;
> > maybe you can help me in a few other questions;
> > in particular, how does the standard specify the solution
> > of ALOG(C) and C1**C2, where C, C1, C2 are complex?
>
> Nothing can be said in general about the branch cuts of these functions
> in Fortran. Some of the functions are clearly defines, some aren't, and
> some require REAL arguments and are not defined on COMPLEX at all.
>
> ACOS(X) - argument must be REAL, and ABS(X).LE.1.0
> ASIN(X) - argument must be REAL, and ABS(X).LE.1.0
> ATAN(X) - argument must be REAL, result is in range
> [-pi/2, +pi/2] (inclusive - on both ends)
> ATAN2(X,Y) - both arguments must be real, Quadrant selected
> by the signs of X and Y, (-pi, +pi] (exclusive of
> negative pi)
> LOG(C) - argument may be complex, imaginary part of result
> is in the range (-pi, +pi]. +pi is only returned
> when the real part of the arg is zero or negative
> and the imaginary part is zero.
> LOG10(X) - Argument must be REAL, no branch cuts given.
> SQRT(C) - argument may be complex, real part of result is
> non-negative. If the realpart of result is zero,
> the imaginary part is non-negative.
> C1**C2 - both operands may be complex. The standard says
> the 'principal value' of the operation is returned.
> No more detail than that. The only real problem is
> what to do if C1 is zero, if both are zero.
>
> ALOG(C) is a specific name for the generic function LOG(C).
>
> >
> > Do you know in detail where the Fortran standard (which chapter) specifies
> > the special solution?
>
> In Fortran 90, the data for the functions is in section 13.13 of the
> standard document. In Fortran 77, similar rules are in section 15.10.1.
>
> >
> > The background for my question is the following: I get the impression
> > that the current C++ Draft
> > Standard does not specify which special solution to choose.
> > If the Fortran people have
> > already done good work, maybe their solution might also be appropriate
> > for C++.
>
> The best work done on this subject in a language standard is in COMMON
> LISP. The Common Lisp document is online as a web page at:
> http://www.supelec.fr/docs/cltl/cltl2.html
> See chapter 12 (click into the table of contents and look under chapter
> 12 for "branch cuts, ...").
>
> Indeed, it's only because I've recently read the Common Lisp document
> that I know these answers off the top of my head - I was comparing the
> requirements of several languages.
>
> --
> J. Giles
> Ricercar Software
Helmut Zeisel
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: swf@elsegundoca.ncr.com (Stan Friesen)
Date: 1997/02/10 Raw View
In article <32FB4745.41C6@wizard.net>, James Kuyper <kuyper@wizard.net> writes:
|> > (26.2.7 of Draft 28.4.95) and for similar functions
|> > (log, pow, ...)? Or is the result implementation dependent?
|>
|> I'll make the question more general - what branch cuts do these
|> functions use? Are there overloaded versions that allow you to specify
|> the location of branch cuts? Which side of the branch is used, for
|> points exactly on the branch cut?
Don't hold your breath. I doubt many people on the committee would even
understand this question, as it is a rather specialized bit of mathematics.
The only reason I have any idea what you are talking about is I have made
a couple of attempts to understand Quantum Mechanics, and ran across branch
cuts while doing so. (And I *still* don't understand QM).
--
swf@elsegundoca.ncr.com sarima@ix.netcom.com
The peace of God be with you.
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Matt Austern <austern@isolde.mti.sgi.com>
Date: 1997/02/11 Raw View
James Kuyper <kuyper@wizard.net> writes:
> I'll make the question more general - what branch cuts do these
> functions use? Are there overloaded versions that allow you to specify
> the location of branch cuts? Which side of the branch is used, for
> points exactly on the branch cut?
There are four multivalued complex functions in the C++ library:
pow, log, log10, and sqrt. In all cases, the branch cuts lie along
the negative real axis.
The stadardization committee didn't want to be innovative in this
area. Complex functions in C++ basically behave the way that you'd
expect from Fortran.
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Helmut Zeisel <zeisel@vai.co.at>
Date: 1997/02/06 Raw View
Several complex functions are not mathematically unique defined
as functions from the complex numbers to the complex numbers,
e.g., sqrt(-1) = +/- i;
Does the C++ standard define which solution to choose for
template<class T> complex<T> sqrt(const complex<T>& );
(26.2.7 of Draft 28.4.95) and for similar functions
(log, pow, ...)? Or is the result implementation dependent?
Helmut Zeisel
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]