Questions tagged [recursion]
For questions about defining recursive functions, recursive algorithms and solving recursive equations.
681 questions
2
votes
1
answer
118
views
Why is wolfram not able to generate some iterations from this recursive system?
Consider the following system:
...
3
votes
5
answers
788
views
How do I set up a recursive algorithm to repeatedly square root a positive real number?
From real analysis, I was asked the following question:
What happens when you hit the square root key repeatedly on a calculator for any initial positive number $x$? Formulate this question in terms ...
5
votes
4
answers
258
views
How to define a constructor-like simplification for symbolic types without causing recursion?
I would like to define a data representation SomeHead[l, r], where the constructor automatically returns a simplified or normalized form. The simplification process ...
2
votes
3
answers
301
views
Recursive Function with Integral
I am trying to recursively define the following function:
...
0
votes
0
answers
87
views
How can I prevent infinite recursion when using `Table` to multiply symbolic basis elements in Mathematica?
I admit I’m a bit desperate for a solution here, I have defined in Mathematica:
A basis newBasis (built from a function ...
3
votes
1
answer
178
views
How to handle general recursive equation
I am trying to figure out how to implement a Lagrangian where one of the constraints is a recursive function. Let me give a super simplified example:
Consider the following recursive function:
...
2
votes
1
answer
224
views
Generate a Table for the Onset of Period Doubling for the Sine Map
Below is my Mathematica code to generate the bifurcation diagram of the sine map x_n+1 = rsin(Pix_n) or in this form f(x) = rsin(Pix). (How to isolate the bifurcation points from the sine map's ...
2
votes
1
answer
129
views
How to introduce an action between sets and an recursive relation?
I would like some advice - help for the following:
Suppose $A, B$ two subsets of $\mathbb N$, we define the following action "$\cdot$":
$A\cdot B=\{ |a\pm b|,\ \forall a\in A, b\in B$ }. For ...
4
votes
2
answers
287
views
Splitting a list recursively
This may be a simple problem, but the goal is to process the list recursively. I want to call a function that splits a list in half recursively. My function is shown below. Could I get help to call it ...
1
vote
3
answers
245
views
Derive the recursion relation of a power series solution of ODE
Problem:
I want to obtain a recursion relation for the coefficients of the power series, which satisfies an ODE. Note: the purpose here is to get the recursion relation, rather than solving the ODE ...
2
votes
2
answers
364
views
How to draw a graph with recursion
I'd like to draw a graph, using recurrence table, but when I add normalization, the program stops working (it does not draw anything). Can you please help me fix it? For example:
Without ...
3
votes
3
answers
371
views
How to isolate the bifurcation points from the sine map's bifurcation diagram
I have the following code for the bifurcation diagram of the sine map. It works well but I would like to isolate where the onset of period doubling begins (the bifurcation points) along the horizontal ...
5
votes
2
answers
214
views
Expression for a vector-valued recurrence relation
I am trying to find an expression for the x[t+1] in the following recurrence relation
x[t + 1] == x[t]/P . x[t]
Where ...
1
vote
1
answer
163
views
Recurrence problem
Here is the code :
Generation of the pulse signal with parameters Vmin, Vmax, Subscript[t, r], Subscript[t, f], Subscript[t, on], T
...
0
votes
1
answer
140
views
RecurrenceTable - Message text not found
According to Mathematica documentation the following code works:
...
4
votes
5
answers
568
views
How to Speed Up the Summation of a Sequence?
A sequence (a_n) is given with a recursive formula, and another new sequence (b_n) is formed by the remainders of each term of (a_n) divided by 3. When calculating the sum of the first 2022 terms of ...
0
votes
3
answers
111
views
Getting symbolic sum from a[k]
My Goal is to get summation from definition a[k] as below. I tried simple arithmetic progression 1,2,3,4,5.. . Although the function Sum returns symbolic result nicely, but my code doesn't. How to fix ...
1
vote
1
answer
122
views
Growing list of lists in for loop [closed]
I want to list all the preimages of the critical values of a polynomial, and I'd like to have them in a list of lists so that all preimages of the same critical values are in the same list.
...
2
votes
2
answers
222
views
List of all sequences with certain properties
I am trying to relearn Mathematica after a gap of around 30 years. I want a list of all sequences of non-negative integers with certain properties. Each sequence has the same length len and the sum of ...
5
votes
1
answer
148
views
Error handling: catch a TerminatedEvaluation[_]
How to "catch" a _TerminatedEvaluation while calculating.
Supposing that I have two methods to get the result, f[x] ...
14
votes
0
answers
384
views
RSolve give a wrong result?
Bug introduced at or before 5.2, persisting through 14.2
I am trying to solve the recurrence solution:
$$
a_{n+1}=a_{n}+2+2\sqrt{a_{n}} \tag1
$$
and the following is my Mathematica code:
...
0
votes
1
answer
156
views
0
votes
3
answers
130
views
Standalone Table Invocation Using NextPrime to Generate Sequence of Division of Integers
My objective is as follows:
Create a sequence of numbers where the denominator is always the next even number (starting with 2) and the numerator is always the next prime (starting with 2).
My first ...
9
votes
4
answers
629
views
Represent and evaluate an infinite expression
I am trying to represent this in Mathematica, then evaluate it:
...
2
votes
1
answer
189
views
Defining a recurrence relation
How do I define the following recurrence relation in Mathematica?
$$ q_0 = \sqrt{w + 2 \epsilon J},\ q_n = \frac{\epsilon\left(J_n q_0 + \sum\limits_{m=1}^{n-1} \left(J_{n-m} + J_{n+m}\right)q_m\right)...
0
votes
3
answers
141
views
2
votes
2
answers
81
views
How to fix parameter locally for iterating recursion equations
The following is a simplified version of a more detailed problem.
I have two coupled recursion equations of two variables, x and y. One equation also depends on a parameter, c:
...
0
votes
0
answers
59
views
Return[] in Recursive Functions [duplicate]
Here is the pseudocode I am using to demonstrate the problem.
...
1
vote
2
answers
188
views
RecurrenceTable vs For loop : they do not give the same results. Why?
I have a second-order recurrence equation that I want to plot.
I've used two different methods.
The first uses RecurrenceTable, the second uses a traditional ...
1
vote
1
answer
174
views
Most efficient way of defining the following sets for every step $n$
For each $n\in\mathbb{N}$, how do we compute sets $A_n$ and $B_n$ below:
Let $A_1=[0,2/3)$. Let $B_1=(2/3,1]$.
If $A_n$ is a union of intervals, then for each interval cut out the
middle $1/2^{n+1}$ ...
3
votes
2
answers
104
views
RSolve does not evaluate this recursion with two boundary conditions
I am using RSolve to solve for a function defined recursively, with two boundary conditions:
First boundary condition describes the relationship between $f(1)$ and $f(0)$
Second boundary condition ...
2
votes
1
answer
125
views
Problem with RecurrenceTable of two variables
Let we have simple recursive function:
...
1
vote
1
answer
79
views
Strange errors of exceeding RecursionLimit in a function with two arguments, one set delayed and one fixed
INTRODUCTION
Hi. I feel a bit embarrased asking this question as the answer may be staring me in the face and there are at least two other stackexchange articles related to it.
MINIMAL WORKING EXAMPLE
...
0
votes
0
answers
119
views
Recursion limit for NDSolve
I have a fairly complex equation containing many terms, I can use the NDSolve for solving the differential equation for lesser terms (6400ish). But can't do it for ...
3
votes
2
answers
337
views
Can Mathematica simplify an ordinary differential equation (ODE) by assuming a power series solution and obtain the recurrence relation?
I have an ordinary differential equation and want to solve it using power series as ψ[x_] = Sum[Subscript[a, n] x^n, {n, 0, ∞}] to obtain the recurrence relation ...
2
votes
1
answer
114
views
Root finding for holomorphic functions, II
This is a follow-up to my question Root finding for holomorphic functions. I am trying to compute $10^6$ zeros of the derivative of the Riemann zeta function $\zeta(s)$ in the critical strip near ...
1
vote
0
answers
90
views
Solving a System of Recursively Defined Equations in Mathematica
I am trying to solve a system of equations in Mathematica where the variables are recursively defined. The system represents a probability distribution, and I want to find the values of the variables ...
2
votes
3
answers
361
views
Finding the limit of a recursive sequence
I have come across a few different questions relating to my issue (namely this one, but the answers are not working for me. Here are my inputs;
...
1
vote
1
answer
169
views
How is my code going over the recursion limit?
I don't know how my code is exceeding the recursion limit of 1024.
...
0
votes
1
answer
126
views
Recursion not working for higher terms
I am trying to find the terms x9,x10,x11 and y6,y7,y8 and so on from the recursive relation given in the code.
...
1
vote
2
answers
285
views
Sorting a list of functions by exploiting the recursive structure
Given a list of functions list and a vector of arguments {t, a}:
...
0
votes
2
answers
204
views
Symbolic recursion
I have the two recursive relations:
...
0
votes
3
answers
169
views
Calculate Bernoulli numbers ( with a twist) [closed]
Mathematica has an inbuilt function BernoulliB that calculates $B_n$ for which,
$$\frac{t} {\left(e^t-1\right)}=\sum_{n=0}^{\infty} \frac{B_n}{n !}t^n $$
I need to ...
1
vote
0
answers
125
views
Understanding HoldFirst in QuickSort algorithm
I have read the implementation of QuickSort algorithm in WL from Roman Maeder's Computer Science with Mathematica (2000).
The implementation is shown below.
...
3
votes
1
answer
151
views
Recurrence formula evaluating with speacial counting of subscripts
Hoping to check some recurrance relationship like this
$a_1 = x$ and $a_2 = y$, with
$$
a_{2n+1} = a_{2n} a_{2n-1}
$$
and
$$
a_{2n+2} = a_{2n+1} + 4
$$
Tried
...
2
votes
2
answers
157
views
Optimization of a Markov сhain with symbolic transition rate
I am trying to work on 1D random walk that can move to left, right or stay with probabilities $p_i$,$q_i$,$r_i$ that changes with the site $i$. I am trying to simulate this by using a recurrence ...
1
vote
1
answer
209
views
How do you Solve a Simultaneous System of Recursions
Consider the following system of simultaneous recursions:
r[n] == s[n-1]
s[n-2] == r[n-3]
I am tring to solve this system (I have given a vastly simplified ...
1
vote
2
answers
206
views
Recursively applying a substitution
I have an expression like this:
2v[j-1]-(s[j]+1)(c[j]-c[j-1]) >= v[j]
I want to apply this recursively say k times. I can do one step like this:
...
5
votes
1
answer
221
views
Implementing recurrence relation for an integral
I would like to implement the following recurrence relation,
$$I_{n+1}=-\log(2)I_n-\sum_{k=1}^n(-1)^k\left(1-\frac{1}{2^k}\right)\frac{n!\zeta(k+1)}{(n-k)!}I_{n-k}$$
with initial conditions,
$$I_0=\...
3
votes
1
answer
319
views
How to write a recursive formula?
What is the Mathematica command for the recursive formula:
F[a_]:=Sum[(-1)^a Binomial[a,k] Log[2]^(a-k) F[k], {k,0,a}]
where
...