(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. 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[ 171663, 5421]*) (*NotebookOutlinePosition[ 172813, 5458]*) (* CellTagsIndexPosition[ 172635, 5450]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Modelling Financial Derivatives with Mathematica", "Title"], Cell["Update, Errata and V5/4 Compatibility Notes", "Subtitle"], Cell["\<\ February 2004 William T. Shaw Quantitative Analysis Group Nomura International plc william.shaw@uk.nomura.com The Mathematical Institute 24-29 St Giles Oxford OX1 3LB shaww@maths.ox.ac.uk\ \>", "Subsubtitle"], Cell[CellGroupData[{ Cell["Read this first", "Section"], Cell[TextData[{ "This notebook has recently been updated to improve compatibility with \ version 5 of ", StyleBox["Mathematica", FontSlant->"Italic"], ". Specifically, this first section comprises a list of changes to get \ things working, that have been tested under version 5.01 of ", StyleBox["Mathematica", FontSlant->"Italic"], ", released in January 2004. The second section consists of a list of \ supplementary observations, while the third consists of a number of known bug \ fixes to deal with issues raised by the release of version 4. Logically, you \ should make the version 4 changes and then the Version 5 changes. However, \ version 5 compatibility with the early chapters is ensured by making some \ very simple quick fixes, whereas you will not run into much trouble with the \ version 4 patches until you start to use the compiler. All of these changes \ will be incorporated into a revision of the book at some point. (After \ Complex Analysis with ", StyleBox["Mathematica", FontSlant->"Italic"], " (CUP 2004/5) is released!)" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Version 5 Quick Fixes", "Subtitle"], Cell[CellGroupData[{ Cell["Global Changes", "Section"], Cell[CellGroupData[{ Cell["Ignore spelling errors!", "Subsection"], Cell["\<\ In running the code in several chapters you will see messages like \ (this one is from Chapter 2).\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(expression\ = \ Exp[\(-x^2\)];\)\), "\[IndentingNewLine]", \(StandardForm[expression]\)}], "Input"], Cell[BoxData[ RowBox[{\(General::"spell1"\), \(\(:\)\(\ \)\), "\<\"Possible spelling \ error: new symbol name \\\"\\!\\(expression\\)\\\" is similar to existing \ symbol \\\"\\!\\(Expression\\)\\\". \ \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", ButtonStyle->\\\"RefGuideLinkText\ \\\", ButtonFrame->None, ButtonData:>\\\"General::spell1\\\"]\\)\"\>"}]], \ "Message"], Cell[BoxData[ \(\[ExponentialE]\^\(-x\^2\)\)], "Output"] }, Open ]], Cell[TextData[{ "This sort of message is a helpful/annoying reminder that you have made a \ mistake/invented a symbol with a name similar to an existing one. In this and \ most cases thsy can be ignored, but check to see if you really have spelt \ somefing rong. You get these messages in amy recent version of ", StyleBox["Mathematica", FontSlant->"Italic"], ". " }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["The Norm function and Packages", "Subsection"], Cell[TextData[{ "In ", StyleBox["Mathematica", FontSlant->"Italic"], " 5 the function Norm is a core kernel function:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?Norm\)\)], "Input"], Cell[BoxData[ RowBox[{"\<\"Norm[expr] gives the norm of a number or array. Norm[expr, \ p] gives the p-norm.\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], ButtonData:>"Norm", Active->True, ButtonStyle->"RefGuideLink"]}]], "Print", CellTags->"Info3285482698-3438469"] }, Open ]], Cell[TextData[{ "In the book I used this (rather recklessly!) to label the cumulative \ normal distribution function. The notation commonly used in finance is ", Cell[BoxData[ \(TraditionalForm\`N(x)\)]], ", but as ", StyleBox["Mathematica", FontSlant->"Italic"], " reserves the N function for enforcing numerical output:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?N\)\)], "Input"], Cell[BoxData[ RowBox[{"\<\"N[expr] gives the numerical value of expr. N[expr, n] \ attempts to give a result with n-digit precision.\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], ButtonData:>"N", Active->True, ButtonStyle->"RefGuideLink"]}]], "Print", CellTags->"Info3285482767-2024397"] }, Open ]], Cell["\<\ I had to pick something else. Henceforth the function will be \ called Ncdf. This should be applied globally throughout all chapters and the \ two packages that came with the book. For example, in Chapter 1, the \ following should be applied:\ \>", "Text"], Cell["\<\ Ncdf[x_] := 1/2*(1 + Erf[x/Sqrt[2]]); done[s_, \[Sigma]_, k_, t_, r_, q_] := ((r - q)*t + Log[s/k])/(\[Sigma]*Sqrt[t]) + (\[Sigma]*Sqrt[t])/2; dtwo[s_, \[Sigma]_, k_, t_, r_, q_] := done[s, \[Sigma], k, t, r, q] - \[Sigma]*Sqrt[t]; BlackScholesCall[s_, k_, v_, r_, q_, t_] := s*Exp[-q*t]*Ncdf[done[s, v, k, t, r, q]] - k*Exp[-r*t]*Ncdf[dtwo[s, v, k, t, \ r, q]]; \ \>", "Input"], Cell["\<\ The two packages BlackScholes.m and AnalyticAmerican.m should be \ similarly edited, along with all other chapters. (Check to see if you have \ received the updated packages with this notebook).\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Precision", "Subsection"], Cell["\<\ There has been some tightening up of how this works. For example, \ in Chapter 2, the sequence of numerical investigations should now be realised \ as follows:\ \>", "Text"], Cell[CellGroupData[{ Cell["N[Sqrt[51]]", "Input"], Cell[BoxData[ \(7.14142842854285`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["Precision[%]", "Input"], Cell[BoxData[ \(MachinePrecision\)], "Output"] }, Open ]], Cell["and you need to ask about this:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \($MachinePrecision\)], "Input"], Cell[BoxData[ \(15.954589770191003`\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["(3/4)^100", "Input"], Cell[BoxData[ \(515377520732011331036461129765621272702107522001\/\ 1606938044258990275541962092341162602522202993782792835301376\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["N[(3/4)^100,10]", "Input"], Cell[BoxData[ \(3.2072021853815038140038413`9.999999999999998*^-13\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["0.75^100", "Input"], Cell[BoxData[ \(3.207202185381504`*^-13\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["N[0.75^100,10]", "Input"], Cell[BoxData[ \(3.207202185381504`*^-13\)], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["New fitting functions", "Subsection"], Cell[TextData[{ "Note the appearance of the ", StyleBox["FindFit", FontFamily->"Courier", FontWeight->"Bold"], " function. This can be used to do fitting based on other objective \ functions, for example, Least Absolute Deviation fitting (which is MLE based \ on double-sided exponential rather than Gaussian noise) (More to come on \ this!)" }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Integrate", "Subsection"], Cell["\<\ Symbolic integration appears to be rather slower in version 5, and \ return results that are carefully couched to the point of major irritation. \ While I have not got to the bottom of this, part of the story is due to much \ more careful checking of cases and presentation of results. \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Options[Integrate]\)], "Input"], Cell[BoxData[ \({Assumptions \[RuleDelayed] $Assumptions, GenerateConditions \[Rule] Automatic, PrincipalValue \[Rule] False}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(?Assumptions\)\)], "Input"], Cell[BoxData[ RowBox[{"\<\"Assumptions is an option for functions such as Simplify, \ Refine and Integrate which specifies default assumptions to be made about \ symbolic quantities.\"\>", " ", ButtonBox[ StyleBox["More\[Ellipsis]", "SR"], ButtonData:>"Assumptions", Active->True, ButtonStyle->"RefGuideLink"]}]], "Print", CellTags->"Info3285485322-1473113"] }, Open ]], Cell["The following examples are interesting in this respect:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[ Integrate[ 1/\((x^2\ + \ a^2)\), \ {x, \ \(-Infinity\), \ Infinity}]]\)], "Input"], Cell[BoxData[ \({2.422`\ Second, If[Re[a\^2] > 0, \[Pi]\/\@a\^2, Integrate[1\/\(a\^2 + x\^2\), {x, \(-\[Infinity]\), \[Infinity]}, Assumptions \[Rule] Re[a\^2] \[LessEqual] 0]]}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[ Integrate[1/\((x^2\ + \ b^2)\), \ {x, \ \(-Infinity\), \ Infinity}, \ GenerateConditions\ \[Rule] \ False]]\)], "Input"], Cell[BoxData[ \({0.7029999999999998`\ Second, \@\(1\/b\^2\)\ \[Pi]}\)], "Output"] }, Open ]], Cell["\<\ The output of the following is what you really expect to see:\ \>", \ "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[ Integrate[1/\((x^2\ + \ c^2)\), \ {x, \ \(-Infinity\), \ Infinity}, \ Assumptions\ \[Rule] \ c > 0]]\)], "Input"], Cell[BoxData[ \({0.734`\ Second, \[Pi]\/c}\)], "Output"] }, Open ]], Cell[TextData[{ "It's almost as if you really want ", StyleBox["Mathematica", FontSlant->"Italic"], " to have a DWIM interface (do what I mean), but it is better to have a \ pedantic system and then you must tell it about your own (often implicit) \ assumptions. DWIM behaviour can be sort-of achieved by setting ", StyleBox["GenerateConditions -> False", FontFamily->"Courier", FontWeight->"Bold"], ". These comments supercede those made in the version 4 update below. I do \ not now recommend the fix used previously!" }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Other Chapter-specific issues note covered by global points and \ existing V4 updates\ \>", "Subsection"], Cell[CellGroupData[{ Cell["Chapter 2 ", "Subsubsection"], Cell["\<\ See the version 4 update below - the Fourier and Laplace transforms \ are now in the kernel. Chapter 2 needs a different example!\ \>", "Text"], Cell["\<\ A bug noticed recently is the non-existent listc used in the \ MultipleListPlot example. Delete it. \ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Chapter 3", "Subsubsection"], Cell["\<\ While there are no M5 issues I should note that I am rewriting \ Section 3.5 as it is confusing. Watch out for an update.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Chapter 4", "Subsubsection"], Cell[TextData[{ "Lots of changes due to the differing behaviour of ", StyleBox["Integrate", FontFamily->"Courier", FontWeight->"Bold"], ", and it is best to use the ", StyleBox["Assumptions", FontFamily->"Courier", FontWeight->"Bold"], " option. If you need help with this, e-mail me at shaww@maths.ox.ac.uk for \ a new version of Chapter 4. " }], "Text"] }, Open ]] }, Closed]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Mathematical Updates", "Subtitle"], Cell[CellGroupData[{ Cell["1. Introduction", "Section"], Cell[TextData[{ "This notebook contains information known as of July 1st 1999 about \n\n(i) \ errors in the first printing of the book\n(ii) errors in the second printing \ of the book\n(iii) changes associated with Version 4 of ", StyleBox["Mathematica", FontSlant->"Italic"], ". \n(iv) other issues raised.\n\nOther comments of potential interest have \ been added, some as a result of comments from readers, whose contribution is \ gratefully acknowledged. \n\nThis note inherits all disclaimers of the \ original test with regard to both the printed material and its electronic \ form.\n\nWith regard to version 4 of ", StyleBox["Mathematica", FontSlant->"Italic"], ", ", StyleBox["this notebook is a first run through by the author designed to \ highlight differences and fix any compatibility porblems.", FontVariations->{"Underline"->True}], " There may be further revisions to this note\n\n(a) in the light of \ feedback from Wolfram Research on issues raised;\n\n(b) becoming more V4 \ savvy with regard to numerical optimization.\n\nComments on how to best make \ use of numerical optimization features are most welcome and will be added to \ this note after moderation. Revisions to this notebook will be posted in the \ same locations as this original.\n\nThe version 4 checks and changes reported \ here was based on re-running the code in the book on a Power Macintosh G3 \ running OS8.x. If you get different effects on other hardware/OS, especially \ Wintel, please let me know and I will update this update." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["2. Errata", "Section"], Cell[TextData[{ "In the following sub-sections corrections to the first and second printing \ known as of end-June 1999. These comments concern mistakes in the \ text/equations/code related to either general development or ", StyleBox["Mathematica", FontSlant->"Italic"], " 3.X implementations. See the section on V4 compatibility for further \ issues raised by changes made to the V4 software. More important items are \ denoted by *.\n\nThe first/second printing is ISBN 0 521 59233 X. They are \ distinguished by \"Reprinted 1999\" on the page containing ISBN and \ disclaimer information, in the second printing.\n\nA special thanks goes to \ Roger Wilson and David Kelly, who spotted several of the glitches." }], "Text"], Cell[CellGroupData[{ Cell["Corrections to First Printing Only", "Subsection"], Cell[TextData[{ "*1. p. 407. In the list of parameter definitions for fine path simulation \ the explanations of ", StyleBox["n", FontFamily->"Courier", FontWeight->"Bold"], " and ", StyleBox["navg", FontFamily->"Courier", FontWeight->"Bold"], " have been swapped. ", StyleBox["n", FontFamily->"Courier", FontWeight->"Bold"], " is the number of paths to be sampled, and ", StyleBox["navg", FontFamily->"Courier", FontWeight->"Bold"], " is the number of sample points on each path.\n\n2. p. 76 equation (39). \ There is a spurious extra ", Cell[BoxData[ \(TraditionalForm\`d\ t\)]], " attached to the combination ", Cell[BoxData[ \(TraditionalForm\`q\_X\ \(\[CapitalDelta]\_2\) X\)]], " within the bracketed collection of terms multiplying ", Cell[BoxData[ \(TraditionalForm\`d\ t\)]], ". This equation should read:" }], "Text"], Cell[BoxData[ FormBox[ RowBox[{\(d\ P\), "=", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ FractionBox[\(\[PartialD]V\), \(\[PartialD]X\), MultilineFunction->None], "-", \(\[CapitalDelta]\_1\ S'\), "-", \(\[CapitalDelta]\_2\)}], ")"}], "d", " ", "X"}], "+", RowBox[{ RowBox[{"(", RowBox[{ FractionBox[\(\[PartialD]V\), RowBox[{"\[PartialD]", SuperscriptBox["S", "\[Prime]", MultilineFunction->None]}], MultilineFunction->None], "-", \(\[CapitalDelta]\_1\ X\)}], ")"}], " ", "d", " ", SuperscriptBox["S", "\[Prime]", MultilineFunction->None]}], "+", " ", RowBox[{"d", " ", "t", " ", RowBox[{"(", " ", RowBox[{ FractionBox[\(\[PartialD]V\), \(\[PartialD]t\), MultilineFunction->None], "+", RowBox[{\(1\/2\), \(\[Sigma]\_X\%2\), \(X\^2\), " ", FractionBox[\(\[PartialD]\^2 V\), \(\[PartialD]X\^2\), MultilineFunction->None]}], " ", "\n", "\t\t\t\t ", "+", " ", RowBox[{"X", " ", SuperscriptBox["S", "\[Prime]", MultilineFunction->None], "\[Rho]", " ", SubscriptBox["\[Sigma]", SuperscriptBox["S", "\[Prime]", MultilineFunction->None]], " ", \(\[Sigma]\_X\), " ", FractionBox[\(\[PartialD]\^2 V\), RowBox[{ RowBox[{"\[PartialD]", SuperscriptBox["S", "\[Prime]", MultilineFunction->None]}], "\[ThinSpace]", \(\[PartialD]X\)}], MultilineFunction->None]}], "+", RowBox[{\(1\/2\), SubsuperscriptBox["\[Sigma]", SuperscriptBox["S", "\[Prime]", MultilineFunction->None], "2"], " ", SuperscriptBox[ SuperscriptBox["S", "\[Prime]", MultilineFunction->None], "2"], FractionBox[\(\[PartialD]\^2 V\), RowBox[{"\[PartialD]", SuperscriptBox[ SuperscriptBox["S", "\[Prime]", MultilineFunction->None], "2"]}], MultilineFunction->None]}], " ", "-", \(q\_X\ \[CapitalDelta]\_2\ X\), "-", RowBox[{ SubscriptBox["q", RowBox[{ SuperscriptBox["S", "\[Prime]", MultilineFunction->None], " ", "X"}]], " ", \(\[CapitalDelta]\_1\), " ", SuperscriptBox["S", "\[Prime]", MultilineFunction->None], " ", "X"}]}], ")"}]}]}]}], TraditionalForm]], "DisplayFormula"], Cell[TextData[{ "3. p. 102, middle of the page. The minus sign should not be in the \ argument of ", StyleBox["PowerExpand", FontFamily->"Courier", FontWeight->"Bold"], ", and ", StyleBox["PowerExpand", FontFamily->"Courier", FontWeight->"Bold"], " has not in fact produced the right answer, for ", Cell[BoxData[ \(TraditionalForm\`x > a\)]], ", which should be" }], "Text"], Cell[BoxData[ \(TraditionalForm\`1 - erf(\(x - a\)\/\(2\ \@\[Tau]\))\)], "Input"], Cell[TextData[{ "which agrees with the code line after \"Picking out...\" and with the ", Cell[BoxData[ \(TraditionalForm\`n = 0\)]], " similarity solution. The correct answer under V3.x can be obtained by \ using instead:" }], "Text"], Cell[BoxData[ \(PowerExpand[\(-%\) /. \((a - x)\) -> \ \((x - a)\)]\)], "Input"], Cell["\<\ 4. p. 123, equations (181,184,187). The partial derivatives w.r.t \ \"t\" should be w.r.t \"tau\". The one in (178), before the time-reversed and \ vol-scaled time tau is introduced, is correct. 5. Also on p. 123, the gremlins had a feast on the brackets. Here is how p. \ 123 should really look (without equation numbers):\ \>", "Text"], Cell[BoxData[{ \(TraditionalForm\`x = log(\ S/E)\), "\n", \(TraditionalForm\`\[Tau] = 1\/2\ \[Sigma]\^2\ \((T - t)\)\)}], "DisplayFormula"], Cell[TextData[{ "If ", Cell[BoxData[ \(TraditionalForm\`q(\[Tau])\)]], " is the \[Tau]-dependent function representing the continuously compounded \ dividend yield ", Cell[BoxData[ \(TraditionalForm\`DY(t)\)]], " (this may contain discrete pieces)," }], "Text"], Cell[BoxData[{ \(TraditionalForm\`\[Null]k\_1[\[Tau]] = \(\(2\ R\ \((\[Tau])\)\)\/\ \[Sigma]\^2 = \(2\ \(r(\ t)\)\)\/\[Sigma]\^2\)\), "\n", \(TraditionalForm\`\[Null]k\_2[\[Tau]] = \(\(2\ \((R\ \((\[Tau])\) - q(\ \[Tau]))\)\)\/\[Sigma]\^2 = \(2\ \((r\ \((t)\) - DY\ \ \((t)\))\)\)\/\[Sigma]\^2\)\)}], "DisplayFormula"], Cell["Then we obtain", "Text"], Cell[BoxData[ \(TraditionalForm\`\[PartialD]V\/\[PartialD]\[Tau] + \ \ \[Null]k\_1[\[Tau]] V = \ \ \[PartialD]\^2 V\/\[PartialD]x\^2\ + \ \ \((\[Null]k\_2[\ \[Tau]]\ - 1\ )\) \[PartialD]V\/\[PartialD]x\ + \ \(2\/\[Sigma]\^2\) K\)], "DisplayFormula"], Cell[TextData[{ "Thus far the change of variables has proceeded as for the European options \ discussed previously. The final part of the previous analysis does not work \ for the present problem unless ", Cell[BoxData[ \(TraditionalForm\`k\_2[\[Tau]]\ \ is\ \(\(constant\)\(.\)\)\)]], " To treat the time-dependent case, let" }], "Text"], Cell[BoxData[ \(TraditionalForm\`z = x + F(\[Tau])\)], "DisplayFormula"], Cell["and set", "Text"], Cell[BoxData[ \(TraditionalForm\`V( x, \[Tau]) = \(u( z, \[Tau])\)\ \[ExponentialE]\^\(-\(B(\[Tau])\)\)\)], \ "DisplayFormula"], Cell["Making the required change of variable leads to", "Text"], Cell[BoxData[ \(TraditionalForm\`u\ \((\[Null]k\_1[\[Tau]] - \[PartialD]B\/\[PartialD]\ \[Tau])\) + \[PartialD]u\/\[PartialD]\[Tau] = \[PartialD]\^2 \ u\/\[PartialD]z\^2 + \(2 K\[ExponentialE]\^\(B(\[Tau])\)\)\/\[Sigma]\^2 + \ \((\(-\(\[PartialD]F\/\[PartialD]\[Tau]\)\) + \[Null]k\_2[\[Tau]] - 1)\)\ \[PartialD]V\/\[PartialD]x\)], "DisplayFormula"], Cell["so we can reduce the problem by making the choices", "Text"], Cell[BoxData[ \(TraditionalForm\`k\_1[\[Tau]] = \[PartialD]B\/\[PartialD]\[Tau]\)], \ "DisplayFormula"], Cell[BoxData[ \(TraditionalForm\`k\_2[\[Tau]] - 1 = \[PartialD]F\/\[PartialD]\[Tau]\)], "DisplayFormula"], Cell["whence we get", "Text"], Cell[BoxData[ \(TraditionalForm\`\[PartialD]u\/\[PartialD]\[Tau] = \[PartialD]\^2 u\/\ \[PartialD]z\^2 + Q(\[Tau])\)], "DisplayFormula"], Cell[TextData[{ "where the diffusion equation now has a \"source term\" ", Cell[BoxData[ \(TraditionalForm\`Q\)]], " representing the coupon payments in these coordinates:" }], "Text"], Cell[BoxData[ \(TraditionalForm\`Q(\[Tau])\ = \(2 K\ \[ExponentialE]\^\(B(\[Tau])\)\)\ \/\[Sigma]\^2\)], "DisplayFormula"], Cell["(End of correction to p. 123)", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Corrections to First and Second Printing", "Subsection"], Cell["\<\ 6. On p. 83, the commutation of the Black-Scholes operator with the \ (homogeneity) operator\ \>", "Text"], Cell[BoxData[ FormBox[ RowBox[{"S", " ", FractionBox[\(\(\[PartialD]\)\(\ \)\), \(\[PartialD]S\), MultilineFunction->None]}], TraditionalForm]], "DisplayFormula"], Cell[TextData[{ "relies on the dividend term being of the form ", Cell[BoxData[ \(TraditionalForm\`D\ = \ q\ S\)]], ". I found out about Peter Carr's related (and much more detailed) work, \ deriving the rho-delta link and the vega-gamma identity using probabilistic \ methods, too late for inclusion in the text, but his working paper on the \ matter is available on the Web. It is \"Deriving Derivatives of Derivative \ Securities\", on www.math.nyu.edu/research/carrp/papers. The operator \ commutation relations are common to both the probabilistic and PDE \ approaches. " }], "Text"], Cell[TextData[{ "7. The gremlins got into the editing of the supersymmetric examples in \ Section 19.4 on pp. 377-378. In the definition of ", StyleBox["SSdataCApp", FontFamily->"Courier", FontWeight->"Bold"], ", the function call should be to ", StyleBox["FastSSEuropeanCallApp", FontFamily->"Courier", FontWeight->"Bold"], ", not ", StyleBox["FastSSSEuropeanCallApp", FontFamily->"Courier", FontWeight->"Bold"], "! Also, in the subsequent plots of the convergence, the string \"", StyleBox["OTS", FontFamily->"Courier", FontWeight->"Bold"], "\" should be replaced by \"", StyleBox["SS", FontFamily->"Courier", FontWeight->"Bold"], "\". So , for example, the first graphic is obtained by " }], "Text"], Cell[BoxData[ \(\(Show[explot, SSPlotC, \ \ PlotRange\ -> \ {0.69, \ 0.70}, \ DisplayFunction\ -> \ $DisplayFunction];\)\)], "Input"], Cell[TextData[{ "8. In Chapter 15, the column headings labelling the numerical and exact \ solution are the wrong way round, in several examples. On p. 285, 287, 289, \ the headings should be in the order: S, numerical, exact, error.\n\n9. \ Regarding Section 6.5 on p141-142, the simple rational approximations to the \ cumulative Normal distribution were in fact first popularized by Mark \ Rubenstein and John Cox in their wonderful book, \"Options Markets\", \ published by Prentice-Hall in 1985. The function I have called ", StyleBox["HFuncOne", FontFamily->"Courier", FontWeight->"Bold"], " appears on p. 343 of that text within the instructions for a programmable \ calculator, and ", StyleBox["HFuncTwo", FontFamily->"Courier", FontWeight->"Bold"], " is given on pp. 261-262. I apologize to Profs Robenstein and Cox both for \ this specific mistake and not referring to their text in many other places, \ especially for discussions of market issues. \n\n10. In Chapter 23, p. 447, \ the 2D numerical integration expressed by ", StyleBox["BasketCallIntegral", FontFamily->"Courier", FontWeight->"Bold"], " produces unstable results - this is currently under investigation. \n\n\ 11. In Chapter 25, despite saying that I have suppressed the dependence on ", Cell[BoxData[ \(TraditionalForm\`T\)]], ", it is left in - the last line on this page and first line of p. 475 \ should read" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(TraditionalForm[U[r, t]]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`\[ExponentialE]\^\(A(t) - r\ \(B(t)\)\)\ Z\)], "Output"] }, Open ]], Cell[TextData[{ "At the top of p. 476, equation (25) is (obviously) obtained by a similar \ application of Traditional Form to ", StyleBox["beqn", FontFamily->"Courier", FontWeight->"Bold"], "." }], "Text"], Cell["\<\ 12. (second printing only) On p. 123 there is still one outer \ bracket missing in the lower part of equation (180), which should read\ \>", \ "Text"], Cell[BoxData[ \(TraditionalForm\`\[Null]k\_2[\[Tau]] = \(\(2\ \((R\ \((\[Tau])\) - q(\ \[Tau]))\)\)\/\[Sigma]\^2 = \(2\ \((r\ \((t)\) - DY\ \ \((t)\))\)\)\/\[Sigma]\^2\)\)], "DisplayFormula"], Cell["These are all known corrections as of 1st Juy 1999.", "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["3. Issues Raised by Recent Papers + More on \"Implied Vol\"", "Section"], Cell["\<\ This section makes brief comments regarding a couple of recent \ publications that either directly refer to the book, or come up with ideas \ that I would have included if writing now.\ \>", "Text"], Cell[CellGroupData[{ Cell["Discretely Observed Barriers", "Subsection"], Cell["\<\ The first paper is the rather wonderful \"Connecting discrete and \ continuous path-dependent options\", by M. Broadie, P. Glasserman, and S.G. \ Kou, (BGK) published in Finance and Stochastics, vol 3, p. 55 (1999). It \ generalizes work first reported in Math. Finance vol 7, p. 325 (1997). I particularly like these papers as they present a means of working with \ simple closed-form analytics, for a large class of path-dependent options, \ but where the barrier/max/min along the path is observed only at (regular) \ discrete time points. This eliminates, with a cunning analytical \ approximation, a large volume of numerical modelling. You should really read this paper to get the idea in full, and were I \ re-writing MFDwM now, I would give several examples both in the development \ of the analytics, and in the comparisons with Monte Carlo later. Their result \ is very concisely stated for the case of (zero-rebate) barrier options, where \ it suffices to make a simple adjustment to the location of the barrier as a \ function of the observation interval. \ \>", "Text"], Cell[CellGroupData[{ Cell["Simple Analytical Adjustment for Barriers", "Subsubsection"], Cell[TextData[{ "The simplest form of the BGK correction applies to barrier options, where \ we consider zero rebate for simplicity. The analytical model in Chapter 8 \ then applies with zero rebate, for the European Barrier option. The idea is \ that a discretely-observed barrier at one level can be replaced by a \ continuously observed barrier that is slighly further away from the current \ asset price. (This is obviously a very naive description of the BGK analysis, \ but is at least intuitive). BGK calculate the correction to the barrier \ location in closed form! Let ", Cell[BoxData[ \(TraditionalForm\`H\)]], " denote the location of the barrier that is observed at a constant time \ interval ", Cell[BoxData[ \(TraditionalForm\`\[CapitalDelta]\ t\ = \ t/m\)]], " where ", Cell[BoxData[ \(TraditionalForm\`t\)]], " is the time to maturity and ", Cell[BoxData[ \(TraditionalForm\`m\)]], " is the number of observations. \n\nFor an up-option, the effective \ barrier to be used in a continuous model is " }], "Text"], Cell[BoxData[ \(TraditionalForm\`H\_u = H\ \[ExponentialE]\^\(\[Beta]\ \[Sigma]\ \@\(\[CapitalDelta]\ t\)\)\)], \ "DisplayFormula"], Cell["For a down-option:", "Text"], Cell[BoxData[ \(TraditionalForm\`H\_d = H\ \[ExponentialE]\^\(\(-\[Beta]\)\ \[Sigma]\ \@\(\[CapitalDelta]\ \ t\)\)\)], "DisplayFormula"], Cell["where", "Text"], Cell[BoxData[ FormBox[ RowBox[{"\[Beta]", "=", RowBox[{"-", FractionBox[ TagBox[ RowBox[{"\[Zeta]", "(", TagBox[\(1\/2\), (Editable -> True)], ")"}], InterpretTemplate[ Zeta[ #]&]], \(\@\(2\ \[Pi]\)\)]}]}], TraditionalForm]], "DisplayFormula"], Cell[TextData[{ "and ", Cell[BoxData[ \(TraditionalForm\`\[Zeta](x)\)]], " denotes the Riemann zeta function evaluated at ", Cell[BoxData[ \(TraditionalForm\`x\)]], ". The error in the valuation in this approximate treatment is ", Cell[BoxData[ FormBox[ RowBox[{\(o(1/\@m)\), Cell[""]}], TraditionalForm]]], ". This is all easy to put into ", StyleBox["Mathematica", FontSlant->"Italic"], ", which does of course have the zeta-function built in. (If you must use \ another environment \[Beta] = 0.5826). Here's the new model for an up and out \ call - the others are corrected similarly. It is assumed that the relevant \ functions from Chapter 8 have been entered into the kernel." }], "Text"], Cell[BoxData[ \(BarrUp[h_, \ \[Sigma]_, \ t_, \ navg_]\ := \ Module[{rootdt\ = \ Sqrt[t/\((navg - 1)\)], \ \[Beta]\ = \ \(-Zeta[1/2]\)/ Sqrt[2\ Pi]}, \[IndentingNewLine]h* Exp[\[Beta]*\[Sigma]*rootdt]]\)], "Input"], Cell["\<\ So weekly observation of a barrier at 120 gives an effective \ barrier at\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BarrUp[120, \ 0.2, \ 1, \ 53]\)], "Input"], Cell[BoxData[ \(121.95475077814582`\)], "Output"] }, Open ]], Cell["\<\ The (zero-rebate) Up and Out Call is then modelled in the BGK \ approximation by\ \>", "Text"], Cell[BoxData[ \(\(\(AnalyticDiscreteUpAndOutCall[p_, k_, h_, sd_, r_, q_, t_, \ m_]\)\(\ \)\(:=\)\(\[IndentingNewLine]\)\(Module[{H\ = \ BarrUp[h, \ sd, \ t, \ m]}, \[IndentingNewLine]{H, \ UpAndOutCall[0, \ p, k, H, sd, r, q, t]}]\)\(\ \)\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(TableForm[ Table[Flatten[{10^k, \ AnalyticDiscreteUpAndOutCall[100, \ 100, \ 120, \ 0.2, \ 0.05, \ 0.02, \ 1, \ 10^k]}], \ {k, \ 1, \ 9}]]\)], "Input"], Cell[BoxData[ TagBox[GridBox[{ {"10", "124.75247240479058`", "2.010377229877453`"}, {"100", "121.41353778377945`", "1.3723613636499863`"}, {"1000", "120.44319782565194`", "1.2054795897966577`"}, {"10000", "120.13991181006327`", "1.155306746339515`"}, {"100000", "120.04422438368886`", "1.1396807338894437`"}, {"1000000", "120.01398315342084`", "1.1347627897471284`"}, {"10000000", "120.00442168322857`", "1.133209925348765`"}, {"100000000", "120.00139824133213`", "1.132719098573899`"}, {"1000000000", "120.00044216096941`", "1.1325639087086792`"} }, RowSpacings->1, ColumnSpacings->3, RowAlignments->Baseline, ColumnAlignments->{Left}], (TableForm[ #]&)]], "Output"] }, Open ]], Cell["The continuum limit is just", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(UpAndOutCall[0, \ 100, \ 100, \ 120, \ 0.2, \ 0.05, \ 0.02, \ 1]\)], "Input"], Cell[BoxData[ \(1.1324921409971846`\)], "Output"] }, Open ]], Cell["\<\ That is all there is to it, except that you need to be careful with \ vega and theta, and this simple model is less accurate when you are close to \ the barrier.\ \>", "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Asian Options", "Subsection"], Cell[TextData[{ "The following is a reply to a paper by Fu, Madan and Wang published in the \ Journal of Computational Finance early in 1999. It is self-explanatory. This \ reply was submitted to the journal - I have to edit out some of the ", StyleBox["Mathematica", FontSlant->"Italic"], " details - subject to this my reply is ", StyleBox["probably", FontSlant->"Italic"], " going to be published by the journal later in 1999." }], "Text"], Cell[TextData[{ StyleBox["Pricing Asian Options with ", FontSize->14], StyleBox["Mathematica", FontSize->14, FontSlant->"Italic"], StyleBox[":\nA Reply to:\nPricing Continuous Asian Options: A Comparison of \ Monte Carlo and Laplace Transform Inversion Methods, by Fu et al, JCF, 1999", FontSize->14] }], "Text"], Cell[CellGroupData[{ Cell["Introduction", "Subsubsection"], Cell[TextData[{ "In a recent paper, Fu, Madan and Wang (1999) have made a very interesting \ comparison of several semi-analytical and numerical methods for the pricing \ of continously averaged Asian Options. One of the methods cited (the \"Shaw\" \ method) is based on a presentation in Chapter 10 of the book (Shaw, 1998), \ where ", StyleBox["Mathematica", FontSlant->"Italic"], " is used to simplify and evaluate the Geman-Yor (1993) description of \ Asian options. In their paper, Fu et al suggest that the \"Shaw\" approach \ can give answers that are in error by an order of magnitude, and/or is highly \ inefficient. Here these claims are rebutted, and we show how-precision \ answers may be obtained from ", StyleBox["Mathematica", FontSlant->"Italic"], " 3.0 when the inversion method is properly applied. This is in a computing \ framework where the full model takes no more than fourteen lines of code. \ Furthermore, a straightforward but time-consuming Monte-Carlo analysis \ suggests that the ", StyleBox["Mathematica", FontSlant->"Italic"], " approach may be highly accurate." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["2. Recap of the Geman-Yor model", "Subsubsection"], Cell[TextData[{ "An excellent description of this model is given by Fu ", StyleBox["et al", FontSlant->"Italic"], ", so only the briefest of summaries will be given. We are investigating \ the model of the continuously and arithmetically averaged Asian Call given by \ Geman and Yor (1993) (henceforth abbreviated as GY), as also summarized by \ Eydeland and Geman (1995). Suppose that the current time is ", Cell[BoxData[ \(TraditionalForm\`t\)]], ", and that the option matures at a time ", Cell[BoxData[ \(TraditionalForm\`T > t\)]], ". The averaging is arithmetic, continuous, and began at a time ", Cell[BoxData[ \(TraditionalForm\`t\_0 \[LessEqual] t\)]], ". Suppose that the known average value of the underlying over the time \ interval ", Cell[BoxData[ \(TraditionalForm\`\([t\_0, \ t]\)\)]], " is ", Cell[BoxData[ \(TraditionalForm\`ES\)]], ". GY define the following changes of variables, as also given by Shaw \ (1998), and presented here as inputs in ", StyleBox["Mathematica", FontSlant->"Italic"], "'s StandardForm:" }], "Text"], Cell[BoxData[{ \(\(\[Tau][T_, \ t_, \ \[Sigma]_]\ := \ \[Sigma]^2\ \((T - t)\)/4;\)\), "\n", \(\(\[Nu][r_, \ q_, \ \[Sigma]_]\ := \ 2 \((r - q)\)/\[Sigma]^2\ - \ 1;\)\), "\n", \(\(\[Alpha][S_, \ ES_, \ K_, \ \[Sigma]_, \ T_, \ t_, \ to_] := \ \[Sigma]^2/\((4*S)\) \((K*\((T - to)\)\ - \ \((t - to)\)* ES)\);\)\), "\n", \(\[Mu][\[Nu]_, \ p_]\ := \ Sqrt[\[Nu]^2\ + \ 2*p]\)}], "Input"], Cell["The value of the average price option is then given by", "Text"], Cell[BoxData[ \(TraditionalForm\`\(\[ExponentialE]\^\(\(-r\)\ \((T - t)\)\)\ 4\ S\ \(C(\ \[Tau], \ \[Nu], \[Alpha])\)\)\/\(\((T - t\_0)\)\ \[Sigma]\^2\)\)], \ "NumberedEquation"], Cell[TextData[{ "The remaining function ", Cell[BoxData[ \(TraditionalForm\`C[\[Nu], \ \[Tau], \ \[Alpha]]\)]], " is not given explicitly, but GY give its Laplace transform, " }], "Text"], Cell[BoxData[ \(TraditionalForm\`U( p, \[Nu], \[Alpha]) = \[Integral]\_0\%\[Infinity]\( C(\[Tau], \ \[Nu], \[Alpha])\)\ \(\[ExponentialE]\^\(\(-p\)\ \ \[Tau]\)\) \[DifferentialD]\[Tau]\)], "NumberedEquation"], Cell["as an integral:", "Text"], Cell[BoxData[ \(TraditionalForm\`U( p, \[Nu], \[Alpha]) = \(\[Integral]\_0\%\(1\/\(2\ \[Alpha]\)\)\(x\^\(\ \(\[Mu] - \[Nu]\)\/2 - 2\)\ \((1 - 2\ \[Alpha]\ x)\)\^\(\(\[Mu] + \[Nu]\)\/2 \ + 1\)\ \[ExponentialE]\^\(-x\)\) \[DifferentialD]x\)\/\(p\ \((p - 2\ \[Nu] - \ 2)\)\ \(\[CapitalGamma](\(\[Mu] - \[Nu]\)\/2 - 1)\)\)\)], "NumberedEquation"], Cell[TextData[{ "where ", Cell[BoxData[ \(TraditionalForm\`\[Mu]\)]], " is as given above as a function of ", Cell[BoxData[ \(TraditionalForm\`p\)]], " and ", Cell[BoxData[ \(TraditionalForm\`\[Nu]\)]], ". GY develop a series description of the transform and show how it can be \ inverted. We shall now explore how this can be managed and simplified in ", StyleBox["Mathematica", FontSlant->"Italic"], "." }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell[TextData[{ "3.", StyleBox[" Mathematica", FontSlant->"Italic"], " Implementation of Arithmetic Asian " }], "Subsubsection"], Cell["\<\ We have already done the first part of the translation to software \ - we first entered the definitions of the various basic functions. Now we \ enter the definition of the integral that is part of the transform, and \ request immediate evaluation. The use of the [[2]] notation is to extract the \ answer relevant to parameters of interest:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(F[ p_, \[Mu]_, \ \[Nu]_, \[Alpha]_] = \[Integral]\_0\%\(1\/\(2\ \ \[Alpha]\)\)x\^\(\(\[Mu] - \[Nu]\)\/2 - 2\)\ \((1 - 2\ \[Alpha]\ x)\)\^\(\(\ \[Mu] + \[Nu]\)\/2 + 1\)\ Exp[\(-x\)] \[DifferentialD]x;\)\), "\n", \(G[p_, \[Mu]_, \ \ \[Nu]_, \ \[Alpha]_]\ = \ \(F[ p, \[Mu], \ \[Nu], \[Alpha]]\)[\([2]\)]\), "\n", \(\)}], "Input"], Cell[BoxData[ \(\(1\/Gamma[ 1 + \[Mu]]\) \((2\^\(1\/2\ \((2 - \[Mu] + \[Nu])\)\)\ \ \[Alpha]\^\(1\/2\ \((2 - \[Mu] + \[Nu])\)\)\ Gamma[ 1\/2\ \((\(-2\) + \[Mu] - \[Nu])\)]\ Gamma[ 1\/2\ \((4 + \[Mu] + \[Nu])\)]\ Hypergeometric1F1[ 1\/2\ \((\(-2\) + \[Mu] - \[Nu])\), 1 + \[Mu], \(-\(1\/\(2\ \[Alpha]\)\)\)])\)\)], "Output"] }, Open ]], Cell["\<\ There are further cancellations when we insert the other terms that \ make up the transform - we also present the result in traditional \ mathematical notation:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(U[p_, \[Mu]_, \[Nu]_, \[Alpha]_] = Simplify[G[p, \[Mu], \ \[Nu], \[Alpha]]\/\(p\ \((p - 2\ \[Nu] - 2)\)\ \ Gamma[\(\[Mu] - \[Nu]\)\/2 - 1]\)]; TraditionalForm[U[p, \[Mu], \[Nu], \[Alpha]]]\)], "Input"], Cell[BoxData[ FormBox[ FractionBox[ RowBox[{\(2\^\(1\/2\ \((\(-\[Mu]\) + \[Nu] + 2)\)\)\), " ", \(\[Alpha]\^\(1\/2\ \((\(-\[Mu]\) + \[Nu] + 2)\)\)\), " ", \(\[CapitalGamma](1\/2\ \((\[Mu] + \[Nu] + 4)\))\), " ", TagBox[ RowBox[{\(\(\(\[ThinSpace]\)\(\_1\)\) F\_1\), "(", RowBox[{ TagBox[\(1\/2\ \((\[Mu] - \[Nu] - 2)\)\), (Editable -> True)], ";", TagBox[\(\[Mu] + 1\), (Editable -> True)], ";", TagBox[\(-\(1\/\(2\ \[Alpha]\)\)\), (Editable -> True)]}], ")"}], InterpretTemplate[ Hypergeometric1F1[ #, #2, #3]&]]}], \(p\ \((p - 2\ \[Nu] - 2)\)\ \(\[CapitalGamma](\[Mu] + 1)\)\)], TraditionalForm]], "Output"] }, Open ]], Cell[TextData[{ "We now have the ingredients to build the ", StyleBox["Mathematica", FontSlant->"Italic"], " model of the arithmetic average price Asian Call. In the following the \ Laplace transform inversion is done by direct numerical integration along the \ truncated Bromwich contour. This contour is a simple vertical line to the \ right of any finite singularities. In Shaw (1998), the truncation is set \ initially at a value of ", Cell[BoxData[ \(TraditionalForm\`500\)]], ". However, I issued the following warning: \"", StyleBox["readers may need to experiment and increase the integration range \ for peculiar parameter values", FontSlant->"Italic"], "\". That is, the integration range must be taken to be long enough that \ the results have stabilized. The inaccurate results cited by Fu et al in \ their Table 4 arise solely from using a truncation that is too short - the \ default value of 500 can easily be seen to be too small for low volatility \ cases by plotting the absolute value of the transform. To emphasize the role \ of the integration truncation parameter, we here make it an explicit argument \ of the option valuation function, and also parametrize the number of \ recursive subdivisions of the range needed - we may also need to increase \ this as the integration range is stretched. " }], "Text"], Cell[BoxData[ \(Off[NIntegrate::slwcon]\)], "Input"], Cell[BoxData[ \(AriAsianPriceCall[S_, \ ES_, \ K_, \ r_, \ q_, \ \[Sigma]_, \ T_, \ t_, \ to_, \ truncation_, \ recursion_] := \n\t Module[{ti = \[Tau][T, \ t, \ \[Sigma]], n = \[Nu][r, \ q, \ \[Sigma]], a\ = \ \[Alpha][S, ES, K, \[Sigma], T, t, to], \ contour}, \n\t contour\ = \ 2 n + 3; \n\t ac\ = \ Re[\ 1/\((2\ Pi)\)* NIntegrate[\t U[\((contour + I\ p)\), \[Mu][n, \((contour + I\ p)\)], n, a]* Exp[\((contour + I\ p)\)*ti], {p, \ \(-truncation\), \ truncation}, \ MaxRecursion\ -> \ recursion]]; \n\ Exp[\(-r\)*\((T\ - \ t)\)]*4*S/\((\((T\ - \ to)\)*\[Sigma]^2)\)* ac]\)], "Input"], Cell[TextData[{ "In their paper, Fu et al present, in Table 4, a list of evaluations for a \ set of parameter values with a common strike set at ", Cell[BoxData[ \(TraditionalForm\`K = 2\)]], ". Here are the first three rows with a truncation of ", Cell[BoxData[ \(TraditionalForm\`500\)]], ", and then 750 and 1000." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Table[ AriAsianPriceCall[1.9, 0, 2, 0.05, \ 0, \ 0.5, \ 1, 0, 0, \ trunc, \ 11], \ {trunc, \ 500, \ 1000, \ 250}]\)], "Input"], Cell[BoxData[ \({0.193173995646941634`, 0.193173800595474354`, 0.193173790055351304`}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Table[ AriAsianPriceCall[2.0, 0, 2, 0.05, \ 0, \ 0.5, \ 1, 0, 0, \ trunc, \ 11], \ {trunc, \ 500, \ 1000, \ 250}]\)], "Input"], Cell[OutputFormData["\<\ {0.24641675372617, 0.2464156967034517, \ 0.2464156902315199}\ \>", "\<\ {0.246417, 0.246416, 0.246416}\ \>"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Table[ AriAsianPriceCall[2.1, 0, 2, 0.05, \ 0, \ 0.5, \ 1, 0, 0, \ trunc, \ 11], \ {trunc, \ 500, \ 1000, \ 250}]\)], "Input"], Cell[OutputFormData["\<\ {0.3062225269467049, 0.3062203525894511, \ 0.3062203648981713}\ \>", "\<\ {0.306223, 0.30622, 0.30622}\ \>"], "Output"] }, Open ]], Cell["\<\ The values of 0.193, 0.246 and 0.306 quoted by Fu et al as arising \ from this method therefore represent outputs that are stable as a function of \ increasing truncation. These same values were given by myself in Shaw (1998). \ The remaining four rows of Table 4 correspond to (in some cases a computation \ timing is reported)\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Table[ AriAsianPriceCall[2.0, 0, 2, 0.02, \ 0, \ 0.1, \ 1, 0, 0, \ trunc, \ 11], \ {trunc, \ 500, \ 1000, \ 250}]\)], "Input"], Cell[OutputFormData["\<\ {0.5203045206368673, 0.3512772960505013, \ 0.2670797173090095}\ \>", "\<\ {0.520305, 0.351277, 0.26708}\ \>"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Table[ AriAsianPriceCall[2.0, 0, 2, 0.18, \ 0, \ 0.3, \ 1, 0, 0, \ trunc, \ 11], \ {trunc, \ 500, \ 1000, \ 250}]\)], "Input"], Cell[OutputFormData["\<\ {0.2168750681750619, 0.2176886177911078, \ 0.2183855185367787}\ \>", "\<\ {0.216875, 0.217689, 0.218386}\ \>"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Table[ AriAsianPriceCall[2.0, 0, 2, 0.0125, \ 0, \ 0.25, \ 2, 0, 0, \ trunc, \ 11], \ {trunc, \ 500, \ 1000, \ 250}]\)], "Input"], Cell[OutputFormData["\<\ {0.1718518177998956, 0.1722847640936459, \ 0.172268068611092}\ \>", "\<\ {0.171852, 0.172285, 0.172268}\ \>"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[ Table[AriAsianPriceCall[2.0, 0, 2, 0.05, \ 0, \ 0.5, \ 2, 0, 0, \ trunc, \ 11], \ {trunc, \ 500, \ 1000, \ 250}]]\)], "Input"], Cell[BoxData[ \({7.41666666666697`\ Second, {0.35009521846796415`, 0.35009521861599474`, 0.35009521899993734`}}\)], "Output"] }, Open ]], Cell["\<\ It is clear that for most of these new examples the default \ integration range is insufficient. Working in reverse order, the last case is \ clearly stable at 0.350. Row 6 is almost stable. We consider the next few \ truncations, adjusting the subdivision parameter accordingly as we go.\ \>", \ "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Table[ AriAsianPriceCall[2.0, 0, 2, 0.0125, \ 0, \ 0.25, \ 2, 0, 0, \ trunc, \ 14], \ {trunc, \ 1250, \ 2000, \ 250}]\)], "Input"], Cell[OutputFormData["\<\ {0.1722688116665579, 0.172268727068065, \ 0.1722687435928478, 0.1722687406595836}\ \>", "\<\ {0.172269, 0.172269, \ 0.172269, 0.172269}\ \>"], "Output"] }, Open ]], Cell["\<\ So row 6 of the Shaw method indeed yields the quoted value of \ 0.172. Turning our attention to row 5, we consider\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Table[ AriAsianPriceCall[2.0, 0, 2, 0.18, \ 0, \ 0.3, \ 1, 0, 0, \ trunc, \ 14], \ {trunc, \ 1250, \ 2000, \ 250}]\)], "Input"], Cell[OutputFormData["\<\ {0.2184103405691631, 0.2183856952869513, \ 0.2183869684709966, 0.2183877356393336}\ \>", "\<\ {0.21841, 0.218386, \ 0.218387, 0.218388}\ \>"], "Output"] }, Open ]], Cell[TextData[{ "so that the truncation-stable result is 0.218(4), rather than 0.217 quoted \ by Fu ", StyleBox["et al", FontSlant->"Italic"], ". It is row four that is most problematic. For this case, within the text, \ Fu ", StyleBox["et al", FontSlant->"Italic"], " do comment on the effect of re-running the integration with larger range. \ Some experimentation leads to rather larger truncations, with stability \ achieved a truncation of 40000, with the following result:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[ AriAsianPriceCall[2.0, 0, 2, 0.02, \ 0, \ 0.1, \ 1, 0, 0, \ 40000, \ 18]]\)], "Input"], Cell[BoxData[ \({2202.08333333334316`\ Second, 0.0559860425382588733`}\)], "Output"] }, Open ]], Cell[TextData[{ "This timing is for my current \"office computer\", which is a \ PowerMacintosh G3 at 433MHz. The times recorded are therefore rather more \ reasonable than the 16200 CPU seconds reported by Fu ", StyleBox["et al", FontSlant->"Italic"], ". Nevertheless, this does raise an efficiency question in relation to \ other implementations. However, my view is that direct brute-force \ integration along the original Bromwich contour is completely inappropriate \ for the low volatility case ", Cell[BoxData[ \(TraditionalForm\`\((\[Sigma] = 0.1)\)\)]], " considered here - indeed it is probably sub-optimal for most cases. This \ particular example says rather more about the unsuitability of direct \ integration along the Bromwich contour, as ", Cell[BoxData[ \(TraditionalForm\`\[Sigma] \[RightArrow] 0\)]], ", than it does about any alleged inefficiencies in the ", StyleBox["Mathematica", FontSlant->"Italic"], " integrator. The right way of dealing with the low volatility case is \ probably to deform the contour to one with faster convergence. This is under \ investigation and will be reported elsewhere.\n\nI also have to point out \ that the matter of \"efficiency\" has as much to do with the time taken to \ code up the model as it does with execution time. In a financial environment, \ the cost of a programmer for one year is now about two orders of magnitude \ greater than the one-off cost of a state-of-the-art Pentium III computer. \ Development time is a key cost element, and the implementation here took \ about 6 hours of my time to put together. Furthermore, we should appreciate \ that the continuous-time Asian is not a regular desk-traded instrument, \ rather, it is a limiting case that is useful for testing the integrity of \ Monte Carlo simulations and PDE approaches to this problem. It's execution \ time is therefore rather unimportant.\n\nOn a related matter, assessing the \ relative accuracy of various approaches, the Monte Carlo simulations \ presented in Table 4 of Fu", StyleBox[" et al", FontSlant->"Italic"], " are of little use, as the number of samples was far too small for the \ standard error to be sufficiently low to allow any useful conclusions to be \ drawn. I re-ran some of the cases myself, using 3650 sampling points per year \ (i.e., this is my own version of their case \"MC10\", or ten fixes per day), \ and several ", StyleBox["millions", FontSlant->"Italic"], " of (antithetic) paths. This was also done in ", StyleBox["Mathematica", FontSlant->"Italic"], " using a batch processing version of the simulation algorithms given in \ Shaw (1998). The cases re-run and values obtained were:\n\nCase 1: 3.52 \ million paths, Value 0.19317, SE < 0.0002;\nCase 4: 2.68 million paths. Value \ 0.055976, SE < 0.00005;\nCase 5: 3.24 million paths. Value 0.21823, SE < \ 0.00015.\n\nwhich compare very well with the ", StyleBox["Mathematica", FontSlant->"Italic"], " continuum values of 0.19317, 0.055986, and 0.21839. (A copy of the \ notebook used to generate these results is available on request from the \ author.) This comparison, and an inspection of the other results in Fu's \ Table 4, does hint that the ", StyleBox["Mathematica", FontSlant->"Italic"], " implementation might be more accurate than any of the other schemes \ presented by Fu ", StyleBox["et al", FontSlant->"Italic"], ", though it would require a further investigation of the MC100 case, and, \ preferably, an understanding of an analogue of the \"Euler-Maclaurin\" error \ formula, for integrating ", StyleBox["random", FontSlant->"Italic"], " walks, to nail this down. But there is certainly no evidence to suggest \ that the ", StyleBox["Mathematica", FontSlant->"Italic"], " implementation of the Geman-Yor model is anything other than a \ high-precision implementation. " }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["References", "Subsubsection"], Cell[TextData[{ "Eydeland, A. and Geman, H., 1995, Asian options revisited: inverting the \ Laplace transform, ", StyleBox["RISK Magazine", FontSlant->"Italic"], ", March.\n\nFu, M.C., Madan, D.B. and Wang, T., 1999, Pricing Continuous \ Asian Options: A Comparison of Monte Carlo and Laplace Transform Inversion \ Methods, Journal of Computational Finance.\n\nGeman, H. and Yor, M., 1993, \ Bessel processes, Asian options, and perpetuities, ", StyleBox["Mathematical Finance", FontSlant->"Italic"], ", 3, p. 349.\n\nShaw, W.T., 1998, Modelling Financial Derivatives with", StyleBox[" Mathematica", FontSlant->"Italic"], ", Cambridge University Press." }], "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Implied Volatility - yet more nonsense...", "Subsection"], Cell[TextData[{ "I have been continuing to amuse myself in my spare time exploring the bad \ behaviour of the \"implied volatility\" construction. In the book I had a \ good rant in Chapter 1 about the unstabled/multivalued nature of the \ valuation as a function of ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\)]], ", and highlighted the particularly bad behaviour of barrier options in \ this respect. It is a fascinating exercise to pursue this question for simple \ European binary options, for in this case the calculation (including the \ multi-valuedness) is analytically tractable using only the simple theory of \ quadratic equations. (No ", StyleBox["FindRoot", FontFamily->"Courier", FontWeight->"Bold"], " or Newton-Raphson needed). In the book the reader was encouraged to \ pursue the corresponding analytics for power and log options. The binary \ analysis goes as follows.\n\nThe value of a European Binary Call option is" }], "Text"], Cell[BoxData[ \(TraditionalForm\`C\_B = B\ \[ExponentialE]\^\(\(-r\)\ t\)\ Norm\ \((d\_2)\)\)], "DisplayFormula"], Cell["and that for a Put is", "Text"], Cell[BoxData[ \(TraditionalForm\`P\_B = B\ \[ExponentialE]\^\(\(-r\)\ t\)\ \(Norm(\(-\ d\_2\))\)\)], "DisplayFormula"], Cell[TextData[{ "where ", Cell[BoxData[ \(TraditionalForm\`d\_2\)]], "is the usual thing, which we write in the form" }], "Text"], Cell[BoxData[ \(TraditionalForm\`d\_2 = \[Alpha]\/\(\[Sigma]\ \@t\) - \(\[Sigma]\ \@t\)\ \/2\)], "DisplayFormula"], Cell["where", "Text"], Cell[BoxData[ \(TraditionalForm\`\[Alpha] = log(\(S\ \[ExponentialE]\^\(\(-q\)\ t\)\)\/\(K\ \[ExponentialE]\^\(\(-r\ \)\ t\)\))\)], "DisplayFormula"], Cell[TextData[{ "Now suppose we are given market prices ", Cell[BoxData[ \(TraditionalForm\`C\_M\)]], " or ", Cell[BoxData[ \(TraditionalForm\`P\_M\)]], " for such instruments. Provided, in each case" }], "Text"], Cell[BoxData[ \(TraditionalForm\`0 < C\_M < B\ \[ExponentialE]\^\(\(-r\)\ t\)\)], "DisplayFormula"], Cell[BoxData[ \(TraditionalForm\`0 < P\_M < B\ \[ExponentialE]\^\(\(-r\)\ t\)\)], "DisplayFormula"], Cell[TextData[{ "the pricing formula can be partially inverted to find ", Cell[BoxData[ \(TraditionalForm\`d\_2\)]], "as a function of market price. We just have, respectively" }], "Text"], Cell[BoxData[ \(TraditionalForm\`d\_2 = Norm\^\(-1\)\ \((C\_M\ \[ExponentialE]\^\(r\ t\)/ B)\)\)], "DisplayFormula"], Cell["and, for a Put:", "Text"], Cell[BoxData[ \(TraditionalForm\`d\_2 = \(-Norm\^\(-1\)\)\ \((P\_M\ \ \[ExponentialE]\^\(r\ t\)/B)\)\)], "DisplayFormula"], Cell[TextData[{ "The ", StyleBox["Mathematica", FontSlant->"Italic"], " implementation of the inverse error function is (Ch. 21, p. 401):" }], "Text"], Cell[BoxData[ \(Convert[x_] := \@2\ InverseErf[2\ x - 1]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(\(Plot[Convert[x], \ {x, \ 0, \ 1}, \ PlotRange\ \[Rule] \ {\(-3\), \ 3}];\)\)], "Input"], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .61803 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.952381 0.309017 0.103006 [ [.21429 .29652 -9 -9 ] [.21429 .29652 9 0 ] [.40476 .29652 -9 -9 ] [.40476 .29652 9 0 ] [.59524 .29652 -9 -9 ] [.59524 .29652 9 0 ] [.78571 .29652 -9 -9 ] [.78571 .29652 9 0 ] [.97619 .29652 -3 -9 ] [.97619 .29652 3 0 ] [.01131 0 -12 -4.5 ] [.01131 0 0 4.5 ] [.01131 .10301 -12 -4.5 ] [.01131 .10301 0 4.5 ] [.01131 .20601 -12 -4.5 ] [.01131 .20601 0 4.5 ] [.01131 .41202 -6 -4.5 ] [.01131 .41202 0 4.5 ] [.01131 .51503 -6 -4.5 ] [.01131 .51503 0 4.5 ] [.01131 .61803 -6 -4.5 ] [.01131 .61803 0 4.5 ] [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 g .25 Mabswid [ ] 0 setdash .21429 .30902 m .21429 .31527 L s [(0.2)] .21429 .29652 0 1 Mshowa .40476 .30902 m .40476 .31527 L s [(0.4)] .40476 .29652 0 1 Mshowa .59524 .30902 m .59524 .31527 L s [(0.6)] .59524 .29652 0 1 Mshowa .78571 .30902 m .78571 .31527 L s [(0.8)] .78571 .29652 0 1 Mshowa .97619 .30902 m .97619 .31527 L s [(1)] .97619 .29652 0 1 Mshowa .125 Mabswid .07143 .30902 m .07143 .31277 L s .11905 .30902 m .11905 .31277 L s .16667 .30902 m .16667 .31277 L s .2619 .30902 m .2619 .31277 L s .30952 .30902 m .30952 .31277 L s .35714 .30902 m .35714 .31277 L s .45238 .30902 m .45238 .31277 L s .5 .30902 m .5 .31277 L s .54762 .30902 m .54762 .31277 L s .64286 .30902 m .64286 .31277 L s .69048 .30902 m .69048 .31277 L s .7381 .30902 m .7381 .31277 L s .83333 .30902 m .83333 .31277 L s .88095 .30902 m .88095 .31277 L s .92857 .30902 m .92857 .31277 L s .25 Mabswid 0 .30902 m 1 .30902 L s .02381 0 m .03006 0 L s [(-3)] .01131 0 1 0 Mshowa .02381 .10301 m .03006 .10301 L s [(-2)] .01131 .10301 1 0 Mshowa .02381 .20601 m .03006 .20601 L s [(-1)] .01131 .20601 1 0 Mshowa .02381 .41202 m .03006 .41202 L s [(1)] .01131 .41202 1 0 Mshowa .02381 .51503 m .03006 .51503 L s [(2)] .01131 .51503 1 0 Mshowa .02381 .61803 m .03006 .61803 L s [(3)] .01131 .61803 1 0 Mshowa .125 Mabswid .02381 .0206 m .02756 .0206 L s .02381 .0412 m .02756 .0412 L s .02381 .0618 m .02756 .0618 L s .02381 .0824 m .02756 .0824 L s .02381 .12361 m .02756 .12361 L s .02381 .14421 m .02756 .14421 L s .02381 .16481 m .02756 .16481 L s .02381 .18541 m .02756 .18541 L s .02381 .22661 m .02756 .22661 L s .02381 .24721 m .02756 .24721 L s .02381 .26781 m .02756 .26781 L s .02381 .28842 m .02756 .28842 L s .02381 .32962 m .02756 .32962 L s .02381 .35022 m .02756 .35022 L s .02381 .37082 m .02756 .37082 L s .02381 .39142 m .02756 .39142 L s .02381 .43262 m .02756 .43262 L s .02381 .45322 m .02756 .45322 L s .02381 .47383 m .02756 .47383 L s .02381 .49443 m .02756 .49443 L s .02381 .53563 m .02756 .53563 L s .02381 .55623 m .02756 .55623 L s .02381 .57683 m .02756 .57683 L s .02381 .59743 m .02756 .59743 L s .25 Mabswid .02381 0 m .02381 .61803 L s 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .5 Mabswid .02513 0 m .02605 .01793 L .02729 .03271 L .02846 .04282 L .03053 .05622 L .03279 .06711 L .0379 .08492 L .04262 .09693 L .05224 .11506 L .06244 .12936 L .0825 .15025 L .10458 .16755 L .14487 .19157 L .18364 .20984 L .22486 .22635 L .26457 .24045 L .30277 .25289 L .34341 .26529 L .38254 .27665 L .42412 .28831 L .46419 .29929 L .50274 .30976 L .54374 .3209 L .58323 .33176 L .6212 .34245 L .66163 .35425 L .70054 .36619 L .7419 .37979 L .78174 .39418 L .82007 .4098 L .86085 .42948 L .88111 .44112 L .90012 .45383 L .91851 .46868 L .93787 .48907 L .94742 .50243 L .95247 .51106 L .95786 .5222 L .96284 .53529 L .96736 .55154 L .96954 .5622 L .97068 .56913 L .9719 .57804 L .97296 .58792 L .97413 .60296 L s .97413 .60296 m .97483 .61803 L s % End of Graphics MathPictureEnd \ \>"], "Graphics", ImageSize->{288, 177.938}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCache->GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHgeoo`004Woo00<007ooOol07Woo0P00jgoo000BOol00`00Oomoo`0POol2003YOol000Yo o`<000Eoo`03001oogoo029oo`<00>Ioo`002goo00<007ooOol017oo00<007ooOol09Goo0P00i7oo 0003Ool50003Ool00`00Oomoo`04Ool3000WOol2003ROol000]oo`03001oogoo00Aoo`03001oogoo 02Uoo`800>1oo`002goo00<007ooOol017oo00<007ooOol0:goo0P00gWoo000:Ool20006Ool00`00 Oomoo`0]Ool3003KOol000]oo`03001oogoo00Aoo`03001oogoo031oo`800=Uoo`004Woo00<007oo Ool0Woo0`00cWoo000BOol00`00Oomoo`0mOol3003;Ool0019oo`03001oogoo041oo`<00Goo000:Ool30005Ool00`00Oomoo`3BOol3000fOol000]oo`03001o ogoo00Aoo`03001oogoo0=Eoo`8003Aoo`002goo00<007ooOol017oo0`00egoo0P005oo`8002Qoo`004Woo0P00i7oo0P009Woo000BOol00`00Oomo o`3UOol00`00Oomoo`0SOol0019oo`03001oogoo0>Ioo`8002=oo`004Woo00<007ooOol0j7oo0P00 8Goo000BOol00`00Oomoo`3ZOol00`00Oomoo`0NOol0019oo`800>aoo`8001ioo`004Woo00<007oo Ool0kGoo00<007ooOol06goo000BOol00`00Oomoo`3^Ool00`00Oomoo`0JOol0019oo`03001oogoo 0>moo`03001oogoo01Uoo`004Woo00<007ooOol0l7oo00<007ooOol067oo000BOol00`00Oomoo`3` Ool00`00Oomoo`0HOol0019oo`800?9oo`03001oogoo01Moo`004Woo00<007ooOol0lWoo00<007oo Ool05Woo000BOol00`00Oomoo`3cOol00`00Oomoo`0EOol0019oo`03001oogoo0?Aoo`03001oogoo 01Aoo`004Woo00<007ooOol0mGoo00<007ooOol04goo000BOol2003fOol00`00Oomoo`0COol0019o o`03001oogoo0?Ioo`03001oogoo019oo`004Woo00<007ooOol0mgoo00<007ooOol04Goo000BOol0 0`00Oomoo`3hOol00`00Oomoo`0@Ool000Uoo`D000Aoo`03001oogoo0?Qoo`03001oogoo011oo`00 2Woo00@007ooOol000Aoo`03001oogoo0?Uoo`03001oogoo00moo`002goo00<007ooOol017oo0`00 nGoo00<007ooOol03goo000Ool000Uo o`05001oogooOol00004Ool00`00Oomoo`3kOol00`00Oomoo`0=Ool000Uoo`05001oogooOol00004 Ool00`00Oomoo`3kOol00`00Oomoo`0=Ool000Yoo`<000Eoo`03001oogoo0?]oo`03001oogoo00eo o`004Woo00<007ooOol0o7oo00<007ooOol037oo000BOol2003mOol00`00Oomoo`0"], ImageRangeCache->{{{0, 287}, {176.938, 0}} -> {-0.0717547, -3.16079, \ 0.00386416, 0.0357276}}] }, Open ]], Cell[TextData[{ "So ", Cell[BoxData[ \(TraditionalForm\`d\_2\)]], " is given, and what we want is ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\)]], ". We have a relation between ", Cell[BoxData[ \(TraditionalForm\`d\_2, \ \[Sigma], \ \[Alpha]\)]], " which is equivalent to a quadratic equation:" }], "Text"], Cell[BoxData[ \(TraditionalForm\`t\ \[Sigma]\^2 + 2\ \@t\ d\_2\ \[Sigma] - 2\ \[Alpha] = 0\)], "DisplayFormula"], Cell["This has (possibly complex) solutions of the form", "Text"], Cell[BoxData[ \(TraditionalForm\`\[Sigma] = \(\(-d\_2\) \[PlusMinus] \@\(d\_2\%2 + 2\ \ \[Alpha]\)\)\/\@t\)], "DisplayFormula"], Cell[TextData[{ "and the product of the two solutions is ", Cell[BoxData[ \(TraditionalForm\`\(-2\) \[Alpha]/t\)]], ". We observe immediately that provided ", Cell[BoxData[ \(TraditionalForm\`\[Alpha] > 0\)]], ", there is a unique positive solution of the quadratic for ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\)]], ", given by taking the upper (+) sign of the square root in the solution. \ The positivity condition on ", Cell[BoxData[ \(TraditionalForm\`\[Alpha]\)]], " is equivalent to the condition" }], "Text"], Cell[BoxData[ \(TraditionalForm\`S\ \[ExponentialE]\^\(\(-q\)\ t\) > K\ \[ExponentialE]\^\(\(-r\)\ t\)\)], "DisplayFormula"], Cell["\<\ When this condition fails (e.g. out of the money call) there is \ trouble. Expressed as a function of \[Sigma]\ \>", "Text"], Cell[BoxData[ FormBox[ RowBox[{ FractionBox[\(\[PartialD]d\_2\), \(\[PartialD]\[Sigma]\), MultilineFunction->None], "=", \(\(-\(\[Alpha]\/\(\[Sigma]\^2\ \@t\)\)\) - \@t\/2\)}], TraditionalForm]], "DisplayFormula"], Cell["and this will equal zero when", "Text"], Cell[BoxData[ \(TraditionalForm\`\[Alpha] = \(-1\)\/2\ \[Sigma]\^2\ t\)], \ "DisplayFormula"], Cell[TextData[{ "This is not possible when ", Cell[BoxData[ \(TraditionalForm\`\[Alpha] > 0\)]], ", but when ", Cell[BoxData[ \(TraditionalForm\`\[Alpha] < 0\)]], " there is a critical value of volatility:" }], "Text"], Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_C\^2 = \(\(-\(\(2\ \[Alpha]\)\/t\)\) = \(-\(\ \(2\ \(log(\(S\ \[ExponentialE]\^\(\(-q\)\ t\)\)\/\(K\ \ \[ExponentialE]\^\(\(-r\)\ t\)\))\)\)\/t\)\)\)\)], "DisplayFormula"], Cell[TextData[{ "where there is a maximum value of ", Cell[BoxData[ \(TraditionalForm\`d\_2\)]], ", and hence a maximum possible Call price, which we call ", Cell[BoxData[ \(TraditionalForm\`C\_crit\)]], ", and a minimum possible Put price, ", Cell[BoxData[ \(TraditionalForm\`P\_crit\)]], ". We proceed further for the case of a Call - the Put goes similarly.\n\n\ If in the case ", Cell[BoxData[ \(TraditionalForm\`\[Alpha] < 0\)]], " the market call price exceeds that given by ", Cell[BoxData[ \(TraditionalForm\`\[Sigma]\_c\)]], ", there is no implied volatility consistent with the given market price. \ If it is less than this critical value, there are two implied volatilities. \n\ \nSo in total there are three cases for a Call provided ", Cell[BoxData[ \(TraditionalForm\`0 < C\_M < B\ \[ExponentialE]\^\(\(-r\)\ t\)\)]], ":\n\n(i) ", Cell[BoxData[ \(TraditionalForm\`\[Alpha] > 0\)]], ": a unique real and positive implied volatility;\n(ii) ", Cell[BoxData[ \(TraditionalForm\`\(\(\[Alpha]\)\(<\)\(0\)\(\ \)\)\)]], "and ", Cell[BoxData[ \(TraditionalForm\`C\_M > \ C\_crit\)]], ": no implied volatility;\n(ii) ", Cell[BoxData[ \(TraditionalForm\`\(\(\[Alpha]\)\(<\)\(0\)\(\ \)\)\)]], "and ", Cell[BoxData[ \(TraditionalForm\`C\_M < \ C\_crit\)]], ": two implied volatilitities." }], "Text"], Cell["This can all be implemented very easily:", "Text"], Cell["InverseN[x_] := Sqrt[2]*InverseErf[2*x - 1]; ", "Input"], Cell["\<\ CallDTwo[CallMkt_, B_, r_, t_] := InverseN[CallMkt*Exp[r*t]/B]; PutDTwo[PutMkt_, B_, r_, t_] := -InverseN[PutMkt*Exp[r*t]/B]; \ \>", "Input"], Cell["Alpha[S_, K_, r_, q_, t_] := Log[S*Exp[(r - q)*t]/K]; ", "Input"], Cell["\<\ CallMax[B_, S_, K_, r_, q_, t_] := Module[{a = Alpha[S, K, r, q, \ t]}, If[a >= 0, B*Exp[-r*t], B*Exp[-r*t]*Norm[-Sqrt[-2*a]]]]; \ \>", "Input"], Cell["\<\ PutMin[B_, S_, K_, r_, q_, t_] := Module[{a = Alpha[S, K, r, q, \ t]}, If[a >= 0, 0, B*Exp[-r*t]*Norm[Sqrt[-2*a]]]]; \ \>", "Input"], Cell["\<\ BinaryCallImpVol[CallMkt_, B_, S_, K_, r_, q_, t_] := Which[ CallMkt >= B*Exp[-r*t], \"Market Price Far Too High\", CallMkt <= 0, \"Market Price Far Too Low\", True, \tModule[{dtwo, alpha, root, rawvol, realvol}, \tdtwo = CallDTwo[CallMkt, B, r, t]; \talpha = Alpha[S, K, r, q, t]; \troot = Sqrt[dtwo^2 + 2*alpha]; \tWhich[ \talpha >= 0, \t-dtwo/Sqrt[t] + root/Sqrt[t], \tTrue, \tIf[CallMkt > CallMax[B, S, K, r, q, t], \t\"Market Price Too High\", \t-dtwo/Sqrt[t] + root/Sqrt[t]*{1, -1}]]] \t]; \ \>", "Input"], Cell["\<\ BinaryPutImpVol[PutMkt_, B_, S_, K_, r_, q_, t_] := Which[ PutMkt >= B*Exp[-r*t], \"Market Price Far Too High\", PutMkt <= 0, \"Market Price Far Too Low\", True, Module[{dtwo, alpha, root, rawvol, realvol}, dtwo = PutDTwo[PutMkt, B, r, t]; alpha = Alpha[S, K, r, q, t]; root = Sqrt[dtwo^2 + 2*alpha]; Which[ alpha >= 0, -dtwo/Sqrt[t] + root/Sqrt[t], True, If[PutMkt < PutMin[B, S, K, r, q, t], \"Market Price Too Low\", -dtwo/Sqrt[t] + root/Sqrt[t]*{1, -1}]]] ];\ \>", "Input"], Cell["Here are some examples with a Call:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BinaryCallImpVol[10, \ 10, \ 100, \ 100, \ 0.05, \ 0, \ 1]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`"Market Price Far Too High"\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(BinaryCallImpVol[5, \ 10, \ 100, \ 100, \ 0.05, \ 0, \ 1]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`0.2583962967732527`\)], "Output"] }, Open ]], Cell["Going further in the money is fine:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BinaryCallImpVol[5, \ 10, \ 105, \ 100, \ 0.05, \ 0, \ 1]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`0.38482409233202386`\)], "Output"] }, Open ]], Cell["\<\ When we come out of the money a quite plausible market price is has \ no matching implied vol within the model:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BinaryCallImpVol[4, \ 10, \ 90, \ 100, \ 0.05, \ 0, \ 1]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`"Market Price Too High"\)], "Output"] }, Open ]], Cell["And which of the following implied vols is the \"right\" one?", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(BinaryCallImpVol[3.5, \ 10, \ 90, \ 100, \ 0.05, \ 0, \ 1]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`{0.3925385023555086`, 0.28206413040057976`}\)], "Output"] }, Open ]], Cell["\<\ If you do not believe this makes sense, try calculating and \ plotting the call value as a function of \[Sigma] with these parameters, \ using the following code lifted from Chapter 6:\ \>", "Text"], Cell["\<\ dtwo[s_, v_, k_, t_, r_, q_] := ((r - q)*t + Log[s/k])/(v*Sqrt[t]) \ - (v*Sqrt[t])/2; \ \>", "Input"], Cell["\<\ BinaryCall[B_, S_, K_, v_, r_, q_, t_] := B*Exp[-r*t]*Norm[dtwo[S, \ v, K, t, r, q]]; \ \>", "Input"], Cell[CellGroupData[{ Cell[BoxData[ \({BinaryCall[10, \ 90, \ 100, \ 0.282064, \ 0.05, \ 0, \ 1], \ BinaryCall[10, \ 90, \ 100, \ 0.392539, \ 0.05, \ 0, \ 1]}\)], "Input"], Cell[BoxData[ \(TraditionalForm\`{3.4999999084509263`, 3.4999997489501795`}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(\(Plot[ BinaryCall[10, \ 90, \ 100, \ \[Sigma], \ 0.05, \ 0, \ 1], \ {\[Sigma], \ 0.01, \ 0.5}];\)\)], "Input"], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .61803 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 1.90476 0.0147151 0.167391 [ [.21429 .00222 -9 -9 ] [.21429 .00222 9 0 ] [.40476 .00222 -9 -9 ] [.40476 .00222 9 0 ] [.59524 .00222 -9 -9 ] [.59524 .00222 9 0 ] [.78571 .00222 -9 -9 ] [.78571 .00222 9 0 ] [.97619 .00222 -9 -9 ] [.97619 .00222 9 0 ] [.01131 .09841 -18 -4.5 ] [.01131 .09841 0 4.5 ] [.01131 .18211 -6 -4.5 ] [.01131 .18211 0 4.5 ] [.01131 .2658 -18 -4.5 ] [.01131 .2658 0 4.5 ] [.01131 .3495 -6 -4.5 ] [.01131 .3495 0 4.5 ] [.01131 .43319 -18 -4.5 ] [.01131 .43319 0 4.5 ] [.01131 .51689 -6 -4.5 ] [.01131 .51689 0 4.5 ] [.01131 .60058 -18 -4.5 ] [.01131 .60058 0 4.5 ] [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 g .25 Mabswid [ ] 0 setdash .21429 .01472 m .21429 .02097 L s [(0.1)] .21429 .00222 0 1 Mshowa .40476 .01472 m .40476 .02097 L s [(0.2)] .40476 .00222 0 1 Mshowa .59524 .01472 m .59524 .02097 L s [(0.3)] .59524 .00222 0 1 Mshowa .78571 .01472 m .78571 .02097 L s [(0.4)] .78571 .00222 0 1 Mshowa .97619 .01472 m .97619 .02097 L s [(0.5)] .97619 .00222 0 1 Mshowa .125 Mabswid .0619 .01472 m .0619 .01847 L s .1 .01472 m .1 .01847 L s .1381 .01472 m .1381 .01847 L s .17619 .01472 m .17619 .01847 L s .25238 .01472 m .25238 .01847 L s .29048 .01472 m .29048 .01847 L s .32857 .01472 m .32857 .01847 L s .36667 .01472 m .36667 .01847 L s .44286 .01472 m .44286 .01847 L s .48095 .01472 m .48095 .01847 L s .51905 .01472 m .51905 .01847 L s .55714 .01472 m .55714 .01847 L s .63333 .01472 m .63333 .01847 L s .67143 .01472 m .67143 .01847 L s .70952 .01472 m .70952 .01847 L s .74762 .01472 m .74762 .01847 L s .82381 .01472 m .82381 .01847 L s .8619 .01472 m .8619 .01847 L s .9 .01472 m .9 .01847 L s .9381 .01472 m .9381 .01847 L s .25 Mabswid 0 .01472 m 1 .01472 L s .02381 .09841 m .03006 .09841 L s [(0.5)] .01131 .09841 1 0 Mshowa .02381 .18211 m .03006 .18211 L s [(1)] .01131 .18211 1 0 Mshowa .02381 .2658 m .03006 .2658 L s [(1.5)] .01131 .2658 1 0 Mshowa .02381 .3495 m .03006 .3495 L s [(2)] .01131 .3495 1 0 Mshowa .02381 .43319 m .03006 .43319 L s [(2.5)] .01131 .43319 1 0 Mshowa .02381 .51689 m .03006 .51689 L s [(3)] .01131 .51689 1 0 Mshowa .02381 .60058 m .03006 .60058 L s [(3.5)] .01131 .60058 1 0 Mshowa .125 Mabswid .02381 .03145 m .02756 .03145 L s .02381 .04819 m .02756 .04819 L s .02381 .06493 m .02756 .06493 L s .02381 .08167 m .02756 .08167 L s .02381 .11515 m .02756 .11515 L s .02381 .13189 m .02756 .13189 L s .02381 .14863 m .02756 .14863 L s .02381 .16537 m .02756 .16537 L s .02381 .19885 m .02756 .19885 L s .02381 .21558 m .02756 .21558 L s .02381 .23232 m .02756 .23232 L s .02381 .24906 m .02756 .24906 L s .02381 .28254 m .02756 .28254 L s .02381 .29928 m .02756 .29928 L s .02381 .31602 m .02756 .31602 L s .02381 .33276 m .02756 .33276 L s .02381 .36624 m .02756 .36624 L s .02381 .38298 m .02756 .38298 L s .02381 .39971 m .02756 .39971 L s .02381 .41645 m .02756 .41645 L s .02381 .44993 m .02756 .44993 L s .02381 .46667 m .02756 .46667 L s .02381 .48341 m .02756 .48341 L s .02381 .50015 m .02756 .50015 L s .02381 .53363 m .02756 .53363 L s .02381 .55037 m .02756 .55037 L s .02381 .56711 m .02756 .56711 L s .02381 .58385 m .02756 .58385 L s .02381 .61732 m .02756 .61732 L s .25 Mabswid .02381 0 m .02381 .61803 L s 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .5 Mabswid .04286 .01472 m .04401 .01472 L .04506 .01472 L .04627 .01472 L .04741 .01472 L .04847 .01473 L .04945 .01475 L .05052 .01478 L .05165 .01483 L .05279 .01493 L .05402 .01509 L .05518 .01531 L .05624 .0156 L .05748 .01606 L .05883 .01672 L .0601 .01755 L .06129 .0185 L .06383 .02121 L .06622 .02467 L .07069 .03361 L .07551 .0466 L .08072 .0639 L .12201 .23088 L .14117 .29553 L .1622 .35282 L .20089 .42942 L .22001 .45728 L .24051 .48188 L .28104 .5187 L .32009 .54376 L .35765 .56133 L .39762 .57502 L .4361 .58464 L .4731 .5914 L .49365 .59431 L .5125 .59653 L .55041 .59988 L .56896 .60105 L .58924 .60201 L .60846 .60267 L .61922 .60293 L .62899 .60311 L .63374 .60317 L .63877 .60323 L .64307 .60326 L .64549 .60328 L .64779 .60329 L .64906 .6033 L .65044 .60331 L .65172 .60331 L Mistroke .65287 .60331 L .65424 .60332 L .65499 .60332 L .6557 .60332 L .65696 .60332 L .65767 .60332 L .65832 .60332 L .65951 .60332 L .66061 .60332 L .66182 .60331 L .66312 .60331 L .66576 .6033 L .66817 .60329 L .6729 .60326 L .67791 .60322 L .68691 .60311 L .6966 .60296 L .70727 .60275 L .72627 .60226 L .74672 .60159 L .78709 .59986 L .82597 .59775 L .86337 .59538 L .90317 .59253 L .94149 .58952 L .97619 .58659 L Mfstroke % End of Graphics MathPictureEnd \ \>"], "Graphics", ImageSize->{288, 177.938}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCache->GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHgOooo000@0003Ool001Eoo`03001oogoo00Moo`03001oogoo00Mo o`03001oogoo00Qoo`03001oogoo00Moo`03001oogoo00Moo`03001oogoo00Moo`03001oogoo00Qo o`03001oogoo00Moo`03001oogoo00Moo`03001oogoo00Qoo`03001oogoo00Moo`03001oogoo00Mo o`03001oogoo00Moo`03001oogoo00Qoo`03001oogoo00Moo`03001oogoo00Moo`03001oogoo00Mo o`03001oogoo00Qoo`03001oogoo00Moo`03001oogoo00Moo`03001oogoo00Moo`03001oogoo00Qo o`03001oogoo00Moo`03001oogoo00Moo`03001oogoo00Qoo`03001oogoo00Moo`005Goo00<007oo Ool027oo00<007ooOol09Goo00<007ooOol0Ool00`00Oomoo`3hOol001Eoo`03001oogoo00eoo`03001o ogoo0?Qoo`000Woo0P0017oo00<007ooOol00Woo0`001Goo00<007ooOol03Woo00<007ooOol0mgoo 00001Goo001oogoo00001goo00D007ooOomoo`0000Aoo`03001oogoo00ioo`03001oogoo0?Moo`00 00Eoo`00Oomoo`0000]oo`03001oogoo009oo`<000ioo`03001oogoo0?Moo`0000Eoo`00Oomoo`00 00]oo`03001oogoo009oo`03001oogoo00ioo`03001oogoo0?Moo`0000Eoo`00Oomoo`0000Moo`@0 00Eoo`03001oogoo00moo`03001oogoo0?Ioo`0000Eoo`00Oomoo`0000Moo`03001oogoo00Ioo`03 001oogoo00moo`03001oogoo0?Ioo`000Woo0P0027oo1@0017oo00<007ooOol03goo00<007ooOol0 mWoo000EOol2000@Ool00`00Oomoo`3fOol001Eoo`03001oogoo011oo`03001oogoo0?Eoo`005Goo 00<007ooOol047oo00<007ooOol0mGoo000EOol00`00Oomoo`0@Ool00`00Oomoo`3eOol001Eoo`03 001oogoo011oo`03001oogoo0?Eoo`005Goo0P004Woo00<007ooOol0m7oo000EOol00`00Oomoo`0A Ool00`00Oomoo`3dOol001Eoo`03001oogoo015oo`03001oogoo0?Aoo`005Goo00<007ooOol04Goo 00<007ooOol0m7oo000EOol2000COol00`00Oomoo`3cOol001Eoo`03001oogoo019oo`03001oogoo 0?=oo`005Goo00<007ooOol04Woo00<007ooOol0lgoo000EOol00`00Oomoo`0BOol00`00Oomoo`3c Ool001Eoo`03001oogoo019oo`03001oogoo0?=oo`005Goo0P0057oo00<007ooOol0lWoo000EOol0 0`00Oomoo`0COol00`00Oomoo`3bOol000eoo`<000Eoo`03001oogoo01=oo`03001oogoo0?9oo`00 3Woo00<007ooOol017oo00<007ooOol04goo00<007ooOol0lWoo000>Ool00`00Oomoo`04Ool3000D Ool00`00Oomoo`3aOol000ioo`03001oogoo00Aoo`03001oogoo01Aoo`03001oogoo0?5oo`003Woo 00<007ooOol017oo00<007ooOol057oo00<007ooOol0lGoo000=Ool20006Ool00`00Oomoo`0DOol0 0`00Oomoo`3aOol000ioo`03001oogoo00Aoo`03001oogoo01Eoo`03001oogoo0?1oo`005Goo0P00 5Woo00<007ooOol0l7oo000EOol00`00Oomoo`0EOol00`00Oomoo`3`Ool001Eoo`03001oogoo01Eo o`03001oogoo0?1oo`005Goo00<007ooOol05Woo00<007ooOol0kgoo000EOol2000GOol00`00Oomo o`3_Ool001Eoo`03001oogoo01Ioo`03001oogoo0>moo`005Goo00<007ooOol05Woo00<007ooOol0 kgoo000EOol00`00Oomoo`0GOol00`00Oomoo`3^Ool001Eoo`03001oogoo01Moo`03001oogoo0>io o`005Goo0P0067oo00<007ooOol0kWoo000EOol00`00Oomoo`0GOol00`00Oomoo`3^Ool001Eoo`03 001oogoo01Qoo`03001oogoo0>eoo`005Goo00<007ooOol067oo00<007ooOol0kGoo000EOol2000I Ool00`00Oomoo`3]Ool001Eoo`03001oogoo01Uoo`03001oogoo0>aoo`0000Aoo`00000000Aoo`03 001oogoo009oo`<000Eoo`03001oogoo01Uoo`03001oogoo0>aoo`000Woo00<007ooOol01goo00D0 07ooOomoo`0000Aoo`03001oogoo01Uoo`03001oogoo0>aoo`000Woo00<007ooOol02goo00<007oo Ool00Woo00<007ooOol06Goo00<007ooOol0k7oo0002Ool00`00Oomoo`0;Ool00`00Oomoo`02Ool3 000JOol00`00Oomoo`3[Ool0009oo`03001oogoo00Moo`@000Eoo`03001oogoo01Yoo`03001oogoo 0>]oo`0000=oo`0000002Goo00<007ooOol01Woo00<007ooOol06Woo00<007ooOol0jgoo0002Ool0 0`00Oomoo`07Ool50004Ool00`00Oomoo`0JOol00`00Oomoo`3[Ool001Eoo`8001aoo`03001oogoo 0>Yoo`005Goo00<007ooOol06goo00<007ooOol0jWoo000EOol00`00Oomoo`0KOol00`00Oomoo`3Z Ool001Eoo`03001oogoo01aoo`03001oogoo0>Uoo`005Goo00<007ooOol077oo00<007ooOol0jGoo 000EOol2000MOol00`00Oomoo`3YOol001Eoo`03001oogoo01eoo`03001oogoo0>Qoo`005Goo00<0 07ooOol07Goo00<007ooOol0j7oo000EOol00`00Oomoo`0MOol00`00Oomoo`3XOol001Eoo`8001mo o`03001oogoo0>Moo`005Goo00<007ooOol07Woo00<007ooOol0igoo000EOol00`00Oomoo`0OOol0 0`00Oomoo`3VOol001Eoo`03001oogoo01moo`03001oogoo0>Ioo`005Goo00<007ooOol07goo00<0 07ooOol0iWoo000EOol2000QOol00`00Oomoo`3UOol001Eoo`03001oogoo021oo`03001oogoo0>Eo o`0037oo1@0017oo00<007ooOol08Goo00<007ooOol0i7oo000=Ool01000Oomoo`0017oo00<007oo Ool08Goo00<007ooOol0i7oo000>Ool00`00Oomoo`04Ool3000QOol00`00Oomoo`3TOol000moo`03 001oogoo00=oo`03001oogoo029oo`03001oogoo0>=oo`0037oo00D007ooOomoo`0000Aoo`03001o ogoo029oo`03001oogoo0>=oo`0037oo00D007ooOomoo`0000Aoo`03001oogoo02=oo`03001oogoo 0>9oo`003Goo0`001Goo00<007ooOol08goo00<007ooOol0hWoo000EOol2000UOol00`00Oomoo`3Q Ool001Eoo`03001oogoo02Aoo`03001oogoo0>5oo`005Goo00<007ooOol09Goo00<007ooOol0h7oo 000EOol00`00Oomoo`0UOol00`00Oomoo`3POol001Eoo`8002Moo`03001oogoo0=moo`005Goo00<0 07ooOol09Woo00<007ooOol0ggoo000EOol00`00Oomoo`0WOol00`00Oomoo`3NOol001Eoo`03001o ogoo02Qoo`03001oogoo0=eoo`005Goo00<007ooOol0:7oo00<007ooOol0gGoo000EOol2000ZOol0 0`00Oomoo`3LOol001Eoo`03001oogoo02Uoo`03001oogoo0=aoo`005Goo00<007ooOol0:Woo00<0 07ooOol0fgoo000EOol00`00Oomoo`0ZOol00`00Oomoo`3KOol001Eoo`8002aoo`03001oogoo0=Yo o`005Goo00<007ooOol0:goo00<007ooOol0fWoo00050003Ool00`00Oomoo`02Ool30005Ool00`00 Oomoo`0/Ool00`00Oomoo`3IOol00005Ool007ooOol00007Ool01@00Oomoogoo000017oo00<007oo Ool0;7oo00<007ooOol0fGoo0002Ool00`00Oomoo`0;Ool00`00Oomoo`02Ool00`00Oomoo`0]Ool0 0`00Oomoo`3HOol000=oo`03001oogoo00Yoo`03001oogoo009oo`<002eoo`03001oogoo0=Qoo`00 00D007ooOomoo`0000Moo`@000Eoo`03001oogoo02ioo`03001oogoo0=Moo`0000D007ooOomoo`00 00Moo`03001oogoo00Ioo`03001oogoo02moo`03001oogoo0=Ioo`0000Aoo`00000000Qoo`D000Ao o`03001oogoo031oo`03001oogoo0=Eoo`005Goo0P007oo0P00cgoo000EOol00`00 Oomoo`0iOol00`00Oomoo`3goo00<007ooOol0bWoo000EOol00`00Oomoo`0lOol00`00Oomoo`39Ool001Eoo`8003ioo`03 001oogoo07oo0004Ool00`00Oomo o`05Ool40005Ool00`00Oomoo`2SOol<001IOol00005001oogooOol00007Ool00`00Oomoo`06Ool0 0`00Oomoo`3oOol9Ool00004Ool000000008Ool50004Ool00`00Oomoo`3oOol9Ool001Eoo`800?mo o`Yoo`00ogoo8Goo0000\ \>"], ImageRangeCache->{{{0, 287}, {176.938, 0}} -> {-0.0416348, -0.296358, \ 0.00194834, 0.0221703}}] }, Open ]], Cell["\<\ The extreme instability and 2-valued-ness of the inverse mapping is \ manifest, and has emerged through the simple use of the analytical theory of \ quadratic equations. As with barrier options, the problem arises when vega \ changes sign or is just very small. A common mistake is to assume that there \ is no problem with the vanilla calls and puts. Although vega is technically \ positive, it is very small for options that are deep in the money, and the \ region over which it is very small grows as maturity approaches. So inversion \ of the mapping is meaningless in these regions, and it follows that such \ portions of the vol surface, calculated off market prices, don't mean much \ either. \ \>", "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["4. Reviews", "Section"], Cell["\<\ You might like to look at the March 99 issue of RISK magazine, \ which contained a very positive review of this book. There are some \ interesting, and mostly very positive, comments on Amazon.com, which I note \ is also happy to publish anonymous comments without moderation. Feel free to \ post your own views here. (Do a book search with author = Shaw, title = \ Derivatives). \ \>", "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Version 4 Changes", "Subtitle"], Cell["\<\ Before going into a chapter by chapter analysis of the impact of \ V4, it is helpful to note that there are a few global issues which impact \ several chapters. First you should note that most of the analytical code in \ Chapters 5-13 works without modification. The main issues relate to a \ compiler change that affects some code blocks for the FD, tree and Monte \ Carlo numerical tools in later chapters, and some changes to transform \ calculus conventions which affect the general theoretical development in the \ very early chapters. There is also what in my view is a bug in the formatting \ of integration output which I hope will be fixed. There are other minor \ issues here and there, of no great signficance - this notebook is only rather \ long as I have tried to trap all points everywhere they appear.\ \>", "Text"], Cell[CellGroupData[{ Cell["Overview of Main Points", "Subsubtitle"], Cell[CellGroupData[{ Cell["Global Change - Impact of Compiler Bug Fix", "Subsection"], Cell[TextData[{ "I am grateful to Tom Wickham-Jones (TWJ) for explaining an undocumented \ change in the way that ", StyleBox["Compile", FontFamily->"Courier", FontWeight->"Bold"], " works that breaks several of the compiled numerical routines (for FD, \ trees, Monte Carlo). It is easy to fix the code. \n\nThe changes eliminate a \ type of bug than can arise when a variable is only initialized once inside a \ conditional construct and then used outside (if it is initialized inside a \ conditional statement and only used inside there is no problem). The bug can \ produce gibberish, as evidenced by this simple example from TWJ, which \ compiles happily under V3.X:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \($Version\)], "Input"], Cell[BoxData[ \("Power Macintosh 3.0 (May 6, 1997)"\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(f\ = \ Compile[{x}, \ Module[\ {t}, \ If[x > 5, \ t = 5.5]; t]]\)], "Input"], Cell[BoxData[ TagBox[ RowBox[{"CompiledFunction", "[", RowBox[{\({x}\), ",", RowBox[{"Module", "[", RowBox[{\({t}\), ",", RowBox[{ RowBox[{"If", "[", RowBox[{\(x > 5\), ",", RowBox[{"t", "=", StyleBox["5.5`", StyleBoxAutoDelete->True, PrintPrecision->2]}]}], "]"}], ";", "t"}]}], "]"}], ",", "\<\"-CompiledCode-\"\>"}], "]"}], False, Editable->False]], "Output"] }, Open ]], Cell["\<\ The following nonsense, or something equivalent, will then result:\ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \({f[1], \ f[6], \ f[1]}\)], "Input"], Cell[BoxData[ \({9.60419255251500558`*^281, 5.5`, 5.5`}\)], "Output"] }, Open ]], Cell["\<\ The version 4 compiler does not allow this, and returns an error:\ \ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \($Version\)], "Input"], Cell[BoxData[ \("4.0 for Power Macintosh (April 20, 1999)"\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(f\ = \ Compile[{x}, \ Module[\ {t}, \ If[x > 5, \ t = 5.5]; t]]\)], "Input"], Cell[BoxData[ \(Compile::"initvar" \(\(:\)\(\ \)\) "The variable \!\(t\) has not been initialized or has been initialized \ to Null."\)], "Message"], Cell[BoxData[ TagBox[\(CompiledFunction[{x}, Module[{t}, If[x > 5, t = 5.5`]; t], "-CompiledCode-"]\), False, Editable->False]], "Output"] }, Open ]], Cell["\<\ To get this through the compiler, we need to do something \ like:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(g\ = \ Compile[{x}, \ Module[\ {t = 1.0}, \ If[x > 5, \ t = 5.5]; t]]\)], "Input"], Cell[BoxData[ TagBox[\(CompiledFunction[{x}, Module[{t = 1.`}, If[x > 5, t = 5.5`]; t], "-CompiledCode-"]\), False, Editable->False]], "Output"] }, Open ]], Cell["and then all is good:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \({g[1], \ g[6], \ g[1]}\)], "Input"], Cell[BoxData[ \({1.`, 5.5`, 1.`}\)], "Output"] }, Open ]], Cell[TextData[{ "Although none of the examples in the book can generate this type of \ nonsense, they do involve local Module variables, some of which only get \ initialized inside a function within the Module, but are reported in the \ output. An example that is closest in spirit to the example supplied by TWJ \ is our compiled function for making samples from the Normal distribution \ quickly. Under V4 we get a cascade of complaints starting with the same ", StyleBox["initvar", FontFamily->"Courier"], " message:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(norm = \ Compile[{mu, \ sigma}, \ \n\t\tModule[{va, \ vb, \ rad\ = \ 2.0, \ den}, \n\t\t\tWhile[ rad\ >= 1.00, \n\t\t\t\t\t\((va\ = \ 2.0*Random[]\ - \ 1.0; \n\t\t\t\t\tvb\ = \ 2.0*Random[]\ - 1.0; \n\t\t\t\t\trad\ = \ va*va + vb*vb)\)]; \n\t\t\tden\ = \ Sqrt[\(-2.0\)*Log[rad]/rad]; \n\t\t\tmu + sigma*va*den]];\)\)], "Input"], Cell[BoxData[ \(General::"spell" \(\(:\)\(\ \)\) "Possible spelling error: new symbol name \"\!\(norm\)\" is similar to \ existing symbols \!\({nora, norb, Norm}\)."\)], "Message"], Cell[BoxData[ \(Compile::"initvar" \(\(:\)\(\ \)\) "The variable \!\(va\) has not been initialized or has been initialized \ to Null."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(Times\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(Plus\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(Times\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"], Cell[BoxData[ \(General::"stop" \(\(:\)\(\ \)\) "Further output of \!\(Compile :: \"cptype\"\) will be suppressed \ during this calculation."\)], "Message"] }, Open ]], Cell[TextData[{ "The problem is that ", StyleBox["va", FontFamily->"Courier", FontWeight->"Bold"], " is in the output line, but is not initialized (but unlike the TWJ \ example, will be when the function is called). The problem is fixed by \ initializing ", StyleBox["va", FontFamily->"Courier", FontWeight->"Bold"], " as follows:" }], "Text"], Cell[BoxData[ \(\(norm = \ Compile[{mu, \ sigma}, \ \n\t\tModule[{va = 1. , \ vb, \ rad\ = \ 2.0, \ den}, \n\t\t\tWhile[ rad\ >= 1.00, \n\t\t\t\t\t\((va\ = \ 2.0*Random[]\ - \ 1.0; \n\t\t\t\t\tvb\ = \ 2.0*Random[]\ - 1.0; \n\t\t\t\t\trad\ = \ va*va + vb*vb)\)]; \n\t\t\tden\ = \ Sqrt[\(-2.0\)*Log[rad]/rad]; \n\t\t\tmu + sigma*va*den]];\)\)], "Input"], Cell["\<\ All of the problems with the compiler in V4 are of this type, and \ are fixed in exactly the same way. You might find it instructive to do so \ yourself, but I have supplied fixed code in the Sections below, for every \ function where it is to be applied. If you have a copy of the electronic \ version on disk, I recommend you paste these changes into the notebooks for \ the relevant chapter.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["\<\ Global Change -Transform Calculus now in kernel; new \ conventions\ \>", "Subsection"], Cell["\<\ The default conventions have now changed, and the manner in which \ phase and normalizations are controlled are different. Furthermore, the \ Fourier and Laplace transform functions are now in core kernel. Loading a \ transform package as before does no harm, and you are reminded that they are \ now in the kernel:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell[BoxData[ \(LaplaceTransform::"obslt" \(\(:\)\(\ \)\) "All LaplaceTransform and InverseLaplaceTransform functionalities are \ now autoloaded. The package Calculus`LaplaceTransform` is obsolete."\)], \ "Message"], Cell[BoxData[ \(Needs::"nocont" \(\(:\)\(\ \)\) "Context \!\(\"Calculus`LaplaceTransform`\"\) was not created when \ Needs was evaluated."\)], "Message"] }, Open ]], Cell["\<\ and similarly with Fourier transforms. For example, with the new \ default conventions, we have\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(FourierTransform[Exp[\(-x^2\)/\((4*t)\)]/Sqrt[4\ Pi\ t], \ x, \ w]\)], "Input"], Cell[BoxData[ \(\[ExponentialE]\^\(\(-t\)\ w\^2\)\/\@\(2\ \[Pi]\)\)], "Output"] }, Open ]], Cell[TextData[{ "If you want the results to all look like the V3 ", StyleBox["defaults", FontSlant->"Italic"], " in the book, you need to use the\n", StyleBox["FourierParameters -> {1,1} \n", FontFamily->"Courier", FontWeight->"Bold"], "option setting, as follows:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(FourierTransform[Exp[\(-x^2\)/\((4*t)\)]/Sqrt[4\ Pi\ t], \ x, \ w, \ FourierParameters\ \[Rule] \ {1, \ 1}]\)], "Input"], Cell[BoxData[ \(\[ExponentialE]\^\(\(-t\)\ w\^2\)\)], "Output"] }, Open ]], Cell["Let's go back, just to check:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(InverseFourierTransform[Exp[\(-t\)\ w^2], \ w, \ x, \[IndentingNewLine]FourierParameters\ \[Rule] \ {1, \ 1}]\)], "Input"], Cell[BoxData[ \(\[ExponentialE]\^\(-\(x\^2\/\(4\ t\)\)\)\/\(2\ \@\[Pi]\ \@t\)\)], \ "Output"] }, Open ]], Cell[TextData[{ "This setting preserves the default conventions used in the V3 packages \ which were mostly employed in the text (except as noted). A list of parameter \ settings is given on p. 854 of the V4 book. My own preference is in fact for \ the \"Modern Physics\" setting of {0, 1}, which happens to be ", StyleBox["Mathematica", FontSlant->"Italic"], "'s new default, but in order to simplify V3-V4 cross-compatibility, I \ suggest the {1,1} setting. " }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Global Change - Integration Formatting ", "Subsection"], Cell["\<\ Well, yours truly definitely thinks this is a bug. Version 3.0 integration makes use of a certain approach to formatting output. \ This will be illustrated by use of an integral of the probability density \ function for the gamma distribution. This is chosen as the integral is \ manifestly unity. Under Version 3.X, we got\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(basic\ = \ Integrate[\[Lambda]^p\ x^\((p - 1)\)\ Exp[\(-\[Lambda]\)\ x]/ Gamma[p], \ {x, \ 0, \ Infinity}]\)], "Input"], Cell[BoxData[ RowBox[{"If", "[", RowBox[{\(Re[p] > 0 && Re[\[Lambda]] > 0\), ",", "1", ",", RowBox[{ SubsuperscriptBox["\[Integral]", "0", InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(\(E\^\(\(-x\)\ \[Lambda]\)\ x\^\(\(-1\) + p\)\ \ \[Lambda]\^p\)\/Gamma[p]\) \[DifferentialD]x\)}]}], "]"}]], "Output"] }, Open ]], Cell["\<\ This is a sensible output, which also ensures that the following \ simple answer extraction works:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(basic[\([2]\)]\)], "Input"], Cell[BoxData[ \(1\)], "Output"] }, Open ]], Cell["\<\ Version 4.0 integration gives a rather different default \ output.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(basic\ = \ Integrate[\[Lambda]^p\ x^\((p - 1)\)\ Exp[\(-\[Lambda]\)\ x]/ Gamma[p], \ {x, \ 0, \ Infinity}]\)], "Input"], Cell[BoxData[ FractionBox[ RowBox[{\(\[Lambda]\^p\), " ", RowBox[{"If", "[", RowBox[{\(Re[p] > 0 && Re[\[Lambda]] > 0\), ",", \(\[Lambda]\^\(-p\)\ Gamma[p]\), ",", RowBox[{ SubsuperscriptBox["\[Integral]", "0", InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(\[ExponentialE]\^\(\(-x\)\ \[Lambda]\)\ x\^\(\(-1\ \) + p\)\) \[DifferentialD]x\)}]}], "]"}]}], \(Gamma[p]\)]], "Output"] }, Open ]], Cell["\<\ My view is the format of this last output is just plain stupid, and \ it also causes the following to fail:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(basic[\([2]\)]\)], "Input"], Cell[BoxData[ \(1\/Gamma[p]\)], "Output"] }, Open ]], Cell["\<\ However, there are two ways around this, (which also work in V3.X). \ You can use instead, either\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Integrate[\[Lambda]^p\ x^\((p - 1)\)\ Exp[\(-\[Lambda]\)\ x]/ Gamma[p], \ {x, \ 0, \ Infinity}, GenerateConditions\ -> \ False]\)], "Input"], Cell[BoxData[ \(1\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(fix\ = \ If[_, \ expr_, \ _]\ -> \ expr\)], "Input"], Cell[BoxData[ \(If[_, expr_, _] \[Rule] expr\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(basic\ /. \ fix\)], "Input"], Cell[BoxData[ \(1\)], "Output"] }, Open ]], Cell[TextData[{ "I have explained below, chapter by chapter, where the use of the \ result[[2]] construction must be avoided. The raw output of basic under V4 is \ ridiculuous, IMHO. I suggest that you avoid overusing the ", StyleBox["GenerateConditions -> False", FontFamily->"Courier", FontWeight->"Bold"], ", (a) because you may miss an important parameter restriction, (b) it is \ a lot of typing! I now use", StyleBox[" /. fix", FontFamily->"Courier", FontWeight->"Bold"], " as it is as much typing as before, and you can do a default integration, \ then, e.g." }], "Text"], Cell[BoxData[ \(\(Integrate[\[Lambda]^p\ x^\((p - 1)\)\ Exp[\(-\[Lambda]\)\ x]/ Gamma[p], \ {x, \ 0, \ Infinity}];\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(new\ = \ %\ /. \ fix\)], "Input"], Cell[BoxData[ \(1\)], "Output"] }, Open ]], Cell[TextData[{ "to carry on to the next stage of your analysis without the ", StyleBox["If", FontFamily->"Courier", FontWeight->"Bold"], " wrapping. If you have finalized a sequence of calculations, this can be \ abbreviated to" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Integrate[\[Lambda]^p\ x^\((p - 1)\)\ Exp[\(-\[Lambda]\)\ x]/ Gamma[p], \ {x, \ 0, \ Infinity}] /. \ fix\)], "Input"], Cell[BoxData[ \(1\)], "Output"] }, Open ]], Cell[TextData[{ "and this is the approach suggested for the book. One might argue that my \ previous approach, which relied on the particular format of an output, was \ sloppy. Perhaps, but I never imagined software would produce output of the \ form exemplified above by the V4 output for ", StyleBox["basic", FontFamily->"Courier", FontWeight->"Bold"], "!" }], "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Issues with NonLinearFit", "Subsection"], Cell[TextData[{ "This only comes up in Chapter 26 in this book but I use it a lot \ elsewhere. The following code, which appeared originally in \"Applied ", StyleBox["Mathematica", FontSlant->"Italic"], "\", and which played nicely with version 2.2, now fails! If you make up \ some data as follows:" }], "Text"], Cell[BoxData[ \(\(exptdata\ = \ Table[{x, \ 1/\((\((x - 10)\)^2\ + \ 0.1)\)\ + \ 1/\((\((x - 13)\)^2\ + \ 0.5)\)\ + \ 0.3\ *Random[]}, \ {x, \ 0, \ 20, \ 0.1}];\)\)], "Input"], Cell["This obviously has peaks at 10 and 13.", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(ListPlot[exptdata, \ PlotJoined\ \[Rule] \ True, \ PlotRange\ \[Rule] \ All];\)\)], "Input"], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .61803 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.047619 0.0126054 0.0579583 [ [.2619 .00011 -3 -9 ] [.2619 .00011 3 0 ] [.5 .00011 -6 -9 ] [.5 .00011 6 0 ] [.7381 .00011 -6 -9 ] [.7381 .00011 6 0 ] [.97619 .00011 -6 -9 ] [.97619 .00011 6 0 ] [.01131 .12852 -6 -4.5 ] [.01131 .12852 0 4.5 ] [.01131 .24444 -6 -4.5 ] [.01131 .24444 0 4.5 ] [.01131 .36036 -6 -4.5 ] [.01131 .36036 0 4.5 ] [.01131 .47627 -6 -4.5 ] [.01131 .47627 0 4.5 ] [.01131 .59219 -12 -4.5 ] [.01131 .59219 0 4.5 ] [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 g .25 Mabswid [ ] 0 setdash .2619 .01261 m .2619 .01886 L s [(5)] .2619 .00011 0 1 Mshowa .5 .01261 m .5 .01886 L s [(10)] .5 .00011 0 1 Mshowa .7381 .01261 m .7381 .01886 L s [(15)] .7381 .00011 0 1 Mshowa .97619 .01261 m .97619 .01886 L s [(20)] .97619 .00011 0 1 Mshowa .125 Mabswid .07143 .01261 m .07143 .01636 L s .11905 .01261 m .11905 .01636 L s .16667 .01261 m .16667 .01636 L s .21429 .01261 m .21429 .01636 L s .30952 .01261 m .30952 .01636 L s .35714 .01261 m .35714 .01636 L s .40476 .01261 m .40476 .01636 L s .45238 .01261 m .45238 .01636 L s .54762 .01261 m .54762 .01636 L s .59524 .01261 m .59524 .01636 L s .64286 .01261 m .64286 .01636 L s .69048 .01261 m .69048 .01636 L s .78571 .01261 m .78571 .01636 L s .83333 .01261 m .83333 .01636 L s .88095 .01261 m .88095 .01636 L s .92857 .01261 m .92857 .01636 L s .25 Mabswid 0 .01261 m 1 .01261 L s .02381 .12852 m .03006 .12852 L s [(2)] .01131 .12852 1 0 Mshowa .02381 .24444 m .03006 .24444 L s [(4)] .01131 .24444 1 0 Mshowa .02381 .36036 m .03006 .36036 L s [(6)] .01131 .36036 1 0 Mshowa .02381 .47627 m .03006 .47627 L s [(8)] .01131 .47627 1 0 Mshowa .02381 .59219 m .03006 .59219 L s [(10)] .01131 .59219 1 0 Mshowa .125 Mabswid .02381 .04158 m .02756 .04158 L s .02381 .07056 m .02756 .07056 L s .02381 .09954 m .02756 .09954 L s .02381 .1575 m .02756 .1575 L s .02381 .18648 m .02756 .18648 L s .02381 .21546 m .02756 .21546 L s .02381 .27342 m .02756 .27342 L s .02381 .3024 m .02756 .3024 L s .02381 .33138 m .02756 .33138 L s .02381 .38933 m .02756 .38933 L s .02381 .41831 m .02756 .41831 L s .02381 .44729 m .02756 .44729 L s .02381 .50525 m .02756 .50525 L s .02381 .53423 m .02756 .53423 L s .02381 .56321 m .02756 .56321 L s .25 Mabswid .02381 0 m .02381 .61803 L s .5 Mabswid .02381 .01803 m .02857 .01832 L .03333 .02585 L .0381 .02206 L .04286 .02915 L .04762 .03049 L .05238 .01818 L .05714 .0175 L .0619 .01542 L .06667 .0153 L .07143 .02679 L .07619 .01795 L .08095 .0219 L .08571 .01573 L .09048 .01629 L .09524 .03123 L .1 .0269 L .10476 .01487 L .10952 .02826 L .11429 .01943 L .11905 .03031 L .12381 .02887 L .12857 .03124 L .13333 .03055 L .1381 .02594 L .14286 .02423 L .14762 .01909 L .15238 .02222 L .15714 .02793 L .1619 .0249 L .16667 .01472 L .17143 .01854 L .17619 .02637 L .18095 .02349 L .18571 .01923 L .19048 .03192 L .19524 .01846 L .2 .02177 L .20476 .01699 L .20952 .03217 L .21429 .02307 L .21905 .02106 L .22381 .02032 L .22857 .02699 L .23333 .02444 L .2381 .02392 L .24286 .02085 L .24762 .02826 L .25238 .03038 L .25714 .03162 L Mistroke .2619 .01637 L .26667 .02072 L .27143 .01718 L .27619 .02152 L .28095 .01653 L .28571 .01713 L .29048 .02323 L .29524 .03054 L .3 .02989 L .30476 .0179 L .30952 .02018 L .31429 .02429 L .31905 .02854 L .32381 .01889 L .32857 .03041 L .33333 .01929 L .3381 .02443 L .34286 .02567 L .34762 .02254 L .35238 .02952 L .35714 .02057 L .3619 .03203 L .36667 .02705 L .37143 .03309 L .37619 .03971 L .38095 .0298 L .38571 .02878 L .39048 .03093 L .39524 .04308 L .4 .03317 L .40476 .04414 L .40952 .03979 L .41429 .03615 L .41905 .03936 L .42381 .04938 L .42857 .04256 L .43333 .05406 L .4381 .05203 L .44286 .0537 L .44762 .06206 L .45238 .07375 L .45714 .09502 L .4619 .10962 L .46667 .12476 L .47143 .14785 L .47619 .18681 L .48095 .24969 L .48571 .33908 L .49048 .43748 L .49524 .5605 L Mistroke .5 .60332 L .50476 .5568 L .50952 .43978 L .51429 .33482 L .51905 .2508 L .52381 .18839 L .52857 .15037 L .53333 .12578 L .5381 .11415 L .54286 .10459 L .54762 .08767 L .55238 .07189 L .55714 .07784 L .5619 .07671 L .56667 .06423 L .57143 .06163 L .57619 .07264 L .58095 .06325 L .58571 .07683 L .59048 .07873 L .59524 .07071 L .6 .07554 L .60476 .08669 L .60952 .08325 L .61429 .09019 L .61905 .11144 L .62381 .11414 L .62857 .12768 L .63333 .13762 L .6381 .14388 L .64286 .13765 L .64762 .13628 L .65238 .14095 L .65714 .12783 L .6619 .11604 L .66667 .0977 L .67143 .08774 L .67619 .08983 L .68095 .07353 L .68571 .07786 L .69048 .06085 L .69524 .05961 L .7 .05223 L .70476 .0428 L .70952 .03982 L .71429 .04037 L .71905 .04663 L .72381 .04897 L .72857 .03099 L .73333 .03791 L Mistroke .7381 .03488 L .74286 .03429 L .74762 .03297 L .75238 .04004 L .75714 .02818 L .7619 .0267 L .76667 .03179 L .77143 .02547 L .77619 .03234 L .78095 .02124 L .78571 .02637 L .79048 .02645 L .79524 .02448 L .8 .01978 L .80476 .01887 L .80952 .03279 L .81429 .03412 L .81905 .01799 L .82381 .03449 L .82857 .02793 L .83333 .02082 L .8381 .01785 L .84286 .0333 L .84762 .01836 L .85238 .0304 L .85714 .0269 L .8619 .02528 L .86667 .01979 L .87143 .0255 L .87619 .02277 L .88095 .03281 L .88571 .03306 L .89048 .03137 L .89524 .02187 L .9 .02636 L .90476 .02611 L .90952 .02603 L .91429 .0209 L .91905 .02598 L .92381 .02892 L .92857 .02724 L .93333 .02059 L .9381 .02633 L .94286 .01823 L .94762 .02347 L .95238 .01961 L .95714 .02711 L .9619 .01639 L .96667 .02683 L .97143 .02633 L Mistroke .97619 .01792 L Mfstroke 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath % End of Graphics MathPictureEnd \ \>"], "Graphics", ImageSize->{288, 177.938}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCache->GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHg7oo00D007ooOomoo`0000=oo`03001oogoo03Eoo`04001o ogoo0002Ool01000Oomoo`001Woo001DOol00`00Oomoo`0hOol00`00Oomoo`02Ool01000Oomoo`00 >7oo00<007ooOol01Goo00<007ooOol0=Woo00<007ooOol00Woo00@007ooOol000Ioo`00E7oo00<0 07ooOol0>7oo00<007ooOol00Woo00@007ooOol003Qoo`03001oogoo00Eoo`03001oogoo03Moo`05 001oogooOol00002Ool00`00Oomoo`04Ool0051oo`@003]oo`03001oogoo009oo`04001oogoo000h Ool01000Oomoogoo1000=goo00D007ooOomoo`00009oo`04001oogoo0006Ool0051oo`03001oogoo 03]oo`8000Aoo`04001oogoo000gOol20003Ool00`00Oomoo`0hOol01@00Oomoogoo00000Woo00@0 07ooOol000Ioo`00D7oo1@00>Woo00<007ooOol00goo0P00>Goo00@007ooOomoo`D003Moo`<000Ao o`8000Moo`00ogoo8Goo000BOol00`00Oomoo`3oOolOol00`00Oomoo`03 Ool00`00Oomoo`08Ool2000:Ool20007Ool00`00Oomoo`03Ool01P00Oomoo`00Ool0009oo`04001o ogoo001KOol01000Oomoogoo0P0000Eoo`00Oomoo`00009oo`03001oogoo00Ioo`800003Ool00000 00=oo`800003Ool007oo00Ioo`04001oo`00000QOol0019oo`03001oogoo05aoo`03001oo`00009o o`03001oo`0000=oo`03001oogoo05=oo`05001oo`00001oo`02000@Ool00`00Ool00005Ool00`00 Oomoo`08Ool00`00Oomoo`0QOol0019oo`03001oogoo05eoo`03001oogoo009oo`80009oo`03001o o`0004ioo`8000=oo`03001oo`0000Aoo`03001oogoo04Eoo`004Woo0P00Hgoo00L007oo001oo`00 Ool00002Ool00`00Oomoo`18Ool01000Oomoo`000Woo00<007ooOol0C7oo000BOol00`00Oomoo`1U Ool01`00Oomoogoo001oo`0004Yoo`07001oogooOol007oo0000CWoo000BOol00`00Oomoo`1ZOol0 0`00Ool00018Ool00`00Oomoo`03Ool00`00Oomoo`1=Ool0019oo`03001oogoo06aoo`@004Eoo`03 001oogoo05=oo`004Woo00<007ooOol0Kgoo00<007ooOol0@goo00<007ooOol0Dgoo000BOol00`00 Oomoo`1`Ool00`00Oomoo`0OOol00`00Oomoo`0MOol3001FOol0019oo`03001oogoo071oo`03001o ogoo01ioo`800003Ool007oo01aoo`03001oogoo05Ioo`004Woo00<007ooOol0LGoo00<007ooOol0 7Goo00@007oo000001eoo`03001oogoo05Ioo`004Woo0P00LWoo00<007ooOol06Goo00@007ooOol0 009oo`03001oo`00009oo`8001Moo`03001oogoo05Moo`004Woo00<007ooOol0LWoo00<007ooOol0 67oo00<007oo00001Woo00D007oo001oo`0001Eoo`8005Uoo`004Woo00<007ooOol0LWoo00<007oo Ool05goo00<007oo000027oo00@007ooOol001Eoo`8005Uoo`004Woo00<007ooOol0LWoo00<007oo Ool05goo00<007ooOol037oo0P004Woo00<007ooOol0FGoo000BOol00`00Oomoo`1cOol00`00Oomo o`0EOol00`00Oomoo`0=Ool00`00Ool0000?Ool00`00Ool0001KOol0019oo`03001oogoo07=oo`03 001oogoo01Eoo`03001oogoo011oo`03001oogoo00aoo`8005aoo`004Woo00<007ooOol0Lgoo00<0 07ooOol05Goo00<007ooOol047oo00<007ooOol02goo00<007ooOol0G7oo000BOol00`00Oomoo`1c Ool00`00Oomoo`0DOol00`00Oomoo`0AOol00`00Oomoo`0;Ool00`00Oomoo`1LOol0019oo`8007Ao o`03001oogoo01Aoo`03001oogoo015oo`03001oogoo00]oo`03001oogoo05aoo`004Woo00<007oo Ool0M7oo00<007ooOol04goo00<007ooOol04Woo00<007ooOol02Goo00<007ooOol0GGoo000BOol0 0`00Oomoo`1dOol00`00Oomoo`0COol00`00Oomoo`0BOol00`00Oomoo`09Ool00`00Oomoo`1MOol0 019oo`03001oogoo07Aoo`03001oogoo019oo`03001oogoo01=oo`03001oogoo00Uoo`03001oogoo 05eoo`004Woo00<007ooOol0M7oo00<007ooOol04Woo00<007ooOol057oo00<007ooOol01goo00<0 07ooOol0GWoo0009Ool50004Ool00`00Oomoo`1eOol00`00Oomoo`0AOol00`00Oomoo`0DOol00`00 Oomoo`07Ool00`00Oomoo`1NOol000Yoo`04001oogoo0004Ool00`00Oomoo`1eOol00`00Oomoo`0@ Ool00`00Oomoo`0FOol00`00Oomoo`05Ool00`00Oomoo`1OOol000]oo`03001oogoo00Aoo`<007Eo o`03001oogoo011oo`03001oogoo01Ioo`03001oogoo00Eoo`03001oogoo05moo`0037oo00<007oo Ool00goo00<007ooOol0MGoo00<007ooOol047oo00<007ooOol05Woo00<007ooOol01Goo00<007oo Ool0Ggoo0009Ool01@00Oomoogoo000017oo00<007ooOol0MWoo00<007ooOol03Woo00<007ooOol0 67oo00<007ooOol017oo00<007ooOol0Ggoo0009Ool01@00Oomoogoo000017oo00<007ooOol0MWoo 00<007ooOol03Woo00<007ooOol06Goo00<007oo00000`00HWoo000:Ool30005Ool00`00Oomoo`1f Ool00`00Oomoo`0>Ool00`00Oomoo`0IOol00`00Ool00002Ool00`00Oomoo`1POol0019oo`03001o ogoo07Moo`03001oogoo00aoo`03001oogoo01]oo`03001oogoo06Aoo`004Woo00<007ooOol0Mgoo 00<007ooOol037oo00<007ooOol0PWoo000BOol00`00Oomoo`1gOol00`00Oomoo`0"], ImageRangeCache->{{{0, 287}, {176.938, 0}} -> {-1.43304, -0.787014, \ 0.0772696, 0.0634853}}] }, Open ]], Cell[BoxData[ \(Needs["\"]\)], "Input"], Cell["\<\ You are supposed to be able to fit a function to this, using any \ available information to supply guesses about some of the parameters. Given a \ quick look at the data, we'll try to give very rough guesses for the peak \ locations, at 11 and 14 (we do not want to help too much!):\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(NonlinearFit[exptdata, a\ + \ b/\((\((x - c)\)^2\ + \ d)\)\ + \ e/\((\((x - f)\)^2\ + \ g)\), \ x, \ {a, b, {c, 11}, d, \ e, \ {f, \ 14}, \ g}, \ MaxIterations\ -> \ 40];\)\)], "Input"], Cell[BoxData[ \(NonlinearFit::"fdin" \(\(:\)\(\ \)\) "Form of parameter specification \!\({c, 11}\) is inconsistent with \ other parameter specifications."\)], "Message"] }, Open ]], Cell["\<\ It can't cope with a starting suggestion or two. It does run, with \ no suggestions for starting values, but gives answers that are complete \ rubbish, as in the following:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(NonlinearFit[exptdata, a\ + \ b/\((\((x - c)\)^2\ + \ d)\)\ + \ e/\((\((x - f)\)^2\ + \ g)\), \ x, \ {a, b, c, d, \ e, \ f, \ g}, \ MaxIterations\ -> \ 40]\)], "Input"], Cell[BoxData[ \(\(\(1.0229333996173884`\)\(\[InvisibleSpace]\)\) - 2.6611523558289885`\/\(\(\(2.685939975421488`\)\(\[InvisibleSpace]\)\) \ + \((\(-18.11050856760202`\) + x)\)\^2\) + 88.57389415833887`\/\(\(\(123.11243921869621`\)\(\[InvisibleSpace]\)\) \ + \((\(\(197.00505852135547`\)\(\[InvisibleSpace]\)\) + x)\)\^2\)\)], "Output"] }, Open ]], Cell[TextData[{ "This problem now has a history - it worked in V2.2, failed in V3.0.0, was \ fixed and a ", StyleBox["MathSource", FontSlant->"Italic"], " patch supplied. However, I can no longer find a bug fix on ", StyleBox["MathSource", FontSlant->"Italic"], " and having reported and obtained a reply the problem, it turns out that \ only way to get this to work is to supply starting guesses for ALL the \ parameters - the following is not too bad:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(NonlinearFit[exptdata, a\ + \ b/\((\((x - c)\)^2\ + \ d)\)\ + \ e/\((\((x - f)\)^2\ + \ g)\), \ x, \ {{a, 1}, {b, 1}, {c, 11}, {d, 1}, \ {e, 1}, \ {f, \ 14}, \ {g, 1}}, \ MaxIterations\ -> \ 40]\)], "Input"], Cell[BoxData[ \(\(\(0.14122598190491795`\)\(\[InvisibleSpace]\)\) + 0.9895733726344869`\/\(\(\(0.49323423605040556`\)\(\[InvisibleSpace]\)\)\ + \((\(-13.003187490205482`\) + x)\)\^2\) + 0.9970504291896056`\/\(\(\(0.09939600335766653`\)\(\[InvisibleSpace]\)\)\ + \((\(-9.998488661013365`\) + x)\)\^2\)\)], "Output"] }, Open ]], Cell["\<\ The view from WRI at the time of writing is that this function was \ never intended to cope with only partial suggestions for parameters, and that \ it worked \"by accident\" in V2.2. Meantime, if you use this function, you must either supply starting values \ for all parameters, or supply no values. Answers from the latter can \ sometimes be nonsense.\ \>", "Text"] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Other Chapter by Chapter Comments", "Subsubtitle"], Cell[CellGroupData[{ Cell["Chapter 1 ", "Section"], Cell["No known V4 issues.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 2", "Section"], Cell["\<\ There are no major problems here but a large list of minor changes, \ as follows.\ \>", "Text"], Cell["\<\ Standard Form now uses double struck characters for certain \ symbols. For example, on p. 17:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[{ \(\(expression\ = \ Exp[\(-x^2\)];\)\), "\[IndentingNewLine]", \(StandardForm[expression]\)}], "Input"], Cell[BoxData[ \(\[ExponentialE]\^\(-x\^2\)\)], "Output"] }, Open ]], Cell[TextData[{ "On page 21, the operation of ", StyleBox["N", FontFamily->"Courier", FontWeight->"Bold"], " on a previous numerical computation is slightly different. Now we have" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(0.75^100\)], "Input"], Cell[BoxData[ \(3.2072021853815043`*^-13\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(N[%, \ 10]\)], "Input"], Cell[BoxData[ \(3.2072021853815043`*^-13\)], "Output"] }, Open ]], Cell["\<\ This may be a bug - it look's rather odd to me, especially as \ does\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(N[\((3/4)\)^100, \ 10]\)], "Input"], Cell[BoxData[ \(3.207202185381504`*^-13\)], "Output"] }, Open ]], Cell[TextData[{ "On p. 26, ", StyleBox["NSolve", FontFamily->"Courier", FontWeight->"Bold"], " returns the results in a different order." }], "Text"], Cell["\<\ On p. 35, the short form of an expression continues to be \ unpredictable, depending on the version. I even got two different answers \ running the same thing in two windows. There must be an option setting I do \ not know about. On p. 44/45 and 46 there is more of the influence of minor \ typesetting changes, for example:\ \>", "Text"], Cell[CellGroupData[{ Cell["DSolve[{y'[x] + x y[x] == 0, y[0] == 1}, y[x], x]", "Input"], Cell[BoxData[ \({{y[x] \[Rule] \[ExponentialE]\^\(-\(x\^2\/2\)\)}}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["qsoln = Solve[3 x^2 - 4 x + 6 == 0, x]", "Input"], Cell[BoxData[ \({{x \[Rule] 1\/3\ \((2 - \[ImaginaryI]\ \@14)\)}, {x \[Rule] 1\/3\ \((2 + \[ImaginaryI]\ \@14)\)}}\)], "Output"] }, Open ]], Cell["\<\ The double struck character is no longer reserved for Traditional \ Form. There are many more such trivial changes throughout the book - this \ will be the last mention of them. On p. 49 we get more functions returned thus:\ \>", "Text"], Cell[CellGroupData[{ Cell["?*Sin*", "Input"], Cell["\<\ ArcSin InverseFourierSinTransform \ SingularValues ArcSinh Sin Sinh FourierSinTransform SingleLetterItalics SinhIntegral IncludeSingularTerm SingularityDepth SinIntegral\ \>", \ "Print"] }, Open ]], Cell["\<\ The transform functions have now been moved into the core kernel, \ whereas previously they were in a Package. So they show up in the result of \ this query. On p. 55/56, you always get different timings depending on the version and \ your hardware. Note that the new numerical features do NOT alter the \ importance of remembering stored values, as in the Fibonacci sequence. Again, on p. 59-60, the fact that the transform packages are now in the \ kernel renders part of this discussion obsolete. The functions themselves \ behave in essentially the same way, but are now normalized diferently. On p.64 the horizontal plot range now inherits the length of the longest list \ (c). Finally, this is not a correction but an observation that some of the algebra \ tools support assumptions. For example:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Simplify[Sqrt[x^2]]\)], "Input"], Cell[BoxData[ \(\@x\^2\)], "Output"] }, Open ]], Cell["V4 now supports", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Simplify[Sqrt[x^2], \ x\ \[Element] \ Reals]\)], "Input"], Cell[BoxData[ \(Abs[x]\)], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 3", "Section"], Cell["No known V4 issues.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 4", "Section"], Cell["\<\ There are only two real issues in this Chapter. The first concerns \ the conventions that apply to Fourier transforms, which have changed. This is \ always a pain, with mathematicians, physicists and engineers all having their \ own pet views! The second is the implication of the format change for \ integration output, as noted in the Main Points note above. First though, on p. 95, two results come out in slightly different form\ \>", \ "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(h[z]\ /. \ \(DSolve[ D[h[z], \ {z, \ 2}]\ + \ z/2\ D[h[z], \ z]\ + 1/2\ h[z]\ == 0, \ h[z], \ z]\)[\([1]\)]\)], "Input"], Cell[BoxData[ \(\[ExponentialE]\^\(-\(z\^2\/4\)\)\ C[ 1] + \[ExponentialE]\^\(-\(z\^2\/4\)\)\ C[2]\ Erfi[ z\/2]\)], "Output"] }, Open ]], Cell["\<\ The second superficial change is rather irritating - we now \ have\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Integrate[ A/Sqrt[\[Tau]]\ Exp[\(-x^2\)/\((4\ \[Tau])\)], \ {x, \ \(-Infinity\), \ Infinity}]\)], "Input"], Cell[BoxData[ FractionBox[ RowBox[{"A", " ", RowBox[{"If", "[", RowBox[{\(Re[\[Tau]] > 0\), ",", \(2\ \@\[Pi]\ \@\[Tau]\), ",", RowBox[{ SubsuperscriptBox["\[Integral]", InterpretationBox[\(-\[Infinity]\), DirectedInfinity[ -1]], InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(\[ExponentialE]\^\(-\(x\^2\/\(4\ \[Tau]\)\)\)\) \ \[DifferentialD]x\)}]}], "]"}]}], \(\@\[Tau]\)]], "Output"] }, Open ]], Cell["instead of the preferable V3 answer in the printed text.", "Text"], Cell["\<\ On p. 96, it is no longer necessary to load the Laplace Transform \ package as it is already in the kernel. The Fourier transforms are also \ preloaded, and the conventions have changed, we now have, by default:\ \>", \ "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(FourierTransform[Exp[\(-x^2\)/\((4*t)\)]/Sqrt[4\ Pi\ t], \ x, \ w]\)], "Input"], Cell[BoxData[ \(\[ExponentialE]\^\(\(-t\)\ w\^2\)\/\@\(2\ \[Pi]\)\)], "Output"] }, Open ]], Cell[TextData[{ "If you want the results to all look like the V3 ", StyleBox["defaults", FontSlant->"Italic"], " in the book, you need to use the\n", StyleBox["FourierParameters", FontFamily->"Courier", FontWeight->"Bold"], " options thus:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(FourierTransform[Exp[\(-x^2\)/\((4*t)\)]/Sqrt[4\ Pi\ t], \ x, \ w, \ FourierParameters\ \[Rule] \ {1, \ 1}]\)], "Input"], Cell[BoxData[ \(\[ExponentialE]\^\(\(-t\)\ w\^2\)\)], "Output"] }, Open ]], Cell["Let's go back, just to check:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(InverseFourierTransform[Exp[\(-t\)\ w^2], \ w, \ x, \[IndentingNewLine]FourierParameters\ \[Rule] \ {1, \ 1}]\)], "Input"], Cell[BoxData[ \(\[ExponentialE]\^\(-\(x\^2\/\(4\ t\)\)\)\/\(2\ \@\[Pi]\ \@t\)\)], \ "Output"] }, Open ]], Cell[TextData[{ "There are other changes, such as the abolition of ", StyleBox["FourierOverallConstant", FontFamily->"Courier", FontWeight->"Bold"], " - these things do not materially affect any of the financial derivatives \ analysis, but you should watch out in you regularly use these things. In some \ ways the new default normalization, with the root 2 Pi stuff arranged \ symmetrically, is nicer, but the fact that things have changed is a real \ nuisance. In V3 the default forward FT was straight integration:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Integrate[ Exp[\(-x^2\)/\((4*t)\)]/Sqrt[4\ Pi\ t]\ Exp[ I\ w\ x], \ {x, \ \(-Infinity\), \ Infinity}]\)], "Input"], Cell[BoxData[ FractionBox[ RowBox[{"If", "[", RowBox[{\(Im[w] == 0 && Re[t] > 0\), ",", \(2\ \[ExponentialE]\^\(\(-t\)\ w\^2\)\ \@\[Pi]\ \@t\), ",", RowBox[{ SubsuperscriptBox["\[Integral]", InterpretationBox[\(-\[Infinity]\), DirectedInfinity[ -1]], InterpretationBox["\[Infinity]", DirectedInfinity[ 1]]], \(\(\[ExponentialE]\^\(\[ImaginaryI]\ w\ x - x\^2\/\(4\ t\)\)\) \[DifferentialD]x\)}]}], "]"}], \(2\ \@\[Pi]\ \@t\)]], "Output"] }, Open ]], Cell[TextData[{ "The comment on p 99 about ", StyleBox["FourierOverallConstant", FontFamily->"Courier", FontWeight->"Bold"], " being one no longer applies. The ", StyleBox["FourierParameters", FontFamily->"Courier", FontWeight->"Bold"], " setting given above causes all V4 FTs to look like those in the book." }], "Text"], Cell["\<\ Regarding p. 102, see the errata also, as this interacts with V3-V4 \ issue. I do not yet have a clean way of cleaning up this integration under \ V4.\ \>", "Text"], Cell["\<\ Matters on p. 103 come out more straightforwardly, but no \ implications. On p. 104, the change in transform operation has some minor but \ irritating effects, due to the convention shift. The comparison of direct \ integration and the use of a transform is now best done with\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(FourierTransform[\(-2\)\ \[Alpha]\ UnitStep[\(-x\)]\ Exp[\[Alpha]\ x]\ \ , \ x, \ \[Omega], \ FourierParameters\ \[Rule] \ {1, \ \(-1\)}]\)], "Input"], Cell[BoxData[ \(\(-\(\(2\ \[Alpha]\)\/\(\[Alpha] - \[ImaginaryI]\ \[Omega]\)\)\)\)], \ "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Integrate[\(-2\)\ \[Alpha]\ Exp[ x\ \((\[Alpha]\ - \ I\ \[Omega])\)], \ {x, \ \(-Infinity\), \ 0}]\)], "Input"], Cell[BoxData[ RowBox[{\(-2\), " ", "\[Alpha]", " ", RowBox[{"If", "[", RowBox[{\(Im[\[Omega]] == 0 && Re[\[Alpha]] > 0\), ",", \(1\/\(\[Alpha] - \[ImaginaryI]\ \[Omega]\)\), ",", RowBox[{ SubsuperscriptBox["\[Integral]", InterpretationBox[\(-\[Infinity]\), DirectedInfinity[ -1]], "0"], \(\(\[ExponentialE]\^\(x\ \((\[Alpha] - \[ImaginaryI]\ \ \[Omega])\)\)\) \[DifferentialD]x\)}]}], "]"}]}]], "Output"] }, Open ]], Cell["\<\ There are several places where overall multiplicative constants \ within an integral have now been brought outside the answer. This causes \ problems when the integration results in an If statement. Subsequent \ manipulation with %[[2]] to exrtact the result of the integration then do not \ work the way it was intended. For example, on p.104, the following \ calculations no longer work.\ \>", "Text"], Cell[BoxData[ \(Clear[\[Alpha]]\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(Integrate[\(-2\)\ \[Alpha]\ Exp[\[Alpha]\ p]\ 1/Sqrt[4\ Pi\ \[Tau]] Exp[\(-\((p - x)\)^2\)/\((4\ \[Tau])\)], \ {p, \ \(-Infinity\), \ 0}]\)], "Input"], Cell[BoxData[ RowBox[{"-", RowBox[{\(1\/\(\@\[Pi]\ \@\[Tau]\)\), RowBox[{"(", RowBox[{"\[Alpha]", " ", RowBox[{"If", "[", RowBox[{\(Re[2\ \[Alpha] + x\/\[Tau]] > 0 && Re[\[Tau]] > 0\), ",", \(\(-\[ExponentialE]\^\(\[Alpha]\ \((x + \[Alpha]\ \ \[Tau])\)\)\)\ \@\[Pi]\ \@\[Tau]\ \((\(-1\) + Erf[\(x + 2\ \[Alpha]\ \[Tau]\)\/\(2\ \@\[Tau]\)])\)\), ",", RowBox[{ SubsuperscriptBox["\[Integral]", InterpretationBox[\(-\[Infinity]\), DirectedInfinity[ -1]], "0"], \(\(\[ExponentialE]\^\(p\ \[Alpha] - \((p - x)\)\^2\ \/\(4\ \[Tau]\)\)\) \[DifferentialD]p\)}]}], "]"}]}], ")"}]}]}]], "Output"] }, Open ]], Cell["\<\ As noted in the Main Points section, the following leads to \ rubbish...\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(GG[x_, \ \[Tau]_, \ \[Alpha]_]\ = \ %[\([2]\)]\)], "Input"], Cell[BoxData[ \(1\/\@\[Pi]\)], "Output"] }, Open ]], Cell["We use instead,", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(GG[x_, \ \[Tau]_, \ \[Alpha]_]\ = %%\ /. fix\)], "Input"], Cell[BoxData[ \(\[ExponentialE]\^\(\[Alpha]\ \((x + \[Alpha]\ \[Tau])\)\)\ \[Alpha]\ \ \((\(-1\) + Erf[\(x + 2\ \[Alpha]\ \[Tau]\)\/\(2\ \@\[Tau]\)])\)\)], "Output"] }, Open ]], Cell["with, as before", "Text"], Cell[BoxData[ \(\(fix\ = \ If[_, \ expr_, \ _]\ -> \ expr;\)\)], "Input"], Cell["\<\ All very logical and correct. At the top of p. 106 the preceding \ sequence of manipulations gives now\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Series[%, \ {\[Alpha], \ Infinity, \ 1}]\)], "Input"], Cell[BoxData[ InterpretationBox[ RowBox[{\(-\(\[ExponentialE]\^\(-\(x\^2\/\(4\ \[Tau]\)\)\)\/\(\@\[Pi]\ \ \@\[Tau]\)\)\), "+", \(\(\[ExponentialE]\^\(-\(x\^2\/\(4\ \[Tau]\)\)\)\ x\)\/\(2\ \@\ \[Pi]\ \[Tau]\^\(3/2\)\ \[Alpha]\)\), "+", InterpretationBox[\(O[1\/\[Alpha]]\^2\), SeriesData[ \[Alpha], DirectedInfinity[ 1], {}, 0, 2, 1]]}], SeriesData[ \[Alpha], DirectedInfinity[ 1], { Times[ -1, Power[ E, Times[ Rational[ -1, 4], Power[ x, 2], Power[ \[Tau], -1]]], Power[ Pi, Rational[ -1, 2]], Power[ \[Tau], Rational[ -1, 2]]], Times[ Rational[ 1, 2], Power[ E, Times[ Rational[ -1, 4], Power[ x, 2], Power[ \[Tau], -1]]], Power[ Pi, Rational[ -1, 2]], x, Power[ \[Tau], Rational[ -3, 2]]]}, 0, 2, 1]]], "Output"] }, Open ]], Cell["\<\ On p. 102 the integration formatting problem raises its ugly head \ again. The sequence beginning with \ \>", "Text"], Cell[BoxData[ \(value\ = \ Exp[\(-r\)\ \((T - t)\)]\ B\ K^\[Lambda]\ \(Integrate[ 1/\((\[CapitalSigma]\ Sqrt[ 2\ Pi])\)\ Exp[\[Lambda]\ y\ - \ \((y\ - \ m)\)^2/\((2\ \[CapitalSigma]^2)\)], \ {y, \ 0, \ Infinity}]\)[\([2]\)]\)], "Input"], Cell["\<\ and then using PowerExpand, which is now useless, needs to be \ replaced by corresponding fixed integrations of the form\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(value\ = \ Exp[\(-r\)\ \((T - t)\)]\ B\ K^\[Lambda]\ Integrate[ 1/\((\[CapitalSigma]\ Sqrt[ 2\ Pi])\)\ Exp[\[Lambda]\ y\ - \ \((y\ - \ m)\)^2/\((2\ \[CapitalSigma]^2)\)], \ {y, \ 0, \ Infinity}]\ /. fix\)], "Input"], Cell[BoxData[ \(\(B\ \[ExponentialE]\^\(\(-r\)\ \((\(-t\) + T)\) + 1\/2\ \[Lambda]\ \ \((2\ m + \[Lambda]\ \[CapitalSigma]\^2)\)\)\ K\^\[Lambda]\ \@\[CapitalSigma]\ \^2\ \((1 + Erf[\(\@\[CapitalSigma]\^2\ \((m + \[Lambda]\ \[CapitalSigma]\^2)\ \)\)\/\(\@2\ \[CapitalSigma]\^2\)])\)\)\/\(2\ \[CapitalSigma]\)\)], "Output"] }, Open ]], Cell["\<\ There are more changes to do with integration and Fourier \ conventions starting on p. 115. \ \>", "Text"], Cell["\<\ The remainder of Chapter 4 requires a great many adjustments to the \ outputs of Integrate to get around the fact that [[2]] no longer reliably \ extracts the relevant part of an If-based answer. These adjustments have no \ financial implications - just replace the [[2]] with /. fix.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Chapter 5", "Section"], Cell["\<\ No known V4 issues. Some standard form outputs will now use \ double-struck characters.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 6", "Section"], Cell["\<\ No significant V4 issues, but just an observation about a point of \ slight disappointment. The support for continued fractions (in a Package \ previously, but brought to my attention by its relocation to the kernel) \ still does not allow one to write the Normal distribution any more elegantly, \ due to the constraint that the running numerator is unity, whereas the \ running numerator here is a simple, but non-constant sequence. Consider the \ following\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(?FromContinuedFraction\)\)], "Input"], Cell[BoxData[ \("FromContinuedFraction[list] reconstructs a number from the list of its \ continued fraction terms."\)], "Print"] }, Open ]], Cell[BoxData[ \(\(expr\ = \ a\ + 1/\((b + 1/\((c + 1/d)\))\)\ ;\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(TraditionalForm[expr]\)], "Input"], Cell[BoxData[ \(TraditionalForm\`a + 1\/\(b + 1\/\(c + 1\/d\)\)\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Simplify[ expr\ - \ FromContinuedFraction[{a, \ b, \ c, \ d}]]\)], "Input"], Cell[BoxData[ \(0\)], "Output"] }, Open ]], Cell["\<\ The first approximation, given on p. 148, is therefore equivalent \ to (after repeated division to get the unit running numerator, and just \ showing the first few terms)\ \>", "Text"], Cell[BoxData[ \(ContinuedFractionApprox[x_]\ := \ FromContinuedFraction[{0, \ x, \ x, \ x/2, \ 2\ x/3, \ 3\ x/\((2*4)\), \ 4*2*x/\((3*5)\)}]\)], "Input"], Cell[TextData[{ "so precomputation is necessary just to make a list to feed into ", StyleBox["FromContinuedFraction", FontFamily->"Courier", FontWeight->"Bold"], ", which is disappointing, and not to my mind worth pursuing." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 7", "Section"], Cell["This all works without modification.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 8", "Section"], Cell[TextData[{ "No significant V4 issues here. On p.186, the plot of machine-precision \ rumblings of Gamma now looks different, which is OK. On p. 187, as there is \ no normalization stuff left outside the integral, the integration for ", StyleBox["UpAndOutPutVega", FontFamily->"Courier", FontWeight->"Bold"], " and ", StyleBox["Gamma", FontFamily->"Courier", FontWeight->"Bold"], " use of ", StyleBox["[[2]]", FontFamily->"Courier", FontWeight->"Bold"], " still works, but use of the ", StyleBox["/. fix", FontFamily->"Courier", FontWeight->"Bold"], " construction is now preferable, as explained in the Main Points section." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 9", "Section"], Cell["This all works without modification.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 10", "Section"], Cell["\<\ First of all, see also the \"Recent Papers\" section for comments \ on the Geman-Yor implementation of continuously and arithmetically averaged \ Asian options. Please note the comment on peculiar parameters. In particular, \ low vols need a much longer Bromwich contour. On p. 207, it is recommended that you change\ \>", "Text"], Cell[BoxData[ \(G[p_, \[Mu]_, \ \ \[Nu]_, \ \[Alpha]_]\ = \ \(F[ p, \[Mu], \ \[Nu], \[Alpha]]\)[\([2]\)]\)], "Input"], Cell["to", "Text"], Cell[BoxData[ \(G[p_, \[Mu]_, \ \ \[Nu]_, \ \[Alpha]_]\ = \ F[p, \[Mu], \ \[Nu], \[Alpha]] /. \ fix\)], "Input"], Cell["\<\ in line with the new general management of integration output. \ Next, on p. 209, the penultimate line of code needs to be changed to\ \>", \ "Text"], Cell[BoxData[ \(Apart[ Residue[U[p, \[Nu], \[Nu], \[Alpha]], \ {p, 0}]\ /. \ Gamma[1/2 \((4 + 2 \[Nu])\)] -> \((1 + \[Nu])\)* Gamma[1 + \[Nu]]]\)], "Input"], Cell["\<\ as a result of the numerator coming out formatted \ differently.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 11", "Section"], Cell["This all works with V4.0.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 12", "Section"], Cell["No V4 issues in this Chapter.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 13", "Section"], Cell["No version 4 problems known.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 14", "Section"], Cell["\<\ We need to initialize one more variable - with the existing code, \ we get\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(ExplicitSolver\ = \n\t Compile[{{initial, _Real, 1}, \ {lower, _Real, 1}, \ {upper, _Real, 1}, alpha}, \n\t\tModule[{wold = initial, \ wnew = initial, \ wvold, m, k, \ tsize\ = \ Length[lower], xsize = Length[initial]}, \n\t\t\tFor[m = 2, \ m\ <= \ tsize, \ \(m++\), \n\t\t\t\t\((wvold\ = \ wold; \ wold = wnew; \n\t\t\t\t\tFor[k = 2, \ k\ < \ xsize, \ \(k++\), \n\t\t\t\t\t\((wnew[\([k]\)]\ = \ alpha\ \((wold[\([k - 1]\)] + wold[\([k + 1]\)])\) + \((1 - 2 alpha)\)\ wold[\([k]\)])\)]; \n\t\t\t\t\t\t\ wnew[\([1]\)]\ = \ lower[\([m]\)]; \n\t\t\t\t\t\twnew[\([xsize]\)]\ = \ upper[\([m]\)])\)]; \n\t\t\t{wvold, wold, wnew}]\n\t\t];\)\)], "Input"], Cell[BoxData[ \(Compile::"initvar" \(\(:\)\(\ \)\) "The variable \!\(wvold\) has not been initialized or has been \ initialized to Null."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(List\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"] }, Open ]], Cell[TextData[{ "So initialize ", StyleBox["wvold", FontFamily->"Courier", FontWeight->"Bold"], " as requested in the following, which works fine:" }], "Text"], Cell[BoxData[ \(\(ExplicitSolver\ = \n\t Compile[{{initial, _Real, 1}, \ {lower, _Real, 1}, \ {upper, _Real, 1}, alpha}, \n\t\tModule[{wold = initial, \ wnew = initial, \ wvold = initial, m, k, \ tsize\ = \ Length[lower], xsize = Length[initial]}, \n\t\t\tFor[m = 2, \ m\ <= \ tsize, \ \(m++\), \n\t\t\t\t\((wvold\ = \ wold; \ wold = wnew; \n\t\t\t\t\tFor[k = 2, \ k\ < \ xsize, \ \(k++\), \n\t\t\t\t\t\((wnew[\([k]\)]\ = \ alpha\ \((wold[\([k - 1]\)] + wold[\([k + 1]\)])\) + \((1 - 2 alpha)\)\ wold[\([k]\)])\)]; \n\t\t\t\t\t\t\ wnew[\([1]\)]\ = \ lower[\([m]\)]; \n\t\t\t\t\t\twnew[\([xsize]\)]\ = \ upper[\([m]\)])\)]; \n\t\t\t{wvold, wold, wnew}]\n\t\t];\)\)], "Input"], Cell["\<\ The timing is now improved, without any further changes - we have \ in V4, on a 266MHz G3 Power Mac\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[\(soln\ = \ ExplicitSolver[initial, lower, upper, \ alpha];\)]\)], "Input"], Cell[BoxData[ \({0.6333333333333258`\ Second, Null}\)], "Output"] }, Open ]], Cell["In V3, with either version, we had:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[\(soln\ = \ ExplicitSolver[initial, lower, upper, \ alpha];\)]\)], "Input"], Cell[BoxData[ \({1.5`\ Second, Null}\)], "Output"] }, Open ]], Cell["\<\ So that's a handy factor of two, without any attempt to figure out \ the implications of packed arrays. Everything else in Section 14.5, and \ indeed, the rest of the Chapter then proceeds as before, only rather \ faster.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 15", "Section"], Cell[TextData[{ "Once the change to ", StyleBox["ExplicitSolver", FontFamily->"Courier", FontWeight->"Bold"], " inherited from Chapter 14 is made this proceeds as before, only faster. \ The tridiagonal solver compiles as before." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 16", "Section"], Cell["\<\ No V4 issues here - it all works. The integrator continues to \ complain about underflow when evaluating the CJM integrals, but the analysis \ is OK.\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 17", "Section"], Cell["\<\ No V4 issues here - it all works, but the naive LP solution appears \ to be slower (to be investigated).\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 18", "Section"], Cell[TextData[{ "No significant V4 issues here. The outputs will look slightly different \ due to the use of double-struck characters in Standard Form output. On p.353 \ of Section 18.3 the ", StyleBox["Series", FontFamily->"Courier", FontWeight->"Bold"], " function now supplies extra terms in the expansion of ", StyleBox["p", FontFamily->"Courier", FontWeight->"Bold"], " and ", StyleBox["q", FontFamily->"Courier", FontWeight->"Bold"], ". \n\nOn p. 359 the calculation of ", StyleBox["provisionalsoln", FontFamily->"Courier", FontWeight->"Bold"], " returns just two solution sets, the second of which is still the correct \ one, rather tidied up now." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 19", "Section"], Cell["No V4 issues.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 20", "Section"], Cell["\<\ This just needs the by-now familiar initialization adjustments to \ code that is fed to compile. Specifically, on p. 388, we now use\ \>", "Text"], Cell[BoxData[ \(\(ManyTimeStepEuro\ = \ \n Compile[{{initial, \ _Real, \ 1}, \ {p, _Real, \ 0}, \ {q, \ _Real, \ 0}, \ {n, \ _Integer, \ 0}}, \n Module[{new\ = \ initial, \ k, \ old\ = \ initial, \ vold\ = \ initial}, \n For[k\ = \ 1, \ k <= n - 1, \ \(k++\), \ \n\((old\ = \ new; \ new\ = \ OneTimeStepEuro[old, p, q])\)]; \nvold\ = \ old; \ old\ = \ new; \n new\ = \ \ OneTimeStepEuro[old, p, q]; \n{Join[new, old], \ vold}]];\)\)], "Input"], Cell[TextData[{ "On pp. 391-392, there are similar changes for the American style, and we \ give the four explicit modifications for Put and Call, and procedural and \ functional variants. It is sufficient to simply add the initialization of the \ local Module variables ", StyleBox["old", FontFamily->"Courier", FontWeight->"Bold"], " and ", StyleBox["vold", FontFamily->"Courier", FontWeight->"Bold"], "." }], "Text"], Cell[BoxData[ \(\(ManyTimeStepAmerCall\ = \ \n Compile[{{initial, \ _Real, \ 1}, \ {p, _Real, \ 0}, \ {q, \ _Real, \ 0}, \ {S, \ _Real, \ 0}, \ {u, \ _Real, \ 0}, \ {d, \ _Real, \ 0}, {n, \ _Integer, \ 0}, \ {K, \ _Real, \ 0}}, \n Module[{new\ = \ initial, \ k, \ r, \ old = \ initial, \ vold = \ initial, \ payoff, \ finpay\ = \ {Max[S - K, 0]}}, \n For[k\ = \ 1, \ k <= n - 1, \ \(k++\), \ \n\((payoff\ = \ Table[Max[S\ d^r\ u^\((n - k - r)\) - K, 0], \ {r, \ 0, n - k}]; \nold\ = \ new; \ new\ = \ OneTimeStepAmer[old, payoff, \ p, q])\)]; \n vold\ = \ old; \ old\ = \ new; \n new\ = \ \ OneTimeStepAmer[old, finpay, p, q]; \n{Join[new, old], \ vold}]];\)\)], "Input"], Cell[BoxData[ \(\(ManyTimeStepAmerCallFun\ = \ \n Compile[{{initial, \ _Real, \ 1}, \ {p, _Real, \ 0}, \ {q, \ _Real, \ 0}, \ {S, \ _Real, \ 0}, \ {u, \ _Real, \ 0}, \ {d, \ _Real, \ 0}, {n, \ _Integer, \ 0}, \ {K, \ _Real, \ 0}}, \n Module[{new\ = \ initial, \ k, \ r, \ old = \ initial, \ vold = \ initial, \ payoff, \ finpay\ = \ {Max[S - K, 0]}}, \n For[k\ = \ 1, \ k <= n - 1, \ \(k++\), \ \n\((payoff\ = \ Table[Max[S\ d^r\ u^\((n - k - r)\) - K, 0], \ {r, \ 0, n - k}]; \n\ \ \ old\ = \ new; \ \n\t new\ = \ OneTimeStepAmerFun[old, payoff, \ p, q])\)]; \n vold\ = \ old; \ old\ = \ new; \n new\ = \ \ OneTimeStepAmerFun[old, finpay, p, q]; \n{Join[new, old], \ vold}]];\)\)], "Input"], Cell[BoxData[ \(\(ManyTimeStepAmerPut\ = \ \n Compile[{{initial, \ _Real, \ 1}, \ {p, _Real, \ 0}, \ {q, \ _Real, \ 0}, \ {S, \ _Real, \ 0}, \ {u, \ _Real, \ 0}, \ {d, \ _Real, \ 0}, {n, \ _Integer, \ 0}, \ {K, \ _Real, \ 0}}, \n Module[{new\ = \ initial, \ k, \ r, \ old = \ initial, \ vold = \ initial, \ payoff, \ finpay\ = \ {Max[K - S, 0]}}, \n For[k\ = \ 1, \ k <= n - 1, \ \(k++\), \ \n\((payoff\ = \ Table[Max[K - S\ d^r\ u^\((n - k - r)\), 0], \ {r, \ 0, n - k}]; \nold\ = \ new; \ new\ = \ OneTimeStepAmer[old, payoff, \ p, q])\)]; \n vold\ = \ old; \ old\ = \ new; \n new\ = \ \ OneTimeStepAmer[old, finpay, p, q]; \n{Join[new, old], \ vold}]];\)\)], "Input"], Cell[BoxData[ \(\(ManyTimeStepAmerPutFun\ = \ \n Compile[{{initial, \ _Real, \ 1}, \ {p, _Real, \ 0}, \ {q, \ _Real, \ 0}, \ {S, \ _Real, \ 0}, \ {u, \ _Real, \ 0}, \ {d, \ _Real, \ 0}, {n, \ _Integer, \ 0}, \ {K, \ _Real, \ 0}}, \n Module[{new\ = \ initial, \ k, \ r, \ old = \ initial, \ vold = \ initial, \ payoff, \ finpay\ = \ {Max[K - S, 0]}}, \n For[k\ = \ 1, \ k <= n - 1, \ \(k++\), \ \n\((payoff\ = \ Table[Max[K - S\ d^r\ u^\((n - k - r)\), 0], \ {r, \ 0, n - k}]; \nold\ = \ new; \ new\ = \ OneTimeStepAmerFun[old, payoff, \ p, q])\)]; \n vold\ = \ old; \ old\ = \ new; \n new\ = \ \ OneTimeStepAmerFun[old, finpay, p, q]; \n{Join[new, old], \ vold}]];\)\)], "Input"], Cell["When we come to the trinomial model, we use", "Text"], Cell[BoxData[ \(\(ManyTimeStepEuroTri\ = \ \n Compile[{{initial, \ _Real, \ 1}, \ {p, _Real, \ 0}, \ {q, \ _Real, \ 0}, \ {r, \ _Real, \ 0}, {n, \ _Integer, \ 0}}, \n Module[{new\ = \ initial, \ k, \ old\ = \ initial}, \n For[k\ = \ 1, \ k <= n, \ \(k++\), \ \n\((old\ = \ new; \ new\ = \ OneTimeStepEuroTri[old, p, q, r])\)]; \n Join[new, old]]];\)\)], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 21", "Section"], Cell[TextData[{ "The timings of Convert are better under V4, but you should still avoid \ this method! The function ", StyleBox["norb", FontFamily->"Courier", FontWeight->"Bold"], " on p. 404 still takes 0.25 seconds on the same machine as before.\n\nThe \ change in the compiler requires several changes in this Chapter. As noted in \ the summary section, the definition on p. 404 gives, now, " }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(norm = \ Compile[{mu, \ sigma}, \ \n\t\tModule[{va, \ vb, \ rad\ = \ 2.0, \ den}, \n\t\t\tWhile[ rad\ >= 1.00, \n\t\t\t\t\t\((va\ = \ 2.0*Random[]\ - \ 1.0; \n\t\t\t\t\tvb\ = \ 2.0*Random[]\ - 1.0; \n\t\t\t\t\trad\ = \ va*va + vb*vb)\)]; \n\t\t\tden\ = \ Sqrt[\(-2.0\)*Log[rad]/rad]; \n\t\t\tmu + sigma*va*den]];\)\)], "Input"], Cell[BoxData[ \(General::"spell" \(\(:\)\(\ \)\) "Possible spelling error: new symbol name \"\!\(norm\)\" is similar to \ existing symbols \!\({nora, norb, Norm}\)."\)], "Message"], Cell[BoxData[ \(Compile::"initvar" \(\(:\)\(\ \)\) "The variable \!\(va\) has not been initialized or has been initialized \ to Null."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(Times\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(Plus\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(Times\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"], Cell[BoxData[ \(General::"stop" \(\(:\)\(\ \)\) "Further output of \!\(Compile :: \"cptype\"\) will be suppressed \ during this calculation."\)], "Message"] }, Open ]], Cell["and we replace it by:", "Text"], Cell[BoxData[ \(\(norm = \ Compile[{mu, \ sigma}, \ \n\t\tModule[{va = 1. , \ vb, \ rad\ = \ 2.0, \ den = 1. }, \n\t\t\tWhile[ rad\ >= 1.00, \n\t\t\t\t\t\((va\ = \ 2.0*Random[]\ - \ 1.0; \n\t\t\t\t\tvb\ = \ 2.0*Random[]\ - 1.0; \n\t\t\t\t\trad\ = \ va*va + vb*vb)\)]; \n\t\t\tden\ = \ Sqrt[\(-2.0\)*Log[rad]/rad]; \n\t\t\tmu + sigma*va*den]];\)\)], "Input"], Cell["A similar fix applies to normpair: before:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(\(normpair = \ Compile[{mu, \ sigma}, \ Module[{va, \ vb, \ rad\ = \ 2.0, \ den}, \n\t\t\tWhile[ rad\ >= 1.00, \n\t\t\t\t\t\((va\ = \ 2.0*Random[]\ - \ 1.0; \ vb\ = \ 2.0*Random[]\ - 1.0; \n\t\t\t\t\trad\ = \ va*va + vb*vb)\)]; \n\t\t\tden\ = \ Sqrt[\(-2.0\)*Log[rad]/rad]; \n\t\t\t{mu + sigma*va*den, \ mu + sigma*vb*den}]];\)\)], "Input"], Cell[BoxData[ \(Compile::"initvar" \(\(:\)\(\ \)\) "The variable \!\(va\) has not been initialized or has been initialized \ to Null."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(Times\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(Plus\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"], Cell[BoxData[ \(Compile::"cptype" \(\(:\)\(\ \)\) "\!\(Times\) not supported for type \!\(\"Void\"\); evaluation will use \ the uncompiled function."\)], "Message"], Cell[BoxData[ \(General::"stop" \(\(:\)\(\ \)\) "Further output of \!\(Compile :: \"cptype\"\) will be suppressed \ during this calculation."\)], "Message"], Cell[BoxData[ \(Compile::"initvar" \(\(:\)\(\ \)\) "The variable \!\(vb\) has not been initialized or has been initialized \ to Null."\)], "Message"] }, Open ]], Cell[TextData[{ "This time we need to initialize both ", StyleBox["va", FontFamily->"Courier", FontWeight->"Bold"], " and ", StyleBox["vb", FontFamily->"Courier", FontWeight->"Bold"], ":" }], "Text"], Cell[BoxData[ \(\(normpair = \ Compile[{mu, \ sigma}, \ Module[{va = 1. , \ vb = 1. , \ rad\ = \ 2.0, \ den}, \n\t\t\tWhile[ rad\ >= 1.00, \n\t\t\t\t\t\((va\ = \ 2.0*Random[]\ - \ 1.0; \ vb\ = \ 2.0*Random[]\ - 1.0; \n\t\t\t\t\trad\ = \ va*va + vb*vb)\)]; \n\t\t\tden\ = \ Sqrt[\(-2.0\)*Log[rad]/rad]; \n\t\t\t{mu + sigma*va*den, \ mu + sigma*vb*den}]];\)\)], "Input"], Cell[CellGroupData[{ Cell["Antithetic Variations", "Subsubsection"], Cell["\<\ The initialized versions of these to be used with V4 are \ just:\ \>", "Text"], Cell[BoxData[ \(\(normat = \ Compile[{mu, \ sigma}, \ \n\t\tModule[{va = 1.0, \ vb = 1.0, \ rad\ = \ 2.0, \ den}, \n\t\t\tWhile[ rad\ >= 1.00, \n\t\t\t\t\t\((va\ = \ 2.0*Random[]\ - \ 1.0; \n\t\t\t\t\tvb\ = \ 2.0*Random[]\ - 1.0; \n\t\t\t\t\trad\ = \ va*va + vb*vb)\)]; \n\t\t\tden\ = \ Sqrt[\(-2.0\)*Log[rad]/rad]; \n\t\t\t{mu + sigma*va*den, \ mu - sigma*va*den}]];\)\)], "Input"], Cell[BoxData[ \(\(normpairat = \ Compile[{mu, \ sigma}, \ \n\t\tModule[{va = 1.0, \ vb = 1.0, \ rad\ = \ 2.0, \ den}, \n\t\t\tWhile[ rad\ >= 1.00, \n\t\t\t\t\t\((va\ = \ 2.0*Random[]\ - \ 1.0; \n\t\t\t\t\tvb\ = \ 2.0*Random[]\ - 1.0; \n\t\t\t\t\trad\ = \ va*va + vb*vb)\)]; \n\t\t\tden\ = \ Sqrt[\(-2.0\)*Log[rad]/rad]; \n\t\t\t{mu + sigma*va*den, \ mu - sigma*va*den, \ mu + sigma*vb*den, \ mu - sigma*vb*den}]];\)\)], "Input"], Cell["\<\ For reasons that are not yet understood, in Section 21.5, the \ EuroCallB (and put) versions now run slightly slower than the type A version, \ under V4. This will be investigated. (As noted in the introduction, this \ notebook is about making sure code works under V4 - fully optimized material \ is under consideration).\ \>", "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 22", "Section"], Cell[TextData[{ "The modification to ", StyleBox["normpairat", FontFamily->"Courier", FontWeight->"Bold"], " made in Chapter 21 must also be made here. There are no other V4 issues." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 23", "Section"], Cell["No V4 issues here - it all works.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 24", "Section"], Cell["\<\ Use the new compiled version of the norm function discussed \ previously.\ \>", "Text"], Cell[BoxData[ \(\(norm = \ Compile[{mu, \ sigma}, \ \n Module[{va\ = \ 1. , \ vb, \ rad\ = \ 2.0, \ den}, While[rad\ >= 1.00, \n\t\t\t\((va\ = \ 2.0*Random[]\ - \ 1.0; vb\ = \ 2.0*Random[]\ - 1.0; \n\t\t\trad\ = \ va*va + vb*vb)\)]; den\ = \ Sqrt[\(-2.0\)*Log[rad]/rad]; \n\t\t\tmu + sigma*va*den]];\)\)], "Input"], Cell["Then everything works.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 25", "Section"], Cell[TextData[{ "The numerical factors of 2 and 1/2 arrange themselves differently under V4 \ in the construction of equations (24) and (25) by the use of Traditional Form \ applied to ", StyleBox["aeqn", FontFamily->"Courier", FontWeight->"Bold"], " and ", StyleBox["beqn", FontFamily->"Courier", FontWeight->"Bold"], ". But there is no logical change. At the top of p. 477, the \ post-application of [[1]] is now un-necessary. Under V4, there are various \ re-organizations of numerical factors in outputs throughout this Chapter that \ are of no consequence." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 26", "Section"], Cell["\<\ See the Main Points section for a discussion of NonlinearFit. On p. \ 486, the following code fails\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(NonlinearFit[exptdata, a\ + \ b/\((\((x - c)\)^2\ + \ d)\)\ + \ e/\((\((x - f)\)^2\ + \ g)\), \ x, \ {a, b, {c, 11}, d, \ e, \ {f, 14}, \ g}, \ MaxIterations\ -> \ 40]\)], "Input"], Cell[BoxData[ \(NonlinearFit::"fdin" \(\(:\)\(\ \)\) "Form of parameter specification \!\({c, 11}\) is inconsistent with \ other parameter specifications."\)], "Message"] }, Open ]], Cell["\<\ It does run, with no suggestions for starting values, but gives \ answers that are rubbish.\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(NonlinearFit[exptdata, a\ + \ b/\((\((x - c)\)^2\ + \ d)\)\ + \ e/\((\((x - f)\)^2\ + \ g)\), \ x, \ {a, b, c, d, \ e, \ f, \ g}, \ MaxIterations\ -> \ 40]\)], "Input"], Cell[BoxData[ \(\(\(1.0229333996173884`\)\(\[InvisibleSpace]\)\) - 2.6611523558289885`\/\(\(\(2.685939975421488`\)\(\[InvisibleSpace]\)\) \ + \((\(-18.11050856760202`\) + x)\)\^2\) + 88.57389415833887`\/\(\(\(123.11243921869621`\)\(\[InvisibleSpace]\)\) \ + \((\(\(197.00505852135547`\)\(\[InvisibleSpace]\)\) + x)\)\^2\)\)], "Output"] }, Open ]], Cell["\<\ The only way to get anywhere is to guess all the parameters - the \ following does work:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(NonlinearFit[exptdata, a\ + \ b/\((\((x - c)\)^2\ + \ d)\)\ + \ e/\((\((x - f)\)^2\ + \ g)\), \ x, \ {{a, 1}, {b, 1}, {c, 11}, {d, 1}, \ {e, 1}, \ {f, \ 14}, \ {g, 1}}, \ MaxIterations\ -> \ 40]\)], "Input"], Cell[BoxData[ \(\(\(0.14122598190491795`\)\(\[InvisibleSpace]\)\) + 0.9895733726344869`\/\(\(\(0.49323423605040556`\)\(\[InvisibleSpace]\)\)\ + \((\(-13.003187490205482`\) + x)\)\^2\) + 0.9970504291896056`\/\(\(\(0.09939600335766653`\)\(\[InvisibleSpace]\)\)\ + \((\(-9.998488661013365`\) + x)\)\^2\)\)], "Output"] }, Open ]], Cell["No other V4 issues noted in Chapter 26.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 27", "Section"], Cell["No V4 issues.", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["Chapter 28", "Section"], Cell["No V4 issues. The series solution still takes an eternity.", "Text"] }, Closed]] }, Open ]] }, Closed]] }, Open ]] }, FrontEndVersion->"5.0 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 951}}, WindowSize->{591, 622}, WindowMargins->{{326, Automatic}, {Automatic, 98}}, ShowCellLabel->False ] (******************************************************************* 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->{ "Info3285482698-3438469"->{ Cell[4901, 162, 332, 9, 44, "Print", CellTags->"Info3285482698-3438469"]}, "Info3285482767-2024397"->{ Cell[5669, 190, 353, 9, 44, "Print", CellTags->"Info3285482767-2024397"]}, "Info3285485322-1473113"->{ Cell[9385, 342, 413, 10, 63, "Print", CellTags->"Info3285485322-1473113"]} } *) (*CellTagsIndex CellTagsIndex->{ {"Info3285482698-3438469", 172294, 5437}, {"Info3285482767-2024397", 172409, 5440}, {"Info3285485322-1473113", 172524, 5443} } *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1776, 53, 65, 0, 150, "Title"], Cell[1844, 55, 63, 0, 51, "Subtitle"], Cell[1910, 57, 221, 13, 250, "Subsubtitle"], Cell[CellGroupData[{ Cell[2156, 74, 34, 0, 73, "Section"], Cell[2193, 76, 1085, 21, 204, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3315, 102, 41, 0, 51, "Subtitle"], Cell[CellGroupData[{ Cell[3381, 106, 33, 0, 73, "Section"], Cell[CellGroupData[{ Cell[3439, 110, 45, 0, 38, "Subsection"], Cell[3487, 112, 122, 3, 33, "Text"], Cell[CellGroupData[{ Cell[3634, 119, 128, 2, 50, "Input"], Cell[3765, 123, 370, 6, 37, "Message"], Cell[4138, 131, 60, 1, 32, "Output"] }, Open ]], Cell[4213, 135, 386, 8, 90, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4636, 148, 52, 0, 30, "Subsection"], Cell[4691, 150, 140, 5, 33, "Text"], Cell[CellGroupData[{ Cell[4856, 159, 42, 1, 30, "Input"], Cell[4901, 162, 332, 9, 44, "Print", CellTags->"Info3285482698-3438469"] }, Open ]], Cell[5248, 174, 354, 9, 71, "Text"], Cell[CellGroupData[{ Cell[5627, 187, 39, 1, 30, "Input"], Cell[5669, 190, 353, 9, 44, "Print", CellTags->"Info3285482767-2024397"] }, Open ]], Cell[6037, 202, 266, 5, 71, "Text"], Cell[6306, 209, 397, 10, 174, "Input"], Cell[6706, 221, 218, 4, 71, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[6961, 230, 31, 0, 30, "Subsection"], Cell[6995, 232, 183, 4, 52, "Text"], Cell[CellGroupData[{ Cell[7203, 240, 28, 0, 30, "Input"], Cell[7234, 242, 51, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7322, 248, 29, 0, 30, "Input"], Cell[7354, 250, 50, 1, 29, "Output"] }, Open ]], Cell[7419, 254, 47, 0, 33, "Text"], Cell[CellGroupData[{ Cell[7491, 258, 50, 1, 30, "Input"], Cell[7544, 261, 53, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7634, 267, 26, 0, 30, "Input"], Cell[7663, 269, 147, 2, 42, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7847, 276, 32, 0, 30, "Input"], Cell[7882, 278, 84, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[8003, 284, 25, 0, 30, "Input"], Cell[8031, 286, 57, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[8125, 292, 31, 0, 30, "Input"], Cell[8159, 294, 57, 1, 29, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[8265, 301, 43, 0, 30, "Subsection"], Cell[8311, 303, 368, 9, 72, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[8716, 317, 31, 0, 30, "Subsection"], Cell[8750, 319, 310, 5, 71, "Text"], Cell[CellGroupData[{ Cell[9085, 328, 51, 1, 30, "Input"], Cell[9139, 331, 157, 3, 48, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[9333, 339, 49, 1, 30, "Input"], Cell[9385, 342, 413, 10, 63, "Print", CellTags->"Info3285485322-1473113"] }, Open ]], Cell[9813, 355, 71, 0, 33, "Text"], Cell[CellGroupData[{ Cell[9909, 359, 136, 4, 30, "Input"], Cell[10048, 365, 222, 4, 79, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10307, 374, 165, 3, 50, "Input"], Cell[10475, 379, 85, 1, 51, "Output"] }, Open ]], Cell[10575, 383, 87, 3, 33, "Text"], Cell[CellGroupData[{ Cell[10687, 390, 158, 3, 50, "Input"], Cell[10848, 395, 60, 1, 40, "Output"] }, Open ]], Cell[10923, 399, 555, 12, 111, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[11515, 416, 115, 3, 48, "Subsection"], Cell[CellGroupData[{ Cell[11655, 423, 35, 0, 29, "Subsubsection"], Cell[11693, 425, 153, 3, 52, "Text"], Cell[11849, 430, 124, 3, 33, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[12010, 438, 34, 0, 29, "Subsubsection"], Cell[12047, 440, 145, 3, 52, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[12229, 448, 34, 0, 29, "Subsubsection"], Cell[12266, 450, 381, 11, 73, "Text"] }, Open ]] }, Closed]] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[12720, 469, 40, 0, 51, "Subtitle"], Cell[CellGroupData[{ Cell[12785, 473, 34, 0, 73, "Section"], Cell[12822, 475, 1563, 26, 386, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[14422, 506, 28, 0, 43, "Section"], Cell[14453, 508, 736, 12, 185, "Text"], Cell[CellGroupData[{ Cell[15214, 524, 56, 0, 38, "Subsection"], Cell[15273, 526, 907, 29, 130, "Text"], Cell[16183, 557, 3090, 65, 115, "DisplayFormula"], Cell[19276, 624, 411, 14, 54, "Text"], Cell[19690, 640, 85, 1, 48, "Input"], Cell[19778, 643, 247, 6, 52, "Text"], Cell[20028, 651, 84, 1, 30, "Input"], Cell[20115, 654, 348, 7, 109, "Text"], Cell[20466, 663, 155, 3, 61, "DisplayFormula"], Cell[20624, 668, 283, 9, 52, "Text"], Cell[20910, 679, 327, 5, 78, "DisplayFormula"], Cell[21240, 686, 30, 0, 33, "Text"], Cell[21273, 688, 278, 5, 43, "DisplayFormula"], Cell[21554, 695, 350, 7, 71, "Text"], Cell[21907, 704, 76, 1, 25, "DisplayFormula"], Cell[21986, 707, 23, 0, 33, "Text"], Cell[22012, 709, 149, 4, 26, "DisplayFormula"], Cell[22164, 715, 63, 0, 33, "Text"], Cell[22230, 717, 369, 5, 43, "DisplayFormula"], Cell[22602, 724, 66, 0, 33, "Text"], Cell[22671, 726, 107, 2, 41, "DisplayFormula"], Cell[22781, 730, 118, 2, 41, "DisplayFormula"], Cell[22902, 734, 29, 0, 33, "Text"], Cell[22934, 736, 140, 2, 43, "DisplayFormula"], Cell[23077, 740, 196, 5, 52, "Text"], Cell[23276, 747, 128, 2, 43, "DisplayFormula"], Cell[23407, 751, 45, 0, 33, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[23489, 756, 62, 0, 38, "Subsection"], Cell[23554, 758, 116, 3, 33, "Text"], Cell[23673, 763, 191, 4, 40, "DisplayFormula"], Cell[23867, 769, 601, 11, 128, "Text"], Cell[24471, 782, 764, 23, 112, "Text"], Cell[25238, 807, 148, 2, 50, "Input"], Cell[25389, 811, 1451, 29, 340, "Text"], Cell[CellGroupData[{ Cell[26865, 844, 57, 1, 30, "Input"], Cell[26925, 847, 93, 1, 30, "Output"] }, Open ]], Cell[27033, 851, 220, 7, 53, "Text"], Cell[27256, 860, 160, 4, 52, "Text"], Cell[27419, 866, 195, 3, 41, "DisplayFormula"], Cell[27617, 871, 67, 0, 33, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[27733, 877, 78, 0, 99, "Section"], Cell[27814, 879, 208, 4, 52, "Text"], Cell[CellGroupData[{ Cell[28047, 887, 50, 0, 38, "Subsection"], Cell[28100, 889, 1095, 18, 174, "Text"], Cell[CellGroupData[{ Cell[29220, 911, 66, 0, 42, "Subsubsection"], Cell[29289, 913, 1070, 23, 126, "Text"], Cell[30362, 938, 142, 3, 31, "DisplayFormula"], Cell[30507, 943, 34, 0, 30, "Text"], Cell[30544, 945, 147, 3, 31, "DisplayFormula"], Cell[30694, 950, 21, 0, 30, "Text"], Cell[30718, 952, 355, 10, 51, "DisplayFormula"], Cell[31076, 964, 742, 18, 67, "Text"], Cell[31821, 984, 265, 5, 59, "Input"], Cell[32089, 991, 97, 3, 30, "Text"], Cell[CellGroupData[{ Cell[32211, 998, 62, 1, 27, "Input"], Cell[32276, 1001, 53, 1, 26, "Output"] }, Open ]], Cell[32344, 1005, 104, 3, 30, "Text"], Cell[32451, 1010, 292, 4, 59, "Input"], Cell[CellGroupData[{ Cell[32768, 1018, 205, 4, 75, "Input"], Cell[32976, 1024, 809, 16, 153, "Output"] }, Open ]], Cell[33800, 1043, 43, 0, 30, "Text"], Cell[CellGroupData[{ Cell[33868, 1047, 104, 2, 27, "Input"], Cell[33975, 1051, 53, 1, 26, "Output"] }, Open ]], Cell[34043, 1055, 185, 4, 30, "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[34277, 1065, 35, 0, 30, "Subsection"], Cell[34315, 1067, 461, 10, 64, "Text"], Cell[34779, 1079, 334, 9, 90, "Text"], Cell[CellGroupData[{ Cell[35138, 1092, 37, 0, 42, "Subsubsection"], Cell[35178, 1094, 1131, 22, 132, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[36346, 1121, 56, 0, 42, "Subsubsection"], Cell[36405, 1123, 1111, 28, 98, "Text"], Cell[37519, 1153, 455, 8, 75, "Input"], Cell[37977, 1163, 70, 0, 30, "Text"], Cell[38050, 1165, 182, 3, 43, "NumberedEquation"], Cell[38235, 1170, 199, 5, 30, "Text"], Cell[38437, 1177, 233, 4, 39, "NumberedEquation"], Cell[38673, 1183, 31, 0, 30, "Text"], Cell[38707, 1185, 354, 5, 71, "NumberedEquation"], Cell[39064, 1192, 457, 15, 66, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[39558, 1212, 138, 5, 42, "Subsubsection"], Cell[39699, 1219, 365, 6, 78, "Text"], Cell[CellGroupData[{ Cell[40089, 1229, 381, 7, 81, "Input"], Cell[40473, 1238, 388, 7, 114, "Output"] }, Open ]], Cell[40876, 1248, 184, 4, 46, "Text"], Cell[CellGroupData[{ Cell[41085, 1256, 233, 4, 68, "Input"], Cell[41321, 1262, 838, 18, 58, "Output"] }, Open ]], Cell[42174, 1283, 1358, 24, 212, "Text"], Cell[43535, 1309, 56, 1, 27, "Input"], Cell[43594, 1312, 739, 13, 187, "Input"], Cell[44336, 1327, 351, 9, 62, "Text"], Cell[CellGroupData[{ Cell[44712, 1340, 161, 3, 43, "Input"], Cell[44876, 1345, 110, 2, 26, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[45023, 1352, 161, 3, 43, "Input"], Cell[45187, 1357, 144, 5, 24, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[45368, 1367, 161, 3, 43, "Input"], Cell[45532, 1372, 144, 5, 24, "Output"] }, Open ]], Cell[45691, 1380, 352, 6, 78, "Text"], Cell[CellGroupData[{ Cell[46068, 1390, 161, 3, 43, "Input"], Cell[46232, 1395, 145, 5, 24, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[46414, 1405, 161, 3, 43, "Input"], Cell[46578, 1410, 146, 5, 24, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[46761, 1420, 164, 3, 43, "Input"], Cell[46928, 1425, 145, 5, 24, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[47110, 1435, 171, 3, 59, "Input"], Cell[47284, 1440, 138, 2, 26, "Output"] }, Open ]], Cell[47437, 1445, 314, 6, 62, "Text"], Cell[CellGroupData[{ Cell[47776, 1455, 165, 3, 43, "Input"], Cell[47944, 1460, 177, 6, 24, "Output"] }, Open ]], Cell[48136, 1469, 138, 3, 30, "Text"], Cell[CellGroupData[{ Cell[48299, 1476, 162, 3, 43, "Input"], Cell[48464, 1481, 177, 6, 24, "Output"] }, Open ]], Cell[48656, 1490, 508, 12, 66, "Text"], Cell[CellGroupData[{ Cell[49189, 1506, 129, 3, 27, "Input"], Cell[49321, 1511, 88, 1, 26, "Output"] }, Open ]], Cell[49424, 1515, 3929, 75, 482, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[53390, 1595, 35, 0, 42, "Subsubsection"], Cell[53428, 1597, 691, 15, 148, "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[54168, 1618, 63, 0, 30, "Subsection"], Cell[54234, 1620, 975, 18, 205, "Text"], Cell[55212, 1640, 124, 2, 25, "DisplayFormula"], Cell[55339, 1644, 37, 0, 33, "Text"], Cell[55379, 1646, 142, 3, 25, "DisplayFormula"], Cell[55524, 1651, 141, 5, 33, "Text"], Cell[55668, 1658, 118, 2, 49, "DisplayFormula"], Cell[55789, 1662, 21, 0, 30, "Text"], Cell[55813, 1664, 160, 3, 41, "DisplayFormula"], Cell[55976, 1669, 234, 8, 30, "Text"], Cell[56213, 1679, 110, 2, 24, "DisplayFormula"], Cell[56326, 1683, 110, 2, 24, "DisplayFormula"], Cell[56439, 1687, 200, 5, 30, "Text"], Cell[56642, 1694, 141, 3, 25, "DisplayFormula"], Cell[56786, 1699, 31, 0, 30, "Text"], Cell[56820, 1701, 126, 2, 25, "DisplayFormula"], Cell[56949, 1705, 160, 5, 32, "Text"], Cell[57112, 1712, 73, 1, 31, "Input"], Cell[CellGroupData[{ Cell[57210, 1717, 119, 2, 27, "Input"], Cell[57332, 1721, 11864, 384, 186, 4001, 282, "GraphicsData", "PostScript", \ "Graphics"] }, Open ]], Cell[69211, 2108, 339, 11, 30, "Text"], Cell[69553, 2121, 125, 2, 27, "DisplayFormula"], Cell[69681, 2125, 65, 0, 30, "Text"], Cell[69749, 2127, 131, 2, 52, "DisplayFormula"], Cell[69883, 2131, 561, 15, 46, "Text"], Cell[70447, 2148, 135, 2, 24, "DisplayFormula"], Cell[70585, 2152, 134, 3, 30, "Text"], Cell[70722, 2157, 257, 6, 48, "DisplayFormula"], Cell[70982, 2165, 45, 0, 30, "Text"], Cell[71030, 2167, 97, 2, 38, "DisplayFormula"], Cell[71130, 2171, 240, 8, 30, "Text"], Cell[71373, 2181, 218, 3, 48, "DisplayFormula"], Cell[71594, 2186, 1413, 38, 190, "Text"], Cell[73010, 2226, 56, 0, 30, "Text"], Cell[73069, 2228, 62, 0, 27, "Input"], Cell[73134, 2230, 152, 3, 42, "Input"], Cell[73289, 2235, 71, 0, 27, "Input"], Cell[73363, 2237, 159, 4, 42, "Input"], Cell[73525, 2243, 147, 4, 42, "Input"], Cell[73675, 2249, 544, 20, 297, "Input"], Cell[74222, 2271, 555, 20, 297, "Input"], Cell[74780, 2293, 51, 0, 30, "Text"], Cell[CellGroupData[{ Cell[74856, 2297, 91, 1, 27, "Input"], Cell[74950, 2300, 78, 1, 26, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[75065, 2306, 90, 1, 27, "Input"], Cell[75158, 2309, 70, 1, 26, "Output"] }, Open ]], Cell[75243, 2313, 51, 0, 30, "Text"], Cell[CellGroupData[{ Cell[75319, 2317, 90, 1, 30, "Input"], Cell[75412, 2320, 71, 1, 26, "Output"] }, Open ]], Cell[75498, 2324, 135, 3, 52, "Text"], Cell[CellGroupData[{ Cell[75658, 2331, 89, 1, 30, "Input"], Cell[75750, 2334, 74, 1, 29, "Output"] }, Open ]], Cell[75839, 2338, 77, 0, 33, "Text"], Cell[CellGroupData[{ Cell[75941, 2342, 91, 1, 30, "Input"], Cell[76035, 2345, 101, 2, 29, "Output"] }, Open ]], Cell[76151, 2350, 208, 4, 52, "Text"], Cell[76362, 2356, 111, 3, 48, "Input"], Cell[76476, 2361, 111, 3, 48, "Input"], Cell[CellGroupData[{ Cell[76612, 2368, 160, 2, 50, "Input"], Cell[76775, 2372, 93, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[76905, 2378, 150, 3, 30, "Input"], Cell[77058, 2383, 14044, 464, 186, 4949, 347, "GraphicsData", "PostScript", \ "Graphics"] }, Open ]], Cell[91117, 2850, 724, 11, 166, "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[91890, 2867, 29, 0, 43, "Section"], Cell[91922, 2869, 404, 7, 109, "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[92375, 2882, 37, 0, 53, "Subtitle"], Cell[92415, 2884, 841, 12, 185, "Text"], Cell[CellGroupData[{ Cell[93281, 2900, 46, 0, 30, "Subsubtitle"], Cell[CellGroupData[{ Cell[93352, 2904, 64, 0, 38, "Subsection"], Cell[93419, 2906, 697, 13, 111, "Text"], Cell[CellGroupData[{ Cell[94141, 2923, 41, 1, 27, "Input"], Cell[94185, 2926, 69, 1, 26, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[94291, 2932, 104, 2, 27, "Input"], Cell[94398, 2936, 570, 15, 26, "Output"] }, Open ]], Cell[94983, 2954, 93, 3, 30, "Text"], Cell[CellGroupData[{ Cell[95101, 2961, 55, 1, 27, "Input"], Cell[95159, 2964, 73, 1, 28, "Output"] }, Open ]], Cell[95247, 2968, 91, 3, 30, "Text"], Cell[CellGroupData[{ Cell[95363, 2975, 41, 1, 27, "Input"], Cell[95407, 2978, 76, 1, 26, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[95520, 2984, 104, 2, 27, "Input"], Cell[95627, 2988, 159, 3, 21, "Message"], Cell[95789, 2993, 163, 4, 26, "Output"] }, Open ]], Cell[95967, 3000, 89, 3, 30, "Text"], Cell[CellGroupData[{ Cell[96081, 3007, 119, 3, 27, "Input"], Cell[96203, 3012, 169, 4, 26, "Output"] }, Open ]], Cell[96387, 3019, 37, 0, 30, "Text"], Cell[CellGroupData[{ Cell[96449, 3023, 55, 1, 27, "Input"], Cell[96507, 3026, 50, 1, 26, "Output"] }, Open ]], Cell[96572, 3030, 542, 10, 63, "Text"], Cell[CellGroupData[{ Cell[97139, 3044, 495, 10, 139, "Input"], Cell[97637, 3056, 191, 3, 35, "Message"], Cell[97831, 3061, 160, 3, 21, "Message"], Cell[97994, 3066, 175, 3, 21, "Message"], Cell[98172, 3071, 174, 3, 21, "Message"], Cell[98349, 3076, 175, 3, 21, "Message"], Cell[98527, 3081, 167, 3, 21, "Message"] }, Open ]], Cell[98709, 3087, 369, 12, 48, "Text"], Cell[99081, 3101, 501, 10, 139, "Input"], Cell[99585, 3113, 418, 7, 62, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[100040, 3125, 96, 3, 48, "Subsection"], Cell[100139, 3130, 341, 6, 62, "Text"], Cell[CellGroupData[{ Cell[100505, 3140, 72, 1, 27, "Input"], Cell[100580, 3143, 227, 4, 35, "Message"], Cell[100810, 3149, 164, 3, 21, "Message"] }, Open ]], Cell[100989, 3155, 119, 3, 30, "Text"], Cell[CellGroupData[{ Cell[101133, 3162, 106, 2, 27, "Input"], Cell[101242, 3166, 83, 1, 52, "Output"] }, Open ]], Cell[101340, 3170, 299, 9, 65, "Text"], Cell[CellGroupData[{ Cell[101664, 3183, 148, 2, 27, "Input"], Cell[101815, 3187, 67, 1, 31, "Output"] }, Open ]], Cell[101897, 3191, 45, 0, 30, "Text"], Cell[CellGroupData[{ Cell[101967, 3195, 161, 3, 43, "Input"], Cell[102131, 3200, 97, 2, 59, "Output"] }, Open ]], Cell[102243, 3205, 483, 9, 64, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[102763, 3219, 61, 0, 30, "Subsection"], Cell[102827, 3221, 348, 7, 109, "Text"], Cell[CellGroupData[{ Cell[103200, 3232, 159, 3, 50, "Input"], Cell[103362, 3237, 390, 8, 47, "Output"] }, Open ]], Cell[103767, 3248, 122, 3, 33, "Text"], Cell[CellGroupData[{ Cell[103914, 3255, 47, 1, 30, "Input"], Cell[103964, 3258, 35, 1, 29, "Output"] }, Open ]], Cell[104014, 3262, 90, 3, 33, "Text"], Cell[CellGroupData[{ Cell[104129, 3269, 159, 3, 50, "Input"], Cell[104291, 3274, 528, 12, 50, "Output"] }, Open ]], Cell[104834, 3289, 131, 3, 52, "Text"], Cell[CellGroupData[{ Cell[104990, 3296, 47, 1, 30, "Input"], Cell[105040, 3299, 45, 1, 44, "Output"] }, Open ]], Cell[105100, 3303, 121, 3, 52, "Text"], Cell[CellGroupData[{ Cell[105246, 3310, 178, 3, 50, "Input"], Cell[105427, 3315, 35, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[105499, 3321, 74, 1, 30, "Input"], Cell[105576, 3324, 62, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[105675, 3330, 49, 1, 30, "Input"], Cell[105727, 3333, 35, 1, 29, "Output"] }, Open ]], Cell[105777, 3337, 605, 14, 111, "Text"], Cell[106385, 3353, 145, 2, 30, "Input"], Cell[CellGroupData[{ Cell[106555, 3359, 55, 1, 30, "Input"], Cell[106613, 3362, 35, 1, 29, "Output"] }, Open ]], Cell[106663, 3366, 255, 7, 53, "Text"], Cell[CellGroupData[{ Cell[106943, 3377, 149, 2, 50, "Input"], Cell[107095, 3381, 35, 1, 29, "Output"] }, Open ]], Cell[107145, 3385, 384, 9, 72, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[107566, 3399, 46, 0, 38, "Subsection"], Cell[107615, 3401, 322, 7, 48, "Text"], Cell[107940, 3410, 234, 5, 43, "Input"], Cell[108177, 3417, 54, 0, 30, "Text"], Cell[CellGroupData[{ Cell[108256, 3421, 125, 2, 27, "Input"], Cell[108384, 3425, 18578, 563, 186, 5955, 403, "GraphicsData", "PostScript", \ "Graphics"] }, Open ]], Cell[126977, 3991, 70, 1, 27, "Input"], Cell[127050, 3994, 306, 5, 46, "Text"], Cell[CellGroupData[{ Cell[127381, 4003, 250, 5, 43, "Input"], Cell[127634, 4010, 181, 3, 35, "Message"] }, Open ]], Cell[127830, 4016, 196, 4, 46, "Text"], Cell[CellGroupData[{ Cell[128051, 4024, 216, 4, 43, "Input"], Cell[128270, 4030, 353, 5, 44, "Output"] }, Open ]], Cell[128638, 4038, 484, 11, 66, "Text"], Cell[CellGroupData[{ Cell[129147, 4053, 266, 5, 43, "Input"], Cell[129416, 4060, 334, 5, 44, "Output"] }, Open ]], Cell[129765, 4068, 380, 8, 94, "Text"] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell[130194, 4082, 56, 0, 30, "Subsubtitle"], Cell[CellGroupData[{ Cell[130275, 4086, 29, 0, 73, "Section"], Cell[130307, 4088, 35, 0, 33, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[130379, 4093, 28, 0, 43, "Section"], Cell[130410, 4095, 105, 3, 33, "Text"], Cell[130518, 4100, 117, 3, 33, "Text"], Cell[CellGroupData[{ Cell[130660, 4107, 128, 2, 50, "Input"], Cell[130791, 4111, 60, 1, 32, "Output"] }, Open ]], Cell[130866, 4115, 206, 6, 53, "Text"], Cell[CellGroupData[{ Cell[131097, 4125, 41, 1, 30, "Input"], Cell[131141, 4128, 58, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[131236, 4134, 43, 1, 30, "Input"], Cell[131282, 4137, 58, 1, 29, "Output"] }, Open ]], Cell[131355, 4141, 92, 3, 33, "Text"], Cell[CellGroupData[{ Cell[131472, 4148, 55, 1, 30, "Input"], Cell[131530, 4151, 57, 1, 29, "Output"] }, Open ]], Cell[131602, 4155, 163, 6, 34, "Text"], Cell[131768, 4163, 348, 6, 90, "Text"], Cell[CellGroupData[{ Cell[132141, 4173, 66, 0, 27, "Input"], Cell[132210, 4175, 84, 1, 42, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[132331, 4181, 55, 0, 30, "Input"], Cell[132389, 4183, 143, 2, 42, "Output"] }, Open ]], Cell[132547, 4188, 249, 6, 90, "Text"], Cell[CellGroupData[{ Cell[132821, 4198, 23, 0, 30, "Input"], Cell[132847, 4200, 289, 7, 110, "Print"] }, Open ]], Cell[133151, 4210, 831, 18, 299, "Text"], Cell[CellGroupData[{ Cell[134007, 4232, 52, 1, 30, "Input"], Cell[134062, 4235, 40, 1, 35, "Output"] }, Open ]], Cell[134117, 4239, 31, 0, 33, "Text"], Cell[CellGroupData[{ Cell[134173, 4243, 78, 1, 30, "Input"], Cell[134254, 4246, 40, 1, 29, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[134343, 4253, 28, 0, 43, "Section"], Cell[134374, 4255, 35, 0, 33, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[134446, 4260, 28, 0, 43, "Section"], Cell[134477, 4262, 459, 9, 128, "Text"], Cell[CellGroupData[{ Cell[134961, 4275, 165, 3, 70, "Input"], Cell[135129, 4280, 149, 3, 46, "Output"] }, Open ]], Cell[135293, 4286, 90, 3, 33, "Text"], Cell[CellGroupData[{ Cell[135408, 4293, 141, 3, 30, "Input"], Cell[135552, 4298, 546, 12, 75, "Output"] }, Open ]], Cell[136113, 4313, 72, 0, 33, "Text"], Cell[136188, 4315, 237, 5, 71, "Text"], Cell[CellGroupData[{ Cell[136450, 4324, 106, 2, 30, "Input"], Cell[136559, 4328, 83, 1, 52, "Output"] }, Open ]], Cell[136657, 4332, 274, 9, 53, "Text"], Cell[CellGroupData[{ Cell[136956, 4345, 148, 2, 50, "Input"], Cell[137107, 4349, 67, 1, 32, "Output"] }, Open ]], Cell[137189, 4353, 45, 0, 33, "Text"], Cell[CellGroupData[{ Cell[137259, 4357, 161, 3, 50, "Input"], Cell[137423, 4362, 97, 2, 60, "Output"] }, Open ]], Cell[137535, 4367, 544, 10, 110, "Text"], Cell[CellGroupData[{ Cell[138104, 4381, 150, 3, 50, "Input"], Cell[138257, 4386, 598, 13, 75, "Output"] }, Open ]], Cell[138870, 4402, 347, 10, 54, "Text"], Cell[139220, 4414, 174, 4, 52, "Text"], Cell[139397, 4420, 300, 5, 71, "Text"], Cell[CellGroupData[{ Cell[139722, 4429, 171, 2, 50, "Input"], Cell[139896, 4433, 100, 2, 43, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[140033, 4440, 151, 3, 30, "Input"], Cell[140187, 4445, 504, 10, 43, "Output"] }, Open ]], Cell[140706, 4458, 413, 7, 109, "Text"], Cell[141122, 4467, 48, 1, 30, "Input"], Cell[CellGroupData[{ Cell[141195, 4472, 188, 3, 50, "Input"], Cell[141386, 4477, 816, 17, 99, "Output"] }, Open ]], Cell[142217, 4497, 96, 3, 33, "Text"], Cell[CellGroupData[{ Cell[142338, 4504, 80, 1, 30, "Input"], Cell[142421, 4507, 44, 1, 46, "Output"] }, Open ]], Cell[142480, 4511, 31, 0, 33, "Text"], Cell[CellGroupData[{ Cell[142536, 4515, 79, 1, 30, "Input"], Cell[142618, 4518, 169, 2, 49, "Output"] }, Open ]], Cell[142802, 4523, 31, 0, 33, "Text"], Cell[142836, 4525, 79, 1, 30, "Input"], Cell[142918, 4528, 126, 3, 52, "Text"], Cell[CellGroupData[{ Cell[143069, 4535, 73, 1, 30, "Input"], Cell[143145, 4538, 1043, 31, 60, "Output"] }, Open ]], Cell[144203, 4572, 127, 3, 52, "Text"], Cell[144333, 4577, 326, 6, 70, "Input"], Cell[144662, 4585, 144, 3, 52, "Text"], Cell[CellGroupData[{ Cell[144831, 4592, 322, 6, 90, "Input"], Cell[145156, 4600, 325, 4, 69, "Output"] }, Open ]], Cell[145496, 4607, 116, 3, 33, "Text"], Cell[145615, 4612, 308, 5, 71, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[145960, 4622, 28, 0, 73, "Section"], Cell[145991, 4624, 111, 3, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[146139, 4632, 28, 0, 43, "Section"], Cell[146170, 4634, 483, 8, 78, "Text"], Cell[CellGroupData[{ Cell[146678, 4646, 59, 1, 27, "Input"], Cell[146740, 4649, 133, 2, 37, "Print"] }, Open ]], Cell[146888, 4654, 84, 1, 27, "Input"], Cell[CellGroupData[{ Cell[146997, 4659, 54, 1, 27, "Input"], Cell[147054, 4662, 81, 1, 59, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[147172, 4668, 102, 2, 27, "Input"], Cell[147277, 4672, 35, 1, 26, "Output"] }, Open ]], Cell[147327, 4676, 194, 4, 46, "Text"], Cell[147524, 4682, 176, 3, 43, "Input"], Cell[147703, 4687, 250, 6, 47, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[147990, 4698, 28, 0, 43, "Section"], Cell[148021, 4700, 52, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[148110, 4705, 28, 0, 43, "Section"], Cell[148141, 4707, 691, 20, 64, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[148869, 4732, 28, 0, 43, "Section"], Cell[148900, 4734, 52, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[148989, 4739, 29, 0, 43, "Section"], Cell[149021, 4741, 341, 7, 94, "Text"], Cell[149365, 4750, 132, 2, 27, "Input"], Cell[149500, 4754, 18, 0, 30, "Text"], Cell[149521, 4756, 124, 2, 27, "Input"], Cell[149648, 4760, 159, 4, 46, "Text"], Cell[149810, 4766, 189, 4, 27, "Input"], Cell[150002, 4772, 88, 3, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[150127, 4780, 29, 0, 43, "Section"], Cell[150159, 4782, 41, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[150237, 4787, 29, 0, 43, "Section"], Cell[150269, 4789, 45, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[150351, 4794, 29, 0, 43, "Section"], Cell[150383, 4796, 44, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[150464, 4801, 29, 0, 43, "Section"], Cell[150496, 4803, 98, 3, 30, "Text"], Cell[CellGroupData[{ Cell[150619, 4810, 921, 15, 235, "Input"], Cell[151543, 4827, 163, 3, 35, "Message"], Cell[151709, 4832, 174, 3, 35, "Message"] }, Open ]], Cell[151898, 4838, 173, 6, 31, "Text"], Cell[152074, 4846, 931, 15, 219, "Input"], Cell[153008, 4863, 123, 3, 30, "Text"], Cell[CellGroupData[{ Cell[153156, 4870, 114, 2, 27, "Input"], Cell[153273, 4874, 69, 1, 26, "Output"] }, Open ]], Cell[153357, 4878, 51, 0, 30, "Text"], Cell[CellGroupData[{ Cell[153433, 4882, 114, 2, 27, "Input"], Cell[153550, 4886, 54, 1, 26, "Output"] }, Open ]], Cell[153619, 4890, 245, 5, 46, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[153901, 4900, 29, 0, 43, "Section"], Cell[153933, 4902, 255, 7, 47, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[154225, 4914, 29, 0, 43, "Section"], Cell[154257, 4916, 173, 4, 46, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[154467, 4925, 29, 0, 43, "Section"], Cell[154499, 4927, 128, 3, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[154664, 4935, 29, 0, 43, "Section"], Cell[154696, 4937, 717, 21, 96, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[155450, 4963, 29, 0, 43, "Section"], Cell[155482, 4965, 29, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[155548, 4970, 29, 0, 43, "Section"], Cell[155580, 4972, 156, 3, 30, "Text"], Cell[155739, 4977, 589, 11, 155, "Input"], Cell[156331, 4990, 445, 13, 64, "Text"], Cell[156779, 5005, 875, 14, 203, "Input"], Cell[157657, 5021, 894, 14, 219, "Input"], Cell[158554, 5037, 874, 14, 203, "Input"], Cell[159431, 5053, 883, 14, 203, "Input"], Cell[160317, 5069, 59, 0, 30, "Text"], Cell[160379, 5071, 461, 8, 123, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[160877, 5084, 29, 0, 43, "Section"], Cell[160909, 5086, 421, 9, 95, "Text"], Cell[CellGroupData[{ Cell[161355, 5099, 495, 10, 139, "Input"], Cell[161853, 5111, 191, 3, 35, "Message"], Cell[162047, 5116, 160, 3, 21, "Message"], Cell[162210, 5121, 175, 3, 21, "Message"], Cell[162388, 5126, 174, 3, 21, "Message"], Cell[162565, 5131, 175, 3, 21, "Message"], Cell[162743, 5136, 167, 3, 21, "Message"] }, Open ]], Cell[162925, 5142, 37, 0, 27, "Text"], Cell[162965, 5144, 507, 10, 139, "Input"], Cell[163475, 5156, 58, 0, 30, "Text"], Cell[CellGroupData[{ Cell[163558, 5160, 487, 9, 107, "Input"], Cell[164048, 5171, 160, 3, 21, "Message"], Cell[164211, 5176, 175, 3, 21, "Message"], Cell[164389, 5181, 174, 3, 35, "Message"], Cell[164566, 5186, 175, 3, 35, "Message"], Cell[164744, 5191, 167, 3, 35, "Message"], Cell[164914, 5196, 160, 3, 35, "Message"] }, Open ]], Cell[165089, 5202, 225, 10, 31, "Text"], Cell[165317, 5214, 514, 10, 107, "Input"], Cell[CellGroupData[{ Cell[165856, 5228, 46, 0, 42, "Subsubsection"], Cell[165905, 5230, 88, 3, 30, "Text"], Cell[165996, 5235, 532, 10, 139, "Input"], Cell[166531, 5247, 593, 11, 155, "Input"], Cell[167127, 5260, 346, 6, 62, "Text"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[167522, 5272, 29, 0, 43, "Section"], Cell[167554, 5274, 208, 6, 31, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[167799, 5285, 29, 0, 43, "Section"], Cell[167831, 5287, 49, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[167917, 5292, 29, 0, 43, "Section"], Cell[167949, 5294, 97, 3, 30, "Text"], Cell[168049, 5299, 423, 8, 91, "Input"], Cell[168475, 5309, 38, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[168550, 5314, 29, 0, 43, "Section"], Cell[168582, 5316, 600, 15, 79, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[169219, 5336, 29, 0, 43, "Section"], Cell[169251, 5338, 123, 3, 30, "Text"], Cell[CellGroupData[{ Cell[169399, 5345, 235, 5, 43, "Input"], Cell[169637, 5352, 181, 3, 35, "Message"] }, Open ]], Cell[169833, 5358, 115, 3, 30, "Text"], Cell[CellGroupData[{ Cell[169973, 5365, 216, 4, 43, "Input"], Cell[170192, 5371, 353, 5, 44, "Output"] }, Open ]], Cell[170560, 5379, 112, 3, 30, "Text"], Cell[CellGroupData[{ Cell[170697, 5386, 266, 5, 59, "Input"], Cell[170966, 5393, 334, 5, 44, "Output"] }, Open ]], Cell[171315, 5401, 55, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[171407, 5406, 29, 0, 43, "Section"], Cell[171439, 5408, 29, 0, 30, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[171505, 5413, 29, 0, 43, "Section"], Cell[171537, 5415, 74, 0, 30, "Text"] }, Closed]] }, Open ]] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)