How to create recursive sequences in list form?

jospercomp shared this question 4 years ago
Answered

I found this super command to create the Fibonacci sequence but the values are separate and I want to form a list of those values.Execute(Join({"f_{1} = 1", "f_{2} = 1"}, Sequence("f_{"+(i + 2) + "} = f_{" + (i+1) + "} + f_{"+ i +"}", i, 1, 10)))

After, This other command say: Create slider(s) for: f_{i}


Sequence(f_{i}, i, 1, 10, 1)

and this other command generate text

Sequence("f_{" + (i) + "}", i, 1, 10, 1)

l1={"f_{1}","f_{2}","f_{3}","f_{4}","f_{5}","f_{6}","f_{7}","f_{8}","f_{9}","f_{10}"}

In this case, I need remove all quotation mark " " so that then it works.

Comments (13)

photo
2

try:

IterationList(a + b, a, b, {1, 2}, 10)

with result l1= {1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144}

link

photo
1

If the recursive sequence is a_n=n*(a_{n-1}) if a(1)=-1 or a_n=(a_{n-1})+n if a(1)=2

how I adding n value recursive.

photo
1

sorry, I don't understand "a_n=n*(a_{n-1}) if a(1)=-1 or a_n=(a_{n-1})+n if a(1)=2"

maybe in english or pseudocode, give an example with result.

photo
1

f_n=n*(f_{n-1}) if f(1)=-1

Execute[Join[{"f_{1} =-1"}, Sequence["f_{"+(i)+"}="+i+"*f_{"+(i-1)+"}",i, 2, 10]]]

f_n=(f_{n-1})+n if f(1)=2

Execute[Join[{"f_{1} =2"}, Sequence["f_{"+(i)+"}=f_{"+(i-1)+"}+"+i,i, 2, 10]]]

f_n=- f_{n-1}*(1+1/n) if f(1)=2

Execute[Join[{"f_{1}=2"},Sequence["f_{"+(i)+"}=- f_{"+(i-1)+"}*(1+1/"+i+")",i, 2, 10]]]

How I can change those three command to IterationList command?

photo
1

d71d64f0a7685932e4703193a384158f


aac225587b711e54ea1d31ea2638c917

41fdb02dda3698f8ce327bb5a3555ec5

photo
1

I attach an image for each command in order.

photo
photo
2

The first sample in 2 versions (l1with IterationList and l2 with Execute(l2script))

Rest later, if necessary (please give feedback. I think you want use the more easy Execute()-variante)

photo
1

Thank you very much for the archive and for the advanced tutoring of Geogebra.

You should upload that file to your Geogebra account.

Title: Recursive Sequence using n / i within the Sequence

photo
1

I would like to learn how to use both to learn how to create super commands. For me the important thing is to learn to use the commands and see how I can implement them in many ways. Going for the easiest is not the most educational decision.

photo
1

Second Example: f_n=(f_{n-1})+n if f(1)=2

Execute(Join({{"l2={2}"}, Sequence("SetValue(l2," + (n) + "," + (n) + " + l2(" + (n) + "-1))", n, 2, 10)}))

=======

Third Example: f_n=- f_{n-1}*(1+1/n) if f(1)=2

Execute(Join({{"l2={2}"}, Sequence("SetValue(l2," + (n) + ",-(1+1/" + (n) + ") * l2(" + (n) + "-1))", n, 2, 10)}))

photo
1

Second Example: f_n=(f_{n-1})+n if f(1)=2

Zip(Element(L, 2), L, IterationList({Element(lst, 1) + 1, Element(lst, 1) + 1 + Element(lst, 2)}, lst, {{1, 2}}, 9))

====

Third Example: f_n=- f_{n-1}*(1+1/n) if f(1)=2

Zip(Element(L, 2), L, IterationList({Element(lst, 1) + 1, -(1+1/(Element(lst, 1) + 1)) * Element(lst, 2)}, lst, {{1, 2}}, 9))

photo
photo
2

Yes your solutions are correct.

In the example-3 I implement a round() because otherwise the floating-point error becomes noticeable.

Attached my solutions including IterationList

Note also the external script list in algebra view

photo
1

The third possibility: recursion in the spreadsheet.

© 2023 International GeoGebra Institute