# speed up a code in mathematica.

Posted 9 years ago
5873 Views
|
5 Replies
|
0 Total Likes
|
 Professionals Hi, I wrote a program as follows. It takes a long time to answer. After two hours of running still does not answer. in the main program mm = nn = 30 that It takes so much more. Please help me. many thanks. Attachments:
5 Replies
Sort By:
Posted 9 years ago
 yes my final result is numerical.NIntegrate is very fast but its answer is zero! it is not correct. where can i use NIntegrate?
Posted 9 years ago
 You should take a look at your various expressions along the way for a simplified version of your code: e.g. for nn = 2; mm = 2; or even nn = 1; mm = 1; Here is the value of your diagonal parameter in this latter case: 1/((-2 I + e) (1 + E^( 1.5625\[CenterDot]10^22 (-(1/100000000000000000000) + e))) (2 I + Conjugate[e])) Ok, one sees that your integration variable was assumed complex along in your computation. Also see the huge numbers involved as well. let's "fix" that and see what we get: diagonal /. Conjugate[e] -> e gives $\frac{1}{(e-2 i) (e+2 i) \left(e^{1.5625\times 10^{22} \left(e-\frac{1}{100000000000000000000}\right)}+1\right)}$and Integrate[diagonal /. Conjugate[e] -> e, {e, 0, Infinity}] returns unevaluated, not surprisingly given that something like Integrate[x^x, x] `returns unevaluated. So, the upshot of this is to perhaps take a line by line look at your algorithm to see what is happening at each stage and then see if there are things that can be done to make sure that it is doing what you are wanting. If your final result is expected to be a numerical result then once your code is revised you will probably want to explore NIntegrate
Posted 9 years ago
 @Marvin Burns i think main problem is in integrate part of code. how can i speed up integration in mathematica.
Posted 9 years ago
 A suggestion: that you work your way away from coding in a traditional procedural approach and recast your problems in more Mathematica-like functional, pattern-matching, Symbolic, and other paradigms. You will achieve much greater clarity and brevity, and you will learn the "way of Mathematica".
Posted 9 years ago
 The final "diagonal" variable looks looks like it would cause an underflow if evaluated. (It has 1 + E^(1.5625*10^22 (-...)) in the denominator.)
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments