Skip to main content

Questions tagged [recursion]

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

0 votes
0 answers
46 views

How to Set Precision for an RSOLVE Problem

The following code was working fine -- now it produces errors. I originally built this in ver 13.1 and I'm now running ver 14. I think I'm getting machine precision errors after k=11 that were not ...
user42700's user avatar
  • 1,773
0 votes
3 answers
85 views

RecursionLimit error appearing if solve the recursion formula

...
liang zhang's user avatar
2 votes
2 answers
46 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: ...
andring's user avatar
  • 393
0 votes
0 answers
57 views

Return[] in Recursive Functions [duplicate]

Here is the pseudocode I am using to demonstrate the problem. ...
CuriousQ's user avatar
1 vote
2 answers
118 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 ...
Pascal77's user avatar
1 vote
1 answer
89 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}$ ...
Arbuja's user avatar
  • 81
3 votes
2 answers
61 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 ...
Kuantew's user avatar
  • 131
2 votes
1 answer
86 views

Problem with RecurrenceTable of two variables

Let we have simple recursive function: ...
lesobrod's user avatar
  • 1,849
1 vote
1 answer
41 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 ...
Russell Jay Hendel's user avatar
0 votes
0 answers
63 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 ...
Bravyi's user avatar
  • 21
3 votes
2 answers
222 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 ...
PhysFan's user avatar
  • 63
2 votes
1 answer
74 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 ...
stopple's user avatar
  • 1,161
1 vote
0 answers
57 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 ...
Resting Platypus's user avatar
2 votes
3 answers
188 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; ...
ant's user avatar
  • 21
1 vote
1 answer
108 views

How is my code going over the recursion limit?

I don't know how my code is exceeding the recursion limit of 1024. ...
SurvivalWish's user avatar
0 votes
1 answer
79 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. ...
Math_student's user avatar
1 vote
2 answers
180 views

Sorting a list of functions by exploiting the recursive structure

Given a list of functions list and a vector of arguments {t, a}: ...
Tugrul Temel's user avatar
  • 6,233
0 votes
2 answers
137 views

Symbolic recursion

I have the two recursive relations: ...
Math_student's user avatar
0 votes
3 answers
112 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 ...
Dotman's user avatar
  • 496
1 vote
0 answers
74 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. ...
LambdaHaskell's user avatar
3 votes
1 answer
128 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 ...
CasperYC's user avatar
  • 1,642
2 votes
2 answers
107 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 ...
Hugo Andrade's user avatar
1 vote
1 answer
164 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 ...
Russell Jay Hendel's user avatar
1 vote
2 answers
92 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: ...
Neill Clift's user avatar
5 votes
1 answer
139 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=\...
bob's user avatar
  • 153
3 votes
1 answer
241 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 ...
Ali Shadhar's user avatar
4 votes
1 answer
99 views

RSolve for system of equations and matrix power [closed]

I have a matrix a = {{3, -2}, {2, -2}}; We can easily find the n-th power, $A^n$ using MatrixPower[a,n] We can also find the ...
Moo's user avatar
  • 3,388
4 votes
1 answer
170 views

How can I compute the $n$-th complete Bell polynomial?

I'm interested in computing the n-th complete Bell polynomial $ B_n(x_1,..., x_n) $ using the formula given as the last equation in the "Exponential Bell polynomials" section here (I tried ...
Robert Lee's user avatar
0 votes
2 answers
40 views

How to obtain terms defined by a recursion relation in terms of the first value without solving the recursion?

I have a set of coefficients $A_{i}^N$ where $i=0,\dots, N$ that obey a recursion relation that takes the form $$A_i^N = C_i^N-\sum_{M=1}^N\sum_{k=0}^{N-M}A_k^{N-M}\psi_{i,k}^{N,M}$$ The coefficients $...
user1620696's user avatar
3 votes
1 answer
165 views

How is this type of piecewise function represented and calculated? [closed]

How is this type of piecewise function as follows in the picture represented and calculated? Use: ...
csn899's user avatar
  • 4,521
1 vote
2 answers
120 views

Simulating the card game War with $m$ suits and $n$ values

I am trying to simulate the card game War to find approximations to the stopping time distribution for different types of decks, and study conditional probabilities of winning given a certain deck. (...
Teg Louis's user avatar
1 vote
2 answers
80 views

Iterate symbolic expression

I'd like to symbolically iterate this formula $1,2,...,n$ times: $$f(z,u)=\frac{z}{1-z}f(z,1)+\frac{zu}{1-zu}f(z,zu)+\frac{z^2u}{1-z^2u}f(z,z^2u).$$ I tried using ...
Daniel Checa's user avatar
2 votes
0 answers
69 views

Unexpected `LinearRecurrence` behavior in 13.2

From the definitions, I expect LinearRecurrence[{1}, {k}, 10] to be a constant array. ...
vapor's user avatar
  • 7,921
7 votes
1 answer
278 views

Recurrences related to Ramanujan's 1/pi formulas for level 10?

In the course of my research years ago, I came across three integer sequences related to Ramanujan's pi formulas but for level $10$. Their recurrence relations may be important. (Just like the level $...
Tito Piezas III's user avatar
1 vote
2 answers
99 views

SummaryBox and Recursion

How can I make it so that what is under the dropdown block is not calculated/constructed at once? Example code: ...
Kirill Belov's user avatar
3 votes
2 answers
159 views

Recursive function with subscript

I am trying to define a recursive function with a subscript. Something similar would be $f_{n+1}(x) = \int 3 x f_{n}(x)dx$. I've tried lists, For function, ...
Vicente Sepúlveda Trivelli's user avatar
1 vote
1 answer
91 views

A recursion in a sum [closed]

I wish to use a recursion to continue the updating n2, n3, etc., up to n30. Probably simple concept for an experienced MM user. Sorry. ...
Thomas 's user avatar
3 votes
1 answer
79 views

Use two derivative rules and iterate several times to get the simplest expression of higher derivative

I have 2 rules of recursive relation of the derivative, I want to use it several times get the higher derivative on [\Theta] of ...
He Tang's user avatar
  • 39
0 votes
2 answers
65 views

Recurrent equation with UnitStep function using RSolve

I have the following equation to solve $$a[n+1] = a[n] + 6 - 100\cdot \theta(a[n]-100)$$ where $\theta(x)$ is the Heaviside step function. So I tried the following ...
Андрей Кокорев's user avatar
0 votes
1 answer
135 views

Kernel crashes after long iterations

I am trying to get a numerical root of a function defined as below. But after some large recursion the kernel get crashed. But for relatively low recursion(10000) that does not make any problem. But I ...
s_mondal's user avatar
1 vote
2 answers
107 views

Module returning Null even with Module as a Return parameter

I'm currently trying to implement Newton's method of approximating roots to approximate the root of 2. I looked into some possible reasons as to why it would return Null, such as the scope of the ...
Jason Ham's user avatar
9 votes
0 answers
996 views

V 13.2 gives TerminatedEvaluation["RecursionLimit"] on code which works before. Why?

Update June 25, 2023. Problem still there in V 13.3. Added screen shot at end. I was trying code which worked all the time: How to extend a function by period and display it I find that in V 13.2 it ...
Nasser's user avatar
  • 147k
0 votes
1 answer
85 views

Problem with For Loop when evaluating a recursive function at multiple points

I am running into problems with my For loop when trying to evaluate my expression. Fix some parameter values : ...
Anna MSJ's user avatar
7 votes
4 answers
452 views

Plastic number rectangle

I'd like to find a nice recursive way of making this image based on the plastic constant Here's a start ...
martin's user avatar
  • 8,778
3 votes
1 answer
235 views

Recursive function Catalan triangle

I'm trying to learn how to build a recursive function. However, I'm not sure to understand how to set a "limit". Here is what I'm trying to make. I want a function that gives me the i,j ...
TheInvisibleParticle's user avatar
1 vote
2 answers
145 views

Speed up calculation of recursively defined list

I have two lists $a$ and $b$ of length $n$ and $n-1$ respectively (typically I have $n \approx 1000$). I have to compute a list $\theta$ of length $n$ which is defined recursively by the following ...
Matteo's user avatar
  • 283
0 votes
0 answers
102 views

Recursive Sum not evaluating correctly

I'm trying to evaluate the following sums that nest into eachother: $$ m_k=\frac{k}{k-1} \left(e^{\gamma}+ \sum_{i=1}^{k-2} {k-1\choose i} \frac{m_i}{i} \right) \\ m_1=e^\gamma $$ and $$ \kappa_n = ...
Mick Stukes's user avatar
1 vote
2 answers
162 views

Recursion with Sum

Using RSolve I tried without success to convert the recursive relation to a non-recursive function. How can I do this? ...
granular_bastard's user avatar
1 vote
1 answer
104 views

Plot of a recursive expression having a parameter

I have a recursive expression defined as $$ h_u= (1-a)(1-b) h_{u-1} + \sum_{k=2}^{u-1} (1-a) b h_{u-1-k} - \sum_{k=2}^{u} h_{u-k} - \sum_{k=1}^{u+1} \Lambda_{u,k} $$ where $\Lambda_{u,k} = \sum_{m=u-k+...
Rosy's user avatar
  • 53
2 votes
1 answer
110 views

Evaluate a double sum using Mathematica

I am evaluating using Mathematica, the double sum $\sum_{u=0}^\infty \lbrace \sum_{k= u+1}^{u+y}[\dfrac{(1-a)}{4} (3/4)^k + 3a[(\dfrac{1}{2})^{k-1} - (\dfrac{3}{4})^{k-1} ]\rbrace $, where $'a' $ is a ...
Rosy's user avatar
  • 53

15 30 50 per page
1
2 3 4 5
14