New Answer
If you are insistent on using the For
loop, then you can see - from translating you LaTeX into Mathematica, that the errors go away, and the code appears to work:
Module[
(*Local Variabels*)
{theSum, collected, mySeriesCoefficients, myCoefficientList, L2, myNewSum},
For[i = 1, i^2 < 10, i++,
theSum = Sum[t^k (k + x1)^2, {k, 0, 18}];
collected = Collect[theSum, x1];
mySeriesCoefficients = SeriesCoefficient[collected, {x1, 0, i}];
myCoefficientList = CoefficientList[mySeriesCoefficients, t];
L2 = FindSequenceFunction[myCoefficientList, k];
myNewSum = Sum[L2 t^k, {k, 0, Infinity}];
Print[myNewSum]
]
]
(*OUTPUT:
(2 (-1+2 t))/(-1+t)^2
1/(1-t)
\!\(
\*UnderoverscriptBox[\(\[Sum]\), \(k = 0\), \(\[Infinity]\)]\(
\*SuperscriptBox[\(t\), \(k\)]\ FindSequenceFunction[{}, k]\)\)
*)
This was achieved following the comments below your original post i.e. multiple commands within a For
loop need to be separated by ;
rather than ,
. It also helps to replace %
with a local variable, as %
is meant for retrieving the most recent output. I am unsure as to whether or not that will work inside a For
loop.
Either way, (as see by the question's rating), just posting LaTeX and broken code is not likely to get you very far. Especially as it was pointed out in the comments that it would be easier for others to help you if you provided code (which I typed out in about a minute after code was not provided). A question that has no effort put into it, is not likely to get anyone willing to put effort in to resolving it. This commentary is not meant to lambaste you, rather help you make more constructive questions in the future. Do not be discouraged as I am sure many of the community will be happy to assist with future, well-prosed questions.
Welcome to the Mathematica S.E. community :)
Original Answer
So this is not the full "answer" (if you were expecting to receive the full code), but should give you the framework you need to do what you are trying to do.
Just as an aside, I wouldn't call this a ''simple'' instruction. As good practice, if your code doesn't work, trying building up to it from smaller chunks.
Anyway, you can build what you are trying to do via the Table
function.
squaresOfILessThan10 = Table[If[i^2 < 10, i, Nothing], {i, 1, 10}];
Table[(*For i = 1, i^2<10, i++*)
Table[
Collect[Sum[t^k (k + x1)^2, {k, 0, 18}], x1]
, {x1, 0, i}
]
, {i, squaresOfILessThan10}]
(*{{t + 4 t^2 + 9 t^3 + 16 t^4 + 25 t^5 + 36 t^6 + 49 t^7 + 64 t^8 +
81 t^9 + 100 t^10 + 121 t^11 + 144 t^12 + 169 t^13 + 196 t^14 +
225 t^15 + 256 t^16 + 289 t^17 + 324 t^18,
1 + 4 t + 9 t^2 + 16 t^3 + 25 t^4 + 36 t^5 + 49 t^6 + 64 t^7 +
81 t^8 + 100 t^9 + 121 t^10 + 144 t^11 + 169 t^12 + 196 t^13 +
225 t^14 + 256 t^15 + 289 t^16 + 324 t^17 + 361 t^18}, {t +
4 t^2 + 9 t^3 + 16 t^4 + 25 t^5 + 36 t^6 + 49 t^7 + 64 t^8 +
81 t^9 + 100 t^10 + 121 t^11 + 144 t^12 + 169 t^13 + 196 t^14 +
225 t^15 + 256 t^16 + 289 t^17 + 324 t^18,
1 + 4 t + 9 t^2 + 16 t^3 + 25 t^4 + 36 t^5 + 49 t^6 + 64 t^7 +
81 t^8 + 100 t^9 + 121 t^10 + 144 t^11 + 169 t^12 + 196 t^13 +
225 t^14 + 256 t^15 + 289 t^16 + 324 t^17 + 361 t^18,
4 + 9 t + 16 t^2 + 25 t^3 + 36 t^4 + 49 t^5 + 64 t^6 + 81 t^7 +
100 t^8 + 121 t^9 + 144 t^10 + 169 t^11 + 196 t^12 + 225 t^13 +
256 t^14 + 289 t^15 + 324 t^16 + 361 t^17 + 400 t^18}, {t +
4 t^2 + 9 t^3 + 16 t^4 + 25 t^5 + 36 t^6 + 49 t^7 + 64 t^8 +
81 t^9 + 100 t^10 + 121 t^11 + 144 t^12 + 169 t^13 + 196 t^14 +
225 t^15 + 256 t^16 + 289 t^17 + 324 t^18,
1 + 4 t + 9 t^2 + 16 t^3 + 25 t^4 + 36 t^5 + 49 t^6 + 64 t^7 +
81 t^8 + 100 t^9 + 121 t^10 + 144 t^11 + 169 t^12 + 196 t^13 +
225 t^14 + 256 t^15 + 289 t^16 + 324 t^17 + 361 t^18,
4 + 9 t + 16 t^2 + 25 t^3 + 36 t^4 + 49 t^5 + 64 t^6 + 81 t^7 +
100 t^8 + 121 t^9 + 144 t^10 + 169 t^11 + 196 t^12 + 225 t^13 +
256 t^14 + 289 t^15 + 324 t^16 + 361 t^17 + 400 t^18,
9 + 16 t + 25 t^2 + 36 t^3 + 49 t^4 + 64 t^5 + 81 t^6 + 100 t^7 +
121 t^8 + 144 t^9 + 169 t^10 + 196 t^11 + 225 t^12 + 256 t^13 +
289 t^14 + 324 t^15 + 361 t^16 + 400 t^17 + 441 t^18}}*)
Wolfram's book Elementary Introduction focuses heavily on Table
, so it wouldn't be bad to get familiar with it :)
{}
button in the editor) not LaTex. Please edit your question and insert the code instead. Also, describe the issue you are having and the expected outcome. $\endgroup${}
button. $\endgroup$For
loop need to be comma separated,
(seei=1;i
...) and for multiple statements in theFor
loop you need to use;
. Second, you're better off usingTable
for this... $\endgroup$