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

learn more… | top users | synonyms

10
votes
0answers
584 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 ...
6
votes
0answers
473 views

Increasing recursion speed in Hull-White trinomial tree calculation

First timer here and have been finding these boards very useful in learning Mathematica. I'm trying to implement a numerical procedure for the Hull-White trinomial tree in Mathematica. Despite using ...
5
votes
0answers
77 views

Improve recursive function (memoization)

These days I am trying to rewrite the following recursive function, in order to gain some speed. It is crucial because I end up using 4-5 similar functions, and I need to decrease execution time. ...
4
votes
0answers
31 views

Maximum number of recursions lower than $RecursionLimit

Consider the following code segment: f[x_]:=Module[{y}, Print[counter++]; Return[f[x+1]]; ]; $RecursionLimit=20; counter=0; f[0] The function terminates ...
4
votes
0answers
78 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 ...
4
votes
0answers
140 views

Efficient Generation of Subgraphs (or, unfriend a friend a day)

NB: If you're not interested in the back-story, you could simply jump forward to the code which I'm seeking to optimize. Also, I believe this code would only work for MMA 8.0 and above. My friends ...
3
votes
0answers
87 views

Generating Functions with multiple arguments

I want to solve the recurrence of Ackermann function using Generating Function in Mathematica. ...
3
votes
0answers
79 views

How to speed up solution of system of recurrence equations

I was wondering how I can improve the speed on this method for solving a particular system of coupled recurrence equations. The system is $$ \begin{align*} &V(m)=\alpha + \beta V(m+1)+\beta \sum_{...
3
votes
0answers
639 views

Solving recursion relations using Mathematica

I want to solve the recursion relation given in equation 2.7(a/b) on page $6$ of this paper. (..the initial seed is $F_1 = G_1 = 1$ and the functions $\alpha$ and $\beta$ are defined on page $5$ in ...
2
votes
0answers
43 views

Convergence of a recursive function

I am trying to study the convergence of a function that is defined by recursion. We want to find for which 'j' the difference between $ g_i^j $ and $ g_i^{j+1} $ is equal or smaller than $10^{-3}$ . ...
2
votes
0answers
278 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 ...
2
votes
0answers
129 views

RSolve and incomplete gamma function

I am interested in how Mathematica uses the incomplete gamma function to solve difference equations. For example, if we have this inhomogeneous, 2nd order equation and use ...
2
votes
0answers
274 views

Am I entering this 2-variable recurrence correctly?

I'm trying to solve this recurrence with two variables. RSolve[g[d, n] == 1 + g[d - 1, n] + g[d - 1, n - 1] && g[d, 0] == g[0, n] == 0, g[d, n], {d, n}] ...
1
vote
0answers
22 views

Solving recurrence equation depending on a parameter

I have a recurrence relation which depends on a parameter $t$ and I am trying to solve it using RSolve. This is what I typed: ...
1
vote
0answers
53 views

recursion and if-statements

So im trying to write a recursion module in mathematica (specifically for strassen multiplication but this doesn't matter). My issue is I don't really know how if statements work in mathematica and if ...
1
vote
0answers
51 views

Index change in a recursive definition

Assume I have the following recursive definition: ...
1
vote
0answers
65 views

Problem with converting recursive code to iterative

I am trying to convert a snippet that uses recursion into one that uses iteration for drawing an L-tree, but my code produces duplicate points. How do I avoid generating them? Recursive version: <...
1
vote
0answers
70 views

RSolve with simple initial condition

Suppose we have the following equation: $$ g_ma_m=r_ma_{m-1} $$ with initial condition $a_L=d$ and $L$ might be negative. The following command ...
1
vote
0answers
79 views

Calculating the recursion at the Fourier domain

I would like to calculate the following recursion with mathematica $$f_n(x)=\int_{B}^{A}f_{n-1}(x-\omega)f(\omega)\mbox{d}\omega\quad\quad f_1(w):=f(w)$$ This is simply the convolution of $f$ with ...
1
vote
0answers
209 views

RSolve doesn't solve this recurrence equation

RSolve[{1 == b ((c k[t - 1]^a - k[t])/(c k[t]^a - k[t + 1])) c a k[t]^(a - 1), k[1] == b, k[3] == a}, k[t], t] I tried to read the documentation in Help ...
0
votes
0answers
23 views

Recursion and Its Stoppage Criteria

Let there be a recursive function V whose first value is set at 0. How can I find its converged value in such a way that the recursion stops when the difference between the newest and the one before ...
0
votes
0answers
48 views

Value Iteration (Recursive iteration) to Minimize (Optimize) a Function

I have a function that I call as "Value". I am trying to find the minimum of this function and this function is a function of 4 other functions. One of these four functions is recursive based on the ...
0
votes
0answers
180 views

simulate a 32-bit signed integer overflow in a recurrence function

Considering the following recurring equation: which is this factorial function: I want to find the value of x where f(x) = 0. Actually, the solution is impossible with Mathematica, and it's ...
0
votes
0answers
150 views

Nested Recursion Equation

I have been trying to solve a "nested recursion equation" using Mathematica. However, when I do something like this: ...
0
votes
0answers
38 views

Scoping in recursive function leading to unexpected results

I'm trying to implement Ramer-Douglas-Peucker line simplification in Mathematica, and I'm running into an issue with recursion. My implementation of the algorithm is below: ...