# Mathematica to help for an Hamiltonian problem

I have an Hamiltonian problem whose 2D phase space exhibit islands of stability (elliptic fixed points).

I can calculate the area of these islands in some cases, but for other cases I would like to use Mathematica (or anything else) to compute it numerically.

The phase space looks like that :

This is a contour plot make with Mathematica. Could anyone with some knowledge of Mathematica provide a way to achieve this ?

-
Calculate the area or plot the graph? – KennyTM Nov 3 '10 at 6:35
I did the plot, from the plot, or from the function I want to calculate the area. – Cedric H. Nov 3 '10 at 7:01

2
This actually seems like a computing question that happens to arise in a physical application, not really a physics question. Or is it just me? – David Zaslavsky♦ Nov 3 '10 at 7:41
Asking here, maybe I'll find someone using Mathematica for physics, I don't think asking in SO is a better idea. – Cedric H. Nov 3 '10 at 8:02

6
I think this one is grey area, leaning towards computing rather than physics. But not voting to close because you attached a nice graph. Always like a good graph. – Alasdair Allan Nov 3 '10 at 10:29
show 3 more comments

## 1 Answer

There is rather nice function in Mathematica 7, which allows one to integrate over an arbitrary complicated region. It is Boole:[True,False]$\to${1,0}. Below is just an example taken from Mathematica Documentation Center. If you have a 2D area defined by the inequality $4 x^4-4 x^2+y^2\leq 0$,

you can integrate any function $f(x,y)$ over this domain as follows:

````Integrate[f[x,y] Boole[y^2 - 4 x^2 + 4 x^4 <= 0], {x, -Infinity,Infinity}, 
{y, -Infinity,Infinity}]
````

For example, if $f(x,y)$ is unity then it gives you the total volume of the integration domain:

````In[1]:= Integrate[Boole[y^2 - 4 x^2 + 4 x^4 <= 0], {x, -Infinity,Infinity}, 
{y, -Infinity,Infinity}]
Out[1]= 8/3
````

In fact, you can use any condition you want, including that is determining your islands of stability. Numerical integration is also possible:

````In[1]:= NIntegrate[Boole[y^2 - 4 x^2 + 4 x^4 <= 0], {x, -Infinity,Infinity}, 
{y, -Infinity,Infinity}]
Out[1]= 2.66667
````
-

By the way, Mathematica is a grate tool widely used by physicists in various areas. I think it is worth to collect questions about it here (by using the new tag "Wolfram Mathematica", not just "Mathematica"). – Grisha Kirilin Nov 12 '10 at 2:20
Thanks, it is not exactly what I was looking for but it might do the trick. About the tags: these two can be made synonyms. – Cedric H. Nov 12 '10 at 11:37
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 4, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9072312712669373, "perplexity_flag": "middle"}