The m files work as functions, so all you need to do is to call that function. I.e., if you called the file game.m, just replace the fprintf('I do not know how to restart, sorry!\n\n') by game
EDIT: That will restart the script right from the beginning. If you want it to restart somewhere else...
Glad you solved it.
I find optimizing Mathematica code tricky, as there generally is several ways of doing the same thing, and it's often not obvious why one should be quicker than the other. Anyway, there's this guide 10 tips for writing fast Mathematica code. You might find it helpful too.
You want to tell Mathematica that your functions are to be treated as functions,
g[b_, c_] := b/c
f[a_, b_, c_] := a*g[b, c]
Note the underscores after the function variables.
Also see the tutorial.
Aha. Yeah, I wondered if the product solution was too simple to suggest but then I remembered that I once spent an hour perfecting a recursive algorithm in java to format a text string before someone reminded me that I could just have used a string replace function.
Nice solution, by the way.
If they are stored in a matrix (as then tend to be when read from a file with e.g. dlmread), you can reshape the matrix into a vector with the cleverly named command 'reshape'.
Since you have an undetermined parameter, Mathematica tries to find an analytic solution, which I don't think will work in this case. If you know the value of r, then a numerical solution is possible (assuming x is a real number).
Yeah, the mathbb command as defined in the amsfonts package (probably amssymb as well) only works with uppercase letters. It's using the wrong font, basically.
You could solve this by using the bbm package and then using the mathbbm command (it is defined for both upper and lower case...
I meant that if you want to post LaTeX code giving you trouble and display the actual code instead of its result, you can write it like
code you don't want the forum to process goes here[\code]
but with the backslash replaced by a slash.
Sorry about that. Yeah, LaTeX distinguishes between...
The array environment should do the trick.
\left. \begin{array}{c} A\\ B\end{array}\right\}
$\left. \begin{array}{c} A\\
B\end{array}\right\}$
or something like that. The "\left." means that there is an invisible thing to the left of whatever you try to enclose with the brackets.
The...
Hello all,
Is there any really good software, package or otherwise, that is helpful for simplifying long operator expressions, particularly with (anti-commuting) electron operators? For example, I'd like to be able to transform Hamiltonians, project onto subspaces with specific occupation...
I prefer using "align" for most things. While I'm not as fanatical as some, align is just more consistent and generally looks nicer. (Although I'm not entirely happy about the lack of space after the + in the second row on the board.)
\begin{align}
x &= x'' + blah blah \nonumber\\
&+...
The forum doesn't have all symbols. This is supposedly the list of supported commands (see here for reference), but I've noted that \tilde doesn't work, \tilde
You are welcome. And, yeah, if the function has a non-zero imaginary part for at least one value of x, then clearly it's not real-valued on the whole domain (i.e. the plot range). However, Mathematica is able to handle cases where the function is piecewise real-valued, it just doesn't plot the...
The problem is that plot tries to make a continuous plot. It then runs into the problem that phih^x is not a real-valued function for non-integer x, and refuses to plot it altogether. To just plot the values at integer values of x, you can use DiscretePlot:
DiscretePlot[{f, y}, {n, -20, 20, 1}]