Subject: RE: eliminate the 2 in binary Mike, I don't think that is 3 in binary form. But you could try 11 David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ when displaying numbers in binary how do I eliminate the 2's when displacing 3 in binary the output is 0100 2 I want the 0100 without the 2 === Subject: Re: potenl Select[Range[10000000],f] optimization & question YOU created the large list when you used Range with a large argument; Mathematica assumed you knew what you wanted to do (as it should). Select makes sense when you're selecting from an existing list that you needed for some other purpose, but if you only want to step through values, there are other methods, such as Do, For, and While. You might also use Sow and Reap to get an output list. Bobby > It appears that Select doesn't take any advantage of a potenl > optimization. When given a function that is going to generate a > large list of items to test, even when there are clearly no side > effects involved, it appears to generate the entire list first, > consuming large amounts of memory, beating the processor cache up, > hammering swap space, etc, and then begins testing the individual > elements. > It can be very easy and clear to write things like this if I don't > start adding my own work-arounds to divide the list into pieces > and iterate over the pieces. > Any chance that an optimization like this might be considered for > a future version? > Anyone have a very clear and simple way to write this that avoids > this problem, and speeds it up, rather than slowing it down? In > the cases I've been using the number of items selected is usually > a tiny fraction of the size of the original list. === Subject: Re: Combining Vectors to Form a Matrix In[1]:= vec1 = {1, 3, 6, 4}; vec2 = {2, 5, 7, 2}; In[2]:= Transpose[{vec1, vec2}] Out[2]= {{1, 2}, {3, 5}, {6, 7}, {4, 2}} You may check the result with In[3]:= MatrixForm[Transpose[{vec1, vec2}]] Tomas Garza Mexico City ----- Original Message ----- === Subject: Combining Vectors to Form a Matrix > Everyone, > What Mathematica function do I use to combine two n x 1 vectors to get > a n x 2 matrix? > === Subject: RE: Combining Vectors to Form a Matrix , avec = Array[a, 5] bvec = Array[b, 5] (mat = Join[{avec, bvec}] // Transpose) // MatrixForm David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Everyone, What Mathematica function do I use to combine two n x 1 vectors to get a n x 2 matrix? === Subject: Re: Combining Vectors to Form a Matrix On 2/26/04 at 5:54 PM, ory.lypny@videotron.ca (ory Lypny) >What Mathematica function do I use to combine two n x 1 vectors to >get a n x 2 matrix? Letting u,v be the two vectors, then Transpose@{u,v} will do what you want -- To reply via email subtract one hundred and four === Subject: Re: Summation limits > I want to do a summation, using the symbol form from clicking on the > palette button, but want to put a test on the index of the iterator. > for example, I will have global variables, k=5 and p = 2, and want to > do a summation from i=1 to k, where i != p. How do I enter the lower > limit i=1;i!=p ? You cannot put a test on the index of the iterator because iterators do not permit this, independent of the form of input. For example, With[{k=5,p=2},Sum[i,{i,1,k}]] is, of course, ok. And, if you convert this input to StandardForm (or TraditionalForm) you get the same 2D form as you would get from a palette. However, there is AFAIK, no way to modify the _iterator_ of Sum[i,{i,1,k}] to include a test. > I realize that I can just wrap the expression being summed in an > If[i!=p, ...], but it would be nice if I could just put this test in > the lower limit. There is a way to do this: use the Notation package to define your own input notation that accepts a lower limit of the form, say i != 1 = p. See http://physics.uwa.edu.au/pub/Mathematica/MathGroup/TestSumIterator.nb Paul -- Paul Abbott Phone: +61 8 9380 2734 School of Physics, M013 Fax: +61 8 9380 1014 The University of Western Australia (CRICOS Provider No 00126G) 35 Stirling Highway Crawley WA 6009 mailto:paul@physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul === Subject: Re: Summation limits > I realize that I can just wrap the expression being summed in an > If[i!=p, ...], but it would be nice if I could just put this test in > the lower limit. > There is a way to do this: use the Notation package to define your own > input notation that accepts a lower limit of the form, say i != 1 = p. > See > http://physics.uwa.edu.au/pub/Mathematica/MathGroup/TestSumIterator.nb Doug > Paul === Subject: RE: Combining Vectors to Form a Matrix Example : be careful : A vector with n composants is not a n x 1 - Matrix in Mathematica, but a list of length n ! Example with n=6 : (v1=Table[Random[Integer,{0,10}],{6}])//MatrixForm (v2=Table[Random[Integer,{0,10}],{6}])//MatrixForm (matr=Transpose[{v1,v2}])//MatrixForm Florian Jaccard -----Message d'origine----- De : ory Lypny [mailto:ory.lypny@videotron.ca] Ë : mathgroup@smc.vnet.net Objet : Combining Vectors to Form a Matrix Everyone, What Mathematica function do I use to combine two n x 1 vectors to get a n x 2 matrix? === Subject: NDsolver To whom it may Concern As you can see from my program there are three equations which are integrated using . As you can see NDsolver integrates these equations fine. Unfortunately however when I plot a graph of one of my parameters errors appear. The errors say that at certain points in the interpolation 'the values are not machine size real numbers'. Does this mean that some of the numbers obtained from the NDsolver are complex? I cannot think of what the source of the error would be. Could you please give me some tips. Please see pasted below the ASCII format. 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[ 23065, 449]*) (*NotebookOutlinePosition[ 23707, 471]*) (* CellTagsIndexPosition[ 23663, 467]*) (*WindowFrame->Normal*) Notebook[{ Cell[BoxData[ ((Clear[eqn1, eqn2, eqn3, MEarth, G, e, Rp, [Theta]start, [Mu], a, p, VR, R0, orbvel, TOrbit, time, ans, R1, R2, R3, M1, M2, M3];))], Input], Cell[BoxData[{ ((cosB = ((R1^2 + R2^2 - R3^2))/((2*R1* R2));)), [IndentingNewLine], ((M = M1 + M2 + M3;)), [IndentingNewLine], ((x = ((M3*R2 + M1*R1*cosB))/M;)), [IndentingNewLine], ((y = ((M1*@((R1^2 - ((R1*cosB))^2))))/ M;)), [IndentingNewLine], ((u = @((R1^2 - ((R1*cosB))^2)) - y;)), [IndentingNewLine], ((C1 = @(((R1*cosB - x))^2 + ((u))^2);)), [IndentingNewLine], ((C2 = @(y^2 + x^2);)), [IndentingNewLine], ((C3 = @(((R2 - x))^2 + y^2);))}], Input], Cell[BoxData[{ (([Phi]2 = ArcCos[((C2^2 + C1^2 - R1^2))/((2*C2* C1))];)), [IndentingNewLine], (([Phi]3 = ArcCos[((C2^2 + C3^2 - R2^2))/((2*C2* C3))];)), [IndentingNewLine], ((x1 = R[t]*Cos[[Theta][t]] + C1*Cos[[Phi]1[t] + [Theta][t]];)), [IndentingNewLine], ((y1 = R[t]*Sin[[Theta][t]] + C1*Sin[[Phi]1[t] + [Theta][t]];)), [IndentingNewLine], ((x2 = R[t]*Cos[[Theta][t]] + C2*Cos[[Phi]2 + [Phi]1[t] + [Theta][ t]];)), [IndentingNewLine], ((y2 = R[t]*Sin[[Theta][t]] + C2*Sin[[Phi]2 + [Phi]1[t] + [Theta][ t]];)), [IndentingNewLine], ((x3 = R[t]*Cos[[Theta][t]] + C3*Cos[[Phi]3 + [Phi]2 + [Phi]1[t] + [Theta][ t]];)), [IndentingNewLine], ((y3 = R[t]*Sin[[Theta][t]] + C3*Sin[[Phi]3 + [Phi]2 + [Phi]1[t] + [Theta][t]];))}], Input], Cell[BoxData[{ ((x1vel = [ParlD]_t x1;)), [IndentingNewLine], ((y1vel = [ParlD]_t y1;)), [IndentingNewLine], ((x2vel = [ParlD]_t x2;)), [IndentingNewLine], ((y2vel = [ParlD]_t y2;)), [IndentingNewLine], ((x3vel = [ParlD]_t x3;)), [IndentingNewLine], ((y3vel = [ParlD]_t y3;))}], Input], Cell[BoxData[ ((T = 1/2*M1*((x1vel^2 + y1vel^2)) + 1/2*M2*((x2vel^2 + y2vel^2)) + 1/2*M3*((x3vel^2 + y3vel^2));))], Input], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{T, =, RowBox[{ RowBox[{(1/2), , M1, , RowBox[{(, RowBox[{ SuperscriptBox[ RowBox[{(, RowBox[{ RowBox[{(Cos[[Theta][t]]), , RowBox[{ SuperscriptBox[R, [Prime], MultilineFunction->None], [, t, ]}]}], -, RowBox[{(R[t]), , (Sin[[Theta][t]]), , RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}]}], +, RowBox[{([Sqrt](((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2)))/((M1 + M2 + M3))^2))), , (Sin[[Theta][t] + [Phi]1[t]]), , RowBox[{(, RowBox[{ RowBox[{-, RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}]}], -, RowBox[{ SuperscriptBox[[Phi]1, [Prime], MultilineFunction->None], [, t, ]}]}], )}]}]}], )}], 2], +, SuperscriptBox[ RowBox[{(, RowBox[{ RowBox[{(Sin[[Theta][t]]), , RowBox[{ SuperscriptBox[R, [Prime], MultilineFunction->None], [, t, ]}]}], +, RowBox[{(Cos[[Theta][t]]), , (R[t]), , RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}]}], +, RowBox[{([Sqrt](((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2)))/((M1 + M2 + M3))^2))), , (Cos[[Theta][t] + [Phi]1[t]]), , RowBox[{(, RowBox[{ RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}], +, RowBox[{ SuperscriptBox[[Phi]1, [Prime], MultilineFunction->None], [, t, ]}]}], )}]}]}], )}], 2]}], )}]}], +, RowBox[{(1/2), , M2, , RowBox[{(, RowBox[{ SuperscriptBox[ RowBox[{(, RowBox[{ RowBox[{(Cos[[Theta][t]]), , RowBox[{ SuperscriptBox[R, [Prime], MultilineFunction->None], [, t, ]}]}], -, RowBox[{(R[t]), , (Sin[[Theta][t]]), , RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}]}], +, RowBox[{((@((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2))), (Sin[ ArcCos[(((-M1) ((2 M2 R1^2 + M3 ((R1^2 - R2^2 + R3^2)))) + M3 (((-M2) ((R1^2 + R2^2 - R3^2)) + M3 (((-R1^2) + R2^2 + R3^2))))))/((2 ((M1 + M2 + M3) )^2 @((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2) @((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2)))/((M1 + M2 + M3))^2)))] + [Theta][ t] + [Phi]1[t]]), , RowBox[{(, RowBox[{ RowBox[{-, RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}]}], -, RowBox[{ SuperscriptBox[[Phi]1, [Prime], MultilineFunction->None], [, t, ]}]}], )}]}]}], )}], 2], +, SuperscriptBox[ RowBox[{(, RowBox[{ RowBox[{(Sin[[Theta][t]]), , RowBox[{ SuperscriptBox[R, [Prime], MultilineFunction->None], [, t, ]}]}], +, RowBox[{(Cos[[Theta][t]]), , (R[t]), , RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}]}], +, RowBox[{((@((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2))), , (Cos[ ArcCos[(((-R1^2) + (1/((M1 + M2 + M3))^2 ) ((M1^2 R1^2 + M2^2 R1^2 + M1 M3 ((R1^2 + R2^2 - R3^2)) + M2 M3 ((R1^2 - R2^2 + R3^2)) + M3^2 ((R2^2 + R3^2))))))/((2 ((@((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2))) [Sqrt](((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2 ^2 + R3^2)))/((M1 + M2 + M3))^2))))] + [Theta][t] + [Phi]1[t]]), , RowBox[{(, RowBox[{ RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}], +, RowBox[{ SuperscriptBox[[Phi]1, [Prime], MultilineFunction->None], [, t, ]}]}], )}]}]}], )}], 2]}], )}]}], +, RowBox[{(1/2), , M3, , RowBox[{(, RowBox[{ SuperscriptBox[ RowBox[{(, RowBox[{ RowBox[{(Cos[[Theta][t]]), , RowBox[{ SuperscriptBox[R, [Prime], MultilineFunction->None], [, t, ]}]}], -, RowBox[{(R[t]), , (Sin[[Theta][t]]), , RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}]}], +, RowBox[{((@((M2^2 R2^2 + M1^2 R3^2 + M1 M2 (((-R1^2) + R2^2 + R3^2)))/((M1 + M2 + M3))^2))), , (Sin[ ArcCos[(((-2) M2 M3 R2^2 + M1^2 ((R1^2 - R2^2 + R3^2)) - M1 ((M2 ((R1^2 + R2^2 - R3^2)) + M3 (((-R1^2) + R2^2 + R3^2))))))/((2 ((M1 + M2 + M3) )^2 @((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2) @((M2^2 R2^2 + M1^2 R3^2 + M1 M2 (((-R1^2) + R2^2 + R3^2)))/((M1 + M2 + M3))^2)))] + ArcCos[(-R1^2) + (1/(8 ((M1 + M2 + M3))^2)) 8 ((M2 + M3))^2 ((R1^2 - ((R1^2 + R2^2 - R3^2))^2/(4 R2^2))) + ((((M3 ((R1^2 - R2^2 - R3^2)) + M2 ((R1^2 + R2^2 - R3^2))))^2/R2^2 + 4 ((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2))))))/((@((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2 ) @((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2))) /((M1 + M2 + M3))^2)))] + [Theta][t] + [Phi]1[t]]), , RowBox[{(, RowBox[{ RowBox[{-, RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}]}], -, RowBox[{ SuperscriptBox[[Phi]1, [Prime], MultilineFunction->None], [, t, ]}]}], )}]}]}], )}], 2], +, SuperscriptBox[ RowBox[{(, RowBox[{ RowBox[{(Sin[[Theta][t]]), , RowBox[{ SuperscriptBox[R, [Prime], MultilineFunction->None], [, t, ]}]}], +, RowBox[{(Cos[[Theta][t]]), , (R[t]), , RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}]}], +, RowBox[{((@((M2^2 R2^2 + M1^2 R3^2 + M1 M2 (((-R1^2) + R2^2 + R3^2)))/((M1 + M2 + M3))^2))), , (Cos[ ArcCos[(((-R2^2) + (1/((M1 + M2 + M3))^2 ) ((((M2^2 + M3^2)) R2^2 + M1^2 ((R1^2 + R3^2)) + M1 ((M3 ((R1^2 + R2^2 - R3^2)) + M2 (((-R1^2) + R2^2 + R3^2))))))))/((2 ((@((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2))) ((@((M2^2 R2^2 + M1^2 R3^2 + M1 M2 (((-R1^2) + R2^2 + R3^2)))/((M1 + M2 + M3))^2)))))] + ArcCos[(((-R1^2) + (1/((M1 + M2 + M3))^2) ((M1^2 R1^2 + M2^2 R1^2 + M1 M3 ((R1^2 + R2^2 - R3^2)) + M2 M3 ((R1^2 - R2^2 + R3^2)) + M3^2 ((R2^2 + R3^2))))))/((2 ((@((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2))) [Sqrt](((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2)))/((M1 + M2 + M3))^2))))] + [Theta][t] + [Phi]1[ t]]), , RowBox[{(, RowBox[{ RowBox[{ SuperscriptBox[[Theta], [Prime], MultilineFunction->None], [, t, ]}], +, RowBox[{ SuperscriptBox[[Phi]1, [Prime], MultilineFunction->None], [, t, ]}]}], )}]}]}], )}], 2]}], )}]}]}]}], ;}], [IndentingNewLine]}]], Input], Cell[BoxData[ ((V = (-((G*MEarth)))*((M1/((@(x1^2 + y1^2))) + M2/((@(x2^2 + y2^2))) + M3/((@(x3^2 + y3^2)))));))], Input], Cell[BoxData[ (((V = (-G) MEarth ((M1/(([Sqrt]((((@((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2)))/((M1 + M2 + M3))^2) Cos[[Theta][t] + [Phi]1[t]] + Cos[[Theta][t]] R[t]))^2 + ((R[t] Sin[[Theta][t]] + @((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2)))/((M1 + M2 + M3))^2) Sin[[Theta][t] + [Phi]1[t]])) ^2)))) + M2/(([Sqrt]((((((@((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2))) Cos[ArcCos[((1/((M1 + M2 + M3))^2) (((-M1) ((2 M2 R1^2 + M3 ((R1^2 - R2^2 + R3^2)))) + M3 (((-M2) ((R1^2 + R2^2 - R3^2)) + M3 (((-R1^2) + R2^2 + R3^2)))))))/((2 @((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2) @((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2)))/ ((M1 + M2 + M3))^2)))] + [Theta][t] + [Phi]1[t]] + Cos[[Theta][t]] R[t]))^2 + ((R[t] Sin[[Theta][t]] + ((@((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2))) Sin[ArcCos[(1/((M1 + M2 + M3))^2) (((-M1) ((2 M2 R1^2 + M3 ((R1^2 - R2^2 + R3^2)))) + M3 (((-M2) ((R1^2 + R2^2 - R3^2)) + M3 (((-R1^2) + R2^2 + R3^2))))))/((2 @((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2) @((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2)))/((M1 + M2 + M3))^2)))] + [Theta][t] + [Phi]1[t]]))^2))) ) + M3/(([Sqrt]((((((@((M2^2 R2^2 + M1^2 R3^2 + M1 M2 (((-R1^2) + R2^2 + R3^2)))/((M1 + M2 + M3))^2))) Cos[ArcCos[(1/((M1 + M2 + M3))^2) (((-2) M2 M3 R2^2 + M1^2 ((R1^2 - R2^2 + R3^2)) - M1 ((M2 ((R1^2 + R2^2 - R3^2)) + M3 (((-R1^2) + R2^2 + R3^2))))))/((2 @((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2) @((M2^2 R2^2 + M1^2 R3^2 + M1 M2 (((-R1^2) + R2^2 + R3^2)))/((M1 + M2 + M3))^2)))] + ArcCos[(1/((M1 + M2 + M3))^2) (((-M1) ((2 M2 R1^2 + M3 ((R1^2 - R2^2 + R3^2)))) + M3 (((-M2) ((R1^2 + R2^2 - R3^2)) + M3 (((-R1^2) + R2^2 + R3^2))))))/((2 @((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2) @((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3^2)))/((M1 + M2 + M3))^2)))] + [Theta][t] + [Phi]1[t]] + Cos[[Theta][t]] R[t]))^2 + ((R[t] Sin[ [Theta][t]] + ((@((M2^2 R2^2 + M1^2 R3^2 + M1 M2 (((-R1^2) + R2^2 + R3^2)))/((M1 + M2 + M3))^2))) Sin[ArcCos[(1/((M1 + M2 + M3))^2) (((-2) M2 M3 R2^2 + M1^2 ((R1^2 - R2^2 + R3^2)) - M1 ((M2 ((R1^2 + R2^2 - R3^2)) + M3 (((-R1^2) + R2^2 + R3^2))))))/((2 @((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2) @((M2^2 R2^2 + M1^2 R3^2 + M1 M2 (((-R1^2) + R2^2 + R3^2)))/((M1 + M2 + M3))^2)))] + ArcCos[(1/((M1 + M2 + M3))^2) (((-M1) ((2 M2 R1 ^2 + M3 ((R1^2 - R2^2 + R3^2)))) + M3 (((-M2) ((R1^2 + R2^2 - R3^2)) + M3 (((-R1^2) + R2^2 + R3^2))))))/((2 @((M1^2 R1^2 + M3^2 R2^2 + M1 M3 ((R1^2 + R2^2 - R3^2)))/((M1 + M2 + M3))^2) @((M2^2 R1^2 + M3^2 R3^2 + M2 M3 ((R1^2 - R2^2 + R3 ^2)))/((M1 + M2 + M3))^2)))] + [Theta][t] + [Phi]1[t]]))^2))))));)([IndentingNewLine]) ))], Input], Cell[BoxData[ ((Lagrange = T - V;))], Input], Cell[BoxData[ ((eqn1 = [ParlD]_t (([ParlD]_(([Theta]')[t])Lagrange)) - [ParlD]_([Theta][t])Lagrange;))], Input], Cell[BoxData[ ((eqn2 = [ParlD]_t (([ParlD]_((R')[t])Lagrange)) - [ParlD]_(R[t])Lagrange;))], Input], Cell[BoxData[ ((eqn3 = [ParlD]_t (([ParlD]_(([Phi]1')[t])Lagrange)) - [ParlD]_([Phi]1[t])Lagrange;))], Input], Cell[BoxData[{ (({MEarth, G, e, Rp, [Theta]start, R1, R2, R3, M1, M2, M3} = {5.97*10^24, 6.672*10^(((-11))), 0.2, 7000*10^3, 0, 100, 50, 100, 100, 100, 100};)), [IndentingNewLine], (([Mu] = G*MEarth;)), [IndentingNewLine], ((a = Rp*((1 + e))/((1 - e^2));)), [IndentingNewLine], ((p = Rp*((1 + e));)), [IndentingNewLine], ((VR = @([Mu]/p)*e*Sin[[Theta]start];)), [IndentingNewLine], ((R0 = p/((1 + e*Cos[[Theta]start]));)), [IndentingNewLine], ((orbvel = @([Mu]/p)*((1 + e*Cos[[Theta]start]))/ R0;)), [IndentingNewLine], ((TOrbit = 2*[Pi]/@([Mu]/((a^3)));)), [IndentingNewLine], ((time = 4*TOrbit;))}], Input], Cell[BoxData[{ (ans = NDSolve[{eqn1 [Equal] 0, eqn2 [Equal] 0, eqn3 [Equal] 0, ([Theta]')[0] [Equal] orbvel, [Theta][0] [Equal] [Theta]start, (R')[0] [Equal] 0, R[0] [Equal] R0, ([Phi]1')[0] [Equal] 0, [Phi]1[0] [Equal] 0}, {[Theta], R, [Phi]1}, {t, 0, time}, MaxSteps [Rule] Infinity, Method [Rule] RungeKutta]), [IndentingNewLine], (Plot[Evaluate[[Theta][t] /. ans], {t, 0, time}, AxesLabel [Rule] {, <[Phi][t]>}, ImageSize [Rule] 350, PlotRange [Rule] All])}], Input] }, FrontEndVersion->4.1 for Microsoft Windows, ScreenRectangle->{{0, 800}, {0, 517}}, WindowSize->{576, 419}, WindowMargins->{{0, Automatic}, {0, Automatic}} ] (******************************************************************* 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, 184, 3, 50, Input], Cell[1892, 55, 608, 11, 184, Input], Cell[2503, 68, 1080, 27, 170, Input], Cell[3586, 97, 391, 6, 130, Input], Cell[3980, 105, 158, 3, 50, Input], Cell[4141, 110, 13106, 236, 2160, Input], Cell[17250, 348, 182, 3, 55, Input], Cell[17435, 353, 3716, 51, 1897, Input], Cell[21154, 406, 54, 1, 30, Input], Cell[21211, 409, 151, 3, 30, Input], Cell[21365, 414, 135, 2, 30, Input], Cell[21503, 418, 147, 2, 30, Input], Cell[21653, 422, 782, 12, 241, Input], Cell[22438, 436, 623, 11, 110, Input] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************) === Subject: Elliptic Integral problem with 5.0 we just upgraded from version 4.2 to 5.0 (5.0.1) and it seems that an some integrals are not solvabla any more Here the input on the system $Version Integrate[Cos[phi]/(x^2 - 2*x*r*Cos[phi] + r^2 + z^2)^(3/2),{phi, 0, 2*Pi}] and the kernel just happily uses up CPU cycles with no result. I have did not turn up information either. Would anybody have a hint on what is going on. Andreas Mathematics, HTI Phone: ++41 +32 32 16 258 Quellgasse 21 Fax: ++41 +32 321 500 CH-2501 Biel WWW: www.hta-bi.bfh.ch/~sha Switzerland === Subject: Draws from Multivariate Normal Distribution Anyone know how to set up random draws from a multivariate normal distribution based on a given n x n covariance matrix? === Subject: Re: optimization & question > It appears that Select doesn't take any advantage of a potenl > optimization. When given a function that is going to generate a > large list of items to test, even when there are clearly no side > effects involved, it appears to generate the entire list first, > consuming large amounts of memory, beating the processor cache up, > hammering swap space, etc, and then begins testing the individual > elements. > It can be very easy and clear to write things like this if I don't > start adding my own work-arounds to divide the list into pieces > and iterate over the pieces. > Any chance that an optimization like this might be considered for > a future version? > Anyone have a very clear and simple way to write this that avoids > this problem, and speeds it up, rather than slowing it down? In > the cases I've been using the number of items selected is usually > a tiny fraction of the size of the original list. What you are asking for is called lazy programming in functional programming circles. Whether a language is lazy or strict, which is the opposite model, is a design decision made early on, Mathematica is fundamentally strict. I believe I have seen examples of Mathematica code that behaves in a lazy fashion, but I can't find the references right now. In general though, if you are iterating over large structures it's better to define an expression that returns just the part of the structure you're interested in and operate on that, collecting the results. For your particular case: Module[{result={}},Do[If[f[i],result=Append[result,i]],{i,10000000}]; result] is a more memory efficient expression. There are probably further optimizations possible. Ssezi === Subject: net-link Suppose a dot-net program ( C#, for example) already has a link to the kernel via net-link. How would I open a notebook from within the dot-net program to either take input (perhaps an equation that the program will then use) or to display graphics? === Subject: Re: eigenvector rotation If you multiply all of the eigenvectors of a Hermin matrix H by Exp[I theta] where theta is real then you still have a valid set of eigenvectors (i.e. they satisfy the H xi = lambdai xi, and the orthonormality conditions = KroneckerDelta[i,j] are satisfied). That means that the value of theta is arbitrary so Mathematica can use any theta she wants, and you can then multiply Mathematica's result by your own Exp[I theta]. Steve Luttrell > Hi > It seems, that when I calculate the eigensystem of a complex Hermin > matrix, th eigenvectors get rotated automatically in such a way, that > the highest absolute valued eigenvector component becomes real. Since I > need the unrotated result, how do I switch off this feature? > Bettina === Subject: Re: eigenvector rotation since Mathematica use the EISPACK routines you have to write your own code to find the eigensystem and you can't use any library because all numerical librarys use EISPACK And I would expect that the effect comes form the Householder rotation during the eigensystem computation. Jens > Hi > It seems, that when I calculate the eigensystem of a complex Hermin > matrix, th eigenvectors get rotated automatically in such a way, that > the highest absolute valued eigenvector component becomes real. Since I > need the unrotated result, how do I switch off this feature? > Bettina === Subject: Re: eigenvector rotation > Hi > It seems, that when I calculate the eigensystem of a complex Hermin > matrix, th eigenvectors get rotated automatically in such a way, that > the highest absolute valued eigenvector component becomes real. Since I > need the unrotated result, how do I switch off this feature? > Bettina Since any complex nonzero multiple of an eigenvector is an eigenvector, one can choose any proper rotation and scaling. In order to obtain another direction, you just have to multiple the eigenvector with a complex number. Why do you think, that the unrotated result is better? How should this vector look like? Alois === Subject: FindMinimum: foo[x_?NumericQ] vs. NumberQ for: FindMinimum[foo[x],{x,x0,x1...}] whereas FindMinimum was evidently attempting a symbolic gradient evaluation of foo[], even though the invocation was indicating to use numeric derivatives. The recommended fix was to redefine foo[] as so: foo[x_?NumericQ] This evidently worked for all involved, but I tried it on what I thought was a similar problem, and had no luck. However, what did work was using NumberQ instead of NumericQ in the pattern-match test. Go figure. HTHs somebody. === Subject: Tab-Delimited Text Would be Heaven Hi everyone, I've played with the Export function to save matrices to text files using the Table format, but always end up with curly brackets, commas and a variable number of spaces between data points. This makes for extra clean up work before importing into a spread sheet. Is there some way to get Mathematica to save to tab-delimited text? === Subject: Finding the intersection of some subspaces, given bases. Suppose I have a collection of subspaces described by bases, for example V1 = {{1,1,0},{1,-1,0}}; V2 = {{1,1,1},{1,1,-1}}; and I'd like to find the intersection of these. I'd like a function along the lines of IntersectSubspaces[V1,V2] = {{1,1,0}} I also need this function to work with vectors over Q(q), rational functions in an indeterminate q. Here's one method that works: IntersectSubspaces[bases__] := Module[{n, perp}, If[Length[{bases}] == 1, Return[bases]]; If[MemberQ[{bases}, {}], Return[{}]]; perp = Simplify[Join @@ (NullSpace[#, Method -> OneStepRowReduction] & /@ {bases})]; If[perp == {}, n = Length[{bases}[[1, 1]]]; IdentityMatrix[n], Simplify[NullSpace[perp, Method -> OneStepRowReduction]]] ] The first two conditions check for some simple cases; only one subspace, and a 0-dimensional subspace. The idea then is to find an orthogonal complement for each of the subspaces, using NullSpace, joining these together to span a spanning set (but not a basis) for the direct sum of the complements, then taking NullSpace of this again to obtain the desired intersection. (There's also an extra check in there for the case where each of the subspaces spans the whole space.) Now -- why use Simplify and Method -> OneStepRowReduction? Simplify is there because the components become quite complicated rational functions in q. (An aside -- is it possible to get NullSpace (and LinearSolve, etc) to perform simplifications at every step? Would this help in doing linear algebra over rational functions?) The Method -> OneStepRowReduction is there ... because otherwise all sorts of bad things seem to happen, and the code runs extremely slowly once we're up in dimension 10 to 20. Unfortunately, this code is still way too slow... Any ideas for a more efficient approach? Scott Morrison scott at-sign math dot berkeley dot edu === Subject: Re: fill the empty spaces in a matrix Ok, now I see. If you actually have empty spaces, but separated with a comma, then use ReplaceAll: In[1]:= aa = {{0, , 0}, {0, 0, 0}, {0, 0,}} Out[1]= {{0, Null, 0}, {0, 0, 0}, {0, 0, Null}} In[2]:= aa /. Null -> 0 Out[2]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}} If you have a symbol, say x (provided x has not been assigned a numerical value), then In[3]:= bb = {{0, x, 0}, {0, 0, 0}, {0, 0, x}} Out[3]= {{0, x, 0}, {0, 0, 0}, {0, 0, x}} In[4]:= bb /. x -> 0 Out[4]= {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}} Tomas ----- Original Message ----- === Subject: RE: fill the empty spaces in a matrix Lets say aa is my matrix the spaces x marks the empty space. If I try to use this matrix in a calculation Mathematica will have a problem because the matrix in not even. Mathematica will see that the first row (0 x 0) does not have the same amount of elements as row 2 (0 0 0 ). Is there a way to tell Mathematica to automatically fill in the empty segments (x) with '0'. / 0 x 0 aa= | 0 0 0 | 0 0 x / or aa= {{0, ,0},{0,0,0},{0,0, }}; sorry for the misunderstanding. -----Original Message----- === Subject: Re: fill the empty spaces in a matrix I'm sorry about my ignorance, not knowing what you mean by an uneven matrix. In any case, you must specify which are the empty positions you want to fill. Tomas Garza Mexico City ----- Original Message ----- === Subject: fill the empty spaces in a matrix > Hi all, > I have an uneven matrix > / 0 0 > aa= | 0 0 0 | > 0 0 / > I want to fill the empty spaces with 0's, how do I do that. > thank you === Subject: Re: fill the empty spaces in a matrix I'm sorry about my ignorance, not knowing what you mean by an uneven matrix. In any case, you must specify which are the empty positions you want to fill. Tomas Garza Mexico City ----- Original Message ----- === Subject: fill the empty spaces in a matrix > Hi all, > I have an uneven matrix > / 0 0 > aa= | 0 0 0 | > 0 0 / > I want to fill the empty spaces with 0's, how do I do that. > thank you === Subject: RE: fill the empty spaces in a matrix Mike, For this question you should give more information. What exactly is the Mathematica form of aa? You could use something like the following. {{0, , 0}, {0, 0, 0}, {0, 0,}} % /. Null -> 0 {{0, Null, 0}, {0, 0, 0}, {0, 0, Null}} {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}} David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Hi all, I have an uneven matrix / 0 0 aa= | 0 0 0 | 0 0 / I want to fill the empty spaces with 0's, how do I do that. thank you === Subject: Functions Mapping Suppose I have a list of operators {Sin, Cos}, and a list of variables {x,y}, I want to apply {Sin,Cos} on {x,y}, and the outcome to be {{Sin[x],Sin[y]},{Cos[x],Cos[y]}} I can achieve this by using Table function with a temporary counter i. But is there any way to do this without using temporary counters? XJ === Subject: Re: Tab-Delimited Text Would be Heaven Hi: Have you tried Export[matrix.tsv, your_matrix_here,TSV] If your os does not recognize the extention tsv just change it to Export[matrix.txt, your_matrix_here,TSV] Hans TSV format is Tab Separated Value > Hi everyone, > I've played with the Export function to save matrices to text files > using the Table format, but always end up with curly brackets, commas > and a variable number of spaces between data points. This makes for > extra clean up work before importing into a spread sheet. Is there > some way to get Mathematica to save to tab-delimited text? > === Subject: Re: Draws from Multivariate Normal Distribution Hi: Look into help under standard packages -> Statistics -> Multinormal distribution Load. < Anyone know how to set up random draws from a multivariate normal > distribution based on a given n x n covariance matrix? > === Subject: Re: Draws from Multivariate Normal Distribution > Anyone know how to set up random draws from a multivariate normal > distribution based on a given n x n covariance matrix? > In the scalar situation, you can use the built in function Quantile[NormalDistribution[mean,variance],Random[]] and if you want the whole sample (of n elements) you can use List[Quantile[NormalDistribution[...],Random[]],{100}]. In the matrix situation, I don't Know... sc === Subject: Re: Draws from Multivariate Normal Distribution Needs[Statistics`MultinormalDistribution`]; mu = {3, 5}; sigma={{1, .3}, {.3, 1}}; dist=MultinormalDistribution[mu, sigma]; draws=RandomArray[dist, {500}]; Show[Graphics[{Point /@ draws, Hue[1], EllipsoidQuantile[dist, .95]}], Frame -> True]; Bob Hanlon << Anyone know how to set up random draws from a multivariate normal distribution based on a given n x n covariance matrix? === Subject: Factoring two-dimensional series expansions? (Ince polynomials again) This is a math question rather than a Mathematica question, but anyway: Suppose I have a function f[x,y] that's a power series expansion in factors x^m y^n , that is, (1) f[x, y] = Sum[ a[m,n] x^m y^n, {m, 0, mm}, {n, 0, mm} ] with known a[m,n] coefficients Are there algorithmic procedures for factoring this function (analytically or numerically) into a simple product of power series or simple folynomials in x and y separately, i.e., (2) f[x ,y] = fx[x] fy[x] or maybe (3) f[z1, z2] = fz1[z1] fz2[z2] where z1 and z2 are linear combinations of x and y ? Or more realistically there tests for *when* or whether the original function can be so factored? The question is motivated by some recent work in paraxial beam propagation in which the function f[x,y] is actually the sum of Hermin polynomials, call 'em h[m,x] and h[n,y] for brevity, with expansion coefficients b[m,n], i.e. (4) f[x, y] = Sum[ b[m,n] h[m,x] h[n,y], {m, 0, mm}, {n, 0, mm} ] where the coefficients b[m,n] can be arbitrary but there is a special constraint that m + n = a constant integer p . Apparently this expansion can be factored into a product like (3) where the functions fz1{z1} and fz2[z2] are both some kind of mysterious Ince polynomials and the variables z1 and z2 are elliptical coordinates in the x,y plane, with the elliptical coordinate system vasrying with the choice of the coefficients b[m,n] . === Subject: Re: queation exporting quaternions from mathematica 5 > the DXF import is for 3d files not for 2d files. > If you would like to import a 2d vector graphics > I recommend PostScript and pstoedit that hat a Mathematica > mode .. > I don't know what graphics conversion programs do you are > using but atleast my 3d modellers have all a continued > DXF import/export. > DXF is not very powerfull for 3d files because it only > export the naked polygons and not texture coordinates, > normals or userdefined colors (different form the plotter > pen colors). The second draw back of DXF files is that the > format is not very compact and even small models generate > very large DXF files. > Jens > A PS to this thread which may actually be a question ... > Just today I had occasion to read a .dxf file into Mathematica, looking for > a way to display it (a template for a kitchen sink from Kohler, if you must > know :-). > I received an error that there was no Z-dimension. This should not have > surprised me, as on-line help indicated that the result of Import-ing the > file would be a 3DGraphicObject. > Still, it seemed to be a bit odd that Mathematica gave up so easily on a > simple 2D figure (rectangle with rounded corners). Is there perhaps some > simple rationale for this? > I also noticed that a lot of graphic conversion programs are dropping ..dxf > (and I assume also .dwg/f) formats from their inventory. > -Bruce Kuska a) a quaternion is not a 3d shape and it is not complicated > b) Mathematica can read and write DXF and STL files > c) if you install MathGL3d from http://phong.informatik.uni-leipzig.de/~kuska/mathgl3dv3/ you can export VRML, POVRay, QuickDraw3D and in the upcomming version > Alias|Wavefront 3d files. Jens > >> >> Hi all, I was wondering (before I purchase the mathematica package) if >> it would be possible to export complicated 3d shapes (like quaternions) >> as meshes (.dxf / .obj), so that I can use it in 3d graphic packages >> like 3ds max. I read that there is an external viewer that displays the >> 3dplot and has export capabilities. But for other packages this is >> normally limited to 3d deformations of standard meshes, so that's why I >> ask >> >> If not possible, would you know another package that would be capable of >> doing just that. >> >> Thx chris > ----------------------------- What are the zeroes of the quaternion zeta function? === Subject: zeroes of the quaternion zeta function. What are the zeroes of the quaternion zeta function? Edward Jones === Subject: RE: Functions Mapping XJ, Outer[#1[#2] &, {Sin, Cos, Exp}, {x, y}] {{Sin[x], Sin[y]}, {Cos[x], Cos[y]}, {E^x, E^y}} David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Suppose I have a list of operators {Sin, Cos}, and a list of variables {x,y}, I want to apply {Sin,Cos} on {x,y}, and the outcome to be {{Sin[x],Sin[y]},{Cos[x],Cos[y]}} I can achieve this by using Table function with a temporary counter i. But is there any way to do this without using temporary counters? XJ === Subject: Re: Functions Mapping Say that a=Range[10], and you wish to map 1..10 into {Sin and Cos}. Try {Sin[#], Cos[#]} & /@ a Is not mathematica great once you find 'tricks' like this. Bob. > Suppose I have a list of operators {Sin, Cos}, and a list of > variables {x,y}, > I want to apply {Sin,Cos} on {x,y}, and the outcome to be > {{Sin[x],Sin[y]},{Cos[x],Cos[y]}} > I can achieve this by using Table function with a temporary counter i. > But is there any way to do this without using temporary counters? > XJ === Subject: Re: Functions Mapping Outer[#1[#2]&, {Sin, Cos},{x,y}] {{Sin[x], Sin[y]}, {Cos[x], Cos[y]}} Bob Hanlon << Suppose I have a list of operators {Sin, Cos}, and a list of variables {x,y}, I want to apply {Sin,Cos} on {x,y}, and the outcome to be {{Sin[x],Sin[y]},{Cos[x],Cos[y]}} I can achieve this by using Table function with a temporary counter i. But is there any way to do this without using temporary counters? === Subject: Re: Functions Mapping >>How about these? >>myF[x_]:={Sin[x],Cos[x]} >>Thread[myF[{x,y}]] >>or just >>{Sin[#],Cos[#]}&/@{x,y} >>which is the same as >>Map[{Cos[#],Sin[#]}&,{x,y}] Ya, it works. But can I just treat Sin, Cos as operators, and do not use temporary variables, such as #, x_ :) XJ === Subject: Re: Finding the intersection of some subspaces, given bases. Scott, Would Grassmann's regressive product be of use here? The regressive product of two multivectors A and B (exterior product of vectors) gives the multivector whose space is the intersection of the spaces of A and B. One advantage might be that the product does not assume a metric, hence does not need or use concepts like orthogonality. A discussion of the regressive product can be found at http://www.ses.swin.edu.au/homes/browne/grassmannalgebra/book/ > Suppose I have a collection of subspaces described by bases, for > example > V1 = {{1,1,0},{1,-1,0}}; > V2 = {{1,1,1},{1,1,-1}}; > and I'd like to find the intersection of these. I'd like a function > along the lines of > IntersectSubspaces[V1,V2] = {{1,1,0}} > I also need this function to work with vectors over Q(q), rational > functions in an indeterminate q. > Here's one method that works: > IntersectSubspaces[bases__] := Module[{n, perp}, > If[Length[{bases}] == 1, Return[bases]]; > If[MemberQ[{bases}, {}], Return[{}]]; > perp = Simplify[Join @@ (NullSpace[#, Method - OneStepRowReduction] & /@ {bases})]; > If[perp == {}, n = Length[{bases}[[1, 1]]]; IdentityMatrix[n], > Simplify[NullSpace[perp, Method -> OneStepRowReduction]]] > ] > The first two conditions check for some simple cases; only one > subspace, and a 0-dimensional subspace. > The idea then is to find an orthogonal complement for each of the > subspaces, using NullSpace, joining these together to span a spanning > set (but not a basis) for the direct sum of the complements, then > taking NullSpace of this again to obtain the desired intersection. > (There's also an extra check in there for the case where each of the > subspaces spans the whole space.) > Now -- why use Simplify and Method -> OneStepRowReduction? Simplify is > there because the components become quite complicated rational > functions in q. (An aside -- is it possible to get NullSpace (and > LinearSolve, etc) to perform simplifications at every step? Would this > help in doing linear algebra over rational functions?) The Method -OneStepRowReduction is there ... because otherwise all sorts of bad > things seem to happen, and the code runs extremely slowly once we're > up in dimension 10 to 20. > Unfortunately, this code is still way too slow... Any ideas for a more > efficient approach? > Scott Morrison > scott at-sign math dot berkeley dot edu ____________________________ John Browne School of Engineering and Science Swinburne University of Technology === Subject: Exceed 4Gb memory limit with an Apple G5? all, My recent work in Mathematica has me bumping repeatedly into the 4Gb limit of addressable memory of Mathematica 5 on my Apple G4. Within the next few months, I need to replace (or augment) this machine with one with a 64-bit processor and OS and a version of Mathematica that supports an address space beyond 4Gb. I see on Wolfram's site that Mathematica supports this extended address Does anyone have personal experience with addresses beyond 4Gb running Mathematica 5 on an Apple G5 running OSX? Tom Burton