mm-809 === Subject: Re: HoldForm > Re Mathematica 5.2.0.0. > This code displays the component differences of matrix subtraction (A-B): > A = {{1, 2}, {3, 4}}; > B = {{5, 6}, {7, -8}}; > > Map[MapThread[HoldForm[#1 - #2] &, {A[[#]], B[[#]]}] &, Range@2] > > As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4--8}}. > > Two questions: > > - What's a better way to do this? > > - How can I replace the -- by +? > > > Bruce > > A simpler approach that my preceding post is MapThread[TraditionalForm[HoldForm[#1] - #2] &, Flatten /@ {A, B}] that returns {1 - 5, 2 - 6, 3 - 7, 4 + 8}. Jean-Marc === Subject: Re: HoldForm >> Re Mathematica 5.2.0.0. >> This code displays the component differences of matrix subtraction (A-B): >> A = {{1, 2}, {3, 4}}; >> B = {{5, 6}, {7, -8}}; >> Map[MapThread[HoldForm[#1 - #2] &, {A[[#]], B[[#]]}] &, Range@2] >> As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4--8}}. >> Two questions: >> - What's a better way to do this? >> - How can I replace the -- by +? >> Bruce > A simpler approach that my preceding post is > > MapThread[TraditionalForm[HoldForm[#1] - #2] &, Flatten /@ {A, B}] > > that returns {1 - 5, 2 - 6, 3 - 7, 4 + 8}. Again, the above result is not a matrix. Sorry about these mistakes. To match exactly what you wanted, a component by component difference of two matrices, the expression should read MapThread[HoldForm[#1] - #2 & , {A, B}, 2] returns {{1 - 5, 2 - 6}, {3 - 7, 4 + 8}} as desired. Jean-Marc === Subject: Re: HoldForm > This code displays the component differences of matrix subtraction (A-B): > A = {{1, 2}, {3, 4}}; > B = {{5, 6}, {7, -8}}; > Map[MapThread[HoldForm[#1 - #2] &, {A[[#]], B[[#]]}] &, Range@2] > As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4--8}}. > Two questions: > - What's a better way to do this? > - How can I replace the -- by +? A={{1,2},{3,4}}; B={{5,6},{7,-8}}; inertPlus[l___]:=HoldForm[Plus[l]] SetAttributes[inertPlus,Listable] inertPlus[A,-B] {{1-5,2-6},{3-7,4+8}} === Subject: Re: HoldForm > Re Mathematica 5.2.0.0. > > This code displays the component differences of matrix subtraction (A-B): > > A = {{1, 2}, {3, 4}}; > > B = {{5, 6}, {7, -8}}; > > Map[MapThread[HoldForm[#1 - #2] &, {A[[#]], B[[#]]}] &, Range@2] > > As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4--8}}. > > Two questions: > > - What's a better way to do this? > > - How can I replace the -- by +? > > > Bruce > > Hi Bruce, The first thing to notice is the Mathematica internal form of the expression that matches, say, 4--8. Using FullForm on your result, we see that the expression is HoldForm[Plus[4, Times[-1, -8]]]. In the example below, we use two consecutive transformation rules: first we get ride of the HoldForm function that prevents to change the sign of the second number while in the meantime we bare the interpretation of the Plus function by using a dummy function myPlus. Then, we replace the dummy function by a HoldForm[Plus[...]] that yields the desired form. MapThread[HoldForm[#1 - #2] & , {Flatten[A], Flatten[B]}] /. HoldForm[(x_) - (y_)?Negative] -> myPlus[x, -y] /. myPlus[x_, y_] -> HoldForm[x + y] returns {1 - 5, 2 - 6, 3 - 7, 4 + 8} Jean-Marc === Subject: Re: HoldForm >> Re Mathematica 5.2.0.0. >> This code displays the component differences of matrix subtraction (A-B): >> A = {{1, 2}, {3, 4}}; >> B = {{5, 6}, {7, -8}}; >> Map[MapThread[HoldForm[#1 - #2] &, {A[[#]], B[[#]]}] &, Range@2] >> As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4--8}}. >> Two questions: >> - What's a better way to do this? >> - How can I replace the -- by +? >> Bruce > Hi Bruce, > > The first thing to notice is the Mathematica internal form of the > expression that matches, say, 4--8. Using FullForm on your result, we > see that the expression is HoldForm[Plus[4, Times[-1, -8]]]. > > In the example below, we use two consecutive transformation rules: first > we get ride of the HoldForm function that prevents to change the sign of > the second number while in the meantime we bare the interpretation of > the Plus function by using a dummy function myPlus. Then, we replace the > dummy function by a HoldForm[Plus[...]] that yields the desired form. > > MapThread[HoldForm[#1 - #2] & , {Flatten[A], Flatten[B]}] /. > HoldForm[(x_) - (y_)?Negative] -> myPlus[x, -y] /. myPlus[x_, y_] -> > HoldForm[x + y] > > returns > > {1 - 5, 2 - 6, 3 - 7, 4 + 8} Of course, the above result is not a matrix. To match exactly what you wanted, a component by component difference of two matrices, the expression should read MapThread[HoldForm[#1 - #2] & , {A, B}, 2] /. HoldForm[(x_) - (y_)?Negative] -> myPlus[x, -y] /. myPlus[x_, y_] -> HoldForm[x + y] Now, you get {{1-5,2-6},{3-7,4+8}} as required. Jean-Marc === Subject: Re: HoldForm > Re Mathematica 5.2.0.0. This code displays the component differences of matrix subtraction > (A-B): A = {{1, 2}, {3, 4}}; B = {{5, 6}, {7, -8}}; Map[MapThread[HoldForm[#1 - #2] &, {A[[#]], B[[#]]}] &, Range@2] As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4--8}}. Two questions: - What's a better way to do this? - How can I replace the -- by +? > Bruce An easier way to get identical looking output Traditional or StandardForm is: Subtract @@ Map[HoldForm, {A, B}, {3}] The difference is that HoldForm is in a different place than in your case. If you really prefer your position of HoldForm you can use: Subtract @@ Map[HoldForm, {A, B}, {3}] /. HoldForm[x_] - HoldForm[ y_] :> HoldForm[x - y] but this no longer looks much simpler than your original approach. However, you can use analogous approach to get the same answer as yours but without the double minus signs: Plus @@ Map[HoldForm, {A, -B}, {3}] /. HoldForm[x_] + HoldForm[y_] :> HoldForm[y + x] Andrzej Kozlowski === Subject: Re: HoldForm A={{1,2},{3,4}}; B={{5,6},{7,-8}}; MapThread[HoldForm[#1 + #2] &, {A, -B},2] {{1 - 5, 2 - 6}, {3 - 7, 4 + 8}} Bob Hanlon > Re Mathematica 5.2.0.0. > > This code displays the component differences of matrix subtraction (A-B): > > A = {{1, 2}, {3, 4}}; > > B = {{5, 6}, {7, -8}}; > > Map[MapThread[HoldForm[#1 - #2] &, {A[[#]], B[[#]]}] &, Range@2] > > As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4--8}}. > > Two questions: > > - What's a better way to do this? > > - How can I replace the -- by +? > > > Bruce > > === Subject: word Hi. I would like to how I can depict complete notebooks (consisting of plots, equations, texts, sections, e.t.c. in a word file. I have used some approaches (from simple copy-paste to more advance) but the main problem is that when I use a p.c. without Mathematica to print the file, the graphs are usually misprinted. Also almost always the notebook loses its format. How can keep the same format? === Subject: Re: word Hi This isn't a very helpful answer and I'm also going to ask the question 'Why do you want to do that ?', so don't feel obliged to read on ... I have never found a satisfactory way of displaying bits and pieces from Mathematica (graphics, equations, etc) in Word. I'd go further and claim never to have found a satisfactory way of displaying any vector graphics format in Word. So I've given up trying. But ... if I have a technical document to write, involving equations, graphics, text, etc, I simply write it in Mathematica. To publish it to non-Mathematica owners you could either give them a copy of MathReader (see the Wolfram web-site) or publish it as a PDF (several good free PDF writers for PCs, go Google). So, why not ditch Word since you already have a much better technical documentation program on your desktop ? Mark Westwood Parallel Programmer > Hi. > I would like to how I can depict complete notebooks (consisting of > plots, equations, texts, sections, e.t.c. in a word file. > I have used some approaches (from simple copy-paste to more advance) > but the main problem is that when I use a p.c. without Mathematica to > print the file, the graphs are usually misprinted. > Also almost always the notebook loses its format. How can keep the same > format? === Subject: simple antiderivative right now. Here is my question. I am doing antiderivatives and tried to check one I did and can't get my handworked answer which is correct by the solution manual to match Mathematica's answer. I copied and pasted everything here so it looks weird until you paste it back in notebook. Here is my input copied and pasted; !(Integrate[8 x - 3 (Sec^2)[x], x]) My output is : !([Integral]((8 x - 3 (Sec^2)[x])) [DifferentialD]x) Why don't I get the answer below as I do when I do it by hand? The antiderivative of Sec^2 is Tan. I am puzzled by the output mathematica gives. !(4 x^2 - 3 Tan [x]) T Harris === Subject: Re: simple antiderivative > right now. Here is my question. > > I am doing antiderivatives and tried to check one I did and can't get my > handworked answer which is correct by the solution manual to match > Mathematica's > answer. I copied and pasted everything here so it looks weird until you > paste it back in notebook. > > Here is my input copied and pasted; > > !(Integrate[8 x - 3 (Sec^2)[x], x]) > > My output is : > > !([Integral]((8 x - 3 (Sec^2)[x])) [DifferentialD]x) > > Why don't I get the answer below as I do when I do it by hand? The > antiderivative of Sec^2 is Tan. I am puzzled by the output mathematica > gives. > > !(4 x^2 - 3 Tan [x]) > > > > T Harris > if you put the square at the syntactically correct position (Integrate[8x-3 Sec[x]^2,x]), Mathematica returns exactly your desired result. Peter === Subject: Re: simple antiderivative > right now. Here is my question. > > I am doing antiderivatives and tried to check one I did and can't get my > handworked answer which is correct by the solution manual to match > Mathematica's > answer. I copied and pasted everything here so it looks weird until you > paste it back in notebook. > > Here is my input copied and pasted; > > !(Integrate[8 x - 3 (Sec^2)[x], x]) > > My output is : > > !([Integral]((8 x - 3 (Sec^2)[x])) [DifferentialD]x) > > Why don't I get the answer below as I do when I do it by hand? The > antiderivative of Sec^2 is Tan. I am puzzled by the output mathematica > gives. > > !(4 x^2 - 3 Tan [x]) > > > > T Harris > You must not separate the head of a function from its argument. Therefore, write Sec[x]^(2) instead of Sec^(2)[x]. For instance, Integrate[8x-3 Sec[x]^(2),x] returns 2 4 x - 3 Tan[x] as expected. Jean-Marc === Subject: Multinomial coefficients evaluation 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 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@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. *******************************************************************) === Subject: RE:FindRoot::nlnum error -Ghyan Link to the forum page for this post: http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=Speci al:Forum_ViewTopic&pid=12111#p12111 === Subject: Re: HoldForm Hi Bruce, A simple modification of your program gives the desired result. Basically, perform A+(-B) rather than performing A-B. So your code will look like, A = {{1, 2}, {3, 4}}; B = {{5, 6}, {7, -8}}; Map[MapThread[HoldForm[#1 + #2] &, {A[[#]], -B[[#]]}] &, Range@2] As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4+8}}. I am not sure why HoldForm treats + and - differently. It performs addition but not subtraction in the sense that, In: HoldForm[2+ (-3)] Out: 2-3 In:HoldForm[2 - (-3) ] Out: 2 - - 3 Bharat. Re Mathematica 5.2.0.0. This code displays the component differences of matrix subtraction (A-B): A = {{1, 2}, {3, 4}}; B = {{5, 6}, {7, -8}}; Map[MapThread[HoldForm[#1 - #2] &, {A[[#]], B[[#]]}] &, Range@2] As desired, the output is {{1 - 5, 2 - 6}, {3 - 7, 4--8}}. Two questions: - What's a better way to do this? - How can I replace the -- by +? > Bruce > -- ---------------------------------------------------------- No problem can withstand the assault of sustained thinking. Voltaire ---------------------------------------------------------- === Subject: Mathlink: Passing functions to C++ Hi all, I am trying to use external ODE solvers, written in C++, in Mathematica. After long efforts I can now, with the help of my friend who is familiar with C++, transfer arrays between Mathematica and C++ via Mathlink. However, we also need to pass the right-hand-sides of ODEs, generated in Mathematica, to C++ for solving. This turns out to be a problem. We assume that one should use the function MLGetFunction but, unfortunately, it is not well documented and there are no examples, both in Mathematica's help and in Todd Gayley's A Mathlink Tutorial. Although it is claimed that any types of data can be easily transferred via Mathlink, we don't see how it can be done practically for such data as functions and equations. Suggestions are welcome. Dmitry === Subject: pattern sequences (what do you think of this feature reqest?) Context: The context for this email is that I am adding a new Method with options to an existing Mathematica function (redefining the base function is not an option). Issue: I have found a way to add the new Method and its options by using the Trott-Strzebonski method. This was rather counter-intuitive. Suggestion: I think two much more clear ways would be to (1) have Attributes[Pattern]={SequenceHold} (in addition to HoldFirst and Protected) to allow matching on pattern objects that are Sequences OR to (2) allow Pattern to match on more than two arguments. What do you think of either of these features? Would you nominate either of them? What are their possible drawbacks? Issue Example: aLMMethodRule=Method[Rule] AugmentedLagrangeMultiplier|{AugmentedLagrangeMultiplier,(_String[Rule]_).. } f[a_,opts___]:= Module[{methodopt,methodoptions}, CompoundExpression[methodoptions=Rest@methodopt[[1,2]];a/.methodoptions]/; If[Length[ methodopt= Cases[{opts},Map[HoldPattern,aLMMethodRule,{0}]]][Equal]0, False,True]] f[stuffed,1[Rule]2, Method[Rule]{AugmentedLagrangeMultiplier,stuffed[Rule]dog}, afgan[Rule]rug] (*the output is dog*) Suggestion (2) Example: rulePatternObject=Rule[_,_] sequenceRuleStringLhsPatternObject=(_String[Rule]_).. f[a_,Pattern[opts,rulePatternObject..., Method[Rule] AugmentedLagrangeMultiplier|{AugmentedLagrangeMultiplier, methodoptions:sequenceRuleStringLhsPatternObject}, rulePatternObject...]]:=a/.methodoptions (*the output should be the same as above with the same function call, but I obviously haven't tested it*) Let me know if I left anything out - this was part of a larger notebook. -- http://chris.chiasson.name/ === Subject: Re: Need pure function to opeate on integer lists Terry, just subtract to your list a right-rotated copy: listA = {1,2,5,6,7,12,13,15,16,17,18,22,23,24}; #-RotateRight[#]&[listA] {-23, 1, 3, 1, 1, 5, 1, 2, 1, 1, 1, 4, 1, 1} Adriano Pascoletti > Hi All, > Suppose I have a list of integers, such as listA = {1,2,5,6,7,12,13,15,16,17,18,22,23,24} how do I construct a pure function that will difference successive > integer elements to produce {1-24,2-1,5-2,6-5,7-6,12-7,13-12,15-13,16-15,17-16,18-17,22-18,23-22,2 > 4-23} .....Terry === Subject: Need pure function to opeate on integer lists Hi All, Suppose I have a list of integers, such as listA = {1,2,5,6,7,12,13,15,16,17,18,22,23,24} how do I construct a pure function that will difference successive integer elements to produce {1-24,2-1,5-2,6-5,7-6,12-7,13-12,15-13,16-15,17-16,18-17,22-18,23-22,24-23} .....Terry === Subject: Re: Need pure function to opeate on integer lists > Suppose I have a list of integers, such as > > listA = {1,2,5,6,7,12,13,15,16,17,18,22,23,24} > > how do I construct a pure function that will difference successive > integer elements to produce > > {1-24,2-1,5-2,6-5,7-6,12-7,13-12,15-13,16-15,17-16,18-17,22-18,23-22,24-23} I have used Bob Hanlon's method described in MapThread[HoldForm[#1 + #2] & , {listA, -RotateRight[listA]}] returns {1 - 24, 2 - 1, 5 - 2, 6 - 5, 7 - 6, 12 - 7, 13 - 12, 15 - 13, 16 - 15, 17 - 16, 18 - 17, 22 - 18, 23 - 22, 24 - 23} as required. HTH, Jean-Marc === Subject: Re: Need pure function to opeate on integer lists > Hi All, > Suppose I have a list of integers, such as > > listA = {1,2,5,6,7,12,13,15,16,17,18,22,23,24} > > how do I construct a pure function that will difference successive > integer elements to produce > > {1-24,2-1,5-2,6-5,7-6,12-7,13-12,15-13,16-15,17-16,18-17,22-18,23-22,24-23} > > ......Terry > > > > Hi Terry, something like In[1]:= cyclicDifference=-Subtract@@@Partition[Prepend[#,Last[#]],2,1]&; cyclicDifference@{1,2,5,6,7,12,13,15,16,17,18,22,23,24} Out[2]= {-23,1,3,1,1,5,1,2,1,1,1,4,1,1} ? Peter === Subject: Re: Need pure function to opeate on integer lists Terry, Does something like this do what you want: myPureFunction = # - RotateRight[#] & myPureFunction[listA] ? Mark Westwood Parallel Programmer > Hi All, > Suppose I have a list of integers, such as listA = {1,2,5,6,7,12,13,15,16,17,18,22,23,24} how do I construct a pure function that will difference successive > integer elements to produce {1-24,2-1,5-2,6-5,7-6,12-7,13-12,15-13,16-15,17-16,18-17,22-18,23-22,24-23} > > .....Terry === Subject: Re: Need pure function to opeate on integer lists > Hi All, > Suppose I have a list of integers, such as listA = {1,2,5,6,7,12,13,15,16,17,18,22,23,24} how do I construct a pure function that will difference successive > integer elements to produce {1-24,2-1,5-2,6-5,7-6,12-7,13-12,15-13,16-15,17-16,18-17,22-18,23-22,24-23} > > .....Terry (#-RotateRight@#&) === Subject: Re: Seemingly strange behavior - HoldForm and Evaluate > I came across this when answering one of the queries posted on this > forum. If I write (1) > In: a = 2; > HoldForm[a] Out: a (2) > In: a=2; > HoldForm[Evaluate[a]] Out: 2 (3) In: a=2; > b=3; > HoldForm[Evaluate[a] + Evaluate[b]] Out: Evaluate[a] + Evaluate[b] Example 2 seems to suggest that Evaluate works as expected, i.e., it > evaluates the expression assigns value 2 despite the HoldAll > attribute of > HoldForm. However, in example 3, evaluate does not function as > expected, or > may it does, but I do not understand why a and b are not assigned > there > values. Bharat. Reading documentation can save time and effort. Evaluate only overrides HoldFirst, etc. attributes when it appears directly as the head of the function argument that would otherwise be held. The behaviour you say you do not understand involves: HoldForm[Plus[Evaluate[a], Evaluate[b]]] HoldForm has attribute HoldALl and Evaluate does not appear directly as head of the argument that would be held (Plus is that head). Andrzej Kozlowski === Subject: Seemingly strange behavior - HoldForm and Evaluate I came across this when answering one of the queries posted on this forum. If I write (1) In: a = 2; HoldForm[a] Out: a (2) In: a=2; HoldForm[Evaluate[a]] Out: 2 (3) In: a=2; b=3; HoldForm[Evaluate[a] + Evaluate[b]] Out: Evaluate[a] + Evaluate[b] Example 2 seems to suggest that Evaluate works as expected, i.e., it evaluates the expression assigns value 2 despite the HoldAll attribute of HoldForm. However, in example 3, evaluate does not function as expected, or may it does, but I do not understand why a and b are not assigned there values. Bharat. === Subject: Re: Quaternion problem--> Jacobian derivation/ Metric > I did Jacobians and metrics way back in Mathematica using > a Jacobian matrix form from Theoretical Mechanics ,Ames and Murnagham, > Dover Books. D was extended to compute the Jacobian directly in version 5.1. Alternatively, you can compute the Jacobian using Outer: Outer[D, f, vars] where f is list of functions and vars is a list of variables. > (*The hard way: there has got to be a more compact way of doing this!*) Indeed there is. > Exp[r]*{Cos[d], Sin[d]*Sin[p]*Cos[t], Sin[d]*Sin[p]*Sin[t], Sin[d]*Cos[p]} > x = Exp[r]*Sin[d]*Sin[p]*Cos[t] > y = Exp[r]*Sin[d]*Sin[p]*Sin[t] > z = Exp[r]*Sin[d]*Cos[p] > t0 = Exp[r]*Cos[d] > xr = D[x, r] > yr = D[y, r] > zr = D[z, r] > tr = D[t0, r] > xt = D[x, t] > yt = D[y, t] > zt = D[z, t] > tt = D[t0, t] > xp = D[x, p] > yp = D[y, p] > zp = D[z, p] > tp = D[t0, p] > xd = D[x, d] > yd = D[y, d] > td = D[t0, d] No need to explicitly define x, y, z, and t0. The Jacobian is just jacobian = D[Exp[r] {Cos[d], Sin[d] Sin[p] Cos[t], Sin[d] Sin[p] Sin[t], Sin[d] Cos[p]}, {{r,t,p,d}}]; Alternatively in Mathematica pre 5.1, jacobian = Outer[D, Exp[r] {Cos[d], Sin[d] Sin[p] Cos[t], Sin[d] Sin[p] Sin[t], Sin[d] Cos[p]}, {r,t,p,d}]; > h1 = FullSimplify[1/Sqrt[xr^2 + yr^2 + zr^2 + tr^2]] > h2 = FullSimplify[1/Sqrt[xt^2 + yt^2 + zt^2 + tt^2]] > h3 = FullSimplify[1/Sqrt[xp^2 + yp^2 + zp^2 + tp^2]] > h4 = FullSimplify[1/Sqrt[xd^2 + yd^2 + zd^2 + td^2]] rra = Simplify[Expand[1/h1^2]] > tta = Simplify[Expand[1/h2^2]] > ppa = Simplify[Expand[1/h3^2]] > dda = Simplify[Expand[1/h4^2]] > The square of the scale factors can be obtained directly as Tr[ Transpose[jacobian] . jacobian, List] // Simplify Paul _______________________________________________________________________ Paul Abbott Phone: 61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul