Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.
Close
From: SourceForge.net <noreply@so...>  20100827 15:30:42

Bugs item #3054399, was opened at 20100827 17:30 Message generated for change (Tracker Item Submitted) made by dzenanz 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: Open Resolution: None 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3054399&group_id=4933 
From: SourceForge.net <noreply@so...>  20100827 17:55:07

Bugs item #3054399, was opened at 20100827 11:30 Message generated for change (Comment added) made by rtoy 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: Open Resolution: None 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   >Comment By: Raymond Toy (rtoy) Date: 20100827 13: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 
From: SourceForge.net <noreply@so...>  20100827 19:08:40

Bugs item #3054399, was opened at 20100827 17:30 Message generated for change (Comment added) made by dzenanz 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: Open Resolution: None 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   >Comment By: Dženan Zukić (dzenanz) Date: 20100827 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: 20100827 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 
From: SourceForge.net <noreply@so...>  20100829 01:38:47

Bugs item #3054399, was opened at 20100827 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   >Comment By: Dieter Kaiser (crategus) Date: 20100829 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,n1); (%o2) 7/4 This is the same as (%i26) 7/4*sum(1/n,i,0,n1); (%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,n1)); (%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: 20100827 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: 20100827 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 
From: SourceForge.net <noreply@so...>  20100830 10:19:29

Bugs item #3054399, was opened at 20100827 17:30 Message generated for change (Settings changed) made by dzenanz 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: Open 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   >Comment By: Dženan Zukić (dzenanz) Date: 20100830 12:19 Message: Sorry, when copying the formula from my C++ code into Maxima for debugging purposes, I missed division by n within cosine functions. This is the correct formula: ratsimp(sum(0.5*cos((4*%pi*i)/n)+cos((2*%pi*i)/n)+0.25,i,0,n1)/n); However, this does not simplify in Maxima. In Derive 6.1, it gives the result I was trying to confirm (the result I suspected by tracing variable values in my code): this sum is equal to 0.25. So, this can be changed from bug to feature request.  Comment By: Dieter Kaiser (crategus) Date: 20100829 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,n1); (%o2) 7/4 This is the same as (%i26) 7/4*sum(1/n,i,0,n1); (%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,n1)); (%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: 20100827 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: 20100827 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 
From: SourceForge.net <noreply@so...>  20100830 13:49:29

Bugs item #3054399, was opened at 20100827 11:30 Message generated for change (Comment added) made by rtoy 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   >Comment By: Raymond Toy (rtoy) Date: 20100830 09:49 Message: Look at Dieter's comments. By using simplify_sum, he gets the answer of 1/4, as expected. Marking report as pending.  Comment By: Dženan Zukić (dzenanz) Date: 20100830 06:19 Message: Sorry, when copying the formula from my C++ code into Maxima for debugging purposes, I missed division by n within cosine functions. This is the correct formula: ratsimp(sum(0.5*cos((4*%pi*i)/n)+cos((2*%pi*i)/n)+0.25,i,0,n1)/n); However, this does not simplify in Maxima. In Derive 6.1, it gives the result I was trying to confirm (the result I suspected by tracing variable values in my code): this sum is equal to 0.25. So, this can be changed from bug to feature request.  Comment By: Dieter Kaiser (crategus) Date: 20100828 21: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,n1); (%o2) 7/4 This is the same as (%i26) 7/4*sum(1/n,i,0,n1); (%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,n1)); (%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: 20100827 15: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: 20100827 13: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 
From: SourceForge.net <noreply@so...>  20100830 14:04:06

Bugs item #3054399, was opened at 20100827 17:30 Message generated for change (Comment added) made by dzenanz 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: Open 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   >Comment By: Dženan Zukić (dzenanz) Date: 20100830 16:04 Message: This is behavior on my box: (%i1) declare(n, constant); (%o1) done (%i2) simplify_sum(sum((1/4+cos(2*i*%pi/n)+1/2*cos(4*i*%pi/n))/n,i,0,n1)); (%o2) simplify_sum(sum(cos((4*%pi*i)/n)/2+cos((2*%pi*i)/n)+1/4,i,0,n1)/n) I copied the statement from Dieter's post. I do not get results 1/4 (as Dieter is getting).  Comment By: Raymond Toy (rtoy) Date: 20100830 15:49 Message: Look at Dieter's comments. By using simplify_sum, he gets the answer of 1/4, as expected. Marking report as pending.  Comment By: Dženan Zukić (dzenanz) Date: 20100830 12:19 Message: Sorry, when copying the formula from my C++ code into Maxima for debugging purposes, I missed division by n within cosine functions. This is the correct formula: ratsimp(sum(0.5*cos((4*%pi*i)/n)+cos((2*%pi*i)/n)+0.25,i,0,n1)/n); However, this does not simplify in Maxima. In Derive 6.1, it gives the result I was trying to confirm (the result I suspected by tracing variable values in my code): this sum is equal to 0.25. So, this can be changed from bug to feature request.  Comment By: Dieter Kaiser (crategus) Date: 20100829 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,n1); (%o2) 7/4 This is the same as (%i26) 7/4*sum(1/n,i,0,n1); (%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,n1)); (%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: 20100827 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: 20100827 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 
From: SourceForge.net <noreply@so...>  20100830 14:15:52

Bugs item #3054399, was opened at 20100827 11:30 Message generated for change (Comment added) made by rtoy 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: Open 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   >Comment By: Raymond Toy (rtoy) Date: 20100830 10:15 Message: Do this first: load(simplify_sum);  Comment By: Dženan Zukić (dzenanz) Date: 20100830 10:04 Message: This is behavior on my box: (%i1) declare(n, constant); (%o1) done (%i2) simplify_sum(sum((1/4+cos(2*i*%pi/n)+1/2*cos(4*i*%pi/n))/n,i,0,n1)); (%o2) simplify_sum(sum(cos((4*%pi*i)/n)/2+cos((2*%pi*i)/n)+1/4,i,0,n1)/n) I copied the statement from Dieter's post. I do not get results 1/4 (as Dieter is getting).  Comment By: Raymond Toy (rtoy) Date: 20100830 09:49 Message: Look at Dieter's comments. By using simplify_sum, he gets the answer of 1/4, as expected. Marking report as pending.  Comment By: Dženan Zukić (dzenanz) Date: 20100830 06:19 Message: Sorry, when copying the formula from my C++ code into Maxima for debugging purposes, I missed division by n within cosine functions. This is the correct formula: ratsimp(sum(0.5*cos((4*%pi*i)/n)+cos((2*%pi*i)/n)+0.25,i,0,n1)/n); However, this does not simplify in Maxima. In Derive 6.1, it gives the result I was trying to confirm (the result I suspected by tracing variable values in my code): this sum is equal to 0.25. So, this can be changed from bug to feature request.  Comment By: Dieter Kaiser (crategus) Date: 20100828 21: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,n1); (%o2) 7/4 This is the same as (%i26) 7/4*sum(1/n,i,0,n1); (%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,n1)); (%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: 20100827 15: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: 20100827 13: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 
From: SourceForge.net <noreply@so...>  20100830 14:27:01

Bugs item #3054399, was opened at 20100827 17:30 Message generated for change (Comment added) made by dzenanz 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: Open 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   >Comment By: Dženan Zukić (dzenanz) Date: 20100830 16:27 Message: That does the trick. But without load command there was no warning/error that "simplify_sum" is not loaded. How many such modules are there? Can they all fit into workspace (memory) on an average computer? (I believe yes). Have you considered autoloading all such modules on startup (as Derive does)? Is there any other reason (besides efficiency) for not loading them all on startup? And my preference: simplicity over efficiency for stuff that is realtimefast (such as simple symbolic math). Anyway, thanks for the help.  Comment By: Raymond Toy (rtoy) Date: 20100830 16:15 Message: Do this first: load(simplify_sum);  Comment By: Dženan Zukić (dzenanz) Date: 20100830 16:04 Message: This is behavior on my box: (%i1) declare(n, constant); (%o1) done (%i2) simplify_sum(sum((1/4+cos(2*i*%pi/n)+1/2*cos(4*i*%pi/n))/n,i,0,n1)); (%o2) simplify_sum(sum(cos((4*%pi*i)/n)/2+cos((2*%pi*i)/n)+1/4,i,0,n1)/n) I copied the statement from Dieter's post. I do not get results 1/4 (as Dieter is getting).  Comment By: Raymond Toy (rtoy) Date: 20100830 15:49 Message: Look at Dieter's comments. By using simplify_sum, he gets the answer of 1/4, as expected. Marking report as pending.  Comment By: Dženan Zukić (dzenanz) Date: 20100830 12:19 Message: Sorry, when copying the formula from my C++ code into Maxima for debugging purposes, I missed division by n within cosine functions. This is the correct formula: ratsimp(sum(0.5*cos((4*%pi*i)/n)+cos((2*%pi*i)/n)+0.25,i,0,n1)/n); However, this does not simplify in Maxima. In Derive 6.1, it gives the result I was trying to confirm (the result I suspected by tracing variable values in my code): this sum is equal to 0.25. So, this can be changed from bug to feature request.  Comment By: Dieter Kaiser (crategus) Date: 20100829 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,n1); (%o2) 7/4 This is the same as (%i26) 7/4*sum(1/n,i,0,n1); (%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,n1)); (%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: 20100827 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: 20100827 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 
From: SourceForge.net <noreply@so...>  20100830 14:57:00

Bugs item #3054399, was opened at 20100827 11:30 Message generated for change (Settings changed) made by rtoy 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: Closed 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,n1); (%o6) 1.75 GUI: wxMaxima on Win7 x64  Maxima version: 5.22.1 Maxima build date: 11:48 8/13/2010 Host type: i686pcmingw32 Lisp implementation type: GNU Common Lisp (GCL) Lisp implementation version: GCL 2.6.8   >Comment By: Raymond Toy (rtoy) Date: 20100830 10:56 Message: Closing report. I'm not going to answer the other questions; those are best asked on the mailing list. Please take your questions there.  Comment By: Dženan Zukić (dzenanz) Date: 20100830 10:27 Message: That does the trick. But without load command there was no warning/error that "simplify_sum" is not loaded. How many such modules are there? Can they all fit into workspace (memory) on an average computer? (I believe yes). Have you considered autoloading all such modules on startup (as Derive does)? Is there any other reason (besides efficiency) for not loading them all on startup? And my preference: simplicity over efficiency for stuff that is realtimefast (such as simple symbolic math). Anyway, thanks for the help.  Comment By: Raymond Toy (rtoy) Date: 20100830 10:15 Message: Do this first: load(simplify_sum);  Comment By: Dženan Zukić (dzenanz) Date: 20100830 10:04 Message: This is behavior on my box: (%i1) declare(n, constant); (%o1) done (%i2) simplify_sum(sum((1/4+cos(2*i*%pi/n)+1/2*cos(4*i*%pi/n))/n,i,0,n1)); (%o2) simplify_sum(sum(cos((4*%pi*i)/n)/2+cos((2*%pi*i)/n)+1/4,i,0,n1)/n) I copied the statement from Dieter's post. I do not get results 1/4 (as Dieter is getting).  Comment By: Raymond Toy (rtoy) Date: 20100830 09:49 Message: Look at Dieter's comments. By using simplify_sum, he gets the answer of 1/4, as expected. Marking report as pending.  Comment By: Dženan Zukić (dzenanz) Date: 20100830 06:19 Message: Sorry, when copying the formula from my C++ code into Maxima for debugging purposes, I missed division by n within cosine functions. This is the correct formula: ratsimp(sum(0.5*cos((4*%pi*i)/n)+cos((2*%pi*i)/n)+0.25,i,0,n1)/n); However, this does not simplify in Maxima. In Derive 6.1, it gives the result I was trying to confirm (the result I suspected by tracing variable values in my code): this sum is equal to 0.25. So, this can be changed from bug to feature request.  Comment By: Dieter Kaiser (crategus) Date: 20100828 21: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,n1); (%o2) 7/4 This is the same as (%i26) 7/4*sum(1/n,i,0,n1); (%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,n1)); (%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: 20100827 15: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: 20100827 13: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 