Help with Fold/outer one-liner (II)
- To: mathgroup at smc.vnet.net
- Subject: [mg28227] Help with Fold/outer one-liner (II)
- From: "Emilio Martin-Serrano Sobrino" <emilio.martin at sema.es>
- Date: Thu, 5 Apr 2001 03:00:42 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi: Sorry for bothering you again. Finally, I think I solved my "Fold/Outer/Function-application" problem; Find it in the attached notebook . Anyway, now my question is: I am there is a more elegant way to the solution; any clue? Emilio Martin-Serrano ReJacobian.nb ------------------------------------------------------------------ This email is confidential and intended solely for the use of the individual to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of Sema Group. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. ------------------------------------------------------------------ (************** Content-type: application/mathematica ************** 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[ 3160, 97]*) (*NotebookOutlinePosition[ 3802, 119]*) (* CellTagsIndexPosition[ 3758, 115]*) (*WindowFrame->Normal*) Notebook[{ Cell[BoxData[ \( (*\ These\ are\ the\ matrices\ to\ differentiate*) \)], "Input"], Cell[BoxData[ \(a1 = {Sin[x[1]]\ Cos[x[2]], \ Sin[x[2]]\ Sin[x[3]]^2, x[3]\ \ Tan[x[3]]}\)], "Input"], Cell[BoxData[ \(a2 = {Cos[x[1]]\ Cos[x[2]], \ Cos[x[2]]\ Sin[x[3]]^2, \ Cos[x[3]\ ]\ Tan[x[3]]}\)], "Input"], Cell[BoxData[ \(a3 = {Cos[x[2]]\ Cos[x[2]], \ Cos[x[2]]\ Sin[x[1]]^2, \ Cos[x[3]\ ]\ Tan[x[2]]}\)], "Input"], Cell[BoxData[ \(a4 = {Cos[x[1]]\ Cos[x[1]], \ Cos[x[2]]\ Sin[x[2]]^2, \ Cos[x[1]\ ]\ Tan[x[1]]}\)], "Input"], Cell[BoxData[ \( (*\ This\ is\ a\ function\ definition\ to\ perform\ the\ task*) \)], "Input"], Cell[BoxData[ \(fCont[f_List] := With[{vars = Array[x, Take[Dimensions[First[f]]]]}, Fold[Outer[D, #, vars] &, First[f], Drop[f, 1]]]\)], "Input"], Cell[BoxData[ \(fCont[{a1, a2, a3, a4}]\)], "Input"], Cell[BoxData[ \( (*\ This\ is\ an\ expresion\ equivalent\ to\ the\ previous\ one, \ it\ yields\ the\ same\ \ \ *) \)], "Input"], Cell[BoxData[ \(With[{vars = Array[x, Take[Dimensions[a1]]]}, Fold[Outer[D, #, vars] &, a1, {a2, a3, a4}]]\)], "Input"], Cell[BoxData[ \( (*\ and\ finally, \ this\ is\ what\ I\ wanted\ *) \)], "Input"], Cell[BoxData[ \(\(With[{vars = Array[x, Take[Dimensions[First[#]]]]}, Fold[Outer[D, #, vars] &, First[#], Drop[#, 1]]] &\)[{a1, a2, a3, a4}]\)], "Input"] }, FrontEndVersion->"4.1 for Microsoft Windows", ScreenRectangle->{{0, 800}, {0, 555}}, WindowSize->{792, 528}, WindowMargins->{{0, Automatic}, {Automatic, 0}} ] (******************************************************************* 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[1705, 50, 85, 1, 30, "Input"], Cell[1793, 53, 114, 2, 30, "Input"], Cell[1910, 57, 121, 2, 30, "Input"], Cell[2034, 61, 121, 2, 30, "Input"], Cell[2158, 65, 121, 2, 30, "Input"], Cell[2282, 69, 105, 2, 30, "Input"], Cell[2390, 73, 166, 3, 50, "Input"], Cell[2559, 78, 56, 1, 30, "Input"], Cell[2618, 81, 138, 2, 30, "Input"], Cell[2759, 85, 130, 2, 30, "Input"], Cell[2892, 89, 84, 1, 30, "Input"], Cell[2979, 92, 177, 3, 50, "Input"] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)