Hi all,
I am new to Mathematica but was wondering if it is possible to list complex (a+ib) elements of a sequence as a function of an element. For instance if I define a sequence recursively as x(k+1) = (1-i) x(k), can Mathematica display as output x(1)=(1-i) x(0); x(2)=(-2i) x(0); x(3)= -2(1+i) x(0); x(4)=-4 x(0); etc. ? If it is possible, how ? What would be the best way to plot the result ?
Thanks !
sol=RSolve[{x[k] == (1 - I) x[-1 + k], x[0] == x0}, x[k], k]
Thank you very much for your answer.
However I was more looking for the following one (your answer did help a little bit…):
RecurrenceTable[{x[n + 1] == (1 - I) x[n], x[0] == 1}, x, {n, 1, 12}]
or
RecurrenceTable[{x[n + 1] == (1 - I) x[n], x[0] == x0}, x, {n, 1, 12}]
Now I have to figure out how I can plot those points in the (Re, Im) plane…
![]()
OK
The RSolve given above yields as answer
{{x[k] -> (1 - I)^k x0}}
Now define a Function fx
fx[k_, x0_] := FullSimplify[(1 - I)^k x0]
Look what happens to
fx[5, 2 + 3 I]
or
Table[fx[j, x0], {j, 1, 10}]
For a plot you must specify x0. Let us chose x0 = 1
tt = Table[{j, fx[j, 1]}, {j, 1, 15}];
pl1 = ListLinePlot[Re[#[[2]]] & /@ tt,PlotStyle->Red] (*real parts*)
pl2 = ListLinePlot[Im[#[[2]]] & /@ tt,PlotStyle->Blue]
Look at both plots in one
Show[pl1, pl2]
Without having acces to such cool functions like ComplexListPlot one could do it in an old fashioned manner oneself
t1 = Table[fx[j, 1], {j, 1, 15}];
t2 = If[Head[#] === Integer, {#, 0}, List[Re[#], Im[#]]] & /@ t1
ListLinePlot[t2]
Thank you.
