Linked Questions
30 questions linked to/from How can I implement dynamic programming for a function with more than one argument?
4
votes
4
answers
739
views
Memoization of a function defined by a recurrence relation [duplicate]
I have a function which is defined by the following recurrence relation
$$h_{n}(x)=h_{n-1}(x)+\frac{\mathrm{e}^{-x^2}}{2^n n!}H_{n}(x)H_{n-1}(x)$$
with the initial condition $h_{0}(x)=0$ and where the ...
0
votes
0
answers
55
views
Keeping memory to reduce the running time of recursion [duplicate]
I am using the following recursion in Mathematica to compute W[n, 1, s] for given n and s:
...
0
votes
0
answers
21
views
How to memoize with patterns? [duplicate]
Here is an artificial example to explain what I am up to. Define
ClearAll[f]
f[x_, y_] := f[x, y] = If[x == 0, g[y], g[f[x - 1, y]]]
Then ...
181
votes
5
answers
18k
views
Performance tuning in Mathematica?
What performance tuning tricks do you use to make a Mathematica application faster? MATLAB has an amazing profiler, but from what I can tell, Mathematica has no similar functionality.
139
votes
8
answers
8k
views
Can one identify the design patterns of Mathematica?
... or are they unnecessary in such a high-level language?
I've been thinking about programming style, coding standards and the like quite a bit lately, the result of my current work on a mixed .Net/...
22
votes
3
answers
5k
views
Why does Mathematica use [[ ]] notation for array indexing?
I am confused by why Mathematica uses [[3]] to get the 3rd element, or [[i,j] to get the i,j-th element of a 2D array.
This ...
9
votes
4
answers
5k
views
Implementing Picard's Iteration for solving ODEs
Picard's Iteration is a way of solving the IVP
$$y'(x)=f(x,y(x)), \quad y(x_0)=y_0 $$
It consists of defining the following sequence of functions recursively:
$$y_0(x):=y_0 \\
y_{n}(x):=y_0+\int_{...
6
votes
3
answers
2k
views
recursive integration
I am trying to do multiple integrations recursively. For instance, I would like to do the following equation for arbitrary integer $n$:
$\displaystyle R_n(t) = \int_0^t \mathrm dt' R_0(t-t') R_{n-1}(...
8
votes
2
answers
2k
views
Why does Expand not work within a function?
I'm writing this fairly simple function:
...
7
votes
2
answers
4k
views
Series of piecewise functions
Let $f_{0}(x):[0,1]\to[0,1]$ be defined by
$$f_{0}(x):=\begin{cases} 3x, & \text{if } x\in [0,\frac{1}{3}] \\
\\
-3x+2, & \text{if } x\in (\frac{1}{3}, \frac{2}{3}] \\
\\
3x+2, & \...
13
votes
2
answers
1k
views
Dynamic Programming with delayed evaluation
By using dynamical programming, we can save intermediate steps for recursive relations, as in
f[n_]:= f[n] = f[n-1] + f[n-2]
However, this only stores ...
7
votes
4
answers
521
views
Recursive piecewise integral relation with piecewise base case?
How is this recursive formula
$$ f_{n+1}(z) = \int_0^1 f_{n}(z-y)\,{\rm d}y $$
implemented in Mathematica? The base case is
$$ f_1(z) = \begin{cases}
1 & 0\leq z\leq 1 \\
0 & \text{...
7
votes
2
answers
485
views
How to implement a numerically efficient Airy Zeta Function
Define the Airy zeta function for $n=2,3,\dots$, by
$$
Z(n) := \sum_r \frac{1}{r^n}.
$$
where the sum is over the zeros $r$ of the Airy function $\operatorname{Ai}$.
In Mathematica the $\operatorname{...
4
votes
3
answers
509
views
How to generate a recurrent sequence
How to generate this type of sequence?
$$ f(n, x) = x f'(n-1, x) \hspace{2 mm}, f(0, x) = e^x$$
How do I evaluate it for numerical values for $x = 1$ or any number?
9
votes
1
answer
1k
views
Compiling a recursive formula
My question is related to computing what is called "invariant measure" for a particular well known fractal - the Sierpinski triangle.
We have an array m of four two by two matrices, say
...