Mathematica Help me to solve Do-loop for large matrices (Mathematica)

AI Thread Summary
The discussion centers on the inefficiency of a Do-loop in Mathematica, which takes over 24 hours to execute, while manual input yields quick results. Users report encountering errors related to SetDelayed and Part when running the Do-loop version, suggesting potential issues in the code. Despite testing individual segments successfully, the Do-loop remains problematic and slow. Suggestions for improvement include tracking changes between the manual and Do-loop versions to identify errors and optimizing the code for better performance. The user seeks advice on modifications to enhance execution speed and resolve the issues encountered.
kaizen.moto
Messages
94
Reaction score
0
Hi all,

I have difficulties about applying the Do-loop command as it takes very long time to run (more than 24 hours and it keeps running).

However, if i do it manually, without Do command, i.e. putting the values of the variables, Mathematica gives me a pretty quick output.

Please see the attached files.

I really appreciate for any comments.


Thanks
 

Attachments

Physics news on Phys.org
When I evaluate the "Do loop" version I see errors

SetDelayed::write: Tag Times in Pi/a[m_] is Protected.
SetDelayed::write: Tag Times in Pi/a[n_] is Protected.
followed by a variety of other SetDelayed and Part errors.

That very likely indicates something is wrong and needs to be tracked down.

But given two notebooks over a hundred kilobytes each with a variety of changes in format and organization makes it very difficult to try to track down what is wrong.

It is unfortunate, but I don't believe there is a "diff" utility that understands Mathematica notebooks and can overlook meaningless differences while pointing out significant differences. I can manually find some of the things you have changed to turn one into the other but I have not been able to track down exactly what was broken in changing from the "manual" to the "do" version.

If this were mine I would track down and figure out and fix what was causing those errors. I would begin at the top of the two files and track down what changes you have made are important, what are not, and where errors have been introduced.
 
Did you test this code in short segments to see if it even works?
Break it down section by section?
 
I have run and checked all the codes, segment by segment by breaking them into an indvidual cell, they are all working fine and give me the outputs without any errors or warning.

I don't have such errors displayed when I run the codes using version 7 (both windows and linux machines).

My problem is only that the Do-loop version takes such a very long time to run and still I don't have any output. I need some suggestions if there is any way to improve my codes or any modifications in the syntax/command that need to be replaced.

I welcome any comments and really appreciate it.

Thank you.
 

Similar threads

Replies
6
Views
4K
Replies
1
Views
4K
Replies
6
Views
10K
Replies
6
Views
8K
Replies
1
Views
2K
Back
Top