login  home  contents  what's new  discussion  bug reports help  links  subscribe  changes  refresh  edit

# Edit detail for #138 asin(complex(1.0,0.0)) revision 3 of 4

 1 2 3 4 Editor: japp Time: 2008/10/29 11:24:12 GMT-7 Note:

From #333:

From FrancoisMaltey Fri Jan 5 07:57:48 -0600 2007
From: Francois Maltey
Date: Fri, 05 Jan 2007 07:57:48 -0600
Subject: patch possible.
Message-ID: <20070105075748-0600@wiki.axiom-developer.org>

I propose to remplace in asin x == atan (x/sqrt(1-x**2)) in trigcat.spad line 162 by

\begin{verbatim}
asin x ==
x=1  => 2*atan 1
x=-1 => -2*atan 1
atan(x/sqrt(1-x**2))
\end{verbatim}

The result seems right...

 Submitted by : (unknown) at: 2007-11-17T21:56:50-08:00 (15 years ago) Name : Axiom Version : default friCAS-20090114 Axiom-20050901 OpenAxiom-20091012 OpenAxiom-20110220 OpenAxiom-Release-141 Category : general Severity : critical serious normal minor wishlist Status : open pending closed Optional subject :   Optional comment :

asin x == atan(x/sqrt(1-x**2))

axiom
asin(1.0)
 (1)
Type: Float
axiom
asin(complex(1.0,0.0))
>> Error detected within library code: catdef: division by zero

Transferred from savannah.

bug #10115 (project axiom)

This and the log(i)-log(-i) bug can be fixed by using GCL's asin and log here. I tried:
if $has Field and$ has sqrt: $->$ then
--       asin x == atan(x/sqrt(1-x**2))
asin x == ASIN(COMPLEX(real x,imag x)$Lisp)$Lisp

but the form of x when complex in axiom is not that of lisp, i.e. asin gets passed a non-number:

>> System error:
((1 . 0) 0 . 0) is not of type NUMBER.

In general, I think it a good idea to avoid having to duplicate the functionality of the standard lisp functions in axiom, but there may be some philosophical reason for doing this due to the domain structures or some such. If one needs the correct logic for a duplicate implementation, one can look at the gcl_numlib.lsp file in the lsp/ subdirectory.

No, here it is a Complex(Float), the implementation of float allow arbitrary precision, Common Lisp no. Morever, it'a generic implementation (in a category)

OK, then what we want is something like:
asin x == - %i * log( %i * x + sqrt(1 - x*x))

but this does not appear to be used when put into trigcat.spad.pamphlet and recompiling. Perhaps someone could explain?

Secondly, perhaps ist is of use to bring forward GMP/mpfr optimized multi-precision floating point in GCL for use by axiom here?

I understand the multi-precision argument, but is there a difference between a "generic imlementation" and the lisp one where the category of the domain coincides precisely with the lisp type?

Lastly, do we have to use this difficult interface as opposed to the developer email list?

take care,

take care ... Yes I think it's a good idea to add mpfr to gcl
Regards

I believe furthermore, that the problem with argument as described in bug #47 will persist if we fix it this way.

I think that a lot of care has to be taken if we use Lisp functions instead of "homegrown" ones.

Concerning the place of discussion, I too think that it would be better to:

• ask on axiom-developer whether it is really an issue, if this is not clear
• signal the issue on IssueTracker?
• discuss it on axiom-developer
• add proposed fixes on IssueTracker?.

Since any change on IssueTracker? will notify axiom-developer, there is no danger of missing anything.

I think that the following definition would work:
asin x == if x = 1 then pi()/2::\$ else atan(x/sqrt(1-x**2))

There is one thing that puzzles me, though. Also in TRANFUN, the following definition is given for pi() :

pi()   == 2*asin(1)

which seems to be asking for trouble. However, I couldn't find a domain that would use this definition for pi(). Maybe it should be rather defined in terms of atan?