Search results

  1. H

    MATLAB Can one repeat a matlab script from the beginning?

    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...
  2. H

    Mathematica Mathematica: f[a,b,c] = a*g[b,c], force evaluate

    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.
  3. H

    Mathematica Mathematica: f[a,b,c] = a*g[b,c], force evaluate

    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.
  4. H

    Mathematica Mathematica : Easy? Function that returns and increases counter.

    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.
  5. H

    Mathematica Mathematica : Easy? Function that returns and increases counter.

    Would something like Product[v[a[j]].d[a[j]], {j, 1, 3}] work for you?
  6. H

    MATLAB Vector concatenation without using a for loop (MATLAB)

    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'.
  7. H

    Mathematica Mathematica: Solve error

    The Plot3D command should be useful.
  8. H

    Mathematica Mathematica: Solve error

    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).
  9. H

    LaTeX Latex mathbb with number does not show correctly

    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...
  10. H

    LaTeX Brace in latex question

    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...
  11. H

    LaTeX Brace in latex question

    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...
  12. H

    Simplifying many body operator expressions

    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...
  13. H

    Mathematica Solving trig equation Mathematica repeats results

    Mathematica considers it a double root. Compare with Solve[x^2 == 0, x].
  14. H

    LaTeX Please help Alignment of very very long equations in latex

    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\\ &+...
  15. H

    LaTeX Wasysym Electrical Symbols in Latex

    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
  16. H

    Mathematica [Mathematica] Simple Problem with the plot function

    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...
  17. H

    Mathematica [Mathematica] Simple Problem with the plot function

    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}]