Linked Questions

4
votes
3answers
409 views

Slow computation of recursive sequences

I want to investigate the asymptotic behavior of the following recursive system: ...
2
votes
1answer
88 views

a recursive function using memoization

I have looked at a lot of these cases, e.g. Can one identify the design patterns of Mathematica? and the included ones. My trimmed example, here establishing the 'initial conditions' (where the ...
3
votes
1answer
102 views

Access to the temporary solution in NDSolve with StepMonitor

I want to step-monitor at each time step of a spatio-temporal NDSolve (using the finite element method) the maximum bending of the function sampled over the curent mesh. For this I first need access ...
0
votes
0answers
34 views

Is there a difference between these two ways to define a function? [duplicate]

(I took this example from another question) f[0] = 0; f[n_] := f[n] = DigitCount[n, 10, 1] + f[n - 1]; f[1016] I notice that this example defines f(n) in a ...
7
votes
6answers
451 views

Remove element from list and store it in variable?

In many programming languages there are functions that remove an element from a set while giving back that element. E.g. I'd like to have a function FetchFromStack ...
-7
votes
4answers
194 views

how to make program read from top-to-bottom? [closed]

"As a general principle, make the program read from top to bottom rather than jumping around. Experts agree that top-to-bottom order contributes most to readability." I think it's difficult to do it ...
11
votes
1answer
144 views

Trace of -{1} expression

I'm trying to understand Trace. Usually it doesn't repeat but it adds {-1,-1} for his simple expression after having a correct ...
1
vote
1answer
402 views

Recursive Function Numerical Integration

I just tried to modify a code snippet for Neumann series to the Fredholm integral equation $ f(x)= \sqrt{x} - \int^1_0 dy\; f(y) \sqrt{x y} $ which I read in another post: How to solve an integral ...
12
votes
2answers
373 views

Time constrained optimization?

I'm trying to solve a maximization problem that apparently is too complicated (it's a convex function) and NMaximize just runs endlessly. I'd like to have an approximate result, though. How can I ...
2
votes
1answer
127 views

How to efficiently manage lists of arbitrary length?

I am running calculations that will generate a list of lists of integers. Throughout the calculations, the number of lists will increase, and already-existing lists will be added to. What is the ...
9
votes
4answers
315 views

How to avoid repetitive calculation when doing numerical integral?

Suppose I have a function f[x] which is very complicated, together with a function g[f[x]]+h[x] to integrate. That is: ...
6
votes
0answers
186 views

Improve recursive function (memoization)

These days I am trying to rewrite the following recursive function, in order to gain some speed. It is crucial because I end up using 4-5 similar functions, and I need to decrease execution time. ...
47
votes
2answers
2k views

Granular versus terse coding

While reading Leonid's grand answers to General strategies to write big code in Mathematica? I came across something that goes against my own practices. I do not disagree with the principle but the ...
130
votes
9answers
11k views

General strategies to write big code in Mathematica?

I think after six months of exposure to Mathematica and the Wolfram Language I am fairly OK with writing short codes and snippets. However, what are some general strategies to use in order to write ...
10
votes
2answers
285 views

How to implement JoinTo efficiently?

AppendTo is not efficient so I'm not quite sure of the best way to implement its analogue for joining (e.g. in python this would be extend function). So how can this be improved: ...

15 30 50 per page