# Tagged Questions

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

37 views

### Computing with recursion; how can I use values with lower indices without recomputing them? [closed]

I have to implement the following expression. V(tk+1)=max{(m×Ctk)/S_tk ,0} S(tk+1)+(Vtk-max{(m×Ctk)/Stk ,0} S(tk+1))×B(tk+1)/Btk How can I implement it so that ...
121 views

### Which data tabulation concept is best suited for discrete dynamic programming problems (e.g. for optimum series of account withdrawals)?

A bank account has starting balance, which shall be completely withdrawn in n steps, such that the sum of benefits of withdrawals is maximum. Remaining balance yield interest between steps such that ...
47 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 ...
58 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: ...
77 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 ...
74 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 ...
656 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 ...
88 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-...
56 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 ...
64 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. ...
54 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 ...
99 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 ...
639 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: ...
142 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 ...
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 ...
114 views

125 views

### Combining memoization and SlotSequence

I found myself writing memoizing code like this: ...
491 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 ...
133 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. ...
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 ...
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. ...
246 views

474 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 ...
960 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 ...
518 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: ...
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?
910 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 ...