MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Help with Fold/outer one-liner (II)

  • To: mathgroup at
  • Subject: [mg28227] Help with Fold/outer one-liner (II)
  • From: "Emilio Martin-Serrano Sobrino" <emilio.martin at>
  • Date: Thu, 5 Apr 2001 03:00:42 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


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


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

* 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:
  email: info at
  phone: +1-217-398-0700 (U.S.)

Notebook reader applications are available free of charge from
Wolfram Research.

(*CacheID: 232*)

(*NotebookOptionsPosition[      3160,         97]*)
(*NotebookOutlinePosition[      3802,        119]*)
(*  CellTagsIndexPosition[      3758,        115]*)

    \( (*\ These\ are\ the\ matrices\ to\ differentiate*) \)], "Input"],

    \(a1 = {Sin[x[1]]\ Cos[x[2]], \ Sin[x[2]]\ Sin[x[3]]^2,
        x[3]\ \ Tan[x[3]]}\)], "Input"],

    \(a2 = {Cos[x[1]]\ Cos[x[2]], \ Cos[x[2]]\ Sin[x[3]]^2, \
        Cos[x[3]\ ]\ Tan[x[3]]}\)], "Input"],

    \(a3 = {Cos[x[2]]\ Cos[x[2]], \ Cos[x[2]]\ Sin[x[1]]^2, \
        Cos[x[3]\ ]\ Tan[x[2]]}\)], "Input"],

    \(a4 = {Cos[x[1]]\ Cos[x[1]], \ Cos[x[2]]\ Sin[x[2]]^2, \
        Cos[x[1]\ ]\ Tan[x[1]]}\)], "Input"],

    \( (*\
      This\ is\ a\ function\ definition\ to\ perform\ the\ task*) \)], 

    \(fCont[f_List] :=
      With[{vars = Array[x, Take[Dimensions[First[f]]]]},
        Fold[Outer[D, #, vars] &, First[f], Drop[f, 1]]]\)], "Input"],

    \(fCont[{a1, a2, a3, a4}]\)], "Input"],

    \( (*\ This\ is\ an\ expresion\ equivalent\ to\ the\ previous\ one, 
      it\ yields\ the\ same\ \ \ *) \)], "Input"],

    \(With[{vars = Array[x, Take[Dimensions[a1]]]},
      Fold[Outer[D, #, vars] &, a1, {a2, a3, a4}]]\)], "Input"],

    \( (*\ and\ finally, \ this\ is\ what\ I\ wanted\ *) \)], "Input"],

    \(\(With[{vars = Array[x, Take[Dimensions[First[#]]]]},
          Fold[Outer[D, #, vars] &, First[#], Drop[#, 1]]] &\)[{a1, a2, 
        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.



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.

  • Prev by Date: Re: norm symbol
  • Next by Date: Re: Problem with InverseFunction
  • Previous by thread: Re: Re: Ordering of output question
  • Next by thread: Re: Help with Fold/outer one-liner (II)