# Tagged Questions

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

3k views

### How can I implement dynamic programming for a function with more than one argument?

Dynamic programming is a technique for avoiding the repeated computation of the same values in a recursive program. Each value computed is immediately stored. If the value is needed again, it is not ...
10k views

### How can I use Mathematica's graph functions to cheat at Boggle?

Boggle is a word game played with 16 dice and a 4x4 tray. This question is inspired by a Stack Overflow question about Boggle that I decided to solve using Mathematica. In addition to Mathematica, I ...
1k views

### What tools can help in realizing tail recursion?

I had nice discussions with Leonid and Rojo that got me interested in tail recursion. Tail recursion is not always easy to realize with Mathematica, so it would be nice to have some tools to help with ...
182 views

### Recursion doesn't happen any more or doesn't happen correctly if I store the recursive relationship in a variable first

I know the following code will form a recursion: Clear["Global`*"] u[i_, n_] := u[i - 1, n] + u[i, n - 1] u[0, n_] := n u[i_, 0] := i u[2, 2] (* => 8 *) But ...
1k views

### How to clear parts of a memoized function?

I have a function of two variables, e.g.: f[a_, b_] := f[a, b] = something f[a - 1, b - 1] etc With the above code I used the concept of memoization to speed up ...
589 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 ...
1k views

$RecursionLimit = Infinity; T[n_, k_]:= T[n, k] = If[n == 0 || k == 1, 1, T[n, k-1] + If[n<k, 0, T[n-k, k]]]; Table[T[n!, n], {n, 1, 9}] Without ... 1answer 617 views ### Finding n-th term of a sequence of functions Lets say, I have the following series of functions,$f_1=a+1f_2=a^2+2a+1f_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$. ... 2answers 298 views ### How to “inform” successive ContourPlot calculations? I need to draw some contour plots of very non-linear functions. As a simple example, take a Mandelbrot Set divergence contour near$z\approx i$. (Just to be clear, I'm not trying to write a ... 5answers 362 views ### Wrapping a function in count I am working through the Programming Paradigms via Mathematica (A First Course) and am attempting to answer the following: Use recursion to count how many times the argument can have its square ... 1answer 244 views ### How to find a recurrence relation for a sequence? I have a sequence given by an explicit formula for n-th term: ... 2answers 1k views ### How to find a recurrence relation for a numerical sequence? This question was inspired by Vladimir Reshetnikov's question (How to find a recurrence relation for a sequence?): Given a finite sequence of numbers, how can we find in MMA a recurrence relation ... 2answers 507 views ### Plotting two recursive functions I'm trying to plot two recursive functions (p and θ) on a map. So far I have: ... 4answers 301 views ### Can the general term my recurrence equations be written with Floor or Mod? I want to know the formula for the general term of the following recurrence system. I guess it can be written with Floor or Mod. ... 1answer 257 views ### Setting$RecursionLimit crashes Mathematica 10

I have encountered what I shall presume is a bug: setting \$RecursionLimit repeatably crashes the Mathematica 10 kernel: ...
308 views

### Build recursion in parallel?

Problem Let's define a simple recursion. f[1] = 1; f[n_] := f[n] = f[n - 1]*n; If I evaluate f in parallel ...
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 ...
79 views

### Fishing for monomials in a nested or partially factored polynomial stream

I have a problem where I'd like to be able to take a multivariate polynomial whose variables are nonscalar and is not written explicitly as a sum of it's nonzero monomial terms and determine which ...
249 views

### A problem about recursion formula of de Casteljau algorithm

I use Mathematica to implement the de Casteljau algorithm $$\vec{P}_{k,i}(u_0)=(1-u_0)\vec{P}_{k-1,i}(u_0)+u_0\vec{P}_{k-1,i+1}(u_0)$$ The graphics that de Casteljau algorithm generated as follows: ...
389 views

### How do I built a zoomable Koch curve?

I'm new to Mathematica and my goal is to write a simple program in order to demonstrate self-similarity of the Koch curve by zooming in. Here is a good example of what I mean (it's a Java applet). I ...