Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have been using Mathematica for quite some time but I have never seen anything like this. It started without warning and I am not sure how to fix this. Please have a look at the following example

https://dl.dropboxusercontent.com/u/23383252/bugs_editor.nb

The notebook exemplifies my problem. Before you run it to check it, please read through it as I have explained every step of the problem. I am using a dropbox link to my notebook, since I have no idea how to attach a file (or if it is possible at all!) to this message.

In short, the problem is as follows: there is an issue with FindMaximum (could be other built in functions as well, but so far this is where it started) where, the editor changes the output from {maximum, {xx -> maximum position}} to {maximum(extra invisible characters), {(xx -> maximum position)(some more invisible characters)}}.

This has a huge impact on the rest of the variable types that are calculated with either element of the FindMaximum output (see the notebook for an example with ListPlot).

Has anyone seen this and how did they fix it.

P.S.: I tried to google this problem but I had no success since I don't really know what generates it.

Update:

As discussed below, I have modified the shared notebook to make it simpler. Got rid of all the unnecessary parameters and replicated the problem on my computer. Now, as rasher said, the issue could arise due to the excessive use of comments. This seems to be the case, because I copy and pasted the first cell where function nx is defined, into a new notebook and same thing happened. Again the problem was fixed if I wrote the function in a new cell.

I will try to add the code to this message together with the output for Va=2:

nx[Va_] := Block[
{WmaxL},
WmaxL = FindMaximum[{rr^2 - 10 rr + Va - 1/rr, rr > 0}, {rr, 1}];
WmaxL
] ;

This is the original function. Please note the extra spaces between the last ] and ; (this was a surprise for me too as is not evident in my notebook!). The output for this function is as not what you would expect from FindMaximum:

Out[15]= {-5.221174649 TextCell[""], {(rr -> 0.3271088) TextCell[""]}}

More surprises! This is what I get when I copy from the Mathematica notebook and paste it here! What is this TextCell in the output?

It is obvious for me why the rest of the notebook is not working as it should, but I have no idea why are these invisible characters inserted in my expressions. I hope this clarifies the issue a bit more, and allows you to check it on your machines too.

P.P.S.: the modified notebook can be found at the same link.

share|improve this question
2  
Can you perhaps post the offending code here to reproduce the problem? Did you try to copy the code to a new notebook and evaluate it there? Also, the bugs tag is only applicable for confirmed bugs. –  Yves Klett May 31 at 10:03
    
this was a new notebook that I created! plus, it doesn't happen all the time. It happens randomply. I would work on different cells, and at some point something like ListPlot will stop working without reason. And when I check back, it is due to FindMaximum and its changed output. How do I post and entire notebook here? I have provided a link to the notebook within my dropbox. It is just a mathematica notebook detailing the problem. –  lucian May 31 at 10:11
    
Your notebook throws errors: FindMaximum::nrgnum: The gradient is not a vector of real numbers at {rr} = {1.}. >> so I cannot reproduce your problem. Please make sure to provide functional code and test it in a fresh kernel session. Oh, and please add your system info (version, OS etc.). –  Yves Klett May 31 at 10:18
    
I just checked it and it works fine for me! There are no errors. The variables at the beginning are irrelevant, this was a taken from a larger project and I did it in a hurry. The problem is in the functions nx, nx2 and nx3. Those are most definitely working and for any positive values of Va will replicate the problem entirely. –  lucian May 31 at 10:24
2  
Throws errors for me, as Yves states. In any case, please copy just the germane code into your post. See the Help section and/or the golden question mark when editing for how to include code properly in a post. Also, bad idea to have rogue comments in code (that is, at end of lines instead of on separate line, or if you must have them on same line, not ending comment (and any preceding code) with ; - MM has been known to get weird/corrupt cells with such comment structures. –  rasher May 31 at 10:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.