Why Didn't I Get the Number in the End?

  • Thread starter Thread starter Petar Mali
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around issues related to numerical integration in Mathematica, particularly focusing on the challenges faced when integrating functions that diverge at the limits. Participants explore methods to handle these divergences and seek clarification on specific Mathematica commands and syntax.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant expresses confusion about not obtaining a numerical result at the end of their calculations.
  • Another participant suggests that the numerical integration diverges at the limits and proposes integrating within a small distance from the limits to see if it converges.
  • There is a discussion about the meaning of certain boundaries in Mathematica and how to interpret them when integrating from 0 to π.
  • Some participants explain that the integrand approaches infinity at the limits (0 and π), which complicates the integration process.
  • One participant attempts to clarify the recursive calculation process they are trying to implement and questions why they did not receive a result for a specific input.
  • Another participant confirms that the issue lies with the limits of integration rather than the specific values being used in the calculations.
  • There is a suggestion on how to write the integration command in Mathematica to avoid singularities.
  • One participant shares a table of results they obtained from their Mathematica file, indicating convergence towards a specific value.
  • A separate query arises regarding the creation of a piecewise function in Mathematica, which another participant attempts to assist with.

Areas of Agreement / Disagreement

Participants generally agree that the limits of integration are problematic due to singularities, but there is no consensus on the best approach to resolve the issues with the specific calculations or the piecewise function. Multiple viewpoints and methods are presented without a definitive resolution.

Contextual Notes

Participants discuss the dependence on specific values and the need for careful handling of limits in numerical integration. There are unresolved questions regarding the implementation of recursion in their calculations.

Who May Find This Useful

Individuals interested in numerical integration techniques, Mathematica programming, and handling singularities in mathematical computations may find this discussion relevant.

Petar Mali
Messages
283
Reaction score
0
I don't understand why I didn't get the number in the end? Thanks for your answer!
 

Attachments

Physics news on Phys.org
The problem is that the numerical integration diverges at the limits. Try integrating to within a small distance of the limits, and then take this small distance smaller and smaller and see if it converges. It seems to converge to a limit of 0.43137. See attached:
 

Attachments

Ok! I will see!

Just to ask you. This boundaries

[tex]\{x,\in ,\pi-\epsilon\},\{y,\in ,\pi-\epsilon\},\{z,\in ,\pi-\epsilon\}[/tex]

What that means? How Mathematica read that. Because I'm integrate from [tex]0[/tex] to [tex]\pi[/tex].

And what means

[tex]Table[\sigma[0.45,1.0,10^{-n}],\{n,1,7\}][/tex]

Thanks for your answer!
 
Last edited:
You tried integrating from 0 to pi, but the integrand goes to infinity at 0 and pi, so Mathematica can't come up with an answer. So instead of integrating from 0 to pi, we try integrating from just a little bit more than zero to just a litlle bit less than pi, then we make the "little bit" smaller and smaller. If we make the "little bit" small enough, it will get as close to the answer you want as we like. So we tell Mathematica to integrate from [tex]\epsilon[/tex] (a small number) to [tex]\pi-\epsilon[/tex]. The Table line then evaluates your function with [tex]\epsilon[/tex] having values of .1, .01, .001, .0001, .00001, .0000001, and .00000001. As you can see, it is getting very close to your answer. Does this make sense?
 
phyzguy said:
You tried integrating from 0 to pi, but the integrand goes to infinity at 0 and pi, so Mathematica can't come up with an answer. So instead of integrating from 0 to pi, we try integrating from just a little bit more than zero to just a litlle bit less than pi, then we make the "little bit" smaller and smaller. If we make the "little bit" small enough, it will get as close to the answer you want as we like. So we tell Mathematica to integrate from [tex]\epsilon[/tex] (a small number) to [tex]\pi-\epsilon[/tex]. The Table line then evaluates your function with [tex]\epsilon[/tex] having values of .1, .01, .001, .0001, .00001, .0000001, and .00000001. As you can see, it is getting very close to your answer. Does this make sense?

Yes I think this make sense. If I understand you, you think that this not converge for

[tex]\sigma[0.45,1][/tex]

I tried to calculate

[tex]\sigma[0.431,1][/tex]

but I also didn't get result? I need to get this result using recursion. If I understand this correctly I need to take for example

[tex]\sigma[blaaa,1][/tex]

and get for example [tex]blabc[/tex]

and then take

[tex]\sigma[blabc,1][/tex]

and get for example [tex]blaac[/tex]

and then take

[tex]\sigma[blaac,1][/tex]

and then say result is blaa. Right?

Why then I didn't get result for [tex]0.431[/tex]?
 

Attachments

You're still not getting it. It's not the 0.45 that is the problem. It is the limits of integration (the 0 and pi) that are the problem. When (x,y,z) = (0,0,0) or (pi,pi,pi), then the denominator of the integrand goes to zero, so the integrand goes to infinity. So you can't numerically integrate all the way to (0,0,0) or (pi,pi,pi) - you have to stop the numerical integration before you get all the way to (0,0,0) and (pi,pi,pi). Do you see?
 
I understand you now. Sometimes in Mathematica we have singularities but we get numbers. How to transform this what I wrote to get numbers and try to do some recursion.

I need to integrate

[tex]\int^{\pi-\epsilon}_{\epsilon}\int^{\pi-\epsilon}_{\epsilon}\int^{\pi-\epsilon}_{\epsilon}dxdydzf[/tex]

How to write that in Mathematica?
 
Now you're getting it. This is exactly what I wrote:
Code:
NIntegrate[f,{x,e,p-e},{y,e,p-e},{z,e,p-e}]
 
Of course :) I talked about recursion. But that result for me is just that table what you get in your Mathematica file.

{0.538265, 0.441277, 0.432402, 0.431477, 0.431379, 0.431369, 0.431368}

I can say now that the result converge to

0.43136

for T=1

Right?
 
  • #10
Right.
 
  • #11
I am trying to plot a function of two variables but it will be piecewise:
f[x_, y_] := {x^2/(x^2 + y^2),-1<=x<=1,-1<=y<=1} and {0, otherwise}
How can I write these commands? It doesn't work...
Please help...
 
  • #12
The attached notebook will do it.
 

Attachments

Similar threads

  • · Replies 30 ·
2
Replies
30
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
796
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K