# Tagged Questions

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

637 views

### How does one clear the memory of a recursive function

I want to implement the recursive function v[n_] := v[n] = v[n-1] + f[n-1] + Random[NormalDistribution[0,s]] to get ...
278 views

### Iterating a rational function

I'm reading about iterating rational functions. I'm given $$R(z)=\frac{3z-2}{2z-1},$$ then the author makes the statement: "Then(by induction), $$R^n(z)=\frac{(2n+1)z-2n}{2nz-(2n-1)}.$$ Is there a ...
710 views

79 views

### Assigning function values in a memoized recursive module

I have a complicated recursive module which I have memoized. I realised that certain isomorphs of inputs to this function will give the same output. Therefore I decided to memoize all such ...
56 views

### FindLinearRecurrence is not working for numerical complex number sometimes?

First FindLinearRecurrence definitely support complex number list, see ...
164 views

### Solving problem using recursive functions

Attached below is a question posed by the Canadian Mathematical Society, and I have my code and answer. Is there a better way of writing the code, and will the answer be different as a result? My ...
85 views

### Problems with multidimensional system of ODEs

I am trying to look at the migration of "i" number of species "c" in "10" number of habitats {designated as "j"} and to study their population size as a function of time "t". I have this following ...
77 views

### Solution to Simultaneous Arithmetic/Geometric Mean Recursion Relations

I'm trying to solve the simultaneous convergent sequences of geometric/arithmetic means where $a_{n+1}=\frac{1}{2}(a_n+b_n)$ and $b_{n+1}=\sqrt{a_nb_n}$ and initial values are $a_0=1+x$ and $b_0=1-x$. ...
2k views

### How can I make a Tribonacci sequence in the form of a list?

How can I make a Tribonacci sequence that is in listing form? it suppose to look like the Fibonacci sequence but I couldn't get ...
826 views

### Recursively appending elements to a list

In wanting to demonstrate the power of Mathematica, I wanted to show my 11-year-old son how we could validate that his sequences homework was correct. We could generate the next value in sequence in a ...
369 views

### Speeding up the non-negativity algorithm for multilinear function with interval probabilities?

The algorithm is a branch-and-bound algorithm that calculates the non-negativity of a multilinear function with interval probabilities. The lines 9-11 has an optimization that is explained on the ...
75 views

### How do I determine the 15th Lucas term in the 3rd order?

I want to implement the Lucas n-Step Number. This command taken from here doesn't seem to work, am I using the right command? ...
124 views

### Recursive function activity

We had the following question on an activity for our students: Let $f_0(x)=x+|x-100|-|x+100|$, and for $n\geq 1$, let $f_n(x)=|f_{n-1}(x)|-1$. For how many values of $x$ is $f_{100}(x)=0$? When I ...
247 views

### How to compile self-referencing functions (to perform recursive a task)

How do I compile a self-referencing function to perform iterative tasks? The naive approach doesn't seem to work. Here is a simple example to illustrate the problem: ...
30 views

### Why am I getting this “recursion depth” error message? [closed]

I am simply trying to use this command p[1,2][1]/.{p[x_,y_][m_]:>pp[x,y][m]} and I'm getting an error message ...
79 views

### how to write generic equation for Recurring differential equations?

Hi I am a biologist and I want to model some ecological data that I have. I am new to mathematics and to ODEs. I want to write generic equations for a multi-dimensional system of ODEs. So, I want to ...
385 views

### Second order differential equation with boundary conditions solving repeatedly

I want to solve a second order differential equation in the interval[-1:1], which does not have a analytic solution, \begin{eqnarray} y''(x) &=& k \phi^2(x)y(x) \\ \phi(x) &=& ...
284 views

### How do you create matrices using submatrix building blocks?

Here is a conundrum I am facing. I have $2$ matrix building blocks. In my problem, I associate integer $2$ with $3\times 3$ matrix $A$ with structure \begin{bmatrix} 0& a& 0\\ c& 0& ...
92 views

### Recursive calculation is very slow

I've got a recursive definition of Arcs that shares equal length and a several other dependencies to each respective predecessor. (Imagine a book being bent.) I formulated all necessary things here: ...
52 views

### Solution of recursive equations with FixedPointList

I want to solve an equation numerically for given starting values, then evaluate 3 integrals for this solution, set the results to the new starting values and iterate until the result converges. Here ...
92 views

### Optimization of recursive functions by using the //. operator [duplicate]

In some cases, recursion in Mathematica (without storing values) is not very efficient. For example, the recursive implementation of Fibonacci numbers (version which doesn't store the values) : ...
60 views

### Solving recursions

This question is tied to my previous question. I have a few recursion formulas, and I keep getting Recursion depth of 1024 exceeded. error. I need to get the ...
76 views

### Method of characteristics, recursion formulas

I'm helping a friend out with a problem. He needs to plot out the solution to a water surge in a pipeline. I have all the parameters set and I've put the equations in Mathematica, but I can't get the ...
66 views

### Recurrence relation for multivariate polynomials

I am trying to define a function which recursively computes a polynomial associated to every binary string: ComputePoly[s_]:=(** Recurse on the string s**) For ...
248 views

151 views

### RSolve gives a Context::ssle error

Bug introduced in 9.0 or earlier and fixed in 10.0 I want to solve the following recurrence equation RSolve[{(k + 2) c[k + 2] q^(k + 1) - c[k] == 0}, c[k], k] ...
867 views

### How to define a recursive pattern?

I want to translate this recursive syntactic definition into a Mathematica pattern1: $$\mathtt{x}: \begin{cases} \text{Null}\\ \{\textit{integer}, \mathtt{x}\} \end{cases}$$ In other ...
71 views

### Building up a sequence dealing with a complex recursive scheme

Suppose I have multiple lists, the first one contains 2 elements, the next one 4 elements, the next one 8 elements, and so forth. Let these elements be labeled as Gij where i refers to the list it ...
420 views

### ToExpression fails with long nested string expressions

Consider the following conversion from String to Mathematica Expression: ...
157 views

### Why does Mathematica not evaluate the difference recurrence using RSolve or RecurrenceTable?

Mathematica does not evaluate the following recurrence of two variables using RSolve and only echoes the input: ...
103 views

### What do RecursionLimit and IterationLimit actually set?

The following recursive functions respectively calculate the length of a Short-cut Collatz Conjecture series and perform a pointless demonstration recursion: ...
329 views

### Mimic a procedural, recursive clustering algorithm for site percolation using functional programming

Sorry in advance for my logorrhea: I just want to make sure all of the information is here. Context and Question I am investigating site percolation on a square lattice. I have a working, ...
124 views

### Closed form of two-layer recurrence

I am trying to find a closed-form expression for $A(0)$, described by the following recurrence forms, as a function of $L$ and $d$: \begin{align} A(\ell) &= 1 + 2^d A(\ell+1) + \sum_{g=0}^{d-1} ...
114 views

72 views

### How to build recursive function which only remembers every pth value and the last two values?

I need to create a recursive function of the natural numbers $f$ which only remembers the last two values it has found and every $p$th value. Below is the form of the code that I am working with, but ...
251 views

### Recursive Euclidean algorithm in Mathematica

Can anyone explain to me how do I use a recursion, if I don't know the limit? For example, I need the remainder $r$ of the Euclidean algorithm for $\gcd(a,b)$ which equals $0$. I figured out that the ...
179 views

### Import nested JSON file [duplicate]

For a project where I receive JSON messages from a web server I was trying to convert these messages into a format that can be used easily within Mathematica. Because JSON also consists of key-value ...
15 views

### Recurrent equations [duplicate]

I want to make a relation to show the first 7 elements that don't have the number 7 in it. So far i know how to make it to show the first 7 elements with RecurrenceTable[{a[n + 1] == 7 a[n] + a[n], ...
63 views

### Evaluate recursive funtion as a whole before computing a recursive step

I'll try to make a basic example of my problem with $n$ being an array of elements, ex. $\{1,2,2,3,3,3\}$: If i have a sum which needs a computed value i would like to compute it beforehand and store ...
346 views

### Usage of Piecewise/RSolve to solve an equation based on condition

I am trying to compute price of call option on a stock using the finite difference method. I have a VBA code for it, and I am trying to find out how I can use Mathematica memoization functions and ...