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

learn more… | top users | synonyms

0
votes
0answers
15 views

Recurrent equations [duplicate]

I want to make a relation to show the first 7 elements that don't have the number 7 in it. So far i know how to make it to show the first 7 elements with RecurrenceTable[{a[n + 1] == 7 a[n] + a[n], ...
-1
votes
0answers
23 views

Delete integer cases that contain specified number [duplicate]

I have a sequence generated with this RecurrenceTable function: RecurrenceTable[{a[n + 1] == 7 a[n], a[1] == 3}, a, {n, 1, 10}] and I would like to remove the ...
1
vote
1answer
93 views

Recursive Euclidean algorithm in Mathematica

Can anyone explain to me how do I use a recursion, if I don't know the limit? For example, I need the remainder $r$ of the Euclidean algorithm for $\gcd(a,b)$ which equals $0$. I figured out that the ...
-3
votes
0answers
28 views

Recursion with an exception [duplicate]

I need to print the first 7 members of the sequence a[n] with its reccurence formula a[n+1]=7*a[n]+n, where a[1]=1 and the digit 7 dosnt occur.
0
votes
2answers
40 views

Using Nest on a function that takes a function as one of its arguments [closed]

I have a function, nS[f_, xk_], which takes as arguments a function f and a vector xk. It ...
0
votes
0answers
66 views

Using Mathematica to solve a recursive system of differential equations

I believe I have a difficult problem to work on specially because I don't have any previously experience using Mathematica in this kind of situation. So I'll try to describe it as best as I can hoping ...
1
vote
1answer
61 views

Computing a recurrence table backward

I am trying to understand how to compute a recursive equation backward say n = 10 to n = 1. I am trying to solve a PDE for which ...
1
vote
1answer
326 views

Usage of Piecewise/RSolve to solve an equation based on condition

I am trying to compute price of call option on a stock using the finite difference method. I have a VBA code for it, and I am trying to find out how I can use Mathematica memoization functions and ...
0
votes
0answers
54 views

Recursive computation using Piecewise

I am trying to create an array using a series of equations using Piecewise. I am stuck in one of them. I am just putting a simplified version of code as below. I ...
0
votes
2answers
73 views

Find recurrence relation for a sum

Let's say I want to find a recursive equation for an exponentially weighted moving average EV[t_]:=(a-1)/(a^t-1)*Sum[a^(t-i)*x[i],{i,1,t}] I can do that manually ...
2
votes
0answers
50 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 ...
0
votes
2answers
67 views

Express recursion formula by Nest function

I'm fairly new to Mathematica and I have to express a formula by Mathematicas Nest-function. I'd like to find the solution for my formula by my own, thats why I ...
0
votes
0answers
29 views

Does the two function for the same input leads to same output?

The first function is y[n_]:=x[n]+0.5*x[n-1]+0.25*x[n-2] the other is y[n_]:=a*x[n+1]+b*x[n]+c*x[n-1] Does exist some ...
0
votes
1answer
73 views

Calculating a function repetitively without using a For loop

In my programme I have defined all these functions: ...
2
votes
1answer
114 views

Can Mathematica solve this type of recurrence?

I have the following recursively defined equation: ...
0
votes
2answers
63 views

Writing a function with variable arguments [duplicate]

I want to write a function which takes multiple arguments varying from 1 to n, where each argument is a triplet. sublistProduct[{$a_1,b_1,c_1$},{$a_2,b_2,c_2$},...] = { $\Pi_{i=1}^{i=n}a_i ...
2
votes
2answers
111 views

How to create a recursive TreeGraph

How could I create a recursive tree graph, such as one defined by the following: A family of trees $T_n$ are defined recursively as follows, for all integers $n \ge 1$. The tree $T_1$ consists of a ...
2
votes
1answer
82 views

How to solve for the closed form of this recurrence?

For integers $L,k \geq 0$: $$T(L,k) = \begin{cases} 0 & \text{if }k \geq d, \text{ever}\\ -a_{k} & \text{if }L=0 \text{ and } k<d\\ a_dT(L-1,k+1) - a_{k}T(L-1,0)& \text{if } L>0 ...
5
votes
1answer
191 views

Compile, “global variables” and recursion

I am trying to do something similar to this, namely to make a Compile'd function outer that itself calls a ...
1
vote
0answers
35 views

Index change in a recursive definition

Assume I have the following recursive definition: ...
2
votes
1answer
60 views

Evaluate recursive funtion as a whole before computing a recursive step

I'll try to make a basic example of my problem with $n$ being an array of elements, ex. $\{1,2,2,3,3,3\}$: If i have a sum which needs a computed value i would like to compute it beforehand and store ...
2
votes
2answers
71 views

Recursion problem

I try to make designation a = {Subscript[a,1], Subscript[a,2], Subscript[a,3]} but receive mistake $RecursionLimit::reclim: Recursion depth of 1024 ...
1
vote
1answer
89 views

Iteration convergence of Newton approximations

I am trying to determine for which initial values Newton's approximation of specific functions (EX: f(x)=x^2 -1)converge and to what numbers it will converge to. *Where Newton's approximations are ...
2
votes
1answer
68 views

Getting the first $n$ terms of a recursion relation

Given a recursion relation, I would like to generate the first $n$ terms (automatically) without having to go term by term. Background Each term is of the form $a_{n}(t)$, that is, $a_{n}$ is a ...
2
votes
1answer
50 views

How do I make Mathematica nest argument changes?

I want something like Nest[f,x,n], but what where f is an argument change like a pushforward and x[t] is a function, for example, symbolically, and not in any sort of code: $$ F{x[t]} \equiv x[2t + ...
2
votes
2answers
79 views

Finding large Collatz Sequences, trying to improve speed

Background: I am already very much in love with Mathematica but I am also a novice. So far I have only gathered experience in procedural programming in Python. Generally speaking I am trying to ...
2
votes
1answer
61 views

RSolve and a recurrence relation

In the book An Introduction to the Analysis of Algorithms there is a recurrence relation for the number of compares used in Quicksort algorithm: $$ C_N=N+1+\sum_{0≤k≤N-1}\frac{1}{N}(C_k+C_{N−k−1}) $$ ...
4
votes
1answer
115 views

How can I implement this recurrence equation in Mathematica?

I asked a similar question yesterday but today I realized that I was implementing the wrong function. I have tried changing the implementation but I can't get it to work. Problem: There is a river ...
0
votes
1answer
46 views

Recurrence doesn't work together with maximize

When I'm trying to use a recurrence relation involving maximize it simply fails to compute anything... ...
2
votes
2answers
176 views

How can I express this recurrence function in Mathematica?

\begin{equation} r_{i+1}=r_{i}+V_{i}{\Delta}t \end{equation} Where \begin{equation} V_{i}=(0.01, 0.40) \end{equation} and ${\Delta}t$ is the difference in time. My implementation (this is for ...
1
vote
1answer
41 views

RecurrenceTable [closed]

I got an error saying ...
0
votes
2answers
68 views

Help Solving A Recusive System: “$RecursionLimit::reclim: Recursion depth of 256 exceeded.”

Was wondering if anyone had any tricks/ideas on solving this system of recursive equations I have. Essentially my goal is to have J2 equal to zero, but to understand how tweaking several parameters ...
-2
votes
1answer
241 views

Recursion depth of 1024 exceeded [closed]

I'm not sure why this code is giving the error :( f[0] = 0; f[n_] := f[n] = DigitCount[n, 10, 1] + f[n - 1]; f[1016]
0
votes
1answer
43 views

Function to Represent Recursive Integral

I'd like to represent the following recursive integral equation to evaluate/graph (for $n\leq3$): $K_{i,n}\left(x\right)=\intop_{x}^{\infty}K_{i,n-1}\left(y\right)dy$ where ...
0
votes
2answers
54 views

Solving linear recursions without constant depth in mathematica

Mathematica does not like this recurrence relation. I do not understand why? ...
0
votes
1answer
85 views

How to improve this function that selects parameters from arbitrary distribution using Recursion?

Below, I have defined a function using Which to select model parameters based upon various conditions. My questions are: Is there any danger in writing this function using Recursion? Is there a more ...
1
vote
2answers
63 views

Solving Recurrence equation for n

I have a recurrence equation $t_n$ which is defined as $$ t_n=2.5t_{n-1}-1.5t_{n-4},\qquad \text{for }n\geq5 $$ Where $$ \begin{align} t_1&=5\\ t_2&=10.5\\ t_3&=26.25\\ t_4&=62.625 ...
0
votes
1answer
76 views

Problem with recursion depth

I want to solve a problem where I need to compute the Euler-Lagrange equation. However I receive a recursion problem, and I don't understand why. ...
0
votes
1answer
66 views

Solving recursion equation with two parameters

I am trying to solve the following recursion equation, a(l,m)=l*a(l,m-1)+a(l-1,m) with initial condition; a(l,m)==0 if l=0 , a(l,m)==1 if m=1 I am trying to solve it ...
0
votes
1answer
71 views

Recursive definition of nested sums

I have a set of functions which take lists as arguments. They recursively nest sums, and I have defined them as follows ...
1
vote
1answer
84 views

How to rewrite and possibly speed up a recursive sum?

I have the following for-loop calculating a multiple nested sum ...
4
votes
1answer
106 views

Display level of recursion of a recursive function during execution

Given a recursive function, is there some simple way to display or store the value of recursion or "how many levels deep" the function is at a given time? For instance, if we wrote the recursive ...
1
vote
1answer
58 views

Implementation of a recursive function [duplicate]

I have been trying to implement a recursive function, but still struggle. Here's what I have written: ...
0
votes
0answers
79 views

Simple recursive function?

I'm new in Mathematica and need some help. I'm trying to make a recursive function but I'm not sure how to iterate through more than one item. To be more clear, take this pseudo code for example: ...
1
vote
0answers
57 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
1answer
139 views

how to make a recursive function to analyse this file

I am stuck at this problem beginning We assume we have keyword k, and the structure in the file: file.txt ...
1
vote
1answer
97 views

Function to calculate finite difference

I wrote a function to calculate multivariate finite difference of different orders ...
0
votes
1answer
65 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
138 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 ...
0
votes
1answer
107 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 ...