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

learn more… | top users | synonyms

2
votes
1answer
46 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
60 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
75 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
52 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
39 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
52 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
50 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
96 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
45 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
159 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
34 views

RecurrenceTable [closed]

I got an error saying ...
0
votes
2answers
61 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
76 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
33 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
50 views

Solving linear recursions without constant depth in mathematica

Mathematica does not like this recurrence relation. I do not understand why? ...
0
votes
1answer
79 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
57 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
70 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
52 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
60 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
70 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
101 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
57 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
76 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
56 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
134 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
88 views

Function to calculate finite difference

I wrote a function to calculate multivariate finite difference of different orders ...
0
votes
1answer
55 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
131 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
93 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 ...
0
votes
0answers
96 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
44 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
92 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] ...
3
votes
1answer
86 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: ...
5
votes
2answers
581 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
110 views

Nested Recursion Equation

I have been trying to solve a "nested recursion equation" using Mathematica. However, when I do something like this: ...
3
votes
3answers
186 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 ...
5
votes
0answers
119 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) &=& ...
1
vote
1answer
158 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 ...
5
votes
2answers
216 views

Plotting two recursive functions

I'm trying to plot two recursive functions (p and θ) on a map. So far I have: ...
14
votes
6answers
591 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 ...
0
votes
2answers
145 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
48 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: ...
22
votes
3answers
1k 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 ...
8
votes
2answers
299 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): ...
10
votes
5answers
665 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 ...
3
votes
2answers
216 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
157 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
105 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
192 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 ...