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

learn more… | top users | synonyms

1
vote
1answer
59 views

Function to calculate finite difference

I wrote a function to calculate multivariate finite difference of different orders ...
2
votes
0answers
24 views

Multidimensional integral to compute the end-to-end distribution of a FENE ideal chain

How do I evaluate the quantity $\left.\frac{d}{d\alpha} \ln Z_\alpha\right|_{\alpha=0}$ for N=30 in Mathematica, when $$ Z_\alpha = V\int e^{-\beta [H(\vec r_1)+H(\vec r_2-\vec r_1)+...+H(\vec ...
3
votes
3answers
174 views

Pare down list recursively

What is the best way to pare down a list whereby the $n$th number is removed from the list recursively? This ...
0
votes
1answer
94 views

Define a Recurrence Table involving other tables

I'm relatively new to using Mathematica. Previously I used Matlab, but lately I noticed that the numbers i got in both of them do not match (mostly it seems that Matlab lacks precision...). The ...
0
votes
1answer
36 views

How to define y[n] = f1 y[n-1] + u[n]?

I need to define a recursion defined by the following equation $y(n) = f_1 y(n-1) + u(n)$ In which $f_1$ is a symbolic constant. I know the values of the sequence u and I know the initial value of ...
2
votes
2answers
105 views

Understanding `NestList` with multiple functions

General question For a function f[n, a], where a is a list and n is a whole number, what is ...
3
votes
1answer
76 views

Mathematica taking too long to calculate recursive function

I have been trying to plot those specific recursively defined functions p1 and q1 in Mathematica: ...
22
votes
7answers
609 views

Alternative ways to implement a triangular recursion

Triangular recursions are a class of algorithms that frequently turn up in computational mathematics. These recursions are expressible in the general form ...
0
votes
1answer
70 views

Recursive functions taking list arguments

I wish to create a function that takes lists (e.g. {plus,plus,minus,0,minus,plus}) and uses the input list to calculate a corresponding value using a set of ...
47
votes
2answers
9k 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 ...
7
votes
2answers
284 views

Recursive partitioning: Is there a better way to do this?

Consider the following function, which recursively splits a list into equal length sublists (the length of the list is assumed to be a power of the second argument): ...
0
votes
0answers
57 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
31 views

Different kind of numeric erros when plotting recursive functions

I have been trying to plot some numeric solutions to a Hamiltonian system. Basically I have ...
1
vote
1answer
63 views

solve recursive factorial function [closed]

Is there a way to solve this recursive factorial function? a[n + 1] = (n+1)*a[n], a[10]=10 I am looking for the value of a[n] ...
4
votes
2answers
561 views

Variable that changes itself

I am trying to store a boolean value into a variable with the additional property that the value changes each time the variable is called. ...
0
votes
0answers
94 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
26 views

how many even number faced dice will be their if 99 dices roll for eternity with some condition [migrated]

Consider a six ­sided dice with number from 1 to 6. Imagine you have a jar with 99 of such dices. You throw all dices on the floor so they all land at different numbers. You look at one dice at a ...
5
votes
0answers
72 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) &=& ...
6
votes
1answer
238 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 ...
3
votes
2answers
240 views

Nonlinear recurrence relation

I entered the following recurrence relation into RSolve and it just gave the question back to me. $$a_{n+1} = \frac{(1+a_n +(a_{n−1})^3)} 3$$ Is there another way to get a formula for the nth term?
14
votes
6answers
526 views

How can I evaluate only a single step of a recursive function?

Let's say have a simple recursive function for the Fibonacci sequence f[0] := 1 f[1] := 1 f[n_] := f[n - 1] + f[n - 2] but I want to see how it will expand in a ...
11
votes
7answers
2k views

Recursive function with if-statement

I am trying to represent the following function definition in Mathematica: $$\begin{align*} f(1)&=1 \\ f(2n)&= \begin{cases}f(n) & \text{if}\space n\equiv0\pmod{2} \\ 2f(n) & ...
5
votes
2answers
177 views

Plotting two recursive functions

I'm trying to plot two recursive functions (p and θ) on a map. So far I have: ...
10
votes
5answers
574 views

How to deal with recursion formula in Mathematica?

In engineering problems, I am always seeing many recursion formula. For instance, In the book "The NURBS book", I discovered many recursion formula Fibonacci ...
0
votes
2answers
84 views

Square root estimation

I happened to read a something online about estimating a square root in a very simple way, known as Heron's method or the Babylonian method for square roots. The following (python?) code was included ...
1
vote
0answers
32 views

Central binomial coefficient [closed]

I am tasked with creating a recursive definition of the binomial coefficients that stores previously calculated values. this is what I have: ...
21
votes
3answers
957 views

Visualisation of a recursive function

Is there a way to nicely visualize recursive functions? (diagrams/plots) More specifically I'm looking for a way to make contrast (visually) between e.g. the cosine function which if continuously ...
5
votes
4answers
253 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. ...
3
votes
2answers
202 views

A problem about recursion formula of deCasteljau algorithm

I use mathematica to realize the deCasteljaul 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 deCasteljaul algorithm generated as below: ...
3
votes
4answers
150 views

Plotting recursive from a for loop

our assignment is that we have make a plot for the possition of 1's From the recursive function if a[n-1] is even then ...
1
vote
1answer
90 views

How to find the closed formula for a recursion [closed]

From theory of recursive functions, an example for linear recursion is: $$ f_x = 0 \ \ \ x\leq 1$$ $$ f_2 = 1$$ $$ f_n = f_{n-1} + 8n - 18$$ If you want to find out a close formula for it, one way is ...
7
votes
2answers
176 views

Solving with DSolve recursively

I need to find $f(x,n)$ in the interval [0,1] defined by recursion, \begin{equation} \frac{d f(x,n+1)}{dx} = f(x,n) \end{equation} with boundary conditions $f(0,n+1) = 1$ and $f(x,0)=1+ x $ Using ...
1
vote
0answers
58 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 ...
4
votes
2answers
178 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 ...
7
votes
1answer
105 views

How to find a recurrence relation for a sequence?

I have a sequence given by an explicit formula for n-th term: ...
2
votes
1answer
80 views

Implementing local variables of a recursive function with either Module or Block

First, some quick background: I have been eagerly learning Wolfram and Mathematica for two months now, and along the way have written about 250 pages of teaching material that has ballooned into a ...
7
votes
2answers
74 views

Recursive function with array of variables

I am trying to create a recursive function which works with an increasing array of variables. Since the formula is quite complex, i will try to simplify my example to the core of my problem. The ...
3
votes
1answer
289 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 ...
5
votes
1answer
186 views

How can I make a “self-referential” replacement operation self-contained?

Fairly often I find use for replacement rules that call themselves on the right-hand side of the rule, e.g.: ...
1
vote
1answer
166 views

Programming a recursive FFT with Mathematica

I'm trying to program a FFT using a recursive function in Mathematica, though my program is not getting me anywhere at the moment. Could you say what's wrong with it and what I can do to make it work? ...
5
votes
1answer
69 views

Specifying Range of RSolve

When I input RSolve[{0 == q[n + 1]^2 + 3 q[n + 1] + 2 q[n + 1] q[n] - 6 q[n] + q[n]^2, q[0] == 1}, q[n], n] I get two complicated-looking complex solutions: ...
4
votes
2answers
127 views

Integrating a periodic function

I have a periodic function ff: ff := Function[x, Piecewise[{{ff[x - 1], x >= 1}, {2 x, 0 <= x < 1}, {ff[x + 1], x < 0}}]] Plotting it works fine: ...
0
votes
0answers
35 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: ...
0
votes
2answers
107 views

Solving an Equation (Recursively)

I have the following Values: $a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=\frac{g_2}{20};a[5]=0$. I need to compute the value of $b[n]$ in the following equation $$a[n]=\sum _{m=0}^{n} (m-2) \;\;a[m] ...
4
votes
3answers
201 views

How to solve an integral equation by iteration method? [duplicate]

How I can obtain $n^{th}$ approximation of the following equation $f(t)=t+\int_0^tds f(s)$ by iteration method?
11
votes
2answers
200 views

ToExpression fails with long nested string expressions

Consider the following conversion from String to Mathematica Expression: ...
5
votes
1answer
217 views

Setting $RecursionLimit crashes Mathematica 10

I have encountered what I shall presume is a bug: setting $RecursionLimit repeatably crashes the Mathematica 10 kernel: ...
3
votes
1answer
102 views

Find exact limit of recurrence relation $x_{n+1}=\cos(x_n)+1, x_0=1$

I did this: b[x_] := Cos[b[x - 1]] + 1; b[0] = 1; num = SequenceLimit[N[Table[b[n], {n, 1, 100}], 50]] I also did the listplot which shows a convergent value. ...
1
vote
2answers
55 views

Print argument of function that exceeds $RecursionLimit

Is there a way to print the argument of a function which results in a $RecursionLimit::reclim error? As an example, cosider the code ...