Another bug? Weird integration results.

IIn summary, the speaker discusses an issue with uploading a notebook and suggests it would be a nice feature for moderators. They provide some code and explain that there seems to be a problem with integrating separately and then combining. They ask if anyone can confirm this issue and share their own results. They then provide different results with and without simplifying the function first.
  • #1
Hepth
Gold Member
464
40
I can't upload the notebook I guess, that would be a nice feature mods! (.nb extension)

But here is my code , there seems to be a problem with integrating separately and then combining.

Code:
$Assumptions = 0 < r < 1 && 0 < z < 1;
FUNCTION = Expand[-(Pi*(-1 + r)*(-12*z + r^2*z + r*(-12 + 11*z)))/(12*(r*(-1 + z) - z))];
temp1 = Table[Integrate[FUNCTION[[i]], z, Assumptions -> $Assumptions], {i, 1, Length[FUNCTION]}] // Total // Expand
temp2 = Integrate[FUNCTION, z, Assumptions -> $Assumptions] // Expand
temp1 /. {r -> 1/16., z -> 0.1}
temp2 /. {r -> 1/16., z -> 0.1}

So the problem is that if I choose each piece of the function, integrate them individually, its not the same result as if i do the whole integration.

This is on MM9 right now. Can anyone confirm this? My results are

0.297957 -0.620063 I
0.495329 -0.00321276 I
 
Physics news on Phys.org
  • #2
Wow it really is just something with not fullsimplifying the function first :

Code:
FUNCTION = (-12*z + r^2*z + r*(-12 + 11*z))/(12*(r*(-1 + z) - z));
Integrate[   Simplify[FUNCTION,   0 < r < 1 && 0 < z < 1], z] /. {r -> 1/16, z -> 1/10} // N
Integrate[   FullSimplify[FUNCTION,   0 < r < 1 && 0 < z < 1], z] /. {r -> 1/16, z -> 1/10} // N

0.168179 -0.00109083 I

0.101165
 

Related to Another bug? Weird integration results.

1. What could be causing the bug in the integration results?

There are a few potential reasons for a bug in integration results, such as incorrect code implementation, compatibility issues, or data input errors. It is important to carefully review the code and data to identify the specific cause of the bug.

2. How can I troubleshoot the bug in the integration results?

To troubleshoot the bug, you can try debugging the code, checking for any errors or warnings, and reviewing the data inputs. You can also consult with colleagues or refer to documentation for assistance.

3. Are there any common mistakes that could lead to incorrect integration results?

Some common mistakes that could contribute to incorrect integration results include using incorrect formulas or equations, using the wrong data types, or forgetting to account for certain variables or conditions.

4. Can using a different integration method help resolve the bug?

In some cases, using a different integration method, such as a more accurate or efficient algorithm, may help resolve the bug. It is worth exploring different options to see if they produce more accurate results.

5. How can I prevent similar bugs from occurring in the future?

To prevent similar bugs from occurring in the future, it is important to thoroughly test and validate the code before implementing it, use consistent and standardized data input procedures, and regularly review and update the code as needed.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
243
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Topology and Analysis
Replies
2
Views
659
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Replies
2
Views
515
  • Advanced Physics Homework Help
Replies
19
Views
882
Replies
1
Views
632
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
949
Back
Top