Waldek Hebisch | 26 Jul 15:17
Picon

Wrong value of complex cosine

In FriCAS I need to use Lisp cosine function for complex
arguments.  But unfortunatly formula used by Closure CL 1.2-rc1
to comput imaginary part of the cosine is wrong: it has incorrect
sign (so, for example '(cos (complex 0.7 1.0))' gives wrong value).
The following patch fixes the problem:

--- openmcl/ccl/level-0/l0-float.lisp.bb	2008-07-04 11:31:37.000000000 -0400
+++ openmcl/ccl/level-0/l0-float.lisp	2008-07-04 11:35:12.000000000 -0400
@@ -702,7 +702,7 @@
     (let* ((r (realpart x))
            (i (imagpart x)))
       (complex (* (cos r) (cosh i))
-               (* (sin r) (sinh i))))
+               (- (* (sin r) (sinh i)))))
     (if (typep x 'double-float)
       (%double-float-cos! x (%make-dfloat))
       #+32-bit-target

--

-- 
                              Waldek Hebisch
hebisch <at> math.uni.wroc.pl 
R. Matthew Emerson | 26 Jul 18:46

Re: Wrong value of complex cosine


On Jul 26, 2008, at 9:19 AM, Waldek Hebisch wrote:

> In FriCAS I need to use Lisp cosine function for complex
> arguments.  But unfortunatly formula used by Closure CL 1.2-rc1
> to comput imaginary part of the cosine is wrong: it has incorrect
> sign (so, for example '(cos (complex 0.7 1.0))' gives wrong value).

Thanks for the report.

I just merged a fix for this into the 1.2 branch.  (It was fixed in  
the trunk a couple of weeks ago.)

To update your lisp, run "svn update" in your ccl directory.  Then  
start up the lisp and evaluate (rebuild-ccl :full t).
Waldek Hebisch | 29 Jul 18:28
Picon

Re: Wrong value of complex cosine

R. Matthew Emerson wrote:
> 
> On Jul 26, 2008, at 9:19 AM, Waldek Hebisch wrote:
> 
> > In FriCAS I need to use Lisp cosine function for complex
> > arguments.  But unfortunatly formula used by Closure CL 1.2-rc1
> > to comput imaginary part of the cosine is wrong: it has incorrect
> > sign (so, for example '(cos (complex 0.7 1.0))' gives wrong value).
> 
> Thanks for the report.
> 
> I just merged a fix for this into the 1.2 branch.  (It was fixed in  
> the trunk a couple of weeks ago.)
> 
> To update your lisp, run "svn update" in your ccl directory.  Then  
> start up the lisp and evaluate (rebuild-ccl :full t).
> 

Thanks, it works now. 

--

-- 
                              Waldek Hebisch
hebisch <at> math.uni.wroc.pl 

Gmane