Mathematica problem

  • Mathematica
  • Thread starter natski
  • Start date
  • #1
267
2
Hi all,

I have attached a notebook which I am doing a calculation in. For some reason, Mathematica is acting inconsistently. When I run the calculation for the first time, it usually doesn't work. By that I mean I get the output that you can see in the notebook attached.

You can that the problem is coming from the subscript 3 in the term H3. I can't understand why it doesn't just read the value of H3 I input early on!?

I could just ditch the subscript but I really don't want to because I want to eventually change the subscript 3 for a general integer i and rerun the program for many different i values.

I should also add that sometimes the program runs with no problems despite having changed nothing. Once it runs once OK, then everytime thereafter is OK.

Please can someone explain what on Earth is going on!
 
Last edited:

Answers and Replies

  • #2
267
2
Um sorry but I solved this problem!
 
  • #3
1,250
2
Avoid the use of subscripts, unless you know how to unprotect the head subscript and change it to type symbol.
 
  • #4
267
2
Thanks for the tip. As a further question, I am trying to use a Goto loop and finding a slight difficulty.

I put a label at the beginning of my notebook and then the Goto at the end and it doesn't work because Goto can't find the Label. Even for simple expressions this happens unless all the equations are on the same line. Is there not a way to use Goto and Label when there are many, many (and so a single line calculation is inconvenient) expressions inbetween them?

Thanks
 
  • #5
1,250
2
No there is no way to make Goto do what you want.

But if you want to Goto a cell, then it is probably because that cell contains a subprocedure. So why not rename the subprocedure, evaluate the cell which defines it, and replace the Goto with function calls?

In the 1970s it was decided that the use of Goto should be deprecated in all languages, because it leads to poorly readable code. Imagine looking all over the place for someone elses Goto Label. Mathematica compromises by allowing the Goto, but restricting it to be local in the sense you describe.
 
  • #6
267
2
Hmmm I don't really understand what you mean, the terms cell, subprocedure and function calls are not really clear to me. Can you please show me an example?
 
  • #7
1,250
2
You said that, when working, all your Goto code was on the same line. The imprortant thing is that all your code was in the same active active cell. See the example.

I tried to guess what issues were having, but if you want to talk specifics you should show me your code.
 

Attachments

Related Threads on Mathematica problem

  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
2
Views
4K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
0
Views
2K
  • Last Post
Replies
4
Views
3K
Replies
2
Views
3K
Replies
8
Views
7K
  • Last Post
Replies
1
Views
3K
Top