Multinomial coefficients evaluation
- To: mathgroup at smc.vnet.net
- Subject: [mg68105] Multinomial coefficients evaluation
- From: "Michal Kvasnicka" <michal.kvasnicka at quick.nOsPam.cz>
- Date: Mon, 24 Jul 2006 00:55:47 -0400 (EDT)
- Organization: Czech Technical University
- Sender: owner-wri-mathgroup at wolfram.com
Why is function Multinomial so slower than its direct definition??? See attached notebook with three equivalent ways of the simple multinomial series expansion. Michal Kvasnicka (************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.2' 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 at 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[ 2702, 93]*) (*NotebookOutlinePosition[ 3347, 115]*) (* CellTagsIndexPosition[ 3303, 111]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[BoxData[ \(n\ = \ 100\)], "Input"], Cell[BoxData[ \(100\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[\ \(Sum[ Multinomial[n1, n2, n3]\ \(a\_1\^n1\) \(a\_2\^n2\) a\_3\^n3 /. n3 \[Rule] n - n1 - n2, {n1, 0, n}, {n2, 0, n - n1}];\)]\)], "Input"], Cell[BoxData[ \({2.234`\ Second, Null}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[\(Sum[\(\((n1 + n2 + n3)\)!\)\/\(\(n1!\) \(n2!\) \(n3!\)\ \)\ \(a\_1\^n1\) \(a\_2\^n2\) a\_3\^n3 /. n3 \[Rule] n - n1 - n2, {n1, 0, n}, {n2, 0, n - n1}];\)]\)], "Input"], Cell[BoxData[ \({0.31199999999999983`\ Second, Null}\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ \(Timing[\(Expand[\((a\_1 + a\_2 + a\_3)\)\^n];\)]\)], "Input"], Cell[BoxData[ \({0.030999999999999694`\ Second, Null}\)], "Output"] }, Open ]] }, FrontEndVersion->"5.2 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 911}}, WindowSize->{679, 740}, WindowMargins->{{Automatic, 96}, {Automatic, 56}} ] (******************************************************************* 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[1776, 53, 44, 1, 30, "Input"], Cell[1823, 56, 37, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[1897, 62, 206, 4, 52, "Input"], Cell[2106, 68, 56, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[2199, 74, 222, 4, 43, "Input"], Cell[2424, 80, 70, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[2531, 86, 81, 1, 30, "Input"], Cell[2615, 89, 71, 1, 29, "Output"] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)
- Follow-Ups:
- Re: Multinomial coefficients evaluation
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: Multinomial coefficients evaluation