0
$\begingroup$

My Goal is to get summation from definition a[k] as below. I tried simple arithmetic progression 1,2,3,4,5.. . Although the function Sum returns symbolic result nicely, but my code doesn't. How to fix to get symbolic result to get 1/2 n (n+1) from a[k] definition?

Sum[i,{i,1,n}] (*1/2 n (n+1) *)(* Sum returns symbolic result*)

a[1]=1;
a[k_Integer?Positive]:=a[k-1]+1    (*definition of arithmetic progression *)
Assuming[Element[{k,n},Integers],Sum[a[k],{k,1,n}]]  (*How to fix to get symbolic result 1/2 n (n+1*)
$\endgroup$
2
  • 1
    $\begingroup$ But these do not give same result? did you check? here is screen shot i.sstatic.net/H3JZn7hO.png i,e, for same n they do not give same value as the Sum. $\endgroup$ Commented Dec 18, 2024 at 1:20
  • 1
    $\begingroup$ I think you need a[1]=1; a[k_Integer?Positive]:=k+a[k-1]; and now they give same results for each n i.sstatic.net/A26q79F8.png You can also do a[k_Integer?Positive] := a[k] = k + a[k - 1]; to speed it up. $\endgroup$ Commented Dec 18, 2024 at 1:29

3 Answers 3

1
$\begingroup$

You can use RSolve, e.g.:

f[n_, k_] := 
 Simplify[
  a[n] /. RSolve[{a[n] == a[n - 1] + n^k, a[1] == 1}, a, n][[1]]]

Some cases:

Grid[Table[{j, 
   StringForm[
    "\!\(\*UnderoverscriptBox[\(\[Sum]\), \(i = 1\), \
\(n\)]\)\!\(\*SuperscriptBox[\(i\), \(``\)]\)", j], f[n, j]}, {j, 0, 
   4}], Frame -> All]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you for your answer. After getting a[n] with RSolve, then using known fact Sum[n,{n,1,n}],then the sum of a[n] arrived. (※The merit of RSolve seems to be that no numerical sample data is needed. I guess some sort of telecoping technique might be used without using fitting technique.) $\endgroup$ Commented Dec 22, 2024 at 5:48
1
$\begingroup$

This gets you what you want in a work around way

a[1] = 1;
a[k_Integer?Positive] := a[k] = k + a[k - 1];
FindFormula[Table[a[i], {i, 1, 10}], n] // Rationalize // Simplify

enter image description here

I do not know why

a[1] = 1;
a[k_Integer?Positive] := a[k] = k + a[k - 1];
Assuming[Element[{k, n}, Integers] && n > 1, Sum[a[k], {k, 1, n}]]

Gives

enter image description here

$\endgroup$
1
$\begingroup$

Using FindSequenceFunction

$Version

(* "14.1.0 for Mac OS X ARM (64-bit) (July 16, 2024)" *)

Clear["Global`*"]

a[1] = 1;
a[k_Integer?Positive] := a[k] = a[k - 1] + 1

sum[n_Integer?Positive] := sum[n] = Sum[a[k], {k, 1, n}]

seq = sum /@ Range[5]

(* {1, 3, 6, 10, 15} *)

FindSequenceFunction[seq, n]

(* 1/2 n (1 + n) *)

Checking,

% === Sum[k, {k, 1, n}]

(* True *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.