A8 == It is a pleasure write to you again. I have three questions to ask. Alexandre Costa Question One: The below code is working fine but I think there are more elegant ways of doing so.Any suggestions are VERY WELCOME.<< DiscreteMath`Permutations`individual1 = RandomPermutation[12]individual2 = RandomPermutation[12]CutPosition = 3 ;CutLength = 4 ;CutSequence = Take[Drop[individual1, CutPosition], CutLength]SonOne = individual2;Do[ If[MemberQ[SonOne, CutSequence[[i]]], SonOne = Delete[SonOne, Position[SonOne, CutSequence[[i]]]]], {i, 1, CutLength}];SonOneSonOne = RotateLeft[SonOne, 1]Do[SonOne = Insert[SonOne, Reverse[CutSequence][[i]], CutPosition + 1], {i, 1, CutLength}]SonOneQuestion Two:How can I change points properties (such as Size and Color) for the plot below? The PlotStyle Option does not work for this LabeledListPlot<< Graphics`Graphics`listcities = {{1, 5}, {4, 6}, {7, 5}, {5, 4}, {9, 4}, {2, 3}, {4, 2}, {6, 2}, {1, 1}, {5, 1}, {3, 0}, {9, 0}};LabeledListPlot[listcities, Axes -> None, Frame -> True, DisplayFunction -> $DisplayFunction]Question Three: Why the Goto statement below is not working?q = 2;Label[start];q = 3;Label[begin];Print[q];q += 1; If[q < 6, Goto[begin], Goto[start]]Reply-To: murray@math.umass.edu ==== I presume packagename is a context name, e.g., Graphics`Colors` . Then evaluating the expression Names[packagename*]containing the wildcard symbol * will probably do what you want.It may tell you more than you want to know unless the package was decently written. By decently I mean that names not needing to be known to the outside world have been enclosed within a Private context within the package's context.> After I load a package using> < Is there a way to figure out what the package exports without editing> the source file?> -- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375 ==== Jose,I generally use the Needs statement to load a package. It avoids doubleloading and all the error messages that result. SayNeeds[Graphics`Graphics`]Then to obtain information on the routines in the package just use...?Graphics`Graphics`*names in the package. If you click on any of the names you obtain the usagemessage for the name. (On earlier Mathematica versions you only obtain alist of the names and you have to use ?name to obtain the usage message.)More link. If you click on that it will bring you to the relevant Helppage. (Private packages may not have that feature.)David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.netApproved: Steven M. Christensen , ModeratorReply-To: ==== Maybe there's a faster way -- I hope so! -- but here's my answer:n = 2^26Timing[RealDigits[N[Pi - 3, n], 10, 20, 19 - n]]67108864{15027.922*Second, {{3, 3, 8, 6, 3, 2, 2, 0, 8, 9, 6, 2, 2, 3, 4, 0, 9, 8, 0, 3},-67108844}}hrMinSec[15027.922]{4*hours, 10*minutes, 27.92200000000048*seconds}Bobby Treat-----Original Message----- ==== Could you tell me the CPU you used and its speed etc...i am curious,other programs out there.> Maybe there's a faster way -- I hope so! -- but here's my answer:> n = 2^26> Timing[RealDigits[N[Pi - 3, n], 10, 20, 19 - n]]> 67108864> {15027.922*Second,> {{3, 3, 8, 6, 3, 2, 2, 0, 8, 9, 6, 2, 2, 3, 4, 0, 9, 8, 0, 3},> -67108844}}> hrMinSec[15027.922]> {4*hours, 10*minutes, 27.92200000000048*seconds}> Bobby Treat> -----Original Message-----> 4 for me?> Could someone calculate the number Pi to 67,108,864 (2^26) decimal> places> I made the calculation in another program and would like to verify its> > ==== > Could you tell me the CPU you used and its speed etc...i am curious,> other programs out there.I used one processor of a dual 1GH Mac and got the same answer with thefollowing speed:4.2 for Mac OS X (June 4, 2002)oldmax = $MaxPrecision 61. 10$MaxPrecision = InfinityInfinityWith[{n = 2^26}, Timing[ pd = RealDigits[N[Pi, n + 1], 10, 20, 19 - n]; ]]{28794.1 Second, Null}MaxMemoryUsed[]512055204pd{{3, 3, 8, 6, 3, 2, 2, 0, 8, 9, 6, 2, 2, 3, 4, 0, 9, 8, 0, 3}, -67108844}Tom Burton-- ==== So would it take about the same amont of time for the complete printoutof digits? Of course it would take a few additional seconds to formatthe output...Or does Mathematica take alot less time when it truncates the output?> Could you tell me the CPU you used and its speed etc...i am curious,> other programs out there.> I used one processor of a dual 1GH Mac and got the same answer with the> following speed:> 4.2 for Mac OS X (June 4, 2002)> oldmax = $MaxPrecision> 6> 1. 10> $MaxPrecision = Infinity> Infinity> With[{n = 2^26}, Timing[> pd = RealDigits[N[Pi, n + 1], 10, 20,> 19 - n]; ]]> {28794.1 Second, Null}> MaxMemoryUsed[]> 512055204> pd> {{3, 3, 8, 6, 3, 2, 2, 0, 8, 9, 6, 2, 2, 3,> 4, 0, 9, 8, 0, 3}, -67108844}> Tom Burton ==== Here's an answer to Question 1:individual1 = RandomPermutation[12]individual2 = RandomPermutation[12]cutPosition = 3;cutLength = 4;cutSequence = Take[Drop[individual1, cutPosition], cutLength]sonOne = Complement[individual2, cutSequence]sonOne = RotateLeft[sonOne, 1]sonOne = Join[Take[sonOne, cutLength - 1], cutSequence, Drop[sonOne, cutLength - 1]]Bobby Treat-----Original Message-----<< DiscreteMath`Permutations`individual1 = RandomPermutation[12]individual2 = RandomPermutation[12]CutPosition = 3 ;CutLength = 4 ;CutSequence = Take[Drop[individual1, CutPosition], CutLength]SonOne = individual2;Do[ If[MemberQ[SonOne, CutSequence[[i]]], SonOne = Delete[SonOne, Position[SonOne, CutSequence[[i]]]]], {i, 1, CutLength}];SonOneSonOne = RotateLeft[SonOne, 1]Do[SonOne = Insert[SonOne, Reverse[CutSequence][[i]], CutPosition + 1], {i, 1, CutLength}]SonOneQuestion Two:How can I change points properties (such as Size and Color) for the plotbelow? The PlotStyle Option does not work for this LabeledListPlot<< Graphics`Graphics`listcities = {{1, 5}, {4, 6}, {7, 5}, {5, 4}, {9, 4}, {2, 3}, {4, 2}, {6, 2}, {1, 1}, {5, 1}, {3, 0}, {9, 0}};LabeledListPlot[listcities, Axes -> None, Frame -> True, DisplayFunction -> $DisplayFunction]Question Three: Why the Goto statement below is not working?q = 2;Label[start];q = 3;Label[begin];Print[q];q += 1; If[q < 6, Goto[begin], Goto[start]] ==== I would like to build my Mathematica notebooks in manner which allows me to carry out two overlapping purposes: 1) prototype an algorithm completely within Mathematica, 2) use Mathematica as a partial evaluator to splice derived expressions into a C language version of the algorithm (with the aid of the Format package from MathSource). The key complication in doing this is that for the Mathematica prototype I want everything to be evaluated, while for splicing I want the results from some of the functions to be retained as data in temporary variables.A first step towards these purposes is simple: write my component functions so they operate on lists (the natural form of the prototype data), then provide lists of arrays for arguments which I would like to supply as data in the resulting C language output forms.An example:--------------------------------------------------In [1]:= t[x_] := {x[[4]]-x[[3]], x[[2]]-x[[1]]}In[2]:= f[x_,y_] := {y, 1}.t[x]In[3]:= f[{1,2,3,4},2]Out[3]= 3In[4]:= f[Array[x,4],2]Out[4]= -x[1] + x[2] + 2 (-x[3] + x[4])In[5]:= CAssign[fcnval, f[Array[x,4],2], AssignToArray->{x}]Out[5]//OutputForm= fcnval=-x[1]+x[2]+2.*(-x[3]+x[4]);--------------------------- -----------------------For various reasons, however, I would like certain expressions of my symbolic derivation to be treated as data for the C language version. In the above example, for instance, I would like the array that function t produces to be a data array. The modification of the above example:--------------------------------------------------In[ 6]:= tc[x_] := Array[tt,2]In[7]:= fc[x_,y_] := {y, 1}.tc[x]In[8]:= CAssign[tt, t[Array[x,4]], AssignToArray->{x}]Out[8]//OutputForm= tt[0]=-x[3]+x[4]; tt[1]=-x[1]+x[2];In[9]:= CAssign[fcnval, fc[Array[x,4],2], AssignToArray->{tt}]Out[9]//OutputForm= fcnval=2.*tt[1]+tt[2];--------------------------------------- -----------But I don't want to carry around two versions of everything, nor do I really want to thread all of the supporting functions through my definitions in order to choose the correct function for the purpose I would rather define the C language alternatives only for functions like t and tc in the example, with f using the appropriate one depending on some evaluation ßag that I set at the highest level.For example, it would be nice to be able to sprinkle in the C language alternatives with a construct likeIn[10]:= t[x_] := {x[[4]]-x[[3]], x[[2]]-x[[1]]}In[11]:= DefineTemporaryForm[t[x_]] := Array[tt,Length[x]/2]then be able to writeIn[8]:= CAssign[tt, t[Array[x,4]], AssignToArray->{x}]Out[8]//OutputForm= tt[0]=-x[3]+x[4]; tt[1]=-x[1]+x[2];In[9]:= CAssign[fcnval, UseTemporaryForm[f[Array[x,4],2]], AssignToArray->{tt}]Out[9]//OutputForm= fcnval=2.*tt[1]+tt[2];I would appreciate any pointers on a good, clean and hopefully simple way to do this within Mathematica!Alex ==== I've been using Mathematica 4.1 on Win98 as a word processor formath-related documents, but often people that need to see the documentsdon't have Mathematica, and for whatever reason on my computer the HTMLsaves don't work at all. I'd like to export to PDF format. I can exportimages to PDF format no problem using, for exampleExport[c:docsplot3.pdf, Plot[Sin[x],{x,-2Pi,2Pi}]],and I can export cells correctly to GIF, JPEG, and WMF formats (probablymore, those are the only ones I tested) using, for exampleExport[c:docscell4.gif, Cell[ <<...(copied cell data from Edit->CopyAs->Cell Expression)...> ]]When I change the filename to a .PDF and evaluate the cell, the programdisplays ÔRunning...' for a second and gives the ÔOut[n] = c:docscell4.pdf' message as if a file was created, but no file is created anywhere with anyname that I could find with Start->Find->[All files and folders created inthe previous day].Is there a limitation to PDF exporting I don't know about? Do I need toupgrade to 4.2? Am I doing something wrong with the Export[] command? Do Ineed a faster computer? A patch? Something else? ==== I recently communicated with technical support about precisely this issue. Here's their reply:``PDF and AI export use psrender, which is a MathLink program that interfaces with the kernel. Since the kernel has no knowledge of how cells are formatted, export cannot generate PDF and AI for cells, just Graphics.Note that this is contrary to the documentation, which says:``All graphics formats in Export can handle any type of 2D or 3D Mathematica graphics. ... They can also handle Notebook and Cell objects.---Selwyn Hollis> I've been using Mathematica 4.1 on Win98 as a word processor for> math-related documents, but often people that need to see the documents> don't have Mathematica, and for whatever reason on my computer the HTML> saves don't work at all. I'd like to export to PDF format. I can export> images to PDF format no problem using, for example> Export[c:docsplot3.pdf, Plot[Sin[x],{x,-2Pi,2Pi}]],> and I can export cells correctly to GIF, JPEG, and WMF formats (probably> more, those are the only ones I tested) using, for example> Export[c:docscell4.gif, Cell[ <<...(copied cell data from Edit->Copy> As->Cell Expression)...> ]]> When I change the filename to a .PDF and evaluate the cell, the program> displays ÔRunning...' for a second and gives the ÔOut[n] = c:docscell4.pdf> Ô message as if a file was created, but no file is created anywhere with any> name that I could find with Start->Find->[All files and folders created in> the previous day].> Is there a limitation to PDF exporting I don't know about? Do I need to> upgrade to 4.2? Am I doing something wrong with the Export[] command? Do I> need a faster computer? A patch? Something else?> ==== Here's a smoother animation, taking into account the period and cuttingthe step size in half (without using more frames):Do[Show[curve, Graphics[Disk[{ xx[t], Cosh[xx[t]]}, 0.035]], PlotRange -> {{-1.2, 1.2}, {0.9,1.65}}, AspectRatio -> Automatic, Axes -> None], {t, 0, 2.3, 0.05}]SelectionMove[EvaluationNotebook[], All, GeneratedCell]FrontEndTokenExecute[OpenCloseGroup] FrontEndTokenExecute[SelectionAnimate]Bobby Treat-----Original Message-----and the equation of motion is diffeq = Simplify[ D[D[L, x'[t]], t] ] == Simplify[ D[L, x[t]] ]Now solve and animate ... xx[t_] = x[t]/. First[ NDSolve[{diffeq, x[0] == -1, x'[0] == 0}, x[t], {t, 0, 5}]] curve = Plot[Cosh[x], {x, -1, 1}] Do[ Show[curve, Graphics[Disk[{xx[t], Cosh[xx[t]]}, 0.025]], PlotRange -> {{-1.2, 1.2}, {0.9, 1.65}}, AspectRatio -> Automatic, Axes->None], {t, 0, 5, 0.1}]----Selwyn Hollis> Dear Colleagues,> I intend to make an animation in which > ball A rolls down on an inclined plane from the left whilst> ball B - starting from the same height - rolls down Cosh[t]'s pathfrom the> right.> x-axis is time t, y-axis is height h.> Ball A is fine; ball B - which should arrive at h=0 before A - isbeyond my> means.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> ==== I would like to build my Mathematica notebooks in manner which allows me to carry out two overlapping purposes: 1) prototype an algorithm completely within Mathematica, 2) use Mathematica as a partial evaluator to splice derived expressions into a C language version of the algorithm (with the aid of the Format package from MathSource). The key complication in doing this is that for the Mathematica prototype I want everything to be evaluated, while for splicing I want the results from some of the functions to be retained as data in temporary variables.A first step towards these purposes is simple: write my component functions so they operate on lists (the natural form of the prototype data), then provide lists of arrays for arguments which I would like to supply as data in the resulting C language output forms.An example:--------------------------------------------------In [1]:= t[x_] := {x[[4]]-x[[3]], x[[2]]-x[[1]]}In[2]:= f[x_,y_] := {y, 1}.t[x]In[3]:= f[{1,2,3,4},2]Out[3]= 3In[4]:= f[Array[x,4],2]Out[4]= -x[1] + x[2] + 2 (-x[3] + x[4])In[5]:= CAssign[fcnval, f[Array[x,4],2], AssignToArray->{x}]Out[5]//OutputForm= fcnval=-x[1]+x[2]+2.*(-x[3]+x[4]);--------------------------- -----------------------For various reasons, however, I would like certain expressions of my symbolic derivation to be treated as data for the C language version. In the above example, for instance, I would like the array that function t produces to be a data array.The modification of the above example:--------------------------------------------------In [6]:= tc[x_] := Array[tt,2]In[7]:= fc[x_,y_] := {y, 1}.tc[x]In[8]:= CAssign[tt, t[Array[x,4]], AssignToArray->{x}]Out[8]//OutputForm= tt[0]=-x[3]+x[4]; tt[1]=-x[1]+x[2];In[9]:= CAssign[fcnval, fc[Array[x,4],2], AssignToArray->{tt}]Out[9]//OutputForm= fcnval=2.*tt[1]+tt[2];--------------------------------------- -----------But I don't want to carry around two versions of everything, nor do I really want to thread all of the supporting functions through my definitions in order to choose the correct function for the purpose I would rather define the C language alternatives only for functions like t and tc in the example, with f using the appropriate one depending on some evaluation ßag that I set at the highest level.For example, it would be nice to be able to sprinkle in the C language alternatives with a construct likeIn[10]:= t[x_] := {x[[4]]-x[[3]], x[[2]]-x[[1]]}In[11]:= DefineTemporaryForm[t[x_]] := Array[tt,Length[x]/2]then be able to writeIn[8]:= CAssign[tt, t[Array[x,4]], AssignToArray->{x}]Out[8]//OutputForm= tt[0]=-x[3]+x[4]; tt[1]=-x[1]+x[2];In[9]:= CAssign[fcnval, UseTemporaryForm[f[Array[x,4],2]], AssignToArray->{tt}]Out[9]//OutputForm= fcnval=2.*tt[1]+tt[2];I would appreciate any pointers on a good, clean and hopefully simple way to do this within Mathematica!Alex ==== To find out what loaded contexts are related to the package, use:Contexts[Integrate`*]{Integrate`,Integrate`Elliptic`} To see the symbols exported by the context, execute:Names[Integrate`*]{(* too many to list here *)}Names[Integrate`*`*]{Integrate`Elliptic`Elliptic}To find out what context a symbol comes from:Context[Integrate]System`Bobby Treat-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , ModeratorReply-To: ==== Oops! That should beindividual1 = RandomPermutation[12]individual2 = RandomPermutation[12]cutPosition = 3;cutLength = 4;cutSequence = Take[Drop[individual1, cutPosition], cutLength]sonOne = DeleteCases[individual2, _?(MemberQ[cutSequence, #] &)]sonOne = RotateLeft[sonOne, 1]sonOne = Join[Take[ sonOne, cutLength - 1], cutSequence, Drop[sonOne, cutLength - 1]]Complement returns a sorted result, and you didn't want that.Bobby Treat-----Original Message-----sonOne = Join[Take[sonOne, cutLength - 1], cutSequence, Drop[sonOne, cutLength - 1]]Bobby Treat-----Original Message-----<< DiscreteMath`Permutations`individual1 = RandomPermutation[12]individual2 = RandomPermutation[12]CutPosition = 3 ;CutLength = 4 ;CutSequence = Take[Drop[individual1, CutPosition], CutLength]SonOne = individual2;Do[ If[MemberQ[SonOne, CutSequence[[i]]], SonOne = Delete[SonOne, Position[SonOne, CutSequence[[i]]]]], {i, 1, CutLength}];SonOneSonOne = RotateLeft[SonOne, 1]Do[SonOne = Insert[SonOne, Reverse[CutSequence][[i]], CutPosition + 1], {i, 1, CutLength}]SonOneQuestion Two:How can I change points properties (such as Size and Color) for the plotbelow? The PlotStyle Option does not work for this LabeledListPlot<< Graphics`Graphics`listcities = {{1, 5}, {4, 6}, {7, 5}, {5, 4}, {9, 4}, {2, 3}, {4, 2}, {6, 2}, {1, 1}, {5, 1}, {3, 0}, {9, 0}};LabeledListPlot[listcities, Axes -> None, Frame -> True, DisplayFunction -> $DisplayFunction]Question Three: Why the Goto statement below is not working?q = 2;Label[start];q = 3;Label[begin];Print[q];q += 1; If[q < 6, Goto[begin], Goto[start]] ==== I would appreciate help with these problems:1. I'm plotting several thousand points, which I can doeither with something like this (this is a test):w = Table[Point[{Random[], Random[]}], {i, 1, 4096}];x = Table[Point[{Random[], Random[]}], {i, 1, 4096}];y = Table[Point[{Random[], Random[]}], {i, 1, 4096}];z = Table[Point[{Random[], Random[]}], {i, 1, 4096}];dw = Graphics[{PointSize[0.01], RGBColor[ 1, 0, 0], w}];dx = Graphics[{PointSize[0.01], RGBColor[.8, .8, .8], x}];dy = Graphics[{PointSize[0.01], RGBColor[ 0, .5, .9], y}];dz = Graphics[{PointSize[0.01], RGBColor[.8, .8, 0], z}];Show[dw, dx, dy, dz, AspectRatio -> Automatic, PlotRange -> {{0, 1}, {0, 1}}, Axes -> Automatic, Frame -> True, Background -> GrayLevel[.026],This gives me dots in 4 colors for distinguishing differentkinds of points in my real application. This works fine butneeds the Point structure. Or, I can do (this is for onekind of point),t = Table[{Random[], Random[]}, {i, 1, 1024}];ListPlot[t, AspectRatio -> Automatic, Axes -> Automatic, Frame -> True, Background -> GrayLevel[.026] ];which seems simpler and may fit into the rest of the programmore easily.1. How do I get the RGBColor Rule or the equivalent intothe latter? The RGBColor[] call is not a rule.2. In the latter case I also want to plot 4 types of points.How do I get ListPlot to put down 4 plots superimposed?Or can't I?3. In either case, I need to make the whole plot area abouttwice as big. That is, it now occupies about a 4 square. Tosee details better in my real plot, and because with 16k pointsthe small plot just looks almost like a solid blur, I want tomake it more like 8 square, or as big as will fit the screen(without changing the plot range or anything else). Theremust be a scale factor somewhere. ==== Steve,You could try something like this:Needs[Graphics`Colors`]Clear[t];Do[t[i] = Table[{Random[], Random[]}, {i, 1, 1024}], {i, 4}];Show[Graphics[ {PointSize[0.005], RoyalBlue, Point /@ t[1], OrangeRed, Point /@ t[2], SpringGreen, Point /@ t[3], CadmiumLemon, Point /@ t[4]}], AspectRatio -> Automatic, Frame -> True, PlotRegion -> {{0.02, 0.96}, {0, 1}}, Background -> IvoryBlack, ImageSize -> 700];The overall size of the plot can be controlled with the ImageSize option.ListPlot is more a hindrance than a help - throw it in the ash can. Just MapPoint onto the lists of point coordinates. Give the color before each set ofpoints. I adjusted the PlotRegion to obtain some black margin on all sidesof the frame.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/dy = Graphics[{PointSize[0.01], RGBColor[ 0, .5, .9], y}];dz = Graphics[{PointSize[0.01], RGBColor[.8, .8, 0], z}];Show[dw, dx, dy, dz, AspectRatio -> Automatic, PlotRange -> {{0, 1}, {0, 1}}, Axes -> Automatic, Frame -> True, Background -> GrayLevel[.026],This gives me dots in 4 colors for distinguishing differentkinds of points in my real application. This works fine butneeds the Point structure. Or, I can do (this is for onekind of point),t = Table[{Random[], Random[]}, {i, 1, 1024}];ListPlot[t, AspectRatio -> Automatic, Axes -> Automatic, Frame -> True, Background -> GrayLevel[.026] ];which seems simpler and may fit into the rest of the programmore easily.1. How do I get the RGBColor Rule or the equivalent intothe latter? The RGBColor[] call is not a rule.2. In the latter case I also want to plot 4 types of points.How do I get ListPlot to put down 4 plots superimposed?Or can't I?3. In either case, I need to make the whole plot area abouttwice as big. That is, it now occupies about a 4 square. Tosee details better in my real plot, and because with 16k pointsthe small plot just looks almost like a solid blur, I want tomake it more like 8 square, or as big as will fit the screen(without changing the plot range or anything else). Theremust be a scale factor somewhere. ==== Bobby,Your ODE is different from both mine and Borut's. You do however get the same as mine with your approach, if you differentiate the total energy rather than the Lagrangian. KE = Simplify[(x'[t]^2 + D[f[x[t]], t]^2)/2]; PE = g*f[x[t]]; totalE = KE + PE; treat = D[totalE, t] == 0 x''[t] - (x''[t] /. First[Solve[treat, x''[t]]]//Apart) == 0Borut's ODE differs only in his factor of 2 in the first-order term. I suspect that might have been a typo... Borut?By the way, some nice animations of mechanical systems (some based on the same sort of approach) can be seen here: http://www.math.armstrong.edu/faculty/hollis/DEmovies/-- Selwyn> The two of you derived slightly different ODE's. I think Selwyn's is> correct, but I only had one physics course, 30 years ago.> Here's a notebook expression showing how Selwyn's approach can be used> to derive the ODE for y[t] = f[x[t]], with arbitrary f. It shows that> solution in a form that is easily compared with Borut's ODE, and then it> shows my own solution (same as Borut's, by a slightly simpler method).> Bobby Treat KE = Simplify[(x'[t]^2 + D[f[x[t]], t]^2)/2]; > PE = g*f[x[t]]; > L = KE - PE; > treat = D[L, t] == 0 ==== I've modified Selwyn's solution to make it more general. In particular,the height can be specified (up to about 35 meters). The differentialequation is solved for t=0 to 5 first. The quarter-period is computedby finding a zero; then the differential equation is solved again fort=0 to the quarter-period, and the solution is extended using reßectionand periodicity. This yields a higher-precision solution. Then I graphthe solution, with a stepsize equal to period/40, from t=0 to Ôperiod',labeling each frame with the values of t, x[t], and y[t]. Using a stepsize that divides period/4 guarantees the lowest point is reached ON aframe when appropriate.Here's the solution as a notebook expression:Notebook[{Cell[CellGroupData[{Cell[Borut L's solution:, Subsubtitle],Cell[TextData[StyleBox[Having noticed your statement ... BEYOND MY MEANS I thing you aren't yetnfamiliar with Lagrangian formalism. It's quite easy to derive a generalnequation of motion for a point mass, subjected to gravity and to moving on ancurve f = y(x) (i.e. f = Cosh[#]&).nn1) I'll leave re-deriving equation to you, here is what I've got (just copynpaste it).:, FontFamily->Courier New, FontSize->10, CharacterEncoding->WindowsANSI]], Text],Cell[BoxData[ RowBox[{selwyn, =, RowBox[{First, [, RowBox[{ RowBox[{ RowBox[{ RowBox[{x, ''}], [, t, ]}], /., RowBox[{Solve, [, RowBox[{diffeq, ,, RowBox[{ RowBox[{x, ''}], [, t, ]}]}], ]}]}], //, Simplify}], ]}]}]], Input],Cell[BoxData[ RowBox[{borut, =, RowBox[{First, [, RowBox[{ RowBox[{ RowBox[{x, ''}], [, t, ]}], /., RowBox[{Solve, [, RowBox[{ RowBox[{getEq, [, Cosh, ]}], ,, RowBox[{ RowBox[{x, ''}], [, t, ]}]}], ]}]}], ]}]}]], Input],Cell[BoxData[ RowBox[{ RowBox[{getEq, [, f_, ]}], :=, [IndentingNewLine], RowBox[{Simplify, [, RowBox[{ RowBox[{ RowBox[{ RowBox[{x, ''}], [, t, ]}], +, RowBox[{ SuperscriptBox[ RowBox[{ RowBox[{x, '}], [, t, ]}], 2], , FractionBox[ RowBox[{2, , RowBox[{ RowBox[{f, '}], [, RowBox[{x, [, t, ]}], ]}], , RowBox[{ RowBox[{f, ''}], [, RowBox[{x, [, t, ]}], ]}]}], RowBox[{1, +, SuperscriptBox[ RowBox[{ RowBox[{f, '}], [, RowBox[{x, [, t, ]}], ]}], 2]}]]}], +, FractionBox[ RowBox[{g, , RowBox[{ RowBox[{f, '}], [, RowBox[{x, [, t, ]}], ]}]}], RowBox[{1, +, SuperscriptBox[ RowBox[{ RowBox[{f, '}], [, RowBox[{x, [, t, ]}], ]}], 2]}]]}],==, 0}], ]}]}]], Input],Cell[TextData[{ StyleBox[2) Next, you integrate it .:, FontFamily->Courier New, FontSize->10, CharacterEncoding->WindowsANSI], }], Text],Cell[BoxData[ RowBox[{ RowBox[{getSol, [, RowBox[{f_, ,, RowBox[{h0_, ?, Positive}], ,, RowBox[{x0_, ?, Positive}]}], ]}], :=, RowBox[{Module, [, RowBox[{ RowBox[{{, tStop, }}], ,, [IndentingNewLine], RowBox[{First, @, RowBox[{NDSolve, [, [IndentingNewLine], RowBox[{ RowBox[{{, RowBox[{ RowBox[{getEq, [, f, ]}], ,, RowBox[{ RowBox[{x, [, 0, ]}], [Equal], h0}], ,, RowBox[{ RowBox[{ RowBox[{x, '}], [, 0, ]}], [Equal], 0}]}], }}], ,, [IndentingNewLine], x, ,, [IndentingNewLine], RowBox[{{, RowBox[{t, ,, 0, ,, 10}], }}], ,, [IndentingNewLine], RowBox[{MaxStepSize, [Rule], RowBox[{1, /, 100}]}], ,, RowBox[{StoppingTest, [RuleDelayed], RowBox[{If, [, RowBox[{ RowBox[{h0, <, 0}], ,, RowBox[{x, >, 0}], ,, RowBox[{x, <, 0}]}], ]}]}]}], [IndentingNewLine], ]}]}]}], [IndentingNewLine], ]}]}]], Input],Cell[<3) Here follows animation code, specially for linear versus cosh case, apply my initial conditions (below)>, Text],Cell[BoxData[ RowBox[{ RowBox[{makeDuo, [, RowBox[{f_, ,, g_, ,, h0_}], ]}], :=, RowBox[{Module, [, RowBox[{ RowBox[{{, RowBox[{ RowBox[{solf, =, RowBox[{getSol, [, RowBox[{f, ,, h0}], ]}]}], ,, RowBox[{solg, =, RowBox[{getSol, [, RowBox[{g, ,, h0}], ]}]}], ,, tf, ,, tg, ,, maxT, ,, minT}], }}], ,, [IndentingNewLine], RowBox[{ RowBox[{tf, =, RowBox[{solf, [, RowBox[{[, RowBox[{ 1, ,, 2, ,, 1, ,, 1, ,, 2}], ]}], ]}]}], ;, [IndentingNewLine], RowBox[{tg, =, RowBox[{solg, [, RowBox[{[, RowBox[{ 1, ,, 2, ,, 1, ,, 1, ,, 2}], ]}], ]}]}], ;, [IndentingNewLine], RowBox[{maxT, =, RowBox[{Max, [, RowBox[{{, RowBox[{tf, ,, tg}], }}], ]}]}], ;, [IndentingNewLine], RowBox[{minT, =, RowBox[{Min, [, RowBox[{{, RowBox[{tf, ,, tg}], }}], ]}]}], ;, [IndentingNewLine], RowBox[{Do, [, RowBox[{ RowBox[{Plot, [, RowBox[{ RowBox[{{, RowBox[{ RowBox[{f, @, x}], ,, RowBox[{g, @, x}]}], }}], ,, RowBox[{{, RowBox[{x, ,, 0, ,, RowBox[{ArcCosh, @, h0}]}], }}], ,, RowBox[{AspectRatio, [Rule], Automatic}], ,, RowBox[{Frame, [Rule], True}], ,, RowBox[{Axes, [Rule], False}], ,, RowBox[{Epilog, [Rule], RowBox[{{, RowBox[{ RowBox[{ AbsolutePointSize, [, 10, ]}], ,, RowBox[{Hue, [, 0, ]}], ,, RowBox[{Point, [, RowBox[{ RowBox[{{, RowBox[{ RowBox[{x, [, t, ]}], ,, RowBox[{f, @, RowBox[{x, [, t, ]}]}]}], }}], /., solf}], ]}], ,, RowBox[{Hue, [, .6, ]}], ,, RowBox[{Point, [, RowBox[{ RowBox[{{, RowBox[{ RowBox[{x, [, t, ]}], ,, RowBox[{g, @, RowBox[{x, [, t, ]}]}]}], }}], /., solg}], ]}]}], }}]}]}], ]}], ,, RowBox[{{, RowBox[{t, ,, 0, ,, minT, ,, minT}], }}]}], ]}]}]}], ]}]}]], Input],Cell[TextData[{ StyleBox[4) My initial conditions. In my opinion, you weren't true on this. Saying nSTARTING FROM THE SAME HEIGHT is not enough - you should specify x asnwell, thus specifing starting POINT and not just height y., FontFamily->Courier New, FontSize->10, CharacterEncoding->WindowsANSI], }], Text],Cell[BoxData[{ RowBox[{makeDuo, [, RowBox[{ RowBox[{ RowBox[{ RowBox[{Cosh, [, 1., ]}], , #}], &}], ,, RowBox[{ RowBox[{Cosh, [, #, ]}], &}], ,, 23}], ]}], [IndentingNewLine], RowBox[{SelectionMove, [, RowBox[{ RowBox[{EvaluationNotebook, [, ]}], ,, All, ,, GeneratedCell}], ]}], n, RowBox[{ FrontEndTokenExecute, [, , ]}], n, RowBox[{ FrontEndTokenExecute, [, , ]}]}], Input]}, Open ]]},ScreenRectangle->{{0, 1024}, {0, 711}},WindowSize->{815, 569},WindowMargins->{{0, Automatic}, {Automatic, -1}},ShowSelection->True]Bobby Treat-----Original Message-----and the equation of motion is diffeq = Simplify[ D[D[L, x'[t]], t] ] == Simplify[ D[L, x[t]] ]Now solve and animate ... xx[t_] = x[t]/. First[ NDSolve[{diffeq, x[0] == -1, x'[0] == 0}, x[t], {t, 0, 5}]] curve = Plot[Cosh[x], {x, -1, 1}] Do[ Show[curve, Graphics[Disk[{xx[t], Cosh[xx[t]]}, 0.025]], PlotRange -> {{-1.2, 1.2}, {0.9, 1.65}}, AspectRatio -> Automatic, Axes->None], {t, 0, 5, 0.1}]----Selwyn Hollis> Dear Colleagues,> I intend to make an animation in which > ball A rolls down on an inclined plane from the left whilst> ball B - starting from the same height - rolls down Cosh[t]'s pathfrom the> right.> x-axis is time t, y-axis is height h.> Ball A is fine; ball B - which should arrive at h=0 before A - isbeyond my> means.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> ==== Try this:<< Graphics`Colors`n = 4096;data = {w, x, y, z} = Array[Random[] &, {4, n, 2}];g@{a_, b_} := ListPlot[a, PlotStyle -> {PointSize[0.005], b}, DisplayFunction -> Identity,Show[g /@ Transpose[{data, {Red, Blue, Yellow, White}}], PlotRange -> {{0, 1}, {0, 1}}, Axes -> Automatic, Frame -> True, DisplayFunction -> $DisplayFunction, Background -> GrayLevel[.026], ImageSize -> 500];Bobby Treat-----Original Message-----dx = Graphics[{PointSize[0.01], RGBColor[.8, .8, .8], x}];dy = Graphics[{PointSize[0.01], RGBColor[ 0, .5, .9], y}];dz = Graphics[{PointSize[0.01], RGBColor[.8, .8, 0], z}];Show[dw, dx, dy, dz, AspectRatio -> Automatic, PlotRange -> {{0, 1}, {0, 1}}, Axes -> Automatic, Frame -> True, Background -> GrayLevel[.026],This gives me dots in 4 colors for distinguishing differentkinds of points in my real application. This works fine butneeds the Point structure. Or, I can do (this is for onekind of point),t = Table[{Random[], Random[]}, {i, 1, 1024}];ListPlot[t, AspectRatio -> Automatic, Axes -> Automatic, Frame -> True, Background -> GrayLevel[.026] ];which seems simpler and may fit into the rest of the programmore easily.1. How do I get the RGBColor Rule or the equivalent intothe latter? The RGBColor[] call is not a rule.2. In the latter case I also want to plot 4 types of points.How do I get ListPlot to put down 4 plots superimposed?Or can't I?3. In either case, I need to make the whole plot area abouttwice as big. That is, it now occupies about a 4 square. Tosee details better in my real plot, and because with 16k pointsthe small plot just looks almost like a solid blur, I want tomake it more like 8 square, or as big as will fit the screen(without changing the plot range or anything else). Theremust be a scale factor somewhere. ==== The same command worked for me, insofar as creating the plot isconcerned.I did get an error message opening the file, saying that Adobe Acrobatwas Unable to find or create the font ÔMathematica1Mono-Bold'. Somecharacters may not display or print correctly. The plot looks fine,though.Bobby Treat-----Original Message-----Export[c:docscell4.gif, Cell[ <<...(copied cell data from Edit->CopyAs->Cell Expression)...> ]]When I change the filename to a .PDF and evaluate the cell, the programdisplays ÔRunning...' for a second and gives the ÔOut[n] =c:docscell4.pdf' message as if a file was created, but no file is created anywhere withanyname that I could find with Start->Find->[All files and folders createdinthe previous day].Is there a limitation to PDF exporting I don't know about? Do I need toupgrade to 4.2? Am I doing something wrong with the Export[] command? DoIneed a faster computer? A patch? Something else? ==== I'm trying to export a table from Mathematica 4.0 to Notepad, for examples,or something similar, but it's impossible for me! It always exports the cellwith all its rubbish, or an image (if I use Word).How can I export just plain _numbers_?ThanxFip ==== You can useExport[file.dat, expr] where expr is a two-dimensional array.Or for more ßexibility study the following.Assuming data has n rows and 2 columns.file = OpenWrite[file.dat];Map[ ( (* the N may be redundant haven't tested the code w/o it *) str = ToString[PaddedForm[N[#[[1]]],{10,6}]]<> <> ToString[PaddedForm[N[#[[2]]],{10,6}]]; (* make numbers e notation: the *^ notation has given me fits, so I just put this in as a precaution *) str = StringReplace[str, *^ -> e]; WriteString[file, str, n] )&, data];Close[file]Hope this helps,Lawrence> I'm trying to export a table from Mathematica 4.0 to Notepad, for examples,> or something similar, but it's impossible for me! It always exports the cell> with all its rubbish, or an image (if I use Word).> How can I export just plain _numbers_?> Thanx> Fip> -- Lawrence A. Walker Jr.http://www.kingshonor.com ==== > I'm trying to export a table from Mathematica 4.0 to Notepad, for examples,> or something similar, but it's impossible for me! It always exports the cell> with all its rubbish, or an image (if I use Word).> How can I export just plain _numbers_?Try with this:WriteSimpleTableForm[file_String, data_List, opts___] := Module[{str}, str = OpenWrite[file]; WriteString[str, ToString[TableForm[data, opts]]]; Close[str]]This is my small solution for this problem.marek ==== I put the following in .../.../KeyEventTranslations.tr:Item[KeyEvent[<,Modifiers-> {Control}], FrontEndExecute[{ FrontEnd`NotebookWrite[FrontEnd`SelectedNotebook[], [LeftDoubleBracket][RightDoubleBracket],After]}]],to make it easy to insert the double-brackets. This works fine, but Iwant the cursor to be placed between the brackets not after them. Howcan this be done?Gru137 Peter--=--=--=--=--=--=--=--=--=--=--=--=--=--= http://home.t-online.de/home/phbrf~~~ ==== >I've been using Mathematica 4.1 on Win98 as a word processor for>math-related documents, but often people that need to see the documents>don't have Mathematica, and for whatever reason on my computer the HTML>saves don't work at all. I'd like to export to PDF format. I can export>images to PDF format no problem using, for example>Export[c:docsplot3.pdf, Plot[Sin[x],{x,-2Pi,2Pi}]],>and I can export cells correctly to GIF, JPEG, and WMF formats (probably>more, those are the only ones I tested) using, for example>Export[c:docscell4.gif, Cell[ <<...(copied cell data from Edit->Copy>As->Cell Expression)...> ]]>When I change the filename to a .PDF and evaluate the cell, the program>displays ÔRunning...' for a second and gives the ÔOut[n] = c:docscell4.pdf>' message as if a file was created, but no file is created anywhere with any>name that I could find with Start->Find->[All files and folders created in>the previous day].>Is there a limitation to PDF exporting I don't know about? Do I need to>upgrade to 4.2? Am I doing something wrong with the Export[] command? Do I>need a faster computer? A patch? Something else?This is a limitation of PDF export. The mechanism for exporting GIF, JPEG, and other raster formats is completely different than the system used for PDF export. Because of this PDF export is limited to graphics expressions. Cells and Notebooks cannot be converted via Export.However, there is a way to generate PDFs using the frontend. Seehttp://support.wolfram.com/mathematica/graphics/export/ convertpdfghostscript.htmlhttp://support.wolfram.com/ mathematica/graphics/export/convertpdfdistiller.html-Dale= === Dear Mathematica friends,how can Mathematica 4.1 be used to combine sound and graphics?In particular, I would like to prepare a demo video aboutdifferential equations. I can Plot the solution and I canPlay the solution. How to combine the 2 results into a single file that can be played back using xine or DivX,like ordinary video can?Best wishes from Prague-- Pavel PokornyMath Dept, Prague Institute of Chemical Technologyhttp://staffold.vscht.cz/mat/Pavel.Pokorny ==== Hoi,it depends a bit what you want to do.E.g.: If you want to write applications for clients then go with thatsystems your clients use (probably Windows).If you just use it for yourself, for development: use what you like more.anymore, likethere were in 3.0 times.The copy and paste problems are gone if you switch off the KDE Klipper.On the other hand, there are a few OS- (or better Window-manager-specific)1.: you cannot rotate text (i.e., FrameLabel settings will look weird (vertically arranged horizontal letters), you have to use RotateLabel -> False generally, or play with the Fonts settings such that horizontal tick marks still fit)2.: If you work with bigger graphics in notebooks I suggest Windows (or MacOS X) sinceleast on my XFree 4.2 installation with a not too modern graphics card). Also I find resizing of larger notebooks somewhat slow.3.: If you like to work with keyboard shortcuts: Windows is better, clearly.4.: There are a couple of Font issues which are better on Windows since not all fontsengels, nederlands, duits of spaans)Rolf MertigMertig ConsultingBerlin ==== I'd like to add a JLink animation of the rolling ball based on Selwyn'ssolution: UseFrontEndForRendering = False;createWindow[] := Module[{frame}, frame = JavaNew[com.wolfram.jlink.MathFrame, Doppler Animation]; drawArea = JavaNew[com.wolfram.jlink.MathCanvas]; drawArea@setUsesFE[UseFrontEndForRendering]; drawArea@setSize[800, 600];JavaBlock[frame@setLayout[JavaNew[ java.awt.BorderLayout]]; frame@add[drawArea, ReturnAsJavaObject[BorderLayout`CENTER]]; frame@pack[]; frame@setSize[800, 600]; frame@setLocation[200, 200]; JavaShow[frame]];frame] drawRoll[t_] := Show[curve, Graphics[{RGBColor[1, 0, 0], Disk[{xx[t], Cosh[xx[t]]}, 0.05]}], PlotRange -> {{-1.2, 1.2}, {0.9, 1.65}}, AspectRatio -> Automatic, Axes -> None, DisplayFunction -> Identity]; times = Range[0, 5, .05]; LoadJavaClass[java.lang.Thread]; AnimationPlot[t_List] := JavaBlock[Block[{frm},frm = createWindow[];Map[(obj = drawRoll[#]; drawArea@setMathCommand[obj];drawArea@repaintNow[]; Thread@sleep[5];) &, t]]]AnimationPlot[times]jerry blimbaum panama city, ß-----Original Message-----and the equation of motion is diffeq = Simplify[ D[D[L, x'[t]], t] ] == Simplify[ D[L, x[t]] ]Now solve and animate ... xx[t_] = x[t]/. First[ NDSolve[{diffeq, x[0] == -1, x'[0] == 0}, x[t], {t, 0, 5}]] curve = Plot[Cosh[x], {x, -1, 1}] Do[ Show[curve, Graphics[Disk[{xx[t], Cosh[xx[t]]}, 0.025]], PlotRange -> {{-1.2, 1.2}, {0.9, 1.65}}, AspectRatio -> Automatic, Axes->None], {t, 0, 5, 0.1}]----Selwyn Hollis> Dear Colleagues,> I intend to make an animation in which > ball A rolls down on an inclined plane from the left whilst> ball B - starting from the same height - rolls down Cosh[t]'s path fromthe> right.> x-axis is time t, y-axis is height h.> Ball A is fine; ball B - which should arrive at h=0 before A - is beyondmy> means.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> ==== I noticed that n Mathematica 3.0 , IntegerDigits function is giving wrong results. This problem is not found in Mathematica 4.1. Whether any body else has also noted any such problem.For example IntegerDigits[10^18+7] will give the digits 0 and 7 , omitting 1.Shyam Sunder Gupta ==== You're right; I wasn't exporting a Cell. I misunderstood his post andsuccessfully executed this:Export[c:docsplot3.pdf, Plot[Sin[x],{x,-2Pi,2Pi}]]but that was working for him, already.Sorry for the confusion.Bobby-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== > w = Table[Point[{Random[], Random[]}], {i, 1, 4096}];> x = Table[Point[{Random[], Random[]}], {i, 1, 4096}];> y = Table[Point[{Random[], Random[]}], {i, 1, 4096}];> z = Table[Point[{Random[], Random[]}], {i, 1, 4096}];> 2. In the latter case I also want to plot 4 types of points.> How do I get ListPlot to put down 4 plots superimposed?> Or can't I?You can, but you have to do it via Graphics`MulitpleListPlot`. Load the requisite packages Needs[Graphics`Colors`]Needs[Graphics`MultipleListPlot `]Define cols = {Black, Red, Green, Blue}; pnts = {PlotSymbol[Triangle], PlotSymbol[Box], PlotSymbol[Diamond],PlotSymbol[Star]};Thengrf = MultipleListPlot[w, x, y, z, PlotStyle->cols, SymbolShape->pnts, SymbolsStyle->cols ];Documentation shows how to incorporate legends and to define other symbols.Dave. ==== ====================================== Dr. David Annetts EM Modelling Analyst Australia David.Annetts@csiro.au ==== ================================== ==== =====>Dear Group,> It is a pleasure write to you again. I have three questions to ask.> Alexandre Costa>Question Two:>How can I change points properties (such as Size and Color) for the plot>below? The PlotStyle Option does not work for this LabeledListPlot><< Graphics`Graphics`>listcities = {{1, 5}, {4, 6}, {7, 5}, {5, 4}, {9, 4}, {2, 3}, {4, 2},>{6, 2}, {1, 1}, {5, 1}, {3, 0}, {9, 0}};>LabeledListPlot[listcities, Axes -> None, Frame -> True,> DisplayFunction -> $DisplayFunction]It's not a built-in feature of LabeledListPlot, so you'll have to do it manually.gr=LabeledListPlot[listcities, Axes -> None, Frame -> True, DisplayFunction -> $DisplayFunction]You can add graphics directives to the points and text with a replacement rule.Show[gr/.x_Point|x_Text->{RGBColor[1,0,0],x}]>Question Three: Why the Goto statement below is not working?>q = 2;>Label[start];>q = 3;>Label[begin];>Print[q];>q += 1; If[q < 6, Goto[begin], Goto[start]]First, let me say that noone should ever use Goto. You should always use a loop or some other process instead. With that said . . .When you type semicolon separated input into the frontend, each command is treated as a separate input (as if they were in separate input cells). So the Labels and the Gotos are evaluated separately and there's no way to jump from one to the other. Instead, the commands need to be within the same expression. This can be done by wrapping the command in a CompoundExpression( q = 2; Label[start]; q = 3; Label[begin]; Print[q]; q += 1; If[q < 6, Goto[begin], Goto[start]])Or some other expression, like a Module.------------------------------------------------------ --------Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== >I would appreciate help with these problems:>1. I'm plotting several thousand points, which I can do>either with something like this (this is a test):>w = Table[Point[{Random[], Random[]}], {i, 1, 4096}];>x = Table[Point[{Random[], Random[]}], {i, 1, 4096}];>y = Table[Point[{Random[], Random[]}], {i, 1, 4096}];>z = Table[Point[{Random[], Random[]}], {i, 1, 4096}];>dw = Graphics[{PointSize[0.01], RGBColor[ 1, 0, 0], w}];>dx = Graphics[{PointSize[0.01], RGBColor[.8, .8, .8], x}];>dy = Graphics[{PointSize[0.01], RGBColor[ 0, .5, .9], y}];>dz = Graphics[{PointSize[0.01], RGBColor[.8, .8, 0], z}];>Show[dw, dx, dy, dz, AspectRatio -> Automatic,> PlotRange -> {{0, 1}, {0, 1}},> Axes -> Automatic,> Frame -> True,> Background -> GrayLevel[.026],>This gives me dots in 4 colors for distinguishing different>kinds of points in my real application. This works fine but>needs the Point structure. Or, I can do (this is for one>kind of point),>t = Table[{Random[], Random[]}, {i, 1, 1024}];>ListPlot[t, AspectRatio -> Automatic,> Axes -> Automatic,> Frame -> True,> Background -> GrayLevel[.026]> ];>which seems simpler and may fit into the rest of the program>more easily.>1. How do I get the RGBColor Rule or the equivalent into>the latter? The RGBColor[] call is not a rule.>2. In the latter case I also want to plot 4 types of points.>How do I get ListPlot to put down 4 plots superimposed?>Or can't I?>3. In either case, I need to make the whole plot area about>twice as big. That is, it now occupies about a 4 square. To>see details better in my real plot, and because with 16k points>the small plot just looks almost like a solid blur, I want to>make it more like 8 square, or as big as will fit the screen>(without changing the plot range or anything else). There>must be a scale factor somewhere.You can plot more than one list with MultipleListPlot.<Automatic,Axes->Automatic,Frame->True, SymbolShape->{ColorPoint[RGBColor[1,0,0]], ColorPoint[RGBColor[.8, .8, .8]],ColorPoint[RGBColor[ 0, .5, .9]], ColorPoint[RGBColor[.8, .8, 0]]}, SymbolStyle->PointSize[0.01],Background->GrayLevel[.026]]---- ---------------------------------------------------------- Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== >I have to use a graphics of mathematica with powerpoint for a little>Y-axes and line of function) are bold or more visible: how can I do>that?Use the PlotStyle and AxesStyle options as inPlot[x,{x,0,5},PlotStyle->Thickness[0.015],AxesStyle-> Thickness[0.015]] ==== Dear Mathematica friends,how can Mathematica 4.1 be used to combine sound and graphics?In particular, I would like to prepare a demo video aboutdifferential equations. I can Plot the solution and I canPlay the solution. How to combine the 2 results into a single file that can be played back using xine or DivX,like ordinary video can?Best wishes from Prague-- Pavel PokornyMath Dept, Prague Institute of Chemical Technologyhttp://staffold.vscht.cz/mat/Pavel.Pokorny ==== I'd like to add a JLink animation of the rolling ball based on Selwyn'ssolution: UseFrontEndForRendering = False;createWindow[] := Module[{frame}, frame = JavaNew[com.wolfram.jlink.MathFrame, Doppler Animation]; drawArea = JavaNew[com.wolfram.jlink.MathCanvas]; drawArea@setUsesFE[UseFrontEndForRendering]; drawArea@setSize[800, 600];JavaBlock[frame@setLayout[JavaNew[ java.awt.BorderLayout]]; frame@add[drawArea, ReturnAsJavaObject[BorderLayout`CENTER]]; frame@pack[]; frame@setSize[800, 600]; frame@setLocation[200, 200]; JavaShow[frame]];frame] drawRoll[t_] := Show[curve, Graphics[{RGBColor[1, 0, 0], Disk[{xx[t], Cosh[xx[t]]}, 0.05]}], PlotRange -> {{-1.2, 1.2}, {0.9, 1.65}}, AspectRatio -> Automatic, Axes -> None, DisplayFunction -> Identity]; times = Range[0, 5, .05]; LoadJavaClass[java.lang.Thread]; AnimationPlot[t_List] := JavaBlock[Block[{frm},frm = createWindow[];Map[(obj = drawRoll[#]; drawArea@setMathCommand[obj];drawArea@repaintNow[]; Thread@sleep[5];) &, t]]]AnimationPlot[times]jerry blimbaum panama city, ß-----Original Message-----and the equation of motion is diffeq = Simplify[ D[D[L, x'[t]], t] ] == Simplify[ D[L, x[t]] ]Now solve and animate ... xx[t_] = x[t]/. First[ NDSolve[{diffeq, x[0] == -1, x'[0] == 0}, x[t], {t, 0, 5}]] curve = Plot[Cosh[x], {x, -1, 1}] Do[ Show[curve, Graphics[Disk[{xx[t], Cosh[xx[t]]}, 0.025]], PlotRange -> {{-1.2, 1.2}, {0.9, 1.65}}, AspectRatio -> Automatic, Axes->None], {t, 0, 5, 0.1}]----Selwyn Hollis> Dear Colleagues,> I intend to make an animation in which > ball A rolls down on an inclined plane from the left whilst> ball B - starting from the same height - rolls down Cosh[t]'s path fromthe> right.> x-axis is time t, y-axis is height h.> Ball A is fine; ball B - which should arrive at h=0 before A - is beyondmy> means.> Matthias Bode> Sal. Oppenheim jr. & Cie. KGaA> Koenigsberger Strasse 29> D-60487 Frankfurt am Main> GERMANY> Mobile: +49(0)172 6 74 95 77> Internet: http://www.oppenheim.de> ==== >I've been using Mathematica 4.1 on Win98 as a word processor for>math-related documents, but often people that need to see the documents>don't have Mathematica, and for whatever reason on my computer the HTML>saves don't work at all. I'd like to export to PDF format. I can export>images to PDF format no problem using, for example>Export[c:docsplot3.pdf, Plot[Sin[x],{x,-2Pi,2Pi}]],>and I can export cells correctly to GIF, JPEG, and WMF formats (probably>more, those are the only ones I tested) using, for example>Export[c:docscell4.gif, Cell[ <<...(copied cell data from Edit->Copy>As->Cell Expression)...> ]]>When I change the filename to a .PDF and evaluate the cell, the program>displays ÔRunning...' for a second and gives the ÔOut[n] = c:docscell4.pdf>' message as if a file was created, but no file is created anywhere with any>name that I could find with Start->Find->[All files and folders created in>the previous day].>Is there a limitation to PDF exporting I don't know about? Do I need to>upgrade to 4.2? Am I doing something wrong with the Export[] command? Do I>need a faster computer? A patch? Something else?This is a limitation of PDF export. The mechanism for exporting GIF, JPEG, and other raster formats is completely different than the system used for PDF export. Because of this PDF export is limited to graphics expressions. Cells and Notebooks cannot be converted via Export.However, there is a way to generate PDFs using the frontend. Seehttp://support.wolfram.com/mathematica/graphics/export/ convertpdfghostscript.htmlhttp://support.wolfram.com/ mathematica/graphics/export/convertpdfdistiller.html-Dale= ===I noticed that n Mathematica 3.0 , IntegerDigits function is giving wrong results. This problem is not found in Mathematica 4.1. Whether any body else has also noted any such problem.For example IntegerDigits[10^18+7] will give the digits 0 and 7 , omitting 1.Shyam Sunder Gupta ==== You're right; I wasn't exporting a Cell. I misunderstood his post andsuccessfully executed this:Export[c:docsplot3.pdf, Plot[Sin[x],{x,-2Pi,2Pi}]]but that was working for him, already.Sorry for the confusion.Bobby-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== > w = Table[Point[{Random[], Random[]}], {i, 1, 4096}];> x = Table[Point[{Random[], Random[]}], {i, 1, 4096}];> y = Table[Point[{Random[], Random[]}], {i, 1, 4096}];> z = Table[Point[{Random[], Random[]}], {i, 1, 4096}];> 2. In the latter case I also want to plot 4 types of points.> How do I get ListPlot to put down 4 plots superimposed?> Or can't I?You can, but you have to do it via Graphics`MulitpleListPlot`. Load the requisite packages Needs[Graphics`Colors`]Needs[Graphics`MultipleListPlot `]Define cols = {Black, Red, Green, Blue}; pnts = {PlotSymbol[Triangle], PlotSymbol[Box], PlotSymbol[Diamond],PlotSymbol[Star]};Thengrf = MultipleListPlot[w, x, y, z, PlotStyle->cols, SymbolShape->pnts, SymbolsStyle->cols ];Documentation shows how to incorporate legends and to define other symbols.Dave. ==== ====================================== Dr. David Annetts EM Modelling Analyst Australia David.Annetts@csiro.au ==== ================================== ==== =====>Dear Group,> It is a pleasure write to you again. I have three questions to ask.> Alexandre Costa>Question Two:>How can I change points properties (such as Size and Color) for the plot>below? The PlotStyle Option does not work for this LabeledListPlot><< Graphics`Graphics`>listcities = {{1, 5}, {4, 6}, {7, 5}, {5, 4}, {9, 4}, {2, 3}, {4, 2},>{6, 2}, {1, 1}, {5, 1}, {3, 0}, {9, 0}};>LabeledListPlot[listcities, Axes -> None, Frame -> True,> DisplayFunction -> $DisplayFunction]It's not a built-in feature of LabeledListPlot, so you'll have to do it manually.gr=LabeledListPlot[listcities, Axes -> None, Frame -> True, DisplayFunction -> $DisplayFunction]You can add graphics directives to the points and text with a replacement rule.Show[gr/.x_Point|x_Text->{RGBColor[1,0,0],x}]>Question Three: Why the Goto statement below is not working?>q = 2;>Label[start];>q = 3;>Label[begin];>Print[q];>q += 1; If[q < 6, Goto[begin], Goto[start]]First, let me say that noone should ever use Goto. You should always use a loop or some other process instead. With that said . . .When you type semicolon separated input into the frontend, each command is treated as a separate input (as if they were in separate input cells). So the Labels and the Gotos are evaluated separately and there's no way to jump from one to the other. Instead, the commands need to be within the same expression. This can be done by wrapping the command in a CompoundExpression( q = 2; Label[start]; q = 3; Label[begin]; Print[q]; q += 1; If[q < 6, Goto[begin], Goto[start]])Or some other expression, like a Module.------------------------------------------------------ --------Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== Mario:Use, for example, PlotStyle->Thickness[0.01] for plot andAxesStyle->Thickness[0.01].Other way is using AbsoluteThickness instead of Thickness.See The Mathematica Book: Section 2.9.3.Germ.87n Buitrago A.----- Original Message -----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== Mario:Use, for example, PlotStyle->Thickness[0.01] for plot andAxesStyle->Thickness[0.01].Other way is using AbsoluteThickness instead of Thickness.See The Mathematica Book: Section 2.9.3.Germ.87n Buitrago A.----- Original Message -----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== I have to use a graphics of mathematica with powerpoint for a littleY-axes and line of function) are bold or more visible: how can I dothat? ==== >I have to use a graphics of mathematica with powerpoint for a little>Y-axes and line of function) are bold or more visible: how can I do>that?Use the PlotStyle and AxesStyle options as inPlot[x,{x,0,5},PlotStyle->Thickness[0.015],AxesStyle-> Thickness[0.015]] ==== >I would appreciate help with these problems:>1. I'm plotting several thousand points, which I can do>either with something like this (this is a test):>w = Table[Point[{Random[], Random[]}], {i, 1, 4096}];>x = Table[Point[{Random[], Random[]}], {i, 1, 4096}];>y = Table[Point[{Random[], Random[]}], {i, 1, 4096}];>z = Table[Point[{Random[], Random[]}], {i, 1, 4096}];>dw = Graphics[{PointSize[0.01], RGBColor[ 1, 0, 0], w}];>dx = Graphics[{PointSize[0.01], RGBColor[.8, .8, .8], x}];>dy = Graphics[{PointSize[0.01], RGBColor[ 0, .5, .9], y}];>dz = Graphics[{PointSize[0.01], RGBColor[.8, .8, 0], z}];>Show[dw, dx, dy, dz, AspectRatio -> Automatic,> PlotRange -> {{0, 1}, {0, 1}},> Axes -> Automatic,> Frame -> True,> Background -> GrayLevel[.026],>This gives me dots in 4 colors for distinguishing different>kinds of points in my real application. This works fine but>needs the Point structure. Or, I can do (this is for one>kind of point),>t = Table[{Random[], Random[]}, {i, 1, 1024}];>ListPlot[t, AspectRatio -> Automatic,> Axes -> Automatic,> Frame -> True,> Background -> GrayLevel[.026]> ];>which seems simpler and may fit into the rest of the program>more easily.>1. How do I get the RGBColor Rule or the equivalent into>the latter? The RGBColor[] call is not a rule.>2. In the latter case I also want to plot 4 types of points.>How do I get ListPlot to put down 4 plots superimposed?>Or can't I?>3. In either case, I need to make the whole plot area about>twice as big. That is, it now occupies about a 4 square. To>see details better in my real plot, and because with 16k points>the small plot just looks almost like a solid blur, I want to>make it more like 8 square, or as big as will fit the screen>(without changing the plot range or anything else). There>must be a scale factor somewhere.You can plot more than one list with MultipleListPlot.<Automatic,Axes->Automatic,Frame->True, SymbolShape->{ColorPoint[RGBColor[1,0,0]], ColorPoint[RGBColor[.8, .8, .8]],ColorPoint[RGBColor[ 0, .5, .9]], ColorPoint[RGBColor[.8, .8, 0]]}, SymbolStyle->PointSize[0.01],Background->GrayLevel[.026]]---- ---------------------------------------------------------- Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== For the life of me I am not sure why the following is not working in my v. 4.2:ru[a]=a->x;f[x_]:=(a+b) /. ru[a];Why do I getf[c] = b+xand notf[c] = b+c?What gives?Lawrence-- Lawrence A. Walker Jr.http://www.kingshonor.comReply-To: kuska@informatik.uni-leipzig.de ==== because te right hand side of SetDelayed[] is notevaluate.Tryru[a] = a -> x;f[x_] := (a + b) /. ru[a];f1[x_] := Evaluate[(a + b) /. ru[a]];and f1[] does what you expectIn[]:={f[c], f1[c]}Out[]={b + x, b + c} Jens> For the life of me I am not sure why the following is not working in my> v. 4.2:> ru[a]=a->x;> f[x_]:=(a+b) /. ru[a];> Why do I get> f[c] = b+x> and not> f[c] = b+c?> What gives?> Lawrence> --> Lawrence A. Walker Jr.> http://www.kingshonor.com ==== Sir,we are having FreeBSD Server,In this we connected a heavy duty Dot matrix printer locally.While on taking outputs, username and file name are printing as BANNER TYPE.Instead of this, we would like to take the print out as username and file name should be printed as header through out the file.if u are having any scripts like that please send usRaj MohanSystem Administrator Reply-To: jmt@dxdydz.net ==== I would like to add :Some characters, at least with a french keyboard, are not directly available typed through their Mathematica entities : [EHat] , [OHat], etc.While this is not an issue when programming, it can become quite painful when writing documentation.> Hoi,> it depends a bit what you want to do.> E.g.: If you want to write applications for clients then go with that> systems your clients use (probably Windows).> If you just use it for yourself, for development: use what you like more.> anymore, like> there were in 3.0 times.> The copy and paste problems are gone if you switch off the KDE Klipper.> On the other hand, there are a few OS- (or better Window-manager-specific)> 1.: you cannot rotate text (i.e., FrameLabel settings will look weird > (vertically arranged> horizontal letters), you have to use> RotateLabel -> False generally, or play with the Fonts settings > such that horizontal> tick marks still fit)> 2.: If you work with bigger graphics in notebooks I suggest Windows (or > MacOS X) since> least on my XFree 4.2> installation with a not too modern graphics card).> Also I find resizing of larger notebooks somewhat slow.> 3.: If you like to work with keyboard shortcuts: Windows is better, clearly.> 4.: There are a couple of Font issues which are better on Windows since > not all fonts> engels, nederlands, duits of spaans)> Rolf Mertig> Mertig Consulting> Berlin> ==== Hoi,it depends a bit what you want to do.E.g.: If you want to write applications for clients then go with thatsystems your clients use (probably Windows).If you just use it for yourself, for development: use what you like more.anymore, likethere were in 3.0 times.The copy and paste problems are gone if you switch off the KDE Klipper.On the other hand, there are a few OS- (or better Window-manager-specific)1.: you cannot rotate text (i.e., FrameLabel settings will look weird (vertically arranged horizontal letters), you have to use RotateLabel -> False generally, or play with the Fonts settings such that horizontal tick marks still fit)2.: If you work with bigger graphics in notebooks I suggest Windows (or MacOS X) sinceleast on my XFree 4.2 installation with a not too modern graphics card). Also I find resizing of larger notebooks somewhat slow.3.: If you like to work with keyboard shortcuts: Windows is better, clearly.4.: There are a couple of Font issues which are better on Windows since not all fontsengels, nederlands, duits of spaans)Rolf MertigMertig ConsultingBerlin ==== I am considering the following integralW[m_,n_]:=Integrate[BesselJ[m, x]*BesselJ[n, x], {x, 0, Infinity}]where m,n are reals >=0. With Mathematica 4.1 I obtain:If[Re[m+n]>-1, -Cos[(m-n)Pi/2]/(2 Pi)*(2 EulerGamma + Log[4] + PolyGamma[0, 1/2(1 + m - n)] + PolyGamma[0, 1/2(1 - m + n)] + 2PolyGamma[0, 1/2(1 + m + n)])and so using this answer as a definition I obtain W[0,0]=-(2 EulerGamma + Log[4] + 4 PolyGamma[0, 1/2])/(2 Pi)=0.84564I suspect that these integrals are divergent (*). So I try the numericalintegration:NW[m_,n_]:=NIntegrate[BesselJ[m, x]*BesselJ[n, x], {x, 0, Infinity}]so thatNW[0,0]=11.167Othe couples areW[1,0]=Indeterminate NW[1,0]=0.597973W[0,1.5]=0.537095 NW[0,1.5]=-5.79306W[1,1]=0.20902 NW[1,1]=17.5425W[2,0]=0.427599 NW[2,0]=-6.83464W[2,1]=Indeterminate NW[2,1]=4.69013(*) The integral is a particular case of the Weber-Schafheitlin integrals(Abramowitz, 11.4.33).Any explanation about the analytical expression will be gratefully accepteed.Roberto.Roberto BrambillaCESIVia Rubattino 5420134 Milanotel +39.02.2125.5875fax +39.02.2125.5492rlbrambilla@cesi.it ==== WRI Tech Support sent me an answer to the font problem. Copying theType 1 (not True Type) fonts made the error go away:A workaround for the font-related issue that you encountered, is toplacecopies of the Mathematica Type 1 fonts fromC:Program FilesWolframResearchMathematica4.2SystemFiles FontsType1intoC:Program FilesAdobeAcrobat 5.0ResourceFontSincerely,George KambouroglouTechnical SupportWolfram Research, Inc.support@wolfram.com-----Original Message-----I've been using Mathematica 4.1 on Win98 as a word processor formath-related documents, but often people that need to see the documentsdon't have Mathematica, and for whatever reason on my computer the HTMLsaves don't work at all. I'd like to export to PDF format. I can exportimages to PDF format no problem using, for exampleExport[c:docsplot3.pdf, Plot[Sin[x],{x,-2Pi,2Pi}]],and I can export cells correctly to GIF, JPEG, and WMF formats (probablymore, those are the only ones I tested) using, for exampleExport[c:docscell4.gif, Cell[ <<...(copied cell data from Edit->CopyAs->Cell Expression)...> ]]When I change the filename to a .PDF and evaluate the cell, the programdisplays ÔRunning...' for a second and gives the ÔOut[n] =c:docscell4.pdf' message as if a file was created, but no file is created anywhere withanyname that I could find with Start->Find->[All files and folders createdinthe previous day].Is there a limitation to PDF exporting I don't know about? Do I need toupgrade to 4.2? Am I doing something wrong with the Export[] command? DoIneed a faster computer? A patch? Something else? ==== SSG> I noticed that n Mathematica 3.0 , IntegerDigits function isSSG> giving wrong results. This problem is not found in MathematicaSSG> 4.1. Whether anybody else has also noted any such problem.SSG> For example IntegerDigits[10^18+7] will give the digits 0SSG> and 7, omitting 1.Having made totally 4,000,000 attemtps,I was not able to reproduce your example.What version of Mathematica do you use?...................................................... 4.2 for Microsoft Windows (February 28, 2002)4.1 for Microsoft Windows (November 2, 2000)4.0 for Microsoft Windows (April 21, 1999)Microsoft Windows 3.0 (April 25, 1997)Windows 387 2.2 (April 9, 1993)IntegerDigits[10^18 + 7]IntegerDigits[10^18 + 7]IntegerDigits[10^18 + 7]IntegerDigits[10^18 + 7]IntegerDigits[10^18 + 7]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7}{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7}{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7}{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7}{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7}....................... ...............................Best wishes,Vladimir BondarenkoMathematical DirectorSymbolic Testing GroupWeb : http://www.CAS-testing.org/ http://maple.bug-list.org/VER2/ (under tuning) http://maple.bug-list.org/VER3/ (under tuning) http://maple.bug-list.org/VER1/ (under tuning)Voice : (380)-652-447325 Mon-Fri 9 a.m.-6 p.m.Mail : 76 Zalesskaya Str, Simferopol, Crimea, Ukraine ==== Just tested it with no errors, version 3.0John A. Velling-----Original Message----- ==== I would appreciate any info on these issues.1. I have a symbol slback. I was gettingtag times lback protected (or something) errors.(A typically uninformative error message.)I suspected there was a separation between the sand l, and they looked too far apart, but when Ispaced past them with the arrow keys, there didnot appear to be anything like a space in between.I retyped the symbol and all was ok. This hashappened before. What's going on ???2. I'm using Raster to plot data pointsin a 256x256 array. Two problems: First,regardless of the ImageSize setting (I need thedisplay as big as possible), the individual data cellswhen examined closely at 300% vary in size byalmost 2:1. This makes detailed inspection of thedata values difficult. Surely there is some settingof something which would make each data cell anexact number of screen pixels? Second, I'musingShow[ Graphics[Raster[ rescol, ColorFunction -> Hue]], AspectRatio -> Automatic, ImageSize -> 700];but the Hues don't allow enough easily distinguishableshades to visually recognize even 6 data values easily.(I'm slightly colorblind.) It would be nice to have blackand white available for two of the data values, but Huedoes not allow this. I don't understand what thedocumentation says about RasterArray.3. I wanted to get this raster image into a formatwhere I could dissect it with Photoshop or equivalent.After much fooling around, I found that I can export theselection as an html file, read it into Navigator, do File>Edit Page, which brings up Netscape Composer, rightclick the image which, allows saving it as a GIF, whichI can finally work on with a photo editor. Maybethere is an easier way, or maybe this description willhelp someone with the same need.Reply-To: kuska@informatik.uni-leipzig.de ==== > I would appreciate any info on these issues.> 1. I have a symbol slback. I was getting> tag times lback protected (or something) errors.> (A typically uninformative error message.)> I suspected there was a separation between the s> and l, and they looked too far apart, but when I> spaced past them with the arrow keys, there did> not appear to be anything like a space in between.> I retyped the symbol and all was ok. This has> happened before. What's going on ???As long as you don't send us the *exact* input we can'thelp you. You should also send the mathematica versionyou are using. But typical this error comes from a equationa*b==cwhere the user has mixed up Equal[] and Set[]> 2. I'm using Raster to plot data points> in a 256x256 array. Two problems: First,> regardless of the ImageSize setting (I need the> display as big as possible), the individual data cells> when examined closely at 300% vary in size by> almost 2:1. This makes detailed inspection of the> data values difficult. Surely there is some setting> of something which would make each data cell an> exact number of screen pixels? Second, I'm> using> Show[ Graphics[Raster[ rescol,> ColorFunction -> Hue]],> AspectRatio -> Automatic,> ImageSize -> 700];> but the Hues don't allow enough easily distinguishable> shades to visually recognize even 6 data values easily.> (I'm slightly colorblind.) The most humans can distinguish 160 gray levels>It would be nice to have black> and white available for two of the data values, but Hue> does not allow this.And something like:mycolor[i_] := Switch[Round[i], 0, RGBColor[0, 0, 0], 1, RGBColor[1, 0, 0], 2, RGBColor[1, 1, 0], 3, RGBColor[0, 1, 0], 4, RGBColor[0, 1, 1], 5, RGBColor[0, 0, 1], _, RGBColor[1, 1, 1]]Show[Graphics[ Raster[Table[Random[Integer, {0, 6}], {16}, {16}], ColorFunction -> mycolor, ColorFunctionScaling -> False]]]does not help ?> I don't understand what the> documentation says about RasterArray.If you can't be more specific *what* you not understandwe can not help you.> 3. I wanted to get this raster image into a format> where I could dissect it with Photoshop or equivalent.And ? waht does Export[] do ? it write the expressionin a desired format, TIFF, PNG, PPM are all losslesscompressed bitmap formats, that Mathematica can exportand that can be imported into PhotoShop> After much fooling around, I found that I can export the> selection as an html file, read it into Navigator, do File>> Edit Page, which brings up Netscape Composer, right> click the image which, allows saving it as a GIF, which> I can finally work on with a photo editor. Maybe> there is an easier way, or maybe this description will> help someone with the same need.May be that thhis description help someone who can't readthe fancy documation on Import[] and Export[]. Jens ==== [snip]> 2. I'm using Raster to plot data points> in a 256x256 array. Two problems: First,> regardless of the ImageSize setting (I need the> display as big as possible), the individual data cells> when examined closely at 300% vary in size by> almost 2:1. This makes detailed inspection of the> data values difficult. Surely there is some setting> of something which would make each data cell an> exact number of screen pixels?GRAY: (No answer received.) I can get around thisby making the images bigger but this is not a completesolution.> Second, I'm using> Show[ Graphics[Raster[ rescol,> ColorFunction -> Hue]],> AspectRatio -> Automatic,> ImageSize -> 700];> but the Hues don't allow enough easily distinguishable> shades to visually recognize even 6 data values easily.> (I'm slightly colorblind.)> The most humans can distinguish 160 gray levels>It would be nice to have black> and white available for two of the data values, but Hue> does not allow this.> And something like:> mycolor[i_] :=> Switch[Round[i],> 0, RGBColor[0, 0, 0],> 1, RGBColor[1, 0, 0],> 2, RGBColor[1, 1, 0],> 3, RGBColor[0, 1, 0],> 4, RGBColor[0, 1, 1],> 5, RGBColor[0, 0, 1],> _, RGBColor[1, 1, 1]]> Show[Graphics[> Raster[Table[Random[Integer, {0, 6}], {16}, {16}],> ColorFunction -> mycolor, ColorFunctionScaling -> False]]]GRAY: Sounds good. I'll try it. Interesting that the help does notcontain this in a form I could easily find.> 3. I wanted to get this raster image into a format> where I could dissect it with Photoshop or equivalent.> And ? what does Export[] do ? it write the expression> in a desired format, TIFF, PNG, PPM are all lossless> compressed bitmap formats, that Mathematica can export> and that can be imported into PhotoShopGRAY: I foolishly thought something like Export would be underthe File menu.> After much fooling around, I found that I can export the> selection as an html file, read it into Navigator, do File>> Edit Page, which brings up Netscape Composer, right> click the image which, allows saving it as a GIF, which> I can finally work on with a photo editor. Maybe> there is an easier way, or maybe this description will> help someone with the same need.GRAY: I just found that simply Copying the image and Pastingit into Paint Shop Pro (or no doubt lots of other bitmapeditors) works. For outputting a Raster noninteractively, there is Export,but I haven't tried it yet. Jens, thank you for your reply. ==== explain to me why I get this behavior and what I can do to fix it.When I run Mathematica in X with the graphical user interface by typing mathematica,I can run the following commands and get the expected output, namely a plot with the plot label in a big font. However, when I run the math command and get the text interface and run the same code I do not get the label in a big font. cc = Plot[Sin[x], {x, 0, Pi}, {PlotLabel -> StyleForm[Label, FontSize -> 60]}]Export[test.eps, cc, eps]I believe that this is due to the different method in which the math and mathematica commands setup fonts. Is there anyway to get the behavior that I want? As a side note when I use the old syntax of cc=Plot[Sin[x],{x,0,Pi},{PlotLabel->FontForm[Label,{ Courier,60}]}]I get it to work. However, I would like not to use this syntax as ithas several limitations.Any suggestions would be greatly appreciated. ==== I have a dual processor Dell computer...unfortunately, I can only access oneof the processors...I purchased Wolfram's parallel processing toolkit which, because of the very poor documentation, never did me any good...i'm toldthat another option for accessing the dual processors is to write C codeetc...I can't C program, so i'm wondering this...duzz anyone have C code,both source and binary, that they could give me for accomplishing this....inaddition, i would like to access this C code with JavaNativeCode, etc...cananyone help me with this? thanks...jerry blimbaum NSWC panama city, ßReply-To: kuska@informatik.uni-leipzig.de ==== you can have a parallel implicit Runge-Kutta methodprogrammed in C *and* with the Parallel Computing Toolkitboth on the base of the MathLink protocol.Since I have a SGI I can't help you with the binaryfor a Dell what ever computer but if you like the source ...You can also have a native MPI source of the code but you willneed a running MPI for your computer. Jens> I have a dual processor Dell computer...unfortunately, I can only access one> of the processors...I purchased Wolfram's parallel processing toolkit which> , because of the very poor documentation, never did me any good...i'm told> that another option for accessing the dual processors is to write C code> etc...I can't C program, so i'm wondering this...duzz anyone have C code,> both source and binary, that they could give me for accomplishing this....in> addition, i would like to access this C code with JavaNativeCode, etc...can> anyone help me with this? thanks...> jerry blimbaum NSWC panama city, ß ==== I have a set of inequalities that I solve with InequalitySolve. But thenit gives a complete set of solutions, but not in the way I would like itto be! :-) For example, the simple following calculation will give:In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6 >= -1}; InequalitySolve[ineq,{y4,y6,y5}]Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6the result is good, but I would like it to be in the simpler butequivalent form y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6How can I tell InequalitySolve to do that? It is simple for this example,but for a large set of simple inequalities InequalitySolve gives lines andlines of results instead of a simple result.Vincent Bouchard ==== f[c] == (c+b)/.ru[c] == (c+b)/.c->x == x+b == b+xBobby Treat-----Original Message-----f[c] = b+c?What gives?Lawrence-- Lawrence A. Walker Jr.http://www.kingshonor.com ==== Sorry; disregard my earlier answer. ru[c] isn't defined, so thatobviously wasn't the correct sequence of events. Here's the right one:f[c] == HoldPattern[(a+b)/.ru[a]]/.x->c == (a+b)/.ru[a] == (a+b)/.a->x == x + b == b + xThe substitution of c for x occurs before the rule ru[a] is evaluated,so there's no x in the expression to replace. Instead, there's an Ôa'to replace with x.If the other sequence had been correct, you have no rule for evaluatingru[c], so it would have remained just that -- ru[c]. When the kerneltried to apply it as a rule to (a+b), there would have been an error.That didn't happen, so that wasn't the sequence of events.Bobby Treat-----Original Message-----f[c] = b+c?What gives?Lawrence-- Lawrence A. Walker Jr.http://www.kingshonor.com ==== You really should read about the difference between := (SetDelayed) and = (Set).When you enter your definitionf[x_]:=(a+b) /. ru[a]the right hand side is not evaluated. So next when you evaluate f[c] you get(a+b)/.ru[a] and only now ru[a] is evaluated, thus giving you (a+b)/.a->x which is b+xThere are several ways to get what you want. One is to use = instead of :=, another to force evaluation of the right hand side withf[x_]:=Evaluate[(a+b) /. ru[a]]yet another to insert the actual rule in the definition of f:f[x_]:=(a+b) /. a->xAndrzej KozlowskiToyama International UniversityJAPANOn Wednesday, September 25, 2002, at 02:50 PM, Lawrence A. Walker Jr. > For the life of me I am not sure why the following is not working in my> v. 4.2:> ru[a]=a->x;> f[x_]:=(a+b) /. ru[a];> Why do I get> f[c] = b+x> and not> f[c] = b+c?> What gives?> Lawrence> -- > Lawrence A. Walker Jr.> http://www.kingshonor.com ==== Well,I have written the following notebook with MathematicaIn[78]:=a=Sqrt[4*Pi/Sqrt[3]]In[79]:=fcom[k_, mu_]:=(( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*(1-Exp[-I*k*(a-mu)])/ (I*k)+ Exp[-I*mu*2* Pi/a]*((1-Exp[-I*(k+2*Pi/a)*(a-mu)])/(I*(k+2*Pi/a))+( 1-Exp[-I*(k-2*Pi/a)*(a-mu)])/(I*(k-2*Pi/a)))+ Exp[-I*mu*4* Pi/a]*((1-Exp[-I*(k+4*Pi/a)*(a-mu)])/(I*(k+4*Pi/a))+( 1-Exp[-I*(k+2*Pi/a)*(a-mu)])/(I*(k+2*Pi/a)))+( 1-Exp[-I*(k-2*Pi/a)*(a-mu)])/(I*(k-2*Pi/a))+( 1-Exp[-I*(k-4*Pi/a)*(a-mu)])/(I*(k-4*Pi/a)))/(3*a)In[80]:= f0[k_,mu_]:=((1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*(a-mu)+ Exp[-I*mu*2* Pi/a]*((1-Exp[-I*2*Pi/a*(a-mu)])/(I*(2*Pi/a))+( 1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a)))+ Exp[-I*mu*4* Pi/a]*((1-Exp[-I*(4*Pi/a)*(a-mu)])/(I*(4*Pi/a))+( 1-Exp[-I*(2*Pi/a)*(a-mu)])/(I*(2*Pi/a)))+( 1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a))+( 1-Exp[-I*(-4*Pi/a)*(a-mu)])/(I*(-4*Pi/a)))/(3*a)In[81]:=fp1 [k_,mu_]:=(( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*(1-Exp[-I*2*Pi/a*( a-mu)])/( I*2*Pi/a)+ Exp[-I*mu*2*Pi/a]*((1-Exp[-I*(4*Pi/a)*(a-mu)])/(I*(4*Pi/a))+ (a-mu))+ Exp[-I*mu*4* Pi/a]*((1-Exp[-I*(6*Pi/a)*(a-mu)])/(I*(6*Pi/a))+( 1-Exp[-I*(4*Pi/a)*(a-mu)])/(I*(4*Pi/a)))+( a-mu)+(1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a)))/(3*a)In[82 ]:=fm1[k_,mu_]:=(( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*( 1-Exp[I*2*Pi/a*(a-mu)])/(-I*2*Pi/a)+ Exp[-I*mu*2*Pi/a]*((a-mu)+(1-Exp[-I*(-4*Pi/a)*(a-mu)])/(I*(- 4*Pi/a)))+ Exp[-I*mu*4*Pi/a]*((1-Exp[-I*(2*Pi/a)*(a-mu)])/(I*(2*Pi/a))+ (a-mu))+( 1-Exp[-I*(-4*Pi/a)*(a-mu)])/(I*(-4*Pi/a))+( 1-Exp[-I*(-6*Pi/a)*(a-mu)])/(I*(-6*Pi/a)))/(3*a)In[83]:=fp2 [k_,mu_]:=(( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*(1-Exp[-I*4*Pi/a*( a-mu)])/( I*4*Pi/a)+ Exp[-I*mu*2* Pi/a]*((1-Exp[-I*(6*Pi/a)*(a-mu)])/(I*(6*Pi/a))+(1-Exp[-I*( 2*Pi/a)*(a-mu)])/(I*(2*Pi/a)))+ Exp[-I*mu*4* Pi/a]*((1-Exp[-I*(8*Pi/a)*(a-mu)])/(I*(8*Pi/a))+( 1-Exp[-I*(6*Pi/a)*(a-mu)])/(I*(6*Pi/a)))+( 1-Exp[-I*(2*Pi/a)*(a-mu)])/(I*(2*Pi/a))+(a-mu))/(3*a)In[84]: =fm2[k_,mu_]:=(( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*( 1-Exp[I*4*Pi/a*(a-mu)])/(-I*4*Pi/a)+ Exp[-I*mu*2* Pi/a]*((1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a))+( 1-Exp[-I*(-6*Pi/a)*(a-mu)])/(I*(-6*Pi/a)))+ Exp[-I*mu*4* Pi/a]*((a-mu)+(1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a)))+( 1-Exp[-I*(-6*Pi/a)*(a-mu)])/(I*(-6*Pi/a))+( 1-Exp[-I*(-8*Pi/a)*(a-mu)])/(I*(-8*Pi/a)))/(3*a)In[85]:=Lp[ 0|N[0],mu_]:=f0[0,mu]In[86]:=Lp[2*Pi/a|N[2*Pi/a],mu_]:=fp1[ 2*Pi/a,mu]In[87]:=Lp[-2*Pi/a|-N[2*Pi/a],mu_]:=fm1[2*Pi/a,mu ]In[88]:=Lp[4*Pi/a|N[4*Pi/a],mu_]:=fp2[4*Pi/a,mu]In[89]:= Lp[-4*Pi/a|-N[4*Pi/a],mu_]:=fm2[-4*Pi/a,mu]In[90]:=Lp[k_,mu _]:=fcom[k,mu]In[91]:=Ll[k_,mu_]:=0/;mu>=aIn[92]:=Ll[k_, mu_]:=0/;mu<=-aIn[93]:=Ll[k_,mu_]:=Lp[k,mu]/;0<=muMonteCarlo,MaxPoints->100000000,Compiled->False]but this is not enough to ensure convergence of the integration. Notice that I have inserted some points in the integration path in order to avoid problems with numerical divergences which Mathematica detects in fcom[k,mu] (but these divergences do not really exist, analitically) Does somebody has a smart suggestion to perform this computation?Fabio ==== In a presentation I wish to use Plot to generate a sequence of frames andthen animate them. The problem is that the audience sees the animationtwice. Once when the frames are being generated and then again after I haveclosed the group and double clicked on the top graphic. However, the firstshowing during generation is enough (but uncontrolled). Is it possible to tidy up the generation of the graphic so that it becomesthe animation?I have tried the followingDo[Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}},ImageSize -> 400]; SelectionMove[EvaluationNotebook[], All, GeneratedCell];FrontEndExecute[{FrontEnd`SelectionAnimate[ 0.1]}]; FrontEndExecute[{FrontEndToken[Clear]}], {t, 0, 15, 0.1}]This works but the cell dividing line ßashes on and off spoiling theanimation and if there is anything in the cell below this jumps up and down.Is there a proper way of doing this?Hugh Goyder ==== I need to program the following recursion scheme for time seriesforecasting (The Innovation Algorithm).I will write it in pseudo-Mathematica notation. K is the given m x mautocovariance (numerical) matrix of the processv[0] = K[[1,1]];H[n,n-k] = (v[k])^(-1) (K[[n+1,k+1]] - Sum[(H[k,k-j] H[n,n-j] v[j]),{j,0,k-}]) for k=0,1,...,n-1v[n] = K[[n+1,n+1]] -Sum[(H[n,n-j])^2 v[j],{j,0,n-1}]The scheme should be solved in the order v[0], H[1,1], v[1], H[2,2],H[2,1], v[2], H[3,3], H[3,2], H[3,1], ...I have already tried to program it in a straght-forward way, but ashave no experience with recursive functions with two variables, itdoesn't seem to work properly and is also very slow. Any help would beRobertReply-To: murray@math.umass.edu ==== I don't understand the problem. Say I enter the 2D form for the reciprocal of the square root of a^2 + b^2, but I enter it in Standard Form (i.e., using the Control key with / to form the fraction, and the Control key with 2 to get the square root symbol).If then I click anywhere within the subexpression inside the square root, then with 2 to three clicks the entire expression under the square root will be highlighted. I can then do a copy-and-paste to put that into any cell, in the usual way -- with keyboard key combinations, right-click context menu, or Mathematica Edit menu.Isn't that GUI enough?Would you REALLY want to be able to DRAG the highlighted expression to a new place? Think of how much of a mess this could cause through inadvertent movement of the mouse after highlighting some subexpression. In fact, I hate Microsoft Word's doing just that!>>I'm a poor physicist trying to figure out how to sort out the>physical from the non-physical solutions to a problem. To do>>that, I need to be able to look at an expression and pick out a>>subexpression, the part under the radical.> GRAY:> This points up the need, which I've been aware of for years, to be> able to select any part of an expression and drag it to a new line for> further processing. Mathematica and the other CAS I'm familiar with are still> pretty much stuck with a command line interface. They need a true> GUI with extensive interaction.> When I can see on the screen exactly what I want to do, why> should I have to type a bunch of stuff in to access what I want?> Maybe we'll see this in version 5? 6? Never?> -- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375 ==== > I'm a poor physicist trying to figure out how to sort out the> physical from the non-physical solutions to a problem. To do> that, I need to be able to look at an expression and pick out a> subexpression, the part under the radical.GRAY: This points up the need, which I've been aware of for years, to beable to select any part of an expression and drag it to a new line forfurther processing. Mathematica and the other CAS I'm familiar with are stillpretty much stuck with a command line interface. They need a trueGUI with extensive interaction. When I can see on the screen exactly what I want to do, whyshould I have to type a bunch of stuff in to access what I want? Maybe we'll see this in version 5? 6? Never?Reply-To: murray@math.umass.edu ==== I get the same result in 4.2 (under Windows). Not sure why. But you could try this modification: PlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur]; Pause[dur], {i, Length[L]}]Then PlaySeq[{224, 256, 384}, 3]seems to work as expected, prolonging the notes before the last one to their full expected duration.> PlayTone[F_, dur_] := Play[Sin[2*Pi*F*t], {t, 0, dur}]> allows me to play a sine wave of frequency F and duration dur> PlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur], {i, Length[L]}]> should allow me to play a sequence of tones> with a given list of frequencies L> and all the same duration dur.> It does not work at least in 4.1> all tones but the last one are much shorter than dur.> any help?> -- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375 ==== this is almost the solution.but it creates some artificial rests.when the sounds are created, there is some silence between the different notes.when after creation one clicks the play sound icon of the group with all the sounds, these rests disappear.is there a way of Play creating ghte waves, but NOT playing them,and then, doubleclicking the sound icon,hearing the sound without rests immediately?> I get the same result in 4.2 (under Windows). Not sure why. But you > could try this modification:> PlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur];> Pause[dur], {i, Length[L]}]> Then> PlaySeq[{224, 256, 384}, 3]> seems to work as expected, prolonging the notes before the last one to > their full expected duration.>>PlayTone[F_, dur_] := Play[Sin[2*Pi*F*t], {t, 0, dur}]>>allows me to play a sine wave of frequency F and duration dur>PlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur], {i, Length[L]}]>should allow me to play a sequence of tones>>with a given list of frequencies L>>and all the same duration dur.>It does not work at least in 4.1>all tones but the last one are much shorter than dur.>any help? > -- --Erich Neuwirth, Computer Supported Didactics Working GroupVisit our SunSITE at http://sunsite.univie.ac.at ==== PlayTone[F_, dur_] := Play[Sin[2*Pi*F*t], {t, 0, dur}]allows me to play a sine wave of frequency F and duration durPlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur], {i, Length[L]}]should allow me to play a sequence of toneswith a given list of frequencies Land all the same duration dur.It does not work at least in 4.1all tones but the last one are much shorter than dur.any help?-- --Erich Neuwirth, Computer Supported Didactics Working GroupVisit our SunSITE at http://sunsite.univie.ac.at ==== using Set (=) instead of SetDelayed (:=) in f[x_]:=(a+b) /. ru[a]; will give you what you desire.Matthias Bode.-----Ursprí.b9ngliche Nachricht-----Gesendet: Mittwoch, 25. September 2002 07:51An: mathgroup@smc.vnet.netBetreff: Strange ReplaceAll behaviorFor the life of me I am not sure why the following is not working in my v. 4.2:ru[a]=a->x;f[x_]:=(a+b) /. ru[a];Why do I getf[c] = b+xand notf[c] = b+c?What gives?Lawrence-- Lawrence A. Walker Jr.http://www.kingshonor.com ==== If you want to do it with the mouse, it's not that difficult. I clickwithin the part I want and double-click until the part is selected.(Each double-click expands the selection by one level of nesting.) Thenpush Ctrl-C, click where you want to put the result, and push Ctrl-V.Does that help any?Bobby-----Original Message-----able to select any part of an expression and drag it to a new line forfurther processing. Mathematica and the other CAS I'm familiar with arestillpretty much stuck with a command line interface. They need a trueGUI with extensive interaction. When I can see on the screen exactly what I want to do, whyshould I have to type a bunch of stuff in to access what I want? Maybe we'll see this in version 5? 6? Never? ==== I met a critical problem for running Mathematica 4.1 on MacOS X 10.2.(OSX native version) I hope such a problem is suitable to be posted tothis ML.What happens is the following. When Mathematica 4.1 installed in HDDis started, a window quickly appears saying that A serious error has occured while Mathematica was starting up. Mathematica will probably not function properly until this problem is resolved. ... The Mathematica fonts are not properly installed in your system. Without these fonts, typeset mathematical expressions cannot be displayed properly.This message is correct. If I chose Continue Anyway, mathematicalexpressins are totally broken.What is strange is that when I start Mathematica 4.1 by double clickingMathematica in CDROM, it works without any problem. Further more,Once Mathematica 4.1 is correctly started in this way, I can restart Mathematicadirectly from double clicking Mathematica in HDD, which is the installed one.Once CDROM is ejected, the error appears again.It is clearly font related problem but I do not know how to solve. If someoneknow how to manage, please let me know.-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-I met a critical problem for running Mathematica 4.1 on MacOS X 10.2.(OSX native version) I hope such a problem is suitable to be posted tothis ML.What happens is the following. When Mathematica 4.1installed in HDDis started, a window quickly appears saying that A serious error has occured while Mathematica was starting up. Mathematica will probably not function properly until this problem is resolved. ... The Mathematica fonts are not properly installed in your system. Without these fonts, typeset mathematical expressions cannot be displayed properly.This message is correct. If I chose Continue Anyway, mathematicalexpressins are totally broken.What is strange is that when I start Mathematica 4.1 by double clickingMathematica in CDROM, it works without any problem. Further more,Once Mathematica 4.1 is correctly started in this way, I can restartMathematicadirectly from double clicking Mathematica in HDD, which is theinstalled one.Once CDROM is ejected, the error appears again.It is clearly font related problem but I do not know how to solve. Ifsomeoneknow how to manage, please let me know.-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--- Apple-Mail-2-977368608-- ==== Toshinao,Try reinstalling Mathematica from the CD.---Selwyn Hollis> I met a critical problem for running Mathematica 4.1 on MacOS X 10.2.> (OSX native version) I hope such a problem is suitable to be posted to> this ML.> What happens is the following. When Mathematica 4.1 installed in HDD> is started, a window quickly appears saying that> A serious error has occured while Mathematica was starting up.> Mathematica will probably not function properly until this problem is> resolved.> ...> The Mathematica fonts are not properly installed in your system.> Without these fonts, typeset mathematical expressions cannot be> displayed properly.> This message is correct. If I chose Continue Anyway, mathematical> expressins are totally broken.> What is strange is that when I start Mathematica 4.1 by double clicking> Mathematica in CDROM, it works without any problem. Further more,> Once Mathematica 4.1 is correctly started in this way, I can restart > Mathematica> directly from double clicking Mathematica in HDD, which is the > installed one.> Once CDROM is ejected, the error appears again.> It is clearly font related problem but I do not know how to solve. If > someone> know how to manage, please let me know.> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> I met a critical problem for running Mathematica 4.1 on MacOS X 10.2.> (OSX native version) I hope such a problem is suitable to be posted to> this ML.> What happens is the following. When Mathematica 4.1installed in HDD> is started, a window quickly appears saying that> A serious error has occured while Mathematica was starting up.> Mathematica will probably not function properly until this problem is> resolved.> ...> The Mathematica fonts are not properly installed in your system.> Without these fonts, typeset mathematical expressions cannot be> displayed properly.> This message is correct. If I chose Continue Anyway, mathematical> expressins are totally broken.> What is strange is that when I start Mathematica 4.1 by double clicking> Mathematica in CDROM, it works without any problem. Further more,> Once Mathematica 4.1 is correctly started in this way, I can restart> Mathematica> directly from double clicking Mathematica in HDD, which is the> installed one.> Once CDROM is ejected, the error appears again.> It is clearly font related problem but I do not know how to solve. If> someone> know how to manage, please let me know.> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> --Apple-Mail-2-977368608--> ==== The reason why InequalitySolve returns it's answer in what sometimes turns out to be unnecessarily complicated form is that the underlying algorithm, Cylindrical Agebraic Decomposition (CAD) returns its answers in this form. Unfortunately it seems to me unlikely that a simplification of the kind you need can be can be accomplished in any general way. To see why observe the following. First of all:In[1]:=FullSimplify[x > 0 || x == 0]Out[1]=x >= 0This is fine. However:In[2]:=FullSimplify[x > 0 && x < 2 || x == 0 && x < 2]Out[2]=x == 0 || 0 < x < 2Of course what you would like is simply 0 <= x < 2. One reason why you can't get it is that while Mathematica can perform a LogicalExpand, as in:In[3]:=LogicalExpand[(x > 0 || x == 0) && x < 2]Out[3]=x == 0 && x < 2 || x > 0 && x < 2There i no LogicalFactor or anything similar that would reverse what LogicalExpand does. if there was then you could perform the sort of simplifications you need for:In[4]:=FullSimplify[(x > 0 || x == 0) && x < 2]Out[4]=0 <= x < 2However, it does not seem to me very likely that such logical factoring can be performed by a general enough algorithm (though I am no expert in this field). In any case, certainly Mathematica can't do this.I also noticed that Mathematica seems unable to show that the answer it returns to your problem is actually equivalent to your simpler one. In fact this looks like a possible bug in Mathematica. Let's first try the function ImpliesQ from the Experimental context:<< Experimental`Now Mathematica correctly gives:In[6]:=ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[6]=TrueHowever:In[7]:=ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[7]=FalseThat simply means that ImpliesQ cannot show the implication, not that it does not hold. ImpliesQ relies on CAD, as does FullSimplify. Switching to FullSimplify we see that:In[8]:=FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[8]=TruewhileIn[9]:=FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[9]=y4 >= -1 && y6 <= y5 <= 1 + y4 + y6On the other hand, taking just the individual summands of Or as hypotheses;In[10]:=FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[10]=TrueIn[11]:=FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6 ]Out[11]=TrueIn fact FullSimplify is unable to use Or in assumptions, which can be demonstrated on an abstract example:In[12]:=FullSimplify[C,(A||B)&&(C)]Out[12]=True In[13]:=FullSimplify[C,LogicalExpand[(A||B)&&(C)]]Out[13]= CThis could be fixed by modifying FullSimplify:In[14]:=Unprotect[FullSimplify];In[14]:= FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify[exp r,y]];In[15]:=Protect[FullSimplify];Now at least we get as before:In[16]:=FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[16]=Truebut also:In[17]:=FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[17]=TrueThis seems to me a possible worthwhile improvement in FullSimplify, though of course not really helpful for your problem.Andrzej KozlowskiToyama International UniversityJAPAN> I have a set of inequalities that I solve with InequalitySolve. But > then> it gives a complete set of solutions, but not in the way I would like > it> to be! :-) For example, the simple following calculation will give:> In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6 >= > -1};> InequalitySolve[ineq,{y4,y6,y5}]> Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6> the result is good, but I would like it to be in the simpler but> equivalent form> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6> How can I tell InequalitySolve to do that? It is simple for this > example,> but for a large set of simple inequalities InequalitySolve gives lines > and> lines of results instead of a simple result.> Vincent Bouchard ==== I have been trying to integrate the following : Integrate[Cosh[2 Abs[x-y]] 2 y, {y,0,1/2}, Assumptions->{Im[x]==0,x>0}] However, Mathematica chokes and simply returns the integral as it is. However, if I split up the integral into two portions, it quickly gives me an answer for the parts. Is there something implicit that I am missing in the Assumptions ?MS.-- 12:02am up 5:06, 1 user, load average: 0.54, 0.22, 0.08 ==== The modification to FullSimplify that I sent earlier works correctly only for assumptions of the form Or[a,b] (and even then not is not always what one would like). For what it's worth here is a better (but slow) version:In[1]:=Unprotect[FullSimplify];In[2]:= FullSimplify[expr_, x_ || y__] := FullSimplify[ FullSimplify[expr, x] || FullSimplify[expr, Or[y]]];In[3]:=Protect[FullSimplify];For example:In[4]:=FullSimplify[Sqrt[(x - 1)^2] + Sqrt[(x - 2)^2] + Sqrt[(x - 3)^2], x > 1 || x > 2 || x > 3]Out[4]=-1 + x + Abs[-3 + x] + Abs[-2 + x] || -3 + 2*x + Abs[-3 + x] || 3*(-2 + x)Andrzej KozlowskiToyama International UniversityJAPAN> The reason why InequalitySolve returns it's answer in what sometimes > turns out to be unnecessarily complicated form is that the underlying > algorithm, Cylindrical Agebraic Decomposition (CAD) returns its > answers in this form. Unfortunately it seems to me unlikely that a > simplification of the kind you need can be can be accomplished in any > general way. To see why observe the following. First of all:> In[1]:=> FullSimplify[x > 0 || x == 0]> Out[1]=> x >= 0> This is fine. However:> In[2]:=> FullSimplify[x > 0 && x < 2 || x == 0 && x < 2]> Out[2]=> x == 0 || 0 < x < 2> Of course what you would like is simply 0 <= x < 2. One reason why you > can't get it is that while Mathematica can perform a LogicalExpand, > as in:> In[3]:=> LogicalExpand[(x > 0 || x == 0) && x < 2]> Out[3]=> x == 0 && x < 2 || x > 0 && x < 2> There i no LogicalFactor or anything similar that would reverse what > LogicalExpand does. if there was then you could perform the sort of > simplifications you need for:> In[4]:=> FullSimplify[(x > 0 || x == 0) && x < 2]> Out[4]=> 0 <= x < 2> However, it does not seem to me very likely that such logical > factoring can be performed by a general enough algorithm (though I am > no expert in this field). In any case, certainly Mathematica can't do > this.> I also noticed that Mathematica seems unable to show that the answer > it returns to your problem is actually equivalent to your simpler one. > In fact this looks like a possible bug in Mathematica. Let's first try > the function ImpliesQ from the Experimental context:> << Experimental`> Now Mathematica correctly gives:> In[6]:=> ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 > <= 1 + y4 + y6]> Out[6]=> True> However:> In[7]:=> ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + > y4 + y6]> Out[7]=> False> That simply means that ImpliesQ cannot show the implication, not that > it does not hold. ImpliesQ relies on CAD, as does FullSimplify. > Switching to FullSimplify we see that:> In[8]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + > y4 + y6]> Out[8]=> True> while> In[9]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 > <= 1 + y4 + y6]> Out[9]=> y4 >= -1 && y6 <= y5 <= 1 + y4 + y6> On the other hand, taking just the individual summands of Or as > hypotheses;> In[10]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[10]=> True> In[11]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 ]> Out[11]=> True> In fact FullSimplify is unable to use Or in assumptions, which can be > demonstrated on an abstract example:> In[12]:=> FullSimplify[C,(A||B)&&(C)]> Out[12]=> True> In[13]:=> FullSimplify[C,LogicalExpand[(A||B)&&(C)]]> Out[13]=> C> This could be fixed by modifying FullSimplify:> In[14]:=> Unprotect[FullSimplify];> In[14]:=> FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify[ex > pr,y]];> In[15]:=> Protect[FullSimplify];> Now at least we get as before:> In[16]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + > y4 + y6]> Out[16]=> True> but also:> In[17]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 > <= 1 + y4 + y6]> Out[17]=> True> This seems to me a possible worthwhile improvement in FullSimplify, > though of course not really helpful for your problem.> Andrzej Kozlowski> Toyama International University> JAPAN> I have a set of inequalities that I solve with InequalitySolve. But > then> it gives a complete set of solutions, but not in the way I would like > it> to be! :-) For example, the simple following calculation will give: In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6 >= -1};> InequalitySolve[ineq,{y4,y6,y5}] Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6 the result is good, but I would like it to be in the simpler but> equivalent form y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6 How can I tell InequalitySolve to do that? It is simple for this > example,> but for a large set of simple inequalities InequalitySolve gives > lines and> lines of results instead of a simple result.> Vincent Bouchard ==== >-----Original Message----->Sent: Wednesday, September 25, 2002 7:51 AM>For the life of me I am not sure why the following is not >working in my >v. 4.2:>ru[a]=a->x;>f[x_]:=(a+b) /. ru[a];>Why do I get>f[c] = b+x>and not>f[c] = b+c?>What gives?>Lawrence>-- >Lawrence A. Walker Jr.>http://www.kingshonor.comLawrence, in your definition of f, x doesn't show up explicitely. So, in theevaluation sequence, when the definition for f[c] is applied, no x appearsat rhs i.e.(a + b) /. ru[a] and such c cannot be inserted. The result is the same asdirectly executingIn[11]:= (a + b) /. ru[a]Out[11]= b + xIf you don't like this, you have to make explicit the Value of ru[a] in thedefiniton of f. One way to do so is to use Set instead of SetDelayed:In[9]:= f[x_] = (a + b) /. ru[a]Out[9]= b + xIn[10]:= f[c]Out[10]= b + cThe drawback of this that not only the value of ru[a] is inserted but alsothe whole expression including ReplaceAll is evaluated. If this is notwanted, you have to insert the value of ru[a] into the unevaluated rhs atthe definition. The general means for this are function application, With orReplace:In[7]:= (g[x_] := (a + b) /. #) &[ru[a]]In[8]:= g[c]Out[8]= b + cIn[16]:= Clear[g]In[20]:=Unevaluated[g[x_] := (a + b) /. rule] /. rule -> ru[a]In[21]:= g[c]Out[21]= b + cHere we have to prevent evaluation of the defintion before our rule isinserted, this is achieved by Unevaluated.With is a bit more complicated, since the scoping rules for SetDelayed wouldnot allow the substition of an expression at rhs containing a patternvariable (the pattern variable is renamed in this case). A simple answer tothis is to also substitute the argument variable (the pattern): In[31]:= Clear[g]In[32]:=With[{rule = ru[a], arg = x_}, g[arg] := (a + b) /. rule]In[33]:= g[c]Out[33]= b + c--Hartmut Wolf ==== Hartmut,I add an explicit illustration to your ingenious solution using With.Hartmut's solution: Clear[g]; ru[a] = a -> x; With[{rule = ru[a], arg = x_}, g[arg] := a + b /. rule]; g[ c] b + cWhy is arg = x_ needed?Without it we get Clear[g]; With[{rule=ru[a]}, g[x_]:=a+b/.rule]; g [c] b+xThe reason for this shows in ?g Global`g g[x$_] := a + b /. a -> xThe x in x_ has been changed to x$ and there is no x$ on the right side.This is a general feature of scoping. Taking it further we get Clear[g]; With[{rule=ru[a]},g[x_]:=a+x/.rule]; g [c] c+x ?g Global`g g[x$_] := a + x$ /. a -> x--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198>-----Original Message----->Sent: Wednesday, September 25, 2002 7:51 AM>For the life of me I am not sure why the following is not>working in my>v. 4.2:>ru[a]=a->x;>f[x_]:=(a+b) /. ru[a];>Why do I get>f[c] = b+x>and not>f[c] = b+c?>What gives?>Lawrence>-->Lawrence A. Walker Jr.>http://www.kingshonor.com>> Lawrence,> in your definition of f, x doesn't show up explicitely. So, in the> evaluation sequence, when the definition for f[c] is applied, no x appears> at rhs i.e.> (a + b) /. ru[a] and such c cannot be inserted. The result is the same as> directly executing> In[11]:= (a + b) /. ru[a]> Out[11]= b + x> If you don't like this, you have to make explicit the Value of ru[a] inthe> definiton of f. One way to do so is to use Set instead of SetDelayed:> In[9]:= f[x_] = (a + b) /. ru[a]> Out[9]= b + x> In[10]:= f[c]> Out[10]= b + c> The drawback of this that not only the value of ru[a] is inserted but also> the whole expression including ReplaceAll is evaluated. If this is not> wanted, you have to insert the value of ru[a] into the unevaluated rhs at> the definition. The general means for this are function application, Withor> Replace:> In[7]:= (g[x_] := (a + b) /. #) &[ru[a]]> In[8]:= g[c]> Out[8]= b + c> In[16]:= Clear[g]> In[20]:=> Unevaluated[g[x_] := (a + b) /. rule] /. rule -> ru[a]> In[21]:= g[c]> Out[21]= b + c> Here we have to prevent evaluation of the defintion before our rule is> inserted, this is achieved by Unevaluated.> With is a bit more complicated, since the scoping rules for SetDelayedwould> not allow the substition of an expression at rhs containing a pattern> variable (the pattern variable is renamed in this case). A simple answerto> this is to also substitute the argument variable (the pattern):> In[31]:= Clear[g]> In[32]:=> With[{rule = ru[a], arg = x_}, g[arg] := (a + b) /. rule]> In[33]:= g[c]> Out[33]= b + c> --> Hartmut Wolf ==== TryIn[1]:=M={{1,2,3},{4,5,6},{7,8,9}};In[2]:= Export[test.csv,M,CSV];Also, avoid using names with capital initial, since these are usuallyreserved for Mathematica functions.Tomas GarzaMexico City----- Original Message -----> M={{1,2,3},{4,5,6},{7,8,9}};> TableForm[M]> 1 2 3> 4 5 6> 7 8 9> The commands like Put or Write create files with a standard Mathematica> matrix notation with braces, I get the the same result with Save As/Copy> Robert ==== I would appreciate if someone could tell me how to put my output forexample a matrix in TableForm as a space-delimited ASCII file inMathematica 3.0.for example:M={{1,2,3},{4,5,6},{7,8,9}};TableForm[M]1 2 34 5 67 8 9The commands like Put or Write create files with a standard Mathematicamatrix notation with braces, I get the the same result with Save As/CopyRobert ==== Much longer. At least 10 times as long. Not sure because I quit. As I readBobby Treat's response, one of my processors had been laboring for more thanthree days to generate all the digits. (I had not considered to display orprint all of them. Why on Earth would I want to do that?) So I started over,asking RealDigits to skip most of the digits.Tom Burton> So would it take about the same amont of time for the complete printout> of digits? Of course it would take a few additional seconds to format> the output...> Or does Mathematica take alot less time when it truncates the output?> Could you tell me the CPU you used and its speed etc...i am curious,> other programs out there.> I used one processor of a dual 1GH Mac and got the same answer with the> following speed:> 4.2 for Mac OS X (June 4, 2002)> oldmax = $MaxPrecision> 6> 1. 10> $MaxPrecision = Infinity> Infinity> With[{n = 2^26}, Timing[> pd = RealDigits[N[Pi, n + 1], 10, 20,> 19 - n]; ]]> {28794.1 Second, Null}> MaxMemoryUsed[]> 512055204> pd> {{3, 3, 8, 6, 3, 2, 2, 0, 8, 9, 6, 2, 2, 3,> 4, 0, 9, 8, 0, 3}, -67108844}> Tom Burton> ==== Often posters to MathGroup copy and paste in the complete cell expression,including the In and Out numbers, when posting to MathGroup.I wonder if this is the best method because one can't then just copy out allthe statements and paste them into a Mathematica notebook. All the statementnumbers have to be edited out and if there are many statement definitionsthis is an extended task for any responder. This, of course, decreases thechances for a response. A better method is for the poster to just copy andpaste the CONTENTS of each cell. This is more work for the poster, but itmay pay off in better responses.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/=== =David,I agree with you that it makes responding and using easier if the In and Outnumbers are not included.An easier way to do this, rather than copying the contents of the cells, isUsually a little manual reformating is needed to distinguish text, input andoutput --- I try to use one tab indent for input and two tabs indent foroutput, plus some blank line adjustment.I wonder if anyone has a way of automatically achieving this reformating.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> Often posters to MathGroup copy and paste in the complete cell expression,> including the In and Out numbers, when posting to MathGroup.> I wonder if this is the best method because one can't then just copy outall> the statements and paste them into a Mathematica notebook. All thestatement> numbers have to be edited out and if there are many statement definitions> this is an extended task for any responder. This, of course, decreases the> chances for a response. A better method is for the poster to just copy and> paste the CONTENTS of each cell. This is more work for the poster, but it> may pay off in better responses.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ ==== copying and pasting is straightforward. I always run my notebooks this way,because showing the In[x], Out[x] does not seem to provide me with muchbeyond clutter.Kevin> Often posters to MathGroup copy and paste in the complete cell expression,> including the In and Out numbers, when posting to MathGroup.> I wonder if this is the best method because one can't then just copy outall> the statements and paste them into a Mathematica notebook. All thestatement> numbers have to be edited out and if there are many statement definitions> this is an extended task for any responder. This, of course, decreases the> chances for a response. A better method is for the poster to just copy and> paste the CONTENTS of each cell. This is more work for the poster, but it> may pay off in better responses.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ ==== >In a presentation I wish to use Plot to generate a sequence of frames and>then animate them. The problem is that the audience sees the animation>twice. Once when the frames are being generated and then again after I have>closed the group and double clicked on the top graphic. However, the first>showing during generation is enough (but uncontrolled).>Hugh GoyderThis creates a graphics cell from a graphics expression.GraphicCell[graphics_] := Cell[GraphicsData[PostScript, DisplayString[graphics]],Graphics]cellgroup.Block[{$ DisplayFunction=Identity, graphs}, graphs = Table[GraphicCell[ Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}}, ImageSize -> 400]], {t,0,15,.1}]; NotebookWrite[EvaluationNotebook[],Cell[CellGroupData[graphs, Closed]]]; SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndExecute[{FrontEndToken[EvaluationNotebook[], SelectionAnimate]}] ]------------------------------------------------------------ --Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== Actually, the reason why ImpliesQ (and FullSimplify) fail toprove the implication is not that the hypothesis is a disjunction.To use the cylindrical algebraic decomposition algorithm theyneed to know that the assumptions imply that all variables arereal. The assumptions mechanism infers variable domains in a purelysyntactical way, i.e. v is assumed to be real if there is an Element[v, Reals] statement or v appears in an inequality.It does not attempt to analyze assumptions further, to figureout that, say y6 >= -1 implies that y6 is real, and then ifwe have y5 == y6 then y5 must be real too. Doing such an analysisin general would require solving the assumptions over complexnumbers, and then finding out which variables need to be real.This would be in general too time consuming to do, but analyzing linear dependencies like the ones in your example is a possiblefuture improvement.ImpliesQ cannot prove the implication here, because it knows onlythat y6 is real.In[1]:= <= -1 && y5 == y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6] Out[2]= False If we add an explicit assumption that y4 and y5 are real, ImpliesQ (and FullSimplify) can prove this implication, and the full version of your example.In[3]:= ImpliesQ[Element[y4|y5, Reals] && y4 == -1 && y6 >= -1 && y5 ==y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6] Out[3]= True In[4]:= ImpliesQ[Element[y4|y5, Reals] && (y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6), y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6] Out[4]=True In[5]:= FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,Element[y4|y5, Reals] && (y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6)] Out[5]=True Adam StrzebonskiWolfram Research > On second thoughts I realized that there seems to be an inherent> ambiguity about what one coudl mean by using alternatives (statements> joned by Or) assumptions. In fact it now seems to me that the> reasonable intertpretation for ImpliesQ and FullSimplify ought to> perhaps be different. It seems to me that ImpliesQ[Or[a,b],c] ought to> return True if aand only if ImpliesQ[a,c] and ImpliesQ[b,c] both return> True. If so this could be acomplished by adding the rule> ImpliesQ[Or[a,b],c] = And[ImpliesQ[a,c],ImpliesQ[b,c]]. That could then> be used in proving that the two answers to the system of inequalities> that of Vincent's original posting are equivalent. On the other hand> probably FullSimplify[a, Or[p,q]] ought to return> Or[FullSimplify[a,p],FullSimplify[a,q]] (or do nothing as it doe snow).> The first approach would seem to be consistent with the way> FullSimplify works with domain specifications but would however have> the strange effect of returning True if just one of the alternatives> were true and the other false. So perhaps after all it is best to> leave FullSimplify as it is. However, it seems to me that ImpliesQ> shoud be able to handle such cases (?)> Andrzej Kozlowski> Toyama International University> JAPAN> The modification to FullSimplify that I sent earlier works correctly> only for assumptions of the form Or[a,b] (and even then not is not> always what one would like). For what it's worth here is a better (but> slow) version:> In[1]:=> Unprotect[FullSimplify];> In[2]:=> FullSimplify[expr_, x_ || y__] := FullSimplify[> FullSimplify[expr, x] || FullSimplify[expr, Or[y]]];> In[3]:=> Protect[FullSimplify];> For example:> In[4]:=> FullSimplify[Sqrt[(x - 1)^2] + Sqrt[(x - 2)^2] +> Sqrt[(x - 3)^2], x > 1 || x > 2 || x > 3]> Out[4]=> -1 + x + Abs[-3 + x] + Abs[-2 + x] ||> -3 + 2*x + Abs[-3 + x] || 3*(-2 + x)> Andrzej Kozlowski> Toyama International University> JAPAN> The reason why InequalitySolve returns it's answer in what sometimes> turns out to be unnecessarily complicated form is that the underlying> algorithm, Cylindrical Agebraic Decomposition (CAD) returns its> answers in this form. Unfortunately it seems to me unlikely that a> simplification of the kind you need can be can be accomplished in any> general way. To see why observe the following. First of all:> In[1]:=> FullSimplify[x > 0 || x == 0]> Out[1]=> x >= 0> This is fine. However:> In[2]:=> FullSimplify[x > 0 && x < 2 || x == 0 && x < 2]> Out[2]=> x == 0 || 0 < x < 2> Of course what you would like is simply 0 <= x < 2. One reason why> you can't get it is that while Mathematica can perform a> LogicalExpand, as in:> In[3]:=> LogicalExpand[(x > 0 || x == 0) && x < 2]> Out[3]=> x == 0 && x < 2 || x > 0 && x < 2> There i no LogicalFactor or anything similar that would reverse> what LogicalExpand does. if there was then you could perform the sort> of simplifications you need for:> In[4]:=> FullSimplify[(x > 0 || x == 0) && x < 2]> Out[4]=> 0 <= x < 2> However, it does not seem to me very likely that such logical> factoring can be performed by a general enough algorithm (though I> am no expert in this field). In any case, certainly Mathematica can't> do this.> I also noticed that Mathematica seems unable to show that the answer> it returns to your problem is actually equivalent to your simpler> one. In fact this looks like a possible bug in Mathematica. Let's> first try the function ImpliesQ from the Experimental context:> << Experimental`> Now Mathematica correctly gives:> In[6]:=> ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5> <= 1 + y4 + y6]> Out[6]=> True> However:> In[7]:=> ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +> y4 + y6]> Out[7]=> False> That simply means that ImpliesQ cannot show the implication, not that> it does not hold. ImpliesQ relies on CAD, as does FullSimplify.> Switching to FullSimplify we see that:> In[8]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1> &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +> y4 + y6]> Out[8]=> True> while> In[9]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5> <= 1 + y4 + y6]> Out[9]=> y4 >= -1 && y6 <= y5 <= 1 + y4 + y6> On the other hand, taking just the individual summands of Or as> hypotheses;> In[10]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[10]=> True> In[11]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 ]> Out[11]=> True> In fact FullSimplify is unable to use Or in assumptions, which can be> demonstrated on an abstract example:> In[12]:=> FullSimplify[C,(A||B)&&(C)]> Out[12]=> True> In[13]:=> FullSimplify[C,LogicalExpand[(A||B)&&(C)]]> Out[13]=> C> This could be fixed by modifying FullSimplify:> In[14]:=> Unprotect[FullSimplify];> In[14]:=> FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify[e> xpr,y]];> In[15]:=> Protect[FullSimplify];> Now at least we get as before:> In[16]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1> &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +> y4 + y6]> Out[16]=> True> but also:> In[17]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5> <= 1 + y4 + y6]> Out[17]=> True> This seems to me a possible worthwhile improvement in FullSimplify,> though of course not really helpful for your problem.> Andrzej Kozlowski> Toyama International University> JAPAN> I have a set of inequalities that I solve with InequalitySolve. But> then> it gives a complete set of solutions, but not in the way I would> like it> to be! :-) For example, the simple following calculation will give:> In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6>= -1};> InequalitySolve[ineq,{y4,y6,y5}]> Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6> the result is good, but I would like it to be in the simpler but> equivalent form> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6> How can I tell InequalitySolve to do that? It is simple for this> example,> but for a large set of simple inequalities InequalitySolve gives> lines and> lines of results instead of a simple result.> Vincent Bouchard> > ==== On second thoughts I realized that there seems to be an inherent ambiguity about what one could mean by using alternatives (statements joned by Or) assumptions. In fact it now seems to me that the reasonable intertpretation for ImpliesQ and FullSimplify ought to perhaps be different. It seems to me that ImpliesQ[Or[a,b],c] ought to return True if aand only if ImpliesQ[a,c] and ImpliesQ[b,c] both return True. If so this could be acomplished by adding the ruleImpliesQ[Or[a,b],c] = And[ImpliesQ[a,c],ImpliesQ[b,c]]. That could then be used in proving that the two answers to the system of inequalities that of Vincent's original posting are equivalent. On the other hand probably FullSimplify[a, Or[p,q]] ought to return Or[FullSimplify[a,p],FullSimplify[a,q]] (or do nothing as it doe snow). The first approach would seem to be consistent with the way FullSimplify works with domain specifications but would however have the strange effect of returning True if just one of the alternatives were true and the other false. So perhaps after all it is best to leave FullSimplify as it is. However, it seems to me that ImpliesQ shoud be able to handle such cases (?)Andrzej KozlowskiToyama International UniversityJAPAN> The modification to FullSimplify that I sent earlier works correctly > only for assumptions of the form Or[a,b] (and even then not is not > always what one would like). For what it's worth here is a better (but > slow) version:> In[1]:=> Unprotect[FullSimplify];> In[2]:=> FullSimplify[expr_, x_ || y__] := FullSimplify[> FullSimplify[expr, x] || FullSimplify[expr, Or[y]]];> In[3]:=> Protect[FullSimplify];> For example:> In[4]:=> FullSimplify[Sqrt[(x - 1)^2] + Sqrt[(x - 2)^2] +> Sqrt[(x - 3)^2], x > 1 || x > 2 || x > 3]> Out[4]=> -1 + x + Abs[-3 + x] + Abs[-2 + x] ||> -3 + 2*x + Abs[-3 + x] || 3*(-2 + x)> Andrzej Kozlowski> Toyama International University> JAPAN> The reason why InequalitySolve returns it's answer in what sometimes > turns out to be unnecessarily complicated form is that the underlying > algorithm, Cylindrical Agebraic Decomposition (CAD) returns its > answers in this form. Unfortunately it seems to me unlikely that a > simplification of the kind you need can be can be accomplished in any > general way. To see why observe the following. First of all: In[1]:=> FullSimplify[x > 0 || x == 0] Out[1]=> x >= 0 This is fine. However: In[2]:=> FullSimplify[x > 0 && x < 2 || x == 0 && x < 2] Out[2]=> x == 0 || 0 < x < 2 Of course what you would like is simply 0 <= x < 2. One reason why > you can't get it is that while Mathematica can perform a > LogicalExpand, as in:> In[3]:=> LogicalExpand[(x > 0 || x == 0) && x < 2] Out[3]=> x == 0 && x < 2 || x > 0 && x < 2 There i no LogicalFactor or anything similar that would reverse > what LogicalExpand does. if there was then you could perform the sort > of simplifications you need for: In[4]:=> FullSimplify[(x > 0 || x == 0) && x < 2] Out[4]=> 0 <= x < 2 However, it does not seem to me very likely that such logical > factoring can be performed by a general enough algorithm (though I > am no expert in this field). In any case, certainly Mathematica can't > do this. I also noticed that Mathematica seems unable to show that the answer > it returns to your problem is actually equivalent to your simpler > one. In fact this looks like a possible bug in Mathematica. Let's > first try the function ImpliesQ from the Experimental context: << Experimental` Now Mathematica correctly gives: In[6]:=> ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 > <= 1 + y4 + y6] Out[6]=> True However: In[7]:=> ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + > y4 + y6] Out[7]=> False That simply means that ImpliesQ cannot show the implication, not that > it does not hold. ImpliesQ relies on CAD, as does FullSimplify. > Switching to FullSimplify we see that: In[8]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 > &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + > y4 + y6] Out[8]=> True while In[9]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 > <= 1 + y4 + y6] Out[9]=> y4 >= -1 && y6 <= y5 <= 1 + y4 + y6 On the other hand, taking just the individual summands of Or as > hypotheses;> In[10]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6] Out[10]=> True In[11]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 ] Out[11]=> True In fact FullSimplify is unable to use Or in assumptions, which can be > demonstrated on an abstract example:> In[12]:=> FullSimplify[C,(A||B)&&(C)] Out[12]=> True In[13]:=> FullSimplify[C,LogicalExpand[(A||B)&&(C)]] Out[13]=> C This could be fixed by modifying FullSimplify: In[14]:=> Unprotect[FullSimplify]; In[14]:=> FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify[e > xpr,y]]; In[15]:=> Protect[FullSimplify]; Now at least we get as before: In[16]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 > &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + > y4 + y6] Out[16]=> True but also: In[17]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 > <= 1 + y4 + y6] Out[17]=> True This seems to me a possible worthwhile improvement in FullSimplify, > though of course not really helpful for your problem.> Andrzej Kozlowski> Toyama International University> JAPAN I have a set of inequalities that I solve with InequalitySolve. But > then> it gives a complete set of solutions, but not in the way I would > like it> to be! :-) For example, the simple following calculation will give: In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6 >= -1};> InequalitySolve[ineq,{y4,y6,y5}] Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6 the result is good, but I would like it to be in the simpler but> equivalent form y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6 How can I tell InequalitySolve to do that? It is simple for this > example,> but for a large set of simple inequalities InequalitySolve gives > lines and> lines of results instead of a simple result.> Vincent Bouchard ==== Hallo!,My name is Nagesh and pursuing research studies in Refrigeration. At present I am writing a Dynamic Refrigeration System Simulation Package. I am using Mathematica as a programming language for the same since last one year. I don't have any programming experience before this. I have following querries:-1. Is any body here have expertise or information about the capability of Mathematica as a system simulation tool?2. Is is possible to program a user friendly interface for my system simulation package with Mathematica or I have to use some other software?3. My refrigeration system simulation package is likely to have approximately 60 First order Differential equations. Is is possible to solve these in Mathematica ? If yes then can anybody here guide me about this further.I am explaining below in short about the objectives I want to fulfill from coding out of my main input file1. Example from Main Input File ( this will contain about 200-250 variables which will be entered by the user of this package)Below is examples of two variables entered into this file, which will be used in other analysis files for further evaluation.2. Example from other analysis file ( there will be about 20-25 other such component analysis files ) where the above mentioned variables from main input file will be used for further evaluations:-Below is one example from this file explaining how the variables from main input file will be used in other files.I hope that this short information will be useful for guiding me to solve the following problems that I am facing. I am facing follwing problems or objectives:-1. My 1st Objective:- The user of this package must be able to change only the value of the variable in the main input file but he must not be able to change the name of the variable itself. For example he must be able to change the value of the variable but he must not be able to change the name of this variable itself.Here our problem is how to achieve or program it so that our objective will be fullfilled.2. My 2nd Objective:- How I can program the main input file so that it will be user friendly in terms of its visuals and satisfying the constraint mentioned above in objective1.3. My 3rd Objective:- How can I program the optional values for each variable in the main input file ? so that there will be always a value assigned to each variable listed in main input file whenever the user opens up this file. If user want to change the values of some variables then he can change them and run the simulation otherwise the simulation run will be done with optional values assigned to each variable in the input file.4. My 4th Objective:- How can I program the check for correctness of the input values supplied by the package user ?I will be very greatful to you for helping and suggesting some technique or method to solve some of my above mentioned programming problems.Can anybody here guide me about the above mentioned programming problems ?Nagesh Rajepandhare ==== I want to add a further suggestion:Probably each differential equation logically belongs to one of the definedclasses in the sense, that it helps to define the behaviour of thecomponent.In this case, each differential equation should be stored in one of thesesclasses as textstring in a form appropriate for the execution inMathematica.Hermann Schmitt----- Original Message -----> Is any body here have expertise or information about the capability of> Mathematica as a system simulation tool?> Mr. Kuska answers:> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> My comment:> That is: He sees the simulation system merely as a set of differential> equations.> The question of Mr. Nagesh:> My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?> The answer of Mr. Kuska is:> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> My comment:> This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.> Nagesh understand it and is it sufficient to check, if all inputs are> numerical?> Additionally I think, it is not userfriendly to see the input merely as a> set of 200-250 numbers.> My suggestion is, that JLink is used, a suggestion Mr. Kusk takes into> consideration, too.> But further I suggest, that classes are defined in Java, which representthe> parts of the system.> Constructors of the classes should build objects with default values.> Graphical user interfaces> should give the opportunity to change the data fields in the objects and> check the input for correctness.> The system should give the opportunity, to store the objects on harddisk> (serialization).> accessed directly.> My name is Nagesh and pursuing research studies in Refrigeration. At> present I am writing a Dynamic Refrigeration System SimulationPackage.> I> am using Mathematica as a programming language for the same since last> one> year. I don't have any programming experience before this. I have> following> querries:-> 1. Is any body here have expertise or information about the capability> of> Mathematica as a system simulation tool?> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> 2. Is is possible to program a user friendly interface for my system> simulation package with Mathematica or I have to use some other> software?> Write a MathLink or J/Link frontend that launch the kernel. But you> should keep> in mind that the user interface is typical 80-90 % of your code.> If you just whant to solve some ode's it is probably easyer to> include one of the excelent ode-solvers from netlib in your C-code> than to call Mathematica to do that. As long as you dont wish to change> the ode's very often (than Mathematica is more ßexible) you should> not use Mathematica.> 3. My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations. Is is possible to> solve these in Mathematica ?> Sure.> If yes then can anybody here guide me about> this further.> Write down the equations and call NDSolve[].> I am explaining below in short about the objectives I want to fulfill> from> coding out of my main input file> 1. Example from Main Input File ( this will contain about 200-250> variables> which will be entered by the user of this package)> This sounds like a *very* userfiendly interface ;-)> > Below is examples of two variables entered into this file, which willbe> used in other analysis files for further evaluation.> 2. Example from other analysis file ( there will be about 20-25 other> such> component analysis files ) where the above mentioned variables frommain> input file will be used for further evaluations:-> Below is one example from this file explaining how the variables from> main> input file will be used in other files.> I hope that this short information will be useful for guiding me to> solve> the following problems that I am facing. I am facing follwing problems> or> objectives:-> 1. My 1st Objective:- The user of this package must be able to change> only> the value of the variable in the main input file but he must not beable> to> change the name of the variable itself. For example he must be able to> change the value of the variable but he must not be able tochange> the> name of this variable itself.> Here our problem is how to achieve or program it so that our objective> will> be fullfilled.> Options with defaulf values ? or something like> {aParam,bParam}={ODEParameter1,ODEParameter2} /.> userRules /.> {ODEParameter1->1,ODEParameter2->2}> 2. My 2nd Objective:- How I can program the main input file so that it> will> be user friendly in terms of its visuals and satisfying the constraint> mentioned above in objective1.> What is *userfiendly* in a file with 250 variables ???> 3. My 3rd Objective:- How can I program the optional values for each> variable in the main input file ? so that there will be always a value> assigned to each variable listed in main input file whenever the user> opens> up this file. If user want to change the values of some variables then> he> can change them and run the simulation otherwise the simulation runwill> be> done with optional values assigned to each variable in the input file.> See above.> 4. My 4th Objective:- How can I program the check for correctness ofthe> input values supplied by the package user ?> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> Jens> ==== I have developed one package where it is included a functions forsolving System of ODE. You can downloaded from:http://web.usal.es/~guillerm/biokmod.The functions are: SystemDSolve and SystemNDSolve Guillermo Sanchez> I want to add a further suggestion:> Probably each differential equation logically belongs to one of the defined> classes in the sense, that it helps to define the behaviour of the> component.> In this case, each differential equation should be stored in one of theses> classes as textstring in a form appropriate for the execution in> Mathematica.> Hermann Schmitt> ----- Original Message -----> I agree with Mr. Kuska, that the system Mr Nagesh describes is not> userfriendly. But I think, the suggestions of Mr. Kuska do not make it> more> userfriendly, rather the opposite is true.> Mr. Nagesh asks> Is any body here have expertise or information about the capability of> Mathematica as a system simulation tool?> Mr. Kuska answers:> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> My comment:> That is: He sees the simulation system merely as a set of differential> equations.> The question of Mr. Nagesh:> My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?> The answer of Mr. Kuska is:> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> My comment:> This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.> Nagesh understand it and is it sufficient to check, if all inputs are> numerical?> Additionally I think, it is not userfriendly to see the input merely as a> set of 200-250 numbers.> My suggestion is, that JLink is used, a suggestion Mr. Kusk takes into> consideration, too.> But further I suggest, that classes are defined in Java, which represent> the> parts of the system.> Constructors of the classes should build objects with default values.> Graphical user interfaces> should give the opportunity to change the data fields in the objects and> check the input for correctness.> The system should give the opportunity, to store the objects on harddisk> (serialization).> accessed directly.> My name is Nagesh and pursuing research studies in Refrigeration. At> present I am writing a Dynamic Refrigeration System Simulation> Package.> I> am using Mathematica as a programming language for the same since last> one> year. I don't have any programming experience before this. I have> following> querries:-> 1. Is any body here have expertise or information about the capability> of> Mathematica as a system simulation tool?> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> 2. Is is possible to program a user friendly interface for my system> simulation package with Mathematica or I have to use some other> software?>> Write a MathLink or J/Link frontend that launch the kernel. But you> should keep> in mind that the user interface is typical 80-90 % of your code.> If you just whant to solve some ode's it is probably easyer to> include one of the excelent ode-solvers from netlib in your C-code> than to call Mathematica to do that. As long as you dont wish to change> the ode's very often (than Mathematica is more ßexible) you should> not use Mathematica.> 3. My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations. Is is possible to> solve these in Mathematica ?> Sure.> If yes then can anybody here guide me about> this further.> Write down the equations and call NDSolve[].> I am explaining below in short about the objectives I want to fulfill> from> coding out of my main input file> 1. Example from Main Input File ( this will contain about 200-250> variables> which will be entered by the user of this package)> This sounds like a *very* userfiendly interface ;-)> > Below is examples of two variables entered into this file, which will> be> used in other analysis files for further evaluation.> 2. Example from other analysis file ( there will be about 20-25 other> such> component analysis files ) where the above mentioned variables from> main> input file will be used for further evaluations:-> Below is one example from this file explaining how the variables from> main> input file will be used in other files.> I hope that this short information will be useful for guiding me to> solve> the following problems that I am facing. I am facing follwing problems> or> objectives:-> 1. My 1st Objective:- The user of this package must be able to change> only> the value of the variable in the main input file but he must not be> able> to> change the name of the variable itself. For example he must be able to> change the value of the variable but he must not be able to> change> the> name of this variable itself.> Here our problem is how to achieve or program it so that our objective> will> be fullfilled.> Options with defaulf values ? or something like> {aParam,bParam}={ODEParameter1,ODEParameter2} /.> userRules /.> {ODEParameter1->1,ODEParameter2->2}> 2. My 2nd Objective:- How I can program the main input file so that it> will> be user friendly in terms of its visuals and satisfying the constraint> mentioned above in objective1.> What is *userfiendly* in a file with 250 variables ???> 3. My 3rd Objective:- How can I program the optional values for each> variable in the main input file ? so that there will be always a value> assigned to each variable listed in main input file whenever the user> opens> up this file. If user want to change the values of some variables then> he> can change them and run the simulation otherwise the simulation run> will> be> done with optional values assigned to each variable in the input file.> See above.> 4. My 4th Objective:- How can I program the check for correctness of> the> input values supplied by the package user ?> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> Jens> > ==== I agree with Mr. Kuska, that the system Mr Nagesh describes is notuserfriendly. But I think, the suggestions of Mr. Kuska do not make it moreuserfriendly, rather the opposite is true.Mr. Nagesh asksIs any body here have expertise or information about the capability ofMathematica as a system simulation tool?Mr. Kuska answers:Since the most system simulation tools are simply solving a system ofordinary differntial equations it is simple to do this with NDSolve[].My comment:That is: He sees the simulation system merely as a set of differentialequations.The question of Mr. Nagesh:My 4th Objective:- How can I program the check for correctness of the input values supplied by the package user ?The answer of Mr. Kuska is:And @@ (NumericQ /@ {aListOfAllYourNumericParameters})My comment:This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.Nagesh understand it and is it sufficient to check, if all inputs arenumerical?Additionally I think, it is not userfriendly to see the input merely as aset of 200-250 numbers.My suggestion is, that JLink is used, a suggestion Mr. Kusk takes intoconsideration, too.But further I suggest, that classes are defined in Java, which represent theparts of the system.Constructors of the classes should build objects with default values.Graphical user interfacesshould give the opportunity to change the data fields in the objects andcheck the input for correctness.The system should give the opportunity, to store the objects on harddisk(serialization).accessed directly.> My name is Nagesh and pursuing research studies in Refrigeration. At> present I am writing a Dynamic Refrigeration System Simulation Package.I> am using Mathematica as a programming language for the same since lastone> year. I don't have any programming experience before this. I havefollowing> querries:-> 1. Is any body here have expertise or information about the capabilityof> Mathematica as a system simulation tool?> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> 2. Is is possible to program a user friendly interface for my system> simulation package with Mathematica or I have to use some othersoftware?> Write a MathLink or J/Link frontend that launch the kernel. But you> should keep> in mind that the user interface is typical 80-90 % of your code.> If you just whant to solve some ode's it is probably easyer to> include one of the excelent ode-solvers from netlib in your C-code> than to call Mathematica to do that. As long as you dont wish to change> the ode's very often (than Mathematica is more ßexible) you should> not use Mathematica.> 3. My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations. Is is possible to> solve these in Mathematica ?> Sure.> If yes then can anybody here guide me about> this further.> Write down the equations and call NDSolve[].> I am explaining below in short about the objectives I want to fulfillfrom> coding out of my main input file> 1. Example from Main Input File ( this will contain about 200-250variables> which will be entered by the user of this package)> This sounds like a *very* userfiendly interface ;-)> Below is examples of two variables entered into this file, which will be> used in other analysis files for further evaluation.> 2. Example from other analysis file ( there will be about 20-25 othersuch> component analysis files ) where the above mentioned variables from main> input file will be used for further evaluations:-> Below is one example from this file explaining how the variables frommain> input file will be used in other files.> I hope that this short information will be useful for guiding me tosolve> the following problems that I am facing. I am facing follwing problemsor> objectives:-> 1. My 1st Objective:- The user of this package must be able to changeonly> the value of the variable in the main input file but he must not be ableto> change the name of the variable itself. For example he must be able to> change the value of the variable but he must not be able to changethe> name of this variable itself.> Here our problem is how to achieve or program it so that our objectivewill> be fullfilled.> Options with defaulf values ? or something like> {aParam,bParam}={ODEParameter1,ODEParameter2} /.> userRules /.> {ODEParameter1->1,ODEParameter2->2}> 2. My 2nd Objective:- How I can program the main input file so that itwill> be user friendly in terms of its visuals and satisfying the constraint> mentioned above in objective1.> What is *userfiendly* in a file with 250 variables ???> 3. My 3rd Objective:- How can I program the optional values for each> variable in the main input file ? so that there will be always a value> assigned to each variable listed in main input file whenever the useropens> up this file. If user want to change the values of some variables thenhe> can change them and run the simulation otherwise the simulation run willbe> done with optional values assigned to each variable in the input file.> See above.> 4. My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})>> Jens ==== See my comments in the following text!Hermann Schmitt----- Original Message -----> Is any body here have expertise or information about the capability of> Mathematica as a system simulation tool?> Mr. Kuska answers:> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> My comment:> That is: He sees the simulation system merely as a set of differential> equations.> hmm, since the original poster write> My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations.> it seems not completly wrong to assume that the system consists of> of ode's ..Yout should not ignore the word merely.It is not enough to have a set 60 differential equations and a set of200-250 numbers. That is not simulation system, which can be used by userswith the exception, perhaps, of the programmer of the system himself.How does e.g. the user know what meaning a number in the set has, ought hecount the numbers from the beginning?Your nice command shows only, if there is an input, which is not a number.But I think the user would like to know, which of the 200 elements are notnumbers.The only good of your command is, that it looks nice and shows yourknowledge!> The question of Mr. Nagesh:> My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?> The answer of Mr. Kuska is:> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> My comment:> This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.> Nagesh understand it and is it sufficient to check, if all inputs are> numerical?> It seems you have a deeper knowlege about the things that Mr. Nagesh> understand. You know him personally ? It is not very polite to> make speculations *what* a other person understand.> And no it is not sufficent to check that all parameters are numbers.> Typical paramters described by intervals, where the assumptions of> a model are valid. But for this checks one needs more knowlege> about the meaning of the parameters. And one needs the knowlege about> the differntial equations, to find out the eigenvalues of the jacobian> ...> Additionally I think, it is not userfriendly to see the input merely asa> set of 200-250 numbers.> My suggestion is, that JLink is used, a suggestion Mr. Kusk takes into> consideration, too.> That will be fast as lightning !> But further I suggest, that classes are defined in Java, which representthe> parts of the system.> That is notable nonsense! When the differntial equations should be> solved with Mathematica, the parts can't be Java classes. Mathematica's> NDSolve[] need a explicit expression to integrate the equations.That's not nonsense, the Mathematica program does not fetch the classes butthe numbers in the classes (or better in the objects).the Java classes in textform. They can then be fetched from the Mathematicaprogram and transformed into expressions by the Command ToExpression.The aim is, to have a clear separation of the system into components, whichare manageable and understandable.> OK you can call a Java class member from Mathematica but this will> be incredible slow when the right hand side is evaluated 200-300> times and every evaluation make several callbacks to the Java source.> Event handler of the Java main program (without some modification in> the event loop) while it is evaluating an other command.My idea is to fetch the values once from the Java objects at the beginning.200-250 numbers is not so much..> Constructors of the classes should build objects with default values.> That's a great idea. If a simulation run should be documented, one> always> need the full listing of the Java source to find the actual parameter> settings.That is not my opinion. I think not every user of the simulation systemshould have to know Java and Mathematica.The user must look for the values in the objects. And the values are in theobjects, if they come from the constructor or from the graphical userinterface.I think, there should be listings of the objects including names of thevariables. In the objects the values are in an meaningful environment.> Graphical user interfaces> should give the opportunity to change the data fields in the objects and> check the input for correctness.> *and* what has a GUI for 200-250 variables to do with Mathematica ?> BTW one has typical much less variables because many parameters> are fixed and it make no sense to change, for example, material> constants of materials that can't exchanged> The system should give the opportunity, to store the objects on harddisk> (serialization).> accessed directly.>> Can you be so kind, to explain *how* your posting help a person that> ask How can I build a simulation system with Mathematica ?> You *can* say Don't use Mathematica, use Java! but this has nothing> to do with the question or with my reply.It is you, who proposes to solve the problem with C/C++ and not to useMathematica (see below!)My point of view is:Use Mathematica, for what Mathemtica is good, and Java, for what Java isgood.Mathematica is not so good as Java for data entry and Java is better thanMathematica to represent the simulation system (by objects).> But I still would suggest to use C/C++ and a numerical> ode-solver, make a fancy GUI/Script> interface and don't use Mathematica for such a simple task.> The ode-solver is the smallest part of such a simulation system.> Jens> My name is Nagesh and pursuing research studies in Refrigeration. At> present I am writing a Dynamic Refrigeration System SimulationPackage.> I> am using Mathematica as a programming language for the same sincelast> one> year. I don't have any programming experience before this. I have> following> querries:-> 1. Is any body here have expertise or information about thecapability> of> Mathematica as a system simulation tool?> Since the most system simulation tools are simply solving a systemof> ordinary differntial equations it is simple to do this with NDSolve[].> 2. Is is possible to program a user friendly interface for my system> simulation package with Mathematica or I have to use some other> software?> Write a MathLink or J/Link frontend that launch the kernel. But you> should keep> in mind that the user interface is typical 80-90 % of your code.> If you just whant to solve some ode's it is probably easyer to> include one of the excelent ode-solvers from netlib in your C-code> than to call Mathematica to do that. As long as you dont wish tochange> the ode's very often (than Mathematica is more ßexible) you should> not use Mathematica.> 3. My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations. Is is possibleto> solve these in Mathematica ?> Sure.> If yes then can anybody here guide me about> this further.> Write down the equations and call NDSolve[].> I am explaining below in short about the objectives I want tofulfill> from> coding out of my main input file> 1. Example from Main Input File ( this will contain about 200-250> variables> which will be entered by the user of this package)> This sounds like a *very* userfiendly interface ;-)> Below is examples of two variables entered into this file, whichwill be> used in other analysis files for further evaluation.> 2. Example from other analysis file ( there will be about 20-25other> such> component analysis files ) where the above mentioned variables frommain> input file will be used for further evaluations:-> Below is one example from this file explaining how the variablesfrom> main> input file will be used in other files.> I hope that this short information will be useful for guiding me to> solve> the following problems that I am facing. I am facing follwingproblems> or> objectives:-> 1. My 1st Objective:- The user of this package must be able tochange> only> the value of the variable in the main input file but he must not beable> to> change the name of the variable itself. For example he must be ableto> change the value of the variable but he must not be able tochange> the> name of this variable itself.> Here our problem is how to achieve or program it so that ourobjective> will> be fullfilled.> Options with defaulf values ? or something like> {aParam,bParam}={ODEParameter1,ODEParameter2} /.> userRules /.> {ODEParameter1->1,ODEParameter2->2}> 2. My 2nd Objective:- How I can program the main input file so thatit> will> be user friendly in terms of its visuals and satisfying theconstraint> mentioned above in objective1.> What is *userfiendly* in a file with 250 variables ???> 3. My 3rd Objective:- How can I program the optional values for each> variable in the main input file ? so that there will be always avalue> assigned to each variable listed in main input file whenever theuser> opens> up this file. If user want to change the values of some variablesthen> he> can change them and run the simulation otherwise the simulation runwill> be> done with optional values assigned to each variable in the inputfile.> See above.> 4. My 4th Objective:- How can I program the check for correctness ofthe> input values supplied by the package user ?> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> Jens>Reply-To: kuska@informatik.uni-leipzig.de ==== > I agree with Mr. Kuska, that the system Mr Nagesh describes is not> userfriendly. But I think, the suggestions of Mr. Kuska do not make it more> userfriendly, rather the opposite is true.> Mr. Nagesh asks> Is any body here have expertise or information about the capability of> Mathematica as a system simulation tool?> Mr. Kuska answers:> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> My comment:> That is: He sees the simulation system merely as a set of differential> equations.hmm, since the original poster writeMy refrigeration system simulation package is likely to have approximately 60 First order Differential equations.it seems not completly wrong to assume that the system consists ofof ode's ..> The question of Mr. Nagesh:> My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?> The answer of Mr. Kuska is:> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> My comment:> This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.> Nagesh understand it and is it sufficient to check, if all inputs are> numerical?It seems you have a deeper knowlege about the things that Mr. Nagesh understand. You know him personally ? It is not very polite tomake speculations *what* a other person understand.And no it is not sufficent to check that all parameters are numbers.Typical paramters described by intervals, where the assumptions ofa model are valid. But for this checks one needs more knowlege about the meaning of the parameters. And one needs the knowlege aboutthe differntial equations, to find out the eigenvalues of the jacobian...> Additionally I think, it is not userfriendly to see the input merely as a> set of 200-250 numbers.> My suggestion is, that JLink is used, a suggestion Mr. Kusk takes into> consideration, too.That will be fast as lightning ! > But further I suggest, that classes are defined in Java, which represent the> parts of the system.That is notable nonsense! When the differntial equations should besolved with Mathematica, the parts can't be Java classes. Mathematica'sNDSolve[] need a explicit expression to integrate the equations.OK you can call a Java class member from Mathematica but this willbe incredible slow when the right hand side is evaluated 200-300times and every evaluation make several callbacks to the Java source.Event handler of the Java main program (without some modification inthe event loop) while it is evaluating an other command.> Constructors of the classes should build objects with default values.That's a great idea. If a simulation run should be documented, onealwaysneed the full listing of the Java source to find the actual parametersettings. > Graphical user interfaces> should give the opportunity to change the data fields in the objects and> check the input for correctness.*and* what has a GUI for 200-250 variables to do with Mathematica ?BTW one has typical much less variables because many parametersare fixed and it make no sense to change, for example, materialconstants of materials that can't exchanged> The system should give the opportunity, to store the objects on harddisk> (serialization).> accessed directly.> Can you be so kind, to explain *how* your posting help a person thatask How can I build a simulation system with Mathematica ?You *can* say Don't use Mathematica, use Java! but this has nothingto do with the question or with my reply. But I still would suggest to use C/C++ and a numerical ode-solver, make a fancy GUI/Scriptinterface and don't use Mathematica for such a simple task.The ode-solver is the smallest part of such a simulation system. Jens> My name is Nagesh and pursuing research studies in Refrigeration. At> present I am writing a Dynamic Refrigeration System Simulation Package.> I> am using Mathematica as a programming language for the same since last> one> year. I don't have any programming experience before this. I have> following> querries:-> 1. Is any body here have expertise or information about the capability> of> Mathematica as a system simulation tool?> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> 2. Is is possible to program a user friendly interface for my system> simulation package with Mathematica or I have to use some other> software?> Write a MathLink or J/Link frontend that launch the kernel. But you> should keep> in mind that the user interface is typical 80-90 % of your code.> If you just whant to solve some ode's it is probably easyer to> include one of the excelent ode-solvers from netlib in your C-code> than to call Mathematica to do that. As long as you dont wish to change> the ode's very often (than Mathematica is more ßexible) you should> not use Mathematica.> 3. My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations. Is is possible to> solve these in Mathematica ?> Sure.> If yes then can anybody here guide me about> this further.> Write down the equations and call NDSolve[].> I am explaining below in short about the objectives I want to fulfill> from> coding out of my main input file> 1. Example from Main Input File ( this will contain about 200-250> variables> which will be entered by the user of this package)> This sounds like a *very* userfiendly interface ;-)> Below is examples of two variables entered into this file, which will be> used in other analysis files for further evaluation.> 2. Example from other analysis file ( there will be about 20-25 other> such> component analysis files ) where the above mentioned variables from main> input file will be used for further evaluations:-> Below is one example from this file explaining how the variables from> main> input file will be used in other files.> I hope that this short information will be useful for guiding me to> solve> the following problems that I am facing. I am facing follwing problems> or> objectives:-> 1. My 1st Objective:- The user of this package must be able to change> only> the value of the variable in the main input file but he must not be able> to> change the name of the variable itself. For example he must be able to> change the value of the variable but he must not be able to change> the> name of this variable itself.> Here our problem is how to achieve or program it so that our objective> will> be fullfilled.> Options with defaulf values ? or something like> {aParam,bParam}={ODEParameter1,ODEParameter2} /.> userRules /.> {ODEParameter1->1,ODEParameter2->2}> 2. My 2nd Objective:- How I can program the main input file so that it> will> be user friendly in terms of its visuals and satisfying the constraint> mentioned above in objective1.> What is *userfiendly* in a file with 250 variables ???> 3. My 3rd Objective:- How can I program the optional values for each> variable in the main input file ? so that there will be always a value> assigned to each variable listed in main input file whenever the user> opens> up this file. If user want to change the values of some variables then> he> can change them and run the simulation otherwise the simulation run will> be> done with optional values assigned to each variable in the input file.> See above.> 4. My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> Jens>Reply-To: kuska@informatik.uni-leipzig.de ==== > My name is Nagesh and pursuing research studies in Refrigeration. At> present I am writing a Dynamic Refrigeration System Simulation Package. I> am using Mathematica as a programming language for the same since last one> year. I don't have any programming experience before this. I have following> querries:-> 1. Is any body here have expertise or information about the capability of> Mathematica as a system simulation tool?Since the most system simulation tools are simply solving a system ofordinary differntial equations it is simple to do this with NDSolve[].> 2. Is is possible to program a user friendly interface for my system> simulation package with Mathematica or I have to use some other software?Write a MathLink or J/Link frontend that launch the kernel. But youshould keepin mind that the user interface is typical 80-90 % of your code.If you just whant to solve some ode's it is probably easyer toinclude one of the excelent ode-solvers from netlib in your C-codethan to call Mathematica to do that. As long as you dont wish to changethe ode's very often (than Mathematica is more ßexible) you shouldnot use Mathematica.> 3. My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations. Is is possible to> solve these in Mathematica ?Sure. > If yes then can anybody here guide me about> this further.Write down the equations and call NDSolve[].> I am explaining below in short about the objectives I want to fulfill from> coding out of my main input file> 1. Example from Main Input File ( this will contain about 200-250 variables> which will be entered by the user of this package)This sounds like a *very* userfiendly interface ;-)> Below is examples of two variables entered into this file, which will be> used in other analysis files for further evaluation.> 2. Example from other analysis file ( there will be about 20-25 other such> component analysis files ) where the above mentioned variables from main> input file will be used for further evaluations:-> Below is one example from this file explaining how the variables from main> input file will be used in other files.> I hope that this short information will be useful for guiding me to solve> the following problems that I am facing. I am facing follwing problems or> objectives:-> 1. My 1st Objective:- The user of this package must be able to change only> the value of the variable in the main input file but he must not be able to> change the name of the variable itself. For example he must be able to> change the value of the variable but he must not be able to change the> name of this variable itself.> Here our problem is how to achieve or program it so that our objective will> be fullfilled.Options with defaulf values ? or something like{aParam,bParam}={ODEParameter1,ODEParameter2} /. userRules /. {ODEParameter1->1,ODEParameter2->2}> 2. My 2nd Objective:- How I can program the main input file so that it will> be user friendly in terms of its visuals and satisfying the constraint> mentioned above in objective1.What is *userfiendly* in a file with 250 variables ???> 3. My 3rd Objective:- How can I program the optional values for each> variable in the main input file ? so that there will be always a value> assigned to each variable listed in main input file whenever the user opens> up this file. If user want to change the values of some variables then he> can change them and run the simulation otherwise the simulation run will be> done with optional values assigned to each variable in the input file.See above.> 4. My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> Jens ==== You would need to make assumptions about y, and you can't. The functionand the limits have to take care of that, and when you try to do that,you end up with an expression that has different antiderivatives ondifferent regions, for different values of x. So, you have to break itup. The assumption x > 0 implies that x is real, so Im[x]==0 isunnecessary.one = Integrate[Cosh[2 (y - x)] 2 y, {y, Min[x, 1/2], 1/2}, Assumptions -> {x > 0}];two = Integrate[Cosh[2 (x - y)] 2 y, {y, 0, Min[x, 1/2]}, Assumptions -> {x > 0}];one + two // FullSimplifyPlot[{one, two, one + two}, {x, 0, 1/2}]; (1/4)*E^(-1 - 2*x)*(E + (-2 + E)*E^(4*x))Bobby Treat-----Original Message----- there something implicit that I am missing in the Assumptions ?MS.-- 12:02am up 5:06, 1 user, load average: 0.54, 0.22, 0.08Reply-To: spammers-go-here@yahoo.com ==== On Friday 27 September 2002 04:18 am, DrBob, as drbob@bigfoot.com, held forth the following in comp.soft-sys.math.mathematica () :> You would need to make assumptions about y, and you can't. The function> and the limits have to take care of that, and when you try to do that,> you end up with an expression that has different antiderivatives on> different regions, for different values of x. So, you have to break it> up. The assumption x > 0 implies that x is real, so Im[x]==0 is> unnecessary.> one = Integrate[Cosh[2 (y - x)]> 2 y, {y, Min[x, 1/2], 1/2}, Assumptions -> {x > 0}];> two = Integrate[Cosh[2 (x - y)] 2> y, {y, 0, Min[x, 1/2]}, Assumptions -> {x > 0}];> one + two // FullSimplify> Plot[{one, two, one + two}, {x, 0, 1/2}];> (1/4)*E^(-1 - 2*x)*(E + (-2 + E)*E^(4*x))> Bobby Treat> -----Original Message-----> I have been trying to integrate the following :> Integrate[Cosh[2 Abs[x-y]] 2 y, {y,0,1/2},> Assumptions->{Im[x]==0,x>0}]> However, Mathematica chokes and simply returns the integral as> it is. However, if I> split up the integral into two portions, it quickly gives me an answer> for the parts. Is> there something implicit that I am missing in the Assumptions ?> MS.> ?Anyways, I will try what you suggest.-- 12:53pm up 27 min, 1 user, load average: 0.19, 0.15, 0.09 ==== Put this after the Plot statement, in the same cell:SelectionMove[EvaluationNotebook[], All, GeneratedCell]FrontEndTokenExecute[OpenCloseGroup] FrontEndTokenExecute[SelectionAnimate]Bobby Treat-----Original Message-----Do[Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}},ImageSize -> 400]; SelectionMove[EvaluationNotebook[], All, GeneratedCell];FrontEndExecute[{FrontEnd`SelectionAnimate[ 0.1]}]; FrontEndExecute[{FrontEndToken[Clear]}], {t, 0, 15, 0.1}]This works but the cell dividing line ßashes on and off spoiling theanimation and if there is anything in the cell below this jumps up anddown.Is there a proper way of doing this?Hugh Goyder ==== >>So would it take about the same amont of time for the completeprintoutof digits? Of course it would take a few additional seconds to formatthe output...I think it would take FAR more time for a complete printout, and mightcrash the Front End. I was thinking about the fact that I calculatedall those digits and then threw them away. I could save them with Saveor DumpSave, and read them in with Get the next time I wanted any ofthem, although the file would be close to 70 MB (if not more). I may dothat, in fact -- I have plenty of disk space.The next step would be to somehow reuse the stored digits if I wantedMORE digits. But how?The Bailey-Borwein-Plouffe Pi algorithm is an avenue of attack, since itcan calculate digits far from the decimal point, without calculatingthose in between. Unfortunately, it calculates hexadecimal digits inthat way, not decimal digits. (That's true for the version I've seen,anyway.) Still, I could take the stored digits, convert to hexadecimal,add more hexadecimal digits with the B-B-P algorithm, and then convertback to decimal. In both conversions, I'd have to be very cognizant ofhow much precision I end up with, but that shouldn't be too difficult.It might go faster if I store hexadecimal digits, as well as decimaldigits, to eliminate one of those conversions at each increase in thenumber of digits.The next step would be to set up an application that allowed anyone toping for digits across the Internet, and would return them if they'restored.Hasn't someone already done that? It seems as if someone would have.Bobby Treat-----Original Message-----> Could you tell me the CPU you used and its speed etc...i am curious,to> other programs out there.> I used one processor of a dual 1GH Mac and got the same answer withthe> following speed:> 4.2 for Mac OS X (June 4, 2002)> oldmax = $MaxPrecision> 6> 1. 10> $MaxPrecision = Infinity> Infinity> With[{n = 2^26}, Timing[> pd = RealDigits[N[Pi, n + 1], 10, 20,> 19 - n]; ]]> {28794.1 Second, Null}> MaxMemoryUsed[]> 512055204> pd> {{3, 3, 8, 6, 3, 2, 2, 0, 8, 9, 6, 2, 2, 3,> 4, 0, 9, 8, 0, 3}, -67108844}> Tom Burton ==== I've been trying to get my Mathematica 4.1 properly configured. I set:######################################################### ##########/usr/local/mathematica/SystemFiles/FrontEnd/ TextResources/X/Specific.tr: @@resource maxForXListFonts 10000# xlsfonts | wc -l 5572/etc/X11/XF86Config: FontPath /usr/X11R6/lib/X11/fonts/100dpi:unscaled FontPath /usr/X11R6/lib/X11/fonts/75dpi:unscaled FontPath /usr/X11R6/lib/X11/fonts/CID FontPath /usr/X11R6/lib/X11/fonts/Speedo FontPath /usr/X11R6/lib/X11/fonts/Type1 FontPath /usr/X11R6/lib/X11/fonts/URW FontPath /usr/X11R6/lib/X11/fonts/kwintv:unscaled FontPath /usr/X11R6/lib/X11/fonts/latin2/Type1 FontPath /usr/X11R6/lib/X11/fonts/local/mma/Type1 FontPath /usr/X11R6/lib/X11/fonts/local/mma/X:unscaled FontPath /usr/X11R6/lib/X11/fonts/misc:unscaled FontPath /usr/X11R6/lib/X11/fonts/misc/sgi:unscaled FontPath /usr/X11R6/lib/X11/fonts/truetype FontPath /usr/X11R6/lib/X11/fonts/uni:unscaled# ls -R /usr/X11R6/lib/X11/fonts/ | grep //usr/X11R6/lib/X11/fonts/:/usr/X11R6/lib/X11/fonts/100dpi: /usr/X11R6/lib/X11/fonts/75dpi:/usr/X11R6/lib/X11/fonts/CID:/ usr/X11R6/lib/X11/fonts/Speedo:/usr/X11R6/lib/X11/fonts/Type1 :/usr/X11R6/lib/X11/fonts/URW:/usr/X11R6/lib/X11/fonts/ encodings:/usr/X11R6/lib/X11/fonts/encodings/large:/usr/X11R6 /lib/X11/fonts/kwintv:/usr/X11R6/lib/X11/fonts/latin2:/usr/ X11R6/lib/X11/fonts/latin2/Type1:/usr/X11R6/lib/X11/fonts/ local:/usr/X11R6/lib/X11/fonts/local/mma:/usr/X11R6/lib/X11/ fonts/local/mma/Type1:/usr/X11R6/lib/X11/fonts/local/mma/X:/ usr/X11R6/lib/X11/fonts/misc:/usr/X11R6/lib/X11/fonts/misc/ sgi:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/ fonts/uni:/usr/X11R6/lib/X11/fonts/util:##################### ###################################When I open the Mathematica Book Reference Guide in the Help Browser, I get a beep and the message says:Unable to find font with family Helvetica, weight Bold, slant Plain, and size 26. Substituting Courier.Compared to the things which *were* broken, this is a minor problem. I can live with the beep. What I would now like to know is how to tell Mathematica what fonts to use by default. This seemingly simple question seems to have no simple answer. Could someone please help me.TIA,^LReply-To: kuska@informatik.uni-leipzig.de ==== I expect that the Helvetica request comes from theFrontend menues and this is lited I your X resources$TopDirectory/SystemFiles/FontEnd/SystemResources/X /XMathematicarequest the helvetica font:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!! GENERAL GUI STYLE / COLOR SETTINGS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!! Choose your GUI widget background color.! CDE: Comment this out.*background: #c0c0c0! Choose a font for buttons/text fields, etc.! You can use xfontsel to get a listing of fonts.!*Menu*fontList: -*-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*! Or just set all the fonts at once.*fontList: -*-helvetica-medium-r-*-*-*-100-*-*-*-*-*-* Jens> I've been trying to get my Mathematica 4.1 properly configured.> I set:> ############################################################## #####> /usr/local/mathematica/SystemFiles/FrontEnd/TextResources/X/ Specific.tr:> @@resource maxForXListFonts> 10000> # xlsfonts | wc -l> 5572> /etc/X11/XF86Config:> FontPath /usr/X11R6/lib/X11/fonts/100dpi:unscaled> FontPath /usr/X11R6/lib/X11/fonts/75dpi:unscaled> FontPath /usr/X11R6/lib/X11/fonts/CID> FontPath /usr/X11R6/lib/X11/fonts/Speedo> FontPath /usr/X11R6/lib/X11/fonts/Type1> FontPath /usr/X11R6/lib/X11/fonts/URW> FontPath /usr/X11R6/lib/X11/fonts/kwintv:unscaled> FontPath /usr/X11R6/lib/X11/fonts/latin2/Type1> FontPath /usr/X11R6/lib/X11/fonts/local/mma/Type1> FontPath /usr/X11R6/lib/X11/fonts/local/mma/X:unscaled> FontPath /usr/X11R6/lib/X11/fonts/misc:unscaled> FontPath /usr/X11R6/lib/X11/fonts/misc/sgi:unscaled> FontPath /usr/X11R6/lib/X11/fonts/truetype> FontPath /usr/X11R6/lib/X11/fonts/uni:unscaled> # ls -R /usr/X11R6/lib/X11/fonts/ | grep /> /usr/X11R6/lib/X11/fonts/:> /usr/X11R6/lib/X11/fonts/100dpi:> /usr/X11R6/lib/X11/fonts/75dpi:> /usr/X11R6/lib/X11/fonts/CID:> /usr/X11R6/lib/X11/fonts/Speedo:> /usr/X11R6/lib/X11/fonts/Type1:> /usr/X11R6/lib/X11/fonts/URW:> /usr/X11R6/lib/X11/fonts/encodings:> /usr/X11R6/lib/X11/fonts/encodings/large:> /usr/X11R6/lib/X11/fonts/kwintv:> /usr/X11R6/lib/X11/fonts/latin2:> /usr/X11R6/lib/X11/fonts/latin2/Type1:> /usr/X11R6/lib/X11/fonts/local:> /usr/X11R6/lib/X11/fonts/local/mma:> /usr/X11R6/lib/X11/fonts/local/mma/Type1:> /usr/X11R6/lib/X11/fonts/local/mma/X:> /usr/X11R6/lib/X11/fonts/misc:> /usr/X11R6/lib/X11/fonts/misc/sgi:> /usr/X11R6/lib/X11/fonts/truetype:> /usr/X11R6/lib/X11/fonts/uni:> /usr/X11R6/lib/X11/fonts/util:> ########################################################> When I open the Mathematica Book Reference Guide in the Help Browser, I get> a beep and the message says:> Unable to find font with family Helvetica, weight Bold, slant Plain, and> size 26. Substituting Courier.> Compared to the things which *were* broken, this is a minor problem. I can> live with the beep. What I would now like to know is how to tell Mathematica what> fonts to use by default. This seemingly simple question seems to have no> simple answer.> Could someone please help me.> TIA,> ^L ==== > I expect that the Helvetica request comes from the> Frontend menues and this is lited I your X resources> $TopDirectory/SystemFiles/FontEnd/SystemResources/X/ XMathematica$PreferencesDirectory? This is where I expected to find this kind of thing in the first place. The idea of chaning user preferences in a system file bothers me.> request the helvetica font:> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!> !> ! GENERAL GUI STYLE / COLOR SETTINGS> !> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!> ! Choose your GUI widget background color.> ! CDE: Comment this out.> *background: #c0c0c0> ! Choose a font for buttons/text fields, etc.> ! You can use xfontsel to get a listing of fonts.> !*Menu*fontList: -*-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*> ! Or just set all the fonts at once.> *fontList: -*-helvetica-medium-r-*-*-*-100-*-*-*-*-*-*I still don't know why Mathematica would ship with the font defaults arranged in such a way as to cause it to give me errors when viewing the help files. It makes me think something is still amiss. Were they expecting my system to have these already installed? Should I have other fonts installed? Where would I get them, if I wanted them?> Jens> STH ==== I have spent far more time attempting to get Mathematica configured than I have using it. I've found the the product to be exceptionally difficult to As an example, I spent several hours trying to figure out how to tell Mathematica to understand the delete key in the way most contemporary systems understand it. I wanted to avoid modifying system configuration files such as:/usr/local/mathematica/SystemFiles/FrontEnd/TextResources/ KeyEventTranslations.trI expected to be able to change something in my own ~/.Mathematic directory, but I could not figure out an obvious way to affect this modification. I want to adjust the font size used in the widgets, but again, I see no ovbious means of modifying these attributes. I suspect it can be accomplished by modifying the ~/.Mathematica/4.1/FrontEnd/init.m. Perhaps to an experienced Mathematica user, the syntax and semantics of this file are obvious. They aren't to me.I also find the overall look & feel of the interface to be archaic. I understand that Mathematica 4.1 was written years ago, and much of the desktops for Unix which exist today did not exist when it was written. I should be receiving Mathematica 4.2 in a few days, so perhaps these concerns will prove undounded. Something tells me that not a lot has changed in this respect.What have others observed?Reply-To: kuska@informatik.uni-leipzig.de ==== I can't understand your criticism. Open a terminal windowand type >maththe delete key work perfect, due to your terminal settings anda command line is the most modern interface I can imagine.It still comes with Mathematica 4.2 and is perfect as before. Jens> I have spent far more time attempting to get Mathematica configured than I> have using it. I've found the the product to be exceptionally difficult to> As an example, I spent several hours trying to figure out how to tell Mathematica to> understand the delete key in the way most contemporary systems understand> it. I wanted to avoid modifying system configuration files such as:> /usr/local/mathematica/SystemFiles/FrontEnd/TextResources/ KeyEventTranslations.tr> I expected to be able to change something in my own ~/.Mathematic directory,> but I could not figure out an obvious way to affect this modification. I> want to adjust the font size used in the widgets, but again, I see no> ovbious means of modifying these attributes. I suspect it can be> accomplished by modifying the ~/.Mathematica/4.1/FrontEnd/init.m. Perhaps> to an experienced Mathematica user, the syntax and semantics of this file are> obvious. They aren't to me.> I also find the overall look & feel of the interface to be archaic. I> understand that Mathematica 4.1 was written years ago, and much of the desktops for> Unix which exist today did not exist when it was written. I should be> receiving Mathematica 4.2 in a few days, so perhaps these concerns will prove> undounded. Something tells me that not a lot has changed in this respect.> What have others observed? ==== > I can't understand your criticism. Open a terminal window> and type>>math> the delete key work perfect, due to your terminal settings and> a command line is the most modern interface I can imagine.> It still comes with Mathematica 4.2 and is perfect as before.> Jens> If I could use bash to edit the command line, recall the command history, and other sorts of things that bash is good at, that would make the command line attractive. There *are* certain advantages to the gui side of things. For example the M-k code completion. That can really speed things up with languages such as Java and C++. I don't believe there is any fundamental reason such a thing could not exist with the command line. IMHO, a well conceived XEmacs lisp package could provide a wonderful frontend. I played around with mma.el for a few minutes, but it wasn't acting like a normal XEmacs package, so I switched back to cursing the Mod1<->Ctrl inversion of the Mathematica frontend.gui front end, get in the way of what really matters. The last thing I Mathematica. What I want to do is improve the overal experience for all of us.STH ==== Dear friendsI have the following problem with Legend and LogPlot and LogPlotPlot: Needs[Graphics`Graphics`]Needs[Graphics`Legend`]{q1[t _],q2[t_],q3[t_]}={0.1 Exp[-0.02 t], 0.2 Exp[-0.025 t], 0.4 Exp[-0.028 t]};(*With Plot legend works fine*)Plot[{q1[t],q2[t],q3[t]}, {t, 0, 100},PlotStyle[Rule]{ {AbsoluteThickness[0.5], AbsoluteDashing[{4,4}]}, AbsoluteThickness[1.5], {AbsoluteThickness[2], AbsoluteDashing[{1,8}]}}, AxesLabel[Rule]{Y, X}, PlotLabel[Rule]Title, PlotLegend[Rule]{1,3,5}, LegendPosition[Rule] {0.5,0}](*However with LogPlot or LogLogPlot the legend desappear*)LogLogPlot[{q1[t],q2[t],q3[t]}, {t, 0, 100},PlotStyle[Rule]{ {AbsoluteThickness[0.5], AbsoluteDashing[{4,4}]}, AbsoluteThickness[1.5], {AbsoluteThickness[2], AbsoluteDashing[{1,8}]}}, AxesLabel[Rule]{Y, X}, PlotLabel[Rule]Title, PlotLegend[Rule]{1,3,5}, LegendPosition[Rule] {0.5,0}]I have shown a particular case, but I has this problem always with Legend and LogPlot and LogPlotPlot. I will appreciate any help.GuillermoSanchez------------------------------------ ---------This message was sent using Endymion MailMan. ==== IIRC, there is a way to get a list of all the symbols defined in the currently running session. I can't seem to find the reference to that command. Could somone point me in the direction of documentation which will tell me how to get information about the current session?TIA,Reply-To: kuska@informatik.uni-leipzig.de ==== Mathematica's PostScript does not need a 3d graphics cardand will not use it.Only the RealTime3D` package make use of the 3d graphics and it'smemory. Since it make an off screen rendering it will be slow and since one must be mad to use it for 10^5 polygons it does notmatter how much graphics memory you have. The tiny polygon countsof Plot3D[] & friends can be handled wit 8 MByte :-)MathGL3d will run fine (not fast) with 8 MByte. For the mostMathGL3d applications 64 MByte sufficient.With more than 10^6 polygons or many huge (1024^2) textures you mayrun into problems. For the MathGL3d development I have GeForce 3/4 cardswith 128 MByte RAM.BTW the RAM of the 3d graphics cards is for textures and Mathematicadoes not know what a texture is or how usefull it is for scientificvisualization. Jens> We are about to order new PCs for a university student lab in which> Mathematica will be installed. Of course they will be using 2D and 3D> graphics -- plots of surfaces, e.g. Sooner or later students will want> to rotate such plots, too.> An unresolved issue is how much graphics RAM to get. On existing> machines we typically have 64MB. But for the PCs we are looking at,> manufacturer's limits on graphics RAM, rather than cost, seems to limit> us to 32 MB.> Is 32 MB adequate not just now, but likely to be adequate as well for> the near future (say, a 3- to 5-year equipment lifetime)?> --> Murray Eisenberg murray@math.umass.edu> Mathematics & Statistics Dept.> Lederle Graduate Research Tower phone 413 549-1020 (H)> University of Massachusetts 413 545-2859 (W)> 710 North Pleasant Street> Amherst, MA 01375Reply-To: kuska@informatik.uni-leipzig.de ==== Names[Global`*]?? Jens> IIRC, there is a way to get a list of all the symbols defined in the> currently running session. I can't seem to find the reference to that> command. Could somone point me in the direction of documentation which> will tell me how to get information about the current session?> TIA, ==== To get a complete list of all variables that have been defined for thecurrent Mathematica session, please try:?`*which should return a list of all variables that have been defined for thecurrent Mathematica session.Steven Shippee ==== > IIRC, there is a way to get a list of all the symbols defined in the> currently running session. I can't seem to find the reference to that> command. Could somone point me in the direction of documentation which> will tell me how to get information about the current session?> TIA,Let's begin with a fresh sessionQuitMake some entries, notice that b, x and y have no definitions - they aresimply created. a=3; b; p= 3x +1; f[y_]:=y^2;We can find all the symbols we have created so far. Names[`*] {a,b,f,p,x,y}Actually, they are the strings of the symbols (otherwise, for example, awould immediately evaluate to 3). InputForm[%] {a, b, f, p, x, y}How can we take out the strings of the undefined symbols?I make a function that test if the symbol has been defined (or has anattribute assigned): SetAttributes[definedQ, HoldFirst]; definedQ[x_String]:= Or[DownValues@@#=!={}, UpValues@@#=!={},OwnValues@@#=!={}, SubValues@@#=!={},DefaultValues@@#=!={},NValues@@#=!={}, Attributes@@#=!={}]&[ ToExpression[x, InputForm, Hold]] definedQ[x_]:= definedQ[Evaluate[ToString[Unevaluated[x]]]]Using this we get Select[Names[`*], definedQ] {a,definedQ,f,p}To get information about the symbolsInformation/@Select[Names[`*], definedQ]; a a = 3 definedQ Attributes[definedQ] = {HoldFirst} definedQ[x_String] := (DownValues @@ #1 =!= {} || UpValues @@ #1 =!= {} || OwnValues @@ #1 =!= {} || SubValues @@ #1 =!= {} || DefaultValues @@ #1 =!= {} || NValues @@ #1 =!= {} & )[ToExpression[x, InputForm, Hold]] definedQ[x_] := definedQ[Evaluate[ ToString[Unevaluated[x]]]] f f[y_] := y^2 p p = 1 + 3*xI have assumed that you are interested only in the symbols in the symbols inthe default context Global`.Other context can be provided for.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198 ==== There are several ways (note that newly defined things are by default inGlobal` context) , one would be ?@bye,Borut| IIRC, there is a way to get a list of all the symbols defined in the| currently running session. I can't seem to find the reference to that| command. Could somone point me in the direction of documentation which| will tell me how to get information about the current session?||| TIA,| ==== Dear all,As far as I understand, FindMinimum can be requested to use theBerndt-Hall-Hall-Hausman method, if the option Method->QuasiNewton is specified. I am pretty convinced that there is no way to tellmathematica to produce as an output the Jacobian vector and the Hessianmatrix at every step. In addition, I have not found a way to specify theDavidon-Fletcher-Powell algorithm to be used.Before I start to program it myself, I was wondering if anybody has writtensome [non-commercial] code that produces such an output for BFGS and evenbetter for DFP optimization.Kyriakos _____+**+____+**+___+**+__+**+_Kyriakos ChourdakisLecturer in Financial EconomicsURL: http://www.qmw.ac.uk/~te9001tel: (++44) (+20) 7882 5086Dept of EconomicsUniversity of London, QMLondon E1 4NSU.K. ==== Both Simplify and ImpliesQ need the assumption that all variablesare real in order to use the CAD algorithm. However, Simplifyuses many other methods trying to simplify each subexpressionof the input, while ImpliesQ only tries to prove that the wholeinput is implied by the assumptions.Here is the series of simplifications that Simplify does in thisexample.- An inequality simplification heuristic using the inequality assumption y6 >= -1 is applied to the whole system. We getsimplification:y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6 -> 1 + y4 >= 0 && y5 >= y6 && 1 + y4 + y6 >= y5- We go into simplification of subexpressions, and get thesesimplifications using reduction modulo a GroebnerBasis ofequation assumptions y4 == -1 and y5 == y6 (Simplify keepsthe result of this transformation even if it has the samecomplexity as the original expression.)1 + y4 -> 0y5 -> y61 + y4 + y6 -> y6y5 -> y6- As the result of subexpression simplifications the three inequalities become then:1 + y4 >= 0 -> 0 >= 0y5 >= y6 -> y6 >= y61 + y4 + y6 >= y5 -> y6 >= y6- 0 >= 0 evaluates to True, y6 >= y6 is simplified to True using transformation x >= y -> x - y >= 0.Adam StrzebonskiWolfram Research> That makes everything clear, except for just one small mystery:> In[1]:=> << Experimental`> In[2]:=> FullSimplify[y4 >= -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6]> Out[2]=> True> In[3]:=> ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6,> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[3]=> False> I now understand why the last one returns False, but why does the> second one return True? Should not the same arument apply in both> cases? Or is it because FullSimplify does not actually need the> assumption that the variables are real while ImliesQ does?> Andrzej> Actually, the reason why ImpliesQ (and FullSimplify) fail to> prove the implication is not that the hypothesis is a disjunction.> To use the cylindrical algebraic decomposition algorithm they> need to know that the assumptions imply that all variables are> real.> The assumptions mechanism infers variable domains in a purely> syntactical way, i.e. v is assumed to be real if there is> an Element[v, Reals] statement or v appears in an inequality.> It does not attempt to analyze assumptions further, to figure> out that, say y6 >= -1 implies that y6 is real, and then if> we have y5 == y6 then y5 must be real too. Doing such an analysis> in general would require solving the assumptions over complex> numbers, and then finding out which variables need to be real.> This would be in general too time consuming to do, but analyzing> linear dependencies like the ones in your example is a possible> future improvement.> ImpliesQ cannot prove the implication here, because it knows only> that y6 is real.> In[1]:= < In[2]:= ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6,> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[2]= False> If we add an explicit assumption that y4 and y5 are real, ImpliesQ> (and FullSimplify) can prove this implication, and the full version> of your example.> In[3]:= ImpliesQ[Element[y4|y5, Reals] && y4 == -1 && y6 >= -1 && y5 ==> y6,> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[3]= True> In[4]:= ImpliesQ[Element[y4|y5, Reals] && (y4 == -1 && y6 >= -1 &&> y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6),> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[4]=> True> In[5]:= FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> Element[y4|y5, Reals] && (y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6)]> Out[5]=> True> Adam Strzebonski> Wolfram Research> On second thoughts I realized that there seems to be an inherent> ambiguity about what one coudl mean by using alternatives (statements> joned by Or) assumptions. In fact it now seems to me that the> reasonable intertpretation for ImpliesQ and FullSimplify ought to> perhaps be different. It seems to me that ImpliesQ[Or[a,b],c] ought to> return True if aand only if ImpliesQ[a,c] and ImpliesQ[b,c] both> return> True. If so this could be acomplished by adding the rule> ImpliesQ[Or[a,b],c] = And[ImpliesQ[a,c],ImpliesQ[b,c]]. That could> then> be used in proving that the two answers to the system of inequalities> that of Vincent's original posting are equivalent. On the other hand> probably FullSimplify[a, Or[p,q]] ought to return> Or[FullSimplify[a,p],FullSimplify[a,q]] (or do nothing as it doe> snow).> The first approach would seem to be consistent with the way> FullSimplify works with domain specifications but would however have> the strange effect of returning True if just one of the alternatives> were true and the other false. So perhaps after all it is best to> leave FullSimplify as it is. However, it seems to me that ImpliesQ> shoud be able to handle such cases (?)> Andrzej Kozlowski> Toyama International University> JAPAN> The modification to FullSimplify that I sent earlier works correctly> only for assumptions of the form Or[a,b] (and even then not is not> always what one would like). For what it's worth here is a better> (but> slow) version:> In[1]:=> Unprotect[FullSimplify];> In[2]:=> FullSimplify[expr_, x_ || y__] := FullSimplify[> FullSimplify[expr, x] || FullSimplify[expr, Or[y]]];> In[3]:=> Protect[FullSimplify];> For example:> In[4]:=> FullSimplify[Sqrt[(x - 1)^2] + Sqrt[(x - 2)^2] +> Sqrt[(x - 3)^2], x > 1 || x > 2 || x > 3]> Out[4]=> -1 + x + Abs[-3 + x] + Abs[-2 + x] ||> -3 + 2*x + Abs[-3 + x] || 3*(-2 + x)> Andrzej Kozlowski> Toyama International University> JAPAN> On Thursday, September 26, 2002, at 11:14 AM, Andrzej Kozlowski> The reason why InequalitySolve returns it's answer in what sometimes> turns out to be unnecessarily complicated form is that the> underlying> algorithm, Cylindrical Agebraic Decomposition (CAD) returns its> answers in this form. Unfortunately it seems to me unlikely that a> simplification of the kind you need can be can be accomplished in> any> general way. To see why observe the following. First of all:> In[1]:=> FullSimplify[x > 0 || x == 0]> Out[1]=> x >= 0> This is fine. However:> In[2]:=> FullSimplify[x > 0 && x < 2 || x == 0 && x < 2]> Out[2]=> x == 0 || 0 < x < 2> Of course what you would like is simply 0 <= x < 2. One reason why> you can't get it is that while Mathematica can perform a> LogicalExpand, as in:> In[3]:=> LogicalExpand[(x > 0 || x == 0) && x < 2]> Out[3]=> x == 0 && x < 2 || x > 0 && x < 2> There i no LogicalFactor or anything similar that would reverse> what LogicalExpand does. if there was then you could perform the> sort> of simplifications you need for:> In[4]:=> FullSimplify[(x > 0 || x == 0) && x < 2]> Out[4]=> 0 <= x < 2> However, it does not seem to me very likely that such logical> factoring can be performed by a general enough algorithm (though I> am no expert in this field). In any case, certainly Mathematica> can't> do this.> I also noticed that Mathematica seems unable to show that the answer> it returns to your problem is actually equivalent to your simpler> one. In fact this looks like a possible bug in Mathematica. Let's> first try the function ImpliesQ from the Experimental context:> << Experimental`> Now Mathematica correctly gives:> In[6]:=> ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <=> y5> <= 1 + y4 + y6]> Out[6]=> True> However:> In[7]:=> ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +> y4 + y6]> Out[7]=> False> That simply means that ImpliesQ cannot show the implication, not> that> it does not hold. ImpliesQ relies on CAD, as does FullSimplify.> Switching to FullSimplify we see that:> In[8]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1> &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +> y4 + y6]> Out[8]=> True> while> In[9]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <=> y5> <= 1 + y4 + y6]> Out[9]=> y4 >= -1 && y6 <= y5 <= 1 + y4 + y6> On the other hand, taking just the individual summands of Or as> hypotheses;> In[10]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[10]=> True> In[11]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 ]> Out[11]=> True> In fact FullSimplify is unable to use Or in assumptions, which can> be> demonstrated on an abstract example:> In[12]:=> FullSimplify[C,(A||B)&&(C)]> Out[12]=> True> In[13]:=> FullSimplify[C,LogicalExpand[(A||B)&&(C)]]> Out[13]=> C> This could be fixed by modifying FullSimplify:> In[14]:=> Unprotect[FullSimplify];> In[14]:=> FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify> [e> xpr,y]];> In[15]:=> Protect[FullSimplify];> Now at least we get as before:> In[16]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1> &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +> y4 + y6]> Out[16]=> True> but also:> In[17]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <=> y5> <= 1 + y4 + y6]> Out[17]=> True> This seems to me a possible worthwhile improvement in FullSimplify,> though of course not really helpful for your problem.> Andrzej Kozlowski> Toyama International University> JAPAN> On Wednesday, September 25, 2002, at 02:51 PM, Vincent Bouchard> I have a set of inequalities that I solve with InequalitySolve. But> then> it gives a complete set of solutions, but not in the way I would> like it> to be! :-) For example, the simple following calculation will give:> In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6> = -1};> InequalitySolve[ineq,{y4,y6,y5}]> Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6> the result is good, but I would like it to be in the simpler but> equivalent form> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6> How can I tell InequalitySolve to do that? It is simple for this> example,> but for a large set of simple inequalities InequalitySolve gives> lines and> lines of results instead of a simple result.> Vincent Bouchard> Andrzej Kozlowski> Toyama International University> JAPAN ==== That makes everything clear, except for just one small mystery:In[1]:=<< Experimental`In[2]:=FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6]Out[2]=TrueIn[3]:=ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[3]=FalseI now understand why the last one returns False, but why does the second one return True? Should not the same arument apply in both cases? Or is it because FullSimplify does not actually need the assumption that the variables are real while ImliesQ does?Andrzej> Actually, the reason why ImpliesQ (and FullSimplify) fail to> prove the implication is not that the hypothesis is a disjunction.> To use the cylindrical algebraic decomposition algorithm they> need to know that the assumptions imply that all variables are> real.> The assumptions mechanism infers variable domains in a purely> syntactical way, i.e. v is assumed to be real if there is> an Element[v, Reals] statement or v appears in an inequality.> It does not attempt to analyze assumptions further, to figure> out that, say y6 >= -1 implies that y6 is real, and then if> we have y5 == y6 then y5 must be real too. Doing such an analysis> in general would require solving the assumptions over complex> numbers, and then finding out which variables need to be real.> This would be in general too time consuming to do, but analyzing> linear dependencies like the ones in your example is a possible> future improvement.> ImpliesQ cannot prove the implication here, because it knows only> that y6 is real.> In[1]:= < In[2]:= ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6,> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[2]= False> If we add an explicit assumption that y4 and y5 are real, ImpliesQ> (and FullSimplify) can prove this implication, and the full version> of your example.> In[3]:= ImpliesQ[Element[y4|y5, Reals] && y4 == -1 && y6 >= -1 && y5 ==> y6,> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[3]= True> In[4]:= ImpliesQ[Element[y4|y5, Reals] && (y4 == -1 && y6 >= -1 &&> y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6),> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[4]=> True> In[5]:= FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> Element[y4|y5, Reals] && (y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6)]> Out[5]=> True> Adam Strzebonski> Wolfram Research On second thoughts I realized that there seems to be an inherent> ambiguity about what one coudl mean by using alternatives (statements> joned by Or) assumptions. In fact it now seems to me that the> reasonable intertpretation for ImpliesQ and FullSimplify ought to> perhaps be different. It seems to me that ImpliesQ[Or[a,b],c] ought to> return True if aand only if ImpliesQ[a,c] and ImpliesQ[b,c] both > return> True. If so this could be acomplished by adding the rule> ImpliesQ[Or[a,b],c] = And[ImpliesQ[a,c],ImpliesQ[b,c]]. That could > then> be used in proving that the two answers to the system of inequalities> that of Vincent's original posting are equivalent. On the other hand> probably FullSimplify[a, Or[p,q]] ought to return> Or[FullSimplify[a,p],FullSimplify[a,q]] (or do nothing as it doe > snow).> The first approach would seem to be consistent with the way> FullSimplify works with domain specifications but would however have> the strange effect of returning True if just one of the alternatives> were true and the other false. So perhaps after all it is best to> leave FullSimplify as it is. However, it seems to me that ImpliesQ> shoud be able to handle such cases (?) Andrzej Kozlowski> Toyama International University> JAPAN> The modification to FullSimplify that I sent earlier works correctly> only for assumptions of the form Or[a,b] (and even then not is not> always what one would like). For what it's worth here is a better > (but> slow) version: In[1]:=> Unprotect[FullSimplify]; In[2]:=> FullSimplify[expr_, x_ || y__] := FullSimplify[> FullSimplify[expr, x] || FullSimplify[expr, Or[y]]]; In[3]:=> Protect[FullSimplify]; For example: In[4]:=> FullSimplify[Sqrt[(x - 1)^2] + Sqrt[(x - 2)^2] +> Sqrt[(x - 3)^2], x > 1 || x > 2 || x > 3] Out[4]=> -1 + x + Abs[-3 + x] + Abs[-2 + x] ||> -3 + 2*x + Abs[-3 + x] || 3*(-2 + x) Andrzej Kozlowski> Toyama International University> JAPAN On Thursday, September 26, 2002, at 11:14 AM, Andrzej Kozlowski The reason why InequalitySolve returns it's answer in what sometimes> turns out to be unnecessarily complicated form is that the > underlying> algorithm, Cylindrical Agebraic Decomposition (CAD) returns its> answers in this form. Unfortunately it seems to me unlikely that a> simplification of the kind you need can be can be accomplished in > any> general way. To see why observe the following. First of all: In[1]:=> FullSimplify[x > 0 || x == 0] Out[1]=> x >= 0 This is fine. However: In[2]:=> FullSimplify[x > 0 && x < 2 || x == 0 && x < 2] Out[2]=> x == 0 || 0 < x < 2 Of course what you would like is simply 0 <= x < 2. One reason why> you can't get it is that while Mathematica can perform a> LogicalExpand, as in:> In[3]:=> LogicalExpand[(x > 0 || x == 0) && x < 2] Out[3]=> x == 0 && x < 2 || x > 0 && x < 2 There i no LogicalFactor or anything similar that would reverse> what LogicalExpand does. if there was then you could perform the > sort> of simplifications you need for: In[4]:=> FullSimplify[(x > 0 || x == 0) && x < 2] Out[4]=> 0 <= x < 2 However, it does not seem to me very likely that such logical> factoring can be performed by a general enough algorithm (though I> am no expert in this field). In any case, certainly Mathematica > can't> do this. I also noticed that Mathematica seems unable to show that the answer> it returns to your problem is actually equivalent to your simpler> one. In fact this looks like a possible bug in Mathematica. Let's> first try the function ImpliesQ from the Experimental context: << Experimental` Now Mathematica correctly gives: In[6]:=> ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= > y5> <= 1 + y4 + y6] Out[6]=> True However: In[7]:=> ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +> y4 + y6] Out[7]=> False That simply means that ImpliesQ cannot show the implication, not > that> it does not hold. ImpliesQ relies on CAD, as does FullSimplify.> Switching to FullSimplify we see that: In[8]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1> &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +> y4 + y6] Out[8]=> True while In[9]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= > y5> <= 1 + y4 + y6] Out[9]=> y4 >= -1 && y6 <= y5 <= 1 + y4 + y6 On the other hand, taking just the individual summands of Or as> hypotheses;> In[10]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6] Out[10]=> True In[11]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 ] Out[11]=> True In fact FullSimplify is unable to use Or in assumptions, which can > be> demonstrated on an abstract example:> In[12]:=> FullSimplify[C,(A||B)&&(C)] Out[12]=> True In[13]:=> FullSimplify[C,LogicalExpand[(A||B)&&(C)]] Out[13]=> C This could be fixed by modifying FullSimplify: In[14]:=> Unprotect[FullSimplify]; In[14]:=> FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify > [e> xpr,y]]; In[15]:=> Protect[FullSimplify]; Now at least we get as before: In[16]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1> &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +> y4 + y6] Out[16]=> True but also: In[17]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= > y5> <= 1 + y4 + y6] Out[17]=> True This seems to me a possible worthwhile improvement in FullSimplify,> though of course not really helpful for your problem.> Andrzej Kozlowski> Toyama International University> JAPAN> On Wednesday, September 25, 2002, at 02:51 PM, Vincent Bouchard I have a set of inequalities that I solve with InequalitySolve. But> then> it gives a complete set of solutions, but not in the way I would> like it> to be! :-) For example, the simple following calculation will give: In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6> = -1};> InequalitySolve[ineq,{y4,y6,y5}] Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6 the result is good, but I would like it to be in the simpler but> equivalent form y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6 How can I tell InequalitySolve to do that? It is simple for this> example,> but for a large set of simple inequalities InequalitySolve gives> lines and> lines of results instead of a simple result.> Vincent BouchardAndrzej KozlowskiToyama International UniversityJAPAN ==== inside a program I need to solve this linear equation in terms of p1.However something odds happens. Sometimes the solution is computed andsometimes the result is empty [I mean no output...]. Is this a bug of thesolve command or am I doing something wrong? The problem is robust to:changing name to the variables and other makeups..Davidps: Sorry for the stupid way in which I copied the command...Solve[(x^2*((-0.9*x^7*(p^2*(-1 - 5.8*x^6 - 14.010000000000002*x^12 - 18.04*x^18 - 13.06*x^24 - 5.040000000000001*x^30 - 0.81*x^36) + x*(7.777777777777779 - 9.074074074074076*x + 30.333333333333336*x^6 - 21.51851851851852*x^7 - 16.333333333333336*x^8 + 44.33333333333334*x^12 + 3.188888888888883*x^13 - 65.68333333333332*x^14 + 28.777777777777786*x^18 + 47.937037037037044*x^19 - 100.10000000000002*x^20 + 7.*x^24 + 45.6037037037037*x^25 - 69.53333333333333*x^26 + 13.299999999999999*x^31 - 19.833333333333332*x^32 - 1.0499999999999996*x^38) + p*(-6 + 8.296296296296296*x - 28.799999999999997*x^6 + 32.785185185185185*x^7 + 9.333333333333336*x^8 - 55.260000000000005*x^12 + 49.04777777777776*x^13 + 38.38333333333334*x^14 - 52.980000000000004*x^18 + 34.20518518518518*x^19 + 60.20000000000001*x^20 - 25.380000000000003*x^24 + 11.736296296296294*x^25 + 43.63333333333334*x^26 - 4.86*x^30 + 2.8999999999999986*x^31 + 13.533333333333333*x^32 + 0.81*x^37 + 1.0499999999999996*x^38)))/(x + 1.9*x^7 + 0.9*x^13)^2 - ((-1 + p - 7*x^6 + p*x^6 + 6*x^7)*(1.2962962962962965 - 3.111111111111112*x^6 + 9.333333333333336*x^7 - 10.111111111111114*x^12 + 22.05*x^13 - 5.703703703703705*x^18 + 17.15*x^19 + 5.483333333333331*x^25 + 1.0499999999999996*x^31 + p1*x^5*(7.000000000000002 - 7.000000000000002*x + 14.000000000000004*x^6 - 14.000000000000004*x^7 + 7.000000000000002*x^12 - 6.999999999999998*x^13) - 1.166666666666667*p*x^4*x1 - 3.500000000000001*p*x^10*x1 - 1.0500000000000003*p*x^11*x1 - 3.500000000000001*p*x^16*x1 - 3.150000000000001*p*x^17*x1 - 1.166666666666667*p*x^22*x1 - 3.150000000000001*p*x^23*x1 - 1.0500000000000003*p*x^29*x1))/((1 + 0.9*x^6)^2*(1 + x^6)^2)))/(p^2*(1 + x^6)^3) == 0, p1] ==== You're right; I misunderstood your problem. First of all, never use Do-- forget it exists -- and don't put the SelectionMove, etc. commandsinside a loop. That's your biggest problem.This should help:Table[Plot[ Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}}], {t, 0, 2Pi - Pi/32, Pi/32}];SelectionMove[EvaluationNotebook[], All, GeneratedCell]FrontEndTokenExecute[OpenCloseGroup] FrontEndTokenExecute[SelectionAnimate]The first time through the animation is a bit slow because the framesare being generated, but then the cell group collapses and things arebetter. I used an increment that's an exact divisor of the period inorder to catch the max and min values of Sin[t], as well as the zerovalue, on each swing. Use the period MINUS the step-size as the upperlimit in order to avoid having a last frame identical to the first.I'm a bit annoyed at the tendency for the plot to jump near zero andPi, but that's because the derivative of Sin is higher there, and we'renot compensating by picking more points there. If we do pick morepoints there, however, we won't perceive t as time. If that's not aconsideration, you could do it this way:f = Which[ -1 ? # ? 1, #, 1 < # ? 3, 2 - #, True, f@Mod[#, 4, -1] ] &;Table[Plot[ f[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}}], { t, -1, 2.9, 0.1}];SelectionMove[EvaluationNotebook[], All, GeneratedCell]FrontEndTokenExecute[OpenCloseGroup] FrontEndTokenExecute[SelectionAnimate]Bobby-----Original Message-----Put this after the Plot statement, in the same cell:SelectionMove[EvaluationNotebook[], All, GeneratedCell]FrontEndTokenExecute[OpenCloseGroup] FrontEndTokenExecute[SelectionAnimate]Bobby Treat-----Original Message-----Is it possible to tidy up the generation of the graphic so that itbecomesthe animation?I have tried the followingDo[Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}},ImageSize -> 400]; SelectionMove[EvaluationNotebook[], All, GeneratedCell];FrontEndExecute[{FrontEnd`SelectionAnimate[ 0.1]}]; FrontEndExecute[{FrontEndToken[Clear]}], {t, 0, 15, 0.1}]This works but the cell dividing line ßashes on and off spoiling theanimation and if there is anything in the cell below this jumps up anddown.Is there a proper way of doing this?Hugh Goyder ==== That's nice because it avoids watching the frames being slowly created,and the group doesn't always collapse as it should, the way I've beendoing it.However, a couple of small changes give a smoother animation with 64frames rather than 151, while GENERATING only 33 frames.Block[{$DisplayFunction = Identity, half, graphs, step = Pi/32}, half = Table[GraphicCell[Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}}, ImageSize -> 400]], {t, -Pi/2, Pi/2 - step, step}]; graphs = Rest@Join[half, Rest@Reverse@half]; NotebookWrite[EvaluationNotebook[], Cell[CellGroupData[graphs,Closed]]]; SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndExecute[{FrontEndToken[EvaluationNotebook[], SelectionAnimate]}]]Bobby-----Original Message----->showing during generation is enough (but uncontrolled).>Hugh GoyderThis creates a graphics cell from a graphics expression.GraphicCell[graphics_] := Cell[GraphicsData[PostScript, DisplayString[graphics]],Graphics]cellgroup.Block[{$ DisplayFunction=Identity, graphs}, graphs = Table[GraphicCell[ Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1,1}}, ImageSize -> 400]], {t,0,15,.1}]; NotebookWrite[EvaluationNotebook[],Cell[CellGroupData[graphs ,Closed]]]; SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndExecute[{FrontEndToken[EvaluationNotebook[], SelectionAnimate]}] ]------------------------------------------------------------ --Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== I'm woking on a kind of a Mathematica cheat-sheet. So I don't have to repeatthe same learning process if I get pulled away for another 6 months.I've attempted to get my domain name to resolve to my IP address, but it seems Verisign and I have different ideas about what 24 hours is.The site is supposed to be www.globalsymmetry.com, but that will not currently resolve. Here's the IP and path:http://66.92.149.152/proprietary/com/wri/index.html This is not a literary masterpiece. It's probably proof that giving just anybody the power to publish is, perhaps, not a guaranty that more quality publication will take place.If anybody has answers to the questions I've come up with, or comments about the answeres, etc. I'd be happy to know. ==== >>I believe the complexity is O(n log n), so this should be good enough.Umm ...good enough? I understand the words individually, but thephrase makes no sense to me.Bobby Treat-----Original Message-----> crash the Front End. I was thinking about the fact that I calculated> all those digits and then threw them away. I could save them withSave> or DumpSave, and read them in with Get the next time I wanted any of> them, although the file would be close to 70 MB (if not more). I maydo> that, in fact -- I have plenty of disk space.> The next step would be to somehow reuse the stored digits if I wanted> MORE digits. But how?> The Bailey-Borwein-Plouffe Pi algorithm is an avenue of attack, sinceit> can calculate digits far from the decimal point, without calculating> those in between. Unfortunately, it calculates hexadecimal digits in> that way, not decimal digits. (That's true for the version I've seen,> anyway.) Still, I could take the stored digits, convert tohexadecimal,> add more hexadecimal digits with the B-B-P algorithm, and then convert> back to decimal. In both conversions, I'd have to be very cognizantof> how much precision I end up with, but that shouldn't be too difficult.> It might go faster if I store hexadecimal digits, as well as decimal> digits, to eliminate one of those conversions at each increase in the> number of digits.> The next step would be to set up an application that allowed anyone to> ping for digits across the Internet, and would return them if they're> stored.> Hasn't someone already done that? It seems as if someone would have.> Bobby TreatIf you're interested in decimal digits, I don't think the BBP algorithmis theway to go. In order to get the nth decimal digit of Pi you need tocompute theprevious n-1 digits, since base conversion is global, not local. ThealgorithmMathematica uses for computing Pi is quite fast - I believe thecomplexity is O(nlog n), so this should be good enough.David> -----Original Message-----calculation in> So would it take about the same amont of time for the completeprintout> of digits? Of course it would take a few additional seconds to format> the output...> Or does Mathematica take alot less time when it truncates the output?> Could you tell me the CPU you used and its speed etc...i amcurious,performance> to> other programs out there.> I used one processor of a dual 1GH Mac and got the same answer with> the> following speed:> 4.2 for Mac OS X (June 4, 2002)> oldmax = $MaxPrecision> 6> 1. 10> $MaxPrecision = Infinity> Infinity> With[{n = 2^26}, Timing[> pd = RealDigits[N[Pi, n + 1], 10, 20,> 19 - n]; ]]> {28794.1 Second, Null}> MaxMemoryUsed[]> 512055204> pd> {{3, 3, 8, 6, 3, 2, 2, 0, 8, 9, 6, 2, 2, 3,> 4, 0, 9, 8, 0, 3}, -67108844}> Tom Burton ==== Edit ->Preferences -> Font OptionsIn Preferences you will find everything you need to configure yourMathematica environment. Also you may want to look up Style Sheets in thebook or the on line help.Yas> I've been trying to get my Mathematica 4.1 properly configured.> I set:> ############################################################# ######> /usr/local/mathematica/SystemFiles/FrontEnd/TextResources/X/ Specific.tr:> @@resource maxForXListFonts> 10000> # xlsfonts | wc -l> 5572> /etc/X11/XF86Config:> FontPath /usr/X11R6/lib/X11/fonts/100dpi:unscaled> FontPath /usr/X11R6/lib/X11/fonts/75dpi:unscaled> FontPath /usr/X11R6/lib/X11/fonts/CID> FontPath /usr/X11R6/lib/X11/fonts/Speedo> FontPath /usr/X11R6/lib/X11/fonts/Type1> FontPath /usr/X11R6/lib/X11/fonts/URW> FontPath /usr/X11R6/lib/X11/fonts/kwintv:unscaled> FontPath /usr/X11R6/lib/X11/fonts/latin2/Type1> FontPath /usr/X11R6/lib/X11/fonts/local/mma/Type1> FontPath /usr/X11R6/lib/X11/fonts/local/mma/X:unscaled> FontPath /usr/X11R6/lib/X11/fonts/misc:unscaled> FontPath /usr/X11R6/lib/X11/fonts/misc/sgi:unscaled> FontPath /usr/X11R6/lib/X11/fonts/truetype> FontPath /usr/X11R6/lib/X11/fonts/uni:unscaled> # ls -R /usr/X11R6/lib/X11/fonts/ | grep /> /usr/X11R6/lib/X11/fonts/:> /usr/X11R6/lib/X11/fonts/100dpi:> /usr/X11R6/lib/X11/fonts/75dpi:> /usr/X11R6/lib/X11/fonts/CID:> /usr/X11R6/lib/X11/fonts/Speedo:> /usr/X11R6/lib/X11/fonts/Type1:> /usr/X11R6/lib/X11/fonts/URW:> /usr/X11R6/lib/X11/fonts/encodings:> /usr/X11R6/lib/X11/fonts/encodings/large:> /usr/X11R6/lib/X11/fonts/kwintv:> /usr/X11R6/lib/X11/fonts/latin2:> /usr/X11R6/lib/X11/fonts/latin2/Type1:> /usr/X11R6/lib/X11/fonts/local:> /usr/X11R6/lib/X11/fonts/local/mma:> /usr/X11R6/lib/X11/fonts/local/mma/Type1:> /usr/X11R6/lib/X11/fonts/local/mma/X:> /usr/X11R6/lib/X11/fonts/misc:> /usr/X11R6/lib/X11/fonts/misc/sgi:> /usr/X11R6/lib/X11/fonts/truetype:> /usr/X11R6/lib/X11/fonts/uni:> /usr/X11R6/lib/X11/fonts/util:> ########################################################> When I open the Mathematica Book Reference Guide in the Help Browser, I get> a beep and the message says:> Unable to find font with family Helvetica, weight Bold, slant Plain, and> size 26. Substituting Courier.> Compared to the things which *were* broken, this is a minor problem. I can> live with the beep. What I would now like to know is how to tell Mathematica what> fonts to use by default. This seemingly simple question seems to have no> simple answer.> Could someone please help me.> TIA,> ^L ==== > Edit ->Preferences -> Font Options> In Preferences you will find everything you need to configure your> Mathematica environment. Also you may want to look up Style Sheets in the> book or the on line help.> Yas> I went into the preferences browser, and it was not clear to me what I was modifying. At one point I clicked on a field filled with text. I had inteded to edit it, and all the text vanished. It didn't bother me as much as such things use to, because I believe I know a backout strategy. It's been a while since I looked at this stuff, and I have to admit it seems far more tractible than it did a year ago. I'll look at the discussion again, and see if it makes more sence to me now.STH ==== > As an example, I spent several hours trying to figure out how to tell> Mathematica to understand the delete key in the way most contemporary> systems understand it. I wanted to avoid modifying system> configuration files such as:> /usr/local/mathematica/SystemFiles/FrontEnd/TextResources/ KeyEventTranslations.tr> I expected to be able to change something in my own ~/.Mathematic> directory, but I could not figure out an obvious way to affect this> modification.If you could post a precise description of what you expect the Delete keyto do when depressed, we could probably provide you with a clear cutanswer of what needs to be done.> I want to adjust the font size used in the widgets, but again, I see> no ovbious means of modifying these attributes. I suspect it can be> accomplished by modifying the ~/.Mathematica/4.1/FrontEnd/init.m.> Perhaps to an experienced Mathematica user, the syntax and semantics> of this file are obvious. They aren't to me.The size of fonts in user interface elements is not specified through theMathemtica init.m file. It is set through an X resource. If you are notfamiliar with resources, you may want to track down an introductory texton the X Window System. Information on application-specific resourcesettings can be found in the Mathematica Getting Started Guide:http://documents.wolfram.com/v4/GettingStarted/ TroubleshootingUnixX.htmlThe setting that you would need to adjust is XMathematica*fontList. Thevalue of the resource is an X Logical Font Description field.> I also find the overall look & feel of the interface to be archaic.That's because Mathematica relies on the Motif library for user interfaceelements.http://www.opengroup.org/desktop/ motif.htmlThe appearance of these elements, such as the menu and scroll bars, wouldbe the same for any other Motif application, such as the DDD debugger orreleases of Netscape prior to verison 4.-- User Interface Programmer paulh@wolfram.comWolfram Research, Inc. ==== hi,> I sholdn't have to. If I start messing with X resource settings for my> user environment, I am sure to break something else which is configured> based on the current settings. There should either be a GUI interface, or a> clearly documented, and easily accessible configuration file to modify such> properties as the size of the fonts in the GUI widgets. This is> functionality which is rightfully expected of a modern desktop UI.[snip]> And I'm sure there is some configuration file in which I could place that,> and hope that what you think will be read by my system *will* in fact be> read, and not subsequently overridden during xsession startup. Things> aren't the way they used to be back in the 1980s. The modern Unix desktop> has moved beyond the paradigm of openlook and motif. See for example> http://www.trolltech.com, http://www.gnome.org, and http://www.kde.orgmoving the frontend over to QT would have some neat side effects: consistent look & feel with the modern linux gui, themeability, source code truetype fonts as QT supports Xrender and Xft (looks great - see KDE3). i think all of those points are of value, but the most important might be source compatibility. ONE frontend for MOST (or ALL) platforms - sounds like a dream :-))gerald -- *************************************Gerald RothM@th Desktop Development************************************* ==== > If you could post a precise description of what you expect the Delete key> to do when depressed, we could probably provide you with a clear cut> answer of what needs to be done.Item[KeyEvent[Delete], DeleteNext]'Most' means Ômore than half.' > I want to adjust the font size used in the widgets, but again, I see> no ovbious means of modifying these attributes. I suspect it can be> accomplished by modifying the ~/.Mathematica/4.1/FrontEnd/init.m.> Perhaps to an experienced Mathematica user, the syntax and semantics> of this file are obvious. They aren't to me.> The size of fonts in user interface elements is not specified through the> Mathemtica init.m file. It is set through an X resource. If you are not> familiar with resources, you may want to track down an introductory text> on the X Window System. I sholdn't have to. If I start messing with X resource settings for my user environment, I am sure to break something else which is configured based on the current settings. There should either be a GUI interface, or a clearly documented, and easily accessible configuration file to modify such properties as the size of the fonts in the GUI widgets. This is functionality which is rightfully expected of a modern desktop UI.> Information on application-specific resource> settings can be found in the Mathematica Getting Started Guide:> http://documents.wolfram.com/v4/GettingStarted/ TroubleshootingUnixX.htmlIt should be in a clear and easy to access configuraton interface, or at least be redily available through the help system in such a way that reasonable queries will locate it. Changing fonts does not belong in a section on trouble shooting, unless this is an acknowledgement that the UI is broken.> The setting that you would need to adjust is XMathematica*fontList. The> value of the resource is an X Logical Font Description field.And I'm sure there is some configuration file in which I could place that, and hope that what you think will be read by my system *will* in fact be read, and not subsequently overridden during xsession startup. Things aren't the way they used to be back in the 1980s. The modern Unix desktop has moved beyond the paradigm of openlook and motif. See for example http://www.trolltech.com, http://www.gnome.org, and http://www.kde.org > I also find the overall look & feel of the interface to be archaic.> That's because Mathematica relies on the Motif library for user interface> elements.> http://www.opengroup.org/desktop/motif.html> The appearance of these elements, such as the menu and scroll bars, would> be the same for any other Motif application, such as the DDD debugger or> releases of Netscape prior to verison 4.My point exactly. ==== Awk! Legends!Basically, the answer to your question is that the PlotLegend option worksONLY for the Plot command and does not work for other types of plots. Forother types of plots you have to use ShowLegend. And ShowLegend is not allthat easy to use, especially since WRI does not give an example for multiplecurves in the Help.Needs[Graphics`Graphics`]Needs[Graphics`Legend`] {q1[t_], q2[t_], q3[t_]} = {0.1 Exp[-0.02 t], 0.2 Exp[-0.025 t], 0.4 Exp[-0.028 t]};Let's look at your first plot.Plot[{q1[t], q2[t], q3[t]}, {t, 0, 100}, PlotStyle -> {{AbsoluteThickness[0.5], AbsoluteDashing[{4, 4}]}, AbsoluteThickness[1.5], {AbsoluteThickness[2], AbsoluteDashing[{1, 8}]}}, AxesLabel -> {Y, X}, PlotLabel -> Title, PlotLegend -> {1, 3, 5}, LegendPosition -> {0.5, 0}, ImageSize -> 500];The legend is almost as big as the plot. It distracts from the realinformation you are trying to convey. Furthermore, the order of the curvesin the legend is the reverse of their order in the plot.The following shows how to put the legend in a LogLogPlot, or other types ofplots. I defined the plot styles independently because they are used inseveral places. I made the legend much smaller and put it in an empty areaof the plot. I also reversed the order of the keys so they would match theorder of the curves in the plot.styles={{AbsoluteThickness[0.5], AbsoluteDashing[{4,4}]},{AbsoluteThickness[1.5]},{ AbsoluteThickness[ 2],AbsoluteDashing[{1,8}]}};ShowLegend[ LogLogPlot[{q1[t], q2[t], q3[t]}, {t, 0, 100}, PlotStyle -> styles, AxesLabel -> {Y, X}, PlotLabel -> Title, ImageSize -> 500, DisplayFunction -> Identity], {MapThread[{Graphics[{Sequence @@ #1, Line[{{0, 0}, {1, 0}}]}], #2} &, {styles, {1, 3, 5}}] // Reverse, LegendPosition -> {-0.7, -0.4}, LegendSize -> {0.2, 0.3}, LegendShadow -> {0.02, -0.02}, LegendSpacing -> 0.5} ];But why use a legend at all? After all, a legend is nothing but another plotin which you have put labels on the curves. Why not put the labels directlyon the curves in the real plot in the first place?LogLogPlot[{q1[t], q2[t], q3[t]}, {t, 0, 100}, PlotStyle -> styles, AxesLabel -> {Y, X}, PlotLabel -> Title, ImageSize -> 500, Epilog -> MapThread[ Text[SequenceForm[Case , #1], {Log[10, 0.01], Log[10, #2[0.01]]}, {0, -1}] &, {{1, 2, 3}, {q1, q2, q3}}]];In the legend you have keyed the curves to numbers 1, 3 and 5. (Perhaps youjust used these as examples and meant to use something different in the realplots?) But these don't seem to have any obvious relation to your functions.I suppose the reader will have to look at another table or look into thetext of your paper or notebook to find out what 1, 3 and 5 mean. So thereader has to go from the graph to the legend then to the text and thenmentally transfer the meaning of the curve back to the main plot. It is somuch nicer to put the meaning right on the curve if you can.For the most part, legends are just computer junk and not even easy tonicely construct. When the legend urge comes over you - try to resist.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ AbsoluteThickness[1.5], {AbsoluteThickness[2], AbsoluteDashing[{1,8}]}}, AxesLabel[Rule]{Y, X}, PlotLabel[Rule]Title, PlotLegend[Rule]{1,3,5}, LegendPosition[Rule] {0.5,0}](*However with LogPlot or LogLogPlot the legend desappear*)LogLogPlot[{q1[t],q2[t],q3[t]}, {t, 0, 100},PlotStyle[Rule]{ {AbsoluteThickness[0.5], AbsoluteDashing[{4,4}]}, AbsoluteThickness[1.5], {AbsoluteThickness[2], AbsoluteDashing[{1,8}]}}, AxesLabel[Rule]{Y, X}, PlotLabel[Rule]Title, PlotLegend[Rule]{1,3,5}, LegendPosition[Rule] {0.5,0}]I have shown a particular case, but I has this problem always with LegendandLogPlot and LogPlotPlot. I will appreciate any help.GuillermoSanchez------------------------------------ ---------This message was sent using Endymion MailMan. ==== Using the Front End as a interface with the kernel I was running some calulations when suddenly pressing Shift+Enter causes the contents of the cell being evaluated to transform to the next text underlined with a red line: NotebookObject[FrontEndObject[LinkObject[dd8,1,1]],8] foollowed by the next messages:An unknown box name (NotebookObject) was sent as the BoxForm for the expression. Check the format rules for the expression.An unknown box name (FrontEndObject) was sent as the BoxForm for the expression. Check the format rules for the expression.An unknown box name (LinkObject) was sent as the BoxForm for the expression. Check the format rules for the expression.An invalid typeset structure was generated: Missing BoxFormData.Any suggestions will be very aprreciated.Cesar ==== I have an odd problem. I need to use and simplify functions that havebeen provided by a piece of software that insists on outputing thefunctional results of a data mining proceedure, using e whenoutputing numbers in scientific notation.I'm having difficultly using Replace, Hold, etc. to correctly evaluatethese types of function formats. For example, y = 5e+5x1+2e-1x2,should be transcribed into 5 10^5 x1 + 0.2 x2.ChuckReply-To: kuska@informatik.uni-leipzig.de ==== str = 5e+5x1+2e-1x2;StringJoin[Characters[str] /. e -> *10^] // ToExpression??Work fine for me.But this type of output is typical generated by a C/FORTRANProgram and you should rewrite the formating rules inthe code that produce this output. Jens> I have an odd problem. I need to use and simplify functions that have> been provided by a piece of software that insists on outputing the> functional results of a data mining proceedure, using e when> outputing numbers in scientific notation.> I'm having difficultly using Replace, Hold, etc. to correctly evaluate> these types of function formats. For example, y = 5e+5x1+2e-1x2,> should be transcribed into 5 10^5 x1 + 0.2 x2.> Chuck ==== RB> I am considering the following integralRB> W[m_,n_]:=Integrate[BesselJ[m, x]*BesselJ[n, x], {x, 0, Infinity}]RB> where m,n are reals >=0. With Mathematica 4.1 I obtain:RB> If[Re[m+n]>-1, -Cos[(m-n)Pi/2]/(2 Pi)*RB> (2 EulerGamma + Log[4] +RB> PolyGamma[0, 1/2(1 + m - n)] +RB> PolyGamma[0, 1/2(1 - m + n)] +RB> 2PolyGamma[0, 1/2(1 + m + n)])RB> Any explanation about the analytical expression will beRB> gratefully accepteed.The expression for W[m_,n_] returned by Mathematica is wrong.To prove, just substitute m = n = 0 which is exactly what you had doneand observe that the output you had hadW[0,0]=-(2 EulerGamma + Log[4] + 4 PolyGamma[0, 1/2])/(2 Pi)= 0.84564was incorrect. The correct answer is 1/2.Mathematica can handle the numeric integration successfullyIn[1] := NIntegrate[BesselJ[1, x]*BesselJ[0, x], {x, 0, Infinity}, Method -> Oscillatory] (* The warnings are skipped *)Out[1] = 0.5Using NIntegrate[BesselJ[0, x]*BesselJ[0, x], {x, 0, Infinity}]without Method -> Oscillatory is not the optimal choice asthe integrand oscillates fairly rapidly over the integrationregion.RB> I suspect that these integrals are divergent (*).In fact, not exactly.Integrate[BesselJ[1, x]*BesselJ[0, x], {x, 0, Infinity}]is equal to 1/2, and Mathematica 4.1 for Microsoft Windows(November 2, 2000) does it correctly, while Mathematica 4.2for Microsoft Windows (February 28, 2002) concocts a strangemixture of a wrong divergence message and the warning thatit cannot check the convergence [should I trust to the secondwarning? or the first?]As a matter of fact,Integrate[BesselJ[1, x]*BesselJ[0, x], {x, 0, Infinity}]converges because the integrand is regular at x=0, bounded overthe whole right semi-axis, and decays as2*Cos[Pi/4 - x]*Cos[(3*Pi)/4 - x]/(Pi*x) + o(1/x)at x -> Infinity .Say, calculateNormal[Series[BesselJ[1, x], {x, Infinity, 1}]] Normal[Series[BesselJ[0, x], {x, Infinity, 1}]] // InputForm->(2*(Cos[Pi/4 - x] - Sin[Pi/4 - x]/(8*x))*(Cos[(3*Pi)/4 - x] +(3*Sin[(3*Pi)/4 - x])/(8*x)))/(Pi*x)then Plot[%,{x,1,10}]and Plot[BesselJ[1,x]*BesselJ[0,x],{x,1,10}]and you could hardly see the difference.Generally, to get to the convergence domain for W in terms ofm and n is easy via the asymtotics of the Bessel functions(use something likeExpand[Normal[Series[BesselJ[m, x], {x, Infinity, 1}]]Normal[Series[BesselJ[n, x], {x, Infinity, 1}]]]then analyze the main term).Best wishes,Vladimir BondarenkoMathematical DirectorSymbolic Testing GroupWeb : http://www.CAS-testing.org/ http://maple.bug-list.org/VER2/ (under tuning) http://maple.bug-list.org/VER3/ (under tuning) http://maple.bug-list.org/VER1/ (under tuning) http://www.beautyriot.com/ (teamwork) http://www.ohaha.com/ (teamwork) Voice: (380)-652-447325 Mon-Fri 9 a.m. - 6 p.m.Mail : 76 Zalesskaya Str, Simferopol, Crimea, Ukraine ==== > inside a program I need to solve this linear equation in terms of p1.> However something odds happens. Sometimes the solution is computed and> sometimes the result is empty [I mean no output...]. Is this a bug of the> solve command or am I doing something wrong? The problem is robust to:> changing name to the variables and other makeups..> DavidThat's the weirdest bug I've seen in weeks. As it happens, it's mine. Atleast the inconsistent behavior, that is. I'll fix it, and maybe alsotry to address the issue of how to handle approximate numbers in testingsubexpressions for zero.I've excised your code and put in place a substantially smaller examplethat I believe is responsible. The table will tend to give erraticresults.zz = (-1.*x^7*(-1. + p - 7.*x^6 + p*x^6 + 6.*x^7)* (7.000000000000002 - 7.000000000000002*x + 14.000000000000004*x^6 - 14.000000000000004*x^7 + 7.000000000000002*x^12 -6.999999999999998*x^13))/ (p^2*(1. + 0.9*x^6)^2*(1. + x^6)^5);One workaround would be to use exact input, say by preprocessing withRationalize.Daniel LichtblauWolfram Research ==== >inside a program I need to solve this linear equation in terms of p1.>However something odds happens. Sometimes the solution is computed and>sometimes the result is empty [I mean no output...]. Is this a bug of the>solve command or am I doing something wrong? The problem is robust to:>changing name to the variables and other makeups..>David>ps: Sorry for the stupid way in which I copied the command...>Solve[(x^2*((-0.9*x^7*(p^2*(-1 - 5.8*x^6 - 14.010000000000002*x^12 -> 18.04*x^18 - 13.06*x^24 -> 5.040000000000001*x^30 - 0.81*x^36) +> x*(7.777777777777779 - 9.074074074074076*x +> 30.333333333333336*x^6 -> 21.51851851851852*x^7 -> 16.333333333333336*x^8 +> 44.33333333333334*x^12 +> 3.188888888888883*x^13 -> 65.68333333333332*x^14 +> 28.777777777777786*x^18 +> 47.937037037037044*x^19 -> 100.10000000000002*x^20 + 7.*x^24 +> 45.6037037037037*x^25 -> 69.53333333333333*x^26 +> 13.299999999999999*x^31 -> 19.833333333333332*x^32 -> 1.0499999999999996*x^38) +> p*(-6 + 8.296296296296296*x -> 28.799999999999997*x^6 +> 32.785185185185185*x^7 +> 9.333333333333336*x^8 -> 55.260000000000005*x^12 +> 49.04777777777776*x^13 +> 38.38333333333334*x^14 -> 52.980000000000004*x^18 +> 34.20518518518518*x^19 +> 60.20000000000001*x^20 -> 25.380000000000003*x^24 +> 11.736296296296294*x^25 +> 43.63333333333334*x^26 - 4.86*x^30 +> 2.8999999999999986*x^31 +> 13.533333333333333*x^32 + 0.81*x^37 +> 1.0499999999999996*x^38)))/(x + 1.9*x^7 +> 0.9*x^13)^2 - ((-1 + p - 7*x^6 + p*x^6 +> 6*x^7)*(1.2962962962962965 - 3.111111111111112*x^6>+> 9.333333333333336*x^7 - 10.111111111111114*x^12>+> 22.05*x^13 - 5.703703703703705*x^18 + 17.15*x^19>+> 5.483333333333331*x^25 + 1.0499999999999996*x^31>+> p1*x^5*(7.000000000000002 - 7.000000000000002*x>+> 14.000000000000004*x^6 -> 14.000000000000004*x^7 +> 7.000000000000002*x^12 -> 6.999999999999998*x^13) -> 1.166666666666667*p*x^4*x1 -> 3.500000000000001*p*x^10*x1 -> 1.0500000000000003*p*x^11*x1 -> 3.500000000000001*p*x^16*x1 -> 3.150000000000001*p*x^17*x1 -> 1.166666666666667*p*x^22*x1 -> 3.150000000000001*p*x^23*x1 -> 1.0500000000000003*p*x^29*x1))/((1 + 0.9*x^6)^2*(1>+> x^6)^2)))/(p^2*(1 + x^6)^3) == 0, p1]You might find it more robust (and the results cleaner) if you Simplify the equation prior to using Solve. Such asSolve[eqn // Rationalize // Simplify, p1]However, if you are assigning values to p or x prior to using Solve, there may not be a solution. That is, for whenever the numerator of the expression for p1 would be zero, e.g., p = (-6 x^7 + 7 x^6 +1)/(x^6 + 1).Bob Hanlon ==== I prefer to delete all output and then Copy As>Notebook expression. ItBobby-----Original Message-----andoutput --- I try to use one tab indent for input and two tabs indent foroutput, plus some blank line adjustment.I wonder if anyone has a way of automatically achieving thisreformating.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> Often posters to MathGroup copy and paste in the complete cellexpression,> including the In and Out numbers, when posting to MathGroup.> I wonder if this is the best method because one can't then just copyoutall> the statements and paste them into a Mathematica notebook. All thestatement> numbers have to be edited out and if there are many statementdefinitions> this is an extended task for any responder. This, of course, decreasesthe> chances for a response. A better method is for the poster to just copyand> paste the CONTENTS of each cell. This is more work for the poster, butit> may pay off in better responses.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ ==== Could someone explain what is going on here, please?In[1]:= a = 77617.; b = 33096.; In[2]:=SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity]; SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b)In[5]:=SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=fOut[6]=-1.1805916207174113*^21In[7]:=a = 77617; b = 33096; In[8]:=g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + (55/10)*b^8 + a/(2*b)In[9]:=gOut[9]=-(54767/66192)In[10]:=N[%]Out[ 10]=-0.8273960599468214PK ==== Peter,I hope that the following example will help - it is a matter or when thingsevaluate.The a in SetAccuracy[a, Infinity], below, evaluates before SetAccuracy acts,so we getSetAccuracy[2.3, Infinity]. The value of a is not changed. a = 2.3; aa = SetAccuracy[a, Infinity] 2589569785738035/1125899906842624But, a 2.3Whereas aa 2589569785738035/1125899906842624--Allan------------------- --Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice : +44 (0)116 271 4198> Could someone explain what is going on here, please?> In[1]:=> a = 77617.; b = 33096.;> In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity];> In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b)> In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity];> In[6]:=> f> Out[6]=> -1.1805916207174113*^21> In[7]:=> a = 77617; b = 33096;> In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + (55/10)*b^8+ a/(2*b)> In[9]:=> g> Out[9]=> -(54767/66192)> In[10]:=> N[%]> Out[10]=> -0.8273960599468214> PK ==== In receiving notebooks from many different people I have noticed thatbeginners often do not know how to use Text cells and write all of theircomments as Input cells. I have even run across some extremely advancedusers who did not know the easy method for entering Text cells. A goodnotebook is usually a blend of Text cells, Input/Output cells and graphicscells. Text cells are very useful for documenting what you are doing andpassing information to other people. Since many people do not know how touse Text cells, I thought I would write a little explanation for beginnerswho are followers of MathGroup.The very easiest method for entering a Text cell is to put the insertionpoint where you want the new cell to be (at the end of the notebook orbetween two existing cells) and then type Alt-7. Then just start typing andyou will have a Text cell.Alternatively you can use MenuFormatStyleText to start a new Text cell.Often, it is useful to put the ToolBar at the top of the notebook. UseMenuFormatShow ToolBar. The drop-down menu on the ToolBar has the variouskinds of cells available for the current style of the notebook. You canselect Text (or any other style) from there.Some users may hesitate to use Text cells because they want to include amathematical expression in the comments. However, that is also very easy.Just use an Inline cell within the text cell. At the point within the textcell where you want to include a mathematical expression, start an Inlinecell by typing Ctrl-(. A selection placeholder will appear on a pinkbackground. You can type a Mathematica expression there just as in an Inputcell. Use Ctrl-) to complete the Inline cell, or Shift-Space. You can evenselect an Inline cell and evaluate it with Shift-Ctrl-Enter.Putting comments in Text cells is far better than using Input cells (or cellgroup header cells). Mathematica won't try to evaluate Text cells, the textwill wrap properly and adjust better to the notebook width if you change it.You can also check the spelling of words by putting the cursor after a wordand using Ctrl-K. (In an Input cell Mathematica doesn't use the dictionary,but uses the table of symbols instead and hence it won't check spelling.)David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/=== =This is because inline cells are not in StandardForm by default, but TraditionalForm.Use the menu item Cell -> Default Inline Format Type -> StandardForm.>David Park's posting reminded me of a frequent annoyance when I am>trying to include some Mathematica expressions within text cells -- a>Mathematica input expression in Standard Form that involves use of a>Control-key combination to form a superscript, square-root, or built-up>fraction:>For example, suppose I want to include within a text cell a Standard>Form expression for the square of x, with the exponent 2 raised. If I>type the x first, even if I immediately highlight it and change it to>Courier (to match the default font for Input cells in Standard Form), as>soon as I press the Control-^ key combination, an Inline cell is created>beginning with the x, and then when I type the exponent 2 everything in>that Inline cell is now in Times, and the x is Italic. To change both>characters to Courier is not so easy: it seems to require separately>the entire Inline cell and selecting Courier does not change the exponent!)>So to avoid this annoyance I normally must first type the desired>expression in a separate Input cell, then copy the contents of that cell>to the desired point in the Text cell.>Any suggestions on a more efficient method for handling this?> In receiving notebooks from many different people I have noticed that> beginners often do not know how to use Text cells ....> Some users may hesitate to use Text cells because they want to include a> mathematical expression in the comments....> Just use an Inline cell within the text cell....>-->Murray Eisenberg murray@math.umass.edu>Mathematics & Statistics Dept.>Lederle Graduate Research Tower phone 413 549-1020 (H)>University of Massachusetts 413 545-2859 (W)>710 North Pleasant Street>Amherst, MA 01375-------------------------------------------------------- ------Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.htmlReply-To : murray@math.umass.edu ==== David Park's posting reminded me of a frequent annoyance when I am trying to include some Mathematica expressions within text cells -- a Mathematica input expression in Standard Form that involves use of a Control-key combination to form a superscript, square-root, or built-up fraction:For example, suppose I want to include within a text cell a Standard Form expression for the square of x, with the exponent 2 raised. If I type the x first, even if I immediately highlight it and change it to Courier (to match the default font for Input cells in Standard Form), as soon as I press the Control-^ key combination, an Inline cell is created beginning with the x, and then when I type the exponent 2 everything in that Inline cell is now in Times, and the x is Italic. To change both characters to Courier is not so easy: it seems to require separately the entire Inline cell and selecting Courier does not change the exponent!)So to avoid this annoyance I normally must first type the desired expression in a separate Input cell, then copy the contents of that cell to the desired point in the Text cell.Any suggestions on a more efficient method for handling this?> In receiving notebooks from many different people I have noticed that> beginners often do not know how to use Text cells ....> Some users may hesitate to use Text cells because they want to include a> mathematical expression in the comments....> Just use an Inline cell within the text cell....-- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375 ==== correctly, all you need to do is to make sure the default inline cell formatis StandardForm. Go to the menu item Cell, select Default Inline FormatType,and change it to StandardForm.Carl WollPhysics DeptU of Washington----- Original Message -----> type the x first, even if I immediately highlight it and change it to> Courier (to match the default font for Input cells in Standard Form), as> soon as I press the Control-^ key combination, an Inline cell is created> beginning with the x, and then when I type the exponent 2 everything in> that Inline cell is now in Times, and the x is Italic. To change both> characters to Courier is not so easy: it seems to require separately> the entire Inline cell and selecting Courier does not change theexponent!)> So to avoid this annoyance I normally must first type the desired> expression in a separate Input cell, then copy the contents of that cell> to the desired point in the Text cell.> Any suggestions on a more efficient method for handling this?> In receiving notebooks from many different people I have noticed that> beginners often do not know how to use Text cells ....> Some users may hesitate to use Text cells because they want to include a> mathematical expression in the comments....> Just use an Inline cell within the text cell....> --> Murray Eisenberg murray@math.umass.edu> Mathematics & Statistics Dept.> Lederle Graduate Research Tower phone 413 549-1020 (H)> University of Massachusetts 413 545-2859 (W)> 710 North Pleasant Street> Amherst, MA 01375Reply-To: kuska@informatik.uni-leipzig.de ==== just one comment: the meaning of the Alt-7 key depend on the style sheet that is in use.The TMJ style use Alt-8 for text and one hasto learn new key short-cuts for every style sheet ! Jens> In receiving notebooks from many different people I have noticed that> beginners often do not know how to use Text cells and write all of their> comments as Input cells. I have even run across some extremely advanced> users who did not know the easy method for entering Text cells. A good> notebook is usually a blend of Text cells, Input/Output cells and graphics> cells. Text cells are very useful for documenting what you are doing and> passing information to other people. Since many people do not know how to> use Text cells, I thought I would write a little explanation for beginners> who are followers of MathGroup.> The very easiest method for entering a Text cell is to put the insertion> point where you want the new cell to be (at the end of the notebook or> between two existing cells) and then type Alt-7. Then just start typing and> you will have a Text cell.> Alternatively you can use MenuFormatStyleText to start a new Text cell.> Often, it is useful to put the ToolBar at the top of the notebook. Use> MenuFormatShow ToolBar. The drop-down menu on the ToolBar has the various> kinds of cells available for the current style of the notebook. You can> select Text (or any other style) from there.> Some users may hesitate to use Text cells because they want to include a> mathematical expression in the comments. However, that is also very easy.> Just use an Inline cell within the text cell. At the point within the text> cell where you want to include a mathematical expression, start an Inline> cell by typing Ctrl-(. A selection placeholder will appear on a pink> background. You can type a Mathematica expression there just as in an Input> cell. Use Ctrl-) to complete the Inline cell, or Shift-Space. You can even> select an Inline cell and evaluate it with Shift-Ctrl-Enter.> Putting comments in Text cells is far better than using Input cells (or cell> group header cells). Mathematica won't try to evaluate Text cells, the text> will wrap properly and adjust better to the notebook width if you change it.> You can also check the spelling of words by putting the cursor after a word> and using Ctrl-K. (In an Input cell Mathematica doesn't use the dictionary,> but uses the table of symbols instead and hence it won't check spelling.)> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ ==== Solve[youre equation, p1, VerifySolutions->True] will return a solution. So willSolve[Rationalize[your equation],p1].Andrzej KozlowskiToyama International UniversityJAPAN> inside a program I need to solve this linear equation in terms of p1.> However something odds happens. Sometimes the solution is computed and> sometimes the result is empty [I mean no output...]. Is this a bug of > the> solve command or am I doing something wrong? The problem is robust to:> changing name to the variables and other makeups..> David> ps: Sorry for the stupid way in which I copied the command...> Solve[(x^2*((-0.9*x^7*(p^2*(-1 - 5.8*x^6 - 14.010000000000002*x^12 -> 18.04*x^18 - 13.06*x^24 -> 5.040000000000001*x^30 - 0.81*x^36) +> x*(7.777777777777779 - 9.074074074074076*x +> 30.333333333333336*x^6 -> 21.51851851851852*x^7 -> 16.333333333333336*x^8 +> 44.33333333333334*x^12 +> 3.188888888888883*x^13 -> 65.68333333333332*x^14 +> 28.777777777777786*x^18 +> 47.937037037037044*x^19 -> 100.10000000000002*x^20 + 7.*x^24 +> 45.6037037037037*x^25 -> 69.53333333333333*x^26 +> 13.299999999999999*x^31 -> 19.833333333333332*x^32 -> 1.0499999999999996*x^38) +> p*(-6 + 8.296296296296296*x -> 28.799999999999997*x^6 +> 32.785185185185185*x^7 +> 9.333333333333336*x^8 -> 55.260000000000005*x^12 +> 49.04777777777776*x^13 +> 38.38333333333334*x^14 -> 52.980000000000004*x^18 +> 34.20518518518518*x^19 +> 60.20000000000001*x^20 -> 25.380000000000003*x^24 +> 11.736296296296294*x^25 +> 43.63333333333334*x^26 - 4.86*x^30 +> 2.8999999999999986*x^31 +> 13.533333333333333*x^32 + 0.81*x^37 +> 1.0499999999999996*x^38)))/(x + 1.9*x^7 +> 0.9*x^13)^2 - ((-1 + p - 7*x^6 + p*x^6 +> 6*x^7)*(1.2962962962962965 - > 3.111111111111112*x^6 +> 9.333333333333336*x^7 - > 10.111111111111114*x^12 +> 22.05*x^13 - 5.703703703703705*x^18 + > 17.15*x^19 +> 5.483333333333331*x^25 + > 1.0499999999999996*x^31 +> p1*x^5*(7.000000000000002 - > 7.000000000000002*x +> 14.000000000000004*x^6 -> 14.000000000000004*x^7 +> 7.000000000000002*x^12 -> 6.999999999999998*x^13) -> 1.166666666666667*p*x^4*x1 -> 3.500000000000001*p*x^10*x1 -> 1.0500000000000003*p*x^11*x1 -> 3.500000000000001*p*x^16*x1 -> 3.150000000000001*p*x^17*x1 -> 1.166666666666667*p*x^22*x1 -> 3.150000000000001*p*x^23*x1 -> 1.0500000000000003*p*x^29*x1))/((1 + > 0.9*x^6)^2*(1 +> x^6)^2)))/(p^2*(1 + x^6)^3) == 0, p1]Reply-To: murray@math.umass.edu ==== For all names, perhaps: Names[*`*]For names you defined at a normal session (without changing to some other context than the default Global`): Names[Global`*]> IIRC, there is a way to get a list of all the symbols defined in the > currently running session. I can't seem to find the reference to that > command. Could somone point me in the direction of documentation which > will tell me how to get information about the current session?> TIA,> -- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375 ==== > For all names, perhaps:> Names[*`*]> For names you defined at a normal session (without changing to some> other context than the default Global`):> Names[Global`*]> IIRC, there is a way to get a list of all the symbols defined in the> currently running session. I can't seem to find the reference to that> command. Could somone point me in the direction of documentation which> will tell me how to get information about the current session?> TIA,> I think I asked the wrong question. I'll have to look at things some more. What you gave me resulted in far more than I was looking for.http://public.globalsymmetry.com/proprietary/com/wri/ system-symbols.htmlhttp://66.92.149.152/proprietary/com/wri /system-symbols.htmlI think I really hosed the code for generating that table. I used 5 lines. I probably didn't need more than two, but I'm too tired right now to think about it. Mathematica is totaly awesome when it comes to what it was intended for. They really need to rent a Troll for a few months and fix this interface. Qt will run on just about anything. Heck, my Win-XP partition runs XFree86, with the KDE, or it did when I booted into XP a month ago.STH ==== ?*does the trick. You can limit it to Global variables with?Global`*Bobby-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== Well, first of of all, your using SetAccuracy and SetPrecision does nothing at all here, since they do not change the value of a or b. You should use a = SetAccuracy[a, Infinity] etc. But even then you won't get the same answer as when you use exact numbers because of the way you evaluate f. Here is the order of evaluation that will give you the same answer, and should explain what is going on:f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121* b^4 - 2) + 5.5*b^8 + a/(2*b), Infinity];a = 77617.; b = 33096.;a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity];f 54767-(-----) 66192Andrzej KozlowskiToyama International UniversityJAPAN> Could someone explain what is going on here, please?> In[1]:=> a = 77617.; b = 33096.;> In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity];> In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + > a/(2*b)> In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity];> In[6]:=> f> Out[6]=> -1.1805916207174113*^21> In[7]:=> a = 77617; b = 33096;> In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + > (55/10)*b^8 + a/(2*b)> In[9]:=> g> Out[9]=> -(54767/66192)> In[10]:=> N[%]> Out[10]=> -0.8273960599468214> PK ==== ====By taking sums and differences of the counterweights 1, 3, ... 3^(k-1)you can precisely express all integers up to the integer whose base 3notation is composed of k ones.By doubling those counterweights, you can precisely express all the EVENintegers up to TWICE that limit, or -1 + 3^k. If you know that unknownsare limited to the integers from 1 to 3^k, this allows you to preciselyweight the even numbers and bracket the odd numbers. Hencecounterweights 2, 6, ... 2*3^(k-1) are sufficient for unknowns up to3^k.Notice that this is an efficient coding scheme: Each counterweight ismultiplied by -1, 0, or 1, so there can be at most 3^k distinctcounterweight sums. More than half are negative or zero, however; thepositive sums and differences number at most (3^k - 1)/2. Since we needto enumerate (and CAN enumerate with even weights) only the even numbersand because we get the maximum unknown 3^k by elimination, we cover upto twice as many as we can enumerate, plus one. Twice (3^k - 1)/2 plusone is 3^k, so we're getting the maximum coverage possible for a givennumber of counterweights.Bobby Treat-----Original Message-----For these 40 positive integers to match 1 to 40 correspondingly, thebiggestshould be 40 (also, the smallest should be 1). So we have:a+b+c+d=40 or 1+b+c+d=40 (we state that a I have a very interesting math problem:If I have a scales,and I> have 40 things that their mass range from 1~40 which each is anature> number,and now I can only make 4 counterweights to measure out each> mass of those things.Question:What mass should the counterweights> be???> The answer is that 1,3,9,27 and I wnat to use mathematica tosolve> this problem.> In fact,I think that this physical problem has various> answer,ex.2,4,10,28> this way also work,because if I have a thing which weight 3 , and I> can measure out by comparing 2<3<4 . But,If I want to solve thismath> problem:> {x|x=k1*a+k2*b+k3*c+k4*d}={1,2,3,4,,,,,,40} where a,b,c,d is nature> numbers.> and {k1,k2,k3,k4}={1,0,-1}> How to solve it ??> mathematica solving method. appreciate any idea sharing> sincerely> bryan> Just use brute force. Needs[DiscreteMath`Combinatorica`]; var = {a, b, c, d}; n = Length[var]; s = Outer[Times, var, {-1, 0, 1} ]; f = Flatten[Outer[Plus, Sequence@@s]]; Since the length of f is just 3^n then the range of numbers> to be covered should be {-(3^n-1)/2, (3^n-1)/2}.> Consequently, the largest of the weights can not exceed> (3^n-1)/2 - (1+2+...+(n-1)) or ((3^n-1) - n(n-1))/2 34 Thread[var->#]& /@ (First /@ Select[{var,f} /. Thread[var->#]& /@ KSubsets[Range[((3^n-1) - n(n-1))/2], n], Sort[#[[2]]] == Range[-(3^n-1)/2,(3^n-1)/2]&]) {{a -> 1, b -> 3, c -> 9, d -> 27}}> Bob Hanlon> Chantilly, VA USA> ==== Plot[Evaluate[Sin[x]/Sin[x]], {x, -2.5, -1.5}]Gives the expected graph.Bobby Treat-----Original Message-----substituting a ßoating-point value for x results in composite divisionbeing performed numerically, with consequent inaccuracy. This can beverified by the following:In[1]:= FullForm[HoldForm[Sin[x]/Sin[x]]Out[1]//FullForm= HoldForm[Times[Sin[x], Power[Sin[x], -1]]]By default, Mathematica scales the y axis such that the smalldiscrepanciesare visible. The PlotRange option may be given to explicitly specify therange for the y axis (for example PlotRange->{0, 2}).Ian McInnes.> I would expect that Plot[Sin[x]/Sin[x], {x, -2.5, -1.5}] would produce a horizontal line at y=1. However, on my Windows XP computer it produces a graph where the yvalueis> less than 1 at several points. Most notibly between x=-1.6 and x=-1.8 Is this just an isolated case? Or does it happen to others? If so -why? Ken.> ==== >>But my actual output reproduces the input form, i.e., it is simplyf[...listA,newEntry,...].That means your arguments don't fit a pattern for which the function isdefined. That is, it has nothing to do with what's on the right side of:=. It's about making sure there are the right number and type ofarguments passed to the function. You haven't told us what the patternis or what the arguments are, so we can't help you.Bobby-----Original Message----- I define a function of the form: f[...,listA_, newEntry_,...]:= Which[...]Here Which has the form of a set of logically exclusive and exhausivetests, each test with its ownaction that modifies the concrete list subsituted for listA_. For instance, if there were only two tests the rhs above wouldbeone that puts the newEntryat the start of listA and the other that puts it at the end: Which[ test1, listA = Insert[listA, newEntry, 1], test2, listA = Insert[listA, newEntry, -1] ]Then I try to use the function, substituting values for the arguments:f[..., listA, newEntry, ...]. Theoutput should be the appropriately modified list. But my actual outputreproduces the input form,i.e., it is simply f[...listA,newEntry,...]. Yet, the program does do something, as the use of evaluate inplaceshows: Suppose that test1 is satisfied by the particular values of thearguments. Then whenI apply evaluate in place to the lhs of the action that is supposed tooccur when test1 is true,in fact the value of Insert[listA,newEntry,1] is correct, but the rhsgivesonly the initial value oflistA and not the modified value that is on the rhs. Concretely, suppose that in the function argument listA is {121}andnewEntry is 200.Then after evaluation of the function (input to the kernel), that linereads, according toevaluate in place: true, {121} = {200, 121}So it seems that only part of the correct action was taken: 200 was putatthe start of listA. Butthe assignment of this value -- the extended list -- to be the new valueoflistA did not take place. I then tried using a new name for the modified list, substituting thisprogram line for test1: test1, newListA = Insert[listA,newEntry,1]What I get here, applying evaluate in place after evaluating thefunctionwith concrete values as aboveis: true, newListA = {200, 121} Trace doesn't help because all I get back is the function namewithits concrete arguments. Any thoughts? Tom ==== The problem is that I do not think there is any bounded 3d body described by your conditions. Anyway, this is how you can use Mathematica (in general) to solve this sort of problem.You need two packages:In[1]:=< 3x && y < 4 - x^2 && z < x^2 + 4, {x}, {y}, {z}]However, you will just get some error messages and a picture that looks two dimensional. If you wanted the volume, evaluate:In[3]:=Integrate[Boole[y>3x&&y<4-x^2&&z3x&&y<4-x^2&&z3x&&y<4-x^2&&z equation :> z=x^2 +4 (as bottom surface)> and on the xy plane which bounded by a parabola y=4-x^2 and y=3x line. How would I use Mathematica to plot out this 3D object or find out its > volumn with only the equation given? Shz Shz> Andrzej Kozlowski 3/September/2002 04:33pm Mathematica could do this sort of thing if there were a three> dimensional object described by your equations (as boundaries) but> there isn't one. More precisely, the pair of equations {z=x^2 +4,> y=4-x^2} describes a parabola in three space which you can plot with: g1=ParametricPlot3D[{x, 4 - x^2, x^2 + 4}, {x, -5, 5}] The equation y=3x describes the plane: g2 = ParametricPlot3D[{x, 3x, z}, {x, -5, 5}, {z, -25, 25}]> You can see the two together in> < Show[{g1,g2}] There are clearly two points of intersection. They can be found with:> Solve[{z == x^2 + 4, y == 4 - x^2, y == 3*x}, {x, y, z}]> {{z -> 5, y -> 3, x -> 1}, {z -> 20, y -> -12, x -> -4}} So where is the 3D object whose volume you want to find? Andrzej Kozlowski> Toyama International University> JAPAN Can I use Mathematica to find out the volumn of this 3 dimensional> object from> the equations : z=x^2 +4, y=4-x^2, y=3x> Shz Shz ==== How can I run mathematica program in background? Is there any waysimilar to fortran or c where one can runs his program in thebackground? Please suggest. RajReply-To: kuska@informatik.uni-leipzig.de ==== math < someresults.m &???BTW this is a problem of your operating systemand not of Mathematica. Jens> How can I run mathematica program in background? Is there any way> similar to fortran or c where one can runs his program in the> background?> Please suggest.> Raj ==== All works fine but now I wanted to generate an animated gif with help of Now the same file which worked earlier produces errors:In[4]:=Export[schwing.gif, schwing, GIF]LinkConnect::linkc: !([LeftSkeleton] 1 [RightSkeleton]) is dead; attempt to connect failed.Out[4]=schwing.gifAlso a dialogue box appears withsuch file or directorysuch file or directoryThe files are at the place and are executable etc. But if one tries to execute them always this No such file or directory error message appears.Does anyone know what to do?-- Hendrik van Hees Fakult.8at f.9fr Physik http://theory.gsi.de/~vanhees/ D-33615 Bielefeld ==== First define the functionsz[x_] := x^2 + 4;y1[x_] := 4 - x^2;y2[x_] := 3x;Figure out where the y limits coincide:Solve[y1[x] == y2[x], x]{{x -> -4}, {x -> 1}}Which is bigger in between?y1[0] - y2[0]4y1 is. Confirm that with a plot. (y2 is linear):Plot[{y1[x], y2[x]}, {x, -5, 5}]Next figure out where z is zero:Solve[z[x] == 0, x]{{x -> -2*I}, {x -> 2*I}}It's never zero for real x, but is it positive, or negative?z[0]4Look at the plot, just for fun:Plot[{z[x]}, {x, -4, 1}]z is positive for all x (but only the interval [-4,1] MATTERS). Thevolume you want, therefore, isIntegrate[z[x]*(y1[x] - y2[x]), {x, -4, 1}]625/4or:g[x_] = Integrate[z[x]*(y1[x] - y2[x]), x]g[1] - g[-4]16*x - 6*x^2 - (3*x^4)/4 - x^5/5625/4Bobby Treat-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== >-----Original Message----->Sent: Wednesday, September 04, 2002 8:56 AM>previous output?>>What is a efficient way to use output expression to define new >function. PeterPeter,I'd say none,... Ôcause look at In[1]:= y = x^2Out[1]= x^2In[2]:= f1[x_] = Out[1]Out[2]= x^2In[3]:= f2[x_] := Out[1]In[4]:= x = 5Out[4]= 5In[5]:= f3[x_] = Out[1]Out[5]= 25In[6]:= Block[{x}, f4[x_] = Out[1]]Out[6]= 25In[7]:= Block[{x}, f5[x_] := Out[1]]In[9]:= f6[x_] = yOut[9]= 25In[10]:= Block[{x}, f7[x_] = y]Out[10]= 25In[11]:= f8[x_] := yIn[12]:= Through[{f1, f2, f3, f4, f5, f6, f7, f8}[#]] & /@ {0, 1}Out[12]= {{0, 25, 25, 0, 25, 25, 0, 25}, {1, 25, 25, 1, 25, 25, 1, 25}}In[13]:= Block[{x}, f9[x_] = Out[1]]Out[13]= %1In[14]:= Through[{f1, f2, f3, f4, f5, f6, f7, f8, f9}[#]] & /@ {0, 1}Out[14]= {{0, %1, 25, 0, %1, 25, 0, 25, %1}, {1, %1, 25, 1, %1, 25, 1, 25, %1}}f1, f4 and f7 come out right, but f1 is based on the condition that thepattern variables of the expression have not been redefined, and f4 is onlycorrect if the history is remembered well. So what rests is f7, but thatwasn't you question.--Hartmut Wolf ==== If we are in the business of giving good links to Doppler demonstrations,here is another one (freeware):http://www.phy.ntnu.edu.tw/java/Doppler/ Doppler.htmlFor anyone interested in good Java implementations of physics phenomena,NTNU Virtual Physics Laboratory athttp://www.phy.ntnu.edu.tw/java/index.html is a treasure chest.This is not Mathematica stuff (as far as I know), but might be of interestto several Mathgroup readers.Ingolf DahlChalmers UniversitySwedenf9aid@fy.chalmers.se-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== My main application for this is in drawing a piece of a plane at a pointnormal to a vector. For me, efficiency is not an important criterion. But Iwant orthogonal vectors so the plane will be composed of squares and notdiamonds. I want unit vectors so that I can easily specify the size of thepiece I am drawing.I posted a summary last evening and it doesn't seem to have appeared today.In any case, I have realized that none of the routines really require theLinearAlgebra`Orthogonalization package, and run faster without it. I havemodified the original routines to use a pure function instead of Normalizeor GramSchmidt.Here is a summary of the responses so far. The timings were done with thefollowing exact vector. They are faster with a machine precision vector.vtest = {1, 2, 1};__________________________________________________________ Hugh Goyder...The original routine wasOrthogonalUnitVectors[v : {_, _, _}] := GramSchmidt[NullSpace[{v}]]but I changed it toOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@ NullSpace[{v}]OrthogonalUnitVectors[vtest]{{-(1/Sqrt[2]), 0, 1/Sqrt[2]}, {-(1/Sqrt[3]), 1/Sqrt[3], -(1/Sqrt[3])}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{2.53 Second, Null}This appears to be the shortest and fastest routine. I would give it theprize for elegance. It is certainly easy to remember.____________________________________________________ ____Ingolf Dahl...OrthogonalUnitVectors[v:{_, _, _}] := (#1/Sqrt[#1 . #1] & ) /@ NullSpace[{v, {0, 0, 0}, {0, 0, 0}}]OrthogonalUnitVectors[vtest]{{-(1/Sqrt[2]), 0, 1/Sqrt[2]}, {-(2/Sqrt[5]), 1/Sqrt[5], 0}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{2.59 Second, Null}This is really the same as Hugh Goyder's routine. It isn't necessary to addthe zero rows to the matrix. NullSpace automatically does it.________________________________________________________ Selwyn Hollis...OrthogonalUnitVectors[v : {_, _, _}] := Module[{u, w}, u = Which[(w = {0, v[[3]], -v[[2]]}).w != 0, w, (w = {v[[3]], 0, -v[[1]]}).w != 0, w, (w = {v[[2]], -v[[1]], 0}).w != 0, w, True, Return[$Failed]]; #/Sqrt[#.#] & /@ {u, Cross[u, v]} ]OrthogonalUnitVectors[vtest]{{0, 1/Sqrt[5], -(2/Sqrt[5])}, {Sqrt[5/6], -Sqrt[2/15], -(1/Sqrt[30])}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{11.92 Second, Null}I wish I understood the reason for using rows of the v Cross matrix as testvectors. It does have the advantage that a dot product is used to give ascalar test for zero. Why not...OrthogonalUnitVectors[v : {_, _, _}] := Module[{u, w}, u = Which[(w = {1, 0, 0})[Cross]v != {0, 0, 0}, w, (w = {0, 1, 0})[Cross]v != {0, 0, 0}, w, True, Return[$Failed]]; #/Sqrt[#.#] & /@ {u, Cross[u, v]} ]OrthogonalUnitVectors[vtest]{{1, 0, 0}, {0, -(1/Sqrt[5]), 2/Sqrt[5]}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{10.33 Second, Null}________________________________________________________ ____John Browne...OrthogonalUnitVectors[v : {_, _, _}] := Module[{r, v1, v2}, r = {Random[], Random[], Random[]}; v1 = Cross[v, r]; v2 = Cross[v1, v]; {v1/Sqrt[Dot[v1, v1]], v2/Sqrt[Dot[v2, v2]]}]OrthogonalUnitVectors[vtest]{{0.26601, -0.534209, 0.802408}, {-0.873254, 0.218984, 0.435286}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{9.17 Second, Null}This has the problem that the r vector might be parallel to v. But in 100000test cases it never happened.____________________________________________________ ________Daniel Lichblau...(Daniel left out the normalization, which I added.)OrthogonalUnitVectors[v:{_, _, _}] := With[{vecs = NullSpace[{v}]}, (#1/Sqrt[#1 . #1] & ) /@ {vecs[[1]], vecs[[2]] - vecs[[2]] . vecs[[1]]*vecs[[1]]}]OrthogonalUnitVectors[vtest]{{-(1/Sqrt[ 2]), 0, 1/Sqrt[2]}, {0, 1/Sqrt[5], -(2/Sqrt[5])}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{3.35 Second, Null}________________________________________________________ ______Garry HelzerOrthogonalVectors[v : {a1_, a2_, a3_}] := With[{w = First[Sort[{{a2, -a1, 0}, {a3, 0, -a1}, {0, a3, -a2}}, OrderedQ[{Plus @@ Abs[#2], Plus @@ Abs[#1]}] &]]}, {w, Cross[v, w]} ]OrthogonalUnitVectors[vtest]{{-(1/Sqrt[2]), 0, 1/Sqrt[2]}, {-(2/Sqrt[5]), 1/Sqrt[5], 0}}Do[OrthogonalUnitVectors[vtest], {10000}] // Timing{2.64 Second, Null}________________________________________________________ __________Tom BurtonA nice feature of the following simple scheme is that you know that the twopoints of discontinuity are where r and -r cross the unit sphere.triad[u_, r_:{1, 0, 0}] := Module[{v = Cross[u, r]}, #/Sqrt[# . #] & /@{u, v, Cross[u, v]}]triad[vtest]{{1/Sqrt[6], Sqrt[2/3], 1/Sqrt[6]}, {0, 1/Sqrt[5], -(2/Sqrt[5])}, {-Sqrt[5/6], Sqrt[2/15], 1/Sqrt[30]}}Do[triad[vtest], {10000}] // Timing{17.02 Second, Null}David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ djmp@earthlink.nethttp://home.earthlink.net/~djmp/ ==== CeZaR,Sort of confused about what you really wanted. If you have forgotten toassign x = ? then you can do the following,Clear[x, eq, m, l]eq = m x^2 + 2(m + 1)x + m + 2l = {};x = 1;For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]]ListPlot[l]But if you really intend to make a list of quadratics and then plot theresults for each of the quadratics then you can try the followingClear[x, eq, m, l]eq = m x^2 + 2(m + 1)x + m + 2;l = {};For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]];test = Table[l[[i]], {i, 1, Length[l], 1}, {x, -50, 50}];MultipleListPlot[test[[5]], test[[10]], test[[15]], test[[20]],test[[25]], test[[30]], test[[35]], test[[40]], test[[45]], test[[50]], test[[55]], test[[60]], PlotJoined -> True, SymbolShape -> None, ImageSize -> 500 ]Essentially your For loop generates a list of quadratics if x is left out.Yas I want to do these operations: eq = m x^2 + 2(m + 1)x + m + 2> l = {}> For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]]> Plot[l, {x, -50, 50}] but i get this error:> l is not a machine-size real number at x = -49.99999583333334 Can someone exaplain to me what i am doing wrong here??> CeZaR ==== Plot[l // Evaluate, {x, -30, 30}, Frame -> True];CeZaR ==== > I want to get some F and R such that:> F[n,p] + R[n,p] = Sum[Binomial[n,k] p^(n-k) (1-p)^k, {k, 0, Floor[n/2] - 1}],> when F[n,p] is an approximation to the sum and the R is the remaining error.> Constantine.>>I'm looking for a way of finding the approximation for partitial binomial>>sum.>>I'll be pleasant for any hint..> [...]> Office: Taub 411You can get a closed form in terms of special functions if you splitinto two cases depending on whether n is even or odd.In[39]:= n = 2*m;In[40]:= InputForm[Sum[Binomial[n,k]*p^(n-k)*(1-p)^k, {k,0,m-1}]]Out[40]//InputForm= p^(2*m)*((p^(-1))^(2*m) - ((-4 + 4/p)^m*Gamma[1/2 + m]* Hypergeometric2F1[1, -m, 1 + m, (-1 + p)/p])/(Sqrt[Pi]*Gamma[1 +m]))In[41]:= n = 2*m+1;In[42]:= InputForm[Sum[Binomial[n,k]*p^(n-k)*(1-p)^k, {k,0,m-1}]]Out[42]//InputForm= p^(1 + 2*m)*((p^(-1))^(1 + 2*m) - (2^(1 + 2*m)*(-1 + p^(-1))^m*Gamma[3/2+ m]* Hypergeometric2F1[1, -1 - m, 1 + m, (-1 + p)/p])/(Sqrt[Pi]*Gamma[2 +m]))Daniel LichtblauWolfram Research ==== I want to get some F and R such that:F[n,p] + R[n,p] = Sum[Binomial[n,k] p^(n-k) (1-p)^k, {k, 0, Floor[n/2] - 1}],when F[n,p] is an approximation to the sum and the R is the remaining error.Constantine.>>I'm looking for a way of finding the approximation for partitial binomial >>sum.>>I'll be pleasant for any hint..>Use the standard add-on package Statistics`NonlinearFit` to do a >NonlinearFit to whatever model you want to use for the approximation.>Bob Hanlon>Chantilly, VA USAConstantine ElsterComputer Science Dept.Technion I.I.T.Office: Taub 411 ==== Constantine,If you break your problem up into two cases, even n and odd n, thenMathematica can sum up your problem and get results, albeit withhypergeometric functions. Consider the following (make sure you look at thiswith a fixed font):In[21]:=evenans = Sum[Binomial[2*n, k]*p^(2*n - k)*(1 - p)^k, {k, 0, n - 1}];In[22]:=PowerExpand[FunctionExpand[FullSimplify[evenans , n [Element] Integers]]]Out[22]= 2 n n n 1 p - 1 2 (1 - p) p Gamma[n + -] Hypergeometric2F1[1, -n, n + 1, -----] 2 p1 - ------------------------------------------------------------- ------- Sqrt[Pi] Gamma[n + 1]In[23]:=oddans = Sum[Binomial[2*n + 1, k]*p^(2*n + 1 - k)*(1 - p)^k, {k, 0, n - 1}];In[24]:=PowerExpand[FunctionExpand[FullSimplify[oddans , n [Element] Integers]]]Out[24]= 2 n + 1 n n + 1 3p - 1 2 (1 - p) p Gamma[n + -] Hypergeometric2F1[1, -n - 1, n +1, -----] 2p1 - ------------------------------------------------------------ -------------------- Sqrt[Pi] Gamma[n + 2]Is this what you were looking for?Carl WollPhysics DeptU of Washington> I want to get some F and R such that: F[n,p] + R[n,p] = Sum[Binomial[n,k] p^(n-k) (1-p)^k, {k, 0, Floor[n/2] -1}],> when F[n,p] is an approximation to the sum and the R is the remainingerror. Constantine.>>I'm looking for a way of finding the approximation for partitialbinomial>>sum.>>I'll be pleasant for any hint..>Use the standard add-on package Statistics`NonlinearFit` to do a>NonlinearFit to whatever model you want to use for the approximation.>>Bob Hanlon>Chantilly, VA USA Constantine Elster> Computer Science Dept.> Technion I.I.T.> Office: Taub 411 ==== >I want to do these operations:>>eq = m x^2 + 2(m + 1)x + m + 2>l = {}>For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]]>Plot[l, {x, -50, 50}]>>but i get this error:>l is not a machine-size real number at x = -49.99999583333334>>Can someone exaplain to me what i am doing wrong here??>eq = m x^2 + 2(m + 1)x + m + 2;l = {};For[i = -30, i < 30, i++, AppendTo[l, eq /. m -> i]];It would be more straightforward and efficient to define the list using Tablel == Table[eq, {m, -30, 29}]TrueTo Plot, use EvaluatePlot[Evaluate[l], {x, -50, 50}];Bob Hanlon ==== >What is a efficient way to use output expression to define new function.Use the menu command Input/Copy Output from Aboveor use % (Out)Bob Hanlon ==== >-----Original Message----->Sent: Wednesday, September 04, 2002 8:57 AM>The problem is that I do not think there is any bounded 3d body >described by your conditions. Anyway, this is how you can use >Mathematica (in general) to solve this sort of problem.>You need two packages:>>In[1]:=><>In[2]:=><< Calculus`Integration`>To see your object use:>InequalityPlot3D[y > 3x && y < 4 - x^2 && z < x^2 + 4, {x}, {y}, {z}]>>However, you will just get some error messages and a picture >that looks >two dimensional. If you wanted the volume, evaluate:>>In[3]:=>Integrate[Boole[y>3x&&y<4-x^2&&z>Out[3]=>-Infinity>>If you impose some limits on z you will get a finite positive answer, >but one that clearly is unbounded:>>In[20]:=>NIntegrate[Boole[y>3x&&y<4-x^2&&z>Out[20]=>2239.58>>In[21]:=>NIntegrate[ Boole[y>3x&&y<4-x^2&&z>Out[21 ]=>20989.6>>Andrzej Sorry, I must have something missing in my previous description. I need to find out the volumn of a 3D object which form by the > equation :> z=x^2 +4 (as bottom surface)> and on the xy plane which bounded by a parabola y=4-x^2 and >y=3x line. How would I use Mathematica to plot out this 3D object or >find out its > volumn with only the equation given? Shz Shz> Andrzej Kozlowski 3/September/2002 04:33pm Mathematica could do this sort of thing if there were a three> dimensional object described by your equations (as boundaries) but> there isn't one. More precisely, the pair of equations {z=x^2 +4,> y=4-x^2} describes a parabola in three space which you can >plot with: g1=ParametricPlot3D[{x, 4 - x^2, x^2 + 4}, {x, -5, 5}] The equation y=3x describes the plane: g2 = ParametricPlot3D[{x, 3x, z}, {x, -5, 5}, {z, -25, 25}]> You can see the two together in> < Show[{g1,g2}] There are clearly two points of intersection. They can be found with:> Solve[{z == x^2 + 4, y == 4 - x^2, y == 3*x}, {x, y, z}]> {{z -> 5, y -> 3, x -> 1}, {z -> 20, y -> -12, x -> -4}} So where is the 3D object whose volume you want to find? Andrzej Kozlowski> Toyama International University> JAPAN Can I use Mathematica to find out the volumn of this 3 dimensional> object from> the equations : z=x^2 +4, y=4-x^2, y=3x> Shz Shz>> >Shz Shz,as Andrzej having said everything about the calculation of the volume, andas still your specification is incomplete, I'm going to show how you canplot at least all you have (communicated).As you said something obout the bottom -- which direction is up? --assuming positive z-direction the I come to the inequalities: y >= 3 x, y <= 4 -x^2, z >= 4 + x^2and arbitrarily, to make the example complete I'll show only parts with z < 20but do not complete the shape.To begin building the graphics we draw the boundary surfaces:[1] the bottom{xmin, xmax} = x /. NSolve[4 - x^2 == 3x, {x}]{-4., 1.}Plot[{4 - x^2, 3x}, {x, xmin, xmax}]{ymin, ymax} = {3 xmin, 4}g3 = Graphics3D[Plot3D[x^2 + 4, {x, xmin, xmax}, {y, ymin, ymax}]][2] the wallsg = ParametricPlot3D[{{x, 4 - x^2, z}, {x, 3x, z}}, {x, xmin, xmax}, {z, 0, 20}]One idea now would be to exploit the Mathematica rendering algorithm, to cutoff the undesired parts of the boundary surfaces:gg = Show[g3, g, PolygonIntersections -> False][Epsilon] = 1. 10^-4g4 = gg /. Line[_] -> {} /. p : Polygon[pts_] :> If[Or @@ (#2 > 4 - #1^2 + [Epsilon] || #2 < 3 #1 - [Epsilon] || #3 < #1^2 + 4 - [Epsilon] &) @@@ pts, {}, p]Show[g4 /. Line[_] -> {}, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, -2.4, 5}]But alas! The edges are rather gnawed off. Increasing epsilon doesn't help,unwanted parts will show up and still some polygons are nibbled away.So we have to do it ourselves:We definetag[inequality_][p_] := Block[{x, y, z}, {x, y, z} = p; If[inequality, {p, inside}, {p, outside}]]...tags points whether inside ore outside.sol[equality_, {p1_, _}, {p2_, _}] := Block[{p, d, x, y, z}, {x, y, z} = p = p1 (1 - d) + p2 d; First[Cases[Solve[equality, d], s_ /; NonNegative[d /. s] :> (p /. s)]] ]...computes the cut on the line between to points of opposite sides.sep[equality_][pp1_, pp2_] := If[pp1[[2]] === pp2[[2]], {pp1}, ppx = sol[equality, pp1, pp2]; {pp1, {ppx, pp1[[2]]}, {ppx, pp2[[2]]}}]...effectively cuts a segment crossing the border into two pieces.cutGraphics3D[g_, inequality_] := Module[{equality = Equal @@ inequality}, g /. Polygon[pts_] :> Block[{tagpts = tag[inequality] /@ pts}, With[{t = sep[equality] @@@ Transpose[{tagpts, RotateLeft[tagpts]}]}, With[{newpts = Cases[t, {p_, label_} /; label == inside :> p,2]}, If[Length[newpts] > 2, Polygon[newpts], {}]] ]]]...Polygons crossing a border are cut, only those inside are kept.We first cut the bottom...g3new = Fold[cutGraphics3D, g3, {y >= 3x, y <= 4 - x^2}]...next the sides...gnew = cutGraphics3D[g, z >= 4 + x^2]...and display:Show[gnew, g3new, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, -2.4, 5}]Show[gnew, g3new, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, -2.4, 15}]Show[gnew, g3new, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, -2.4, -2}]Show[gnew, g3new, BoxRatios -> {1, 1, .5}, ViewPoint -> {1.3, 2.5, 2}]Here I have brought a method, I had already posted twice, to a more handyform.To make that reminiscence complete, we could also define a coloring functioncolorGraphics3D[g_, inequality_, colorinside_, coloroutside_] := Module[{equality = Equal @@ inequality}, g /. Polygon[pts_] :> Block[{tagpts = tag[inequality] /@ pts}, With[{t = sep[equality] @@@ Transpose[{tagpts, RotateLeft[tagpts]}]}, {With[{newpts = Cases[t, {p_, label_} /; label == outside :> p, 2]}, If[Length[newpts] > 2,{FaceForm[SurfaceColor[coloroutside]], Polygon[newpts]}, {}]], With[{newpts = Cases[t, {p_, label_} /; label == inside :> p, 2]}, If[Length[newpts] > 2, {FaceForm[SurfaceColor[colorinside]], Polygon[newpts]}, {}]]} ]]]and with...g3D = Graphics3D[Plot3D[E^(-(x^2/2) - y^2/2)/(2*Pi) , {x, -2, 2}, {y, -2,2}]]Show[colorGraphics3D[g3D, With[{e = Take[{x, y, z}, 2] - {0.8, -0.5}}, e.e] <= 1, Hue[0, 0.3, 1], Hue[0.6, 0.3, 1]]]--Hartmut Wolf ==== This result seems to me to be wrong (it's right?):In[1]:=Integrate[Sqrt[a^2*Cos[t]^2 + b^2*Sin[t]^2], {t, 0, 2*Pi}, Assumptions->{Im[a]==0, Im[b]==0}]Out[1]=0....but written in another way, it's right:In[2]:=Integrate[Sqrt[a^2 + (b^2 - a^2)*Sin[t]^2], {t, 0, 2*Pi}, Assumptions -> {Im[a] == 0, Im[b] == 0}]Out[2]=If[a^2/(-a^2 + b^2) >= 0 || b^2/(-a^2 + b^2) <= 0 || Im[a^2/(-a^2 + b^2)] != 0, (4*a^2*Sqrt[-1 + b^2/a^2]*EllipticE[ 1 - b^2/a^2])/Sqrt[-a^2 + b^2], Integrate[Sqrt[a^2 + (-a^2 + b^2)*Sin[t]^2], {t, 0, 2*Pi}]]Someone can explane me this difference?Raf. ==== involved Bessel equations(electro-magnetic field in coaxial) but when I initialize and calculate that2 eqs for the 2nd or 3rd time, Ôcause I changed some parameters, I see astrange Removed[n] instead of the value of n (=0).I use the line Remove[Global`*];at the beginning to clear any variable and I think it could be the problem.So, have I always to quit and restart the program in order to recalculatethat equations?Filippo Sola ==== Can someone provide me more information on how ListIntegrate worksthan what is contained in the version 4 manual ? Is there a websiteperhaps or tutorial ?I would like to know how the beginning and end of a list of {x,y}pairs that is being integrated is dealt with by ListIntegrate.I know a series of polynomials is somehow used but how ? Do theseoverlap ? Are they piecewise continuous ?Are these polynomials available for inspection ? How do they change asa function of k ?optimum k value for a given list ? For any given list, will accuracymonotonically increase with increasing values of k ? Is thereanything in the Option Inspector that could cause unexpected behaivorwith ListIntegrate ?Are there any good rules of thumb or procedures that will help ensurea reasonable answer is produced ?Is there a way of estimating the error or accuracy of integrationperformed by ListIntegrate ? ==== Be sure to note the following and what comes after it near the end of the Help Browser info on ListIntegrate:``This package has been included for compatibility with previous versions of Mathematica. The functionality of this package has been superseded by improvements made to InterpolatingFunction.In other words, ListIntegrate is a dinosaur that you don't need at all!To integrate a list of data with Mathematica, one can proceed in either of two ways: (1) Construct an interpolating function and use NIntegrate (or, better, NIntegrateInterpolatingFunction) on that (which is what ListIntegrate apparently does); or (2) apply a simple routine that implements the trapezoidal rule, Simpson's rule, or maybe some higher order method.Assuming you've chosen to take path #1, you need to realize the following:(a) NIntegrate[Interpolation[data, InterpolationOrder->1][x], {x,a,b}] is equivalent to the trapezoidal rule;(b) NIntegrate[Interpolation[data, InterpolationOrder->2][x], {x,a,b}] is *not* equivalent to Simpson's rule (because of the peculiar way that Interpolation works);(c) Interpolation[data, InterpolationOrder->k] generally does not return a smooth function unless you set InterpolationOrder->n-1, where n is the number of data points, which is the case where a single polynomial of degree n-1 fits the data points.(d) If you want to integrate a smooth interpolant, you can do this: <k][x], {x, 0, 5}, PlotRange -> All], {k, 1, 6}](The last of those plots will give a warning message.)Having said all that, you really should consider path #2 instead. Here are a couple of links to a MathGroup discussion of last July (somehow the thread got split up):http://library.wolfram.com/mathgroup/archive/2002/Jul/ msg00490.htmlhttp://library.wolfram.com/mathgroup/archive/ 2002/Jul/msg00519.htmlI hope all this helps some.----Selwyn Hollis > Can someone provide me more information on how ListIntegrate works > than what is contained in the version 4 manual ? Is there a website > perhaps or tutorial ? > I would like to know how the beginning and end of a list of {x,y} > pairs that is being integrated is dealt with by ListIntegrate. > I know a series of polynomials is somehow used but how ? Do these > overlap ? Are they piecewise continuous ? > Are these polynomials available for inspection ? How do they change as > a function of k ? > optimum k value for a given list ? For any given list, will accuracy > monotonically increase with increasing values of k ? Is there > anything in the Option Inspector that could cause unexpected behaivor > with ListIntegrate ? > Are there any good rules of thumb or procedures that will help ensure > a reasonable answer is produced ? > Is there a way of estimating the error or accuracy of integration > performed by ListIntegrate ? > > ==== I timed Daniel's three solutions and Gary's one (plus a couple of my owna little later):perps1[v_] := If[v[[1]] == v[[2]] == 0, {{1, 0, 0}, {0, 1, 0}}, {{v[[2]], -v[[ 1]], 0}, Cross[v, {v[[2]], -v[[1]], 0}]}]perps2[v_] := With[{vecs = NullSpace[{v}]}, {vecs[[ 1]], vecs[[2]] - (vecs[[2]].vecs[[1]])*vecs[[1]]}]perps2C = Compile[{{v, _Real, 1}}, Module[{vecs = NullSpace[{v}]}, { vecs[[1]], vecs[[2]] - (vecs[[2]].vecs[[1]])*vecs[[1]]}]]helzer[v : {a1_, a2_, a3_}] := With[{w = First[Sort[{{a2, -a1, 0}, {a3, 0, -a1}, {0, a3, -a2}}, OrderedQ[{Plus @@ Abs[#2], Plus @@ Abs[#1]}] &]]}, {w, Cross[v, w]}]vecs = Table[Random[], {10000}, {3}]; Timing[perps1 /@ vecs; ]Timing[perps2 /@ vecs; ]Timing[perps2c /@ vecs; ]Timing[helzer /@ vecs; ]{1.7350000000000012*Second, Null}{0.5619999999999994*Second, Null}{0.219 Second, Null}{2.7349999999999994*Second, Null}I made a small change to Daniel's perps1, and got a solution as fast asperps2c, WITHOUT compiling. Compiling tripled the speed again, sotreatC is the fastest solution I've seen so far.treat[{a_, b_, c_}] := If[a == b == 0, {{1, 0, 0}, {0, 1, 0}}, {{b, -a, 0}, {a*c, b*c, -a^2 -b^2}}]treatC = Compile[{{v, _Real, 1}}, If[v[[1]] == v[[2]] == 0, {{1, 0, 0}, {0, 1, 0}}, {{v[[2]], -v[[1]], 0}, {v[[1]]*v[[3]], v[[2]]*v[[3]], -v[[1]]^2 - v[[2]]^2}}]]vecs = Table[Random[], {10000}, {3}]; Timing[perps2c /@ vecs; ]Timing[helzer /@ vecs; ]Timing[treat /@ vecs; ]Timing[treatC /@ vecs;]{0.2190000000000083*Second, Null}{2.7339999999999947*Second, Null}{0.25*Second, Null}{0.07800000000000296*Second, Null}None of these solutions reliably return normalized vectors.Bobby Treat-----Original Message-----> pose the problem to MathGroup. Who has the most elegant Mathematica> routine...> OrthogonalUnitVectors::usage = OrthogonalUnitVectors[v:{_,_,_}] willreturn> two unit vectors orthogonal to each other and to v.> You can assume that v is nonzero.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/Some possibilities:perps1[v_] := If [v[[1]]==v[[2]]==0, {{1,0,0},{0,1,0}}, {{v[[2]],-v[[1]],0}, Cross[v,{v[[2]],-v[[1]],0}]} ]perps2[v_] := With[{vecs=NullSpace[{v}]}, {vecs[[1]], vecs[[2]] - (vecs[[2]].vecs[[1]])*vecs[[1]]} ]This appears to be 2-3 times faster than perps1 for vectors of machinereals. I get another factor of 2 using Compile, which is appropriate fore.g. graphics use.perps2C = Compile[{{v,_Real,1}}, Module[{vecs=NullSpace[{v}]}, {vecs[[1]], vecs[[2]] - (vecs[[2]].vecs[[1]])*vecs[[1]]} ]]In[61]:= vecs = Table[Random[], {10000}, {3}];In[62]:= Timing[p2 = Map[perps1C,vecs];]Out[62]= {0.49 Second, Null}This is on a 1.5 GHz processor.Daniel LichtblauWolfram Research ==== >I was wondering if there is a method for resizing Raster graphics>(resizing the actual matrix of pixels, not just the display size). I>am processing a large number of JPEG images, and we sometimes need to>reduce the image size to allow data processing algorithms to function>without running out of memory. In the past we simply used a program>such as Photoshop to resize them before importing them into>Mathematica. Due to the number of images we are processing now this>is very inconvenient and it would be very useful if there was a method>for accomplishing it in Mathematica, but I can't find one. I also>thought about doing something simple like sampling every few pixels or>averaging, but I thought there might be a method with more efficacy>than this. I also tried exporting the graphics with the Export command>as new JPEGs and manipulating the ImageResolution and ImageSize>options but this seemed to have no effect. Any help would be much>appreciated.>Aaron UrbasIn 4.2, the following should work (as long as you define newsize).in = Import[file.jpg];Export[newfile.jpg, in, ImageSize->newsize]In 4.1 and earlier, this will not work because an optimization interferes with the ImageSize and rasters are written out with the raster size, not the ImageSize. There is a ConversionOption to force the behavior you want.in = Import[file.jpg];Export[newfile.jpg, Show[in, ImageSize->newsize], ConversionOptions->{RasterExport->Graphics}]-Dale ==== Borrowing liberally from Daniel, I like the following:ClearAll[sumBin, sumBinOdd, sumBinEven, index]sumBinOdd = Sum[Binomial[2index + 1, k]*p^(2index + 1 - k)*(1 - p)^k, { k, 0, index - 1}];sumBinEven = Sum[Binomial[2index, k]* p^(2index - k)*(1 - p)^k, {k, 0, index - 1}];sumBin[n_, Odd] = sumBinOdd /. {index -> (n - 1)/2};sumBin[n_, Even] = sumBinEven /. {index -> n/2};sumBin[n_?EvenQ] = sumBin[n, Even];sumBin[n_?OddQ] = sumBin[n, Odd];It allows you to see the solution symbolically for both odd and even n,and also to calculate it when n is a known integer. We also have theopportunity, for instance, to assume that 3x is even and calculatesumBin[3x, Even]p^(3*x)*((1/p)^(3*x) - ((-4 + 4/p)^((3*x)/2)* Gamma[1/2 + (3*x)/2]*Hypergeometric2F1[1, -((3*x)/2), 1 + (3*x)/2, (-1 + p)/p])/(Sqrt[Pi]*Gamma[1 +(3*x)/2]))or assume 3x is odd and calculatesumBin[3*x, Odd]p^(3*x)*((1/p)^(3*x) - (2^(3*x)*(-1 + 1/p)^((1/2)*(-1 + 3*x))* Gamma[3/2 + (1/2)*(-1 + 3*x)]*Hypergeometric2F1[1, -1 + (1/2)*(1 - 3*x), 1 + (1/2)*(-1 + 3*x), (-1 +p)/p])/(Sqrt[Pi]* Gamma[2 + (1/2)*(-1 + 3*x)]))Bobby Treat-----Original Message-----> when F[n,p] is an approximation to the sum and the R is the remainingerror.> Constantine.>In a message dated 8/28/02 4:44:13 AM, celster@cs.technion.ac.il>>I'm looking for a way of finding the approximation for partitialbinomial>>sum.>>I'll be pleasant for any hint..> [...]> Office: Taub 411You can get a closed form in terms of special functions if you splitinto two cases depending on whether n is even or odd.In[39]:= n = 2*m;In[40]:= InputForm[Sum[Binomial[n,k]*p^(n-k)*(1-p)^k, {k,0,m-1}]]Out[40]//InputForm= p^(2*m)*((p^(-1))^(2*m) - ((-4 + 4/p)^m*Gamma[1/2 + m]* Hypergeometric2F1[1, -m, 1 + m, (-1 + p)/p])/(Sqrt[Pi]*Gamma[1 +m]))In[41]:= n = 2*m+1;In[42]:= InputForm[Sum[Binomial[n,k]*p^(n-k)*(1-p)^k, {k,0,m-1}]]Out[42]//InputForm= p^(1 + 2*m)*((p^(-1))^(1 + 2*m) - (2^(1 + 2*m)*(-1 + p^(-1))^m*Gamma[3/2+ m]* Hypergeometric2F1[1, -1 - m, 1 + m, (-1 + p)/p])/(Sqrt[Pi]*Gamma[2 +m]))Daniel LichtblauWolfram Research ==== I've found that Mathematica 4.2 takes too long to finish to generate firsttime help browser. Is this normal? How many time should it take?Calimero ==== Please excuse me if this has been discussed before; I haven't been monitoring the group very much.A long time ago I posted to this group as well as to Wolfram about the errors in many or all functions involving Fourier transforms when values of FourierParameters other than the default values are used. The group responded that indeed there was a problem so I'm wondering if it was ever fixed. My version (then and now) is 4.0.1 for Macintosh.Jerry ==== Could you help me?I'm to solve heat conductivity equation (Laplas equation) - partial differential equation. Are there any ready-to-use packages that will help me do the job?Standard function DSolve cannot! And so do functions from package Calculus`DSolveIntegrals`.More info: the space where the equation is to be solved is cylindre (not infinite). Andrew. ==== When I multiply an expression with 0 it is giving 0.expression whichis creating problem in the further calculation.eg.In[1]:=func1[r_]:=Exp[-r/2]In[2]:coeff[[1,1 ]]=0.0;;;In[34]:=func1[r]coeff[[1,1]]Out[34]:=0.Exp[-r/2]I want anything to be multiply by zero must be zero. How can I do that? Your suggestion will be highly appreciated. Raj ==== > When I multiply an expression with 0 it is giving 0.expression which> is creating problem in the further calculation.No. Your trouble comes when you multiply an expression by theßoating-point number 0.0, rather than by the precise symbolic 0 (having nodecimal point). Merely make the coefficient 0 (rather than 0.0) andeverything should work as you wish.David> eg. In[1]:=func1[r_]:=Exp[-r/2]> In[2]:coeff[[1,1]]=0.0;> ;> ;> In[34]:=func1[r]coeff[[1,1]] Out[34]:=0.Exp[-r/2] I want anything to be multiply by zero must be zero. How can I do that?-- -------------------- http://NewsReader.Com/ -------------------- Usenet Newsgroup ServiceReply-To: kuska@informatik.uni-leipzig.de ==== Unprotect[Times]Times[0 ., __] := 0Protect[Times] Jens> When I multiply an expression with 0 it is giving 0.expression which> is creating problem in the further calculation.> eg.> In[1]:=func1[r_]:=Exp[-r/2]> In[2]:coeff[[1,1]]=0.0;> ;> ;> In[34]:=func1[r]coeff[[1,1]]> Out[34]:=0.Exp[-r/2]> I want anything to be multiply by zero must be zero.> How can I do that?> Your suggestion will be highly appreciated.> Raj ==== Now I'm trying to calculate this formula:Delta[eq_, x_]:=Coefficient[eq, x]^2 - 4 Coefficient[eq, x^2] Coefficient[eq, x^0]eq has this form a x^2 + b x + cBut there is a problem with the x^0 coefficient!How can I overcome that?CeZaRReply-To: kuska@informatik.uni-leipzig.de ==== andDelta[eq_, x_]:=Coefficient[eq, x]^2 - 4 Coefficient[eq, x,2]Coefficient[eq, x,0]does what you want. Because the Help-Browser say:Coefficient[expr, form, 0] picks out terms that are not proportional toform. Jens> Now I'm trying to calculate this formula:> Delta[eq_, x_]:=Coefficient[eq, x]^2 - 4 Coefficient[eq, x^2] Coefficient[eq, x^0]> eq has this form a x^2 + b x + c> But there is a problem with the x^0 coefficient!> How can I overcome that?> CeZaR ==== I need to fill the space between two contour lines, C1 and C2, withred color, and leave the other place white. What trick I have to use?Any suggestion and advice will be appreciated.Jun LinReply-To: kuska@informatik.uni-leipzig.de ==== gr = ContourPlot[x^2 + y^2, {x, -1, 1}, {y, -1, 1}, Contours -> {0.2, 0.4}, ColorFunction -> (If[# >= 0.2 && # <= 0.4, RGBColor[1, 0, 0], RGBColor[1, 1, 1]] &), ColorFunctionScaling -> False ] Jens> I need to fill the space between two contour lines, C1 and C2, with> red color, and leave the other place white. What trick I have to use?> Any suggestion and advice will be appreciated.> Jun Lin ==== I am trying to find an example that will demonstrate the difference between$PrePrint and $Post. I found an old thread in this news group where auser wanted to display all matrices using MatrixForm. Some users suggestedthe following: In[1]:= $Post=(#/.mtrx_?MatrixQ:>MatrixForm[mtrx]&);Then Dave Withoff said it's better to assign this to $PrePrint since theobjective here is to adjust the display rather than the result of thecalculation. With the assignment to $Post you could, for example, getunexpected results from calculations using %, since matrices will be wrappedin MatrixForm.--------However, if we use $Post above, the next input will compute the inversethe matrix. I did verify that Inverse can't take a matrix wrapped inMatrixForm. Can somebody give an example where doing this with $PrePrintinstead of $Post gives a different result. In[2]:= m={{2,3},{0,1}}; Inverse[%] Out[3]= (* Inverse of (m) in MatrixForm, not shown. *)------ Ted Ersek Get Mathematica tips, tricks from http://www.verbeia.com/mathematica/tips/Tricks.htmlReply-To : kuska@informatik.uni-leipzig.de ==== yo can just tryIn[]:=$Post = (# /. mtrx_?MatrixQ :> AnyHead[mtrx] &);In[]:=m = {{2, 3}, {0, 1}}In[]:=q=%;In[]:=Head[q]andIn[]:=$PrePost = (# /. mtrx_?MatrixQ :> AnyHead[mtrx] &);In[]:=m = {{2, 3}, {0, 1}}In[]:=q=%;In[]:=Head[q]But you are right -- the behaviour of MatrixForm[] in your exampleis strange. Jens> I am trying to find an example that will demonstrate the difference between> $PrePrint and $Post. I found an old thread in this news group where a> user wanted to display all matrices using MatrixForm. Some users suggested> the following:> In[1]:= $Post=(#/.mtrx_?MatrixQ:>MatrixForm[mtrx]&);> Then Dave Withoff said it's better to assign this to $PrePrint since the> objective here is to adjust the display rather than the result of the> calculation. With the assignment to $Post you could, for example, get> unexpected results from calculations using %, since matrices will be wrapped> in MatrixForm.> --------> However, if we use $Post above, the next input will compute the inverse> the matrix. I did verify that Inverse can't take a matrix wrapped in> MatrixForm. Can somebody give an example where doing this with $PrePrint> instead of $Post gives a different result.> In[2]:= m={{2,3},{0,1}};> Inverse[%]> Out[3]= (* Inverse of (m) in MatrixForm, not shown. *)> ------> Ted Ersek> Get Mathematica tips, tricks from> http://www.verbeia.com/mathematica/tips/Tricks.html ==== myArray is a list of triplets which look like {n,k,p}, where n and kare integers and p is real number. repetitions in n and k are allowedbut no two triplets ar the same.I define a function, myfunc[n_,pthreshold_] as follows.myfunc[n_,pthreshold_] := Module[{t},t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]];If[t>=0,t,-1]]It prints the largest k for which p is greater than pthreshold for agiven n and-1 if there is no such k. The function does its job fine. My problem is as follows. I would like to plot a collection of plots,myfunc[n,p], for 1<=n<=21 with respect to p. unfortunately thefollowing does not work as desired.Plot[Table[myfunc[n,p],{n,1,21}],{p,0.0,1.0}] because the Table gets evaluated to numeric value (-1) before Plot isinvoked. ==== I made a mistake in the definition of the question. The function is correctly defined as myfunc[n_,pthreshold_] := Module[{t}, t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> k, 2]]; If[t>=0,t,-1]]Please note that inserting Evaluate before Table does not workcorrectly either, because evaluating myfunc[n,p] when p is not anumber, gives -1.> Plot[Table[myfunc[n,p],{n,1,21}],{p,0.0,1.0}] > because the Table gets evaluated to numeric value (-1) before Plot is> invoked.Reply-To: kuska@informatik.uni-leipzig.de ==== could you supply a complete example next time ?Try myfunc[] with a more restrictive pattern and it works:myArray = Flatten[Table[{n, 1, Random[]}, {15}, {n, 1, 21}], 1];myfunc[n_, pthreshold_?NumericQ] := Module[{t}, t = Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]]; If[t >= 0, t, -1]]Plot[Evaluate[Table[myfunc[n, p], {n, 1, 21}]], {p, 0.0, 1.0}] Jens> myArray is a list of triplets which look like {n,k,p}, where n and k> are integers and p is real number. repetitions in n and k are allowed> but no two triplets ar the same.> I define a function, myfunc[n_,pthreshold_] as follows.> myfunc[n_,pthreshold_] := Module[{t},> t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]];> If[t>=0,t,-1]]> It prints the largest k for which p is greater than pthreshold for a> given n and> -1 if there is no such k. The function does its job fine.> My problem is as follows. I would like to plot a collection of plots,> myfunc[n,p], for 1<=n<=21 with respect to p. unfortunately the> following does not work as desired.> Plot[Table[myfunc[n,p],{n,1,21}],{p,0.0,1.0}]> because the Table gets evaluated to numeric value (-1) before Plot is> invoked. ==== For my PDE class we have been calculating Fourier transforms. The instructorarrived today with a printout of two plots of a certain Fourier transform,done with a different CAS. The first plot was to 30 terms, the second was to120 terms. Curious, I translated the functions into Mathematica (4.0 on Windows2000on a PIII 700) to see how much time this required to process. I wasStaggered at how much time it took. Here's the code:L = 2;f[x_] := UnitStep[x - 1];b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]Out[23]={419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]}In this case the number of terms is 30.The time required per number of terms seems to fit the following polynomial:y = 0.3926x^2 + 2.2379xThis is a large amount of time. I understand that the code is not optimized,and was more or less copied from the code in the other CAS, but is this areasonable amount of time, or is something going wrong? I don't use Mathematicabecause of the speed, but should it be this slow?Just curious,Steve Story ==== > I don't use Mathematica> because of the speed, but should it be this slow?Mathematica has become more competitive in the speed department in recentyears. See for example the attached comparison (not sent to newsgroup) byStephan Steinhaus (steinhaus-net.de). So when Mathematica takes a very longtime, you should investigate. In this case inserting Evaluate[] in twoplacesIn[91]:=b[n_] := Evaluate[(2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]];....In[104]:=Timing[Plot[Evaluate[FS[120, x]], {x, 0, 2}]]Out[104]={0.18 Second,[SkeletonIndicator]Graphics[SkeletonIndicator]} speeds the process enormously (18 milliseconds to plot 120 terms on myfeeble old 500MHz PowerBook).Why was it so slow before? When I switch from an ordinary numerical languageto Mathematica, I enter into an implicit bargain withMathematica: the software will go the extra mile to get me a good answer,including (1) using exra precision (sometimes without being asked) and (2)carrying around unevaluated mathematical expressions (usually without beingasked) that could possibly be evaluated more appropriately at a later time.Most tools cannot do either of these things, so I don't have to worry aboutit, except for the bad answers that result now and then. But I need to takecare that Mathematica does not burden itself unnecessarily. That's my sideof the bargain.Number (2) is the issue here. Your definition of b[n] is written so thatMathematica analytically evaluates b separately for each n. But you know inthis case that the integration can be done safely once for all n. So do it!The huge difference, though, comes from pre-evaluating the argument to Plot.Read the on-line help! You should pre-evaluate where possible. In somecases, the most common of which involve branching within the definition offunction to plot, you cannot pre-evaluate so, in keeping with the bargain,Mathematica goes the extra mile and holds back just in case. You need tosteer it into the shortcut when it's OK.Hope this helps,Tom Burton-- Reply-To: kuska@informatik.uni-leipzig.de ==== with your code you compute the expansion coefficents everytime when FS[] is evaluated. Store the values for b[n] withL = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]and you need only a 1-3 seconds (depending on your machine) Jens> For my PDE class we have been calculating Fourier transforms. The instructor> arrived today with a printout of two plots of a certain Fourier transform,> done with a different CAS. The first plot was to 30 terms, the second was to> 120 terms.> Curious, I translated the functions into Mathematica (4.0 on Windows2000> on a PIII 700) to see how much time this required to process. I was> Staggered at how much time it took. Here's the code:> L = 2;> f[x_] := UnitStep[x - 1];> b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];> FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];> Timing[Plot[FS[30, x], {x, 0, 2}]]> Out[23]=> {419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]}> In this case the number of terms is 30.> The time required per number of terms seems to fit the following polynomial:> y = 0.3926x^2 + 2.2379x> This is a large amount of time. I understand that the code is not optimized,> and was more or less copied from the code in the other CAS, but is this a> reasonable amount of time, or is something going wrong? I don't use Mathematica> because of the speed, but should it be this slow?> Just curious,> Steve Story ==== I would like to use mathematica type papers for my math courses, butI'm having trouble formatting documents. Despite searching, I've beenunable to find a complete guide to word processing with mathematica.Does anyone know where such a document could be found? ==== Look at in the Help browser or in the Mathematica Book Style Sheet Also, you have the documentation included for package Author Tools(only in Mathematica 4.2).Guillermo Sanchez > I would like to use mathematica type papers for my math courses, but> I'm having trouble formatting documents. Despite searching, I've been> unable to find a complete guide to word processing with mathematica.> Does anyone know where such a document could be found? ==== Kenny,Sympathy but no solution.I too have been trying to use Mathematica (v4.2 most recently) to typemaths papers and the like but I'm not ready to ditch LaTeX yet. Thereare just too many cases where I cannot figure out how to achieve what Iwant in Mathematica, things like:- left brackets spanning multiple lines for defining hybrid functions;- vertical alignment of equals signs in multi-line equations orderivations;- setting typefaces in tables of material.I figure most of this is do-able, but I don't have the time, orpatience, to spend too much time on it. So, I'll be the first customerwhen you write the guide to math publishing in Mathematica - I just hopeyou won't have to use LaTeX to write it.Mark Westwood> I would like to use mathematica type papers for my math courses, but> I'm having trouble formatting documents. Despite searching, I've been> unable to find a complete guide to word processing with mathematica.> Does anyone know where such a document could be found? ==== OrthogonalUnitVectors that I sent a few minutes ago doesn't do what Ithought it would.After making either definition below I get the following:In[2]:= s1=OrthogonalUnitVectors[{1,0,1/2,1,0},{0,1,-1,1/2,2}]Out[2] = {{0, -2/Sqrt[5], 0, 0, 1/Sqrt[5]}, {-2/3, -1/3, 0, 2/3, 0}, {-1/3, 2/3,2/3, 0, 0}}The dot products below aren't zero, so the vectors aren't orthogonal. Whatwent wrong?In[3]:= Part[s1,1].Part[s1,2]Out[3]= 2/(3*Sqrt[5])In[4]:= Part[s1,1].Part[s1,3]Out[3]= -4/(3*Sqrt[5])--------------> Hugh Goyder and David Park gave a most elegant function to find two> vectors that are orthogonal to one vector in 3D. The key to coming up> with the elegant solution is an understanding of Mathematica's NullSpace> function. We can easily make the version from Hugh and David much more> general with the version below.> -------------> OrthogonalUnitVectors[vect__?VectorQ]:= > #/Sqrt[#.#]&/@NullSpace[{vect}]> -------------> The version above will give a set of unit orthogonal vectors if given any> number of vectors in any dimension. > So besides giving it a 3D vector we can give it the following:> OrthogonalUnitVectors[{2,1,0,-1,1}]> or> OrthogonalUnitVectors[{0,1,0,1/2,1},{1,0,-1,1/2}]> ------------> But the short version above isn't very robust.> (1) Clear[x,y,z];NullSpace[{{x,y,z}}]> returns two vectors orthogonal to {x,y,z}, but the two vectors> NullSpace returns aren't orthogonal to each other. > So (OrthogonalUnitVectors) should only work with numeric vectors.> (2) We should ensure all the vectors have the same dimension and length>1.> I give a less concise version below that corrects these problems.> ------------> OrthogonalUnitVectors[vect__?(VectorQ[#,NumericQ]&)]/;> (SameQ@@Length/@{vect})&&(Length[First[{vect}]]>1):= > #/Sqrt[#.#]&/@NullSpace[{vect}]> --------------> Ted Ersek> Get Mathematica tips, tricks from> http://www.verbeia.com/mathematica/tips/Tricks.html> ==== Daniel Lichtblau has pointed out that NullSpace does not generally giveorthogonal vectors. Therefore the routines that depended upon that were inerror. He says that it does give orthogonal vectors when the input vectorcontains approximate numbers. For graphical purposes this will be goodenough for me. Therefore I modify Ted's routine toOrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ] &)] /; (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) := #/Sqrt[#.#] & /@ NullSpace[{vect}// N]and the short version for 3D vectorsOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@ NullSpace[{v//N}]For exact vectors I might use for 3DOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@ {temp = First[NullSpace[{v}]], v[Cross]temp}I'm still looking for something that is easy to remember.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ The version above will give a set of unit orthogonal vectors if given anynumber of vectors in any dimension.So besides giving it a 3D vector we can give it the following: OrthogonalUnitVectors[{2,1,0,-1,1}] or OrthogonalUnitVectors[{0,1,0,1/2,1},{1,0,-1,1/2}]------------ But the short version above isn't very robust.(1) Clear[x,y,z];NullSpace[{{x,y,z}}] returns two vectors orthogonal to {x,y,z}, but the two vectorsNullSpace returns aren't orthogonal to each other. So (OrthogonalUnitVectors) should only work with numeric vectors.(2) We should ensure all the vectors have the same dimension and length >1.I give a less concise version below that corrects these problems.------------OrthogonalUnitVectors[vect__?(VectorQ[# ,NumericQ]&)]/; (SameQ@@Length/@{vect})&&(Length[First[{vect}]]>1):= #/Sqrt[#.#]&/@NullSpace[{vect}]-------------- Ted Ersek Get Mathematica tips, tricks from http://www.verbeia.com/mathematica/tips/Tricks.html ==== I am unsure if my messages are making it through to the usegroup so I will try again. I have several differential equations I would like to plot in Mathematica. I would like to plot the Slope Fields of them though. Can anyone lead me in the right direction? I can solve the equations trivially but I want to display the slope fields. An example follows :y' + 2y = 3-John ==== John,You can do it from scratch with PlotVectorField from the Graphics`PlotField` package, but you make make your life easier (and get prettier plots) by using my DEGraphics package, which can be found at MathSource (it's part of the DiffEqs suite of packages) or here:http://www.math.armstrong.edu/faculty/hollis/mmade/ DiffEqs---Selwyn Hollis> I am unsure if my messages are making it through to the usegroup so I > will try again. I have several differential equations I would like to > plot in Mathematica. I would like to plot the Slope Fields of them > though. Can anyone lead me in the right direction? I can solve the > equations trivially but I want to display the slope fields. An example > follows :> y' + 2y = 3> -John> Reply-To: kuska@informatik.uni-leipzig.de ==== Needs[Graphics` PlotField`]PlotVectorField[{x, 3 - 2 y}, {x, 0, 4}, {y, -1, 4}, Axes -> True]??? Jens> I am unsure if my messages are making it through to the usegroup so I> will try again. I have several differential equations I would like to> plot in Mathematica. I would like to plot the Slope Fields of them> though. Can anyone lead me in the right direction? I can solve the> equations trivially but I want to display the slope fields. An example> follows :> y' + 2y = 3> -John ==== You can proceed like this :delta[poly2_, var_] := Coefficient[poly2, var, 1]^2 - 4*Coefficient[poly2,var, 0]*Coefficient[poly2, var, 2]Meilleures salutationsFlorian Jaccard-----Message d'origine-----Envoy.8e : ven., 6. septembre 2002 09:17è : mathgroup@smc.vnet.netObjet : Coefficient problemNow I'm trying to calculate this formula:Delta[eq_, x_]:=Coefficient[eq, x]^2 - 4 Coefficient[eq, x^2]Coefficient[eq, x^0]eq has this form a x^2 + b x + cBut there is a problem with the x^0 coefficient!How can I overcome that?CeZaR ==== This works:eq = a x^2 + b x + cdiscriminant[eq_, x_] := Coefficient[eq, x]^2 - 4 Coefficient[eq, x, 2] Coefficient[eq, x, 0]discriminant[eq, x]x^0 is reduced to 1 and the Coefficient of 1 doesn't make sense toMathematica, because it depends on what the variable is (a, b, c, orx?). So, the other form of the Coefficient call is needed. I used itfor the second power too, but that wasn't necessary. I think that formis best, though, since it allows no ambiguity.I renamed the function because that's what the quantity is often called,for a quadratic.Bobby Treat-----Original Message-----CeZaR ==== >-----Original Message----->Sent: Friday, September 06, 2002 9:17 AM>myArray is a list of triplets which look like {n,k,p}, where n and k>are integers and p is real number. repetitions in n and k are allowed>but no two triplets ar the same.>>I define a function, myfunc[n_,pthreshold_] as follows.>>myfunc[n_,pthreshold_] := Module[{t},>t=Max[Cases[myArray, {n, k_, p_} /; (p >= pthreshold) -> p, 2]];>If[t>=0,t,-1]]>>It prints the largest k for which p is greater than pthreshold for a>given n and>-1 if there is no such k. The function does its job fine. >>My problem is as follows. I would like to plot a collection of plots,>myfunc[n,p], for 1<=n<=21 with respect to p. unfortunately the>following does not work as desired.>>Plot[Table[myfunc[n,p],{n,1,21}],{p,0.0,1.0}] >>because the Table gets evaluated to numeric value (-1) before Plot is>invoked.>The problem with your calculation indented is (1) to evaluate Table (withinPlot), which gives {myfunc[1, p], ..., myfunc[21, p]}but (2) *then* to prevent further evaluation of myfunc[.., p] to -1. Thereare several tricks to do so, e.g. ...Hold[Plot[toPlot, {p, 0, 1}]] /. toPlot -> Table[headPlaceholder[n, p], {n, 3}] /. headPlaceholder -> myfunc // ReleaseHold...but in your case just simply prevent evaluation of myfunc[.., p] with pbeing a Symbol by defining:myfunc2[n_, pthreshold_?NumericQ] := ...now...Plot[Evaluate[Table[myfunc2[n, p], {n, 21}]], {p, 0, 1}]...works as expected.BTW, what do you want to read off the plot, that you didn't know fromTable[myfunc[n, 0], {n, 21}] ?--Hartmut Wolf ==== >-----Original Message----->Sent: Friday, September 06, 2002 9:17 AM When I multiply an expression with 0 it is giving 0.expression which>is creating problem in the further calculation.>>eg.>>In[1]:=func1[r_]:=Exp[-r/2]>In[2]:coeff[[ 1,1]]=0.0;>;>;>In[34]:=func1[r]coeff[[1,1]]>>Out[34]:=0.Exp[- r/2]>>I want anything to be multiply by zero must be zero. How can I do that? >Your suggestion will be highly appreciated.> Raj>Raj,this simply is, because 0. Exp[-r/2] is not always zero! func1[-Infinity]coeff[[1, 1]]Infinity::indet: Indeterminate expression 0. Infinity encountered.Out[90]= Indeterminate--Hartmut Wolf ==== I have a mathematica notebook showing using the alternating direction implicit method for solving heat conduction in 2D via finite difference methods. Moving from 2D to 3D is pretty simple although I can't find my notebook on this anymore :( . The 3D method is sometimes called Brian's method. http://mid-ohio.mse.berkeley.edu/scott/projects/index.html Scott> Could you help me?> I'm to solve heat conductivity equation (Laplas > equation) - partial differential equation. Are there > any ready-to-use packages that will help me do the job?> Standard function DSolve cannot! And so do functions > from package Calculus`DSolveIntegrals`.> More info: the space where the equation is to be > solved is cylindre (not infinite).> Andrew.> ==== I am working with Mathematica 4.0, and I would like pass my data todo one graphic in Origin 5.0. How can I do this in more simple manner? ==== > I need to fill the space between two contour lines, C1 and C2, with> red color, and leave the other place white. What trick I have to use?> Any suggestion and advice will be appreciated.Over the years I have alighted upon the following scheme. Suppose I want tocolor only between contour levels 1 and 2:In[84]:=Needs[Graphics`Colors`]In[88]:=ContourPlot[x, {x, -1, 3}, {y, 0, 1}, Contours -> {0, 1, 2, 3, 4}, ColorFunction -> (If[1 < # < 2, Red, White] & ), ColorFunctionScaling -> False];1. Specify the specific contour levels instead of specifying only the count.2. Disable ColorFunctionScaling so the argument to ColorFunction correspondsto the contour levels.Hope this helps,Tom Burton ==== David Park replied with----------------Daniel Lichtblau has pointed out that NullSpace does not generally giveorthogonal vectors. Therefore the routines that depended upon that were inerror. He says that it does give orthogonal vectors when the input vectorcontains approximate numbers. For graphical purposes this will be goodenough for me. Therefore I modify Ted's routine toOrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ] &)] /; (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) := #/Sqrt[#.#] & /@ NullSpace[{vect}// N]----------------Lets see what NullSpace does with approximate complex vectors.In[1]:= v1 = {1.0 I, 0.0, 0.5 I, 0.0, 1.0}; v2 = {0.0, 2.0, 1.0 I, 2.0, 0.5}; {v3,v4,v5} = NullSpace[{v1,v2}]Out[3]= {{-0.730153 + 0.*I, 0. - 0.138254*I, 0.250585 + 0.*I, 0. - 0.138254*I, 0.+ 0.60486*I}, {0. + 0.*I, -0.515861 + 0.*I, 0. + 0.457321*I, 0.687357 + 0.*I, 0.22866+ 0.*I}, {0. + 0.*I, 0.510406 + 0.*I, 0. + 0.740442*I, -0.23274 + 0.*I, 0.370221+ 0.*I}}--------In the next line we see NullSpace returned vectors that are orthogonal tothe vectors we gave NullSpace.In[4]:= {v1.v3, v1.v4, v1.v5, v2.v3, v2.v4, v2.v5}//ChopOut[4]= {0, 0, 0, 0, 0, 0}----------However, the vectors returned aren't orthogonal to each other.In[5]:= {v3.v4, v3.v5, v4.v5}//ChopOut[5]= {0.229195*I, 0.371087*I, -0.677239}---------I suppose an OrthogonalUnitVectors function that uses NullSpace should (1) Only accept real valued vectors. (2) Ensure NullSpace is given approximate vectors.------ Ted Ersek ==== >OrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ] &)] /;> (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) :=> #/Sqrt[#.#] & /@ NullSpace[{vect}// N]---------------->>Lets see what NullSpace does with approximate complex vectors.>>In[1]:=> v1 = {1.0 I, 0.0, 0.5 I, 0.0, 1.0};> v2 = {0.0, 2.0, 1.0 I, 2.0, 0.5};> {v3,v4,v5} = NullSpace[{v1,v2}]>>Out[3]=> {{-0.730153 + 0.*I, 0. - 0.138254*I, 0.250585 + 0.*I, 0. - 0.138254*I,>0.>+ 0.60486*I}, > {0. + 0.*I, -0.515861 + 0.*I, 0. + 0.457321*I, 0.687357 + 0.*I, 0.22866>+ 0.*I}, > {0. + 0.*I, 0.510406 + 0.*I, 0. + 0.740442*I, -0.23274 + 0.*I, 0.370221>+ 0.*I}}-------->In the next line we see NullSpace returned vectors that are orthogonal to>the vectors we gave NullSpace.>>In[4]:=> {v1.v3, v1.v4, v1.v5, v2.v3, v2.v4, v2.v5}//Chop>>Out[4]=> {0, 0, 0, 0, 0, 0}---------->However, the vectors returned aren't orthogonal to each other.>>In[5]:=> {v3.v4, v3.v5, v4.v5}//Chop>>Out[5]=> {0.229195*I, 0.371087*I, -0.677239}--------->I suppose an OrthogonalUnitVectors function that uses NullSpace should > (1) Only accept real valued vectors. > (2) Ensure NullSpace is given approximate vectors.------> Ted ErsekI think you will find that the output vectors are orthogonal if you use thecomplex conjugate. for example v4.Conjugate[v5] is zero.Dennis Wangsness ==== >I need to fill the space between two contour lines, C1 and C2, with>red color, and leave the other place white. What trick I have to use?>Any suggestion and advice will be appreciated.Needs[Graphics`FilledPlot`];Needs[Graphics `Colors`];FilledPlot[{4 - x^2, 3x}, {x, -4, 1}, Fills -> Red];Bob Hanlon ==== >For my PDE class we have been calculating Fourier transforms. The instructor>arrived today with a printout of two plots of a certain Fourier transform,>done with a different CAS. The first plot was to 30 terms, the second was>to>120 terms.> Curious, I translated the functions into Mathematica (4.0 on Windows2000>on a PIII 700) to see how much time this required to process. I was>Staggered at how much time it took. Here's the code:>>L = 2;>f[x_] := UnitStep[x - 1];>b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];>>FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];>>Timing[Plot[FS[30, x], {x, 0, 2}]]>>Out[23]=>{419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]}>>In this case the number of terms is 30.>>The time required per number of terms seems to fit the following polynomial:>>y = 0.3926x^2 + 2.2379x>>This is a large amount of time. I understand that the code is not optimized,>and was more or less copied from the code in the other CAS, but is this>a>reasonable amount of time, or is something going wrong? I don't use Mathematica>because of the speed, but should it be this slow?>>Just curious,Your definition of b recalculates the integral for every call. To evaluate the integral onceinclude Evaluate.Clear[f, b, FS];L = 2;f[x_] := UnitStep[x - 1];b[n_] := Evaluate[ (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]];In the case of FS it is best to wait for an integer value of N prior to performing the Sum.FS[N_Integer, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];Now Evaluate the argument of the Plot to cause the Sum to be done once.Timing[Plot[Evaluate[FS[120, x]], {x, 0, 2}]][[1]]0.366667 SecondWhile my computer may be faster than yours, this result for N=120 is 1000 times faster than your result for N=30.Bob Hanlon ==== > Now I'm trying to calculate this formula:> Delta[eq_, x_]:=Coefficient[eq, x]^2 - 4 Coefficient[eq, x^2] Coefficient[eq, x^0]> eq has this form a x^2 + b x + c> But there is a problem with the x^0 coefficient!> How can I overcome that?> CeZaRCoefficient cannot figure out who is and is not a variable when avariable of 1 is specified. To work around this you might instead dodelta1[poly_, x_] := Coefficient[poly,x]^2 - 4*Coefficient[poly,x,2]*Coefficient[poly,x,0]I prefer instead to use CoefficientList:delta2[poly_, x_] := (#[[2]]^2 - 4*#[[1]]*#[[3]])&[CoefficientList[poly,x]]In[25]:= poly = a*x^2+b*x+c;In[26]:= delta1[poly,x] === delta2[poly,x]Out[26]= TrueDaniel LichtblauWolfram Research ==== >>Delta[eq_, x_]:=Coefficient[eq, x]^2 - 4 Coefficient[eq, x^2] Coefficient[eq,>x^0]>>eq has this form a x^2 + b x + c>>But there is a problem with the x^0 coefficient!>How can I overcome that?see on-line help for Coefficientdelta[eq_, x_] := Coefficient[eq, x, 1]^2 - 4 *Coefficient[eq, x, 2] *Coefficient[eq, x, 0];eq = a*x^2 + b*x + c;delta[eq, x]b^2 - 4*a*cBob Hanlon ==== Would someone with a very fast machine and lots of memory be willing to try this Solve for me?It is the inverse of the 20 node quadratic hexahedral mapping used in finite element analysis.None of my computers can handle this - they run out of memory (using (*Hex20 Node definition in global coordinates *)Clear[x1, y1, z1,x2, y2, z2,x3, y3, z3,x4, y4, z4,x5, y5, z5,x6, y6, z6,x7, y7, z7,x8, y8, z8,x9, y9, z9,x10, y10, z10,x11, y11, z11,x12, y12, z12,x13, y13, z13,x14, y14, z14,x15, y15, z15,x16, y16, z16,x17, y17, z17,x18, y18, z18,x19, y19, z19,x20, y20, z20];(* local coordinates *)Clear[u, v, w];(* Global co-ordinates *)Clear[x, y, z];(* corner nodes *)N1= (1-u)*(1-v)*(1-w)*(-2-u-v-w)/8;N3= (1+u)*(1-v)*(1-w)*(-2+u-v-w)/8;N5= (1+u)*(1+v)*(1-w)*(-2+u+v-w)/8;N7= (1-u)*(1+v)*(1-w)*(-2-u+v-w)/8;N13=(1-u)*(1-v)*(1+w)*(-2-u-v +w)/8;N15=(1+u)*(1-v)*(1+w)*(-2+u-v+w)/8;N17=(1+u)*(1+v)*(1 +w)*(-2+u+v+w)/8;N19=(1-u)*(1+v)*(1+w)*(-2-u+v+w)/8;(* to u nodes *)N2= (1-u^2)*(1-v)*(1-w)/4;N6= (1-u^2)*(1+v)*(1-w)/4;N14=(1-u^2)*(1-v)*(1+w)/4;N18=(1-u^2) *(1+v)*(1+w)/4;(* to v nodes *)N4= (1+u)*(1-v^2)*(1-w)/4;N8= (1-u)*(1-v^2)*(1-w)/4;N16=(1+u)*(1-v^2)*(1+w)/4;N20=(1-u)*( 1-v^2)*(1+w)/4;(* to w nodes *)N9= (1-u)*(1-v)*(1-w^2)/4;N10=(1+u)*(1-v)*(1-w^2)/4;N11=(1+u)*( 1+v)*(1-w^2)/4;N12=(1-u)*(1-v)*(1-w^2)/4;(* solve the inverse transform *)Solve[{x1*N1+x2*N2+x3*N3+x4*N4+x5*N5+x6*N6+x7*N7+x8*N8+x9 *N9+x10*N10+x11*N11+x12*N12+x13*N13+x14*N14+x15*N15+x16*N16+ x17*N17+x18*N18+x19*N19+x20*N20-x==0,y1*N1+y2*N2+y3*N3+y4* N4+y5*N5+y6*N6+y7*N7+y8*N8+y9*N9+y10*N10+y11*N11+y12*N12+y13 *N13+y14*N14+y15*N15+y16*N16+y17*N17+y18*N18+y19*N19+y20*N20 -y==0,z1*N1+z2*N2+z3*N3+z4*N4+z5*N5+z6*N6+z7*N7+z8*N8+z9*N9+ z10*N10+z11*N11+z12*N12+z13*N13+z14*N14+z15*N15+z16*N16+z17* N17+z18*N18+z19*N19+z20*N20-z==0},{u,v,w}]Christopher J. PurcellDefence R&D Canada .9a Atlantic9 Grove St., PO Box 1012Dartmouth NS Canada B2Y 3Z7 ==== Needs[Graphics`Colors`];ContourPlot[Sin[x y], {x, -5, 5}, {y, -5, 5}, ColorFunction -> (If[0.5 < # < 0.7, Red, White] &)];Bob Hanlon>ContourPlot?>Jun Lin > In a message dated 9/6/02 3:53:58 AM,>I need to fill the space between two contour lines,> C1 and C2, with>red color, and leave the other place white. What> trick I have to use?>Any suggestion and advice will be appreciated.> Needs[Graphics`FilledPlot`];> Needs[Graphics`Colors`];> FilledPlot[{4 - x^2, 3x}, {x, -4, 1}, Fills -> Red]; ==== Jun Lin,Here is an example.Needs[Graphics`Colors`]Let's make a contour plot of this function.f[x_, y_] := Sin[x]Sin[2y]Let's specify the exact contours to use. I got rid of the 0. contour becauseit is difficult to obtain in this plot.contourvalues = Complement[Range[-1, 1, 0.2], {0.}]{-1, -0.8, -0.6, -0.4, -0.2, 0.2, 0.4, 0.6, 0.8, 1.}Now we define a ColorFunction for the plot. I actually colored two differentbands to show how you can make a general color function to give each band adesired color.cfun[z_] := Which[ -0.6 < z < -0.42, RoyalBlue, 0.4 < z < 0.6, Red, True, White]ContourPlot[f[x, y], {x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 30, ColorFunctionScaling -> False, ColorFunction -> cfun, Contours -> contourvalues];Using the option ColorFunctionScaling -> False says that the z value will bethe actual value of f[x,y]. Otherwise, in general, it will be scaled between0 and 1. It is easier to write a color function when z is the actual valueof the function.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.netApproved: Steven M. Christensen , ModeratorReply-To: ==== I checked again the six solutions I had previously timed, and they DOgive orthogonal results. (None of them depend on NullSpace for that.)By the way, I reused my combinations function (from a recent problemon adding fractions to get 1) to check for orthogonality: ClearAll[orthogonalQ] orthogonalQ[v : {__?VectorQ}] := And @@ (Chop@(Dot @@ #) == 0 & /@ combinations[v, {2}]) << DiscreteMath`Combinatorica`; ClearAll[combinations]; r = Range[1, 9]; combinations::usage = combinations[list,n:{__Integer}] lists the combinations of list taken n at a time; combinations[r_List, n_Integer, {}] := If[n > Length@r, {}, DiscreteMath`Combinatorica`KSubsets[r, n]]; combinations[r_List, n_Integer, e_?VectorQ] := Join[e, #] & /@ DiscreteMath`Combinatorica`KSubsets[Complement[r, e], n]; combinations[r_List, n_Integer, e : {__?VectorQ}] := Flatten[ combinations[r, n, #] & /@ e, 1]; combinations[r_List, n : {__Integer}] := Which[Plus @@ n ==Length@r, Join[#, Complement[r, #]] & /@ combinations[r, Drop[n, -1]], Plus @@ n > Length@r, {}, True, Fold[ combinations[r, #2, #1] &, {}, n]]Bobby-----Original Message----- (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) := #/Sqrt[#.#] & /@ NullSpace[{vect}// N]and the short version for 3D vectorsOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@NullSpace[{v//N}]For exact vectors I might use for 3DOrthogonalUnitVectors[v : {_, _, _}] := #/Sqrt[#.#] & /@ {temp = First[NullSpace[{v}]], v[Cross]temp}I'm still looking for something that is easy to remember.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ OrthogonalUnitVectors[vect__?VectorQ]:= #/Sqrt[#.#]&/@NullSpace[{vect}]-------------The version above will give a set of unit orthogonal vectors if givenanynumber of vectors in any dimension.So besides giving it a 3D vector we can give it the following: OrthogonalUnitVectors[{2,1,0,-1,1}] or OrthogonalUnitVectors[{0,1,0,1/2,1},{1,0,-1,1/2}]------------ But the short version above isn't very robust.(1) Clear[x,y,z];NullSpace[{{x,y,z}}] returns two vectors orthogonal to {x,y,z}, but the two vectorsNullSpace returns aren't orthogonal to each other. So (OrthogonalUnitVectors) should only work with numeric vectors.(2) We should ensure all the vectors have the same dimension and length>1.I give a less concise version below that corrects these problems.------------OrthogonalUnitVectors[vect__?(VectorQ[# ,NumericQ]&)]/; (SameQ@@Length/@{vect})&&(Length[First[{vect}]]>1):= #/Sqrt[#.#]&/@NullSpace[{vect}]-------------- Ted Ersek Get Mathematica tips, tricks from http://www.verbeia.com/mathematica/tips/Tricks.html ==== I have substituted the letters SS, CC, X, Y and Z1 and Z2 for some complicated expressions just to illustrate the form of the function. This function works and all the conditions are necessary but I am sure a more elegant programming solution perhaps using While could be found. Any f[{Sa_, Ca_, Aa_, Sb_, Cb_, Ab_, a_, b_}] := {If[Aa == Ab, a Sa + b Sb, If[Ca == 0 || Cb == 0, a Sa + b Sb, SS]], If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0, Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0, Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0, Nil, If[Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0, Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} ==== Check out the Help for Coefficient.Coefficient[expr, form, 0] picks out terms that are not proportional toform.Delta[eq_, x_] := Coefficient[eq, x]^2 - 4 Coefficient[eq, x^2] Coefficient[eq, x, 0]Delta[a x^2 + b x + c, x]b^2 - 4*a*cDavid Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/=== =Dear all,1.) How to find the General Solution for below's partial differential equation? (y + u) du/dx + y (du/dy) = x - y** I use d to represent the partial differential symbol.Can it be solved by function NDSolve in mathematica 4.1? How?2.) I manage to get the roots of complex equation z^5 = i fromSolve[z^5 == i, z]. It gave me straight the 5 roots in the output.Is there any way to view the steps in mathematica?Shz Shz ==== ===================================================== ==== =====================of the individual or entity to which they are addressed. Any disclosure, copying,distribution and diversion contrary to the applicable export control laws andregulations including US Export Administration Regulations is strictly prohibited.and do not disclose it to others. Please notify the postmaster@hitachi.com.myof the delivery error by replying to this message and then delete it from your ==== =================================================== ==== ===========================I have been trying to code Sethian's Fast Marching Method in 2D but Mathematicahas been very slow (taking something like 1-2 hours for something thatshould take much less than a second in C++). I am sure part of the problemmy time.I looked at the list archives and there was mention of an profilingpackage for Mathematica but a)I can't find it & b)It may not work with Mathematica 4.*.My questions:1. Any general suggestions on how to figure out which functions are takingmost of the time? I guess I could manually have each function I aminterested in monitoring keep a variable that counts the amount of CPUtime that has been spent on it by doing something like:function[args_]:=Module[{},functionTimer+=Timing[ .... My actual function..... ][[1]]]but it would very cumbersome to do this to all of the functions in myprogram and I am not sure I will get accurate results anyway.2. Compiling functions is not always that easy. I did read the on-linedocs and the archives and it does take some work to make a functioncompile usefully. Is there an FAQ or a tutorial somewhere?3. Am I the only one who finds the lack of a profiler really reallyannoying ? Mathematica is powerful and it is usually easy to ask it to do what uwant. The challenge a lot of times is doing so without taking too long.HusainPS: One more quick one: Why does the front end act funny when I have the ==== Caution: the definitionb[n_] := Evaluate[(2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]];doesn't immediately compute the integral unless f is already defined atthis point, and in that case you may as well writeb[n_] = (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];instead. If b will be computed more than once for the same n, its evenbetter to do it THIS way (if f and L do not change):f[x_] = Cos[x] (* for example *)Simplify[Integrate[f[x]*Sin[n*Pi*(x/L)], {x, 0, L}]](L*((-n)*Pi + n*Pi*Cos[L]*Cos[n*Pi] + L*Sin[L]*Sin[n*Pi]))/ ((L - n*Pi)*(L + n*Pi))b[n_] := b[n] = (L*((-n)*Pi + n*Pi*Cos[L]*Cos[n*Pi] + L*Sin[L]*Sin[n*Pi]))/ ((L - n*Pi)*(L + n*Pi))Bobby-----Original Message-----Stephan Steinhaus (steinhaus-net.de). So when Mathematica takes a verylongtime, you should investigate. In this case inserting Evaluate[] in twoplacesIn[91]:=b[n_] := Evaluate[(2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0,L}]];....In[104]:=Timing[Plot[Evaluate[FS[120, x]], {x, 0, 2}]]Out[104]={0.18 Second,[SkeletonIndicator]Graphics[SkeletonIndicator]} speeds the process enormously (18 milliseconds to plot 120 terms on myfeeble old 500MHz PowerBook).Why was it so slow before? When I switch from an ordinary numericallanguageto Mathematica, I enter into an implicit bargain withMathematica: the software will go the extra mile to get me a goodanswer,including (1) using exra precision (sometimes without being asked) and(2)carrying around unevaluated mathematical expressions (usually withoutbeingasked) that could possibly be evaluated more appropriately at a latertime.Most tools cannot do either of these things, so I don't have to worryaboutit, except for the bad answers that result now and then. But I need totakecare that Mathematica does not burden itself unnecessarily. That's mysideof the bargain.Number (2) is the issue here. Your definition of b[n] is written so thatMathematica analytically evaluates b separately for each n. But you knowinthis case that the integration can be done safely once for all n. So doit!The huge difference, though, comes from pre-evaluating the argument toPlot.Read the on-line help! You should pre-evaluate where possible. In somecases, the most common of which involve branching within the definitionoffunction to plot, you cannot pre-evaluate so, in keeping with thebargain,Mathematica goes the extra mile and holds back just in case. You need tosteer it into the shortcut when it's OK.Hope this helps,Tom Burton-- ==== With the second method below (mine), the times add up to 40% less than with the first method (Jens-Peer's), for what SEEMS to be exactly the same work. Go figure!Can anybody explain that?(* Jens-Peer *)ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}];FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.547 Second, .89»¡Graphics.89»[DownExcl amation]}(* Treat #1 *)Timing[(2/L)*Integrate[f[x]*Sin[n*Pi*(x/L)], {x, 0, L}]]{0.016000000000000014*Second, (2*(Cos[(n*Pi)/2] - Cos[n*Pi]))/(n*Pi)}ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2*(Cos[(n*Pi)/2] - Cos[n*Pi]))/(n*Pi);FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.297 Second, .89»¡Graphics.89»[DownExcl amation]}Even stranger, it SLOWS the Plot if we precompute b before Timing starts:(* Treat #2 *)ClearAll[f, b, FS]L = 2; f[x_] := UnitStep[x - 1]; b[n_] := b[n] = (2*(Cos[(n*Pi)/2] - (-1)^n))/(n*Pi); b /@ Range[30]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}]; Timing[Plot[FS[30, x], {x, 0, 2}]]{0.328 Second, .89»¡Graphics.89»[DownExcl amation]}But here's a winner:(* Treat #3 *)ClearAll[f, b, FS]L = 2; f[x_] := UnitStep[x - 1]; b[n_] := b[n] = N[(2*(Cos[(n*Pi)/2] - (-1)^n))/ (n*Pi)]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}]; Timing[Plot[FS[30, x], {x, 0, 2}]]{0.204 Second, .89»¡Graphics.89»[DownExcl amation]}Apparently, computing b within the Plot causes machine-precision arithmetic to be used, and that saves time. Precomputing b and then converting exact expressions to approximate ones within the Plot seems to take longer. For that to make sense, I think it must be that n is approximate (not Integer) when it is passed to b within Plot.Bobby Treat-----Original Message-----and you need only a 1-3 seconds (depending on your machine) Jens For my PDE class we have been calculating Fourier transforms. The instructor> arrived today with a printout of two plots of a certain Fourier transform,> done with a different CAS. The first plot was to 30 terms, the second was to> 120 terms.> Curious, I translated the functions into Mathematica (4.0 on Windows2000> on a PIII 700) to see how much time this required to process. I was> Staggered at how much time it took. Here's the code: L = 2;> f[x_] := UnitStep[x - 1];> b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}]; Timing[Plot[FS[30, x], {x, 0, 2}]] Out[23]=> {419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]} In this case the number of terms is 30. The time required per number of terms seems to fit the following polynomial: y = 0.3926x^2 + 2.2379x This is a large amount of time. I understand that the code is not optimized,> and was more or less copied from the code in the other CAS, but is this a> reasonable amount of time, or is something going wrong? I don't use Mathematica> because of the speed, but should it be this slow? Just curious, Steve Story ==== Even better -- MUCH better -- add Bob Hanlon's Evaluate to the other tricks:ClearAll[f, b, FS]L = 2; f[x_] := UnitStep[x - 1]; b[n_] := b[n] = N[(2*(Cos[(n*Pi)/2] - (-1)^n))/(n*Pi)]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}]; Timing[Plot[Evaluate[FS[30, x]], {x, 0, 2}]]{0.015 Second, .89»¡Graphics.89»[DownExcl amation]}ClearAll[f, b, FS]L = 2; f[x_] := UnitStep[x - 1]; b[n_] := b[n] = N[(2*(Cos[(n*Pi)/2] - (-1)^n))/(n*Pi)]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}]; Timing[Plot[Evaluate[FS[120, x]], {x, 0, 2}]]{0.063 Second, .89»¡Graphics.89»[DownExcla mation]}Bobby Treat-----Original Message-----Timing[Plot[FS[30, x], {x, 0, 2}]]{0.547 Second, .89»¡Graphics.89»[DownExcla mation]}(* Treat #1 *)Timing[(2/L)*Integrate[f[x]*Sin[n*Pi*(x/L)], {x, 0, L}]]{0.016000000000000014*Second, (2*(Cos[(n*Pi)/2] - Cos[n*Pi]))/(n*Pi)}ClearAll[f, b, FS]L = 2;f[x_] := UnitStep[x - 1];b[n_] := b[n] = (2*(Cos[(n*Pi)/2] - Cos[n*Pi]))/(n*Pi);FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}];Timing[Plot[FS[30, x], {x, 0, 2}]]{0.297 Second, .89»¡Graphics.89»[DownExcl amation]}Even stranger, it SLOWS the Plot if we precompute b before Timing starts:(* Treat #2 *)ClearAll[f, b, FS]L = 2; f[x_] := UnitStep[x - 1]; b[n_] := b[n] = (2*(Cos[(n*Pi)/2] - (-1)^n))/(n*Pi); b /@ Range[30]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}]; Timing[Plot[FS[30, x], {x, 0, 2}]]{0.328 Second, .89»¡Graphics.89»[DownExcl amation]}But here's a winner:(* Treat #3 *)ClearAll[f, b, FS]L = 2; f[x_] := UnitStep[x - 1]; b[n_] := b[n] = N[(2*(Cos[(n*Pi)/2] - (-1)^n))/ (n*Pi)]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*(x/L)], {n, 1, N}]; Timing[Plot[FS[30, x], {x, 0, 2}]]{0.204 Second, .89»¡Graphics.89»[DownExcl amation]}Apparently, computing b within the Plot causes machine-precision arithmetic to be used, and that saves time. Precomputing b and then converting exact expressions to approximate ones within the Plot seems to take longer. For that to make sense, I think it must be that n is approximate (not Integer) when it is passed to b within Plot.Bobby Treat-----Original Message-----and you need only a 1-3 seconds (depending on your machine) Jens For my PDE class we have been calculating Fourier transforms. The instructor> arrived today with a printout of two plots of a certain Fourier transform,> done with a different CAS. The first plot was to 30 terms, the second was to> 120 terms.> Curious, I translated the functions into Mathematica (4.0 on Windows2000> on a PIII 700) to see how much time this required to process. I was> Staggered at how much time it took. Here's the code: L = 2;> f[x_] := UnitStep[x - 1];> b[n_] := (2/L)*Integrate[f[x]*Sin[n*Pi*x/L], {x, 0, L}]; FS[N_, x_] := Sum[b[n]*Sin[n*Pi*x/L], {n, 1, N}]; Timing[Plot[FS[30, x], {x, 0, 2}]] Out[23]=> {419.713 Second, [SkeletonIndicator]Graphics[SkeletonIndicator]} In this case the number of terms is 30. The time required per number of terms seems to fit the following polynomial: y = 0.3926x^2 + 2.2379x This is a large amount of time. I understand that the code is not optimized,> and was more or less copied from the code in the other CAS, but is this a> reasonable amount of time, or is something going wrong? I don't use Mathematica> because of the speed, but should it be this slow? Just curious, Steve Story ==== How can I plot with Mathematica two function in the same graphic?I explain better:compare a and b). ==== (1) Is there a way in Mathematica 4.2 to put two separate gifs into asingle, cell side by side (with some intervening space), withouthaving to combine them in some graphics program first?In particular, I'd like to do that within a text cell.Even in a new Input cell, if I first create a GridBox (via Inut>CreateTable/Matrix/Palette) and then try to insert the first gif (viaEdit>Insert Object>Create from File ....), Mathematica promptlycrashes. (Mathematica 4.2 under Windows 2000.)I just don't see how to get anything other than a single gif into acell.(2) Is there a way to cause a gif imported into a Mathematica 4.2notebook to become a hyperlink -- so that when the user clicks on thegif the hyperlink's target is summoned?(My aim in all this is to use Mathematica to create web pages withhigh mathematical content -- saving the notebook as HTML+MathML --without having to do any extensive editing of the resulting .xml andrelated files. That way as the source Mathematica notebook changes, Iwould need only to re-export without further tinkering with the .xmlfile, etc.) -- Murray Eisenberg Internet: murray@math.umass.edu Mathematics & Statistics Dept. Voice: 413-545-2859 (W) University of Massachusetts 413-549-1020 (H) ==== Your method 1), below, does not produce correct results if one thenuses menu>Save As Special>HTML+MathML.I view the resulting .xml file in a MathML-enabled browser (e.g.,Mozilla with appropriate TrueType fonts installed -- the four BaKoMacm fonts, the old Mathematica Math1, etc., fonts, and the two MTfonts. Then the everything in the originally multi-line inline cellappears on one line separate by a ?, as do the alignment markers. Inthe page source, these unrendered symbols have codes #8289 and #63328,respectively.Is there an issue of the encoding used in the browser here? I did tryUnicode-7, Unicode-8, and several of the Western encodings availableunder Mozilla's Default Character Encoding.Or is it something else? Note that I do also have the newMathematica TrueType fonts (Mathematica1, etc.).P.S. I don't think Mathematica documents this, but if one wants a fileexported from Mathematica as HTML+MathML to be rendered correctly by abrowser, it seems to require an extension of .xml rather than .html. >>When writing a series of equations in mathematica (in a text cell) >>is there any way to align the equations at the = similar to >>what can be done in the equation editor made by math type (used >>in word etc.)? > Mike, > Two ways > 1) Start an inline cell in your text cell (menu>Edit>ExpressionInput>Start > Inline Cell) > Type in your equations with the alignment marker (Esc am Esc) inafter each > equal sign. > Close the inline cell (menu>Edit>Expression Input>End Inline Cell). > Select the text cell (or the inline cell, though this is a delicate > operation, do it by repeatedly double clicking in it}. > Use menu> Format>Text Alignment>On Alignment Marker. > -- you will find that all single letters are now italic - you can select > individual letters and change this - alternatively you can select theinline > cell and use the option inspector (menu>Format>Option Inspector) to set > SingleLetterItalics->False) > -- you can put existing text in an inline cell by selcting it and using > menu>Edit>Expression Input>Start Inline Cell, but you may have to adjust > the line breaks after this.... -- Murray Eisenberg Internet: murray@math.umass.edu Mathematics & Statistics Dept. Voice: 413-545-2859 (W) University of Massachusetts 413-549-1020 (H) ==== Group,Can anyone help me with the following? I guess this is something trivial for most of you, but I have being struggling with it for weeks.The problem is to construct a taxonomic hierarchy whose structure is hereby described by example:<< DiscreteMath`Combinatorica`n[1]:= m = 10;(*with the following I get the 1th level (1--element) partition*)in[2]:= ks1 = Partition[Range[m], 1](*Now the following gives all the 2th-level (?) different partitions that can be set up by joining two elements in the 1-element partition and leaving the rest as they are?*)(*First, these are all possible Ôjoinings' to generate the two elements Ôpieces' from 1th level (1--element) partition*)in[3]:= ks2 = KSubsets[Range[m], 2](*And this generates all the 2th-level (?) different partitions that can be set up by joining two elements in the 1-element partition and leaving the rest as they are.*)in[4]:= p2 = MapThread[Complement[Append[#1, #2], (Sequence @@ {#} & /@ Partition[#2, 1])] &, {Array[ks1&, Length[ks2]], ks2}];Length[p2]in[5]:= p2[[1]]out[5]:= {{3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {1, 2}}in[6]:= p2[[Length[p2]]]out[6]:= {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9, 10}}(*compute in[4] t and see the full output*)(*Now I need to solve the problem of given the ith-level (?) different partitions to set up all the i+1th different partitions by joining two elements in the ith level partition and leaving the rest as they are? *)(*for example given the following 2th-level partition*){3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {1, 2}(*we should get*){{{4}, {5}, {6}, {7}, {8}, {9}, {10}, {1, 2, 3}},{{3}, {5}, {6}, {7}, {8}, {9}, {10}, {1, 2, 4}},{{3}, {4}, {6}, {7}, {8}, {9}, {10}, {1, 2, 5}},{{3}, {4}, {5}, {7}, {8}, {9}, {10}, {1, 2, 6}},{{3}, {4}, {5}, {6}, {8}, {9}, {10}, {1, 2, 7}},{{3}, {4}, {5}, {6}, {7}, {9}, {10}, {1, 2, 8}},{{3}, {4}, {5}, {6}, {7}, {8}, {10}, {1, 2, 9}},{{3}, {4}, {5}, {6}, {7}, {8}, {9}, {1, 2, 10}}}(*The process would end up to *){1,{2,3,4,5,6,7,8,9,10}}{2,{1,3,4,5,6,7,8,9,10}}{3,{ 1,2,4,5,6,7,8,9,10}}{4,{1,2,3,5,6,7,8,9,10}}{5,{ 1,2,3,4,6,7,8,9,10}}{6,{1,2,3,4,5,7,8,9,10}}{7,{ 1,2,3,4,5,6,8,9,10}}{8,{1,2,3,4,5,6,7,9,10}}{9,{ 1,2,3,4,5,6,7,8,10}}{10,{1,2,3,4,5,6,7,8,9}}(* and*){1,2,3,4,5,6,7,8,9,10}Emilio Martin-Serrano ==== > I too have been trying to use Mathematica (v4.2 most recently) to type> maths papers and the like but I'm not ready to ditch LaTeX yet. There> are just too many cases where I cannot figure out how to achieve what I> want in Mathematica, things like:> - left brackets spanning multiple lines for defining hybrid functions;You can accomplish this by doing the following:1) Put your function braches in the rows of a grid box structure.2) Add the following options to your cell: ShowAutoStyles -> False SpanMaxSize -> InfinityThe following cell snippet demonstrates how this inßuences the result. To view it, paste the Cell[] expression into a notebook and then click on Yes when you are prompted on whether the front end should interpret the result.Cell[BoxData[ FormBox[ RowBox[{ RowBox[{f, (, x, )}], =, RowBox[{{, GridBox[{ {x, RowBox[{x, , <, 0}]}, { SuperscriptBox[x, 2], RowBox[{0, [LessEqual], x, <, 1}]}, { RowBox[{sin, (, x, )}], RowBox[{1, [LessEqual], x, <, 2}]}, { RowBox[{[CapitalGamma], (, x, )}], RowBox[{x, [GreaterEqual], 2}]} }]}]}], TraditionalForm]], DisplayFormula, ShowAutoStyles->False, SpanMaxSize->Infinity]> - vertical alignment of equals signs in multi-line equations or> derivations;Put your equations in a GridBox and set the ColumnAlignments option to a string containing the equal sign.Cell[BoxData[ FormBox[GridBox[{ { RowBox[{ RowBox[{ RowBox[{3, x}], , +, , RowBox[{4, , y}]}], , =, , 9}]}, { RowBox[{ RowBox[{ RowBox[{2, x}], , -, , RowBox[{7, , y}]}], =, RowBox[{32, , -, , RowBox[{sin, (, x, )}]}]}]} }], TraditionalForm]], DisplayFormula, GridBoxOptions->{ColumnAlignments->{=}}]> - setting typefaces in tables of material.I think the Author Tools material that comes with Mathematica 4.2 might be able to help you do this.-- User Interface Programmer paulh@wolfram.comWolfram Research, Inc. ==== You have three nonlinear (fourth-order) equations and 23 unknowns. Afaster computer won't help any.Bobby-----Original Message-----(*Hex20 Node definition in global coordinates *)Clear[x1, y1, z1,x2, y2, z2,x3, y3, z3,x4, y4, z4,x5, y5, z5,x6, y6, z6,x7, y7, z7,x8, y8, z8,x9, y9, z9,x10, y10, z10,x11, y11, z11,x12, y12, z12,x13, y13, z13,x14, y14, z14,x15, y15, z15,x16, y16, z16,x17, y17, z17,x18, y18, z18,x19, y19, z19,x20, y20, z20];(* local coordinates *)Clear[u, v, w];(* Global co-ordinates *)Clear[x, y, z];(* corner nodes *)N1= (1-u)*(1-v)*(1-w)*(-2-u-v-w)/8;N3= (1+u)*(1-v)*(1-w)*(-2+u-v-w)/8;N5= (1+u)*(1+v)*(1-w)*(-2+u+v-w)/8;N7= (1-u)*(1+v)*(1-w)*(-2-u+v-w)/8;N13=(1-u)*(1-v)*(1+w)*(-2-u-v +w)/8;N15=(1+u)*(1-v)*(1+w)*(-2+u-v+w)/8;N17=(1+u)*(1+v)*(1 +w)*(-2+u+v+w)/8;N19=(1-u)*(1+v)*(1+w)*(-2-u+v+w)/8;(* to u nodes *)N2= (1-u^2)*(1-v)*(1-w)/4;N6= (1-u^2)*(1+v)*(1-w)/4;N14=(1-u^2)*(1-v)*(1+w)/4;N18=(1-u^2) *(1+v)*(1+w)/4;(* to v nodes *)N4= (1+u)*(1-v^2)*(1-w)/4;N8= (1-u)*(1-v^2)*(1-w)/4;N16=(1+u)*(1-v^2)*(1+w)/4;N20=(1-u)*( 1-v^2)*(1+w)/4;(* to w nodes *)N9= (1-u)*(1-v)*(1-w^2)/4;N10=(1+u)*(1-v)*(1-w^2)/4;N11=(1+u)*( 1+v)*(1-w^2)/4;N12=(1-u)*(1-v)*(1-w^2)/4;(* solve the inverse transform *)Solve[{x1*N1+x2*N2+x3*N3+x4*N4+x5*N5+x6*N6+x7*N7+x8*N8+x9 *N9+x10*N10+x11*N11+x12*N12+x13*N13+x14*N14+x15*N15+x16*N16+ x17*N17+x18*N18+x19*N19+x20*N20-x==0,y1*N1+y2*N2+y3*N3+y4* N4+y5*N5+y6*N6+y7*N7+y8*N8+y9*N9+y10*N10+y11*N11+y12*N12+y13 *N13+y14*N14+y15*N15+y16*N16+y17*N17+y18*N18+y19*N19+y20*N20 -y==0,z1*N1+z2*N2+z3*N3+z4*N4+z5*N5+z6*N6+z7*N7+z8*N8+z9*N9+ z10*N10+z11*N11+z12*N12+z13*N13+z14*N14+z15*N15+z16*N16+z17* N17+z18*N18+z19*N19+z20*N20-z==0},{u,v,w}]Christopher J. PurcellDefence R&D Canada - Atlantic9 Grove St., PO Box 1012Dartmouth NS Canada B2Y 3Z7 ==== If I haven't missed a step, the following should work nicely -- bestdone before defining any of the symbols that appear:Attributes[dummyIf] = HoldAll;Attributes[dummyWhich] = HoldAll;expr = {If[Aa == Ab, a Sa + b Sb, If[Ca == 0 || Cb == 0, a Sa + b Sb,SS]], If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0, Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0, Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0, Nil, If[ Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0, Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} /. {If -> dummyIf};rule1 = dummyIf[a_, b_, dummyIf[c_, d_, e_]] -> dummyWhich[a, b, c, d, True, e];rule2 = dummyIf[a_, dummyIf[ b_, c_, d_], e_] -> dummyWhich[a && b, c, a, d, True,e];rule3 = dummyIf[a_, dummyIf[b_, c_, d_]] -> dummyWhich[a && b, c, a, d];rule4 = dummyWhich[a__, b_, dummyIf[c_, d_, e_], f___] -> dummyWhich[a, b && c, d, b, e, f];rule5 = dummyWhich[a__, b_, dummyWhich[c_, d_, e___], f___] -> dummyWhich[a, b && c, d, b, dummyWhich[e], f];rule6 = dummyWhich[] :> Null;rule7 = HoldPattern[True && a_] :> a;expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7} /. {dummyWhich -> WhichThe result of that last line is:{Which[Aa == Ab, a Sa + b Sb, Ca == 0 || Cb == 0, a Sa + b Sb, True, SS], Which[Aa == Ab, a Ca + b Cb, Ca == 0 || Cb == 0, a Ca + b Cb, True, CC], Which[Ca == 0 && Cb == 0, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0, Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, X > 180, X - 180, X < 0, X + 180, True, X]}I've used Null where that would be the result of your original logic --maybe you want it to be Nil. Or maybe you want to use Null instead ofNil. Your choice. Wherever you see Null, there's possibly a case youhaven't covered.Bobby Treat-----Original Message----- If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0, Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0,Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0, Nil, If[Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0, Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} ==== Dear Group,I have a program to take the local polynomial non parametric regressionof two variables. It uses Compile, unfortunately, and regularly, butinconsistently, causes Mathematica to crash (in Win2K, with I forgetwhat error, and in Win98/Mathematica4.0 with an invalid memory access fromMathDLL.dll). I am running Mathematica 4.1, and have this problem consistentlyon 4 different machines.Here is the code, if it doesn't crash the first time, it will the secondor third:(*w = Compile[{{xj, _Real, 0}, {XX, _Real, 1}, {YY, _Real, 1}, {h, _Real,0}, {nn, _Integer, 0}, {ord, _Integer, 0}},First[Inverse[Sum[Outer[Times, Table[If[Positive[q], (XX[[i]] - xj)^q,1], {q, 0, ord}],Table[If[Positive[q], (XX[[i]] - xj)^q, 1.], {q, 0,ord}]*E^(-0.5*((XX[[i]] - xj)/h)^2)], {i, nn}]] .Sum[(Table[If[Positive[q], (XX[[i]] - xj)^q, 1.], {q, 0, ord}]*YY[[i]])*E^(-0.5*((XX[[i]] - xj)/h)^2), {i, nn}]]];*)(*!(tt = MemoryInUse[]; ListPlot[Table[{((i + 1))^2, (Timing[ nn = ((i + 1))^2; [Epsilon] = Table[Random[]*3, {i,nn}]; testX = Table[i* .3 - Random[]*2, {i, nn}]; testY = Table[Sin[i/3] - 2, {i, nn}] + [Epsilon]; Map[w[#, testX, testY, .1 + Random[], nn, 0] &, testX];])[([1])]/Second}, {i, 15}], PlotJoined ->True, PlotLabel -> ]; MemoryInUse[] - tt)*)I have followed Ted Ersek's tips and tricks(http://www.verbeia.com/mathematica/tips/tip_ index.html) about Compile,and have tried changing all variable names (works sometimes), removingany hidden spaces, restructuring the formulas, changing all 0's to 0. Ôsand all 1's to 1. Ôs, etcetera etcetera, but I still can't comprehendwhat the problem might be. Doing w[[-2]] shows a list of op-codenumbers, and one function name, Inverse[#1]&, so it seems to me thatthere are no problems with the use of Compile here. Would anyone haveany thoughts???Bernard Gressburnthebiscuit@netscape.net ==== Expanding on my earlier simplification of the Moran Research code, Istudied the problem a little more and found another useful Rule and aRule that should help but doesn't. Maybe somebody can explain what I'mdoing wrong on that one.My earlier result (after applying rule1, ... rule7) had the following asthird element of a List in the definition of f:Which[ Ca == 0 && Cb == 0, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0, Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, X > 180, X - 180, X < 0, X + 180, True, X]Several things occurred to me in terms of simplifying this. The firstwas that the last six arguments of Which could be replaced with two, asfollows:Which[ Ca == 0 && Cb == 0, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0, Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, True,Mod[X,180]]This probably has no advantage other than clarity, but that's worththe others:rule8 = dummyIf[a_ > b_, a_ - b_, dummyIf[a_ < 0, a_ + b_, a_]] :>Mod[a, b];but it had no effect on the expression. Apparently there was no match,and I can't see why.The second thing I noticed was that the conditionCa == 0 && Cb == 0occurs twice in the Which statement. The following rule fixes that kindof situation:rule9 = dummyWhich[a___, b_, c_, d__, b_, e_, f__] /; EvenQ[Length[List[a]]] &&EvenQ[Length[List[d]]] && EvenQ[Length[List[f]]] :> dummyWhich[a, b, c, d, f];expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule9}The third thing I noticed was the treatment of Aa and Ab. TheexpressionsIf[Aa > 90, Aa - 90, Aa + 90]If[Ab > 90, Ab - 90, Ab + 90]in the original expression may be equivalent (depending on what's knownabout Aa and Ab a priori) to:Mod[Aa+90,180]Mod[Ab+90,180]If that is a valid assumption in the situation (no way for me to know),the expression is nowWhich[ Ca == 0 && Cb == 0, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, Z1 == Z2 && Ca > 0, Mod[Aa + 90, 180], Z1 == Z2 && Cb > 0, Mod[Ab + 90, 180], Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, True, Mod[X, 180]]The next thing I notice is that the sixth condition, Z1==Z2, whichresults in Null if found True, isn't needed. If Z1==Z2 then one of thefirst five conditions is also true, so execution wouldn't get that far.Hence we can delete that condition-response pair.Finally, I'm stopping with this:Which[ Ca == 0 == Cb, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, Z1 == Z2 && Ca > 0, Mod[Aa + 90, 180], Z1 == Z2 && Cb > 0, Mod[Ab + 90, 180], Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, True, Mod[X, 180]]I have no idea what you're actually doing with this code, but it looksweird even AFTER I've simplified it.Bobby Treat-----Original Message----- 0, Aa, If[Cb < 0, Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0, Nil, If[ Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0, Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} /. {If -> dummyIf};rule1 = dummyIf[a_, b_, dummyIf[c_, d_, e_]] -> dummyWhich[a, b, c, d, True, e];rule2 = dummyIf[a_, dummyIf[ b_, c_, d_], e_] -> dummyWhich[a && b, c, a, d, True,e];rule3 = dummyIf[a_, dummyIf[b_, c_, d_]] -> dummyWhich[a && b, c, a, d];rule4 = dummyWhich[a__, b_, dummyIf[c_, d_, e_], f___] -> dummyWhich[a, b && c, d, b, e, f];rule5 = dummyWhich[a__, b_, dummyWhich[c_, d_, e___], f___] -> dummyWhich[a, b && c, d, b, dummyWhich[e], f];rule6 = dummyWhich[] :> Null;rule7 = HoldPattern[True && a_] :> a;expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7} /. {dummyWhich -> WhichThe result of that last line is:{Which[Aa == Ab, a Sa + b Sb, Ca == 0 || Cb == 0, a Sa + b Sb, True, SS], Which[Aa == Ab, a Ca + b Cb, Ca == 0 || Cb == 0, a Ca + b Cb, True, CC], Which[Ca == 0 && Cb == 0, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0, Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, X > 180, X - 180, X < 0, X + 180, True, X]}I've used Null where that would be the result of your original logic --maybe you want it to be Nil. Or maybe you want to use Null instead ofNil. Your choice. Wherever you see Null, there's possibly a case youhaven't covered.Bobby Treat-----Original Message----- If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0, Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0,Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0, Nil, If[Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0, Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} ==== Sorry... ONE MORE simplification:Which[ Ca == 0 == Cb, Nil, Z1 == Z2, Which[Ca < 0, Aa, Cb < 0, Ab, Ca > 0, Mod[Aa + 90, 180], Cb > 0, Mod[Ab + 90, 180]], Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, True, Mod[X, 180]]I didn't like repeating the Z1==Z2 test.Upon noticing this, I thought at first that my rule5 caused thissituation to occur, but actually I have to delete both rule 4 AND rule5to eliminate it, and the resulting expression wouldn't be as easy tounderstand.Bobby Treat-----Original Message----- Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0, Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, X > 180, X - 180, X < 0, X + 180, True, X]Several things occurred to me in terms of simplifying this. The firstwas that the last six arguments of Which could be replaced with two, asfollows:Which[ Ca == 0 && Cb == 0, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0, Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, True,Mod[X,180]]This probably has no advantage other than clarity, but that's worththe others:rule8 = dummyIf[a_ > b_, a_ - b_, dummyIf[a_ < 0, a_ + b_, a_]] :>Mod[a, b];but it had no effect on the expression. Apparently there was no match,and I can't see why.The second thing I noticed was that the conditionCa == 0 && Cb == 0occurs twice in the Which statement. The following rule fixes that kindof situation:rule9 = dummyWhich[a___, b_, c_, d__, b_, e_, f__] /; EvenQ[Length[List[a]]] &&EvenQ[Length[List[d]]] && EvenQ[Length[List[f]]] :> dummyWhich[a, b, c, d, f];expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7, rule9}The third thing I noticed was the treatment of Aa and Ab. TheexpressionsIf[Aa > 90, Aa - 90, Aa + 90]If[Ab > 90, Ab - 90, Ab + 90]in the original expression may be equivalent (depending on what's knownabout Aa and Ab a priori) to:Mod[Aa+90,180]Mod[Ab+90,180]If that is a valid assumption in the situation (no way for me to know),the expression is nowWhich[ Ca == 0 && Cb == 0, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, Z1 == Z2 && Ca > 0, Mod[Aa + 90, 180], Z1 == Z2 && Cb > 0, Mod[Ab + 90, 180], Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, True, Mod[X, 180]]The next thing I notice is that the sixth condition, Z1==Z2, whichresults in Null if found True, isn't needed. If Z1==Z2 then one of thefirst five conditions is also true, so execution wouldn't get that far.Hence we can delete that condition-response pair.Finally, I'm stopping with this:Which[ Ca == 0 == Cb, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, Z1 == Z2 && Ca > 0, Mod[Aa + 90, 180], Z1 == Z2 && Cb > 0, Mod[Ab + 90, 180], Aa == Ab, Aa, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, True, Mod[X, 180]]I have no idea what you're actually doing with this code, but it looksweird even AFTER I've simplified it.Bobby Treat-----Original Message----- 0, Aa, If[Cb < 0, Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0, Nil, If[ Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0, Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} /. {If -> dummyIf};rule1 = dummyIf[a_, b_, dummyIf[c_, d_, e_]] -> dummyWhich[a, b, c, d, True, e];rule2 = dummyIf[a_, dummyIf[ b_, c_, d_], e_] -> dummyWhich[a && b, c, a, d, True,e];rule3 = dummyIf[a_, dummyIf[b_, c_, d_]] -> dummyWhich[a && b, c, a, d];rule4 = dummyWhich[a__, b_, dummyIf[c_, d_, e_], f___] -> dummyWhich[a, b && c, d, b, e, f];rule5 = dummyWhich[a__, b_, dummyWhich[c_, d_, e___], f___] -> dummyWhich[a, b && c, d, b, dummyWhich[e], f];rule6 = dummyWhich[] :> Null;rule7 = HoldPattern[True && a_] :> a;expr //. {rule1, rule2, rule3, rule4, rule5, rule6, rule7} /. {dummyWhich -> WhichThe result of that last line is:{Which[Aa == Ab, a Sa + b Sb, Ca == 0 || Cb == 0, a Sa + b Sb, True, SS], Which[Aa == Ab, a Ca + b Cb, Ca == 0 || Cb == 0, a Ca + b Cb, True, CC], Which[Ca == 0 && Cb == 0, Nil, Z1 == Z2 && Ca < 0, Aa, Z1 == Z2 && Cb < 0, Ab, (Z1 == Z2 && Ca > 0) && Aa > 90, Aa - 90, Z1 == Z2 && Ca > 0, Aa + 90, Z1 == Z2 && (Cb > 0 && Ab > 90), Ab - 90, Z1 == Z2 && Cb > 0, Ab + 90, Z1 == Z2, Null, Aa == Ab, Aa, Ca == 0 && Cb == 0, Nil, Ca == 0, Ab, Cb == 0, Aa, Y == 0, Nil, X > 180, X - 180, X < 0, X + 180, True, X]}I've used Null where that would be the result of your original logic --maybe you want it to be Nil. Or maybe you want to use Null instead ofNil. Your choice. Wherever you see Null, there's possibly a case youhaven't covered.Bobby Treat-----Original Message----- If[Aa == Ab, a Ca + b Cb, If[Ca == 0 || Cb == 0, a Ca + b Cb, CC]], If[Ca == 0 && Cb == 0, Nil, If[Z1 == Z2, If[Ca < 0, Aa, If[Cb < 0,Ab, If[Ca > 0, If[Aa > 90, Aa - 90, Aa + 90], If[Cb > 0, If[Ab > 90, Ab - 90, Ab + 90]]]]], If[Aa == Ab, Aa, If[Ca == 0 && Cb == 0, Nil, If[Ca == 0, Ab, If[Cb == 0, Aa, If[Y == 0, Nil, If[X > 180, X - 180, If[X < 0, X + 180, X]]]]]]]]]} ==== If x1 through x20 aren't unknowns, you should have told me their values.If you can't, they are UNKNOWN.True, you're not solving for them... but they affect the dimensionalityof the problem just as if you WERE solving for them. You have a20-dimensional space full of contingencies -- solution forms that dependon the values of x1 through x20. The Solve function won't deal withcontingencies even if it could, and if it tried, there would be toomany.Bobby-----Original Message----->Bobby-----Original Message----->Sent: Saturday, September 07, 2002 1:54 AM>resend>Would someone with a very fast machine and lots of memory be willing to>try>this Solve for me?>It is the inverse of the 20 node quadratic hexahedral mapping used in>finite element analysis.>None of my computers can handle this - they run out of memory (using(*Hex20 Node definition in global coordinates *)>Clear[>x1, y1, z1,>x2, y2, z2,>x3, y3, z3,>x4, y4, z4,>x5, y5, z5,>x6, y6, z6,>x7, y7, z7,>x8, y8, z8,>x9, y9, z9,>x10, y10, z10,>x11, y11, z11,>x12, y12, z12,>x13, y13, z13,>x14, y14, z14,>x15, y15, z15,>x16, y16, z16,>x17, y17, z17,>x18, y18, z18,>x19, y19, z19,>x20, y20, z20];(* local coordinates *)>Clear[u, v, w];(* Global co-ordinates *)>Clear[x, y, z];(* corner nodes *)>N1= (1-u)*(1-v)*(1-w)*(-2-u-v-w)/8;>N3= (1+u)*(1-v)*(1-w)*(-2+u-v-w)/8;>N5= (1+u)*(1+v)*(1-w)*(-2+u+v-w)/8;>N7= (1-u)*(1+v)*(1-w)*(-2-u+v-w)/8;>N13=(1-u)*(1-v)*(1+w)*(-2-u-v +w)/8;>N15=(1+u)*(1-v)*(1+w)*(-2+u-v+w)/8;>N17=(1+u)*(1+v)*(1 +w)*(-2+u+v+w)/8;>N19=(1-u)*(1+v)*(1+w)*(-2-u+v+w)/8;>(* to u nodes *)>N2= (1-u^2)*(1-v)*(1-w)/4;>N6= (1-u^2)*(1+v)*(1-w)/4;>N14=(1-u^2)*(1-v)*(1+w)/4;>N18=(1-u^2) *(1+v)*(1+w)/4;>(* to v nodes *)>N4= (1+u)*(1-v^2)*(1-w)/4;>N8= (1-u)*(1-v^2)*(1-w)/4;>N16=(1+u)*(1-v^2)*(1+w)/4;>N20=(1-u)*( 1-v^2)*(1+w)/4;>(* to w nodes *)>N9= (1-u)*(1-v)*(1-w^2)/4;>N10=(1+u)*(1-v)*(1-w^2)/4;>N11=(1+u)*( 1+v)*(1-w^2)/4;>N12=(1-u)*(1-v)*(1-w^2)/4;(* solve the inverse transform *)>Solve[{>x1*N1+x2*N2+x3*N3+x4*N4+x5*N5+x6*N6+x7*N7+x8*N8+x9 *N9+x10*N10+>x11*N11+x12*N12+x13*N13+x14*N14+x15*N15+x16*N16+ x17*N17+x18*N18+x19*N19+>x20*N20-x==0,>y1*N1+y2*N2+y3*N3+y4* N4+y5*N5+y6*N6+y7*N7+y8*N8+y9*N9+y10*N10+>y11*N11+y12*N12+y13 *N13+y14*N14+y15*N15+y16*N16+y17*N17+y18*N18+y19*N19+>y20*N20 -y==0,>z1*N1+z2*N2+z3*N3+z4*N4+z5*N5+z6*N6+z7*N7+z8*N8+z9*N9+ z10*N10+>z11*N11+z12*N12+z13*N13+z14*N14+z15*N15+z16*N16+z17* N17+z18*N18+z19*N19+>z20*N20-z==0},>{u,v,w}]>Christopher J. Purcell>Defence R&D Canada - Atlantic>9 Grove St., PO Box 1012>Dartmouth NS Canada B2Y 3Z7Christopher J. PurcellDefence R&D Canada - Atlantic9 Grove St., PO Box 1012Dartmouth NS Canada B2Y 3Z7 ==== If we do think of x1...x20 as constants, it's still fourth-order, withthree simultaneous equations. Evaluate this:Solve[a x^4 + b x^3 + c x^2 + d x + e == 0, x]and look at the four solutions found -- for a single variable and oneequation!For your problem, I'm thinking there'd be at least 4^3 solutions, eachof them even more complicated than these, and an unknown number ofcontingencies to deal with, depending on values of the xi. Check eachradical for a negative argument, and the special cases multiply quickly.For some values of the xi, there'd be no solutions; for other values,many solutions.If you do manage to solve this, I'd love to see the method!Bobby-----Original Message-----many.Bobby-----Original Message----->Bobby-----Original Message----->Sent: Saturday, September 07, 2002 1:54 AM>resend>Would someone with a very fast machine and lots of memory be willing to>try>this Solve for me?>It is the inverse of the 20 node quadratic hexahedral mapping used in>finite element analysis.>None of my computers can handle this - they run out of memory (using(*Hex20 Node definition in global coordinates *)>Clear[>x1, y1, z1,>x2, y2, z2,>x3, y3, z3,>x4, y4, z4,>x5, y5, z5,>x6, y6, z6,>x7, y7, z7,>x8, y8, z8,>x9, y9, z9,>x10, y10, z10,>x11, y11, z11,>x12, y12, z12,>x13, y13, z13,>x14, y14, z14,>x15, y15, z15,>x16, y16, z16,>x17, y17, z17,>x18, y18, z18,>x19, y19, z19,>x20, y20, z20];(* local coordinates *)>Clear[u, v, w];(* Global co-ordinates *)>Clear[x, y, z];(* corner nodes *)>N1= (1-u)*(1-v)*(1-w)*(-2-u-v-w)/8;>N3= (1+u)*(1-v)*(1-w)*(-2+u-v-w)/8;>N5= (1+u)*(1+v)*(1-w)*(-2+u+v-w)/8;>N7= (1-u)*(1+v)*(1-w)*(-2-u+v-w)/8;>N13=(1-u)*(1-v)*(1+w)*(-2-u-v +w)/8;>N15=(1+u)*(1-v)*(1+w)*(-2+u-v+w)/8;>N17=(1+u)*(1+v)*(1 +w)*(-2+u+v+w)/8;>N19=(1-u)*(1+v)*(1+w)*(-2-u+v+w)/8;>(* to u nodes *)>N2= (1-u^2)*(1-v)*(1-w)/4;>N6= (1-u^2)*(1+v)*(1-w)/4;>N14=(1-u^2)*(1-v)*(1+w)/4;>N18=(1-u^2) *(1+v)*(1+w)/4;>(* to v nodes *)>N4= (1+u)*(1-v^2)*(1-w)/4;>N8= (1-u)*(1-v^2)*(1-w)/4;>N16=(1+u)*(1-v^2)*(1+w)/4;>N20=(1-u)*( 1-v^2)*(1+w)/4;>(* to w nodes *)>N9= (1-u)*(1-v)*(1-w^2)/4;>N10=(1+u)*(1-v)*(1-w^2)/4;>N11=(1+u)*( 1+v)*(1-w^2)/4;>N12=(1-u)*(1-v)*(1-w^2)/4;(* solve the inverse transform *)>Solve[{>x1*N1+x2*N2+x3*N3+x4*N4+x5*N5+x6*N6+x7*N7+x8*N8+x9 *N9+x10*N10+>x11*N11+x12*N12+x13*N13+x14*N14+x15*N15+x16*N16+ x17*N17+x18*N18+x19*N19+>x20*N20-x==0,>y1*N1+y2*N2+y3*N3+y4* N4+y5*N5+y6*N6+y7*N7+y8*N8+y9*N9+y10*N10+>y11*N11+y12*N12+y13 *N13+y14*N14+y15*N15+y16*N16+y17*N17+y18*N18+y19*N19+>y20*N20 -y==0,>z1*N1+z2*N2+z3*N3+z4*N4+z5*N5+z6*N6+z7*N7+z8*N8+z9*N9+ z10*N10+>z11*N11+z12*N12+z13*N13+z14*N14+z15*N15+z16*N16+z17* N17+z18*N18+z19*N19+>z20*N20-z==0},>{u,v,w}]>Christopher J. Purcell>Defence R&D Canada - Atlantic>9 Grove St., PO Box 1012>Dartmouth NS Canada B2Y 3Z7Christopher J. PurcellDefence R&D Canada - Atlantic9 Grove St., PO Box 1012Dartmouth NS Canada B2Y 3Z7 ==== The documentation you're talking about doesn't even deserve to be calleddocumentation. A few hints; that's it.Bobby Treat-----Original Message-----> unable to find a complete guide to word processing with mathematica.> Does anyone know where such a document could be found? ==== This is a question that's been asked and answered a number of times. One answer, by me, can be found by going to www.wolfram.com and selecting first Resource Library and then MathGroup on the Resource Library page; then search for direction field. You'll find, among many others, the URL: http://library.wolfram.com/mathgroup/archive/2002/Jul/ msg00163.html(This is not to chastise you for not first looking there, but to suggest a way for you to find answers more efficiently than waiting for the ou need to load the package, then manufacture a vector field whose plotis the slope field (what you call vector ßow diagram). To do thelatter, let me separately define the function giving the right-hand sideof the ODE; you don't really have to do that, but could instead directlyuse as the first argument to PlotVectorField the right-hand side of mydefinition of f. << Graphics`PlotField` f[t_, y_] := {1, 1/y} field = PlotVectorField[f[t, y], {t, 0, 3}, {y, 0.05, 3}];I gave a name to the graphics result just in order to re-display thefield below along with the graph of one solution. First, find a generalsolution: soln = First @ DSolve[{y'[t] == 1/y[t], y[0] == 1}, y[t], t]{y[t] -> Sqrt[2]*Sqrt[1/2 + t]} grf = Plot[y[t] /. soln, {t, 0, 3}];Now combine the plot with the field: Show[grf, field];Note that PlotVectorField does not always give quite the result youmight want, since the vector lengths are scaled with respect to themagnitude of the actual vectors. You might want just a directionfield in which all arrows have the same length. You can produce such agraphic by using the ScaleFunction and ScaleFactor options toPlotVectorField. For example: field = PlotVectorField[f[t, y], {t, 0, 3}, {y, 0.05, 3}, ScaleFunction -> (1 &), ScaleFactor -> 0.175];... I have several differential equations I would like toplot in Mathematica. I would like to plot the Slope Fields of them though. Can anyone lead me in the right direction? I can solve the equations trivially but I want to display the slope fields. An example follows :y' + 2y = 3...-- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375 ==== I am trying to implement a very simple sorted tree to quickly store somereal numbers I need. I have written an add, delete, minimum, and pop(delete the lowest value) function and they seem to work ok but are veryslow. Let's just look @ my implementation of the add part:nums=Null;(*my initial blank Tree)In[326]:=Clear[add]In[327]:=add[Null,x_Real]:=node[x ,Null,Null]add[Null,node[x_Real,lower_,higher_]]=node[x, lower,higher]In[328]:=add[node[x_Real,lower_,higher_],y_ Real]:= If[x>y,node[x,add[lower,y],higher],node[x,lower,add[higher,y] ]]In[288]:=add[node[x_Real,lowerx_,higherx_],node[y_Real, lowery_,highery_]]:=If[x>y, node[x,add[lowerx,node[y,lowery,highery]],higherx], node[x,lowerx,add[higherx,node[y,lowery,highery]]] ]Now this is my attempt to test how fast my add works:SeedRandom[5];Do[nums=add[nums,Random[]],{5000}];// TimingOut[333]={13.279 Second,Null}running on an 1.4GHz Athlon with 1GB of ram).Questions:1. Is this as fast as I can get my code to run?2. Am I doing something obviously stupid?3. would Compiling things help?Husain ==== The vectors that NullSpace gives do not need to be orthogonal toeach other. What about the following variant, that adds one vectorat a time? It may not be fast enough for serious number crunching.OrthogonalComplement[v__ /; MatrixQ[{v}]] := With[{n = Length[NullSpace[{v}]]}, Take[Nest[Join[{First[NullSpace[#]]}, #] &, {v}, n], n]];OrthonormalComplement[v__ /; MatrixQ[{v}]] := Map[#/Sqrt[#.#] &, OrthogonalComplement[v]];When the input of OrthogonalComplement is integer, I expect the outputto be integer too:OrthogonalComplement[{1, 2, 3}]{{1, -5, 3}, {-3, 0, 1}} Gianluca Gorni> OrthogonalUnitVectors that I sent a few minutes ago doesn't do what I> thought it would.> After making either definition below I get the following:> In[2]:=> s1=OrthogonalUnitVectors[{1,0,1/2,1,0},{0,1,-1,1/2,2}]> Out[2]=> {{0, -2/Sqrt[5], 0, 0, 1/Sqrt[5]}, {-2/3, -1/3, 0, 2/3, 0}, {-1/3, 2/3,> 2/3, 0, 0}}> The dot products below aren't zero, so the vectors aren't orthogonal. What> went wrong?> In[3]:= > Part[s1,1].Part[s1,2]> Out[3]=> 2/(3*Sqrt[5])> In[4]:= > Part[s1,1].Part[s1,3]> Out[3]=> -4/(3*Sqrt[5])> --------------> Hugh Goyder and David Park gave a most elegant function to find two> vectors that are orthogonal to one vector in 3D. The key to coming up> with the elegant solution is an understanding of Mathematica's NullSpace> function. We can easily make the version from Hugh and David much more> general with the version below.> -------------> OrthogonalUnitVectors[vect__?VectorQ]:=> #/Sqrt[#.#]&/@NullSpace[{vect}]> -------------> The version above will give a set of unit orthogonal vectors if given any> number of vectors in any dimension.> So besides giving it a 3D vector we can give it the following:> OrthogonalUnitVectors[{2,1,0,-1,1}]> or> OrthogonalUnitVectors[{0,1,0,1/2,1},{1,0,-1,1/2}]> ------------> But the short version above isn't very robust.> (1) Clear[x,y,z];NullSpace[{{x,y,z}}]> returns two vectors orthogonal to {x,y,z}, but the two vectors> NullSpace returns aren't orthogonal to each other.> So (OrthogonalUnitVectors) should only work with numeric vectors.> (2) We should ensure all the vectors have the same dimension and length> 1.> I give a less concise version below that corrects these problems.> ------------> OrthogonalUnitVectors[vect__?(VectorQ[#,NumericQ]&)]/;> (SameQ@@Length/@{vect})&&(Length[First[{vect}]]>1):=> #/Sqrt[#.#]&/@NullSpace[{vect}]> --------------> Ted Ersek> Get Mathematica tips, tricks from> http://www.verbeia.com/mathematica/tips/Tricks.html> ==== I am using MultipleListPlot to plot a range of 2D graphs and have found thatthe last graph, which has a much greater (by a factor of 4) x range than theothers does not plot completely but is truncated in the x direction. Byremoving the Frame, I can see the points where these lie outside the Framebut these are not joined etc. How do I get over this?-Malcolm Woodruff ==== Group,Sorry for the previous posting. The following solves (to some extent my problem)< (1) Is there a way in Mathematica 4.2 to put two separate gifs into a> single, cell side by side (with some intervening space), without> having to combine them in some graphics program first? In particular, I'd like to do that within a text cell. Even in a new Input cell, if I first create a GridBox (via Inut>Create> Table/Matrix/Palette) and then try to insert the first gif (via> Edit>Insert Object>Create from File ....), Mathematica promptly> crashes. (Mathematica 4.2 under Windows 2000.)You could do something like this:grlist = Map[Import[#, GIF]&, {, }]celist = Map[Cell[GraphicsData[PostScript, DisplayString[#]]]&, grlist]CellPrint[Cell[BoxData[GridBox[{celist}]], Text]]This embeds the PostScript versions of these graphics each as inline cellsin a GridBox[] structure.> (2) Is there a way to cause a gif imported into a Mathematica 4.2> notebook to become a hyperlink -- so that when the user clicks on the> gif the hyperlink's target is summoned?Again, we embed the PostScript graphic within an inline cell. Here is afunction that does what you describe:createGIFHyperlink[gifImage_String, url_String] := NotebookWrite[EvaluationNotebook[], Cell[BoxData[ ButtonBox[ Cell[GraphicsData[PostScript, DisplayString[Import[gifImage, GIF]]]], ButtonStyle -> Hyperlink, ButtonData :> {URL[url], None}]], Text]]-- User Interface Programmer paulh@wolfram.comWolfram Research, Inc. ==== > 1.) How to find the General Solution for below's partial differential> equation?> (y + u) du/dx + y (du/dy) = x - y> ** I use d to represent the partial differential symbol.> Can it be solved by function NDSolve in mathematica 4.1? How?It's been a while, but I suspect that the presence of the nonlinearconvective term u du/dx alone makes a general solution unlikely. It's easyto get a numerical solution for a particular set of boundary conditions, butyou are not guaranteed a solution. For instance, the following choice of aand b are skirting failure, as the diagnostic contour plot shows.Tom BurtonNeeds[Graphics`Colors`]!((soln = With[{a = (-1), b = 1.27, e = 0.001}, solutions = NDSolve[{((y + u[x, y])) [PartialD]_x u[x, y] + y [PartialD]_y u[x, y] == x - y, u[x, b] == 0, u[a, y] == 0}, u, {x, a, 10}, {y, b, 10}]; [IndentingNewLine]Plot3D[ Evaluate[u[x, y] /. [InvisibleSpace]First[solutions]], {x, a, 10}, {y, b, 10}, PlotPoints [Rule] 50]; [IndentingNewLine]ContourPlot[ Evaluate[y + u[x, y] /. [InvisibleSpace]First[solutions]], {x, a, 10}, {y, b, 10}, PlotPoints [Rule] 50, ColorFunction [Rule] ((If[#1 > e, Green, Red] &))][IndentingNewLine]];)) ==== I'd be happier if I could just control pagination, or if automaticpagination were done sensibly.Yes, I can make a page break where I want one, but I can't eliminatepage-breaks that leave tons of white-space at the end of some pages. Insome of my notebooks, Mathematica puts the first cell on a page byitself, using less than an inch --- and NOT because the next cell takesa whole page. If I force the first two cells to stay together, theproblem just moves to the next page.It's enough to make Mathematica useless as a word processor all byitself.Bobby Treat-----Original Message-----derivations;- setting typefaces in tables of material.I figure most of this is do-able, but I don't have the time, orpatience, to spend too much time on it. So, I'll be the first customerwhen you write the guide to math publishing in Mathematica - I just hopeyou won't have to use LaTeX to write it.Mark Westwood> I would like to use mathematica type papers for my math courses, but> I'm having trouble formatting documents. Despite searching, I've been> unable to find a complete guide to word processing with mathematica.> Does anyone know where such a document could be found? ==== > Wouldn't it be nice if NullSpace's behavior were DOCUMENTED? Otherwise,> it's futile to give it approximate numbers expecting any particular> behavior. Even if it always works, it may not work in the next version> of Mathematica.> BobbyThe expected, and documented, behavior is that the output should be abasis for the null space, that is, solutions of the homogeneous matrixequation A.x==0. If this were to stop working then that would be aserious bug. Is this the behavior you mean?The implementation notes of the manual mention that approximateNullSpace is based on a singular values decomposition. This in factgives resulting vectors that are orthonormal by the usualconjugate-symmetric inner product on C (though these are now notnormal to the original vector in this same inner product, unless theyare real-valued). But this basis-orthogonality is not part of themission of NullSpace and moreover should not become part of it. Hencethat particular (and implementation dependent) aspect of NullSpaceshould not become documented.Daniel LichtblauWolfram Research ==== Wouldn't it be nice if NullSpace's behavior were DOCUMENTED? Otherwise,it's futile to give it approximate numbers expecting any particularbehavior. Even if it always works, it may not work in the next versionof Mathematica.Bobby-----Original Message-----enough for me. Therefore I modify Ted's routine toOrthogonalUnitVectors[vect__?(VectorQ[#, NumericQ] &)] /; (SameQ @@ Length /@ {vect}) && (Length[First[{vect}]] > 1) := #/Sqrt[#.#] & /@ NullSpace[{vect}// N]----------------Lets see what NullSpace does with approximate complex vectors.In[1]:= v1 = {1.0 I, 0.0, 0.5 I, 0.0, 1.0}; v2 = {0.0, 2.0, 1.0 I, 2.0, 0.5}; {v3,v4,v5} = NullSpace[{v1,v2}]Out[3]= {{-0.730153 + 0.*I, 0. - 0.138254*I, 0.250585 + 0.*I, 0. -0.138254*I, 0.+ 0.60486*I}, {0. + 0.*I, -0.515861 + 0.*I, 0. + 0.457321*I, 0.687357 + 0.*I,0.22866+ 0.*I}, {0. + 0.*I, 0.510406 + 0.*I, 0. + 0.740442*I, -0.23274 + 0.*I,0.370221+ 0.*I}}--------In the next line we see NullSpace returned vectors that are orthogonaltothe vectors we gave NullSpace.In[4]:= {v1.v3, v1.v4, v1.v5, v2.v3, v2.v4, v2.v5}//ChopOut[4]= {0, 0, 0, 0, 0, 0}----------However, the vectors returned aren't orthogonal to each other.In[5]:= {v3.v4, v3.v5, v4.v5}//ChopOut[5]= {0.229195*I, 0.371087*I, -0.677239}---------I suppose an OrthogonalUnitVectors function that uses NullSpace should (1) Only accept real valued vectors. (2) Ensure NullSpace is given approximate vectors.------ Ted Ersek ==== Plot[{x,x^2},{x,0,10}]Tomas GarzaMexico City----- Original Message ----- ==== Mario,Here is a fancy version of your plot. I used Text statements within anEpilog option to label the two curves. The regular plot statement allows youto plot a series of functions inclosed in a list.Needs[Graphics`Colors`]Plot[{x, x^2}, {x, 0, 1}, PlotStyle -> {Black, Blue}, Frame -> True, FrameLabel -> {x, y}, PlotLabel -> Comparison of Two Functions, Epilog -> {Text[x, {0.5, 0.55}], Blue, Text[x^2, {0.7, 0.4}]}, Background -> Linen, ImageSize -> 500];David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== >How can I plot with Mathematica two function in the same graphic? I>explain better: I'd like to draw a) y=x and b) y=x^2 in the same axesPlot[{x, x^2},{x,-2,2}] ==== This might be a convenient way of defining color functions:ClearAll[cfun]cfun[colors_List, brkPts_List] /; Length@colors == Length@brkPts := Function[z, Which @@ Sequence@Flatten@Transpose[{Less[z, #] & /@ brkPts,colors}]]colors = {White, RoyalBlue, White, Red, White};brkPts = {-0.6, -0.42, 0.4, 0.6, Infinity};ContourPlot[f[x, y], { x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 30, ColorFunctionScaling ->False, ColorFunction -> cfun[colors, brkPts], Contours -> contourvalues];colors = {Yellow, Peru, Salmon, Apricot, HotPink, Linen};brkPts = {-0.6, -0.42, 0.2, 0.4, 0.6, Infinity};Timing[ContourPlot[f[x, y], {x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 30, ColorFunctionScaling -> False, ColorFunction -> cfun[colors,brkPts], Contours -> contourvalues];]Bobby Treat-----Original Message-----it is difficult to obtain in this plot.contourvalues = Complement[Range[-1, 1, 0.2], {0.}]{-1, -0.8, -0.6, -0.4, -0.2, 0.2, 0.4, 0.6, 0.8, 1.}Now we define a ColorFunction for the plot. I actually colored twodifferentbands to show how you can make a general color function to give eachband adesired color.cfun[z_] := Which[ -0.6 < z < -0.42, RoyalBlue, 0.4 < z < 0.6, Red, True, White]ContourPlot[f[x, y], {x, 0, Pi}, {y, 0, Pi}, PlotPoints -> 30, ColorFunctionScaling -> False, ColorFunction -> cfun, Contours -> contourvalues];Using the option ColorFunctionScaling -> False says that the z valuewill bethe actual value of f[x,y]. Otherwise, in general, it will be scaledbetween0 and 1. It is easier to write a color function when z is the actualvalueof the function.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== For what it's worth, here's a version of Simpson's rule that works with both equally spaced and unequally spaced points.simp = Compile[{x1,y1,x2,y2,x3,y3},With[{h13=x1-x3, h12=x1-x2, h23=x2-x3},(-y1*h23*(2x1-3x2+x3) - y2*h13^2 + y3*h12*(x1-3x2+2x3))*h13/(6h12*h23)]]; ListSimpson[vals_?VectorQ, dx_Real]:= With[{n=Length[vals]},If[OddQ[n], (dx/3)*(First[vals] + Last[vals] + 4*Plus@@vals[[Range[2,n-1,2]]] + 2*Plus@@vals[[Range[3,n-2,2]]]), $Failed]];ListSimpson[datapts_?MatrixQ] := If[OddQ[Length[datapts]], Plus@@(simp@@Flatten[#]&/@ Partition[datapts,3,2]), $Failed] (* equally spaced points*)data = Table[100*Sin[x], {x, 0, 100, 0.001}];ListSimpson[data, .001] // Timing {0.21 Second, 13.7681}(* randomly spaced points *)Table[{data = Sort[Table[With[{x = Random[Real,{0,100}]},{x,100*Sin[x]}],{100001}]]; ListSimpson[data] // Timing,With[{xvals = Transpose[data][[1]]},gaps = Drop[RotateLeft[xvals] - xvals, -1];{Min[gaps], Max[gaps]}]},{4}] {{{1.62 Second, 13.8348}, {1.32223*10^-8, 0.0114454}}, {{1.59 Second, 13.8261}, {2.42163*10^-8, 0.0127803}}, {{1.62 Second, 13.8455}, {1.08923*10^-9, 0.0119059}}, {{1.54 Second, 13.7987}, {9.66814*10^-9, 0.0106988}}}---Selwyn Hollis> Mathew, Some possibilities < Integrate[> Interpolation[data, InterpolationOrder[Rule]1][x],> {x,0,100}]//Timing {4.56 Second,13.768} Trapezium rule with equal steps: #[[1]]+#[[-1]]+ 2 Tr[Take[#,{2,-2}]]&[data[[All,2]]] 0.01/2//Timing {0.22 Second,13.768} Trapezium rule with possibly unequal steps (Drop[#1,1] - Drop[#1,-1]).(Drop[#2,-1] + Drop[#2,1])&[> data[[All,1]], data[[All,2]]]/2//Timing {0.83 Second,13.768} --> Allan ---------------------> Allan Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> I've tracked down the slow operation of my Mathematica simulation > code to> lie in the ListIntegrate command:> G[n_] := ListIntegrate[xsec Phi[n], 1]> where both xsec and Phi[n] are 400 values long.> Is there a way to speed up ListIntegrate via Compile or a similar > technique?> Matt> ---> Matthew Rosen> Harvard-Smithsonian Center for Astrophysics> Mail Stop 59> 60 Garden Street> Cambridge, MA 02138> e: mrosen@cfa.harvard.edu> o: (617) 496-7614> ==== Daniel,I don't mean to be overly critical of WRI's documentation -- it's verygood, as such things go. Nor do I like to overlook chances to make itbetter. Do you?Your own comments below point out that we should expect vectorsresulting from NullSpace to be orthonormal by the usualconjugate-symmetric inner product on C. But that's not spelled out(documented) for dummies like myself who don't know that's a naturalresult of singular values decomposition.The mission of NullSpace (or any function) is to adhere todocumentation, so reasonable persons may differ on whether orthogonalityis a feature we should depend on.The mission of documentation is to tell us what to expect. When itdoesn't, the result is that we spend all this time discussing issuesonline, trying to figure things out. A simple don't depend onorthogonal results would be nice, if that's the intent.In any case, I just spent ten minutes LOOKING for implementation notesfor NullSpace, and have not found any. Searching for implementationnotes doesn't help and there's no link from NullSpace. What use isdocumentation I can't find?In general, I don't like Mathematica's quirky Help Browser, in which Icannot search for anything that's not indexed. Every other help engineon my computer (and there are hundreds) allows me to search for words,and that's exactly what I need in order to find all mentions ofNullSpace.Bobby Treat-----Original Message-----> of Mathematica.> BobbyThe expected, and documented, behavior is that the output should be abasis for the null space, that is, solutions of the homogeneous matrixequation A.x==0. If this were to stop working then that would be aserious bug. Is this the behavior you mean?The implementation notes of the manual mention that approximateNullSpace is based on a singular values decomposition. This in factgives resulting vectors that are orthonormal by the usualconjugate-symmetric inner product on C (though these are now notnormal to the original vector in this same inner product, unless theyare real-valued). But this basis-orthogonality is not part of themission of NullSpace and moreover should not become part of it. Hencethat particular (and implementation dependent) aspect of NullSpaceshould not become documented.Daniel LichtblauWolfram Research ==== P.J.,I'd be very interested in how you created these fancy cells. Do youopen a cell, push Ctrl-Shift-e, type in all that text, then pushCtrl-Shift-e again?Bobby Treat-----Original Message-----1) Put your function braches in the rows of a grid box structure.2) Add the following options to your cell: ShowAutoStyles -> False SpanMaxSize -> InfinityThe following cell snippet demonstrates how this inßuences the result.To view it, paste the Cell[] expression into a notebook and then clickon Yes when you are prompted on whether the front end should interpret the result.Cell[BoxData[ FormBox[ RowBox[{ RowBox[{f, (, x, )}], =, RowBox[{{, GridBox[{ {x, RowBox[{x, , <, 0}]}, { SuperscriptBox[x, 2], RowBox[{0, [LessEqual], x, <, 1}]}, { RowBox[{sin, (, x, )}], RowBox[{1, [LessEqual], x, <, 2}]}, { RowBox[{[CapitalGamma], (, x, )}], RowBox[{x, [GreaterEqual], 2}]} }]}]}], TraditionalForm]], DisplayFormula, ShowAutoStyles->False, SpanMaxSize->Infinity]> - vertical alignment of equals signs in multi-line equations or> derivations;Put your equations in a GridBox and set the ColumnAlignments option to astring containing the equal sign.Cell[BoxData[ FormBox[GridBox[{ { RowBox[{ RowBox[{ RowBox[{3, x}], , +, , RowBox[{4, , y}]}], , =, , 9}]}, { RowBox[{ RowBox[{ RowBox[{2, x}], , -, , RowBox[{7, , y}]}], =, RowBox[{32, , -, , RowBox[{sin, (, x, )}]}]}]} }], TraditionalForm]], DisplayFormula, GridBoxOptions->{ColumnAlignments->{=}}]> - setting typefaces in tables of material.I think the Author Tools material that comes with Mathematica 4.2 mightbe able to help you do this.-- User Interface Programmer paulh@wolfram.comWolfram Research, Inc. ==== > I'd be very interested in how you created these fancy cells. Do you> open a cell, push Ctrl-Shift-e, type in all that text, then push> Ctrl-Shift-e again?Surely you have grossly overestimated my expertise with Mathematicatypesetting language syntax. :-)Here is the walkthrough for creating each sample cell.Example 1:1) Set down a cell insertion point in your notebook.3) Click on the cell's bracket.4) Click on the front end menu command sequence:Format -> Cell Style -> DisplayFormula5) Click on the front end menu command sequence:Cell -> Display As -> TraditionalForm6) Click on the front end menu command:Format -> Option Inspector...7) Make sure that the Option Inspector scope indicator is set toselection.8) Enter the name of the option ShowAutoStyles into the search field andpress the Lookup button.9) Change the value of the option ShowAutoStyles from True to False. Thisprevents the front end from showing the left brace with the umatchedsyntax coloring.10) Look up the option SpanMaxSize as was done in step (8).11) Change the value of this option to Infinity.12) Close the Option Inspector dialog.13) Click within the cell you just created to create an editor caret.14) Type in the text f(x) = {4 x 2.17) Enter in the function branch definitions in the left column, and thedomains of definition in the right column. You can use the Tab key tonavigate between grid elements.Example 2:1) Repeat Steps (1) - (11) in Example 1.2) With the cell bracket still selected, look up the option namedColumnAlignments. Change it from {Center} to {=}.3) Close the Option Inspector dialog.4) Click within the cell you just created to create an editor caret.6) Enter in the equations, with one equation per grid element.I used the front end menu command Edit -> Copy As -> Cell Expression toget the underlying expressions.Hope that demystifies the procedure for you.-- User Interface Programmer paulh@wolfram.comWolfram Research, Inc. ==== You're not doing anything dumb as far as I can see, but you're using farmore memory than necessary. Here are statistics for your algorithm onmy machine:SeedRandom[5];nums = NullDo[nums = add[nums, Random[]], {5000}]; // Timingnums // LeafCountnums // ByteCountCount[nums, Null, Infinity]Count[nums, node[_, Null, _], Infinity]Count[nums, node[_, _, Null], Infinity]Count[nums, node[_, Null, Null], Infinity]Count[nums, node[___], Infinity]Count[nums, node[_, _node | _?NumericQ, _node | _?NumericQ], Infinity]Depth[nums]{4.406000000000001*Second, Null}150012400005001 (* Null values in the tree *)2458 (* nodes without left offspring *)2543 (* nodes without right offspring *)1669 (* leaf nodes *)4999 (* total nodes *)1667 (* nodes with both left and right offspring *)28 (* minus one, makes 27 levels in the tree *)It's clearly not ideal to store 5001 Nulls for 5000 actual values!Here's a method that doesn't change the algorithm much, but changes thestorage method a great deal:First of all, I'm lazy, so I'll redefine <,>,<=,>=, etc. to make thecode simpler:Unprotect[Less, Greater, LessEqual, GreaterEqual];Less[a : _node ..] := Less @@ (First /@ {a})LessEqual[a : _node ..] := LessEqual @@ (First /@ {a})Greater[a : _node ..] := Greater @@ (First /@ {a})GreaterEqual[a : _node ..] := GreaterEqual @@ (First /@ {a})Protect[Less, Greater, LessEqual, GreaterEqual];Again because I'm lazy, I'll define node so that I don't have toconsciously avoid leaf nodes and unnecessary nesting:ClearAll[node]node[a___, node[b_], c___] = node[a, b, c];node[node[a__]] = node[a];Here's my add function:Clear[add]add[Null, x_] = node[x];add[x_, (y_)?NumericQ] := add[node[x], node[y]]add[(x_)?NumericQ, y_] := add[node[x], node[y]]add[node[x_], node[y_]] := If[x > y, node[x, y], node[y, x]] (* <--THERE! *)add[node[x_, lower_], y_node] := Which[y >= node[x], node[x, lower, y], y <= node[lower], node[lower, y, x], True, node[y, lower, x]]add[node[x_, lower_, higher_], y_node] /; node[y] <= node[x] := node[x, add[lower, y], higher]add[node[x_, lower_, higher_], y_node] := node[x, lower, add[higher,y]]Where I have a pointer is the code that prevents adding right-offspringto a leaf node. That avoids nodes like your node[a,Null,c]. When youwould have node[a,b,Null], I have node[a,b]. When you would havenode[a,Null,Null], I use a itself.Timing and space requirements are much better now:SeedRandom[5];nums = NullTiming[Do[nums = add[nums, Random[]], {5000}]; ]{2.109*Second, Null}LeafCount[nums]ByteCount[nums]Count[nums, Null, Infinity]Count[nums, node[_], Infinity]Count[nums, node[_, _], Infinity]Count[nums, node[_, _, _], Infinity]Count[nums, node[___], Infinity]Depth[nums]7852 (* 48% fewer leaf expressions, mostly due to Nulls and right-offspring eliminated *)165624 (* 31% less storage *)0 (* no Nulls, versus 5001 *)0 (* no leaf nodes, versus 1669 *) (* no nodes without left-offspring, versus 2458 *)705 (* nodes without right offspring, versus 2543 *)2146 (* nodes with both left and right offspring, versus 1667 *)2851 (* total nodes *)21 (* 21 tree levels versus 27 *)The logical structure is identical to yours except that there are nonodes with only right-offspring. This incidentally tends to reduce treedepth.The storage format is far different: there are no trivial (childless)nodes, and nodes with left-offspring but no right-offspring are storedwithout a Null on the right.I could make this quite a bit faster, I think, if I spent time on thecode to eliminate changes to Less, Greater, etc. and the frequentnesting followed by unnesting that goes on in the algorithm. It mighttake twice as much code, however, so I like it as is.You're probably better off storing these things in a heap, of course.Or -- better yet -- use the built-in Sort and Ordering functions.Bobby Treat-----Original Message-----In[327]:=add[Null,x_Real]:=node[x,Null,Null] add[Null,node[x_Real,lower_,higher_]]=node[x,lower,higher]In [328]:=add[node[x_Real,lower_,higher_],y_Real]:= If[x>y,node[x,add[lower,y],higher],node[x,lower,add[higher,y] ]]In[288]:=add[node[x_Real,lowerx_,higherx_],node[y_Real, lowery_,highery_]]:=If[x>y, node[x,add[lowerx,node[y,lowery,highery]],higherx], node[x,lowerx,add[higherx,node[y,lowery,highery]]] ]Now this is my attempt to test how fast my add works:SeedRandom[5];Do[nums=add[nums,Random[]],{5000}];// TimingOut[333]={13.279 Second,Null}RH7.3running on an 1.4GHz Athlon with 1GB of ram).Questions:1. Is this as fast as I can get my code to run?2. Am I doing something obviously stupid?3. would Compiling things help?Husain