Skip to content
Advertisement

Sympy – Arithmetic and geometric sequence in recursive form

I would like to define arithmetic and geometric sequences in recursive form like

  • Un+1 = Un + r (u0 n>0)
  • Un+1 = qUn (u0 n>0)

In Sympy, one can define in closed form an arithmetic sequence like this :

JavaScript

How can I define (not solve) this sequence in recursive form (Un+1 = Un + r) ?

Advertisement

Answer

You’ll need to define the recurrence relation using Function.

There is also a RecursiveSeq that may help

Example:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement