when I simply run a sequence of inputs everything is fine, bit as soon as I put exactly the same inputs into a function of two variables and call this function with the same parameters used before the UI crashes. This doesn't happen for all functions, but for this one it does. Any ideas?

Any help would be very much appreciated.

PS: Don't ask why I define a constant to be a function of S, this will be used as a function of S later.

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

5

You're using N as a variable in the function definition. It is highly recommended that you don't start your symbol names with a capital letter to avoid these conflicts, and care must be taken if you choose to ignore the recommendation. It is especially important when you are only using a single letter.
–
rcollyerJan 16 '13 at 15:55

2

Consider f[x_, N_] := N[x, N]. With this definition, f[Pi, 20] evaluates to 20[π, 20]. Not what you would want, is it? Your code does something like that.
–
m_goldbergJan 16 '13 at 16:47

@Nasser In fact in this example Nis coloured green in the function, which can be a warning sign.
–
SzabolcsJan 16 '13 at 18:29

1 Answer
1

To expand on the comment by @rcollyer, that is exactly the source of trouble here. You have effectively disabled the numeric evaluation. The table of symbolic results gets huge quickly. As an experiment (to be done with caution) remove the N[] wrappers from the Erf evaluations. Then do

res = makeFirstCrossing[1, 25];

(And make good and well sure you use that semicolon.)

The result has a LeafCount of 586830445. I've no doubt that you are simply running out of memory.

If you change the pattern variable from N_ to n_ and likewise change the two usages at the beginning of the function then it will behave itself.

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.