For questions related to user defined caching mechanisms, memoization, in particular.

learn more… | top users | synonyms

0
votes
0answers
45 views

Reuse symbolic polynomial

Suppose I have a function that returns a polynomial in x, GetPoly[params_,x_]:=GetPoly[params,x]... but it is quite slow, so ...
4
votes
1answer
50 views

How can I access memoized values from parallel evaluation? [duplicate]

I want to evaluate a table of functions with ParallelTable. Here is the serial code: ...
3
votes
0answers
75 views

Change of basis of polynomials

Suppose I have a favourite basis for polynomials in $x_1,\dotsc,x_n$, say non-symmetric Macdonald polynomials to be specific. I can easily compute these, and thus the change-of-basis matrix that takes ...
0
votes
0answers
73 views

Memoization and upvalues

Can I store an algorithm to one variable and the result as an upvalue to another? With regard to the problematic code below (real algorithm and argument test omitted), I would like to store the ...
6
votes
2answers
652 views

How does one clear the memory of a recursive function

I want to implement the recursive function v[n_] := v[n] = v[n-1] + f[n-1] + Random[NormalDistribution[0,s]] to get ...
4
votes
2answers
82 views

Assigning function values in a memoized recursive module

I have a complicated recursive module which I have memoized. I realised that certain isomorphs of inputs to this function will give the same output. Therefore I decided to memoize all such input-...
3
votes
0answers
55 views

Memoized function with function parameter [duplicate]

I have some code that takes a function and uses the function to do some complicated computation. Thus, I wish to store this so I don't have to repeat this. Below, it is more simple than my real ...
1
vote
0answers
61 views

Prevent Mathematica using previous result [closed]

How can I prevent mathematica from using the previous computation in new one? How do I make the code below to compute same amount of time without memorizing previous computation. ...
7
votes
0answers
50 views

Time complexity to choose the right overload from the memoized function

If we want to save some outputs of the function, we often use the memoization pattern as follows, f[x_]:=f[x]=x f/@Range[10^5] If I call this function many times ...
10
votes
1answer
96 views

How to speed up the evaluation of a function with a large LeafCount but many repeated sub-functions for use in NIntegrate

General Context Apparently, the memory leak in NIntegrate is unavoidable pre-MMA-10.2. I have some (two-dimensional) numerical integration to do on a complicated ...
9
votes
1answer
634 views

Can I memoize retroactively?

I have a function defined something like this: f[x_] := Module[...]; I can easily write a memoized version of it like this: ...
8
votes
0answers
141 views

How to write crash-robust code?

When a notebook crashes all the work I was doing is lost - I'd like to ameliorate this situation! Is there a way to decorate a symbol so that it is saved to disk whenever it changes, or after a ...
41
votes
2answers
2k views

Memoization with pure functions?

Is this possible? If I have a simple function, say: f=If[#>0,1,2]& then for each value of # this will re-evaluate f right? Is it possible to define a ...
2
votes
1answer
114 views

Kernel crashed after $RecursionLimit = Infinity

$RecursionLimit = Infinity; T[n_, k_]:= T[n, k] = If[n == 0 || k == 1, 1, T[n, k-1] + If[n<k, 0, T[n-k, k]]]; Table[T[n!, n], {n, 1, 9}] Without ...
5
votes
2answers
125 views

Combining memoization and SlotSequence

I found myself writing memoizing code like this: ...
2
votes
0answers
461 views

SystemException[MemoryAllocationFailure] with Memoized function [closed]

Version 10.1 Win7x64 Enterprise. This is more of a report than a question but others may have seen the same / have insights. I have some code (that I can't really post as it's too big) with a large ...
6
votes
1answer
132 views

Saving memoization to disk

I like using memoization (i.e. the construct myFunction[x_]:=myFunction[x]=...) when I have a heavy function that I need to re-evaluate on the same arguments. ...
3
votes
0answers
53 views

Parallelization and memoization? [duplicate]

I have an expensive function on discrete values, f[n_] := f[n] = n^2 (* Expensive calculation *) Since f[n] is an expensive ...
9
votes
2answers
156 views

using memoization with conditional statement

I would like some advice about the use of memoization in conjunction with conditional statements. Let me try to explain my problem: I am constructing a function depending on a number of parameters. ...
7
votes
2answers
246 views

Correct way to use memoization for recurrence relation having an Integral

I am trying to construct a way to make a function for the following recurrence relation. $$ Q(N,L) = \int_{0}^{L-(N-1)a} Q(N-1, L-a-z) dz $$, with the initial condition $Q(2,L) = \frac{1}{2} (a-L)...
5
votes
0answers
130 views

Dropbox datastore

Dropbox seems to have a feature where it can be used as a database. This would be really cool to use for memoized functions, that can be restored on several computers and sessions. I have a function ...
4
votes
3answers
303 views

have a function redefine itself as it maps through a list

I have a list which contains sublists, e.g. list = {{a,b}, {a,b,c}, {a,b,a,a}, {b,c}, ...} I then map a function through each sublist. This function should ...
2
votes
3answers
129 views

Extract memoized results in the form of a rule

Lets say I define a function f with memoization. Is there some way to extract the memoized values? For example, ...
12
votes
1answer
779 views

Relative performance of the Julia language

I was just reviewing the Mathematica benchmark code linked from the Julia language home page http://julialang.org/. The stated goal of the benchmarks is to test the performance of specific algorithms, ...
4
votes
4answers
379 views

How to do memoization together with evaluation of a complicated function

UPDATE 2: much shorter version Given a list of paired indices {i, j}={{1,2}, {3,4}, …}, I need to first evaluate a rather complicated function test[i,j,x] (because ...
0
votes
1answer
79 views

Optimizing repeated function calls

Easiest way to keep my library nice, is to naively call some functions many times with same parameters. Doing so prevents from zoo of (library-)global variables and complicated initialisation ...
7
votes
1answer
166 views

Garbage collection for memoized functions on subkernels

I have a top-level function which operates on some data: findBestIntegers[data_]:=ParallelMap[optimize,data] which makes parallelized calls to an optimization ...
1
vote
2answers
75 views

Unintentional function memoisation via Dynamic

I needed to display edge labels of a graph in a way that allows the edge labels to be moved. ...
4
votes
2answers
213 views

Is it possible to `Protect` a dynamic programming process?

I wrote a function using dynamic programming to speed up the evaluation. For safety, I also want to protect this function. Take factorial for example: ...
0
votes
0answers
85 views

When to use memoization concept in Mathematica? [duplicate]

I have recently learnt memoization concept. But I am not sure in what scenarios i need to use this concept. if someone can help me out with different scenarios it would help me a lot to develop a ...
11
votes
2answers
825 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 ...
1
vote
1answer
154 views

Only perform a symbolic differentiation once

I want to define a function that involves a differentiation step that Mathematica can do easily, which might be of the form ...
16
votes
3answers
461 views

How to memoize a function with Options?

Consider the following modified fibonacci function: ...
2
votes
0answers
81 views

SetDelayed and avoiding function calls through memoization [duplicate]

I am fairly new to Mathematica. I am working my way through a number of books. I have been looking at the use of SetDelayed and want to confirm that my ...
25
votes
3answers
1k views

How to clear parts of a memoized function?

I have a function of two variables, e.g.: f[a_, b_] := f[a, b] = something f[a - 1, b - 1] etc With the above code I used the concept of memoization to speed up ...
9
votes
3answers
5k views

Get polynomial interpolation formula

I'm attempting to get a polynomial interpolation formula out of Mathematica but I am absolutely lost. I stared out using ...
2
votes
1answer
222 views

tricky memoization

Let's say I have the NDSolve example for documentation involving splitting 2nd order into set of 1st order ODEs: ...
3
votes
2answers
355 views

Problems with DumpSave and memoization

I defined a function that takes some time to compute using memoization: y[a_, b_, c_] := y[a, b, c] = First[$y /. NDSolve[.........] so that if I call y[a,b,c] ...
6
votes
0answers
473 views

Increasing recursion speed in Hull-White trinomial tree calculation

First timer here and have been finding these boards very useful in learning Mathematica. I'm trying to implement a numerical procedure for the Hull-White trinomial tree in Mathematica. Despite using ...
9
votes
3answers
948 views

Improve speed for calculating a recursive sequence

I want to calculate following recursive sequence: $\alpha_{0}=0,\\ \cos(\alpha_{i})=\cos(\alpha_{i-1})\cdot\cos(\beta_{i})+\sin(\alpha_{i-1})\cdot\sin(\beta_{i})\cdot\cos(\gamma_{i}).$ In ...
14
votes
3answers
512 views

Using Memoization with a Mutable Object

In looking for a solution to this question, I ran across some old binary tree code by Daniel Lichtblau, reproduced below: ...
67
votes
5answers
5k views

What does the construct f[x_] := f[x] = … mean?

This question mentions "x := x = trickery". What does defining a function as f[x_] := f[x] = ... do and what is it good for?
33
votes
3answers
897 views

Parallelize evaluation of function with memoization

I have a complicated function that I need multiple times, so I want to memoize it and have the first evaluation done in parallel. Unlike in my example below it's not a continuous function, so ...
12
votes
3answers
346 views

Memoization of Rounded inputs

Memoization is a technique for improving performance by having a function remember its previous arguments. For example, f[x_]:=f[x]=mySlowFunction[x] will be ...
45
votes
4answers
3k views

How can I implement dynamic programming for a function with more than one argument?

Dynamic programming is a technique for avoiding the repeated computation of the same values in a recursive program. Each value computed is immediately stored. If the value is needed again, it is not ...