From: SourceForge.net <no...@so...> - 2010-08-29 01:38:47
|
Bugs item #3054399, was opened at 2010-08-27 17:30 Message generated for change (Comment added) made by crategus You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3054399&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core - Simplification Group: None >Status: Pending >Resolution: Works For Me Priority: 5 Private: No Submitted By: Dženan Zukić (dzenanz) Assigned to: Nobody/Anonymous (nobody) Summary: Sum incorrectly calculated Initial Comment: The commands below are steps to reproduce. The correct sum for n=5 is 0.25. (%i2) declare (n, constant); (%o2) done (%i6) sum((0.25+cos(2*i*%pi)+0.5*cos(4*i*%pi))/n,i,0,n-1); (%o6) 1.75 GUI: wxMaxima on Win7 x64 ------------------------------------------------------------- Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686-pc-mingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8 ------------------------------------------------------------- ---------------------------------------------------------------------- >Comment By: Dieter Kaiser (crategus) Date: 2010-08-29 03:38 Message: I do not see a problem and I get the expected results: (%i2) sum((1/4+cos(2*i*%pi)+1/2*cos(4*i*%pi))/n,i,0,n-1); (%o2) 7/4 This is the same as (%i26) 7/4*sum(1/n,i,0,n-1); (%o26) 7/4 When a division by n is missing in the cos functions we have to use the function simplify_sum to get a simplified result: (%i20) simplify_sum(sum((1/4+cos(2*i*%pi/n)+1/2*cos(4*i*%pi/n))/n,i,0,n-1)); (%o20) 1/4 This again is a correct result. The result does not depend on n. Setting the status to pending and the resolution to "works for me". Dieter Kaiser ---------------------------------------------------------------------- Comment By: Dženan Zukić (dzenanz) Date: 2010-08-27 21:08 Message: You missed division by n (at the end). And I missed division by n within cosines. I will have to check this again on Monday - I guess I have found a bug in my code now :D ---------------------------------------------------------------------- Comment By: Raymond Toy (rtoy) Date: 2010-08-27 19:55 Message: Why is the correct answer 0.25? 0.25+cos(2*i*%pi)+0.5*cos(4*i*%pi) = 0.25 + 1 + 0.5 = 1.75 for all integer i. So it looks like the sum should always be 1.75 to me. Did I miss something? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3054399&group_id=4933 |