(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 4.0, MathReader 4.0, or any compatible application. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 21523, 778]*) (*NotebookOutlinePosition[ 22202, 802]*) (* CellTagsIndexPosition[ 22158, 798]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Integrazione numerica \"classica\" e metodo Monte Carlo", "Subtitle", FontVariations->{"Underline"->True}], Cell[CellGroupData[{ Cell[TextData[{ "Esempio (banale): ", Cell[BoxData[ FormBox[ StyleBox[\(\[Integral]\_0\%1\( cos(x)\) dx\), FontSize->18], TraditionalForm]]], " = ?" }], "Section"], Cell["\<\ Si cercheranno approssimazioni numeriche basate sui valori assunti dalla \ funzione integranda in punti equispaziati del dominio d'integrazione.\ \>", "Text"], Cell["\<\ Dati del problema e scelta del passo di calcolo (qui corrispondente a 100 \ divisioni dell'intervallo [0, 1] ):\ \>", "Text"], Cell[BoxData[{ \(\(f[x_] := Cos[x];\)\), "\[IndentingNewLine]", \(\(a = 0;\)\), "\[IndentingNewLine]", \(\(b = 1;\)\), "\[IndentingNewLine]", \(\(T = 100;\)\), "\[IndentingNewLine]", \(\(h = \(b - a\)\/T;\)\), "\[IndentingNewLine]", \(X[n_] := a + h*n\)}], "Input"], Cell["\<\ Il valor vero dell'integrale (per il confronto) \[EGrave], naturalmente, sin \ (1):\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\[Integral]\_a\%b f[x] \[DifferentialD]x\)], "Input"], Cell[BoxData[ \(Sin[1]\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Int = N[%]\)], "Input"], Cell[BoxData[ \(0.8414709848078965`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["Metodo \"dei rettangoli centrati\"", "Subsection"], Cell["\<\ Si sommano le aree dei rettangoli che hanno per base le frazioni scelte \ dell'intervallo e per altezza i valori della f(x) a met\[AGrave] delle \ stesse:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Int\_R = N[h \(\[Sum]\+\(n = 1\)\%T f[X[n - 1\/2]]\)]\)], "Input"], Cell[BoxData[ \(0.8414744909472264`\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\[CapitalDelta]\_R = Abs[1 - Int/Int\_R]\)], "Input"], Cell[BoxData[ \(4.166661458637755`*^-6\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Metodo \"dei trapezi\" o \"dei rettangoli traslati\"", "Subsection"], Cell["\<\ Si sommano le aree dei trapezi che hanno per altezza le frazioni scelte \ dell'intervallo e per basi i segmenti orientati di misura f(X(n)) , il che \ equivale, per costruzione geometrica, a considerare gli n-1 rettangoli di \ base h interni al dominio, con altezze pari alle basi sopradette, pi\[UGrave] \ i due rettangoli estremi, di base dimezzata ed altezze misurate da f(a) ed \ f(b) :\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Int\_T = N[\(h\/2\) \((f[a] + f[b] + 2 \(\[Sum]\+\(n = 1\)\%\(T - 1\)f[X[n]]\))\)]\)], "Input"], Cell[BoxData[ \(0.8414639725380028`\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\[CapitalDelta]\_T = Abs[1 - Int/Int\_T]\)], "Input"], Cell[BoxData[ \(8.333416667394289`*^-6\)], "Output"] }, Open ]], Cell["\<\ (questa approssimazione risulta pi\[UGrave] efficace della precedente solo \ quando la funzione integranda esibisce dei cambi di concavit\[AGrave] nel \ dominio d'integrazione - altrimenti il lato obliquo dei trapezi risulta \ sempre al di sotto o al di sopra della curva f(x) , sicch\[EAcute] ad ogni \ passo i singoli errori si sommano).\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Metodo \"di Simpson\"", "Subsection"], Cell["\<\ Consta di una somma con pesi differenti per gli intervalli di ordine pari o \ dispari:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Int\_S = N[\(h\/\(\(3\)\(\ \)\)\) \((f[a] - f[b] + 2 \(\[Sum]\+\(n = 1\)\%\(T/2\)\((2 f[X[2 n - 1]] + f[X[2 n]])\)\))\)]\)], "Input"], Cell[BoxData[ \(0.8414709848546454`\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Abs[1 - Int/Int\_S]\)], "Input"], Cell[BoxData[ \(5.555622628605761`*^-11\)], "Output"] }, Open ]], Cell["\<\ Questo metodo (che richiede che si divida il dominio d'integrazione in un \ numero pari di intervalli) equivale ad approssimare la curva integranda con \ archi di parabola, infatti:\ \>", "Text"], Cell[CellGroupData[{ Cell[TextData[{ "Integrale dell'arco di parabola ", Cell[BoxData[ \(TraditionalForm\`y\ \((x)\)\ = P\_2\ \ x\^2\ + \ P\_1\ x\ + \ P\_0\)]], " passante per tre punti consecutivi del campione" }], "Subsubsection"], Cell[BoxData[ \(f[x_] =. ; a =. ; b =. ; T =. ; h =. ;\)], "Input"], Cell["\<\ Determinazione del sistema relativo alla parabola passante per tre punti \ dati:\ \>", "Text"], Cell[BoxData[ \(\(W[n_] = Simplify[ Solve[{A\ X[n]\^2 + B\ X[n] + K \[Equal] f[X[n]], A\ X[n + 1]\^2 + B\ X[n + 1] + K \[Equal] f[X[n + 1]], A\ X[n + 2]\^2 + B\ X[n + 2] + K \[Equal] f[X[n + 2]]}, {A, B, K}]];\)\)], "Input"], Cell["Assegnazione delle espressioni funzionali dei coefficienti:", "Text"], Cell[BoxData[{ \(\(P\_2[n_] = \(W[n]\)[\([1, 1, 2]\)];\)\), "\[IndentingNewLine]", \(\(P\_1[n_] = \(W[n]\)[\([1, 2, 2]\)];\)\), "\[IndentingNewLine]", \(\(P\_0[n_] = \(W[n]\)[\([1, 3, 2]\)];\)\)}], "Input"], Cell["\<\ Calcolo dell'area relativa al generico intervallo (a+2n*h , a+(2n+2)*h) :\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Simplify[\(P\_2[2 n]\/3\) \((X[2 \((n + 1)\)]\^3 - X[2 n]\^3)\) + \(P\_1[2 n]\/2\) \((X[2 \((n + 1)\)]\^2 - X[2 n]\^2)\) + P\_0[2 n] \((X[2 \((n + 1)\)] - X[2 n])\)]\)], "Input"], Cell[BoxData[ \(1\/3\ h\ \((f[a + 2\ h\ n] + 4\ f[a + h + 2\ h\ n] + f[a + 2\ h\ \((1 + n)\)])\)\)], "Output"] }, Open ]], Cell["\<\ Dividendo i termini nei valori pari e dispari dei multipli del passo, la \ somma di tutti gli integrali al variare di n pu\[OGrave] scriversi come\ \>", "Text"], Cell[BoxData[ FormBox[ RowBox[{\(\(\(h\)\(\ \)\)\/3\), RowBox[{"(", RowBox[{\(f(a)\), "+", \(f(b)\), "+", RowBox[{"2", " ", RowBox[{ StyleBox[ UnderoverscriptBox["\[Sum]", StyleBox[\(n = 1\), FontSize->10], StyleBox[\(T/2 - 1\), FontSize->10]], FontSize->18], \(f(X(2 n))\)}]}], "+", RowBox[{"4", " ", RowBox[{ StyleBox[ UnderoverscriptBox["\[Sum]", StyleBox[\(n = 1\), FontSize->10], StyleBox[\(T/2\), FontSize->10]], FontSize->18], \(f(X(2\ n - 1))\)}]}]}], ")"}]}], TraditionalForm]], "Text"], Cell["che \[EGrave] la ", "Text"], Cell[BoxData[ FormBox[ RowBox[{\(\(\(h\)\(\ \)\)\/3\), RowBox[{"(", RowBox[{\(f(a)\), "-", \(f(b)\), "+", RowBox[{"2", " ", RowBox[{ StyleBox[ UnderoverscriptBox["\[Sum]", StyleBox[\(n = 1\), FontSize->10], StyleBox[\(T/2\), FontSize->10]], FontSize->18], RowBox[{ StyleBox["[", FontSize->16], \(f(X(2 n)) + 2 \( f(X(2\ n - 1))\)\), StyleBox["]", FontSize->16]}]}]}]}], ")"}]}], TraditionalForm]], "Text"], Cell["del metodo di Simpson.", "Text"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Integrazione col metodo Monte Carlo: caso monodimensionale", "Section"], Cell[BoxData[{ \(\(f[x_] := Cos[x];\)\), "\[IndentingNewLine]", \(\(a = 0;\)\), "\[IndentingNewLine]", \(\(b = 1;\)\), "\[IndentingNewLine]", \(\(T = 100;\)\), "\[IndentingNewLine]", \(\(h := \(b - a\)\/T;\)\)}], "Input"], Cell["\<\ La funzione \[EGrave] valutata in un numero T di punti del dominio \ distribuiti casualmente in modo uniforme:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Int\_MC = N[h \(\[Sum]\+\(n = 1\)\%T f[Random[]]\)]\)], "Input"], Cell[BoxData[ \(0.806595153586243`\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Abs[1 - Int/Int\_MC]\)], "Input"], Cell[BoxData[ \(0.04323833470433125`\)], "Output"] }, Open ]], Cell["Con un milione di punti-campione:", "Text"], Cell[BoxData[ \(\(T = 10\^6;\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(Int\_MC = N[h \(\[Sum]\+\(n = 1\)\%T f[Random[]]\)]\)], "Input"], Cell[BoxData[ \(0.8414532217438617`\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Abs[1 - Int/Int\_MC]\)], "Input"], Cell[BoxData[ \(0.00002110998398463515`\)], "Output"] }, Open ]], Cell["\<\ Tale errore va confrontato direttamente con quelli precedentemente ricavati \ per i metodi \"classici\" di approssimazione, rivelando la scarsa idoneit\ \[AGrave] del metodo, in questo caso.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Il confronto nei casi multidimensionali: D=2", "Section"], Cell[BoxData[{ \(\(f[x_, y_] := Cos[x] Cos[y];\)\), "\[IndentingNewLine]", \(\(a = 0;\)\), "\[IndentingNewLine]", \(\(b = 1;\)\), "\[IndentingNewLine]", \(\(T = 100;\)\), "\[IndentingNewLine]", \(\(h = \(b - a\)\/T;\)\), "\[IndentingNewLine]", \(X[n_] := a + h*n\)}], "Input"], Cell["Il valore esatto dell'integrale \[EGrave], naturalmente:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Int = N[Sin[1]\^2]\)], "Input"], Cell[BoxData[ \(0.7080734182735712`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["Metodo dei rettangoli centrati", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(Int\_R = N[\(h\^2\) \(\[Sum]\+\(n = 1\)\%T\(\[Sum]\+\(m = 1\)\%T\((f[ X[m - 1\/2], X[n - 1\/2]])\)\)\)]\)], "Input"], Cell[BoxData[ \(0.7080793189148941`\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\[CapitalDelta]\_R = Abs[1 - Int/Int\_R]\)], "Input"], Cell[BoxData[ \(8.333305556607051`*^-6\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Metodo di Simpson bidimensionale", "Subsection"], Cell["\<\ Analogamente al caso monodimensionale, questo metodo adotta l'interpolazione \ tramite un settore di quadrica di una porzione di grafico della funzione \ integranda corrispondente ad un quadrato contenente 9 punti-campione.\ \>", "Text"], Cell[CellGroupData[{ Cell[TextData[{ "Integrale dei due settori di paraboloide ", Cell[BoxData[ \(TraditionalForm\`z\ \((x\ , \ y)\)\ = P\_\(2, 0\)\ \ x\^2\ + P\_\(0, 2\)\ \ y\^2\ + \ P\_\(1, 1\)\ x\ y\ + P\_\(1, 0\)\ \ x\ + P\_\(0, 1\)\ \ y\ + \ P\_\(0, 0\)\)]], " passanti per un quadrato di 3X3 punti adiacenti del campione" }], "Subsubsection"], Cell[BoxData[ \(f[x_, y_] =. ; a =. ; b =. ; T =. ; h =. ;\)], "Input"], Cell[BoxData[ \(Y[n_] := a + h*n\)], "Input"], Cell["\<\ Sistema rappresentante un paraboloide passante per sei punti:\ \>", "Text"], Cell[BoxData[ \(\(W[m_, n_] = Simplify[ Solve[Flatten[ Table[\[Sum]\+\(i = 1\)\%2\((\(x\_i\) X[m + p]\^i + \(y\_i\) Y[n + q]\^i)\) + z\ X[m + p] Y[n + q] + k \[Equal] f[X[m + p], Y[n + q]], {p, 0, 2}, {q, 0, 2 - p}]], {k, y\_1, y\_2, x\_1, z, x\_2}]];\)\)], "Input"], Cell["Assegnazione delle espressioni funzionali dei coefficienti:", "Text"], Cell[BoxData[ \(\(Table[ P\_\(i, j\)[m_, n_] = \(W[m, n]\)[\([1, \(-i\^2\)/2 + 7/2 i + j + 1, 2]\)], {i, 0, 2}, {j, 0, 2 - i}];\)\)], "Input"], Cell["\<\ Dal punto di vista operativo, si divider\[AGrave] il quadrato di 9 \ punti-campione in due triangoli che includeranno nel loro perimetro sei punti \ ciascuno venendo a condividerne, pertanto, tre, posti su una diagonale del \ quadrato.\ \>", "Text"], Cell["\<\ Il volume compreso fra il generico \"triangolo inferiore\" ed il piano xy pu\ \[OGrave] scriversi:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(ST\_inf = Simplify[\[Sum]\+\(i = 1\)\%3\(\[Sum]\+\(j = 1\)\%\(4 - i\)\(P\_\(i - \ 1, j - 1\)[2 m, 2 n]\/\(2 i\ j\)\) \((X[2 \((m + 1)\)]\^i - X[2 m]\^i)\) \((Y[2 \((n + 1)\)]\^j - Y[2 n]\^j)\)\)]\)], "Input"], Cell[BoxData[ \(1\/3\ h\^2\ \((2\ f[a + 2\ h\ m, a + 2\ h\ n] - 2\ f[a + 2\ h\ m, a + h + 2\ h\ n] + f[a + 2\ h\ m, a + 2\ h\ \((1 + n)\)] - 2\ f[a + h + 2\ h\ m, a + 2\ h\ n] + 6\ f[a + h + 2\ h\ m, a + h + 2\ h\ n] + f[a + 2\ h\ \((1 + m)\), a + 2\ h\ n])\)\)], "Output"] }, Open ]], Cell["\<\ Per analogia, il volume relativo al \"triangolo superiore\" sar\[AGrave], \ sostituendo le coordinate dei tre punti variati:\ \>", "Text"], Cell[BoxData[ \(\(ST\_sup = 1\/3\ h\^2\ \((2\ f[a + 2\ h\ \((1 + m)\), a + 2\ h\ \((1 + n)\)] - 2\ f[a + 2\ h\ \((1 + m)\), a + h + 2\ h\ n] + f[a + 2\ h\ m, a + 2\ h\ \((1 + n)\)] - 2\ f[a + h + 2\ h\ m, a + 2\ h\ \((1 + n)\)] + 6\ f[a + h + 2\ h\ m, a + h + 2\ h\ n] + f[a + 2\ h\ \((1 + m)\), a + 2\ h\ n])\);\)\)], "Input"], Cell["\<\ Cosicch\[EAcute] all'intero quadrato comprendente il punto (a+(2m+1)*h , \ a+(2n+1)*h) ed i suoi otto primi vicini compete un volume:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(ST = Simplify[ST\_inf + ST\_sup]\)], "Input"], Cell[BoxData[ \(2\/3\ h\^2\ \((f[a + 2\ h\ m, a + 2\ h\ n] - f[a + 2\ h\ m, a + h + 2\ h\ n] + f[a + 2\ h\ m, a + 2\ h\ \((1 + n)\)] - f[a + h + 2\ h\ m, a + 2\ h\ n] + 6\ f[a + h + 2\ h\ m, a + h + 2\ h\ n] - f[a + h + 2\ h\ m, a + 2\ h\ \((1 + n)\)] + f[a + 2\ h\ \((1 + m)\), a + 2\ h\ n] - f[a + 2\ h\ \((1 + m)\), a + h + 2\ h\ n] + f[a + 2\ h\ \((1 + m)\), a + 2\ h\ \((1 + n)\)])\)\)], "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Calcolo dell'integrale", "Subsubsection"], Cell["Reimmissione dei dati del problema:", "Text"], Cell[BoxData[{ \(\(f[x_, y_] := Cos[x] Cos[y];\)\), "\[IndentingNewLine]", \(\(a = 0;\)\), "\[IndentingNewLine]", \(\(b = 1;\)\), "\[IndentingNewLine]", \(\(T = 100;\)\), "\[IndentingNewLine]", \(\(h = \(b - a\)\/T;\)\)}], "Input"], Cell["Calcolo dell'integrale:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Int\_S = N[\[Sum]\+\(n = 0\)\%\(T/2 - 1\)\(\[Sum]\+\(m = 0\)\%\(T/2 - \ 1\)ST\)]\)], "Input"], Cell[BoxData[ \(0.7080734193356992`\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Abs[1 - Int/Int\_S]\)], "Input"], Cell[BoxData[ \(1.5000253261732155`*^-9\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Metodo Monte Carlo", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(Int\_MC = N[\(h\^2\) \(\[Sum]\+\(n = 1\)\%\(T\^2\)f[Random[], Random[]]\)]\)], "Input"], Cell[BoxData[ \(0.7071140369444405`\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Abs[1 - Int/Int\_MC]\)], "Input"], Cell[BoxData[ \(0.0013567561652096938`\)], "Output"] }, Open ]], Cell["\<\ La precisione risulta un po' pi\[UGrave] competitiva, rispetto al caso \ precedente, con quella dei metodi classici, anche se \[EGrave] ancora \ largamente insufficiente.\ \>", "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ D=3 con rilevazione dei tempi di calcolo (su un campione ridotto)\ \>", "Section"], Cell[BoxData[{ \(\(f[x_, y_, z_] := Cos[x] Cos[y] Cos[z];\)\), "\[IndentingNewLine]", \(\(a = 0;\)\), "\[IndentingNewLine]", \(\(b = 1;\)\), "\[IndentingNewLine]", \(\(T = 50;\)\), "\[IndentingNewLine]", \(\(h = \(b - a\)\/T;\)\), "\[IndentingNewLine]", \(\(X[n_] = a + h*n;\)\)}], "Input"], Cell["Valore esatto:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Int = N[Sin[1]\^3]\)], "Input"], Cell[BoxData[ \(0.5958232365909556`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["Metodo dei rettangoli centrati", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[ Int\_R = N[\ \(h\^3\) \(\[Sum]\+\(p = 1\)\%T\(\[Sum]\+\(n = 1\)\%T\(\ \[Sum]\+\(m = 1\)\%T\((f[X[m - 1\/2], X[n - 1\/2], X[p - 1\/2]])\)\)\)\)]]\)], "Input"], Cell[BoxData[ \({38.5`\ Second, 0.5958530285968864`}\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\[CapitalDelta]\_R = Abs[1 - Int/Int\_R]\)], "Input"], Cell[BoxData[ \(0.00004999891668078238`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Metodo dei rettangoli centrati con calcolo preventivo delle coordinate dei \ punti-campione del dominio\ \>", "Subsubsection"], Cell[BoxData[ \(\(Table[X\_i[n_] = a + h*n, {i, 3}];\)\)], "Input"], Cell[BoxData[ \(\(M = Table[X\_i[n - 1\/2], {i, 3}, {n, T}];\)\)], "Input"], Cell["\<\ Si sommano i relativi valori di f , con il loro peso uniforme:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[ Int\_R = N[\(h\^3\) Plus @@ Flatten[ Outer[f, M[\([1]\)], M[\([2]\)], M[\([3]\)]]]]]\)], "Input"], Cell[BoxData[ \({19.010000000000005`\ Second, 0.5958530285968864`}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\[CapitalDelta]\_R = Abs[1 - Int/Int\_R]\)], "Input"], Cell[BoxData[ \(0.00004999891668078238`\)], "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Metodo Monte Carlo", "Subsection"], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[ Int\_MC = N[\(h\^3\) \(\[Sum]\+\(n = 1\)\%\(T\^3\)f[Random[], Random[], Random[]]\)]]\)], "Input"], Cell[BoxData[ \({3.3500000000000085`\ Second, 0.5954554903123129`}\)], "Output"] }, Open ]], Cell["Errore relativo:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Abs[1 - Int/Int\_MC]\)], "Input"], Cell[BoxData[ \(0.0006175881902605873`\)], "Output"] }, Open ]], Cell[TextData[{ "Si pu\[OGrave] iniziare a cogliere gi\[AGrave] in quest'ultimo esempio il \ duplice vantaggio del metodo Monte Carlo rispetto ai classici: la qualit\ \[AGrave] sostanzialmente inalterata dell'approssimazione all'aumentare della \ dimensione del dominio, quindi la sua crescente competitivit\[AGrave] (a \ parit\[AGrave] di punti-campione) rispetto a metodi che abbattono \ progressivamente la precisione del calcolo rispetto al caso monodimensionale \ ", Cell[BoxData[ \(TraditionalForm\`\((\ p(d) \[TildeTilde] \([p(d = 1)]\)\^\(\(\ \)\(1/d\)\)\ )\)\)]], " - anche se una reale equipollenza \[EGrave] raggiunta, con i metodi pi\ \[UGrave] sofisticati come quello di Simpson o della regola di Gauss, solo \ per D \[TildeTilde] 25-30 - , ma, soprattutto, il mantenimento di una \ elementare tecnica di campionamento del dominio stesso, a differenza degli \ altri casi che, persino in un esempio elementare come questo (integrazione su \ un tassellamento cubico), costringono al calcolo della funzione integranda in \ un set ben determinato di punti del dominio (nel caso del metodo pi\[UGrave] \ semplice, i centri dei cubi), con un rilevante aumento dei tempi di calcolo, \ anche quando l'indirizzamento \[EGrave] predeterminato (attraverso la matrice \ M)." }], "Text"] }, Open ]] }, Open ]] }, Open ]] }, FrontEndVersion->"4.0 for Microsoft Windows", ScreenRectangle->{{0, 800}, {0, 527}}, WindowSize->{693, 475}, WindowMargins->{{0, Automatic}, {Automatic, 1}}, CellLabelAutoDelete->True ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1739, 51, 114, 1, 64, "Subtitle"], Cell[CellGroupData[{ Cell[1878, 56, 194, 7, 60, "Section"], Cell[2075, 65, 168, 3, 52, "Text"], Cell[2246, 70, 136, 3, 33, "Text"], Cell[2385, 75, 294, 6, 144, "Input"], Cell[2682, 83, 108, 3, 33, "Text"], Cell[CellGroupData[{ Cell[2815, 90, 73, 1, 42, "Input"], Cell[2891, 93, 40, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[2968, 99, 43, 1, 30, "Input"], Cell[3014, 102, 53, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[3104, 108, 56, 0, 47, "Subsection"], Cell[3163, 110, 179, 4, 52, "Text"], Cell[CellGroupData[{ Cell[3367, 118, 86, 1, 51, "Input"], Cell[3456, 121, 53, 1, 29, "Output"] }, Open ]], Cell[3524, 125, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[3581, 129, 73, 1, 30, "Input"], Cell[3657, 132, 56, 1, 29, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[3762, 139, 74, 0, 47, "Subsection"], Cell[3839, 141, 415, 7, 71, "Text"], Cell[CellGroupData[{ Cell[4279, 152, 137, 3, 51, "Input"], Cell[4419, 157, 53, 1, 29, "Output"] }, Open ]], Cell[4487, 161, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[4544, 165, 73, 1, 30, "Input"], Cell[4620, 168, 56, 1, 29, "Output"] }, Open ]], Cell[4691, 172, 363, 6, 71, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[5091, 183, 43, 0, 47, "Subsection"], Cell[5137, 185, 110, 3, 33, "Text"], Cell[CellGroupData[{ Cell[5272, 192, 201, 4, 51, "Input"], Cell[5476, 198, 53, 1, 29, "Output"] }, Open ]], Cell[5544, 202, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[5601, 206, 52, 1, 30, "Input"], Cell[5656, 209, 57, 1, 29, "Output"] }, Open ]], Cell[5728, 213, 205, 4, 52, "Text"], Cell[CellGroupData[{ Cell[5958, 221, 237, 6, 43, "Subsubsection"], Cell[6198, 229, 71, 1, 30, "Input"], Cell[6272, 232, 104, 3, 33, "Text"], Cell[6379, 237, 292, 6, 72, "Input"], Cell[6674, 245, 75, 0, 33, "Text"], Cell[6752, 247, 220, 3, 70, "Input"], Cell[6975, 252, 97, 2, 33, "Text"], Cell[CellGroupData[{ Cell[7097, 258, 243, 4, 64, "Input"], Cell[7343, 264, 125, 2, 42, "Output"] }, Open ]], Cell[7483, 269, 170, 3, 33, "Text"], Cell[7656, 274, 865, 23, 69, "Text"], Cell[8524, 299, 33, 0, 33, "Text"], Cell[8560, 301, 696, 18, 69, "Text"], Cell[9259, 321, 38, 0, 33, "Text"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[9358, 328, 77, 0, 53, "Section"], Cell[9438, 330, 245, 5, 123, "Input"], Cell[9686, 337, 134, 3, 33, "Text"], Cell[CellGroupData[{ Cell[9845, 344, 84, 1, 51, "Input"], Cell[9932, 347, 52, 1, 29, "Output"] }, Open ]], Cell[9999, 351, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[10056, 355, 53, 1, 30, "Input"], Cell[10112, 358, 54, 1, 29, "Output"] }, Open ]], Cell[10181, 362, 49, 0, 33, "Text"], Cell[10233, 364, 47, 1, 30, "Input"], Cell[CellGroupData[{ Cell[10305, 369, 84, 1, 51, "Input"], Cell[10392, 372, 53, 1, 29, "Output"] }, Open ]], Cell[10460, 376, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[10517, 380, 53, 1, 30, "Input"], Cell[10573, 383, 57, 1, 29, "Output"] }, Open ]], Cell[10645, 387, 214, 4, 52, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[10896, 396, 63, 0, 53, "Section"], Cell[10962, 398, 305, 6, 144, "Input"], Cell[11270, 406, 72, 0, 33, "Text"], Cell[CellGroupData[{ Cell[11367, 410, 51, 1, 31, "Input"], Cell[11421, 413, 53, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[11511, 419, 52, 0, 47, "Subsection"], Cell[CellGroupData[{ Cell[11588, 423, 161, 3, 51, "Input"], Cell[11752, 428, 53, 1, 29, "Output"] }, Open ]], Cell[11820, 432, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[11877, 436, 73, 1, 30, "Input"], Cell[11953, 439, 56, 1, 29, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[12058, 446, 54, 0, 47, "Subsection"], Cell[12115, 448, 247, 4, 52, "Text"], Cell[CellGroupData[{ Cell[12387, 456, 377, 8, 61, "Subsubsection"], Cell[12767, 466, 75, 1, 30, "Input"], Cell[12845, 469, 49, 1, 30, "Input"], Cell[12897, 472, 85, 2, 33, "Text"], Cell[12985, 476, 372, 7, 138, "Input"], Cell[13360, 485, 75, 0, 33, "Text"], Cell[13438, 487, 179, 4, 31, "Input"], Cell[13620, 493, 259, 5, 52, "Text"], Cell[13882, 500, 122, 3, 33, "Text"], Cell[CellGroupData[{ Cell[14029, 507, 278, 5, 53, "Input"], Cell[14310, 514, 332, 6, 62, "Output"] }, Open ]], Cell[14657, 523, 148, 3, 33, "Text"], Cell[14808, 528, 415, 7, 104, "Input"], Cell[15226, 537, 157, 3, 33, "Text"], Cell[CellGroupData[{ Cell[15408, 544, 65, 1, 30, "Input"], Cell[15476, 547, 494, 9, 100, "Output"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[16019, 562, 47, 0, 43, "Subsubsection"], Cell[16069, 564, 51, 0, 33, "Text"], Cell[16123, 566, 255, 5, 123, "Input"], Cell[16381, 573, 39, 0, 33, "Text"], Cell[CellGroupData[{ Cell[16445, 577, 120, 3, 51, "Input"], Cell[16568, 582, 53, 1, 29, "Output"] }, Open ]], Cell[16636, 586, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[16693, 590, 52, 1, 30, "Input"], Cell[16748, 593, 57, 1, 29, "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[16866, 601, 40, 0, 47, "Subsection"], Cell[CellGroupData[{ Cell[16931, 605, 129, 3, 54, "Input"], Cell[17063, 610, 53, 1, 29, "Output"] }, Open ]], Cell[17131, 614, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[17188, 618, 53, 1, 30, "Input"], Cell[17244, 621, 56, 1, 29, "Output"] }, Open ]], Cell[17315, 625, 194, 4, 52, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[17558, 635, 92, 2, 53, "Section"], Cell[17653, 639, 319, 6, 144, "Input"], Cell[17975, 647, 30, 0, 33, "Text"], Cell[CellGroupData[{ Cell[18030, 651, 51, 1, 31, "Input"], Cell[18084, 654, 53, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[18174, 660, 52, 0, 47, "Subsection"], Cell[CellGroupData[{ Cell[18251, 664, 214, 4, 53, "Input"], Cell[18468, 670, 70, 1, 29, "Output"] }, Open ]], Cell[18553, 674, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[18610, 678, 73, 1, 30, "Input"], Cell[18686, 681, 57, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[18780, 687, 136, 3, 43, "Subsubsection"], Cell[18919, 692, 71, 1, 30, "Input"], Cell[18993, 695, 79, 1, 42, "Input"], Cell[19075, 698, 88, 2, 33, "Text"], Cell[CellGroupData[{ Cell[19188, 704, 160, 4, 31, "Input"], Cell[19351, 710, 84, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[19472, 716, 73, 1, 30, "Input"], Cell[19548, 719, 57, 1, 29, "Output"] }, Open ]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[19666, 727, 40, 0, 47, "Subsection"], Cell[CellGroupData[{ Cell[19731, 731, 158, 4, 54, "Input"], Cell[19892, 737, 84, 1, 29, "Output"] }, Open ]], Cell[19991, 741, 32, 0, 33, "Text"], Cell[CellGroupData[{ Cell[20048, 745, 53, 1, 30, "Input"], Cell[20104, 748, 56, 1, 29, "Output"] }, Open ]], Cell[20175, 752, 1308, 21, 185, "Text"] }, Open ]] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)