(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of 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[ 11533, 401]*) (*NotebookOutlinePosition[ 12205, 425]*) (* CellTagsIndexPosition[ 12161, 421]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Demo for PolynomSeries package", "Title"], Cell[BoxData[ \(\(SetDirectory["\"]; \)\)], "Input"], Cell[BoxData[ \(<< PolynomSeries`\)], "Input"], Cell["\<\ Package PolynomSeries contains tools for dealing with multivariate \ polynomial series. Surprisingly, Mathematica lacks tools for working with \ polynomial series and the present package is intended to fill this gap. Below \ is a brief description of the functionalities of the package. Let us generate \ a simple polynomial with respect to one variable x1:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(p = Plus@@Flatten[Table[1 + x1^i, \ {i, \ 0, \ 5}]]\)], "Input"], Cell[BoxData[ \(7 + x1 + x1\^2 + x1\^3 + x1\^4 + x1\^5\)], "Output"] }, Open ]], Cell["\<\ To transform this polynomial into the series use the \ following:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(R\ = \ Polynom2Series[p, \ {x1}]\)], "Input"], Cell[BoxData[ \({{0, 7}, {1, x1}, {2, x1\^2}, {3, x1\^3}, {4, x1\^4}, {5, x1\^5}}\)], "Output"] }, Open ]], Cell[TextData[ "The above list, R, is the main object of the package. Each element of R \ consists of two entries: the first one is the power \[Alpha] =\[Alpha]1 + \ \[Alpha]2... \[Alpha]n of the term x1^\[Alpha]1 x2^\[Alpha]2} ... \ xn^\[Alpha]n, which is itself thesecond entry. Here xj are the elements in \ the second input parameter of the function. Consider an example of \ multivariate series. Create first a polynomial by"], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(p1 = Plus@@Flatten[ Table[y1^i*y2^j*y3^k, \ {i, \ 0, \ 1}, \ {j, \ 1, \ 2}, \ {k, \ 1, \ 2}]]\)], "Input"], Cell[BoxData[ \(y2\ y3 + y1\ y2\ y3 + y2\^2\ y3 + y1\ y2\^2\ y3 + y2\ y3\^2 + y1\ y2\ y3\^2 + y2\^2\ y3\^2 + y1\ y2\^2\ y3\^2\)], "Output"] }, Open ]], Cell["\<\ Transforming the polynomial into a series with respect to y1, y2, \ y3 yields:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(R1\ = \ Polynom2Series[p1, \ {y1, \ y2, \ y3}]\)], "Input"], Cell[BoxData[ \({{2, y2\ y3}, {3, y1\ y2\ y3 + y2\^2\ y3 + y2\ y3\^2}, {4, y1\ y2\^2\ y3 + y1\ y2\ y3\^2 + y2\^2\ y3\^2}, {5, y1\ y2\^2\ y3\^2}} \)], "Output"] }, Open ]], Cell["\<\ One can consider a transformation of the polynomial into series \ with respect to some (not all) variables (y2, y3$below):\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Polynom2Series[p1, \ {y1, \ y3}]\)], "Input"], Cell[BoxData[ \({{1, y2\ y3 + y2\^2\ y3}, {2, y1\ y2\ y3 + y1\ y2\^2\ y3 + y2\ y3\^2 + y2\^2\ y3\^2}, {3, y1\ y2\ y3\^2 + y1\ y2\^2\ y3\^2}}\)], "Output"] }, Open ]], Cell["\<\ To transform series back to the polynomial use the command \ Series2Polynom[ ] (and check whether the result is the same as the original \ polynomial)\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(p2\ = \ Series2Polynom[R1]; \np2 === p1\)], "Input"], Cell[BoxData[ \(True\)], "Output"] }, Open ]], Cell["\<\ Several arithmetic operations on series of type R are defined in \ the package. To add two series use AddR[R1, R2] command:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(R2\ = \ AddR[R, \ R1]\)], "Input"], Cell[BoxData[ \({{0, 7}, {1, x1}, {2, x1\^2 + y2\ y3}, {3, x1\^3 + y1\ y2\ y3 + y2\^2\ y3 + y2\ y3\^2}, {4, x1\^4 + y1\ y2\^2\ y3 + y1\ y2\ y3\^2 + y2\^2\ y3\^2}, {5, x1\^5 + y1\ y2\^2\ y3\^2}}\)], "Output"] }, Open ]], Cell["Multiplying two series and retaining terms up to index 3:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MultRR[R, \ R1, \ 3]\)], "Input"], Cell[BoxData[ \({{2, 7\ y2\ y3}, {3, x1\ y2\ y3 + 7\ y1\ y2\ y3 + 7\ y2\^2\ y3 + 7\ y2\ y3\^2}}\)], "Output"] }, Open ]], Cell["\<\ If, however, we want to know only terms of index 4 use MultRRLayer[ \ ] command:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MultRRLayer[R, \ R1, \ 4]\)], "Input"], Cell[BoxData[ \({{4, x1\^2\ y2\ y3 + x1\ y1\ y2\ y3 + x1\ y2\^2\ y3 + 7\ y1\ y2\^2\ y3 + x1\ y2\ y3\^2 + 7\ y1\ y2\ y3\^2 + 7\ y2\^2\ y3\^2}}\)], "Output"] }, Open ]], Cell["Series can also be multiplied by a constant:", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(MultRC[R, \ 2]\)], "Input"], Cell[BoxData[ \({{0, 14}, {1, 2\ x1}, {2, 2\ x1\^2}, {3, 2\ x1\^3}, {4, 2\ x1\^4}, {5, 2\ x1\^5}}\)], "Output"] }, Open ]], Cell["or taken with an opposite sign", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(NegR[R]\)], "Input"], Cell[BoxData[ \({{0, \(-7\)}, {1, \(-x1\)}, {2, \(-x1\^2\)}, {3, \(-x1\^3\)}, {4, \(-x1\^4\)}, {5, \(-x1\^5\)}}\)], "Output"] }, Open ]], Cell["\<\ The commands defined in the package return series already ordered \ by their indices. This is done by OrderR[ ] command which can also be \ accessed by the user to order series obtained by other means. For example, \ begin lists two series can be joined in which case they will have to be \ ordered:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(R2\ = \ Join[R, \ R1]\)], "Input"], Cell[BoxData[ \({{0, 7}, {1, x1}, {2, x1\^2}, {3, x1\^3}, {4, x1\^4}, {5, x1\^5}, {2, y2\ y3}, {3, y1\ y2\ y3 + y2\^2\ y3 + y2\ y3\^2}, {4, y1\ y2\^2\ y3 + y1\ y2\ y3\^2 + y2\^2\ y3\^2}, {5, y1\ y2\^2\ y3\^2}} \)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(OrderR[R2]\)], "Input"], Cell[BoxData[ \({{0, 7}, {1, x1}, {2, x1\^2 + y2\ y3}, {3, x1\^3 + y1\ y2\ y3 + y2\^2\ y3 + y2\ y3\^2}, {4, x1\^4 + y1\ y2\^2\ y3 + y1\ y2\ y3\^2 + y2\^2\ y3\^2}, {5, x1\^5 + y1\ y2\^2\ y3\^2}}\)], "Output"] }, Open ]], Cell["\<\ It is often in the applications that one needs to substitute a new \ series for some (or all) variables in the given series. This can be done \ using SubstR[R, RV, xvar, yvar, n] command. Here RV is a vector of series \ with respect to new variables yvar which are substituted into R which is in \ turn a series with respect to variables xvar. To substitite a simple series \ $(1+z1, 2+z2, 3+z3)$ to every (y1, y2, y3) in the series R1, first generate \ a vector of series substitions:\ \>", "Text"], Cell[BoxData[ \(\(subst\ = \ {1 + z1, \ 2 + z2, \ 3 + z3}; \)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(RVy\ = \ MapThread[Polynom2Series[#1, \ #2]&, \ {subst, \ {{z1}, \ {z2}, \ {z3}}}]\)], "Input"], Cell[BoxData[ \({{{0, 1}, {1, z1}}, {{0, 2}, {1, z2}}, {{0, 3}, {1, z3}}}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Function2Series[Sin[z], \ z, \ R, \ x, \ 3]\)], "Input"], Cell[BoxData[ \({{0, \(-\(301\/6\)\)}, {1, \(-\(\(47\ x1\)\/2\)\)}, {2, \(-27\)\ x1\^2}, {3, \(-\(\(92\ x1\^3\)\/3\)\)}}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Rxy\ = \ SubstR[R1, \ RVy, \ {y1, \ y2, \ y3}, \ {z1, \ z2, \ z3}, \ 3]\)], "Input"], Cell[BoxData[ \({{0, 42}, {1, 6\ z1 + 27\ z2 + 20\ z3}, {2, 3\ z1\ z2 + 3\ z2\^2 + 2\ z1\ z3 + 12\ z2\ z3 + 2\ z3\^2}, {3, z1\ z2\ z3 + z2\^2\ z3 + z2\ z3\^2}}\)], "Output"] }, Open ]], Cell["\<\ Note that we only retain terms up to index 3. If, user is \ interested only in terms of index, say, 4, SubstRLayer[ ] is to be \ used:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Rxy\ = \ SubstRLayer[R1, \ RVy, \ {y1, \ y2, \ y3}, \ {z1, \ z2, \ z3}, \ 4]\)], "Input"], Cell[BoxData[ \({{4, z1\ z2\^2\ z3 + z1\ z2\ z3\^2 + z2\^2\ z3\^2}}\)], "Output"] }, Open ]], Cell["\<\ The package also has tools for applying functions to series. The \ function is first expanded in the power series in the neighbourhood of a point x_0 (0 default), and the series R$is then substituted into the \ function series. If the function is not singular in zero, it can safely be \ applied to any series:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(Function2Series[Sin[z], \ z, \ R, \ x1\ , 3]\)], "Input"], Cell[BoxData[ \({{0, \(-\(301\/6\)\)}, {1, \(-\(\(47\ x1\)\/2\)\)}, {2, \(-27\)\ x1\^2}, {3, \(-\(\(92\ x1\^3\)\/3\)\)}}\)], "Output"] }, Open ]], Cell["\<\ There are separate commands for two commonly used functions which \ are singular in zero: it is square root of series and inverse function. The \ correct usage of this commands can only be guarantereed if the series contain \ constant term (i.e. term with index 0). To find square root with terms up to \ index 4 use\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(SqrtR[R, \ 3]\)], "Input"], Cell[BoxData[ \({{0, \@7}, {1, x1\/\(2\ \@7\)}, {2, \(27\ x1\^2\)\/\(56\ \@7\)}, {3, \(365\ x1\^3\)\/\(784\ \@7\)}}\)], "Output"] }, Open ]], Cell["Inverse series (1/R) is found by", "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(InverseR[R, \ 3]\)], "Input"], Cell[BoxData[ \({{0, 1\/7}, {1, \(-\(x1\/49\)\)}, {2, \(-\(\(6\ x1\^2\)\/343\)\)}, {3, \(-\(\(36\ x1\^3\)\/2401\)\)}}\)], "Output"] }, Open ]], Cell[TextData[ "Package also contains functions for deleting zero (empty) elements \ (DeleteZero[R]), for cutting down series retaining terms with index\nless or \ equal to n (CutR[R, n]), simplifying terms in the series (SimplifyR[R, var]), \ generating simple series of the form {{\[Alpha], k x^\[Alpha]}} by GenR[x, \ \[Alpha], k]. "], "Text"], Cell[CellGroupData[{ Cell[BoxData[ \(CutR[R1, \ 2]\)], "Input"], Cell[BoxData[ \({{2, y2\ y3}}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(DeleteZeroR[R1]\)], "Input"], Cell[BoxData[ \({{2, y2\ y3}, {3, y1\ y2\ y3 + y2\^2\ y3 + y2\ y3\^2}, {4, y1\ y2\^2\ y3 + y1\ y2\ y3\^2 + y2\^2\ y3\^2}, {5, y1\ y2\^2\ y3\^2}} \)], "Output"] }, Open ]] }, Open ]] }, FrontEndVersion->"X 3.0", ScreenRectangle->{{0, 1280}, {0, 1024}}, ScreenStyleEnvironment->"Working", WindowSize->{744, 876}, WindowMargins->{{163, Automatic}, {Automatic, 22}} ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1731, 51, 47, 0, 107, "Title"], Cell[1781, 53, 69, 1, 27, "Input"], Cell[1853, 56, 50, 1, 27, "Input"], Cell[1906, 59, 381, 6, 68, "Text"], Cell[CellGroupData[{ Cell[2312, 69, 84, 1, 27, "Input"], Cell[2399, 72, 72, 1, 29, "Output"] }, Open ]], Cell[2486, 76, 89, 3, 32, "Text"], Cell[CellGroupData[{ Cell[2600, 83, 66, 1, 27, "Input"], Cell[2669, 86, 102, 2, 29, "Output"] }, Open ]], Cell[2786, 91, 441, 6, 68, "Text"], Cell[CellGroupData[{ Cell[3252, 101, 156, 4, 27, "Input"], Cell[3411, 107, 150, 2, 29, "Output"] }, Open ]], Cell[3576, 112, 102, 3, 32, "Text"], Cell[CellGroupData[{ Cell[3703, 119, 80, 1, 27, "Input"], Cell[3786, 122, 178, 3, 29, "Output"] }, Open ]], Cell[3979, 128, 146, 3, 32, "Text"], Cell[CellGroupData[{ Cell[4150, 135, 65, 1, 27, "Input"], Cell[4218, 138, 176, 3, 29, "Output"] }, Open ]], Cell[4409, 144, 174, 4, 50, "Text"], Cell[CellGroupData[{ Cell[4608, 152, 73, 1, 43, "Input"], Cell[4684, 155, 38, 1, 27, "Output"] }, Open ]], Cell[4737, 159, 147, 3, 32, "Text"], Cell[CellGroupData[{ Cell[4909, 166, 55, 1, 27, "Input"], Cell[4967, 169, 238, 4, 47, "Output"] }, Open ]], Cell[5220, 176, 73, 0, 32, "Text"], Cell[CellGroupData[{ Cell[5318, 180, 53, 1, 27, "Input"], Cell[5374, 183, 125, 3, 29, "Output"] }, Open ]], Cell[5514, 189, 104, 3, 32, "Text"], Cell[CellGroupData[{ Cell[5643, 196, 58, 1, 27, "Input"], Cell[5704, 199, 179, 3, 29, "Output"] }, Open ]], Cell[5898, 205, 60, 0, 32, "Text"], Cell[CellGroupData[{ Cell[5983, 209, 47, 1, 27, "Input"], Cell[6033, 212, 124, 2, 29, "Output"] }, Open ]], Cell[6172, 217, 46, 0, 32, "Text"], Cell[CellGroupData[{ Cell[6243, 221, 40, 1, 27, "Input"], Cell[6286, 224, 138, 2, 29, "Output"] }, Open ]], Cell[6439, 229, 323, 6, 68, "Text"], Cell[CellGroupData[{ Cell[6787, 239, 55, 1, 27, "Input"], Cell[6845, 242, 252, 4, 47, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[7134, 251, 43, 1, 27, "Input"], Cell[7180, 254, 238, 4, 47, "Output"] }, Open ]], Cell[7433, 261, 514, 8, 86, "Text"], Cell[7950, 271, 79, 1, 27, "Input"], Cell[CellGroupData[{ Cell[8054, 276, 132, 3, 27, "Input"], Cell[8189, 281, 91, 1, 27, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[8317, 287, 76, 1, 27, "Input"], Cell[8396, 290, 147, 2, 45, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[8580, 297, 115, 3, 27, "Input"], Cell[8698, 302, 195, 3, 47, "Output"] }, Open ]], Cell[8908, 308, 159, 4, 32, "Text"], Cell[CellGroupData[{ Cell[9092, 316, 120, 3, 27, "Input"], Cell[9215, 321, 85, 1, 29, "Output"] }, Open ]], Cell[9315, 325, 334, 6, 68, "Text"], Cell[CellGroupData[{ Cell[9674, 335, 77, 1, 27, "Input"], Cell[9754, 338, 147, 2, 45, "Output"] }, Open ]], Cell[9916, 343, 340, 6, 68, "Text"], Cell[CellGroupData[{ Cell[10281, 353, 46, 1, 27, "Input"], Cell[10330, 356, 142, 2, 51, "Output"] }, Open ]], Cell[10487, 361, 48, 0, 32, "Text"], Cell[CellGroupData[{ Cell[10560, 365, 49, 1, 27, "Input"], Cell[10612, 368, 144, 2, 45, "Output"] }, Open ]], Cell[10771, 373, 347, 5, 68, "Text"], Cell[CellGroupData[{ Cell[11143, 382, 46, 1, 27, "Input"], Cell[11192, 385, 47, 1, 27, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[11276, 391, 48, 1, 27, "Input"], Cell[11327, 394, 178, 3, 29, "Output"] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)