1
$\begingroup$

I have a simple table:

example1 = Table[N[x^(x/r), 5], {r, 1, 10}, {x, 1, 10}]

I want to create a new table Table[Sum[N[x^(x/r), 5], {r, 1, k}],{k,1,10},{x,1,10}], but using the data from example1 rather than having to recalculate x^(x/r) and then sum the results - clearly advantageous when the table gets bigger.

I assume it's a simple thing to do, but I can't figure it out. I input

example2 = Table[Sum[example1, {r, 1, k}], {k, 1, 10}, {x, 1, 10}]

but the result is a table of tables.

How do I do this? Is it even possible?

$\endgroup$
  • $\begingroup$ Oddly, no. For example at {x,k}->{2,3} $\endgroup$ – Richard Burke-Ward Aug 26 '18 at 10:05
1
$\begingroup$

You can use Accumulate on example1 to get the same table produced by Table[Sum[N[x^(x/r), 5], {r, 1, k}],{k,1,10},{x,1,10}]:

example3 = Accumulate[example1] 

{{1.0000, 4.0000, 27.000, 256.00, 3125.0, 46656., 8.2354*10^5, 1.6777*10^7, 3.8742*10^8, 1.0000*10^10},
{2.0000, 6.0000, 32.196, 272.00, 3180.9, 46872., 8.2445*10^5, 1.6781*10^7, 3.8744*10^8, 1.0000*10^10},
{3.0000, 7.5874, 35.196, 278.35, 3195.5, 46908., 8.2454*10^5, 1.6782*10^7, 3.8744*10^8, 1.0000*10^10},
{4.0000, 9.0016, 37.476, 282.35, 3203.0, 46923., 8.2457*10^5, 1.6782*10^7, 3.8744*10^8, 1.0000*10^10},
{5.0000, 10.321, 39.409, 285.38, 3208.0, 46931., 8.2459*10^5, 1.6782*10^7, 3.8744*10^8, 1.0000*10^10},
{6.0000, 11.581, 41.141, 287.90, 3211.8, 46937., 8.2460*10^5, 1.6782*10^7, 3.8744*10^8, 1.0000*10^10},
{7.0000, 12.800, 42.742, 290.11, 3215.0, 46942., 8.2461*10^5, 1.6782*10^7, 3.8744*10^8, 1.0000*10^10},
{8.0000, 13.989, 44.252, 292.11, 3217.7, 46946., 8.2461*10^5, 1.6782*10^7, 3.8744*10^8, 1.0000*10^10},
{9.0000, 15.156, 45.694, 293.96, 3220.2, 46949., 8.2462*10^5, 1.6782*10^7, 3.8744*10^8, 1.0000*10^10},
{10.000, 16.304, 47.085, 295.70, 3222.4, 46952., 8.2462*10^5, 1.6782*10^7, 3.8744*10^8, 1.0000*10^10}}

example3  == Table[Sum[N[x^(x/r), 5], {r, 1, k}],{k,1,10},{x,1,10}]

True

$\endgroup$
  • $\begingroup$ Not quite sure what I'm supposed to do with this. I'm a complete novice... I'm after a table that uses example1 as its source data. $\endgroup$ – Richard Burke-Ward Aug 26 '18 at 10:07
  • $\begingroup$ OK, I'm still missing something. What would the expression be to create a new table using example1? you're showing me a test rather than the table... I know I'm being dumb. I appreciate your patience. $\endgroup$ – Richard Burke-Ward Aug 26 '18 at 10:12
  • $\begingroup$ Fab. Thanks. Sorry to have been so slow. $\endgroup$ – Richard Burke-Ward Aug 26 '18 at 10:17
  • $\begingroup$ @RichardBurke-Ward, my pleasure. Thank you for the accept. $\endgroup$ – kglr Aug 26 '18 at 10:18
  • $\begingroup$ Let us continue this discussion in chat. $\endgroup$ – Richard Burke-Ward Aug 26 '18 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.