![]() |
Summing a function
Is there a way to write a function, specify a range of integers, and have Excel return the sum of the function evaluated at each integer? The only way that I know how to do this is to actually create a list with every integer and the corresponding value of the funciton at that integer and then sum the list. This is not a good idea, however, when the number of integers is in the thousands. Is there any way to get around this? -- Spreadsheet ------------------------------------------------------------------------ Spreadsheet's Profile: http://www.excelforum.com/member.php...o&userid=34730 View this thread: http://www.excelforum.com/showthread...hreadid=547480 |
Summing a function
- How do you know which integers you want to sum?
- Are the integers all in one column? "Spreadsheet" wrote: Is there a way to write a function, specify a range of integers, and have Excel return the sum of the function evaluated at each integer? The only way that I know how to do this is to actually create a list with every integer and the corresponding value of the funciton at that integer and then sum the list. This is not a good idea, however, when the number of integers is in the thousands. Is there any way to get around this? -- Spreadsheet ------------------------------------------------------------------------ Spreadsheet's Profile: http://www.excelforum.com/member.php...o&userid=34730 View this thread: http://www.excelforum.com/showthread...hreadid=547480 |
Summing a function
I want the sum of the function evaluated at a range of integers. I want to be able to specify the range of integers as a paramater of the function. For example, suppose there is some function that does what I want called SUMFUNC. SUMFUNC(X^2,1,10) would return the sum of squares from 1 to 10 (i.e. 1+4+9+16+...+100). Or maybe if I have two cells, with the starting integer in A1 and the ending integer in A2 the funciton would look as follows: SUMFUCNC((A1:A2)^2). This would also return 1+4+9+...+100. I just made this up as an example and I'm sure that there is no easy solution like this. But if anybody has any ideas, please let me know. -- Spreadsheet ------------------------------------------------------------------------ Spreadsheet's Profile: http://www.excelforum.com/member.php...o&userid=34730 View this thread: http://www.excelforum.com/showthread...hreadid=547480 |
Summing a function
I don't believe any such function exists. You'd have to create a
User-Defined-Funtion. -- Gary Brown "Spreadsheet" wrote: I want the sum of the function evaluated at a range of integers. I want to be able to specify the range of integers as a paramater of the function. For example, suppose there is some function that does what I want called SUMFUNC. SUMFUNC(X^2,1,10) would return the sum of squares from 1 to 10 (i.e. 1+4+9+16+...+100). Or maybe if I have two cells, with the starting integer in A1 and the ending integer in A2 the funciton would look as follows: SUMFUCNC((A1:A2)^2). This would also return 1+4+9+...+100. I just made this up as an example and I'm sure that there is no easy solution like this. But if anybody has any ideas, please let me know. -- Spreadsheet ------------------------------------------------------------------------ Spreadsheet's Profile: http://www.excelforum.com/member.php...o&userid=34730 View this thread: http://www.excelforum.com/showthread...hreadid=547480 |
Summing a function
The list of integers could be hidden as an array name.
If the integers are {1,2,3,4,5,6,7,8,9,10} then Start (A1=1) and End (A2=10) define this list named Seqn Insert Name Define Seqn Refers To: =ROW(INDEX(A:A,Start):INDEX(A:A,End)) The sum of the squares is then =SUMPRODUCT(Seqn^2) =385 With the use of Mod and Int, etc, Seqn can be built up to any complexity you want. |
Summing a function
How about using this array formula:
=sum(row(1:10)^2) You may change the numbers to suit your needs. Regards, Daniel |
Summing a function
Or maybe if I have two cells, with the starting integer in A1 and the ending integer in A2 the funciton would look as follows: SUMFUCNC((A1:A2)^2). This would also return 1+4+9+...+100. Let's see A1 for first integer, and B1 as last integer, use this array formula: =SUM(ROW(INDIRECT("A"&INDIRECT("A1")&":B"&INDIRECT ("B1")))^2) Regards, Daniel |
Summing a function
Let's see A1 for first integer, and B1 as last integer...
=SUM(ROW(INDIRECT("A"&INDIRECT("A1")&":B"&INDIRECT ("B1")))^2) Hi. For this particular equation, another option might be: =(A1*((3-2*A1)*A1-1)+B1*(B1+1)*(2*B1+1))/6 as the sum from 1 to n 'squared' is n*(1 + n)*((1 + 2*n)/6) -- HTH. :) Dana DeLouis Windows XP, Office 2003 "Daniel Erwin" wrote in message oups.com... Or maybe if I have two cells, with the starting integer in A1 and the ending integer in A2 the funciton would look as follows: SUMFUCNC((A1:A2)^2). This would also return 1+4+9+...+100. Let's see A1 for first integer, and B1 as last integer, use this array formula: =SUM(ROW(INDIRECT("A"&INDIRECT("A1")&":B"&INDIRECT ("B1")))^2) Regards, Daniel |
Summing a function
Thanks Daniel, I got the array formula to work, although it didn't work until I Ctrl-Shift-Entered it. -- Spreadsheet ------------------------------------------------------------------------ Spreadsheet's Profile: http://www.excelforum.com/member.php...o&userid=34730 View this thread: http://www.excelforum.com/showthread...hreadid=547480 |
All times are GMT +1. The time now is 05:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com