# How to create recursive sequences in list form?

jospercomp shared this question 1 year 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) 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 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. 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. 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? 1    1

I attach an image for each command in order.  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) 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 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. 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)})) 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))  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 1

The third possibility: recursion in the spreadsheet.

Leave a Comment
• GeoGebra
• Help
• Partners
• Contact us
• Feedback & Questions
• This email address is being protected from spambots. You need JavaScript enabled to view it.
• +43 677 6137 2693
© 2021 International GeoGebra Institute