For questions about defining recursive functions, recursive algorithms and solving recursive equations.

learn more… | top users | synonyms

3
votes
0answers
209 views

Transform recursion for coefficients into differential equation for generating function

Assume, one is given a linear recursion with polynomial coefficients for a sequence $(a_i)_i$, such as a[i] == i a[i-1] I would like to convert this recursion ...
0
votes
4answers
108 views

RSolve fails on a two-equation non-linear system

I have a system of just two recurrence equations, I need to solve them and so I use RSolve: ...
0
votes
0answers
36 views

What does K[1] represent? [on hold]

I am trying to solve this recurrence relation: RSolve[a[n]==k*a[n-1]+t[n], a[n], n] Mathematica returns: $\left\{\left\{a(n)\to j^{n-1} \left(\sum ...
1
vote
1answer
40 views
0
votes
0answers
43 views

How can I use a For loop in a recursive function?

I am creating a simple radix2 FFT algorithm (based on Cooley-Turkey) by using a recursive function to obtain the fft. The function is supposed to work on a list (assuming the length is a power of ...
1
vote
0answers
17 views

Solving a pair of recurrence relations [duplicate]

Why does this RSolve[{y[t] == a*y[t - 1]}, {y[t]}, t] work, while this ...
0
votes
1answer
63 views

How to plot particular piecewise defined functions in mathematica

How to plot such functions in Mathematica? Let $a_0, p,g,c$ be any positive integers, defining: $$a_{n+1} = \begin{cases}\frac{a_n}{p} &, a_n \text{ divisible by p}\\ ga_n +c &, a_n \text{ ...
0
votes
0answers
66 views

Caching RecursionLimit::reclim error

I am learning how to catch exceptions, RecursionLimit::reclim in particular. To see how it works, I came up with the following example: ...
4
votes
1answer
141 views

Creating a dynamic plot directly from the recurrence relation

I have the following recurrence relation that has no general solution: $$x(t+1) = \frac{x^2 + x(1-x)(1-sh)}{x^2 + 2x(1-x)(1-sh) + (1-x)^2(1-s)}$$ In Mathematica language it gives: ...
2
votes
0answers
90 views

Faster Ways to compute recursive summation

It takes a long time to compute the summation below, and I'd like to know if there are some better ways to compute things faster. I have used $3$ ways to calculate, but they are very unsatisfactory. I ...
4
votes
2answers
143 views

Nested list to graph

The following nested list can be regarded as a representation of a (tree) graph: ...
0
votes
1answer
49 views

How to define a function that operate with a base case recursively? [duplicate]

Let's start from the simplest case: say I have a function $f(x)=x$, and let's say I want to define a new function (of $x$) to be its $n$-th power $(f(x))^n$. How should I write the code? I tried: ...
1
vote
2answers
81 views

Summing Over a Variable Number of Indices

I am trying to figure out the best way to include a variable number of indexes of summation in a program. For example: Suppose I want to define a function $g[n,s]$ that returns the sum ...
2
votes
2answers
118 views

Solving a dynamic program via recursion

I'm trying to use recursion to solve a joint inventory/ dynamic pricing problem as in monahan, petruzzi and zhao 2004. I tried to solve for y[t] and ...
7
votes
1answer
740 views

Efficient backtracking with Mathematica

Backtracking is a general algorithm for finding all (or some) solutions to some computational problem, that incrementally builds candidates to the solutions, and abandons each partial candidate c ...
0
votes
1answer
93 views

How to solve the recursion equation that include the uncertain value i in it?

I write the following code of a recursion equation, but it can not work correctly. ...
3
votes
2answers
115 views

Unset while running recursion

I am trying to run a recursive definition while at the same time clearing previously found values, so my memory is not completely consumed. I found this: How to clear parts of a memoized function? ...
1
vote
3answers
232 views

List of Tribonacci Polynomials with Mathematica? [duplicate]

I want to list top ten of Tribonacci polynomials. I have following algorithm, but it doesnt work. ...
5
votes
1answer
278 views

What is the most elegant way to specifiy a start case for recursion?

When writing recursive code that computes the least value at which a condition is true and various other scenarios it is often necessary to specify a base case. What I have done to supply this is ...
0
votes
1answer
48 views

Defining a formal Primitive Recursion

I'm searching for a way to define the function this wikipedia article call Primitive Recursion. It should have two functions as argument and it should return a function. I need this as helping in ...
1
vote
1answer
106 views

Defining a recursive integral sequence

I have a recursive integral sequence as follows: $$y_0(x)=1+r,$$ $$y_1(x)=-\frac{1}{\Gamma(a)}\int_0^x (x-t)^{a-1} y_0(t) dt,$$ $$\vdots$$ $$y_n(x)=-\frac{1}{\Gamma(a)}\int_0^x (x-t)^{a-1} y_{n-1}(t) ...
2
votes
1answer
139 views

calculating a sequence of functions using iteration

I am trying to compute a sequence of functions using iteration and keep running into problems trying to use built in looping commands because of the recursive nature of the definition. The code below ...
11
votes
7answers
365 views

Concatenation of lists in a Fibonacci-like pattern

I am trying to create a List of elements that follow the general pattern: $$X_{n+1} = X_n X_{n-1}$$ where the operation on the right hand side is concatenation, i.e., joining. I want to achieve the ...
4
votes
1answer
175 views

Computing a series in terms of exponential function

Is there any way to compute the following series in terms of exponential function ? $$\sum_{k=0}^\infty Y_1(k)\;x^k$$ where $$Y_1(k) = \frac{(k - 1)!}{k!}Y_3(k - 1)$$ $$Y_2(k) = \frac{(k - ...
0
votes
1answer
89 views

Explicit, closed formula for recursive integral as a function of the recursive parameter

This is a follow-up of this question/answer. I'm working on a recursive integral more complicated than the one on the linked question, but this one can be used as an example. I would like to obtain ...
5
votes
3answers
388 views

Solving recurrence sequence using an ODE

I'm trying to solve the recurrence a[n] == 0 for n < l a[l] == 1 a[n] == (l + 2(n - l) a[n - l] + (n - l)(n - 1) a[n - 1])/n(n - l + 1) for n >= l using ...
1
vote
1answer
246 views

Solving a nonlinear system of recurrence equations

I am having two problems regarding Mathematica, and both of them are happening because it does not accept such inputs: ...
1
vote
1answer
111 views

Why do I get an error message when for this type of recursion?

When I type the following code: mus[] = 0; mus[x__] := First[List[x]] + mus[Rest[List[x]]] What one would think would happen is that if, ...
5
votes
1answer
103 views

How can I use a recursive function in a Module

I have a question about using a recursive function in a module. I made the following example to illustrate the question. The followwing code works: ...
2
votes
2answers
131 views

Rook walk and RecurrenceTable in Mathematica

This appears in a combinatorics book: $a(m,n)=2 a(m,n-1)+2 a(m-1,n)-3 a(m-1,n-1)$ It is a recurrence equation for the number of rook walks from $(0,0)$ to $(m,n)$. The initial conditions are: $ ...
5
votes
1answer
161 views

How to deal with too much recursion

I have put together a very simple climate model based around four equations which define the state at time t based on time t-1, ...
1
vote
2answers
64 views

Optimize recurrence output

I have recurrence and I need to calculate first $N$ members of the sequence ...
9
votes
2answers
275 views

Recursive Integral for Volume of $n$-Ball

The volume of an $n$-ball (the $(n+1)$-dimensional analogue of a disk) of radius $r$ can be found by the following integral recurrence: $$V_0(r)=2r$$ ...
3
votes
4answers
252 views

Recursive function for calculating the arithmetic mean of a vector

I want to write recursive function for calculating the arithmetic mean of a vector. For $X(n)=\{1,2,3,\ldots, n\}$, the formula is ${\rm Mean}(X(n))=((n-1)\, {\rm Mean}((X(n-1))+X_n)/n$. My ...
4
votes
3answers
132 views

Long waiting time for computing a summation

It takes a long time to compute the summation below, and I'd like to know if there are alternative ways to compute things faster. When replacing $15$ by $\infty$, then I should get $3^{1/3}$. I need ...
2
votes
2answers
218 views

Recursive formula involving a piecewise function

I am trying to construct a recursion, g[t], where g[t] = a[t] if g[t-1] = 1 ...
5
votes
1answer
166 views

How can I define a Listable function only apply to a vector?

Consider the function f which should behave as f[{{1, 2}, {3, 4}, {5, 6, 7}}] ...
8
votes
3answers
365 views

Create sine function with random increase in phase

I am trying to simulate a signal that randomly increases its phase, so far I have tried two thing but neither worked. I usually use matlab but I want to learn some Mathematica so I thought I would try ...
2
votes
1answer
131 views

Integral of GeneratingFunction

I know that GeneratingFunction can be used to compute the generating function $\sum_{n=0}^\infty a_n x^n$ of a sequence $(a_n)_n$ via GeneratingFunction[a[n],n,x] ...
0
votes
1answer
105 views

fit recursive function to data

I have a function $g(x, n)$, which is a recursive expression: $x$ is a variable and $n$ the number of iterations. In my case $n=3$ for all $x$. An example is the following: ...
1
vote
1answer
213 views

Finding n-th term of a sequence of functions

Lets say, I have the following series of functions, $f_1=a+1$ $f_2=a^2+2a+1$ $f_3=a^3+3a^2+3a+1$ Assume that $f_4, f_5,$ and $f_6$ are also known. However $f_n$ is not known as a function of $n$. ...
7
votes
0answers
201 views

Compile recursive function modifying global variables

How to compile recursive formula when it relies on more than a few global variables (global to the topmost compiled function)? It is unreasonable to pass on all such variables to each recursive ...
1
vote
1answer
196 views

How can I solve my recursion equation?

How can I solve the recursion equation given below? I doubt there have no solution for the recursion equation because this is circulating recucrsion equation. ...
7
votes
2answers
275 views

How can I define a sequence of functions?

I need to define a function fun, and then re-define this function iteratively. The code is given at the end. First, a function ...
3
votes
1answer
146 views

Converting this recursive function definition into nested sums?

Here's the recursive function I'm using: DH[n_, k_, s_] := Sum[Binomial[k, k - j] DH[n/m^j, k - j, m + 1], {m, s, n^(1/k)}, {j, 1, k}] DH[n_, 0, s_] := 1 Now, ...
6
votes
1answer
130 views

Recurrences of lists

Assume we have a multi-dimensional recurrence, e.g. $\qquad\begin{align*} a_1 &= (1,2) \\ a_n &= (1,2) + a_{n-1} \quad, n>1 \end{align*}$ with the easy solution $a_n = (n,2n)$. How ...
3
votes
2answers
134 views

Implementation of a recurrence relation for the polynomials appearing in the large order asymptotics of the Bessel functions

I would like to implement the recurrence relation for the polynomials $U_n(x)$ appearing in the large order asymptotics of the Bessel functions. The recurrence in question is ...
0
votes
2answers
113 views

Problem with Looping/Recurrence - Null Results [closed]

I'm trying to create a function that maps over a list of bits, and either returns the original bit or "mis-reads" the bit itself. The idea here is to simulate transcription errors. Here's the ...
1
vote
4answers
277 views

Recurrence relation in a table

I am trying to generate a list of x-values for a function using a module, where my x-value must increase by 'a' if the term ...
1
vote
2answers
91 views

Using RecurrenceTable index to call elements of a vector

I am having trouble doing something that seems straightforward. I have a recursive sequence that I would like to produce which looks as follows: ...