From: SourceForge.net <no...@so...> - 2003-11-16 18:22:26
|
Bugs item #836773, was opened at 2003-11-05 21:43 Message generated for change (Comment added) made by wjenkner You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=836773&group_id=4933 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Barton Willis (willisbl) Assigned to: Nobody/Anonymous (nobody) Summary: ntrig is broken Initial Comment: (C4) load("ntrig.mac"); (D4) ?C\:\/maxima\/Maxima\/share\/maxima\/5\.9\.0 \/share\/trigonometry\/ntrig\.mac (C5) sin(6*%pi/5); (D5) (SQRT(5)-1)*SQRT(SQRT(5)+5)/(4*SQRT(2)) (C6) float(%); (D6) 0.58778525229247 (C7) sin(float(6*%pi/5)); (D7) -0.58778525229247 Barton ---------------------------------------------------------------------- >Comment By: Wolfgang Jenkner (wjenkner) Date: 2003-11-16 19:21 Message: Logged In: YES user_id=581700 What about combining the two approaches like this. define_variable (usin_list, block([e1 : (sqrt(5)-1)/4, e2 : (sqrt(5)-1)*sqrt(sqrt(5)+5)/(4*sqrt(2)), e3 : (sqrt(5)+1)/4, e4 : sqrt(sqrt(5)+5)/(2*sqrt(2))], [e1, e2, e3, e4, 1, e4, e3, e2, e1, 0]), any)$ usin(n):= /* MODE_DECLARE treats INTEGER like FIXNUM... */ (mode_declare(n,number), /* Note that this works because MOD is supposed to return an integer in [-9, 10] here. Sadly, GCL misbehaves (see bug #706562). Normally, this doesn't matter, however: If the argument of SIN is an integer multiple of %pi/2 the usual simplification routines take care of it, so at this point N won't be a multiple of 5. */ if (n : mod(n, 20)) > 0 then usin_list[n] else -usin_list[10+n])$ ucos(n):= usin(5-n)$ ---------------------------------------------------------------------- Comment By: Barton Willis (willisbl) Date: 2003-11-15 20:47 Message: Logged In: YES user_id=895922 I wrote testing code for ntrig; both proposed fixes pass all the tests. Barton ---------------------------------------------------------------------- Comment By: Stavros Macrakis (macrakis) Date: 2003-11-10 23:07 Message: Logged In: YES user_id=588346 Please test the following replacement for ntrig. /* Some of these simplifications give results with radicals in the denominator. These could be pre-simplified here, but ratsimp(...),algebraic:true will also take care of it. */ eval_when([translate,batch,demo,load,loadfile], matchdeclare(n,integerp))$ tellsimpafter(sin(n*%pi/10),usin(n))$ tellsimpafter(cos(n*%pi/10),ucos(n))$ tellsimpafter(tan(n*%pi/10),usin(n)/ucos(n))$ tellsimpafter(cot(n*%pi/10),ucos(n)/usin(n))$ tellsimpafter(sec(n*%pi/10),1/ucos(n))$ tellsimpafter(csc(n*%pi/10),1/usin(n))$ usin_list: makelist( [ 0, (sqrt(5)-1)/4, sqrt(2)*(sqrt(5)-1)*sqrt(sqrt(5)+5)/8, (sqrt(5)+1)/4, sqrt(sqrt(5)+5)/(2*sqrt(2)), 1] [i], i,[1,2,3,4,5,6,5,4,3,2,1,2,3,4,5,6,5,4,3,2] ) /* In the pre-11/2003 version, usin_list[3] was (sqrt(5)-1)*sqrt(sqrt(5)+5)/(4*sqrt(2)). But the new version is better simplified, and simplifies just as well. */ $ usin(n):= (declare(n,integer), n : remainder(n,20), if n<0 then n:n+20, /* Workaround for bug in remainder */ (if n <= 10 then usin_list[n+1] /* 1-origin indexing */ else -usin_list[n+1]) )$ ucos(n):=usin(n+5)$ ---------------------------------------------------------------------- Comment By: Wolfgang Jenkner (wjenkner) Date: 2003-11-07 18:51 Message: Logged In: YES user_id=581700 Perhaps simply rewrite USIN(N):= BLOCK([YUK:mod(N,20)], signum(YUK)*(YUK:abs(mod(YUK,10)), IF YUK=1 THEN (SQRT(5)-1)/4 ELSE IF YUK=2 THEN (SQRT(5)-1)*SQRT(SQRT(5)+5)/(4*SQRT(2)) ELSE IF YUK=3 THEN (SQRT(5)+1)/4 ELSE IF YUK=4 THEN SQRT(SQRT(5)+5)/(2*SQRT(2))))$ UCOS(N):= USIN(5-N)$ ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=836773&group_id=4933 |