3563 === Subject: Re: Question on making a piecewise function periodic tia sal2 I do not understand fully what you want to do. But, to make a function periodic is a piece of cake. E.g. if we want some function f to have period L we may define an operator: makeper[f_,L_]= f[Mod[#,L]]& Here is an example. We want a sine with periode: 1: sin1= makeper[Sin,1] you may plot the result: Plot[sin1[x],{x,0,3}] Of course, when you make a function periodic with the wrong periode, you will get y discontinuity. hope this helps, Daniel > Question on making a piecewise function periodic tia sal2 > I'm trying to make a piecewise function look periodic. > example (shows the positive humps of the sin wave from 0 to 2Pi) > Manipulate[test=choice[ Piecewise[{{Sin[a*t],t +C,t>Pi}}],{t,0,2 Pi}],{a,1,5},{C,0,2},{choice,{Plot,Expand}}] This command will work if t is 0 to 2 Pi but the sin wave goes > negative after that I think If I use the Mod command example: Manipulate[test=choice[ Piecewise[{{Sin[a*t],t +C,t>Mod[Pi,4]}}],{t,0,2 Pi}],{a,1,5},{C,0,2},{choice,{Plot,Expand}}] It could work so it would never go negative but I'm not sure how to > implement mod command so the sin wave won=92t go negative. I'm also > open to other suggestions. The reason why I'm doing this is that when I do periodic interpolation > the formula > Breaks down due to the Gibbs Phenomenon. The signals I'm creating > have about 200 separate values that=92s why it breaks down. But I'm > using a simple example to see if it can be done. So I can basically > stitch multiple simple wave signals together to create one big complex > one and still have the ability to make the complex signal periodic > over time. Tia sal2 > === Subject: Re: User interface version 7: Alt Gr issue > I have a Belgian keyboard. To enter [ or {, I have to press and hold > the Alt Gr key. In Mathematica 6.0.3 this works as expected. However in > version 7.0 I get a blue block plus the { or [ symbol. I have to remove > these blue blocks manually. I really can't understand that Wolfram can > release such a horrible interface! In summary you must do: Open /usr/local/Wolfram/Mathematica/7.0/SystemFiles/FrontEnd/ TextResources/X/KeyEventTranslations.tr file on your system.(eg.: sudo nano ..., paths may vary). Then somewhere under EventTranslations[{ type some newlines, then paste this literally: Item[KeyEvent[ISO_Level3_Shift], FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], Sequence[], After]}] ], This code translates the Alt-Gr key(ISO_Level3_Shift) to produce something in the notebook, which is in this case nothing, becase Sequence[] evaluates to nothing, albeit its syntactically correct. good luck. === Subject: Re: Mathematica 7 on an Asus Eee PC Laptop? > Has anyone tried running Mathematica 7 on an Asus Eee PC Laptop under > Linux? hi, I have a eeePC900 with eeebuntu (the last one), and Mathematica run perfectly... Andrea === Subject: Re: Mathematica 7 on an Asus Eee PC Laptop? > Has anyone tried running Mathematica 7 on an Asus Eee PC Laptop under > Linux? hi, I have a eeePC900 with eeebuntu (the last one), and Mathematica > run perfectly... Hi Andrea, Just out of curiosity, have you run the benchmarks that come with Mathematica on the netbook? If so, could you, please, report the results and perhaps write a line or two about your overall experience with the system. I am asking because I was wondering whether a netbook + a CAS (commercial or open source) could be a suitable replacement of a laptop in classroom setting (e.g. doing interactive presentations with some real-time computations or plots of simple expressions or models). --Jean-Marc === Subject: Question on making a function periodic tia sal2 me to reply to my original message today...gremlins in the machine I guess anyone know how to get it so one graph will start at the end of the first one? Here's a picture of what I get using Jaccard code he helped me with: http://test.onewithall.net/math/2wavescurrent.jpg period1 = Pi; startPeriod1 = 0; fper1[t_] := Sin[Mod[t - startPeriod1, period1] + startPeriod1] period2 = 2 Pi; startPeriod2 = Pi; fper2[t_] := .3*Sin[Mod[t - startPeriod2, period2] + startPeriod2] Manipulate[ test = choice[{fper1[a*t], fper2[a*t] + c}, {t, 0, 2*Pi}], {a, 1, 5}, {c, 0, 2}, {choice, {Plot, Expand}}] Here's one example picture of what I'm trying to get by joining waves together: http://test.onewithall.net/math/1waveafter.jpg Or if you need to see both images on one page http://test.onewithall.net/math/both.jpg I've tried adding Piecewise again but the original problem pops up Manipulate[ test = choice[ Piecewise[{{fper1[a*t], t < Pi}, {fper2[a*t - Pi] + c, t > Pi}}], {t, 0, 2 Pi}], {a, 1, 5}, {c, 0, 2}, {choice, {Plot, Expand}}] The reason why I'm doing this is that when I do periodic interpolation the formula Breaks down due to the Gibbs Phenomenon. The signals I'm creating have about 200 separate values thats why it breaks down. But I'm using a simple example to see if it can be done. So I can basically stitch multiple simple wave signals together to create one big complex one and still have the ability to make the complex signal periodic over time. tia sal2 === Subject: How to modify an Excel file Excel files, and they work fine. The only problem is that, as far as I understood, they cannot work with cell formats. This means that I could not find a way to import an Excel file, modify a cell and then export it in a new file with the same formatting as the original. Is there, to your knowledge, a way to let Mathematica write a value in a cell of an existing Excel file without using Excel Link and without modifying the cell's format? I have both Mathematica and Excel installed on my PC. Hope some of you has a solution! === Subject: Re: How to modify an Excel file assume that you have an Excell sheet with 1,2 in the first row and 3,4 in the second row saved to a file d:/tmp/t.xls. Read it in Mathematica by: d = Import[d:/tmp/t.xls] this gives: {{{1., 2.}, {3., 4.}}} now we add 10 to every cell and save it in d:/tmp/t1.xlsby: d=d+10; Export[d:/tmp/t1.xls, d] If you open this file, you will see that all the cells are changed. hope this helps, Daniel > Excel files, and they work fine. The only problem is that, as far as I > understood, they cannot work with cell formats. This means that I > could not find a way to import an Excel file, modify a cell and then > export it in a new file with the same formatting as the original. Is there, to your knowledge, a way to let Mathematica write a value in > a cell of an existing Excel file without using Excel Link and > without modifying the cell's format? I have both Mathematica and Excel installed on my PC. Hope some of you has a solution! === Subject: Re: Keeping plot annotations after regenerating a plot Hi David, I agree with you that what I'm doing is some kind of kludge. But if your graphics needs aren't very demanding that's all you'd need. For the reports that I write I usually only need some simple data plots or model outputs. Nothing really fancy. Some quick annotations, like arrows with a condition code are all I need. What Mathematica now has more or less covers what I need (I could use better legends, though) and it's many times better than MS Excel I guess WRI could place user additions in the Graphics structure as an option so that it would easier to manipulate them: Graphics[ {original plot stuff, UserAdditions}, PlotRange->Automatic, etc..., UserAdditions-> {GraphicsStuff, GraphicsStuff} ] > Sjoerd, As appealing as the drawing tools may seem, I must disagree that they are= a > solution to producing professional custom graphics and displays. My reaso= n > for saying this is that they do not provide a precise written description= of > the graphics, which can then be modified. The drawing tools might be > suitable for quick sketches but I don't believe they are suitable for > graphics that undergo a process of development and modification. What happened is that you found the problem with using drawing tools, and > then found a fix and way around it. But how many times might a custom plo= t > need to be modified in the process of development? How many times will it= be > necessary to go through the fix? Does this work with dynamics, or within = a > Manipulate statement? (I don't actually know.) It is much better to have a SINGLE explicit specification statement for a > generated graphic, or combined dynamic graphic and page display. Making a > good custom graphic generally takes a fair amount of work because there i= s > much detail to specify. The Presentations package makes it much easier to construct custom graphi= cs, > and now also dynamic page displays combining graphics with other > expressions. One can just specify one thing after another, with primitive= s > from any of the standard plot types. I just finished a dynamic presentation that contains movable line segment= s, > step by step construction of a geometric diagram with checkboxes, several > sliders built intoa textual display, an action button, a graduated ruler > that can be moved. The calculations for the last operation are time > consuming in a dynamic display and are triggered only when the ruler is > moved. The entire presentation took several days to develop and ended up > much longer and different than the initial design. Trying to do this with > drawing tools or within a Manipulate statement would have been extremely > difficult, and frustrating - if it was even possible. Developing professional displays takes a lot of work because of all the > essential detail. Working without explicit written specifications, or try= ing > to twist something like the baroque Manipulate statement to specific need= s > is simply impossible. David Park > djmp...@comcast.nethttp://home.comcast.net/~djmpark/ > I really like the possibility to manually add graphics and text to a > plot using the Mathematica 6/7 drawing tools palette. It's often much > quicker > than having to program them. However, more often than not, just after > I finish making those annotations I discover that I used the wrong > parameter value for the plotted model or want larger axes label fonts > or so. Problem is, when I regenerate the plot I'll erase my own annotations > and I have to redo them. I found some sort of solution that I'd like > to share. Perhaps you folks know of a better solution? * Assign your first plot with annotations to a variable, say y. > * Re-generate the first plot (without annotations) and with essential > font change; call it x > * Execute: x[[1]] = {x[[1]], y[[1, 2 ;; -1]]}; and x now has your old annotations. Seems to work for most 2D plots. I tried Plot, ListPlot, DensityPlot > and ContourPlot and a few of their options. Not sure whether it is > really robust. > === Subject: Re: How to stop the latest Mathematica hijacking the .nb extension in Has anyone had a similar problem: The latest (V7 in this case) > Mathematica installation seems to hijack the file association to .nb > files to itself. This is usually what the user wants, but in some cases > (if the latest version has severe bugs etc.) it would be nice to open > the notebooks with previous version (in V6 in this case) when > double-clicking in Explorer. Usually one could just edit or remove the file association in > Tools->Folder Options->File Types with Windows Explorer, but Mathematica > seems to use some trick that always opens with the latest, even if you > try to change the association. Has anybody found a workaround to this? The problem seems to exists at > least with XP and Vista. Antti When you set the file association to a particular Mathematica binary, add the command-line option -directlaunch as the first argument to the binary. This will disable the mechanism which launches the best available version of Mathematica. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: still ignores special cases of functions There is an error in your own code. Your definition of c[1] is either unnecessary or wrong. The first equation is only true if c[1] = k cc (in which case the general definition of c would be sufficient). You define it as cc. Hello > The Sum[] seems to ignore special cases of a function. Try the > following: c[n_] := k cc^n; > c[1] := cc; > Sum[c[m], {m, 1, Infinity, 1}] // FullSimplify > c[1] + Sum[c[m], {m, 2, Infinity, 1}] // FullSimplify > Sum[k cc^n, {n, 1, Infinity, 1}] // FullSimplify > c[1] Obviously the special case > c[1] := cc > is completely ignored by Sum[]. > As I understand this is a bug in the Sum[] or in internal work with > function definitions. > The corresponding pages of the Documentation are: > tutorial/MakingDefinitionsForFunctions > and > tutorial/TheOrderingOfDefinitions I can add that in v.7.0.0 the bug is still here: In[1]:= c[n_] := k cc^n; > c[1] := cc; > Sum[c[m], {m, 1, Infinity, 1}] // FullSimplify Out[3]= False Out[4]= True === Subject: Re: still ignores special cases of functions > There is an error in your own code. Your definition of c[1] is either > unnecessary or wrong. The first equation is only true if c[1] = k cc (in which case the > general definition of c would be sufficient). You define it as cc. > You are mistaking. Try to read the following pages of the manual: tutorial/TheOrderingOfDefinitions tutorial/MakingDefinitionsForFunctions This is a piecewise function but Sum[] does not work with Piecewise[] at all. And it ignores the special cases of function definitions. === Subject: Re: The use of Piecewise function > How can I to use the Piecewise function for symbolic calculations. For > example, let the equation of ellastic line of a beam In[]: M[x_]:=Piecewise[{{Subscript[V, A]x,0<=x (x-b),b<=x<=a+b}}]; > DSolve[{y''[x]==M[x],y[a+b]==0,y'[a+b]==0},y[x],x]; > Y[x_]=y[x]/.%[[1]] Out[]:-[Piecewise]1/12 a^2 (2 a+3 b) P a+b>=0[And]-a>0 > 1/4 (2 b (a+b)^2-1/3 b (3 a^2+6 b a+2 b^2)) P -a<=0 + etc, etc I have proved with Assumptions, Assuming, but it does'nt work. Not sure to understand your last sentence. For instance, what is wrong (if anything) with the following result? What results do you expect? Note that with a correct set of assumptions, the solutions is simplified and no piecewise functions are left (see In/Out[3]). In[1]:= M[x_] := Piecewise[{{Subscript[V, A] x, 0 <= x < b}, {Subscript[V, A] x - P (x - b), b <= x <= a + b}}] sol = DSolve[{y''[x] == M[x], y[a + b] == 0, y'[a + b] == 0}, y, x] Assuming[-a <= 0 && b > x && x > 0, Simplify[y[x] /. sol[[1]]]] Out[2]= {{y -> Function[{x}, a ([Piecewise] { {1/2 (a + b)^2 Subscript[V, A], a + b >= 0 && -a > 0}, { b (a + b) P - 1/2 (a + b)^2 P + 1/2 (a + b)^2 Subscript[V, A], -a <= 0} }) + b ([Piecewise] { {1/2 (a + b)^2 Subscript[V, A], a + b >= 0 && -a > 0}, { b (a + b) P - 1/2 (a + b)^2 P + 1/2 (a + b)^2 Subscript[V, A], -a <= 0} }) - x ([Piecewise] { {1/2 (a + b)^2 Subscript[V, A], a + b >= 0 && -a > 0}, { b (a + b) P - 1/2 (a + b)^2 P + 1/2 (a + b)^2 Subscript[V, A], -a <= 0} }) - [Piecewise] { {1/6 (a + b)^3 Subscript[V, A], a + b >= 0 && -a > 0}, {1/2 b (a + b)^2 P - 1/6 (a + b)^3 P + 1/6 (a + b)^3 Subscript[V, A], -a <= 0} } + [Piecewise] { {((x^3 Subscript[V, A])/6), x >= 0 && b - x > 0}, {1/2 b P x^2 - (P x^3)/6 + (x^3 Subscript[V, A])/6, b - x <= 0 && a + b - x >= 0} }]}} Out[3]= 1/6 (-(a + b) P (2 a^2 + a (b - 3 x) - b (b - 3 x)) + (a + b - x)^2 (2 a + 2 b + x) Subscript[V, A]) --Jean-Marc === Subject: Maximizing function which defines a routine (Apologies up front for my utter lack of programming ability--the only language Ive ever really programmed in is Basic and I havent even done much of that) I have a function G in two arguments (x,y) which uses a loop (Im using label/goto for this loop if that gives any idea of my programming abilities) to alter the values of three state variables (a,b,c). The output of this function is to store the final values of these three variables a,b,c, (globally). Is it possible in Mathematica to use Maximize or NMaximize on this function, in order to, for example, find the x which maximizes a (given y)? Mark === Subject: Re: Maximizing function which defines a routine Hi Mark, assuming that you have G[x,y] that returns: {a,b,c}, you may maximize G over x with e.g. y=1 by: NMaximize[G[x,1][[1]],x Here is a simplified example: G[x_] := {-(x - 1)^2, 1}; NMaximize[G[x][[1]], x]] hope this helps, Daniel > (Apologies up front for my utter lack of programming ability--the only language Ive ever really programmed in is Basic and I havent even done much of that) I have a function G in two arguments (x,y) which uses a loop (Im using label/goto for this loop if that gives any idea of my programming abilities) to alter the values of three state variables (a,b,c). The output of this function is to store the final values of these three variables a,b,c, (globally). Is it possible in Mathematica to use Maximize or NMaximize on this function, in order to, for example, find the x which maximizes a (given y)? Mark > === Subject: NEWBIE QUESTION - How to create a barchart with two data sets. I am new to Mathematica and can't seem to figure out how to do a simple bar chart using 2 data sets, in Excel you either have the data in a series in rows or columns. An example might be something like.... http://z.about.com/d/spreadsheets/1/0/Z/3/-/-/column_chart.jpg Any help would be great. Tim === Subject: Re: NEWBIE QUESTION - How to create a barchart with two data sets. Hi Tim, I hadn't used BarChart before, so I gave it a try. I can see your problems, given the bewildering set of options. Here is my version: BarChart3D[ { Labeled[{70000, 60000, 10000}, 2005, Below] }, BaseStyle -> {FontFamily -> Arial, FontWeight -> Bold, FontSize -> 16}, BarSpacing -> {0, 1}, ChartLegends -> (Style[#, {FontFamily -> Arial, FontWeight -> Bold, FontSize -> 14}] & /@ {Total Revenues, Total Expenses, Profit/Loss}), FaceGrids -> {{0, 1, 0}}, FaceGridsStyle -> Directive[{Thick, RGBColor[0.9, 0.9, 0.9]}], LabelStyle -> {}, ChartBaseStyle -> {EdgeForm[{Thin, Opacity[0.8]}]}, ChartStyle -> {Directive[Blend[{Blue, Gray}, 0]], Directive[Blend[{Blue, Lighter[Gray]}, 0.6]], Directive[Blend[{Blue, Lighter[Gray]}, 0.8]]}, ChartElementFunction -> Cube, Lighting -> {{Ambient, GrayLevel[0.6]}, {Directional, White, {{1, -3, 5}, {0, 0, 0}}}} ] > I am new to Mathematica and can't seem to figure out how to do a simple b= ar chart using 2 data sets, in Excel you either have the data in a series i= n rows or columns. An example might be something like.... http://z.about.com/d/spreadsheets/1/0/Z/3/-/-/column_chart.jpg Any help would be great. Tim === Subject: Re: NEWBIE QUESTION - How to create a barchart with two data sets. > I am new to Mathematica and can't seem to figure out how to do a simple bar > chart using 2 data sets, in Excel you either have the data in a series in > rows or columns. An example might be something like.... http://z.about.com/d/spreadsheets/1/0/Z/3/-/-/column_chart.jpg Any help would be great. Assuming you have Mathematica 7, you could use the built-in function BarChart[], passing the datasets as a list of lists. For instance, BarChart[{{1, 2, 3}, {1, 3, 2}}] --Jean-Marc === Subject: Re: NEWBIE QUESTION - How to create a barchart with two data sets. dta = Sort /@ Table[RandomInteger[{0, 255}], {10}, {2}] BarChart3D[dta] ?? Jens > I am new to Mathematica and can't seem to figure out how to do a simple bar chart using 2 data sets, in Excel you either have the data in a series in rows or columns. An example might be something like.... http://z.about.com/d/spreadsheets/1/0/Z/3/-/-/column_chart.jpg Any help would be great. Tim > === Subject: Re: set of ODE's Hi Baris, I think the problem is that Mathematica assume x to be a scalar variable. A (not very elegant) way to get around this would be: A = RandomReal[{1, -1}, {3, 3}]; x[t_] = {{x11[t], x12[t], x13[t]}, {x21[t], x22[t], x23[t]}, {x31[t], x32[t], x33[t]}}; f = NDSolve[ Flatten[ { MapThread[Equal, {x'[t], A.x[t]}, 2], MapThread[Equal, {x[0], RandomReal[1, {3, 3}]}, 2] } ], {x11, x12, x13, x21, x22, x23, x31, x32, x33}, {t, 0, 20} ] > I think my e-mail didn't go through so I am sending it again. Sorry if yo= u have already received it. Here is my question: I have a large set of vector/matrix ODE's I want to solve numerically. Bu= t I am having some problems with the notation. For example something like t= hat works very well A = RandomReal[{1, -1}, {3, 3}]; > NDSolve[{x'[t] == A.x[t], x[0] == RandomReal[1, {3, 3}]}, x, {t, = 0, 20}] but it doesn't work if I add a constant term to the right hand side of th= e equation: NDSolve[{x'[t] == A.x[t] + IdentityMatrix[3], x[0] == RandomReal[= 1, {3, 3}]}, x, {t, 0, 20}] I guess the problem is that Mathematica adds A.x[t] to all the components= of the IdentityMatrix[3] as if it is a scalar quantity. I defined the iden= tity matrix to be a matrix function with zero derivative etc, so that it do= esn't get evaluated immediately and that works but there should be a better= way of doing it with the Hold function I guess. Do you have any idea how t= o do this in a more elegant way? === Subject: Re: Automatic Numbering in Mathematica The Presentations package contains a sub-package called KeyEquations that allows the users to keep a list of key equations. They can be defined to display in any style, both for the equation and the label. So you could have square brackets if you wished. The equations can be recalled at any point and used as normal equations. A notebook and PDF file showing an example of this will be posted at Peter Lindsay's site: Peter Lindsay at the Mathematical Institute in the University of St Andrews [ www.mcs.st-and.ac.uk ] has kindly undertaken to maintain an archive that provides downloadable notebooks and PDF files for various Presentations solutions that have appeared on MathGroup. http://blackbook.mcs.st-and.ac.uk/~Peter/djmpark/html/ David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Is there any kind of user control over how the automatic numbering in Mathematica works? For example I figured out how to set a cell to have a formula auto numbered, however I couldn't figure out how to tweak whats actually displayed there - for instance I'd like to prepend the section number and replace the default brackets with square ones: default in Mathematica (1) (2) ... etc I'd like: [4.1] [4.2a] [4.2b] [4.3] ... etc === Subject: Re: Automatic Numbering in Mathematica Hi TL, You can do that using the stylesheet editor (Format/Stylesheet editor...). Assuming you're in the default style make a cell in your notebook in the DisplayedFormulaNumbered style, open the stylesheet editor and edit the style by clicking and then typing ctrl-shift-E (Show expression). Replace the contents with: Cell[StyleData[DisplayFormulaNumbered], CellMargins->{{60, Inherited}, {Inherited, Inherited}}, StripStyleOnPaste->True, CellFrameLabels->{{None, Cell[ TextData[{[, CounterBox[Section],. ,CounterBox[DisplayFormulaNumbered], ]}]]}, {None, None}}, DefaultFormatType->DefaultInputFormatType, HyphenationOptions->{HyphenationCharacter->[Continuation]}, LanguageCategory->Formula, ScriptLevel->0, SingleLetterItalics->True, CounterIncrements->DisplayFormulaNumbered, MenuPosition->1710, UnderoverscriptBoxOptions->{LimitsPositioning->True}] ctrl-shift-E to close again. This is a modified version of the original hat I copied from the you can click through to its parent by clicking it's parent name in the top of the stylesheet. If you want you could also change the definition in the default style, but I would suggest making a copy and use that as your own style file. BTW Don't know how to have to do these a, b numberings of yours. Aee they generated automatically? > Is there any kind of user control over how the automatic numbering in > Mathematica works? > For example I figured out how to set a cell to have a formula auto > numbered, however I couldn't figure out how to tweak whats actually > displayed there - for instance I'd like to prepend the section number > and replace the default brackets with square ones: default in Mathematica > (1) > (2) > ... > etc I'd like: > [4.1] > [4.2a] > [4.2b] > [4.3] > ... > etc > Is there any kind of user control over how the automatic numbering in > Mathematica works? > For example I figured out how to set a cell to have a formula auto > numbered, however I couldn't figure out how to tweak whats actually > displayed there - for instance I'd like to prepend the section number > and replace the default brackets with square ones: default in Mathematica > (1) > (2) > ... > etc I'd like: > [4.1] > [4.2a] > [4.2b] > [4.3] > ... > etc === Subject: Re: Is this so hard? > You didn't want another initial (or boundary) condition for this 2nd > order ODE? > You're right. DSolve[{x''[t] == 1/x[t]^2, x[0] == -1, x'[0] == 0}, x, t] This still gives no answer. Any ideas? Mathematica 6.0.3 seems to take forever to yield a result, if any. Mathematica 7.0.0 is faster and says something (see In[1]) :-) Also, it an appropriate range for t (see In[2] and In[3] below). In[1]:= DSolve[{x''[t] == 1/x[t]^2, x[0] == -1, x'[0] == 0}, x, t] During evaluation of In[1]:= DSolve::bvimp: General solution contains implicit solutions. In the boundary value problem these solutions will be ignored, so some of the solutions will be lost. >> Out[1]= {} In[2]:= NDSolve[{x''[t] == 1/x[t]^2, x[0] == -1, x'[0] == 0}, x, {t, 1}] Out[2]= {{x -> InterpolatingFunction[]}} In[3]:= NDSolve[{x''[t] == 1/x[t]^2, x[0] == -1, x'[0] == 0}, x, {t, 10}] During evaluation of In[3]:= NDSolve::ndsz: At t == 1.1107203514808217`, step size is effectively zero; singularity or stiff system suspected. >> Out[3]= {{x -> InterpolatingFunction[]}} In[4]:= $Version Out[4]= 7.0 for Microsoft Windows (32-bit) (November 10, 2008) --Jean-Marc === Subject: Re: Is this so hard? Try solving it numerically. t0 = 1.12; sol = NDSolve[{x''[t] == 1/x[t]^2, x[0] == -1, x'[0] == 0}, x, {t, 0, t0}] Plot[(x /. sol[[1]])[t], {t, 0, t0}] This gives the following error message: NDSolve::ndsz: At t == 1.1107203590726262`, step size is effectively zero; singularity or stiff system suspected. There is a singularity where x[t] goes to zero, which makes the 1/x[t]^2 term in the ODE blow up. -- Stephen Luttrell West Malvern, UK > You didn't want another initial (or boundary) condition for this 2nd >> order ODE? > > You're right. DSolve[{x''[t] == 1/x[t]^2, x[0] == -1, x'[0] == 0}, x, t] This still gives no answer. Any ideas? > === Subject: Re: What do such expression like (0->1), (0->0) in solutions mean? > Solving a system of equations I've got answer in a usual form > variable1->solution1, variable2->solution2,.., but in the bodies of solutions > there are terms like (0->0), (0->1). What does it mean? This is not a result that one would expect. Now, if you could post an example of an expression that returns this kind of result as solution... --Jean-Marc === Subject: undefined function I want to use an undefined function in an expression like: epp = f0 lamdap direction[sigma =96 X] where f0, lamdap are scalar values and direction[sigma =96 X] is an undefined function, but the result of this function is a second order tensor (3x3-matrix). How can I define this function? Later I must take the elements of epp ( yp[1] = epp[[1,1]]) and follow up with this. When I try it now I get the error-message: Part::partd : Part specification <<1>> is longer than depth of object. Cetin Haftaoglu Arbeitsgruppe Modellierung und Simulation in der Werkstoffmechanik Fachgruppe V.2 =96Werkstoffmechanik Unter den Eichen 87 D-12205 Berlin Deutschland Tel: +49-30-8104-3194 Fax: +49-30-8104-1527 Email: cetin.haftaoglu@bam.de Web: www.bam.de === Subject: Re: undefined function Hi Cetin, obviously you must tell Mathematica that the output of your direction is a tensor. You e.g. may define: Direction[x_]:=Array[G,{3,3}] with this: epp=f0 landmap direction[sigma]; epp[[1,1]] gives: f0 landmap G[1, 1] hope this helps, Daniel I want to use an undefined function in an expression like: epp = f0 lamdap direction[sigma =96 X] where f0, lamdap are scalar values and direction[sigma =96 X] is an undefined > function, but the result of this function is a second order tensor > (3x3-matrix). How can I define this function? Later I must take the elements of epp ( yp[1] = epp[[1,1]]) and follow up > with this. When I try it now I get the error-message: Part::partd : Part specification <<1>> is longer than depth of object. Cetin Haftaoglu Arbeitsgruppe Modellierung und Simulation in der Werkstoffmechanik Fachgruppe V.2 =96Werkstoffmechanik Unter den Eichen 87 D-12205 Berlin Deutschland Tel: +49-30-8104-3194 Fax: +49-30-8104-1527 Email: cetin.haftaoglu@bam.de Web: www.bam.de > === Subject: Re: undefined function > I want to use an undefined function in an expression like: epp = f0 lamdap direction[sigma =96 X] where f0, lamdap are scalar values and direction[sigma =96 X] is an undefined > function, but the result of this function is a second order tensor > (3x3-matrix). How can I define this function? You could use the built-in function *Array* to simulate the tensor returned by the yet undefined function direction[]. In[1]:= epp = f0 lamdap Array[d, {3, 3}] Out[1]= {{f0 lamdap d[1, 1], f0 lamdap d[1, 2], f0 lamdap d[1, 3]}, {f0 lamdap d[2, 1], f0 lamdap d[2, 2], f0 lamdap d[2, 3]}, {f0 lamdap d[3, 1], f0 lamdap d[3, 2], f0 lamdap d[3, 3]}} > Later I must take the elements of epp ( yp[1] = epp[[1,1]]) and follow up > with this. When I try it now I get the error-message: Part::partd : Part specification <<1>> is longer than depth of object. With the above strategy, the following works: In[2]:= epp[[1, 1]] Out[2]= f0 lamdap d[1, 1] --Jean-Marc === Subject: Re: Please answer to my questions,thank you. > I want to know if epsilon is a predefined character in mathematica, > like pi? if no, when I write the greek caracter epsilon in an equation > how mathematica interprets it? must I fix the value of epsilon? > epsilon is a legal variable name just as b or q. No pre-defined values. Instead of asking you could have checked that yourself easily. Just type esc-e-esc, and hit enter, or ?-esc-e-esc, or esc-e-esc//N, or just esc-e-esc in the documentation centre. Whether it can be used in an equation? Try, don't ask! Reduce[{xP == 1 + a/yP, (yP - xP)^2 <= [Epsilon]}, {xP, yP}] > On 7 jan, 13:11, Sjoerd C. de Vries (yP - xP)^2 is not so much different from |yP-xP|. Note that I have > changed epsilon in your test Abs[yP - xP] <= epsilon in epsilon2, with which I meant the square of epsilon, epsilon^2 All real yP and xP that pass the Abs[yP - xP] <= epsilon test also > pass the (yP - xP)^2 <= epsilon^2 test and vice versa. The latter can > be handled easier by Mathematica, though. With respect to your Nest[ ] question. I don't think it's > mathematically possible. Take for instance the case that f is defined > as f[x_]:= - x. Your equation would have infinite solutions, not only > the i-j one you mention. Same with f = Sin and x= n Pi. Anyway, I > don't think mathematica could solve this if you don't specify al least > the Nesting depth. On 6 jan, 10:10, Sjoerd C. de Vries Hi Olfa, [comments between your text lines] > 1-reduce: f(f(f(...(v) i times=f(f(f(...(w) j times. I've tried= = > ne= > st = > like this: > Nest[f,v,i]=C5 Nest[f,w,j] > , but I have this error: > Nest::intnm: Non-negative machine-size integer expected at positi= on= > 3= > in = > Nest[f,v,i] and > Nest::intnm: Non-negative machine-size integer expected at positi= on= > 3= > in = > Nest[f,w,j] > =C2 Well, Mathematica is really gung-ho to get to work for you. It real= ly > wants to Nest so badly, but then you give it nothing to chew on. Qu= it= > e > naturally, it complains. You didn't tell it how often to Nest. I'm not sure what you want to achieve here. Solve this equation for > the unknown f,v,i,w, and j? Impossible. But even if it would be > possible you're using the wrong syntax. Should be something like So= lv= > e > [Nest[f, v, i] == Nest[v, w, j], {v}] or so. 2-I want to use lists symbollically like this: m, mP,l,lP are lis= ts= > , = > j,jP= ,i,iP are variables.By symbolically I mean without specifying the c= on= > cr= > ete elements and the concrete length of these lists > i<=iP,j-Length[m]=C5 jP-Length[mP], > Join[l,m]=C5 Join[lP,mP], > Nest[Rest,m,i]=C5 Nest[Rest,mP,iP] There are some weird codes in there that I'm trying to interpret. N= ot > really sure whether I get it all. > You can't really have abstract lists in Mathematica. You can say > something like d = Array[c, i] and e=Array[b,j], but you'll get= t= > he > same complaints as above. The assignments have been made and replac= in= > g > i with a number yields a real list for d: In[55]:= d /. i -> 5 Out[55]= {c[1], c[2], c[3], c[4], c[5]} so far so good, but if you try to Join d and e you get nonsense: In[58]:= Join[d, e] During evaluation of In[58]:= Array::ilsmn: Single or list of non= - > negative machine-size integers expected at position 2 of Array > [c,i,b,j]. > > Out[58]= Array[c, i, b, j] I guess you could make some functions yourself that operate on > abstract lists but that would be hard work. 3-when I have j = > =N= > a= > s result. I'm sorry, but this doesn't make sense at all. Why would i have to > equal N? This is only true if j equals N-1, but you claim that j o > j==N-2 or N-3 would also fit the inequality. And what do you mean by 'result'? Result of what? 4-solve this system of equations: xP = 1 + a/yP=C2 and |yP= -x= > P|= > <= > = > = epsilon Since this involves an inequality Solve can't be used. If a and > epsilon are symbolic FindInstance can also not be used. Reduce shou= ld > work, but it doesn't get me an answer within a couple of minutes, s= o > with a small rewrite it becomes: Reduce[{xP == 1 + a/yP, (yP - xP)^2 <= epsilon2}, {xP, yP}] and now Reduce seems to be able to solve the system. > Yours faithfully, > Olfa MRAIHI - Masquer le texte des messages pr=E9c= =E= > 9d= > ents - - Afficher le texte des messages pr=E9c=E9dents - Hi Mr Sjoerd, > thank you for your reply.Here some clarifications and corrections: I'm not sure what you want to achieve here. Solve this equation for the unknown f,v,i,w, and j? Impossible. But even if it would be > possible you're using the wrong syntax. Should be something like > Solve > [Nest[f, v, i] == Nest[f, w, j], {v}] or so. well I explain exactly what I hope mathematica to do for me: > when I have f(f(f(...(x) i times == f(f(f(...(y) j times and i>= =j= > t= > hen > i want to have y in terms of the others which is y=f(f(f(...(x) i-j > times. So with mathematica syntaxe I will have :Reduce[i>=j,Nest[f,= i,= > x] > ==Nest[f,j,y],{y},Backsubstitution->True] and I want the solution= t= > o > be:y=Nest[f,i-j,x], is it possible? do you know how could i deal wi= th > this? Reduce should work, but it doesn't get me an answer within a couple = of= > m= > inutes, so > with a small rewrite it becomes: > Reduce[{xP == 1 + a/yP, (yP - xP)^2 <= epsilon2}, {xP, yP}] > and now Reduce seems to be able to solve the system. But (yP - xP)^2 is different from |yP-xP| what I want is: > Reduce[{xP == 1 + a/yP, Abs[yP - xP] <= epsilon}, {xP, yP}, > Backsubstitution -> True] or Reduce[{xP == 1 + a/yP, Abs[yP - = xP= > ] = > <= > 10^-6]}, {xP, yP}, > Backsubstitution -> True] > it doesn't get me an answer within a couple of minutes!! how you can > explain that and what i have to do? thank you!- Masquer le texte des messages pr=E9c=E9dents - - Afficher le texte des messages pr=E9c=E9dents - >3-when I have j output >I'm sorry, but this doesn't make sense at all. Why would i have to >equal N? This is only true if j equals N-1, but you claim that jj==N-2 or N-3 would also fit the inequality. you're right! but when I add the condition that Not(i still true? I want to know if epsilon is a predefined character in mathematica, > like pi? if no, when I write the greek caracter epsilon in an equation > how mathematica interprets it? must I fix the value of epsilon? thank you, === Subject: Re: Please answer to my questions,thank you. like pi? if no, when I write the greek caracter epsilon in an equation > how mathematica interprets it? must I fix the value of epsilon? The Greek character [Epsilon] has no built-in meaning, i.e. it is just a symbol like, say, a, b, or c. In other words, it stands by itself. It is up to you, if needed, to set [Epsilon] to some value(s), which can be any symbolic or numeric expression. Usually, this is the context of the problem you try to solve that will tell you if you must do so and what value is appropriate. --Jean-Marc === Subject: Re: Is this so hard? It returns in around six seconds for me in version 7: $Version = 7.0.0 for Linux x86 (32-bit) (November 23, 2008) In[1]:= TimeConstrained[Timing[DSolve[{x''[t] == 1/x[t]^2, x[0] == -1}, x, t]], 7200] //InputForm DSolve::bvimp: General solution contains implicit solutions. In the boundary value problem these solutions will be ignored, so some of the solutions will be lost. Out[1]//InputForm= {6.652416, {}} In version 6, the following seems to take a long time: Timing[Solve[(Log[-1 + (C[1] + Sqrt[C[1]]*Sqrt[C[1] - 2/x[t]])*x[t]]/C[1]^(3/2) + (Sqrt[C[1] - 2/x[t]]*x[t])/C[1])^2 == (t + C[2])^2, x[t]]] Sorry for the inconvenience. Bhuvanesh, Wolfram Research === Subject: Re: Graphics in PlotMarkers buggy in Mathematica 7 Another workaround would be placing each marker between curly brackets. As in: ListPlot[{{{1, 1}}, {{1, 2}}}, PlotMarkers -> {{Graphics[{Hue[0.5], Circle[]}]}, {Graphics[{Hue[0.96], Circle[]}]}}] > in Mathematica 7 on Mac OS X, try to execute this simple example: ListPlot[{{{1, 1}}, {{1, 2}}}, PlotMarkers -> {Graphics[{Hue[0.5], > Circle[]}], Graphics[{Hue[0.96],Circle[]}]}] Whereas this works in Mathematica 6.03, there is now the error > An improperly formatted option was encountered while reading a > GraphicsBox. The option was not in the form of a rule. This is apparently caused by any graphics directive (such as Hue, > Opacity, Thickness), but I was able to reliably work around it by > replacing Graphics with HoldForm@Graphics. There seems to be no problem with Graphics3D markers, and according to > the documentation there should be no problem with arbitrary Graphics > as plot markers, either. I'm guessing there has been some subtle > change in Graphics' inner workings that conflicts with its use in > PlotMarkers - but who knows. Anyway, HoldForm is the cure, in case anyone else stumbles over this > issue. Jens === Subject: Re: Graphics in PlotMarkers buggy in Mathematica 7 > Another workaround would be placing each marker between curly > brackets. As in: ListPlot[{{{1, 1}}, {{1, 2}}}, > PlotMarkers -> {{Graphics[{Hue[0.5], > Circle[]}]}, {Graphics[{Hue[0.96], Circle[]}]}}] in Mathematica 7 on Mac OS X, try to execute this simple example: ListPlot[{{{1, 1}}, {{1, 2}}}, PlotMarkers -> {Graphics[{Hue[0.5], > Circle[]}], Graphics[{Hue[0.96],Circle[]}]}] Whereas this works in Mathematica 6.03, there is now the error > An improperly formatted option was encountered while reading a > GraphicsBox. The option was not in the form of a rule. This is apparently caused by any graphics directive (such as Hue, > Opacity, Thickness), but I was able to reliably work around it by > replacing Graphics with HoldForm@Graphics. There seems to be no problem with Graphics3D markers, and according to > the documentation there should be no problem with arbitrary Graphics > as plot markers, either. I'm guessing there has been some subtle > change in Graphics' inner workings that conflicts with its use in > PlotMarkers - but who knows. Anyway, HoldForm is the cure, in case anyone else stumbles over this > issue. Jens Sjoerd, to be fool-proof. Jens === Subject: Re: Graphics in PlotMarkers buggy in Mathematica 7 Looks like a genuine bug. The part of the graphics code that place the circles in Mathematica 7 is (using FullForm): Inset[Graphics[List[Hue[0.5]], Circle[List[0, 0]]], 6]] whereas in Mathematica 6 it is (looks the same, but it's subtilly different): Inset[Graphics[List[Hue[0.5], Circle[List[0, 0]]]], 6]] Clearly, in Mathematica 7 the outmost List does not wrap around all graphics primitives as it does in Mathematica 6, but only around the first one. The closing bracket is misplaced. This leaves the latter primitives bungling. > in Mathematica 7 on Mac OS X, try to execute this simple example: ListPlot[{{{1, 1}}, {{1, 2}}}, PlotMarkers -> {Graphics[{Hue[0.5], > Circle[]}], Graphics[{Hue[0.96],Circle[]}]}] Whereas this works in Mathematica 6.03, there is now the error > An improperly formatted option was encountered while reading a > GraphicsBox. The option was not in the form of a rule. This is apparently caused by any graphics directive (such as Hue, > Opacity, Thickness), but I was able to reliably work around it by > replacing Graphics with HoldForm@Graphics. There seems to be no problem with Graphics3D markers, and according to > the documentation there should be no problem with arbitrary Graphics > as plot markers, either. I'm guessing there has been some subtle > change in Graphics' inner workings that conflicts with its use in > PlotMarkers - but who knows. Anyway, HoldForm is the cure, in case anyone else stumbles over this > issue. Jens === Subject: Re: user-defined function templates in Mathematica 7.0 This actually worked long before Version 7. JMJ > Mathematica 7.0 allows user-defined function templates to be easily creat= ed! > .....To define a function template for a user-defined function, make > the template the first statement in the usage message for the > function. For example, to define the template f[a,b] for the function > f, you could use the following command: f::usage=f[a,b] is an example > of a function. It works very well. > Happy templating! === Subject: Re: user-defined function templates in Mathematica 7.0 > Mathematica 7.0 allows user-defined function templates to be easily created! > .....To define a function template for a user-defined function, make > the template the first statement in the usage message for the > function. For example, to define the template f[a,b] for the function > f, you could use the following command: f::usage=f[a,b] is an example > of a function. It works very well. > Happy templating! Well, this new feature seems to have been introduced ages ago! At least since Mathematica 3 as far as I can remember correctly. Ever tried Shift+Ctrl+K (Shift+Cmd+K on Mac) to complete a command? The template that is displayed comes from this feature. Templates are also accessible from the Edit menu. --Jean-Marc === Subject: Re: Solving nonlinear coupled differential equations in Mathematica your equations are not a differential equation for z[x] because ode = {y''[x] == y[x] + z'[x], z[x]^3 == y'[x] + 3}; ode /. Solve[D[#, x] & /@ Last[ode], z'[x]][[1]] gives: {Derivative[2][y][x] == y[x] + Derivative[2][y][x]/(3*z[x]^2), z[x]^3 == 3 + Derivative[1][y][x]} that does not include z'[x] any more and more over z[x] is complete undetermined. Setting ode1 = ode /. Solve[D[#, x] & /@ Last[ode], z'[x]][[1]]; yodes= First /@ (ode1 /. Solve[Last[ode1], z[x]]) gives three possible equations for y[x] and NDSolve[ {#, y[1] == 2 , y[0] == 3}, y[x], {x, 0, 1}] & /@ yodes will solve it with some numerical error messages because I'm not able to to take the right solution for z[x] Jens > Here is a set of equations I would like to solve y''[x]==y+z'[x] > z[x]^3=y'[x]+3 With boundary conditions of y[1]==2 and y[0]==3 Using NDSolve on these equations, Mathematica says the order of the > equations is 3 and it has only 2 initial conditions. But the order of > this system of equations is 2 as far as I see (since order is defined > as the highest derivative) When I do try to put another boundary condition in like z[0]==0 > Mathematica spits out that it cant solve for the derivatives and is > using a mass matrix method (error:ntdvmm) and then it says that it has > significant errors (error:berr) and will return the best solution > found. Any help on this matter will be greatly appreciated. > === Subject: Re: printing symbols at as a table SetAttributes[PrintTable, HoldAll] PrintTable[syms_List] := Module[{s = Hold[syms]}, s = s /. sym_Symbol /; ValueQ[sym] :> HoldForm[sym]; Grid[ Transpose[{s[[1]], ReleaseHold[s[[1]]]}], Frame -> All ] ] and m = 1; g = 9.81; q = 2; PrintTable[{m, g, q}] will do it. Jens > HiI have done a long calculation. But now I want to print some > variables and their values. eg: r 20 > g 2.34 > s m^2 + D and so on .... > as a summary. The In /Out makes me crazy. I want to create a table of > all values. with the symbol on the left ath value on the right. some > are numeric ei i have assigned a r. Now i want to get the symbol > 'r'. I hope i am not confusing here. > === Subject: Re: File Corrupted In earlier versions corrupted notebooks were much more common, I haven't had a corrupted one since about version 5.1 or so (I hope this will not become a problem again with version 7). So I and others have had some unpleasant experience with fixing notebooks with a text editor and it is very cumbersome. > I have a long notebook, which I intended to use in my class starting > next week. I know it is probably too late for your class, but I still wanted to make a suggestion: Have you tried to open the notebook file with the 'Mathematica Source Editor' of the Wolfram Workbench? It is just a plain text editor, but it knows Mathematica syntax, so you can highlight a cell-expression by triple clicking on the corresponding Cell-Header. I think that would make it much more convenient to locate the corrupted cell than everything else I tried before. For a very large notebook you might want to turn off some of the features of this editor in the preferences, so the file will load faster. I have no corrupted notebook at this time and don't plan to create one, especially not a huge one :-), so probably others will want to comment how useful the workbench turns out to be for repairing notebooks in real life... Another suggestion would be to not let your notebooks grow too much, but to split the content to a bunch of notebooks and probably create a TOC-Notebook or Hyperlinks to switch between them. In the long turn that is not only safer but also more convenient since they will open, react and especially safe faster than a giant monster... hth, albert === Subject: Re: inverting Laplace transforms InverseLaplaceTransform[1/(s+Exp[-s]), s, t] Mathematica can't seem to do much at all in the way of inverse transforms, nothing more than Exp[-s] as far as I can find. === Subject: Re: Moving $UserBaseDirectory makes all paclets do not working > I just have moved $UserBaseDirectory to D:MATHEMATICA_USERBASE (by > using the MATHEMATICA_USERBASE operating system environment variable) > and, of course, I have copied all content of original > $UserBaseDirectory to new location: In[1]:= $UserBaseDirectory Out[1]= D:MATHEMATICA_USERBASE But as a result all paclets does not work: > In[2]:= ExampleData[{TestImage, Lena}] Import::nffil: File not found during Import. > Set::shape: Lists {DataPaclets`ExampleDataDump`Keys > [TestImage],DataPaclets`ExampleDataDump`Properties[TestImage]} and > $Failed are not the same shape. > Import::nffil: File not found during Import. > Set::shape: Lists {DataPaclets`ExampleDataDump`Keys > [TestImage],DataPaclets`ExampleDataDump`Properties[TestImage]} and > $Failed are not the same shape. > Import::nffil: File not found during Import. > General::stop: Further output of Import::nffil will be suppressed > during this calculation. > Set::shape: Lists {DataPaclets`ExampleDataDump`Keys > [TestImage],DataPaclets`ExampleDataDump`Properties[TestImage]} and > $Failed are not the same shape. > General::stop: Further output of Set::shape will be suppressed during > this calculation. >> > (Mathematica takes 100% CPU for a long time) How to solve this issue? I don't know, but my guess is that the 'cache' for the data paclets contains references to your old location. So what I would try is to delete everyting within the new 'Paclets' subdirectory (probably you want to just move it to see if it works). I would expect that this causes mathematica to download all data again when you use the Data-functions, but to create the 'cache' with correct references. Note: I have not tried if that really solves your problem, but think it is worth a try. If it really should work, let us know... hth, albert === Subject: Re: Moving $UserBaseDirectory makes all paclets do not working I just have moved $UserBaseDirectory to D:MATHEMATICA_USERBASE (by > using the MATHEMATICA_USERBASE operating system environment variable) > and, of course, I have copied all content of original > $UserBaseDirectory to new location: In[1]:= $UserBaseDirectory Out[1]= D:MATHEMATICA_USERBASE But as a result all paclets does not work: In[2]:= ExampleData[{TestImage, Lena}] Import::nffil: File not found during Import. > Set::shape: Lists {DataPaclets`ExampleDataDump`Keys > [TestImage],DataPaclets`ExampleDataDump`Properties[TestImage]} and > $Failed are not the same shape. > Import::nffil: File not found during Import. > Set::shape: Lists {DataPaclets`ExampleDataDump`Keys > [TestImage],DataPaclets`ExampleDataDump`Properties[TestImage]} and > $Failed are not the same shape. > Import::nffil: File not found during Import. > General::stop: Further output of Import::nffil will be suppressed > during this calculation. > Set::shape: Lists {DataPaclets`ExampleDataDump`Keys > [TestImage],DataPaclets`ExampleDataDump`Properties[TestImage]} and > $Failed are not the same shape. > General::stop: Further output of Set::shape will be suppressed during > this calculation. > > (Mathematica takes 100% CPU for a long time) How to solve this issue? I don't know, but my guess is that the 'cache' for the data paclets > contains references to your old location. So what I would try is to > delete everyting within the new 'Paclets' subdirectory (probably you > want to just move it to see if it works). I would expect that this > causes mathematica to download all data again when you use the > Data-functions, but to create the 'cache' with correct references. Note: I have not tried if that really solves your problem, but think it > is worth a try. If it really should work, let us know... hth, albert I have tried that you suggest. The result is recreating the Paclets directory and it's content. Nevertheless paclets still do not work. === Subject: Plot Lists of values from excel to mathematica Hello everybody I'd like to plot in mathematica one four columns data that i have in excel, how i can do that in mathematica? For example I have: 1 5 2 4 2 6 1 2 3 2 2 1 4 1 7 2 I'd like to have a plot wher on the x axis I have 1,2,3,4 and for the x=1 the point are at: 5,2,4; at x=2 the points are at 6,1,2 and so on. What is the simplest way to do that in mathematica? Dino === Subject: Solving the Quintic: Correction to x^5 + 20 x + 32 == 0 root example There is an error on one of the Solving the Quintic pages. It is necessary to change a minus sign to a plus sign to get a correct N[%] value -1.363962165089939` The change is marked below with the comment (*fixed*). The Solving the Quintic page in error is http://library.wolfram.com/examples/quintic/main.html The page shows the following: There are polynomials of degree greater than four which do not factor over the rationals, but that can still be solved in radicals. An example is the quintic: x^5 + 20 x + 32 == 0 one of whose roots is 1/5 (-(2500 Sqrt[5] + 250 Sqrt[50 - 10 Sqrt[5]] - 750 Sqrt[50 + 10 Sqrt[5]])^(1/5) - (-2500 Sqrt[5] + 750 Sqrt[50 - 10 Sqrt[5]] + 250 Sqrt[50 + 10 Sqrt[5]])^(1/5) +(*fixed*) (2500 Sqrt[5] + 750 Sqrt[50 - 10 Sqrt[5]] + 250 Sqrt[50 + 10 Sqrt[5]])^(1/5) - (2500 Sqrt[5] - 250 Sqrt[50 - 10 Sqrt[5]] + 750 Sqrt[50 + 10 Sqrt[5]])^(1/5)) The corrected result can be checked using: N[#^5 + 20 # + 32 == 0 &[%], 100] Can anyone who has the Solving the Quintic poster see if it is correct on there? All of the roots are given by evaluating this: Module[{prim1, prim2, prim3, prim4, r1, r2, r3, r4}, r1 = -(2500*5^(1/2) + 250* (50 - 10*5^(1/2))^(1/2) - 750 *(50 + 10*5^(1/2))^(1/2))^(1/5); r2 = (2500*5^(1/2) + 750 *(50 - 10*5^(1/2))^(1/2) + 250 *(50 + 10*5^(1/2))^(1/2))^(1/5); r3 = -(-2500*5^(1/2) + 750 *(50 - 10*5^(1/2))^(1/2) + 250* (50 + 10*5^(1/2))^(1/2))^(1/5); r4 = -(2500*5^(1/2) - 250* (50 - 10*5^(1/2))^(1/2) + 750 *(50 + 10*5^(1/2))^(1/2))^(1/5); prim1 = (-1 - 5^(1/2) + 2^(1/2)*I*(5 - 5^(1/2))^(1/2))/4; prim2 = (-1 + 5^(1/2) - 2^(1/2)*I*(5 + 5^(1/2))^(1/2))/4; prim3 = (-1 + 5^(1/2) + 2^(1/2)*I*(5 + 5^(1/2))^(1/2))/4; prim4 = (-1 - 5^(1/2) - 2^(1/2)*I*(5 - 5^(1/2))^(1/2))/4; {x -> #} & /@ ({{r1, r2, r3, r4}.{1, 1, 1, 1}, {r1, r2, r3, r4}.{prim2, prim4, prim1, prim3}, {r1, r2, r3, r4}.{prim3, prim1, prim4, prim2}, {r1, r2, r3, r4}.{prim1, prim2, prim3, prim4}, {r1, r2, r3, r4}.{prim4, prim3, prim2, prim1}}/5)] Check the roots using: N[Solve[x^5 + 20 x + 32 == 0, x], 100] == N[%, 100] The Solving the Quintic poster notebooks are available at http://library.wolfram.com/infocenter/TechNotes/158/ The Radical.nb notebook is what was used here. Change the simp function to do Expand[Simplify[%]] on its result and discard the Discriminant definition which is built into versions 6 & 7 to get the results in a form like what is shown here. Also change Solve::rad to SolveQuintic::rad in two places before evaluating all cells. Q.E.D. === Subject: Problem in generating a DO cycle (mathematica 6.0) Through these commands I acquire a bitmap image from a my folder and create a Graylevels file: Quit; SetDirectory[ C:Users...DatiBitmapxxx]; nome = p6a.bmp; Import[nome, ImageSize]; row = ToExpression[Import[nome, ImageSize]][[1]]; col = ToExpression[Import[nome, ImageSize]][[2]]; vmax = row*col; gv = Array[f, vmax]; gl = Import[nome, GrayLevels]; at this point I have a matrix with all graylevels. Now my problem is to create a two DO cycle (one for rows and one for columns) which allow me to generate an array (gv) whose elements are the product row x column of the matrix: gv[i] = gl [j,k] where: {i,1,Vmax} {j,1,row} {k,1,col} Can you pleasa herlp me to generate these Do Cycle? Vale === Subject: Re: Problems using MathLink Yes, you need to call delete[] for the dims array. you also not free the memory ! void rot(MLINK link, double theta) > { /* > Because the original function was only sending Heads of type List, > We can simply pass MLPutRealArray a NULL pointer for the heads > argument and MathLink will send the head List for each level of the > array. > */ double a[3][3]; > a[0][0] = cos(theta); a[0][1] = sin(theta); a[0][2] = 0; > a[1][0] = - sin(theta); a[1][1] = cos(theta); a[1][2] = 0; > a[2][0] = 0; a[2][1] = 0; a[2][2] = 1; long *dims, depth; /* > The array is only depth 2. The original version told MLPutRealArray > that > the data array 'a' had a depth of 3. MLPutRealArray tried to send > the extra dimension > which didn't actually exist which lead to the crash. > */ dims = new long[2]; > dims[0] = 3; dims[1] = 3; > MLPutRealArray(link, *a, dims, (char **)0, 2); /************************************************* > because otherwise, every call waste 32 byte of heap memory > ************************************************/ > delete[] dims; > } Jens > Here are the modifications that this function needs in order to >> work correctly: > void rot(MLINK link, double theta) >> { > /* >> Because the original function was only sending Heads of type List, >> We can simply pass MLPutRealArray a NULL pointer for the heads >> argument and MathLink will send the head List for each level of the >> array. >> */ > double a[3][3]; >> a[0][0] = cos(theta); >> a[0][1] = sin(theta); >> a[0][2] = 0; >> a[1][0] = - sin(theta); >> a[1][1] = cos(theta); >> a[1][2] = 0; >> a[2][0] = 0; >> a[2][1] = 0; >> a[2][2] = 1; > long *dims, depth; > /* >> The array is only depth 2. The original version told >> MLPutRealArray that >> the data array 'a' had a depth of 3. MLPutRealArray tried to send >> the extra dimension >> which didn't actually exist which lead to the crash. >> */ > dims = new long[2]; >> dims[0] = 3; >> dims[1] = 3; >> MLPutRealArray(link, *a, dims, (char **)0, 2); >> } > > Steve Wilson >> Senior Network/System Protocol Developer >> Wolfram Research, Inc. > > you are sure that your array has the depth 3 and not > the dimension 3 x 3, and what is the third dimension > in a[3][3] .. BTW, you never delete[] heads,dims. > If you wish to fill your main memory you should > use larger pieces of memory > that you don't recycle, you are faster done than. Jens > I'm trying to write a subroutine in C++ that passes a rotation >> matrix to >> Mathematica through MathLink. The code compiles fine, but when I >> try to run >> the compiled program, I get a segfault at the point in the >> program where the >> subroutine is called. As far as I can tell, the fault occurs >> whenever the >> program calls MLPutRealArray or MLPutReal32Array. > Here is my code for the subroutine: > void rot(MLINK link, double theta) >> { >> char **heads, **HEAD; >> heads = new char*[3]; >> heads[0] = List; >> heads[1] = List; >> heads[2] = List; >> double a[3][3], *b; >> a[0][0] = cos(theta); >> a[0][1] = sin(theta); >> a[0][2] = 0; >> a[1][0] = - sin(theta); >> a[1][1] = cos(theta); >> a[1][2] = 0; >> a[2][0] = 0; >> a[2][1] = 0; >> a[2][2] = 1; >> long *dims, *D, depth; >> dims = new long[3]; >> dims[0] = 3; >> dims[1] = 3; >> dims[2] = 3; >> MLPutRealArray(link, *a, dims, heads, 3); >> } > Is there something in this code that I'm missing that causes the >> fault? Or >> is this a but in the ml32i3.dll file? > Yours, > Johnathan Yik > === Subject: Re: Problems using MathLink you also not free the memory ! void rot(MLINK link, double theta) { /* Because the original function was only sending Heads of type List, We can simply pass MLPutRealArray a NULL pointer for the heads argument and MathLink will send the head List for each level of the array. */ double a[3][3]; a[0][0] = cos(theta); a[0][1] = sin(theta); a[0][2] = 0; a[1][0] = - sin(theta); a[1][1] = cos(theta); a[1][2] = 0; a[2][0] = 0; a[2][1] = 0; a[2][2] = 1; long *dims, depth; /* The array is only depth 2. The original version told MLPutRealArray that the data array 'a' had a depth of 3. MLPutRealArray tried to send the extra dimension which didn't actually exist which lead to the crash. */ dims = new long[2]; dims[0] = 3; dims[1] = 3; MLPutRealArray(link, *a, dims, (char **)0, 2); /************************************************* because otherwise, every call waste 32 byte of heap memory ************************************************/ delete[] dims; } Jens > Here are the modifications that this function needs in order to work > correctly: void rot(MLINK link, double theta) > { /* > Because the original function was only sending Heads of type List, > We can simply pass MLPutRealArray a NULL pointer for the heads > argument and MathLink will send the head List for each level of the > array. > */ double a[3][3]; > a[0][0] = cos(theta); > a[0][1] = sin(theta); > a[0][2] = 0; > a[1][0] = - sin(theta); > a[1][1] = cos(theta); > a[1][2] = 0; > a[2][0] = 0; > a[2][1] = 0; > a[2][2] = 1; long *dims, depth; /* > The array is only depth 2. The original version told MLPutRealArray that > the data array 'a' had a depth of 3. MLPutRealArray tried to send > the extra dimension > which didn't actually exist which lead to the crash. > */ dims = new long[2]; > dims[0] = 3; > dims[1] = 3; > MLPutRealArray(link, *a, dims, (char **)0, 2); > } > Steve Wilson > Senior Network/System Protocol Developer > Wolfram Research, Inc. > you are sure that your array has the depth 3 and not >> the dimension 3 x 3, and what is the third dimension >> in a[3][3] .. > BTW, you never delete[] heads,dims. >> If you wish to fill your main memory you should >> use larger pieces of memory >> that you don't recycle, you are faster done than. > Jens > > I'm trying to write a subroutine in C++ that passes a rotation > matrix to > Mathematica through MathLink. The code compiles fine, but when I > try to run > the compiled program, I get a segfault at the point in the program > where the > subroutine is called. As far as I can tell, the fault occurs > whenever the > program calls MLPutRealArray or MLPutReal32Array. Here is my code for the subroutine: void rot(MLINK link, double theta) > { > char **heads, **HEAD; > heads = new char*[3]; > heads[0] = List; > heads[1] = List; > heads[2] = List; > double a[3][3], *b; > a[0][0] = cos(theta); > a[0][1] = sin(theta); > a[0][2] = 0; > a[1][0] = - sin(theta); > a[1][1] = cos(theta); > a[1][2] = 0; > a[2][0] = 0; > a[2][1] = 0; > a[2][2] = 1; > long *dims, *D, depth; > dims = new long[3]; > dims[0] = 3; > dims[1] = 3; > dims[2] = 3; > MLPutRealArray(link, *a, dims, heads, 3); > } Is there something in this code that I'm missing that causes the > fault? Or > is this a but in the ml32i3.dll file? Yours, Johnathan Yik === Subject: Re: Problems using MathLink Here are the modifications that this function needs in order to work correctly: void rot(MLINK link, double theta) { /* Because the original function was only sending Heads of type List, We can simply pass MLPutRealArray a NULL pointer for the heads argument and MathLink will send the head List for each level of the array. */ double a[3][3]; a[0][0] = cos(theta); a[0][1] = sin(theta); a[0][2] = 0; a[1][0] = - sin(theta); a[1][1] = cos(theta); a[1][2] = 0; a[2][0] = 0; a[2][1] = 0; a[2][2] = 1; long *dims, depth; /* The array is only depth 2. The original version told MLPutRealArray that the data array 'a' had a depth of 3. MLPutRealArray tried to send the extra dimension which didn't actually exist which lead to the crash. */ dims = new long[2]; dims[0] = 3; dims[1] = 3; MLPutRealArray(link, *a, dims, (char **)0, 2); } Steve Wilson Senior Network/System Protocol Developer Wolfram Research, Inc. you are sure that your array has the depth 3 and not > the dimension 3 x 3, and what is the third dimension > in a[3][3] .. BTW, you never delete[] heads,dims. > If you wish to fill your main memory you should > use larger pieces of memory > that you don't recycle, you are faster done than. Jens > I'm trying to write a subroutine in C++ that passes a rotation >> matrix to >> Mathematica through MathLink. The code compiles fine, but when I >> try to run >> the compiled program, I get a segfault at the point in the program >> where the >> subroutine is called. As far as I can tell, the fault occurs >> whenever the >> program calls MLPutRealArray or MLPutReal32Array. > Here is my code for the subroutine: > void rot(MLINK link, double theta) >> { >> char **heads, **HEAD; >> heads = new char*[3]; >> heads[0] = List; >> heads[1] = List; >> heads[2] = List; >> double a[3][3], *b; >> a[0][0] = cos(theta); >> a[0][1] = sin(theta); >> a[0][2] = 0; >> a[1][0] = - sin(theta); >> a[1][1] = cos(theta); >> a[1][2] = 0; >> a[2][0] = 0; >> a[2][1] = 0; >> a[2][2] = 1; >> long *dims, *D, depth; >> dims = new long[3]; >> dims[0] = 3; >> dims[1] = 3; >> dims[2] = 3; >> MLPutRealArray(link, *a, dims, heads, 3); >> } > Is there something in this code that I'm missing that causes the >> fault? Or >> is this a but in the ml32i3.dll file? > Yours, > Johnathan Yik === Subject: Re: Problems using MathLink Since I posted to MathGroup I have discovered that the compiled program runs properly if I set the fourth argument in MLPutRealArray to NULL rather than using the values contained within the heads array. Presumably I have misunderstood how this argument works. If I understand your message, I should set the last argument of MLPutRealArray to 2 and declare dims to have length 2 rather than 3, with dims[0] and dims[1] both being 3. However, when I modified the code as stated above, the program was able to compile and run, but MLPutArray was not able to successfully pass the value, returning a value of 0. Calling MLErrorMessage only resulted in an Unknown Mathlink problem encountered message. Is there any reason why this is so? Yours, Johnathan Yik I'm trying to write a subroutine in C++ that passes a rotation matrix to > Mathematica through MathLink. The code compiles fine, but when I try t= > o run > the compiled program, I get a segfault at the point in the program where > = > the > subroutine is called. As far as I can tell, the fault occurs whenever = > the > program calls MLPutRealArray or MLPutReal32Array. Here is my code for the subroutine: void rot(MLINK link, double theta) > { > char **heads, **HEAD; > heads = new char*[3]; > heads[0] = List; > heads[1] = List; > heads[2] = List; > double a[3][3], *b; > a[0][0] = cos(theta); > a[0][1] = sin(theta); > a[0][2] = 0; > a[1][0] = - sin(theta); > a[1][1] = cos(theta); > a[1][2] = 0; > a[2][0] = 0; > a[2][1] = 0; > a[2][2] = 1; > long *dims, *D, depth; > dims = new long[3]; > dims[0] = 3; > dims[1] = 3; > dims[2] = 3; > MLPutRealArray(link, *a, dims, heads, 3); } Is there something in this code that I'm missing that causes the fault? = > Or > is this a but in the ml32i3.dll file? You have a 2-dimensional (3x3) array of real numbers, yet you're > telling MathLink that you have a 3-dimensional (3x3x3) array of real > numbers. MathLink attempts to read 27 real numbers when you only have > 9 allocated and the program crashes. -Rob === Subject: Re: Problems using MathLink you are sure that your array has the depth 3 and not the dimension 3 x 3, and what is the third dimension in a[3][3] .. BTW, you never delete[] heads,dims. If you wish to fill your main memory you should use larger pieces of memory that you don't recycle, you are faster done than. Jens I'm trying to write a subroutine in C++ that passes a rotation matrix to > Mathematica through MathLink. The code compiles fine, but when I try to run > the compiled program, I get a segfault at the point in the program where the > subroutine is called. As far as I can tell, the fault occurs whenever the > program calls MLPutRealArray or MLPutReal32Array. Here is my code for the subroutine: void rot(MLINK link, double theta) > { > char **heads, **HEAD; > heads = new char*[3]; > heads[0] = List; > heads[1] = List; > heads[2] = List; > double a[3][3], *b; > a[0][0] = cos(theta); > a[0][1] = sin(theta); > a[0][2] = 0; > a[1][0] = - sin(theta); > a[1][1] = cos(theta); > a[1][2] = 0; > a[2][0] = 0; > a[2][1] = 0; > a[2][2] = 1; > long *dims, *D, depth; > dims = new long[3]; > dims[0] = 3; > dims[1] = 3; > dims[2] = 3; > MLPutRealArray(link, *a, dims, heads, 3); > } Is there something in this code that I'm missing that causes the fault? Or > is this a but in the ml32i3.dll file? Yours, Johnathan Yik === Subject: Re: NEWBIE QUESTION - How to create a barchart with two data sets. >I am new to Mathematica and can't seem to figure out how to do a >simple bar chart using 2 data sets, in Excel you either have the >data in a series in rows or columns. Using version 7 of Mathematica, first generate two data sets by doing something like: dataSet1 = RandomReal[NormalDistribution[5, 1], 100]; dataSet2 = RandomReal[NormalDistribution[7, 1], 100]; then the bar chart (which I interpret to be a histogram) can be done as: Histogram[{dataSet1, dataSet2}] And if you truly do want bar charts rather than a histogram, simply replace Histogram with BarChart. Of course with random data as I've generated above, the plot produced by BarChart is meaningless. With either BarChart or Histogram, there are a variety of options available for controlling the appearance of the plot. See the documentation for details. === Subject: Re: Maximizing function which defines a routine >(Apologies up front for my utter lack of programming ability--the >only language Ive ever really programmed in is Basic and I havent >even done much of that) >I have a function G in two arguments (x,y) which uses a loop (Im >using label/goto for this loop if that gives any idea of my >programming abilities) to alter the values of three state >variables (a,b,c). The output of this function is to store the final >values of these three variables a,b,c, (globally). >Is it possible in Mathematica to use Maximize or NMaximize on this >function, in order to, for example, find the x which maximizes a >(given y)? The only answer possible to your question is that it depends on details of the function you have not posted. There is nothing about using loops as part of the function definition automatically prevents NMaximize from being successful. If you provide details of your function (preferably the Mathematica code that implements your function) I or another poster quite likely can help you. Now having said the above, I will also note efficient programming in Mathematica is quite different than programming in Basic. I do not believe there are any programs in Mathematica that would be considered efficient programs that use a label/goto construct. In fact, most efficient Mathematica programs do not use explicit loops. Additionally, using a loop to modify global variables is probably a bad idea. Usually, this causes problems when the same variables are used else where in a notebook. If you plan to use Mathematica quite a bit and want to become proficient in writing Mathematica code, there are a number of books that will give you a good place to start. For example, there are Maeder's books Programming in Mathematica and The Mathematica Programmer. I am sure others responding to your post can provide other recommendations. === Subject: Re: Solve / NSolve > Solve is a > *symbolic* solver, i.e. it manipulates the equations in essentially an > algebraic way (which does not mean that it does so in a similar fashion > as a human being would do). OTOH, NSolve uses *numeric* algorithms. > (Both sets of tools and algorithms have virtually nothing in common in > terms of strategies; roughly speaking, symbolic manipulations for the > former, iterative computations for the latter, for instance.) > It is a common misconception that Solve is algenriaic while NSolve uses > iterative computations (it generally does not, FindRoot does that), or > that the algorithms used by Solve and NSolve have nothing in common. Both > Solve and NSolve are primarily intended for solving algebraic equations. > They also have quite a lot in common. In fact, in when NSolve is given a > non-algebraic system it simply passes it to Solve and does not attempt to > solve it using iterative methods. For algebraic systems both Solve and > NSolve rely on Groebner basis, but while Solve uses exact Groeber basis > NSolve (at least with WorkingPrecision other than MachiePrecision) relies on > Mathematica's implementation of numerical GroebnerBasis > (GroebnerBasis[...,CoefficientDomain->InexactNumbers]), which in turns > relies on Mathematica's significance arithmetic. > To sum up, while Solve and NSolve usually (but not always) use different > algorithms, they are both essentially algebraic solvers. In fact NSolve is > more pure algebraic solver since it won't even touch non-algebraic > equations passing them to Solve to try its luck on them (which is usually > lacking). Andrzej, not bother to check the documentation about the actual methods used by NSolve and just quickly write the reply trusting my memory. --Jean-Marc === Subject: Re: Solve / NSolve > Solve is a > *symbolic* solver, i.e. it manipulates the equations in > essentially an > algebraic way (which does not mean that it does so in a similar > fashion > as a human being would do). OTOH, NSolve uses *numeric* algorithms. > (Both sets of tools and algorithms have virtually nothing in > common in > terms of strategies; roughly speaking, symbolic manipulations for > the > former, iterative computations for the latter, for instance.) > It is a common misconception that Solve is algenriaic while > NSolve uses iterative computations (it generally does not, > FindRoot does that), or that the algorithms used by Solve and NSolve > have nothing in common. Both Solve and NSolve are primarily > intended for solving algebraic equations. They also have quite a lot > in common. In fact, in when NSolve is given a non-algebraic system > it simply passes it to Solve and does not attempt to solve it using > iterative methods. For algebraic systems both Solve and NSolve rely > on Groebner basis, but while Solve uses exact Groeber basis NSolve > (at least with WorkingPrecision other than MachiePrecision) relies > on Mathematica's implementation of numerical GroebnerBasis > (GroebnerBasis[...,CoefficientDomain->InexactNumbers]), which in > turns relies on Mathematica's significance arithmetic. > To sum up, while Solve and NSolve usually (but not always) use > different algorithms, they are both essentially algebraic solvers. > In fact NSolve is more pure algebraic solver since it won't even > touch non-algebraic equations passing them to Solve to try its luck > on them (which is usually lacking). Andrzej Kozlowski I guess, the statement that NSolve generally does not use iterative methods was a bit unclear. More accurately, for a single univariate polynomial equations NSolve uses the Jenkins-Traub algorithm (as do most other CAS), which is iterative. For general polynomial systems, however, numerical Groebner basis is used, which ultimately leads to solving a univariate polynomial equation, which of course, uses an iterative method. So in this sense Jean-Marc was correct. However, the Jenkins-Traub method, even though iterative, unlike the Newton-Raphson method does not perform any differentiation, hence it can be considered algebraic. Compare this with FindRoot, which uses the Newton-Raphson and works with any sufficiently smooth functions, not necessarily algebraic ones. Andrzej Kozlowski === Subject: Re: Solve / NSolve >> Solve is a >> *symbolic* solver, i.e. it manipulates the equations in essentially >> an >> algebraic way (which does not mean that it does so in a similar >> fashion >> as a human being would do). OTOH, NSolve uses *numeric* algorithms. >> (Both sets of tools and algorithms have virtually nothing in common >> in >> terms of strategies; roughly speaking, symbolic manipulations for the >> former, iterative computations for the latter, for instance.) It is a common misconception that Solve is algenriaic while NSolve uses iterative computations (it generally does not, FindRoot does that), or that the algorithms used by Solve and NSolve have nothing in common. Both Solve and NSolve are primarily intended for solving algebraic equations. They also have quite a lot in common. In fact, in when NSolve is given a non-algebraic system it simply passes it to Solve and does not attempt to solve it using iterative methods. For algebraic systems both Solve and NSolve rely on Groebner basis, but while Solve uses exact Groeber basis NSolve (at least with WorkingPrecision other than MachinePrecision) relies on Mathematica's implementation of numerical GroebnerBasis (GroebnerBasis[...,CoefficientDomain->InexactNumbers]), which in turns relies on Mathematica's significance arithmetic. To sum up, while Solve and NSolve usually (but not always) use different algorithms, they are both essentially algebraic solvers. In fact NSolve is more pure algebraic solver since it won't even touch non-algebraic equations passing them to Solve to try its luck on them (which is usually lacking). Andrzej Kozlowski === Subject: Re: Solve / NSolve > Well, as the subject tells you I have an issue with Solve / NSolve. > Instead of describing more in words I will ask you to evaluate the > cells below. The plot you see there is what I expect to get; it is > also correct. Now change NSolve to Solve in the line huygTemp. Don't > you see a different plot now? Also the solution takes less time to > compute, right? Could anyone explain to me this behaviour? Or at least > try to explain it? Why does NSolve take so much more time to find a > solution? And why is Solve finding the wrong one? Any suggestions on > how to improve the huygTemp function (speedwise) are also welcome. > Perhaps I should say that I'm using the following version of > Mathematica: 6.0 for Sun Solaris SPARC (64-bit) (April 20, 2007). Note that some function definition(s) are missing. Nevertheless, keep in mind that Solve and NSolve do not use the same algorithms. Solve is a *symbolic* solver, i.e. it manipulates the equations in essentially an algebraic way (which does not mean that it does so in a similar fashion as a human being would do). OTOH, NSolve uses *numeric* algorithms. (Both sets of tools and algorithms have virtually nothing in common in terms of strategies; roughly speaking, symbolic manipulations for the former, iterative computations for the latter, for instance.) Now, Solve returns: 1. General symbolic solutions that hold in most cases but not necessarily all cases: specific cases are ignored or not checked; for instance whether the coefficient 'a' is different from zero in the quadratic equation a*x^2 + b*x + c == 0. 2. Solutions may be not optimized for numeric computations. For instance, a polynomial or rational expression in Horner form, say c + x (b + a x) for the above quadratic, is much more stable numerically speaking and less prone to round off error. Also, do not forget that Solve, NSolve, and the like, are *high level* functions, meaning that they do not implement just one algorithms but dozen of them and contains code that analyses equations and monitors intermediate results and automatically decides what is the best course of action and what algorithm to use and/or switch to. Finally, rather than Solve, you may want to give Reduce a try. --Jean-Marc === Subject: Re: Solve / NSolve >> I[...] >> Note that some function definition(s) are missing. Nevertheless, keep in >> mind that Solve and NSolve do not use the same algorithms. Solve is a >> *symbolic* solver, i.e. it manipulates the equations in essentially an >> algebraic way (which does not mean that it does so in a similar fashion >> as a human being would do). OTOH, NSolve uses *numeric* algorithms. >> (Both sets of tools and algorithms have virtually nothing in common in >> terms of strategies; roughly speaking, symbolic manipulations for the >> former, iterative computations for the latter, for instance.) Not really. http://forums.wolfram.com/mathgroup/archive/2008/Apr/msg00144.html Well, I stand corrected! I replied too quickly, not bothering to check the accuracy of my examples. Sorry for any confusion this might have brought. --Jean-Marc === Subject: Info about Ito's package from Mark Fisher Hello I just downloaded the Ito's package implemented by M.Fiusher I found in Wolfram website. Is there anyone who already applied this package to define the Ito formula to a multi-asset options I mean: instead of considering a simple SDE -> dS=S*mu*dt+S*sigma*dW we consider -> dS_i=mu_i*S_i*dt+sigma_i*dt*sW_i where Correlation(d ln(S_i),d ln(S_j)) * dt=dW_i*dW_j=Corr_j,j dt P === Subject: Re: Components of InterpolatingFunction > How does one see (print, display) the piecewise polynomials that are > inside an InterpolatingFunction object? I.e. both the domains and the > polynomials themselves that InterpolatingFunction is broken into. AFAIK, there does not exist any direct (built-in) way of getting the expressions for the polynomials used by InterpolatingFunction objects. However, *InterpolatingPolynomial* constructs explicitly a polynomial/rational expression for a given set of points. You will find below an example, from the section Properties & Relations from the online documentation for InterpolatingFunction, that shows how to get explicit formulae for the polynomials. In[1]:= points = {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}; ifun = Interpolation[points]; pf[x_] = Piecewise[{ {InterpolatingPolynomial[{{0, 0}, {1, 1}, {2, 3}, {3, 4}}, x], x < 2}, {InterpolatingPolynomial[{{1, 1}, {2, 3}, {3, 4}, {4, 3}}, x], 2 <= x < 3}, {InterpolatingPolynomial[{{2, 3}, {3, 4}, {4, 3}, {5, 0}}, x], x >= 3} }] Plot[pf[x] - ifun[x], {x, 0, 5}, PlotRange -> All] Out[2]= 1 2 - x Piecewise[{{(1 + (- + -----) (-1 + x)) x, x < 2}, 2 3 1 3 - x {1 + (2 + (-(-) + -----) (-2 + x)) (-1 + x), 2 <= x < 3}, 2 6 {3 + (4 - x) (-2 + x), x >= 3}}] --Jean-Marc === Subject: Mathematica and Access I have to manage an huge database in Microsoft Access format. I'm trying to do the job using Mathematica because hard computational work is involved, but I'm unable to find the right way using Mathematca's help only. Therefore, I export data from .MDB file in a TSV formatted one, precess them, import data in .MDB file again. No doubt, it's a repetitive, slow, tedious method; I would love modify data (as an example, decrease by 10% prices of all books having been hanging for more than an year) directly within Mathematica Front End (or by means of a Kernel batch call). Please can you suggest if it is feasible and, possibly point out a tutorial about that ? Does anyone got a try before ? Best Regard Ignacio === Subject: Re: passing initial point to LinearProgramming Hi Slava, LinearProgramming is a minimization problem, Therefore, a numerical minimum finder like e.g. FindMinimum that takes a starting point could be used. However, as these functions are for more general problems than linear ones, it is not clear if the calculation time is reduced. You would have to try this out. hope this helps, Daniel > I have to solve a series of nearby Linear Programming problems (a few > hundreds to a few thousand constraints and variables). It is known that for nearby problems using the solution of one problem > as a starting point for the other can get a considerable speedup for > Symplex Method. However, as far as I can see, LinearProgramming[] function does not > allow specification of a starting point. Is there (perhaps a > non-documented) workaround? === Subject: Taking LCM in a polynomial expression Hi I have a symbolic matrix that I invert. When I take each individual entry of the resulting matrix, I get an expression of the form: num1/den1 + num2/den1 + .... + num_n/den1 where den1 is the determinant of the matrix. I'd like to get an expression of the form: Num/Den. I tried using Simplify (as well as multiplying the matrix by its determinant), but it doesn't seem to help. Any suggestions? On a related note, the final Num is a polynomial in two variables - say x,y. I'd like to arrange it in decreasing powers of x - like f1(y) x^n + f2(y) x^n-1... + constant. What function should use? Is there any way to both in a single step? Srikanth === Subject: Re: Is this so hard? When you do In[125]:= DSolve[{x''[t] == 1/x[t]^2}, x, t] Out[125]= Solve[(Log[-2 + 2 (C[1] + Sqrt[C[1]] Sqrt[C[1] - 2/x[t]]) x[t]]/C[1]^(3/2) + ( Sqrt[C[1] - 2/x[t]] x[t])/C[1])^2 == (t + C[2])^2, x[t]] So the general solution is in implicit form like error message saying. But you could get the numerical solution using NDSolve: In[123]:= NDSolve[{x''[t]==1/x[t]^2,x[0]==-1,x'[0]==0},x,{t,0,1}] Out[123]= {{x->InterpolatingFunction[{{0.,1.}},<>]}} === Subject: Re: Solving nonlinear coupled differential equations in Mathematica > Here is a set of equations I would like to solve y''[x]==y+z'[x] > z[x]^3=y'[x]+3 With boundary conditions of y[1]==2 and y[0]==3 Using NDSolve on these equations, Mathematica says > the order of the > equations is 3 and it has only 2 initial conditions. > But the order of > this system of equations is 2 as far as I see (since > order is defined > as the highest derivative) When I do try to put another boundary condition in > like z[0]==0 > Mathematica spits out that it cant solve for the > derivatives and is > using a mass matrix method (error:ntdvmm) and then it > says that it has > significant errors (error:berr) and will return the > best solution > found. Any help on this matter will be greatly appreciated. > z^3 = y' + 3 -> 3*z^2*z' = y'' Inserting in the first equation gives 3*z^2*z' = y + z' or z'=y/(3*z^2-1) So you should solve the following two equations (I) z'=y/(3*z^2-1) (II) y'=z^3-3 with appropriate boundary conditions. === Subject: Re: Problems using MathLink I've looked at the code for the file that calls the subroutine, and it appears that I have been attempting to pass the array to a loopback link, though I am not sure if this would indeed cause the problem or not. Changing the link to a direct link to the Mathematica kernel appears to raise another problem, as the program appears to just sit there without appear specific to my program, as my attempts to run the quotient program from the examples also resulted in the program sitting dead without taking further action. Here is the code for the program that calls the subroutine. I have been compiling the code in cygwin using g++: #include #include #include #include mathlink.h #include fields.h using namespace std; int main(int argc, char **argv) { int error, n, k; const char *a, *b; MLENV ep; MLINK lp, func; ep = MLInitialize(0); lp = MLOpenArgcArgv(ep, argc, argv, &error); rot(lp, 1.0); MLEndPacket(lp); MLPutFunction(lp, Exit, 0); MLClose(lp); MLDeinitialize(ep); cout << MLError(func) << n << MLErrorMessage(func) << endl; return 0; } > Very strange. Nothing else stands out to me as being wrong. I don't know > what to tell you. If you want to send the full code I can try to look at it when I get the > chance. Yes, MLPutInteger works, but MLPutRealArray doesn't. MLPutIntegerArray > also works, but for some reason, I can't get MLPutRealArray to work right. Yours, Johnathan Yik > Since I posted to MathGroup I have discovered that the compiled program > runs properly if I set the fourth argument in MLPutRealArray to NULL rather > than using the values contained within the heads array. Presumably I have > misunderstood how this argument works. > This argument is optional. If the heads are all List then you can safely >> pass NULL. I don't see any reason why the old code wouldn't have worked >> though. > If I understand your message, I should set the last argument of > MLPutRealArray to 2 and declare dims to have length 2 rather than 3, with > dims[0] and dims[1] both being 3. > Correct. > However, when I modified the code as stated above, the program was able > to compile and run, but MLPutArray was not able to successfully pass the > value, returning a value of 0. Calling MLErrorMessage only resulted in an > Unknown Mathlink problem encountered message. Is there any reason why this is so? > I think that should work. Is the link in the proper state to receive the >> array? If you replace the MLPutRealArray(...) call with MLPutInteger(link, >> 0) does that succeed? > Rob Raguet-Schofield > (rob ra gA skO fEld) === Entering ?[P*] gives a formated reference list of all Special Character names such as [Pi] which match. ?[*Phi] matches [CapitalPhi], [CurlyPhi] and [Phi]. This capability is new for version 7. It is not mentioned on the reference page for the Information function. This is better than having to search thru the reference page guide/ListingOfNamedCharacters which only lists 884 of the 947 that [*] reports. Evaluate following input to see the 63 which are not documented on the reference page guide/ListingOfNamedCharacters. Information[[ <> # <> ]] & /@ {Akuz, Andy, CapitalOE, Check*Box, COMPATIBILITY*, Divides, DoubleDot, KeyBar, Klingon*, Minus, Mod*Key, NumberComma, OE, ShiftKey, Short*, Spooky, Stepper*, TripleDot, UnknownGlyph, Villa}; Note that some are infix operators with built-in evaluation rules: m [Divides] n is by default interpreted as Divisible[n,m]. x [ShortDownArrow] y is by default interpreted as ShortDownArrow[x,y]. x [ShortUpArrow] y is by default interpreted as ShortUpArrow[x,y]. Just six, [CheckedBox], [Divides], [DoubleDot], [ShortDownArrow], [ShortUpArrow] and [TripleDot] have ref/Characters/ reference pages. Only [CapitalOE], [Minus] and [OE] are new in version 7. Of the documented ones, [DifferenceDelta], [DiscreteRatio], [DiscreteShift], [Equivalent], [Formal*](A-Z), [FormalCapital*](A-Z), [Function*] and [Xnor] are new in version 7. According to the ref/Characters/ reference pages the [Formal*] special character are used to represent a formal parameter that will never be assigned a value. The others are prefix or infix operators with built-in evaluation rules: !(*SubscriptBox[([DiscreteRatio]),(k)]y) is by default interpreted as DiscreteRatio[y,k]. !(*SubscriptBox[([DifferenceDelta]),(k)]y) is by default interpreted as DifferenceDelta[y,k]. !(*SubscriptBox[([DiscreteShift]),(k)]y) is by default interpreted as DiscreteShift[y,k]. x [Equivalent] y is by default interpreted as Equivalent[x,y]. x [Xnor] y is by default interpreted as Xnor[x,y]. x [Function] y is by default interpreted as Function[x,y]. Q.E.D. === Subject: User Defined Global Variables - How to do it? I am trying to define my own global variables which will be known to every function that I write just like the system global variable $HomeDirectory. I have a function which has been written to read values from a disk file and using those values calculate the values of the global variables. I do not know where to put this fuhction so that, at the begiinning of a Mathematica session, these user defined global varialbes are available to be used by any function that I have written that is part of the packages that are autmatically loaded at the beginning of a session. I have previously defined my own global variables in a file called init.m and this file is located in directory: C:Documents and SettingsDonaldApplication DataMathematicaAutoloadFoo (I have created the last directory Foo off of Autoload.) This method works for global variables that are defined by a simple assignment statement within the file init.m: globalVarA = value Every function that I have written and put into a package - and these packages are loaded *** automatically *** at the beginning of a Mathematica session - can use and knows the value of globalVarA which is defined in init.m. So, before the packages are loaded at the first time I hit Shift + Enter the system already knows the value of globalVarA because it was defined in the init.m file. I now need global variables that cannot be defined so easily by a simple assignment statement. Their values have to be read in and calculated in some function that I call. The sole purpose of this function is to read in and calculate the values of these global variables. There are two problems: (1) I don't know how to make these values globally available to all other functions that are used in the session and that are defined in the packages I created. (2) I don't know how to get this function [the function which calculates the values of the global variables) to start up automatically BEFORE I ever have to hit the first Shift + Enter. This function which calculaes the values of global variables uses itself some of the other functions I defined in the packages I created which are automatically loaded at session start time. For instance, below is the schematic defintion of a function where I am calculating the values of two global variables, globalVarB and globalVarC that I want every other function to have access to [access to the values in these global variables] if they need the values of these two variables in their own calculations, just like every function has access to the system global variable $HomeDirectory. globalDefintions[] := Module[{}, (* Read in values and do calculations for globalVarB and globalVarC ) Return[{globalVarB, globalVarC}] ];(* End Module globalDefinitions *) Then the function is invoked: {globalVarB, globalVarC} = globalDefinitions[]; Where can I put the definition of this function called globalDefintions and its invocation so that: (1) the user does not have to explicity invoke the globalDefinition function at the beginning of every Mathematica session (2) every function in any package that I write should know the values I have tried putting the above defintion of the globalDefinition function in the init.m file and then calling this function from within the init.m file, but that doesn't work. I have tried the same thing by putting the globalDefinition function in the Private and Public sections of a package that I have written (which, as stated above, is automatically loaded at the beginning of every session) and invoked the function within the package - also in a the private and public sections of the package (in a cell in the package that is an initialization cell) but that does not work either. Are there any solutions? === Subject: Re: Mathematica 7 on an Asus Eee PC Laptop? I was using Mathematica on a laptop, teaching at the University of Texas over 7 years ago. I'm sure you'll have no problem today. (Other than the usual. STUDENTS.) Bobby > Has anyone tried running Mathematica 7 on an Asus Eee PC Laptop under >> Linux? > hi, I have a eeePC900 with eeebuntu (the last one), and Mathematica >> run perfectly... Hi Andrea, Just out of curiosity, have you run the benchmarks that come with > Mathematica on the netbook? If so, could you, please, report the results > and perhaps write a line or two about your overall experience with the > system. I am asking because I was wondering whether a netbook + a CAS > (commercial or open source) could be a suitable replacement of a laptop > in classroom setting (e.g. doing interactive presentations with some > real-time computations or plots of simple expressions or models). --Jean-Marc > -- DrMajorBob@longhorns.com === Subject: Torus radii & Meshes Hi everybody! I am trying to make a 3D plot of a torus highlighting its circular sections. Now, I am not that trained with Mathematica, and all I've succeeded in doing is to get the vertical section. I still miss the horizontal one: ParametricPlot3D[ { {(3 + Cos[v]) Sin[u], (3 + Cos[v]) Cos[u], 4 + Sin[v]} }, {u, 0, 2 Pi}, {v, 0, 2 Pi}, MeshFunctions -> {#4 &}, Mesh -> {{{3 Pi/4, Directive[Red, Thick]}}}, PlotStyle -> {Green, Opacity[0.5]}] Another question. Is mathematica able to manipulate meshes? I mean, I know I can import and plot 3D models (STL, Maya, and so on), but what if I want to manipulate that data, getting adjacency matrices and other information? Is there a tutorial on this issue? Franco === Subject: Finding a sine wave An experiment will give me three coordinates which lie on a sine wave. I have to find the sine wave efficiently. There are three unknowns the sine wave amplitude, A, the wavelength of the sine wave, L, and the phase, ph. I also know that the wavelength is larger than the interval containing my measurement points. I think this condition removes possible multiple solutions. Below I give two methods which need improving. The first method uses FindRoot. This methods works about 60% of the time. I give six examples where it fails. The failure may be due to poor initial guesses. In the second method I use FindFit. This is not quite the correct method because I have an equal number of equations and unknowns. Some of the failures here, I think, are due to there being no error for the algorithm to work with. I give examples of failures. I have also tried FindInstance, Reduce and NSolve but I don't think these are appropriate. Here are some questions 1. I would really like a symbolic solution rather than an iterative one. Is such a solution possible? 2. Can anyone improve on the methods below to make them more robust? 3. I have some control over my x-locations. How can I work out best x locations given an estimate of the wavelength L? xx = Sort[Join[{0}, RandomReal[{0, 10}, 2]]] yy = RandomReal[{-25, 25}, 3] sol = FindRoot[{yy[[1]] - A*Sin[ph], yy[[2]] - A*Sin[2*Pi*(xx[[2]]/L) + ph], yy[[3]] - A*Sin[2*Pi*(xx[[3]]/L) + ph]}, {{A, Max[Abs[yy]]}, {L, Max[xx]}, {ph, 0}}] Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, Epilog -> {PointSize[0.02], (Point[#1] & ) /@ Transpose[{xx, yy}]}, PlotRange -> {{0, 10}, {-25, 25}}] FindRootFailures = {{{0, 3.781264462608982, 3.797055100562352}, {-22.948348087068737, 1.4581744078038472, -14.242676740704574}}, {{0, 4.424069570670131, 8.861716396743098}, {-6.444538773775843, -10.787309362608688, 15.579334094330942}}, {{0, 4.424069570670131, 8.861716396743098}, {-5.944536471563289, 10.627536107497393, -21.294232497202316}}, {{0, 1.3680556047878967, 8.546115267250002}, {4.128528863849845, 2.9017293848933923, -22.51610539815371}}, {{0, 1.3738869718371616, 5.689309423462079}, {20.553993773523437, -16.972841620064592, 16.61185061676568}}, {{0, 1.0408828831133632, 8.484645515699821}, {-3.7267589861478045, 4.1016610850387, -24.600635061804443}}}; (({xx, yy} = #1; sol = FindRoot[{yy[[1]] - A*Sin[ph], yy[[2]] - A*Sin[2*Pi*(xx[[2]]/L) + ph], yy[[3]] - A*Sin[2*Pi*(xx[[3]]/L) + ph]}, {{A, Max[Abs[yy]]}, {L, Max[xx]}, {ph, 0}}]; Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, Epilog -> {PointSize[0.02], (Point[#1] & ) /@ Transpose[{xx, yy}]}, PlotRange -> {{0, 10}, {-25, 25}}]) & ) /@ FindRootFailures xx = Sort[Join[{0}, RandomReal[{0, 10}, 2]]] yy = RandomReal[{-25, 25}, 3] sol = FindFit[ Transpose[{xx, yy}], {A*Sin[2*Pi*(x/L) + ph], Max[Abs[xx]] < L}, {A, L, ph}, x] Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, Epilog -> {PointSize[0.02], (Point[#1] & ) /@ Transpose[{xx, yy}]}, PlotRange -> {{0, 10}, {-25, 25}}] FindFitFailures = {{{0, 2.463263668380835, 4.3190892163093615}, {-1.8407827676541144, -8.736574079785198, 12.661520984622932}}, {{0, 3.894521446091823, 9.937403619870642}, {12.381369822165155, 15.840399165432128, -6.914634137727327}}, {{0, 8.087369725271945, 8.343899312282815}, {24.73795103895976, -13.396248713970305, 7.150470311065216}}, {{0, 1.5480031866178834, 9.575255260205617}, {-8.163720246784278, 13.373468882892958, -18.018462091502098}}, {{0, 0.6152784485896601, 0.818296772602134}, {-1.858698140836046, 3.695113783904491, -1.3186989232026658}}, {{0, 4.743093154057316, 6.028314583406327}, {-16.60893277597446, -17.413392198343093, -18.54081837965986}}}; (({xx, yy} = #1; sol = FindFit[ Transpose[{xx, yy}], {A*Sin[2*Pi*(x/L) + ph], Max[Abs[xx]] < L}, {A, L, ph}, x]; Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, Epilog -> {PointSize[0.02], (Point[#1] & ) /@ Transpose[{xx, yy}]}, PlotRange -> {{0, 10}, {-25, 25}}]) & ) /@ FindFitFailures === Subject: Re: Newbie: Howjavascript:; to Draw the 2-dimensional feasible set I have an optimization problem (2 decision variables x1=2C x2). I would like to know how to obtain a graph (with Mathematica) representing its feasible set. The feasible set is the union of two polyhedra. Pratim === Subject: webMathematica - comments, opinions, user group (?) I'm interested in what people know on the scoop for comments and opinions on webMathematica. Also, does anyone know if there is a user group? The basis of my question is as follows. I have been using the product for about 6 months now, and I'm getting a lot of high mileage out of and give it a 5-star rating. Nevertheless, it's based on Mathematica V5.2 (i.e., the webMathematica product from Wolfram does not support a higher version), and the new webMathematica that should support higher versions now seems several years delayed. Do I make the correct inference that webMathematica did not turn out to have as wide an appeal as Wolfram had hoped for and that it is almost in the category of discontinued product? Or on the flip side is there a vibrant community out there that I can join? Google hits seem to turn up only the Wolfram site, again leading to my inference that the product did not turn out in the success category for Wolfram. Does anyone know why? Any more comments, opinions, or knowledge on the history and context of webMathematica? -Scot Martin === Subject: ntdvmm error Hi Im trying to solve two coupled nonlinear differential equations using the shooting method (see variables A and B). The file is can be downloaded at http://web.mit.edu/~shahriar/Public/submission.nb When I run it I keep getting the error NDSolve::ntdvmm: Cannot solve to find an explicit formula for the derivatives. NDSolve will try solving the system using a mass matrix method. >> and then Mathematica hangs and doesnt do anything. If I change Hz->0 for T, Mathematica solves it properly but it doesnt seem to like it when Hz is nonzero. Any help on getting past this error will be greatly appreciated S === Subject: Re: Solve / NSolve between Solve and NSolve. Have any of you tried to run the code i provided (including the missing function definition which I provided later)? I'm aware that Solve and NSolve do not use the same algorithm to solve an equation, but it does not seem logical to me that they don't give the same solution to the same system of algebraic equations. What could be the reason for this? I'm also concerned witht he speed. Solve is much faster than NSolve for my problem. How come? In addition to the code I provided earlier, I just tried with another example of a system of two algebraic equations: {1.1 x^2 + y^2 == 1.0, x + 1.1 y == 0.0} Solve[%, {x, y}] // Timing NSolve[%%, {x, y}] // Timing When evaluating this cell you'll see that Solve is substantially faster than NSolve, but they yield the same solution. However, in my first example they do not yield the same solution in all cases. Hopefully some of you can shed some light on all this. It could also be me comparing apples and oranges. Let me hear your thoughts on all this. Sigmund === Although Mathematica 7 is a very powerful peace of software as far as the computational part goes it turns out to be quite limited and unstable when it comes to word editing and processing, despite the claims in the help that it is almost as powerful as WinWord. For example it crashed multiple times on me while I was trying to setup the right fonts and sizes, as a result I lost all my work several times, it also messed up my fonts, sizes, styles, settings for the equations, its undo is totally useless and I couldn't figure out how to format a text and a graphic in two or more columns and display them side by side in a notebook as well as how to control what goes on what page and while printing to PDF often it wouldn't print all pages, but just the first 2-3. All that said I'm wondering what program to use to write my work in, and I'm asking for advice - is WinWord any better when it comes to handling equations? Any other choices? What is the best way to export Mathematica 7 equations and graphics? === Subject: Intermediate computational results I have a mathematical expression and I have to demonstrate a real world example - an actual computation using the formula. For that purpose I'd like to show all intermediate steps, not just the final result. Is there a way to tell Mathematica to do one step at a time and not just show the final result? For example A=B+CD B=10 C=11 D=12 A=10+11x12=10+132=142 In other words I wouldn't like to type in all the equations with the exact numerical values. === Subject: Mathematica Player Pro 7 now available Mathematica Player Pro 7, the professional platform for running interactive Mathematica applications and documents, is now available! Based on Mathematica 7 technology, this new version comes with the same built-in technology to parallelize computations over multiple cores. It also supports other application areas introduced in Mathematica 7--including image processing and on-demand curated data--while retaining all the features and compatibility of the original Mathematica Player Pro. Player Pro marries convenient deployment with Mathematica's computation and rapid application development environment--an ideal combination for workgroups, consulting teams, researchers, commercial application builders, and others looking to roll out dynamic solutions, whether to clients or across their own organizations. For more information about Player Pro and Mathematica's complete deployment options, visit: http://www.wolfram.com/interactivedeployment NOTE: All current Mathematica 7 Premier Service customers are eligible to receive three complimentary copies of Player Pro for distribution. To request your copies, go to http://www.wolfram.com/premiersupport/playerpro === Subject: Re: Taking LCM in a polynomial expression Hi Srikanth, the magic word to get a common denominator is: Together. E.g.: Together[num1/den1 + num2/den1] The second question is tougher. Mathematica orders increasingly by default. You therefore have to prevent this by e.g. HoldForm. Try: a2 x^2 + a1 x + a0 and HoldForm[a2 x^2 + a1 x + a0] Next question is how to get the polynomial inside HoldForm. Assume p=a0 + a1 x + a2 x^2 a polynomial in default ordering. We may get its coefficients with CoefficientList. The function Reverse reverses the coefficients list cof=Reverse@CoefficientList[p, x] the powers of x in our ordering: pow=Table[x^i, {i, 2, 0, -1}] The polynomial term in a list: pol= cof pow Now we insert pol into HoldForm by substitution and change List into Plus: HoldForm[dummy]/.dummy->pol /. List->Plus All together: p=a0 + a1 x + a2 x^2; cof=Reverse@CoefficientList[p, x]; pow=Table[x^i, {i, 2, 0, -1}]; pol= cof pow; HoldForm[dummy]/.dummy->pol /. List->Plus this gives: a2 x^2+a1 x+a0 hope this helps, Daniel > Hi > I have a symbolic matrix that I invert. When I take each individual > entry of the resulting matrix, I get an expression of the form: > num1/den1 + num2/den1 + .... + num_n/den1 > where den1 is the determinant of the matrix. I'd like to get an > expression of the form: > Num/Den. I tried using Simplify (as well as multiplying the matrix by its > determinant), but it doesn't seem to help. Any suggestions? On a related note, the final Num is a polynomial in two variables - > say x,y. I'd like to arrange it in decreasing powers of x - like f1(y) > x^n + f2(y) x^n-1... + constant. What function should use? Is there > any way to both in a single step? Srikanth > === Subject: Re: Taking LCM in a polynomial expression >Hi I have a symbolic matrix that I invert. When I take each >individual entry of the resulting matrix, I get an expression of the >form: num1/den1 + num2/den1 + .... + num_n/den1 where den1 is the >determinant of the matrix. I'd like to get an expression of the >form: Num/Den. Use Together. For example, In[2]:= expr = Plus @@ Table[n/x^n, {n, 3}] Out[2]= 3/x^3+2/x^2+1/x In[5]:= Together[expr] // TraditionalForm Out[5]//TraditionalForm= (x^2+2 x+3)/x^3 === Subject: Import MDB Version 7 on Vista according to Wolfram Mathematica should be able to read an Access database. The first example from the manual: Import[ ExampleData/buildings.mdb, Elements ] works as expected. However, the next example (and all others) from the manual: Import[ ExampleData/buildings.mdb, Datasets ] reports an error: Import::fmterr: Cannot import data as MDB format. As this is not a very exaustive message, I do not know whats wrong. In the manual I found: System requirement: Import of MDB files is supported on computers that are capable of running Java 1.5. I am running version 1.6, could it be that a newer version is not accepted by Mathematica? Daniel === Subject: Re: still ignores special cases of functions I think I misread your post. However, I still think there are reasons not to call this a bug. Bear with me while I try to elaborate. What's going on is that, as a first step, Sum evaluates its first argument when it gets it. The argument is c[m]. So, how should this be evaluated? Mathematica does this through pattern matching. Does c[m] match c[1]? Possibly, but undecidable, so c[1] should certainly not be returned. Does c[m] match c[n_]? Yes, surely. Therefore, it can (and should?) be evaluated. As a result, k cc^n is passed to Sum's internals. You can see with Trace that it indeed does this. If you evaluate c[m] on a line of its own you get the same result. So, actually, it's not really a bug of Sum, but it has more to do with the general philosophy of function argument pattern matching. If you could define c[m] such that mathematica cannot select the most general case the Sum goes OK. That's what we'll do next. Below I'll show the results of four possible ways of defining c[m]: 1) your definition, 2) using If, 3) using Piecewise, and 4) using Which. The latter three all work as desired. (*** your definition ***) In[59]:= ClearAll[c]; c[n_] := k cc^n; c[1] := cc; c[1] c[m] c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[62]= cc Out[63]= cc^m k Out[64]= cc k == cc (*** If ***) In[83]:= ClearAll[c]; c[n_] := If[n > 1, k cc^n, cc] c[1] c[m] c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[85]= cc Out[86]= If[m > 1, k cc^m, cc] Out[87]= True (*** Piecewise ***) In[88]:= ClearAll[c]; c[n_] := [Piecewise] { {cc, n == 1}, {k cc^n, True} } c[1] c[m] c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[90]= cc Out[91]= [Piecewise] { {cc, m == 1}, {cc^m k, !(* TagBox[True, PiecewiseDefault, AutoDelete->False, DeletionWarning->True])} } Out[92]= True (*** Which ***) In[93]:= ClearAll[c]; c[n_] := Which[n == 1, cc, n > 1, k cc^n]; c[1] c[m] c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[95]= cc Out[96]= Which[m == 1, cc, m > 1, k cc^m] Out[97]= True Actually, I had high hopes for the following modification of your original definition: In[212]:= ClearAll[c]; c[n_ /; n != 1] := k cc^n; c[n_ /; n == 1] := cc; c[1] c[m] c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[215]= cc Out[216]= c[m] Out[217]= cc + Sum[c[m], {m, 2, [Infinity], 1}] == Sum[c[m], {m, 1, [Infinity], 1}] However, this returns unevaluated (but at least it isn't wrong). This must have something to do with Sum getting passed the -more or less- abstract function c[m], where all other new variants above pass explicit functions. Hope this sheds some light on this matter. There is an error in your own code. Your definition of c[1] is either > unnecessary or wrong. The first equation is only true if c[1] = k cc (in which case the > general definition of c would be sufficient). You define it as cc. > You are mistaking. Try to read the following pages of the manual: > tutorial/TheOrderingOfDefinitions > tutorial/MakingDefinitionsForFunctions > This is a piecewise function but Sum[] does not work with Piecewise[] > at all. And it ignores the special cases of function definitions. === Subject: Parallel computing with Mathematica 7? I have installed Mathematica 7 on my new laptop (Intel Centrino double core, Windows XP) and the first thing I tried was the long awaited parallllllel computing. I have tried different new commands and what I saw was a black box with input and no output. I could not see any evidence that parallelization works for me. My basic test was to create a table of two equal elements being the trace of the exponential of a large matrix. One such operation takes 8 sec., so the sequential computation of the table requires the double time being 16 sec. Parallelization should reduce the time to 8 sec. However, this does not happen. Here is the code that I used: Timing[ParallelTable[Element,{i,1,2}]] where Element = Tr[MatrixExp[A]] and A is a large latrix. I have looked at the system performace in the Windows Task Manager. Both with Table and ParallelTable the processor load was 50%, that is, only one core of the two was working. In addition, I have found that the command Parallelize does not take the option Method->... Does anybody have a positive experience with parallelization in Mathematica 7? Do I have to perform a special setup to get these features working? I tried different ...Kernel... manipulations to no avail. Dmitry === Subject: Re: Plot Lists of values from excel to mathematica Hi Dino, assume that your data is in file f.xls. Then we read the file, extract the first table and transpose the data because we want to work with raws not columns. d = Transpose[Import[d:/tmp/t.xls, Data] [[1]]] If your x values are 1,2,3.., this is the default and we my simply only specify the y-values like in: ListLinePlot[Rest[d]] However, if you have arbitrary x values, we must add them to every raw of y values: d = Transpose[{d[[1]], #}] & /@ Rest[d]; ListLinePlot[d] hope this helps, Daniel > Hello everybody I'd like to plot in mathematica one four columns data > that i have in excel, how i can do that in mathematica? For example I > have: > 1 5 2 4 > 2 6 1 2 > 3 2 2 1 > 4 1 7 2 I'd like to have a plot wher on the x axis I have 1,2,3,4 and for the > x=1 the point are at: 5,2,4; at x=2 the points are at 6,1,2 and so on. > What is the simplest way to do that in mathematica? === Subject: Re: Plot Lists of values from excel to mathematica I presume your data comes from Excel in the form of a list of lists, with each constituent list being a row of your table, i.e.: xy = {{1,5,2,4},{2,6,1,2},{3,2,2,1},{4,1,7,2}}; Define an auxiliary function to associate the first entry in each row with each of the remaining entries in its row: f[lis_] := Flatten[Outer[List, {First[lis]}, Rest[lis]], 1] Now Apply that function to each row (but do it all at once) and do a ListPlot of the result: ListPlot[f/@xy,PlotStyle->{PointSize[Large]}] I don't know whether this is the simplest way, but it's a reasonably straightforward way. > Hello everybody I'd like to plot in mathematica one four columns data > that i have in excel, how i can do that in mathematica? For example I > have: > 1 5 2 4 > 2 6 1 2 > 3 2 2 1 > 4 1 7 2 I'd like to have a plot wher on the x axis I have 1,2,3,4 and for the > x=1 the point are at: 5,2,4; at x=2 the points are at 6,1,2 and so on. > What is the simplest way to do that in mathematica? > Dino > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Plot Lists of values from excel to mathematica do you mean data = ImportString[1 5 2 4 2 6 1 2 3 2 2 1 4 1 7 2, Table]; ListPlot[Transpose[Drop[#, 1] & /@ data],Joined -> True] ?? Jens > Hello everybody I'd like to plot in mathematica one four columns data > that i have in excel, how i can do that in mathematica? For example I > have: > 1 5 2 4 > 2 6 1 2 > 3 2 2 1 > 4 1 7 2 I'd like to have a plot wher on the x axis I have 1,2,3,4 and for the > x=1 the point are at: 5,2,4; at x=2 the points are at 6,1,2 and so on. > What is the simplest way to do that in mathematica? > Dino > === Subject: Re: Plot Lists of values from excel to mathematica data = {{1, 5, 2, 4}, {2, 6, 1, 2}, {3, 2, 2, 1}, {4, 1, 7, 2}}; f[x_List] := {First[x], #} & /@ Rest[x]; plotData = Transpose[f /@ data]; ListLinePlot[plotData, PlotMarkers -> Automatic, AxesOrigin -> {0, 0}] Bob Hanlon Hello everybody I'd like to plot in mathematica one four columns data that i have in excel, how i can do that in mathematica? For example I have: 1 5 2 4 2 6 1 2 3 2 2 1 4 1 7 2 I'd like to have a plot wher on the x axis I have 1,2,3,4 and for the x=1 the point are at: 5,2,4; at x=2 the points are at 6,1,2 and so on. What is the simplest way to do that in mathematica? Dino -- Bob Hanlon === Subject: Re: Is this so hard? > I gave DSolve this thing: DSolve[{x''[t] == 1/x[t]^2, x[0] == -1}, x, t] It made it think and think until it crashed. > Is this DE so hard? I figured it was something basic. Ram, I shall adopt your sophisticated terminology. This thing: DSolve[{x''[t] == 1/x[t]^2, x[0] == -1}, x, t] is a semantically/syntactically incomplete expression since, If you want to solve a second order ODE, you need to supply 2 boundary/ initial conditions, not just 1 as you did. This has been promptly noted by Murray. This is basic ODE theory. Yet you dauntlessly persevered, offering to Mathematica (and to us) your new thing: DSolve[{x''[t] == 1/x[t]^2, x[0] == -1, x'[0] == 0}, x, t] and asked us why Mathematica cannot give you an intelligible (to you) answer. Mathematica in reality gives you a very clear answer. It tells you that, in order to solve for the boundary/initial conditions, it must solve a system of equations involving inverse/implicit functions and that it cannot do that. This has been explained to you by Jens-Peer. Mathematica can very easily solve your =93thing=94 numerically s = NDSolve[{x''[t] == 1/x[t]^2, x[0] == -1, x'[0] == 0}, x, {t, -1, 1}] and plot it Plot[Evaluate[x[t] /. s], {t, -1, 1}, PlotRange -> All] and you can easily check that this is indeed the solution: first we can examine the phase portrait g1 = StreamPlot[{y, 1/x^2}, {x, -1.5, 1}, {y, -1, 1}, StreamPoints -> {{{{-1, 0}, Red}, Automatic}}] Then we can draw your numerical solution in the phase portrait g2 = ParametricPlot[Evaluate[{x[t], x'[t]} /. s], {t, -8/10, 8/10}, AspectRatio -> 1, ColorFunction -> BlueGreenYellow, PlotStyle -> Thick] and finally we can superimpose two plots and see that they match Show[g1, g2] As you see, all this is something basic for Mathematica, I can't figure out why it was not for you. === Subject: Re: Problem in generating a DO cycle (mathematica 6.0) Hi Valeria, Some comments about your program: 1. Quit needs brackets -> Quit[] 2. Import[nome, ImageSize]; does nothing: the ; suppresses the output of the picture's dimensions 3. dimension assignment can be done more elegantly in one statement: {row,col} = ToExpression[Import[nome, ImageSize]]; 4. Depending on how you are going to generate gv it may not be necessary to prepare gv to hold some items as you do with Array. 5. You are not very clear how you want elements of gl mapped to gv. You call it the product, but I'll assume you want some 2D to 1D reshuffeling. Possibilities are, for instance, putting them in a list row after row, or column after column. Both can be done without a Do loop. Actually, a surprising number of constructions that are done in other programming languages with Do loops can be written very succintly in Mathematica by avoiding Do. They run most often also quite a bit faster that way. You could say gv = Flatten[gl]; if you want to do it row by row, or gv = Flatten[Transpose[gl]]; if you want to do it column by column. If you persist in using Do loops it would be something like: Do[gv[[k+col(j-1)]] = gl[[j,k]],{j,row},{k,col}]; or Do[gv[[k+col(j-1)]] = gl[[j,k]],{k,col},{j,row}]; depending on which way you'll to fold your matrix into a list. Note that in this case your preparation of gv is indeed necessary because your using an index in this array. Note that you do not need to explicitely nest two Do loops (it is possible, though). Specifying two sets of iterations in one Do construct is sufficient. By the way, the last one of these iterations is, confusingly, the 'inner loop'! Hope this helps. Through these commands I acquire a bitmap image from a my folder and crea= te > a Graylevels file: Quit; > SetDirectory[ C:Users...DatiBitmapxxx]; > nome = p6a.bmp; > Import[nome, ImageSize]; > row = ToExpression[Import[nome, ImageSize]][[1]]; > col = ToExpression[Import[nome, ImageSize]][[2]]; > vmax = row*col; > gv = Array[f, vmax]; > gl = Import[nome, GrayLevels]; at this point I have a matrix with all graylevels. Now my problem is to create a two DO cycle (one for rows and one for > columns) which allow me to generate an array (gv) whose elements are the > product row x column of the matrix: gv[i] = gl [j,k] where: > {i,1,Vmax} > {j,1,row} > {k,1,col} Can you pleasa herlp me to generate these Do Cycle? Vale === Subject: Re: Problem in generating a DO cycle (mathematica 6.0) Hi Valeria, if I understand correctly, you have a matrix: m and want to change this into a vector: v, containing the elemnsts of m. In mathematica there are often easier ways than Do loops. In this case: Flatten[m] will return a vector containing the elements of m raw-wise (first raw,second raw..) Flatten[Transpose[m]]] gives a vector column-wise. hope this helps, Daniel Through these commands I acquire a bitmap image from a my folder and create > a Graylevels file: Quit; > SetDirectory[ C:Users...DatiBitmapxxx]; > nome = p6a.bmp; > Import[nome, ImageSize]; > row = ToExpression[Import[nome, ImageSize]][[1]]; > col = ToExpression[Import[nome, ImageSize]][[2]]; > vmax = row*col; > gv = Array[f, vmax]; > gl = Import[nome, GrayLevels]; > at this point I have a matrix with all graylevels. Now my problem is to create a two DO cycle (one for rows and one for > columns) which allow me to generate an array (gv) whose elements are the > product row x column of the matrix: gv[i] = gl [j,k] where: > {i,1,Vmax} > {j,1,row} > {k,1,col} Can you pleasa herlp me to generate these Do Cycle? Vale === Subject: Re: Problem in generating a DO cycle (mathematica 6.0) try gv = Flatten[ ImageData[Import[http://sipi.usc.edu/database/misc/5.1.09.tiff]], 1]; or in your case gv = Flatten[ ImageData[Import[p6a.bmp]], 1]; with Mathematica 7 and with Mathematica 6 gv = Flatten[ Import[http://sipi.usc.edu/database/misc/5.1.09.tiff][[1, 1]], 1] or gv = Flatten[ Import[p6a.bmp][[1, 1]], 1] BTW: Your code is awfully nonsense and you should really read the manual. Jens Through these commands I acquire a bitmap image from a my folder and create > a Graylevels file: Quit; > SetDirectory[ C:Users...DatiBitmapxxx]; > nome = p6a.bmp; > Import[nome, ImageSize]; > row = ToExpression[Import[nome, ImageSize]][[1]]; > col = ToExpression[Import[nome, ImageSize]][[2]]; > vmax = row*col; > gv = Array[f, vmax]; > gl = Import[nome, GrayLevels]; > at this point I have a matrix with all graylevels. Now my problem is to create a two DO cycle (one for rows and one for > columns) which allow me to generate an array (gv) whose elements are the > product row x column of the matrix: gv[i] = gl [j,k] where: > {i,1,Vmax} > {j,1,row} > {k,1,col} Can you pleasa herlp me to generate these Do Cycle? Vale === Subject: Re: Moving $UserBaseDirectory makes all paclets do not working > I have tried that you suggest. The result is recreating the Paclets > directory and it's content. Nevertheless paclets still do not work. I have now take the time to try what you do. If I set MATHEMATICA_USERBASE to an empty directory, then everything seems to work, including DataPaclets (only thing to move might be the mathpass file, if that is in your old USERBASE). In that directory I have grepped all files for the name of that directory and it tells me that some binary files within PacletConfiguration match the string, so I would guess these are a candidate for your problem. Have you tried to only copy those files to your new USERBASE that you know what they are good for? You might want to try an empty directory first, if that works copy and try until you find the offending file(s)... hth, albert === Subject: Re: Mathematica and Access I have just detected that it not wrong pathes but wrong user input that made the examples not work. You must install the example databases first with DatabaseLink`DatabaseExamples` before the examples work. How to do that is also explained in the DatabaseLink-Documentation. albert === Subject: Re: Mathematica and Access > I have to manage an huge database in Microsoft Access format. I have no experience with huge access databases (usually when databases get huge I think the database-people try to avoid access, but 'huge' might be relative...). Have you looked at the DatabaseLink documentation? They have an example about how to handle an access database via ODBC there, which does exactly what you seem to need. Just search for ODBC in the documentation center. The documentation was obviously done with version 5 but it still works with 7, except that the example database is now here: ../SystemFiles/Links/DatabaseLink/Examples/publisher.mdb the interesting thing is, that this works even without access being installed. The downside is that some of the examples in the documentation don't work, probably since pathes have changed... hth, albert > I'm trying to do the job using Mathematica because hard computational > work is involved, but I'm unable to find the right way using > Mathematca's help only. Therefore, I export data from .MDB file in a TSV formatted one, precess > them, import data in .MDB file again. No doubt, it's a repetitive, slow, tedious method; I would love > modify data (as an example, decrease by 10% prices of all books having > been hanging for more than an year) directly within Mathematica Front > End (or by means of a Kernel batch call). Please can you suggest if it is feasible and, possibly point out a > tutorial about that ? Does anyone got a try before ? Best Regard Ignacio > === Subject: Re: Mathematica and Access Hi Ignacio, I've never tried this, but Mathematica has database connectivity built- in. Have you read DatabaseLink/tutorial/Overview in the documentation centre? One of the supported databases seems to be Access. I have to manage an huge database in Microsoft Access format. I'm trying to do the job using Mathematica because hard computational > work is involved, but I'm unable to find the right way using > Mathematca's help only. Therefore, I export data from .MDB file in a TSV formatted one, precess > them, import data in .MDB file again. No doubt, it's a repetitive, slow, tedious method; I would love > modify data (as an example, decrease by 10% prices of all books having > been hanging for more than an year) directly within Mathematica Front > End (or by means of a Kernel batch call). Please can you suggest if it is feasible and, possibly point out a > tutorial about that ? Does anyone got a try before ? Best Regard Ignacio === Subject: Re: Mathematica and Access Ignacio, have a look at the DatabaseLink package. As of 6.0, retrieving data works fine for me. In the 7.0 help-browser: DatabaseLink/tutorial/Overview Yves I have to manage an huge database in Microsoft Access format. I'm trying to do the job using Mathematica because hard computational > work is involved, but I'm unable to find the right way using > Mathematca's help only. Therefore, I export data from .MDB file in a TSV formatted one, precess > them, import data in .MDB file again. No doubt, it's a repetitive, slow, tedious method; I would love > modify data (as an example, decrease by 10% prices of all books having > been hanging for more than an year) directly within Mathematica Front > End (or by means of a Kernel batch call). Please can you suggest if it is feasible and, possibly point out a > tutorial about that ? Does anyone got a try before ? Best Regard Ignacio > === Subject: Taking LCM in a polynomial expression try Factor: In[4]:= (num1/den1 + num2/den1 + num3/den1) // Factor Out[4]= (num1 + num2 + num3)/den1 Have fun, :-) , Alexei Hi I have a symbolic matrix that I invert. When I take each individual entry of the resulting matrix, I get an expression of the form: num1/den1 + num2/den1 + .... + num_n/den1 where den1 is the determinant of the matrix. I'd like to get an expression of the form: Num/Den. I tried using Simplify (as well as multiplying the matrix by its determinant), but it doesn't seem to help. Any suggestions? On a related note, the final Num is a polynomial in two variables - say x,y. I'd like to arrange it in decreasing powers of x - like f1(y) x^n + f2(y) x^n-1... + constant. What function should use? Is there any way to both in a single step? Srikanth -- Alexei Boulbitch, Dr., Habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: Import MDB according to Wolfram Mathematica should be able to read an Access database. The first example from the manual: Import[ ExampleData/buildings.mdb, Elements ] works as expected. However, the next example (and all others) from the manual: Import[ ExampleData/buildings.mdb, Datasets ] reports an error: Import::fmterr: Cannot import data as MDB format. As this is not a very exaustive message, I do not know whats wrong. no idea whats going wrong, but for mdb files you have the alternative to access the data via DatabaseLink which probably has even some advantages, although it is admittedly a little more work to set this up... > In the manual I found: System requirement: Import of MDB files is supported on computers that are capable of running Java 1.5. I am running version 1.6, could it be that a newer version is not accepted by Mathematica? I don't even think that mathematica uses the systems JVM, it installs its own and only if it is (mis-)configured to do so it would use another, so I think this probably wants to say a Java 1.5 JVM running on your computer (platform) is available so Mathematica can be shipped with it. Probably that comes from a time when there was no Java 1.5 available for one or some of the supported platforms... To me it looks like version 7 comes with Java 1.6 anyway so I think that is not your problem. On my computer mathematica 6 uses Java 1.5 and the example still doesn't work. It is probably just that the library that is used for this imports can't for some reason handle that file, I have no idea how common that is with access databases, there might very well be different versions of the data forma. The following seems to work alright (once you have set up the odbc driver for buildings.mdb as described in the DatabaseLink): Needs[DatabaseLink`] conn = OpenSQLConnection[JDBC[odbc, buildings]] SQLTables[conn] SQLSelect[conn, Buildings] hth, albert === Subject: Re: webMathematica - comments, opinions, user group (?) Scott We have been working on an update for webMathematica, one that uses a higher version of Mathematica and also that has a significant number of new features. It has been in a stable and nearly ready state for some time. Unfortunately, it was pushed back by the release of Mathematica 7. The release of the base Mathematica always has to take priority. Now that Mathematica 7 is released, we hope to move forward with webMathematica. In the interim there is a beta version of the update that is available and you could sign up to try this. We would also like to hear about what you have done with your existing webMathematica. We certainly do consider webMathematica to be an important and relevant way to deliver Mathematica, and fully intend to support and to develop it. Tom Wickham-Jones Wolfram Research > I'm interested in what people know on the scoop for comments and opinio= ns > on webMathematica. Also, does anyone know if there is a user group? The basis of my question is as follows. I have been using the product for > about 6 months now, and I'm getting a lot of high mileage out of and give= it > a 5-star rating. Nevertheless, it's based on Mathematica V5.2 (i.e., the > webMathematica product from Wolfram does not support a higher version), a= nd > the new webMathematica that should support higher versions now seems > several years delayed. Do I make the correct inference that webMathematica did not turn out to h= ave > as wide an appeal as Wolfram had hoped for and that it is almost in the > category of discontinued product? Or on the flip side is there a vibrant community out there that I can joi= n? > Google hits seem to turn up only the Wolfram site, again leading to my > inference that the product did not turn out in the success category for > Wolfram. Does anyone know why? Any more comments, opinions, or knowledge on the history and context of > webMathematica? -Scot Martin === Subject: Constrain independent variable in FindFit? Hello. I am trying to fit two sets of data (two different quantities, both as a function of time), whose models share common parameters, in a manner similar to this MathGroup post: http://forums.wolfram.com/mathgroup/archive/2008/Jan/msg00155.html I am using the FindFit commmand, and I already successfully specify initial values of the input parameters (I can also constrain them, but am not doing so currently). However, my model is ill-behaved for early times, and the error from the early times outside my range of interest prevents convergence to good parameter values. To avoid the ill-behaved time values and achieve convergence, I would like to limit the search for the fit to a particular range of times (say, t0 to t1). Is it possible to constrain the range of independent variable values for the FindFit function's search? My FindFit function looks something like this: FindFit[newdat, {err[t]}, {{Gamma, 1}, {N0, 2*10^6}}, t], where 'newdat' and 'err[t]' are basically as they are in the aforementioned post except that 'newdat' begins at t=t0 instead of t=0 = and 'err[t]' has been weighted by the uncertainties in my data. I've already looked through Mathematica's documentation and through MathGroup archives without much return. Hopefully someone can provide -- Pascal Pascal Mickelson mickelsp@rice.edu === Subject: Trivial question I haven't used Mathematica for a year so I've forgotten a lot. I want to take the product of elements in a list of definite length. e={e1,e2,e3, ... ,e13} (13 could be anything) I want e1 e2 .... e13. In other words like Total[e]=e1+e2... Steve Gray === Subject: Re: Trivial question > I haven't used Mathematica for a year so I've forgotten a lot. > I want to take the product of elements in a list of definite length. > e={e1,e2,e3, ... ,e13} (13 could be anything) > I want e1 e2 .... e13. In other words like Total[e]=e1+e2... Apply (shortcut @@). For instance, In[59]:= e = {e1, e2, e3} Apply[Times, e] Times @@ e Out[59]= {e1, e2, e3} Out[60]= e1 e2 e3 Out[61]= e1 e2 e3 In[62]:= e = {1, 2, 3} Apply[Times, e] Times @@ e Out[62]= {1, 2, 3} Out[63]= 6 Out[64]= 6 --Jean-Marc === Subject: Re: Trivial question Times @@ e ?? Jens > I haven't used Mathematica for a year so I've forgotten a lot. > I want to take the product of elements in a list of definite length. > e={e1,e2,e3, ... ,e13} (13 could be anything) > I want e1 e2 .... e13. In other words like Total[e]=e1+e2... Steve Gray > === Subject: Re: Trivial question Times @@ e -Francesco > I haven't used Mathematica for a year so I've forgotten a lot. > I want to take the product of elements in a list of definite length. > e={e1,e2,e3, ... ,e13} (13 could be anything) > I want e1 e2 .... e13. In other words like Total[e]=e1+e2... Steve Gray > === Subject: Re: Solving the Quintic: Correction to x^5 + 20 x + 32 == 0 root > There is an error on one of the Solving the Quintic > pages. It is necessary to change a minus sign to a plus > sign to get a correct N[%] value -1.363962165089939` > The change is marked below with the comment (*fixed*). The Solving the Quintic page in error ishttp://library.wolfram.com/exam= ples/quintic/main.html The page shows the following: There are polynomials of degree greater than four which > do not factor over the rationals, but that can still be > solved in radicals. An example is the quintic: x^5 + 20 x + 32 == 0 one of whose roots is 1/5 (-(2500 Sqrt[5] + 250 Sqrt[50 - 10 Sqrt[5]] - > 750 Sqrt[50 + 10 Sqrt[5]])^(1/5) - > (-2500 Sqrt[5] + 750 Sqrt[50 - 10 Sqrt[5]] + > 250 Sqrt[50 + 10 Sqrt[5]])^(1/5) +(*fixed*) > (2500 Sqrt[5] + 750 Sqrt[50 - 10 Sqrt[5]] + > 250 Sqrt[50 + 10 Sqrt[5]])^(1/5) - > (2500 Sqrt[5] - 250 Sqrt[50 - 10 Sqrt[5]] + > 750 Sqrt[50 + 10 Sqrt[5]])^(1/5)) The corrected result can be checked using: N[#^5 + 20 # + 32 == 0 &[%], 100] Can anyone who has the Solving the Quintic poster see > if it is correct on there? All of the roots are given by evaluating this: Module[{prim1, prim2, prim3, prim4, r1, r2, r3, r4}, > r1 = -(2500*5^(1/2) + 250* (50 - 10*5^(1/2))^(1/2) - > 750 *(50 + 10*5^(1/2))^(1/2))^(1/5); > r2 = (2500*5^(1/2) + 750 *(50 - 10*5^(1/2))^(1/2) + > 250 *(50 + 10*5^(1/2))^(1/2))^(1/5); > r3 = -(-2500*5^(1/2) + 750 *(50 - 10*5^(1/2))^(1/2) + > 250* (50 + 10*5^(1/2))^(1/2))^(1/5); > r4 = -(2500*5^(1/2) - 250* (50 - 10*5^(1/2))^(1/2) + > 750 *(50 + 10*5^(1/2))^(1/2))^(1/5); > prim1 = (-1 - 5^(1/2) + 2^(1/2)*I*(5 - 5^(1/2))^(1/2))/4; > prim2 = (-1 + 5^(1/2) - 2^(1/2)*I*(5 + 5^(1/2))^(1/2))/4; > prim3 = (-1 + 5^(1/2) + 2^(1/2)*I*(5 + 5^(1/2))^(1/2))/4; > prim4 = (-1 - 5^(1/2) - 2^(1/2)*I*(5 - 5^(1/2))^(1/2))/4; > {x -> #} & /@ ({{r1, r2, r3, r4}.{1, 1, 1, 1}, > {r1, r2, r3, r4}.{prim2, prim4, prim1, prim3}, > {r1, r2, r3, r4}.{prim3, prim1, prim4, prim2}, > {r1, r2, r3, r4}.{prim1, prim2, prim3, prim4}, > {r1, r2, r3, r4}.{prim4, prim3, prim2, prim1}}/5)] Check the roots using: N[Solve[x^5 + 20 x + 32 == 0, x], 100] == N[%, 100] The Solving the Quintic poster notebooks are available athttp://library= .wolfram.com/infocenter/TechNotes/158/ The Radical.nb notebook is what was used here. Change > the simp function to do Expand[Simplify[%]] on its result > and discard the Discriminant definition which is built into > versions 6 & 7 to get the results in a form like what is > shown here. Also change Solve::rad to SolveQuintic::rad > in two places before evaluating all cells. Q.E.D. The poster has it correct. -Bob === Subject: Re: Newbie: Howjavascript:; to Draw the 2-dimensional feasible set RegionPlot[ y > x - 2 && y < 1.5 && x < y^2, {x, -2, 2}, {y, -2, 2}] ?? Jens > I have an optimization problem (2 > decision variables x1=2C x2). I would like to know how to obtain a graph > (with Mathematica) representing its feasible set. The feasible set is the union of two polyhedra. > Pratim > === Subject: Re: Parallel computing with Mathematica 7? > I have installed Mathematica 7 on my new laptop (Intel Centrino double > core, Windows XP) and the first thing I tried was the long awaited > parallllllel computing. I have tried different new commands and what I > saw was a black box with input and no output. I could not see any > evidence that parallelization works for me. I'm not sure I quite understand your example, but here's an operation that is sped up tremendously via parallelization: t = AbsoluteTime[]; data = Table[PrimeQ[x + I*y, GaussianIntegers -> True], {x, -1000, 1000}, {y, -1000, 1000}]; time1 = AbsoluteTime[] - t 7.042566 To run it in parallel, it might make sense to LaunchKernels first: LaunchKernels[] I get 8 kernels on my machine. Now, simply change the Table to ParallelTable: t = AbsoluteTime[]; data = ParallelTable[PrimeQ[x + I*y, GaussianIntegers -> True], {x, -1000, 1000}, {y, -1000, 1000}]; time2 = AbsoluteTime[] - t 1.238292 A silly example, perhaps, but there are quite a few similar types of exercises at Project Euler: http://projecteuler.net/ Also, I posted a webpage a month or so ago illustrating a technique to use Mathematica to coordinate Java programs through JLink: http://facstaff.unca.edu/mcmcclur/Mathematica/ParallelJLink/ Finally, here are a couple more things to keep in mind with regard to parallel computation: * Due to overhead in running parallel computations (extra memory, interprocess communication, etc.) it is very unusual for a parallel computation on n kernels to run n times faster. * There's generally no apriori way to break the problem up, since we don't necessarily know which sub-parts will run faster than other sub-parts. It's best if, like in this example, the sub-problems run at similar rates. === Subject: Re: Parallel computing with Mathematica 7? > (* parallelization fails because of MatrSize *) > MatrSize = 100; TableLength = 2; > t = AbsoluteTime[]; > Tim = Timing[ > ParallelTable[ > Tr[MatrixExp[ > Table[i j + i - 1., {i, 1, MatrSize}, {j, 1, MatrSize}]]], {i= , > 1, TableLength}]]; Be sure to call DistributeDefinitions[MatrSize] before you use MatrSize in a parallel computation. It might make sense to place TableLength in there too but it's not essential in this example, since ParallelTable only breaks the computation up along the inner most index. Mark McClure === Subject: Re: Parallel computing with Mathematica 7? Hi All, Some of the examples above do not work because the definitions, such are working examples. I have a double-core processor. **************************************************************************** ************** (* not parallelized; Timing and AbsoluteTime yield consistent results *) MatrSize = 100; TableLength = 2; t = AbsoluteTime[]; Tim = Timing[ Table[Tr[ MatrixExp[ Table[i j + i - 1., {i, 1, MatrSize}, {j, 1, 1 MatrSize}]]], {i, 1, TableLength}]]; Tim[[1]] time2 = AbsoluteTime[] - t 16.296 16.3127088 **************************************************************************** * distributed over the kernels; Timing fails *) MatrSize = 100; TableLength = 2; t = AbsoluteTime[]; TableLength}]]; Tim[[1]] time2 = AbsoluteTime[] - t 0.047 8.8125000 ****************************************************************** Another important application is parallelization of loops. I have found that Do loops can be parallelized: ********************************************************************* (* not parallelized *) MatrSize = 100; n = 4; t = AbsoluteTime[]; Do[ Print[k=, k, , Done by kernel: , $KernelID]; , {k, n}]; time2 = AbsoluteTime[] - t Output: k=1, Done by kernel: 0 k=2, Done by kernel: 0 k=3, Done by kernel: 0 k=4, Done by kernel: 0 32.5781250 ************************************************************************ (* parallelized *) MatrSize = 100; n = 4; t = AbsoluteTime[]; DistributeDefinitions[MatrSize] Parallelize[ Do[ Print[k=, k, , Done by kernel: , $KernelID]; , {k, n}] ]; time2 = AbsoluteTime[] - t Output: k=3, Done by kernel: 1 k=1, Done by kernel: 2 k=2, Done by kernel: 2 k=4, Done by kernel: 1 17.0937500 ************************************************************************* To the contrast, the For-loop cannot be parallelized, and I guess the While-loop cannot be parallelized as well. Now I will be rewriting my programs replacing For-loops by Do-loops. Dmitry === Subject: Re: Parallel computing with Mathematica 7? [...] t = AbsoluteTime[]; data = ParallelTable[ PrimeQ[x + I*y, GaussianIntegers -> True], {x, -1000, 1000}, {y, -1000, 1000}]; time2 = AbsoluteTime[] - t On my double-core laptop I've got the times unparallelized: 8.63 sec parallelized: 6.58 sec In my Wondowx task manager I saw that processor load was close to 100% in the parallelized case. The speed gain is inessential because elementary operations are very quick and the avantage of parallelization gets used up by the communication overhead. Now back to my original example with a long elementary calculation taking about 8 sec. In this case I expected the gain of parallelization to be about the factor 2. However, my attempt of parallelization failed for a reason that will be seen below. I have found that one can indeed get parallelization working. Here are my examples of calculating the trace of the exponential of a large matrix: **************************************************************************** *********** (* not parallelized; Timing and AbsoluteTime yield consistent results *) MatrSize = 100; TableLength = 2; t = AbsoluteTime[]; Tim = Timing[ Table[Tr[ MatrixExp[ Table[i j + i - 1., {i, 1, MatrSize}, {j, 1, 1 MatrSize}]]], {i, 1, TableLength}]]; Tim[[1]] time2 = AbsoluteTime[] - t 16.296 16.3127088 ************************************************************************ (* parallelization fails because of MatrSize *) MatrSize = 100; TableLength = 2; t = AbsoluteTime[]; Tim = Timing[ ParallelTable[ Tr[MatrixExp[ Table[i j + i - 1., {i, 1, MatrSize}, {j, 1, MatrSize}]]], {i, 1, TableLength}]]; Tim[[1]] time2 = AbsoluteTime[] - t 16.344 16.5470868 **************************************************************************** *************** (* parallelization works with speed gain close to 2 if MatrSize is replaced by its numerical value; Timing fails *) MatrSize = 100; TableLength = 2; t = AbsoluteTime[]; Tim = Timing[ ParallelTable[ Tr[MatrixExp[Table[i j + i - 1., {i, 1, 100}, {j, 1, 100}]]], {i, 1, TableLength}]]; Tim[[1]] time2 = AbsoluteTime[] - t 4.30211*10^-16 9.0157404 **************************************************************************** ****** MatrSize = 100; TableLength = 2; t = AbsoluteTime[]; TableLength}]]; Tim[[1]] time2 = AbsoluteTime[] - t 16.312 16.312708 **************************************************************************** ********* It seems that newly introduced parallelization is still buggy. As I noted in my previous message, the command Parallelize does not take the option Method->... Still, for typical oprtations like filling tables one can achieve a gain close to 2 if elementary operations are long. This is what many of simple Mathematica user need. Dmitry === Subject: Re: Parallel computing with Mathematica 7? > Does anybody have a positive experience with parallelization in > Mathematica 7? yes, but your example > Timing[ParallelTable[Element,{i,1,2}]] where Element = Tr[MatrixExp[A]] and A is a large latrix. is a very stupid one. You can't expect that the distribution of a large matrix A to the kernels will not need the most of the time, while the computation of the expression itself is so quick that you will never see a speed up. Since the master kernel does the most work when it distribute the matrix to the other kernels ( and this is a serial task), you see only this in the processor load. Successful parallelization, i.e., one with a speed up, is a hard work and not a matter of putting Parallel*[] in every possible position. BTW: A parallel program should be slower than a serial one. Only in a few cases this is not the case. Jens > I have installed Mathematica 7 on my new laptop (Intel Centrino double > core, Windows XP) and the first thing I tried was the long awaited > parallllllel computing. I have tried different new commands and what I > saw was a black box with input and no output. I could not see any > evidence that parallelization works for me. My basic test was to create a table of two equal elements being the > trace of the exponential of a large matrix. One such operation takes 8 > sec., so the sequential computation of the table requires the double > time being 16 sec. Parallelization should reduce the time to 8 sec. > However, this does not happen. Here is the code that I used: Timing[ParallelTable[Element,{i,1,2}]] where Element = Tr[MatrixExp[A]] and A is a large latrix. I have looked at the system performace in the Windows Task Manager. > Both with Table and ParallelTable the processor load was 50%, that is, > only one core of the two was working. In addition, I have found that the command Parallelize does not take > the option Method->... Does anybody have a positive experience with parallelization in > Mathematica 7? Do I have to perform a special setup to get these > features working? I tried different ...Kernel... manipulations to no > avail. Dmitry > === Subject: Re: Parallel computing with Mathematica 7? On 17 Jan., 11:26, Jens-Peer Kuska > Does anybody have a positive experience with parallelization in > > Mathematica 7? yes, but your example Timing[ParallelTable[Element,{i,1,2}]] where Element = Tr[MatrixExp[A]] and A is a large latrix. is a very stupid one. You can't expect that the distribution > of a large matrix A to the kernels will not need the > most of the time, while the computation of the expression > itself is so quick that you will never see a speed up. > Since the master kernel does the most work when > it distribute the matrix to the other kernels ( > and this is a serial task), you see only > this in the processor load. Successful parallelization, i.e., one with a speed up, > is a hard work and not a matter > of putting Parallel*[] in every possible position. BTW: A parallel program should be slower than a serial one. > Only in a few cases this is not the case. Jens I have installed Mathematica 7 on my new laptop (Intel Centrino double > core, Windows XP) and the first thing I tried was the long awaited > parallllllel computing. I have tried different new commands and what I > saw was a black box with input and no output. I could not see any > evidence that parallelization works for me. My basic test was to create a table of two equal elements being the > trace of the exponential of a large matrix. One such operation takes 8 > sec., so the sequential computation of the table requires the double > time being 16 sec. Parallelization should reduce the time to 8 sec. > However, this does not happen. Here is the code that I used: Timing[ParallelTable[Element,{i,1,2}]] where Element = Tr[MatrixExp[A]] and A is a large latrix. I have looked at the system performace in the Windows Task Manager. > Both with Table and ParallelTable the processor load was 50%, that is, > only one core of the two was working. In addition, I have found that the command Parallelize does not take > the option Method->... Does anybody have a positive experience with parallelization in > Mathematica 7? Do I have to perform a special setup to get these > features working? I tried different ...Kernel... manipulations to no > avail. Dmitry Jens, I believe most of Mathematica users are interested in trivial cases of parallelization such as Tables, Maps, and Do-loops. This does not require programming efforts and in the case of long elementary tasks yields the speed gain close to n, where n is the number of kernels. My examples posted in this thread confirm this. Concerning nontrivial cases of parallelization, this indeed requires a harder work, so that I doubt that it can be relevant for Mathematica users. I personally would wait until Mathematica developers provide parallel versions of NDSolve and other popular routines. If I decide to rewrite an ODE solver in a parallelized way, I would do it within a programming language rather than within Mathematica. Best, Dmitry === Subject: Re: Finding a sine wave Your constraint on the wavelength will NOT make solutions unique, I think, and not all data will yield a solution at all. Here are three solvers you might try; the first is yours, except that I've put constraints on the wavelength. Your version set a starting point, only, for the wavelength. Clear[findSin, fitSin, minSin] findSin[xx_List, yy_List] := findSin[xx, yy] = Block[{a, ph, wl, x}, a Sin[ph + 2 Pi x/wl] /. FindRoot[ yy - a Sin[ph + 2 Pi xx/wl] // Evaluate, {{a, Max[Abs[yy]]}, {wl, 2 Max@xx, Max@xx, 10 Max@xx}, {ph, 0}}]] fitSin[xx_List, yy_List] := fitSin[xx, yy] = Block[{a, ph, wl, x}, a Sin[ph + 2 Pi x/wl] /. FindFit[Rest@Transpose@{xx, yy}, {a Sin[ph + 2 Pi x/wl], wl > Max@Abs@xx, 0 < 2 Pi ph < Max@Abs@xx}, {a, ph, wl}, x] ] minSin[xx_List, yy_List] := minSin[xx, yy] = Block[{a, ph, wl, x}, a Sin[ph + 2 Pi x/wl] /. Last@NMinimize[{#.# &[Thread[yy - a Sin[ph + 2 Pi xx/wl]]], wl > Max@xx, 0 < ph < (1/2 Pi) Max@xx}, {a, ph, wl}] ] xx=Sort[Join[{0},RandomReal[{0,10},2]]]; yy=RandomReal[{-25,25},3]; f[x_]=findSin[xx,yy] g[x_]=fitSin[xx,yy] h[x_]=minSin[xx,yy] -27.4879 Sin[0.456353-1.55521 x] FindFit::eit: The algorithm does not converge to the tolerance of 4.806217383937354`*^-6 in 500 iterations. The best estimated solution, with feasibility residual, KKT residual or complementary residual of {1.0772*10^-10,0.0000226396,3.80526*10^-11}, is returned. >> -37.2328 Sin[0.527053+0.0356086 x] -27.4879 Sin[2.68524+1.55521 x] Plot[{f@x, g@x, h@x}, {x, 0, 10}, Epilog -> {PointSize[0.02], Point /@ Transpose@{xx, yy}}, PlotRange -> {{0, 10}, {-25, 25}}] minSin will (almost always?) return a solution without errors, but it won't always fit the data points. The other two will fail in ALL SORTS of ways. In only three random draws, I found an example for which none of the solvers actually fit the data: xx={0, 1.5565, 6.32643} yy={0.305144, 3.21477, 17.9622} f[x_] = findSin[xx, yy] g[x_] = fitSin[xx, yy] h[x_] = minSin[xx, yy] FindRoot::reged: The point {21.1716,63.2643,0.000205665} is at the edge of the search region {6.32643,63.2643} in coordinate 2 and the computed search direction points outside the region. >> 21.1716 Sin[0.000205665+0.0993164 x] 16.5886 Sin[1.00688+0.993164 x] -9.61001 Sin[4.39622+0.993164 x] findSin fit the first two points, fitSin fit NONE of the points, and minSin fit only the second point. I'm pretty sure NO Sin function fits those data points, with a wavelength longer than the interval. Bobby > An experiment will give me three coordinates which lie on a sine wave. > I have to find the sine wave efficiently. There are three unknowns the > sine wave amplitude, A, the wavelength of the sine wave, L, and the > phase, ph. I also know that the wavelength is larger than the interval > containing my measurement points. I think this condition removes > possible multiple solutions. Below I give two methods which need improving. The first method uses > FindRoot. This methods works about 60% of the time. I give six > examples where it fails. The failure may be due to poor initial > guesses. In the second method I use FindFit. This is not quite the > correct method because I have an equal number of equations and > unknowns. Some of the failures here, I think, are due to there being > no error for the algorithm to work with. I give examples of failures. > I have also tried FindInstance, Reduce and NSolve but I don't think > these are appropriate. Here are some questions 1. I would really like a symbolic solution rather than an iterative > one. Is such a solution possible? > 2. Can anyone improve on the methods below to make them more robust? > 3. I have some control over my x-locations. How can I work out best x > locations given an estimate of the wavelength L? xx = Sort[Join[{0}, RandomReal[{0, 10}, 2]]] yy = RandomReal[{-25, 25}, 3] sol = FindRoot[{yy[[1]] - A*Sin[ph], > yy[[2]] - A*Sin[2*Pi*(xx[[2]]/L) + ph], > yy[[3]] - A*Sin[2*Pi*(xx[[3]]/L) + ph]}, {{A, > Max[Abs[yy]]}, {L, Max[xx]}, {ph, 0}}] Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, > Epilog -> {PointSize[0.02], (Point[#1] & ) /@ > Transpose[{xx, yy}]}, PlotRange -> {{0, 10}, {-25, 25}}] FindRootFailures = {{{0, 3.781264462608982, > 3.797055100562352}, {-22.948348087068737, 1.4581744078038472, > -14.242676740704574}}, {{0, 4.424069570670131, > 8.861716396743098}, {-6.444538773775843, -10.787309362608688, > 15.579334094330942}}, {{0, 4.424069570670131, > 8.861716396743098}, {-5.944536471563289, 10.627536107497393, > -21.294232497202316}}, {{0, 1.3680556047878967, > 8.546115267250002}, {4.128528863849845, 2.9017293848933923, > -22.51610539815371}}, {{0, 1.3738869718371616, > 5.689309423462079}, {20.553993773523437, -16.972841620064592, > 16.61185061676568}}, {{0, 1.0408828831133632, > 8.484645515699821}, {-3.7267589861478045, 4.1016610850387, > -24.600635061804443}}}; (({xx, yy} = #1; > sol = FindRoot[{yy[[1]] - A*Sin[ph], > yy[[2]] - A*Sin[2*Pi*(xx[[2]]/L) + ph], yy[[3]] - A*Sin[2*Pi*(xx[[3]]/L) + ph]}, {{A, > Max[Abs[yy]]}, {L, Max[xx]}, {ph, 0}}]; > Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, Epilog -> {PointSize[0.02], (Point[#1] & ) /@ > Transpose[{xx, yy}]}, > PlotRange -> {{0, 10}, {-25, 25}}]) & ) /@ > FindRootFailures xx = Sort[Join[{0}, RandomReal[{0, 10}, 2]]] yy = RandomReal[{-25, 25}, 3] sol = FindFit[ > Transpose[{xx, yy}], {A*Sin[2*Pi*(x/L) + ph], > Max[Abs[xx]] < L}, {A, L, ph}, x] Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, > Epilog -> {PointSize[0.02], (Point[#1] & ) /@ > Transpose[{xx, yy}]}, PlotRange -> {{0, 10}, {-25, 25}}] FindFitFailures = {{{0, 2.463263668380835, > 4.3190892163093615}, {-1.8407827676541144, -8.736574079785198, > 12.661520984622932}}, {{0, 3.894521446091823, > 9.937403619870642}, {12.381369822165155, 15.840399165432128, > -6.914634137727327}}, {{0, 8.087369725271945, > 8.343899312282815}, {24.73795103895976, -13.396248713970305, > 7.150470311065216}}, {{0, 1.5480031866178834, > 9.575255260205617}, {-8.163720246784278, 13.373468882892958, > -18.018462091502098}}, {{0, 0.6152784485896601, > 0.818296772602134}, {-1.858698140836046, 3.695113783904491, > -1.3186989232026658}}, {{0, 4.743093154057316, > 6.028314583406327}, {-16.60893277597446, -17.413392198343093, > -18.54081837965986}}}; (({xx, yy} = #1; > sol = FindFit[ > Transpose[{xx, yy}], {A*Sin[2*Pi*(x/L) + ph], > Max[Abs[xx]] < L}, {A, L, ph}, x]; > Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, Epilog -> {PointSize[0.02], (Point[#1] & ) /@ > Transpose[{xx, yy}]}, > PlotRange -> {{0, 10}, {-25, 25}}]) & ) /@ > FindFitFailures -- DrMajorBob@longhorns.com === Subject: Weird self-fixing problem with cell styles I was working on a Mathematica notebook when I suddenly found that I could not use the different cell styles. (Section, Subsection, Tex, Input, etc.) Several thins seemed broken: 1. On the toolbar, there is a popup menu for selecting a style; it was empty - no choices. 2. The menu item Format > Style offered only one choice : Other... 3. The menu item Format > Screen Environment was disabled (grayed out). I blundered around trying to find an option that referred to cell styles. In desperation I changed the Style Sheet, and changed it right back again. And that fixed all the symptoms. I felt that I had been acting out an AI Koan, from that fine old (!!) book _The New Hacker's Dictionary_, p. 404: A novice was trying to fix a broken Lisp machine by turning the power off and on. Knight, seeing what the student was doing, spoke sternly. 'You cannot fix a machine by just power-cycling it with no understanding of what is going wrong.' Knight turned the machine off and on. The machine worked. I have an Apple Power PC running Mac OS X version 10.5.5; and Mathematica 8.0.1.0. My notebook and stylesheet were originally written with an older version, but I think they have been kept up to date as needed. So what happened? And am I Knight, or am I the novice? -- Christopher J. Henrich chenrich@monmouth.com http://www.mathinteract.com === Subject: Re: Weird self-fixing problem with cell styles I am also having the same problems. It is irritating to see that the styles and fonts are constantly changed every time I run a code. To whom I should report? Temel -----Original Message----- === Subject: Re: Weird self-fixing problem with cell styles What happened was that something presumably changed the style sheet of the notebook to another one. One possibility is that it was changed somehow to the internal style sheet used by the Documentation Center which has its styles set so that they do not appear in the Format>Style menu. It is certainly possible that this--or something like it--happened due to a bug. Of course if you can find the steps that caused this to happen, yoiu shodl report it to Wolfram support so that they can investigate it... --David > I was working on a Mathematica notebook when I suddenly found that I > could not use the different cell styles. (Section, Subsection, Tex, > Input, etc.) Several thins seemed broken: 1. On the toolbar, there is a popup menu for selecting a style; it was > empty - no choices. 2. The menu item Format > Style offered only one choice : Other... 3. The menu item Format > Screen Environment was disabled (grayed out). I blundered around trying to find an option that referred to cell > styles. In desperation I changed the Style Sheet, and changed it right > back again. And that fixed all the symptoms. I felt that I had been acting out an AI Koan, from that fine old (!!) > book _The New Hacker's Dictionary_, p. 404: A novice was trying to fix a broken Lisp machine by turning th= e > power off and on. Knight, seeing what the student was doing, spoke sternly. 'You > cannot fix a machine by just power-cycling it with no understanding of > what is going wrong.' Knight turned the machine off and on. The machine worked. I have an Apple Power PC running Mac OS X version 10.5.5; and > Mathematica 8.0.1.0. My notebook and stylesheet were originally writte= n > with an older version, but I think they have been kept up to date as > needed. So what happened? And am I Knight, or am I the novice? -- > Christopher J. Henrich > chenr...@monmouth.comhttp://www.mathinteract.com === Subject: Re: Weird self-fixing problem with cell styles > I have an Apple Power PC running Mac OS X version 10.5.5; and > Mathematica 8.0.1.0. My notebook and stylesheet were originally written > with an older version, but I think they have been kept up to date as > needed. So what happened? And am I Knight, or am I the novice? Using Mathematica 8.0.1.0 you probably just are a beta tester :-) sorry, nothing serious from me on this... albert === Subject: Re: Weird self-fixing problem with cell styles What happened was that something presumably changed the style sheet of the notebook to another one. One possibility is that it was changed somehow to the internal style sheet used by the Documentation Center which has its styles set so that they do not appear in the Format>Style menu. It is certainly possible that this--or something like it--happened due to a bug. Of course if you can find the steps that caused this to happen, yoiu shodl report it to Wolfram support so that they can investigate it... --David > I was working on a Mathematica notebook when I suddenly found that I > could not use the different cell styles. (Section, Subsection, Tex, > Input, etc.) Several thins seemed broken: 1. On the toolbar, there is a popup menu for selecting a style; it was > empty - no choices. 2. The menu item Format > Style offered only one choice : Other... 3. The menu item Format > Screen Environment was disabled (grayed out). I blundered around trying to find an option that referred to cell > styles. In desperation I changed the Style Sheet, and changed it right > back again. And that fixed all the symptoms. I felt that I had been acting out an AI Koan, from that fine old (!!) > book _The New Hacker's Dictionary_, p. 404: A novice was trying to fix a broken Lisp machine by turning th= e > power off and on. Knight, seeing what the student was doing, spoke sternly. 'You > cannot fix a machine by just power-cycling it with no understanding of > what is going wrong.' Knight turned the machine off and on. The machine worked. I have an Apple Power PC running Mac OS X version 10.5.5; and > Mathematica 8.0.1.0. My notebook and stylesheet were originally writte= n > with an older version, but I think they have been kept up to date as > needed. So what happened? And am I Knight, or am I the novice? -- > Christopher J. Henrich > chenr...@monmouth.comhttp://www.mathinteract.com === Subject: Re: Weird self-fixing problem with cell styles > I was working on a Mathematica notebook when I suddenly found that I > could not use the different cell styles. (Section, Subsection, Tex, > Input, etc.) Several thins seemed broken: 1. On the toolbar, there is a popup menu for selecting a style; it was > empty - no choices. 2. The menu item Format > Style offered only one choice : Other... 3. The menu item Format > Screen Environment was disabled (grayed out). I blundered around trying to find an option that referred to cell > styles. In desperation I changed the Style Sheet, and changed it right > back again. And that fixed all the symptoms. What happened was that something presumably changed the style sheet of > the notebook to another one. One possibility is that it was changed > somehow to the internal style sheet used by the Documentation Center > which has its styles set so that they do not appear in the > Format>Style menu. It is certainly possible that this--or something > like it--happened due to a bug. Of course if you can find the steps that caused this to happen, yoiu > shodl report it to Wolfram support so that they can investigate it... --David I found another file with the same symptoms, and managed to get comparison data, using an ASCII editor to look at two versions of the file, one displaying the symptoms and one fixed. The important difference was near the end of the file, at the very end of Notebook content. The buggy version had this: StyleDefinitions->Notebook[{ Cell[ StyleData[StyleDefinitions -> DefaultPkg.nb]]}, Visible -> False, FrontEndVersion -> 6.0 for Mac OS X PowerPC (32-bit) (June 19, 2007), StyleDefinitions -> PrivateStylesheetFormatting.nb] ] whereas the fixed version had this in the same place: StyleDefinitions->DefaultPkg.nb A sample of other notebooks, including one last modified in 2002, have the latter, simpler content. -- Christopher J. Henrich chenrich@monmouth.com http://www.mathinteract.com === Subject: Re: Problems using MathLink This works (though doesn't do anything productive). #include #include #include #include mathlink.h //#include fields.h using namespace std; void rot(MLINK link, double theta) { char* heads[2] = {List, List}; double a[3][3]; a[0][0] = cos(theta); a[0][1] = sin(theta); a[0][2] = 0; a[1][0] = - sin(theta); a[1][1] = cos(theta); a[1][2] = 0; a[2][0] = 0; a[2][1] = 0; a[2][2] = 1; long dims[2] = {3, 3}, depth = 2; MLPutRealArray(link, *a, dims, heads, depth); cout << err = << MLError(link) << endl; } int main(int argc, char **argv) { int error, n, k, pkt; const char *a, *b; MLENV ep; MLINK lp, func; ep = MLInitialize(0); lp = MLOpenArgcArgv(ep, argc, argv, &error); MLPutFunction(lp, EvaluatePacket, 1); rot(lp, 1.0); MLEndPacket(lp); // drain the link while((pkt = MLNextPacket(lp)) != 0 && pkt != RETURNPKT) MLNewPacket(lp); // Don't call Exit[], just close the link //MLPutFunction(lp, Exit, 0); MLClose(lp); MLDeinitialize(ep); // func is uninitialized, and the environment gone anyway //cout << MLError(func) << n << MLErrorMessage(func) << endl; return 0; } run with: $ ./a.out -linkmode launch -linkname 'MathKernel' -mathlink Rob Raguet-Schofield (rob ra gA skO fEld) === Subject: Re: Problem in generating a DO cycle (mathematica 6.0) Don't know how this ToExpression got into my text, but it should be deleted. Sjoerd > Hi Valeria, Some comments about your program: 1. Quit needs brackets -> Quit[] 2. Import[nome, ImageSize]; does nothing: the ; suppresses the > output of the picture's dimensions 3. dimension assignment can be done more elegantly in one statement: > {row,col} = ToExpression[Import[nome, ImageSize]]; 4. Depending on how you are going to generate gv it may not be > necessary to prepare gv to hold some items as you do with Array. 5. You are not very clear how you want elements of gl mapped to gv. > You call it the product, but I'll assume you want some 2D to 1D > reshuffeling. Possibilities are, for instance, putting them in a list > row after row, or column after column. Both can be done without a Do > loop. Actually, a surprising number of constructions that are done in other > programming languages with Do loops can be written very succintly in > Mathematica by avoiding Do. They run most often also quite a bit > faster that way. You could say gv = Flatten[gl]; if you want to do it row by row, or gv > = Flatten[Transpose[gl]]; if you want to do it column by column. If you persist in using Do loops it would be something like: > Do[gv[[k+col(j-1)]] = gl[[j,k]],{j,row},{k,col}]; or > Do[gv[[k+col(j-1)]] = gl[[j,k]],{k,col},{j,row}]; depending on which way you'll to fold your matrix into a list. Note > that in this case your preparation of gv is indeed necessary because > your using an index in this array. Note that you do not need to > explicitely nest two Do loops (it is possible, though). Specifying two > sets of iterations in one Do construct is sufficient. By the way, the > last one of these iterations is, confusingly, the 'inner loop'! Hope this helps. > Through these commands I acquire a bitmap image from a my folder and cr= ea= > te > a Graylevels file: Quit; > SetDirectory[ C:Users...DatiBitmapxxx]; > nome = p6a.bmp; > Import[nome, ImageSize]; > row = ToExpression[Import[nome, ImageSize]][[1]]; > col = ToExpression[Import[nome, ImageSize]][[2]]; > vmax = row*col; > gv = Array[f, vmax]; > gl = Import[nome, GrayLevels]; at this point I have a matrix with all graylevels. Now my problem is to create a two DO cycle (one for rows and one for > columns) which allow me to generate an array (gv) whose elements are th= e > product row x column of the matrix: gv[i] = gl [j,k] where: > {i,1,Vmax} > {j,1,row} > {k,1,col} Can you pleasa herlp me to generate these Do Cycle? Vale === Subject: Re: User Defined Global Variables - How to do it? >I am trying to define my own global variables which will be known to >every function that I write just like the system global variable >$HomeDirectory. I have a function which has been written to read >values from a disk file and using those values calculate the values >of the global variables. >I do not know where to put this fuhction so that, at the begiinning >of a Mathematica session, these user defined global varialbes are >available to be used by any function that I have written that is >part of the packages that are autmatically loaded at the beginning >of a session. >I have previously defined my own global variables in a file called >init.m and this file is located in directory: >C:Documents and SettingsDonaldApplication >DataMathematicaAutoloadFoo to make these values globally available to all other functions that are us= ed >in the session and that are defined in the packages I created. You can put any valid Mathematica code in an init.m file. There is no restriction on the number of lines of code or the complexity of the code put into the init.m files. However, it should be obvious a very lengthy computation place in an init.m file will mean an equivalently long start up time for any Mathematica session. >(2) I don't know how to get this function [the function which calculates t= he values >of the global variables) to start up automatically BEFORE I ever have to >hit the first Shift + Enter. This function which calculaes the values of = global variables uses itself some of the other functions I defined in the p= ackages I created which are automatically loaded at session start time. You should realize there is more than one init.m file where things can be put. In particular, there is an init.m file in the directory returned by: ToFileName[$UserBaseDirectory,Kernel] code in this file will load and run *before* any thing in the autoload directory is loaded. If you put your functions in this file you should get the result you want. === Subject: Re: Solve / NSolve >differences between Solve and NSolve. Have any of you tried to run >the code i provided (including the missing function definition which >I provided later)? I'm aware that Solve and NSolve do not use the >same algorithm to solve an equation, but it does not seem logical >to me that they don't give the same solution to the same system of >algebraic equations. What could be the reason for this? For any problem where you are using machine precision numbers, there will always be values that lead to different solutions when different algorithms are used. This comes about due to rounding and precision issues. This is inherent with anything other than exact arithmetic. This issue is not limited to just Solve/NSolve nor is it a Mathematica issue. === Subject: Re: Moving $UserBaseDirectory makes all paclets do not working I have now take the time to try what you do. If I set > MATHEMATICA_USERBASE to an empty directory, then everything seems to > work, including DataPaclets (only thing to move might be the mathpass > file, if that is in your old USERBASE). path to the folder contains characters in non-English locale then importing of TIFF files does not work: In[1]:= ExampleData[{TestImage, Lena}] During evaluation of In[1]:= Import::fnfnd: File TIFF not found. >> Out[1]= $Failed This is a bug in Import[]: In[1]:= SetDirectory[$UserBaseDirectory <> /Paclets/Repository/ExampleData_TestImage_Lena-6.0.1/Data]; Import[Lena.tiff] During evaluation of In[1]:= Import::fnfnd: File TIFF not found. >> Out[2]= $Failed The same things happen with importing and exporting PNG and GZIP formats. === Subject: Re: still ignores special cases of functions > I think I misread your post. However, I still think there are reasons > not to call this a bug. Bear with me while I try to elaborate. What's going on is that, as a first step, Sum evaluates its first > argument when it gets it. The argument is c[m]. So, how should this be > evaluated? Mathematica does this through pattern matching. Does c[m] match c[1]? > Possibly, but undecidable, so c[1] should certainly not be returned. > Does c[m] match c[n_]? Yes, surely. Therefore, it can (and should?) be > evaluated. As a result, k cc^n is passed to Sum's internals. You can > see with Trace that it indeed does this. If you evaluate c[m] on a > line of its own you get the same result. So, actually, it's not really a bug of Sum, but it has more to do with > the general philosophy of function argument pattern matching. If you > could define c[m] such that mathematica cannot select the most general > case the Sum goes OK. That's what we'll do next. Below I'll show the results of four possible ways of defining c[m]: 1) > your definition, 2) using If, 3) using Piecewise, and 4) using Which. > The latter three all work as desired. (*** your definition ***) > In[59]:= ClearAll[c]; > c[n_] := k cc^n; > c[1] := cc; > c[1] > c[m] > c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == > Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[62]= cc Out[63]= cc^m k Out[64]= cc k == cc (*** If ***) > In[83]:= ClearAll[c]; > c[n_] := If[n > 1, k cc^n, cc] > c[1] > c[m] > c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == > Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[85]= cc Out[86]= If[m > 1, k cc^m, cc] Out[87]= True (*** Piecewise ***) > In[88]:= ClearAll[c]; > c[n_] := [Piecewise] { > {cc, n == 1}, > {k cc^n, True} > } > c[1] > c[m] > c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == > Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[90]= cc Out[91]= [Piecewise] { > {cc, m == 1}, > {cc^m k, !(* > TagBox[True, > PiecewiseDefault, > AutoDelete->False, > DeletionWarning->True])} > } Out[92]= True (*** Which ***) > In[93]:= ClearAll[c]; > c[n_] := Which[n == 1, cc, n > 1, k cc^n]; > c[1] > c[m] > c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == > Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[95]= cc Out[96]= Which[m == 1, cc, m > 1, k cc^m] Out[97]= True Actually, I had high hopes for the following modification of your > original definition: In[212]:= ClearAll[c]; > c[n_ /; n != 1] := k cc^n; > c[n_ /; n == 1] := cc; > c[1] > c[m] > c[1] + Sum[c[m], {m, 2, [Infinity], 1}] == > Sum[c[m], {m, 1, [Infinity], 1}] // FullSimplify Out[215]= cc Out[216]= c[m] Out[217]= > cc + Sum[c[m], {m, 2, [Infinity], 1}] == > Sum[c[m], {m, 1, [Infinity], 1}] However, this returns unevaluated (but at least it isn't wrong). This > must have something to do with Sum getting passed the -more or less- > abstract function c[m], where all other new variants above pass > explicit functions. Hope this sheds some light on this matter. > {i,...}] in really gets only evaluated version of f[i]. In this case the above-mentioned Documentation's pages threw me into confusion. It is nice that now Sum[] works at least with Piecewize[] and If[]. === Subject: Can someone run this code to give me coordinates? Here's some Mathematica code to make a list of the 240 points in the coordinates: =F4 = (1/2) (1 + Sqrt[5]); =F9 = Exp[I Pi / 30]; a = Sqrt[(1/2) (1 + =F4^(3/2)/(3^(1/2) 5^(1/4)))]; b = Sqrt[(1/2) (1 + =F4^(-3/2)/(3^(1/2) 5^(1/4)))]; c = Sqrt[(1/2) (1 - =F4^(-3/2)/(3^(1/2) 5^(1/4)))]; d = Sqrt[(1/2) (1 - =F4^(3/2)/(3^(1/2) 5^(1/4)))]; ci[n_] := 2 Cos[n Pi/30]; r1 = a/ci[9]; r2 = b/ci[9]; r3 = c/ci[9]; r4 = d/ci[9]; r5 = a/ci[3]; r6 = b/ci[3]; r7 = c/ci[3]; r8 = d/ci[3]; Ac[n_] := {r1 =F9^(2 n), r4 =F9^(22 n), r6 =F9^(14 n + 1), r7 =F9^(26 n + 1) }; Bc[n_] := {r2 =F9^(2 n + 29), r3 =F9^(22 n + 19), -r8 =F9^(14 n + 24), -r5 =F9^(26 n + 18) }; Cc[n_] := {r3 =F9^(2 n + 29), -r2 =F9^(22 n + 19), r5 =F9^(14 n + 24), -r8 =F9^(26 n + 18) }; Dc[n_] := {r4 =F9^(2 n), -r1 =F9^(22 n), r7 =F9^(14 n + 1), -r6 =F9^(26 n= + 1) }; Ec[n_] := {r5 =F9^(2 n), r8 =F9^(22 n), -r2 =F9^(14 n + 1), -r3 =F9^(26 n= + 1) }; Fc[n_] := {r6 =F9^(2 n + 29), r7 =F9^(22 n + 19), r4 =F9^(14 n + 24), r1 =F9^(26 n + 18) }; Gc[n_] := {r7 =F9^(2 n + 29), -r6 =F9^(22 n + 19), -r1 =F9^(14 n + 24), r4 =F9^(26 n + 18) }; Hc[n_] := {r8 =F9^(2 n), -r5 =F9^(22 n), -r3 =F9^(14 n + 1), r2 =F9^(26 n= + 1) }; ptsA = Table[ Flatten[Table[{N[Re[Ac[n][[i]]]], N[Im[Ac[n][[i]]]]}, {i, 1, 4}]], {n, 0, 29}]; ptsB = Table[ Flatten[Table[{N[Re[Bc[n][[i]]]], N[Im[Bc[n][[i]]]]}, {i, 1, 4}]], {n, 0, 29}]; ptsC = Table[Flatten[Table[{N[Re[Cc[n][[i]]]], N[Im[Cc[n][[i]]]]}, {i, 1, 4}]], {n, 0, 29}]; ptsD = Table[Flatten[Table[{N[Re[Dc[n][[i]]]], N[Im[Dc[n][[i]]]]}, {i, 1, 4}]], {n, 0, 29}]; ptsE = Table[Flatten[Table[{N[Re[Ec[n][[i]]]], N[Im[Ec[n][[i]]]]}, {i, 1, 4}]], {n, 0, 29}]; ptsF = Table[Flatten[Table[{N[Re[Fc[n][[i]]]], N[Im[Fc[n][[i]]]]}, {i, 1, 4}]], {n, 0, 29}]; ptsG = Table[Flatten[Table[{N[Re[Gc[n][[i]]]], N[Im[Gc[n][[i]]]]}, {i, 1, 4}]], {n, 0, 29}]; ptsH = Table[Flatten[Table[{N[Re[Hc[n][[i]]]], N[Im[Hc[n][[i]]]]}, {i, 1, 4}]], {n, 0, 29}]; pts = Join[ptsA, ptsB, ptsC, ptsD, ptsE, ptsF, ptsG, ptsH]; This should provide a table with 240 rows and 8 columns. The data will be used for an 8D modeling project in Second Life. === Subject: Re: Can someone run this code to give me coordinates? > =F4 = (1/2) (1 + Sqrt[5]); > =F9 = Exp[I Pi / 30]; > a = Sqrt[(1/2) (1 + =F4^(3/2)/(3^(1/2) 5^(1/4)))]; [...] My newsreader as well as the web interface to Google Groups render some of the symbol names as =F4 or =F9. Preferably, you should post the expressions in *InputForm*. To do so, select the cell(s) you want to include in your email, then within the *Cell* menu select either *Convert To* or *Display As* and choose *InputForm*. Finally, copy and paste as usual. - Jean-Marc === Subject: Re: Is this so hard? Ram. === Subject: usage of TrigToExp? Results from function TrigToExp seemed weird to me. Could anyone In[41]:= TrigToExp[Cos[2 x]] During evaluation of In[41]:= Nonreal::warning: Nonreal number encountered. Out[41]= Nonreal In[43]:= TrigToExp[Cos[y] Sin[x]] Out[43]= 0 Zatuch === Subject: Re: usage of TrigToExp? Zatuch > I suspect you've given x a value, but I'm not sure what value would give > those results. TrigToExp[Cos[2 x]] 1/2 E^(-2 I x) + 1/2 E^(2 I x) TrigToExp[Cos[y] Sin[x]] 1/4 I (E^(-I x) - E^(I x)) (E^(-I y) + E^(I y)) Bobby >> Results from function TrigToExp seemed weird to me. Could anyone > In[41]:= TrigToExp[Cos[2 x]] >> During evaluation of In[41]:= Nonreal::warning: Nonreal number >> encountered. >> Out[41]= Nonreal > In[43]:= TrigToExp[Cos[y] Sin[x]] >> Out[43]= 0 > Zatuch > -- > DrMajorBob@longhorns.com > === Subject: Re: usage of TrigToExp? Zatuch, I don't get these errors. Have you tried this on a clean kernel? Which version are you using? > Results from function TrigToExp seemed weird to me. Could anyone In[41]:= TrigToExp[Cos[2 x]] > During evaluation of In[41]:= Nonreal::warning: Nonreal number > encountered. > Out[41]= Nonreal In[43]:= TrigToExp[Cos[y] Sin[x]] > Out[43]= 0 Zatuch === Subject: Re: usage of TrigToExp? in some of your init.m files you load probably the RealOnly.m package http://library.wolfram.com/infocenter/MathSource/6771/ and this cause the problem. Remove it and all work as expected. Your system behave not as a clean Mathematica. Jens > Results from function TrigToExp seemed weird to me. Could anyone In[41]:= TrigToExp[Cos[2 x]] > During evaluation of In[41]:= Nonreal::warning: Nonreal number > encountered. > Out[41]= Nonreal In[43]:= TrigToExp[Cos[y] Sin[x]] > Out[43]= 0 Zatuch > === Subject: Re: usage of TrigToExp? > Results from function TrigToExp seemed weird to me. Could anyone In[41]:= TrigToExp[Cos[2 x]] > During evaluation of In[41]:= Nonreal::warning: Nonreal number > encountered. > Out[41]= Nonreal In[43]:= TrigToExp[Cos[y] Sin[x]] > Out[43]= 0 It looks as though you loaded the old Miscellanous`RealOnly package. Try again in a fresh session, without loading RealOnly. -- Helen Read University of VErmont === Subject: Re: usage of TrigToExp? I suspect you've given x a value, but I'm not sure what value would give those results. TrigToExp[Cos[2 x]] 1/2 E^(-2 I x) + 1/2 E^(2 I x) TrigToExp[Cos[y] Sin[x]] 1/4 I (E^(-I x) - E^(I x)) (E^(-I y) + E^(I y)) Bobby > Results from function TrigToExp seemed weird to me. Could anyone In[41]:= TrigToExp[Cos[2 x]] > During evaluation of In[41]:= Nonreal::warning: Nonreal number > encountered. > Out[41]= Nonreal In[43]:= TrigToExp[Cos[y] Sin[x]] > Out[43]= 0 Zatuch > -- DrMajorBob@longhorns.com === Subject: Re: usage of TrigToExp? > Results from function TrigToExp seemed weird to me. Could anyone In[41]:= TrigToExp[Cos[2 x]] > During evaluation of In[41]:= Nonreal::warning: Nonreal number > encountered. > Out[41]= Nonreal In[43]:= TrigToExp[Cos[y] Sin[x]] > Out[43]= 0 It is very likely that that x and y have been assigned some values Clear[x,y], or x =. and y. or start a fresh kernel. In[1]:= TrigToExp[Cos[2 x]] Out[1]= 1/2 E^(-2 I x) + 1/2 E^(2 I x) In[2]:= TrigToExp[Cos[y] Sin[x]] Out[2]= 1/4 I (E^(-I x) - E^(I x)) (E^(-I y) + E^(I y)) --Jean-Marc === Subject: Re: Solve / NSolve the equations you were referring to are from an earlier post of mine from 3 months or so ago. What I talk about now is this: derData = Function[{data, h}, (Drop[data, 2] - Drop[data, -2])/(2 h)]; huygTemp = Function[{a, b, c, t0, t, r0, dphi}, Module[{x0 = r0[[1]], y0 = r0[[2]], x1, y1, dx0, dy0, eq1, eq2, sol, pos, drop, x2, y2}, dx0 = derData[x0, dphi]; dy0 = derData[y0, dphi]; x0 = Delete[x0, {{1}, {-1}}]; y0 = Delete[y0, {{1}, {-1}}]; eq1 = Equal[#, 1] & /@ ((x - x0)^2/(a t)^2 + (y - y0 - c t)^2/(b t)^2); eq2 = Equal[#, 0] & /@ (-2 dx0 (x - x0)/(a t)^2 - 2 dy0 (y - y0 - c t)/(b t)^2); sol = NSolve[#, {x, y}] & /@ (Transpose[{eq1, eq2}]); x1 = x /. sol; drop = Flatten@Position[Flatten[Differences /@ x1], x_ /; x == 0]; y1 = y /. sol; pos = Ordering[Abs[#], -1] & /@ x1; x2 = MapThread[Extract, {x1, pos}]; y2 = MapThread[Extract, {y1, pos}]; If[ drop != {}, y2[[drop]] = MapThread[Extract, {y1[[drop]], Ordering[Abs[#], -1]& /@ (Transpose@y1[[drop]])}] ]; {x2, y2} = Join[{#[[-2]]}, #, {#[[2]]}] & /@ {x2, y2} ] ]; Module[{a = 1, b = 2, c = 1, t0 = 1/100, t = 1/10, r0, phi, dphi = 2 [Pi]/50, front, fun, x1, y1, drop, pos, x2, y2}, phi = N@Range[-dphi, 2 [Pi] + dphi, dphi]; r0 = {a t0 Cos[phi], b t0 Sin[phi] + c t0}; fun = huygTemp[a, b, c, t0, t, #, dphi] &; front = Nest[fun, r0, 10] // Timing; {First@front, ListPlot[Transpose@Last@front]} ] Here I would like some comments on the use of NSolve vs. the use of Solve in the huygTemp function above. It seems that NSolve produces more reliable results (as well as results that I would call correct), but doing so in a significantly longer time than Solve uses to yield a solution, albeit this solution is not what I would perceive as the correct solution for my problem. Some of your comments, Andrzej, have probably already covered part of what I'm asking about. Would you, Andrzej, as well as others, mind to take a look at this. Sigmund > In your second case there are no parameters and Solve and NSolve use >> different algorithms. Solve rationalizes the equations and uses exact >> GroebnerBasis, NSolve uses numerical Groebner basis. The first approach is >> faster in this case but the second approach shoudl be more reliable in cases >> involving numerical instability. > > misleading. So I have decided to send a little more detailed explanation > with the hope that it can be of some use. > The standard method of solving systems of polynomial equations with exact > coefficient is based on an algebraic algorithm called the Groebner basis > algorithm. This is the algorithm used by Solve. Unfortunately, like most > exact algebraic algorithms it has rather high complexity. One might hope > that in cases when one only needs approximate solutions (particularly when > the coefficients of the system are approximate anyway) there would be a > faster numerical method. Unfortunately the GroebnerBasis algorithm is > numerically unstable and in unfavorable cases a small perturbation in the > coefficients of the system will lead to a very different solution. Thus the > algorithm cannot be used reliably with fixed precision arithmetic (and in > particular with MachinePrecision). > The obvious approach, adopted by most computer algebra systems is this: > given a polynomial system with inexact coefficients, first rationalize it, > then use the exact Groebner basis algorithm to find solutions and finally > apply N with the requested precision. This is exactly what Solve does. This > method is effective except for a minor problem that rationalizing is not a > unique operation so in unstable situation different rationalizations will > give different results and a more serious problem that this approach will be > impossibly slow on more complex systems. > Mathematica offers also another approach, based on its significance > arithmetic (a fast approximation to interval arithmetic) that in many > situations can overcome both problems. Essentially the precision of > computations is automatically increased until GroebnerBasis computations > produce a stable answer. On complex problems this is usually faster than > using exact Grobner basis on a rationalized system, but it can be slower in > the case of simple systems. > NSolve uses this approach, but I am not quite sure if it does it only when > WorkingPrecision other than MachinePrecision is used or always. > In any case, the general principle is: avoid if possible using symbolic > functions (and that includes Simplify etc) on input containing inexact > quantities as the results can be quite different form what you might expect. Andrzej Kozlowski -- Sigmund Vestergaard, M.Sc.Eng. student R=E6veh=F8jvej 36, 1., -611 DK-2800 Kongens Lyngby Denmark === Subject: Re: Solve / NSolve > In your second case there are no parameters and Solve and NSolve use > different algorithms. Solve rationalizes the equations and uses > exact GroebnerBasis, NSolve uses numerical Groebner basis. The first > approach is faster in this case but the second approach shoudl be > more reliable in cases involving numerical instability. misleading. So I have decided to send a little more detailed explanation with the hope that it can be of some use. The standard method of solving systems of polynomial equations with exact coefficient is based on an algebraic algorithm called the Groebner basis algorithm. This is the algorithm used by Solve. Unfortunately, like most exact algebraic algorithms it has rather high complexity. One might hope that in cases when one only needs approximate solutions (particularly when the coefficients of the system are approximate anyway) there would be a faster numerical method. Unfortunately the GroebnerBasis algorithm is numerically unstable and in unfavorable cases a small perturbation in the coefficients of the system will lead to a very different solution. Thus the algorithm cannot be used reliably with fixed precision arithmetic (and in particular with MachinePrecision). The obvious approach, adopted by most computer algebra systems is this: given a polynomial system with inexact coefficients, first rationalize it, then use the exact Groebner basis algorithm to find solutions and finally apply N with the requested precision. This is exactly what Solve does. This method is effective except for a minor problem that rationalizing is not a unique operation so in unstable situation different rationalizations will give different results and a more serious problem that this approach will be impossibly slow on more complex systems. Mathematica offers also another approach, based on its significance arithmetic (a fast approximation to interval arithmetic) that in many situations can overcome both problems. Essentially the precision of computations is automatically increased until GroebnerBasis computations produce a stable answer. On complex problems this is usually faster than using exact Grobner basis on a rationalized system, but it can be slower in the case of simple systems. NSolve uses this approach, but I am not quite sure if it does it only when WorkingPrecision other than MachinePrecision is used or always. In any case, the general principle is: avoid if possible using symbolic functions (and that includes Simplify etc) on input containing inexact quantities as the results can be quite different form what you might expect. Andrzej Kozlowski === Subject: Re: Solve / NSolve > between Solve and NSolve. Have any of you tried to run the code i > provided (including the missing function definition which I provided > later)? I'm aware that Solve and NSolve do not use the same algorithm > to solve an equation, but it does not seem logical to me that they > don't give the same solution to the same system of algebraic > equations. What could be the reason for this? I'm also concerned witht > he speed. Solve is much faster than NSolve for my problem. How come? > In addition to the code I provided earlier, I just tried with another > example of a system of two algebraic equations: {1.1 x^2 + y^2 == 1.0, x + 1.1 y == 0.0} > Solve[%, {x, y}] // Timing > NSolve[%%, {x, y}] // Timing When evaluating this cell you'll see that Solve is substantially > faster than NSolve, but they yield the same solution. However, in my > first example they do not yield the same solution in all cases. Hopefully some of you can shed some light on all this. It could also > be me comparing apples and oranges. Let me hear your thoughts on all > this. Sigmund This is a bit of a tangle. One thing you probably do not realize is that people using version 7 get different behavior from you. Specifically, the Solve variant will give a slew of error messages due to badness in your Drop code. I isolated a simple example that shows this difference, and I'll cover it below because it also serves, to an extent, to show why NSolve is safer for a problem like this even in absence of such error messages. polys = {100*(-0.11 + x)^2 + 25*(-0.21 + y)^2 - 1, (-1.8774107494749928*(-0.11 + x))/10^13 - 10.971072010497574*(-0.21 + y)}; Mathematica 6: In[12]:= Solve[polys==0, {x, y}] Out[12]= {{x -> 0.0785768, y -> 0.21}, {x -> 0.139692, y -> 0.21}} Mathematica 7: In[13]:= Solve[polys==0, {x, y}] Out[13]= {{x -> 0.109135, y -> 0.21}, {x -> 0.109135, y -> 0.21}} Observe that the latter claims a double root whereas the x coordinates in the former are well separated. So let me say a bit about what Solve does. It starts by rationalizing all coefficients and computing an exact Groebner basis. In both versions this is similarly handled, although the rationalization is different in a way that is irrelevant for the present discussion. It then feeds a univariate polynomial to a numerical root finder. In version 6 and prior this was Jenkins-Traub. In version 7 I believe this is no longer the case, at least by default. Here is the univariate polynomial produced by one of the versions. I will show the resulting roots in both versions. upoly = -1.049020730058627*^75*y + 2.4976684049014928*^75*y^2 + 1.1014717665615586*^74; Mathematica 6: In[17]:= InputForm[Roots[upoly==0, y]] Out[17]//InputForm= y == 0.20999999999999952 || y == 0.21000000000000058 Mathematica 7: In[16]:= InputForm[Roots[upoly==0, y]] Out[16]//InputForm= y == 0.21000000000000002 || y == 0.21000000000000002 In the first case the roots are separated slightly, and in the second they are not. This extremely small difference is what messes up later computations of x; the small root difference gets magnified by some large coefficients in the polynomial(s) that relate x to y, so the x values get separated in version 6. Clearly when the y values are identical this will not happen. I do not view this as a bug in the new root finding code. It may well be a bug fix, in that the code now only tries to return digits that are justifiable by the input precision. The bad handling, if any, is in Solve, in rationalizing and then finding a Groebner basis. Reason being, this can make numerator coefficients huge, thus introducing numeric instability. Huge coefficients pose no problem in principle, when doing exact computation (the domain of Solve). For approximate error downstream (e.g. in numeric handling of Roots). As for speed, I can say a bit. This particular equation set is fast to handle, and Solve manages to beat NSolve in timing. That is by no means always the case, and is quite rare for most polynomial systems that come my way. Moreover even in version 6, the Solve solution is garbage (check the residuals), hence your bad pictures. It is just not garbage with spurious multiplicity, hence does not run afoul of the Drop code. In contrast, the NSolve solution gives small residuals. Probably worth spending a bit more time in that code, if it is better suited to handle the problem. Daniel Lichtblau Wolfram Research === Subject: Re: Solve / NSolve Actually, the problem in your original example has virtually nothing to do with the difference between NSolve and Solve. In fact, NSolve is not used in your example at all. The reason is that when you call NSolve with equations involving parameters all it does is to refer your equations to Solve and then apply N. Just compare: Solve[{f[1, 2, 1/2, 4/5, t], df[1, 2, 1/2, 4/5, t]}, {x, y}] // N with NSolve[{f[1, 2, 1/2, 4/5, t], df[1, 2, 1/2, 4/5, t]}, {x, y}] where f is the function in your original post. You will see that you get essentially the same answer arranged in a somewhat different way. So the difference between your final answers derives from the order in which N and and Power Expand Simplify are applied. In the first case you perform algebraic operations first and apply N last, in the second case you apply N before algebraic operations. The second approach is definitely not the thing to do, since once you expression is no longer exact algebraic transformations cannot be performed exactly. In your second case there are no parameters and Solve and NSolve use different algorithms. Solve rationalizes the equations and uses exact GroebnerBasis, NSolve uses numerical Groebner basis. The first approach is faster in this case but the second approach shoudl be more reliable in cases involving numerical instability. Andrzej Kozlowski > between Solve and NSolve. Have any of you tried to run the code i > provided (including the missing function definition which I provided > later)? I'm aware that Solve and NSolve do not use the same algorithm > to solve an equation, but it does not seem logical to me that they > don't give the same solution to the same system of algebraic > equations. What could be the reason for this? I'm also concerned witht > he speed. Solve is much faster than NSolve for my problem. How come? > In addition to the code I provided earlier, I just tried with another > example of a system of two algebraic equations: {1.1 x^2 + y^2 == 1.0, x + 1.1 y == 0.0} > Solve[%, {x, y}] // Timing > NSolve[%%, {x, y}] // Timing When evaluating this cell you'll see that Solve is substantially > faster than NSolve, but they yield the same solution. However, in my > first example they do not yield the same solution in all cases. Hopefully some of you can shed some light on all this. It could also > be me comparing apples and oranges. Let me hear your thoughts on all > this. Sigmund > === Subject: Re: How to modify an Excel file I tried to work out the example you have given in your earlier e-mail. It works fine until the following point... but then I am not able to get the Charts properly as I receive $Failed commands and it seems that I face with exceptions but I do not know how to deal with these exceptions. Could you tell me if you know.. Tugrul ************************************************* You can even create a chart: chartCastSep = CastNETObject[workbook[Charts[][Add[]]], Microsoft.Office.Interop.Excel.ChartClass] chartCastSep@ChartWizard[srcRange]; If you prefer a XY scatter plot then: LoadNETType[Microsoft.Office.Interop.Excel.XlChartType] chartCastSep[ ChartWizard[srcRange, XlChartType`xlXYScatter, format = 1, plotBy = 2, catLab = 1, serLab = 0, hasLegend = True, Title, CategoryTitle, ValueTitle, ExtraTitle]] ************************************************* === Subject: Re: How to modify an Excel file > Excel files, and they work fine. The only problem is that, as far as I > understood, they cannot work with cell formats. This means that I > could not find a way to import an Excel file, modify a cell and then > export it in a new file with the same formatting as the original. Is there, to your knowledge, a way to let Mathematica write a value in > a cell of an existing Excel file without using Excel Link and > without modifying the cell's format? I have both Mathematica and Excel installed on my PC. Hope some of you has a solution! > Hello You can write directly in an existing Excel file using NETLink. For details see the documentation in the Help Browser at NETLink/tutorial/ Overview. I recommend to run the example ExcelPieChart.nb. If everything works OK you are ready to attack your problem. The following commands will load the package, install NET, start Excel, make it visible and start a dialog Window to open an existing Excel file: Needs[NETLink`] InstallNET[] excel = CreateCOMObject[Excel.Application] If[ ! NETObjectQ[excel], Return[$Failed]] excel[Visible] = True excel[FindFile[]] This selects the Excel Workbook and Excel Worksheet (here the first worksheet): workbook = excel[Workbooks[1]] worksheet = excel[Workbooks[1][Worksheets[1]]] worksheet[Range[A1][Value]] = Primzahlen; worksheet[Range[A1][Font[Bold]]] = True; This specifies a range: start = B3; cols = 2; rows = 10; srcRange = worksheet@Range[start]@Resize[rows, cols] values = Table[{i^2, Prime[i]}, {i, rows}]; srcRange@Value = values; You can even create a chart: chartCastSep = CastNETObject[workbook[Charts[][Add[]]], Microsoft.Office.Interop.Excel.ChartClass] chartCastSep@ChartWizard[srcRange]; If you prefer a XY scatter plot then: LoadNETType[Microsoft.Office.Interop.Excel.XlChartType] chartCastSep[ ChartWizard[srcRange, XlChartType`xlXYScatter, format = 1, plotBy = 2, catLab = 1, serLab = 0, hasLegend = True, Title, CategoryTitle, ValueTitle, ExtraTitle]] With some Excel knowledge you can even read and write the formula in the Excel cells or read and write Excel Macro code. I hope this helps and good luck. Norbert Marxer === Subject: Re: Trivial question You will get a lot of answers to this. Apply[Times, e] I would probably not use 'e' as your variable name though, too easy to confuse with E. Michael > I haven't used Mathematica for a year so I've forgotten a lot. > I want to take the product of elements in a list of definite length. > e={e1,e2,e3, ... ,e13} (13 could be anything) > I want e1 e2 .... e13. In other words like Total[e]=e1+e2... Steve Gray === Subject: Re: Trivial question Times@@e Bobby > I haven't used Mathematica for a year so I've forgotten a lot. > I want to take the product of elements in a list of definite length. > e={e1,e2,e3, ... ,e13} (13 could be anything) > I want e1 e2 .... e13. In other words like Total[e]=e1+e2... Steve Gray > -- DrMajorBob@longhorns.com === Subject: Re: Trivial question >I haven't used Mathematica for a year so I've forgotten a lot. I >want to take the product of elements in a list of definite length. >e={e1,e2,e3, ... ,e13} (13 could be anything) I want e1 e2 .... >e13. In other words like Total[e]=e1+e2... This is done using Apply and Times, i.e. Times@@e which is shorthand for Apply[Times,e] === Subject: Re: Trivial question e = {e1, e2, e3, e4, e5}; Times @@ e e1 e2 e3 e4 e5 which is shorthand for Apply[Times, e] e1 e2 e3 e4 e5 Bob Hanlon I haven't used Mathematica for a year so I've forgotten a lot. I want to take the product of elements in a list of definite length. e={e1,e2,e3, ... ,e13} (13 could be anything) I want e1 e2 .... e13. In other words like Total[e]=e1+e2... Steve Gray -- Bob Hanlon === At the risk of being perceived as a philosophical apologist (!), I will share with you my thinking on these topics, i.e., Mathematica's ballooning command set. (The syntax has not changed much since the earliest versions.) First, I think it's important to realize that there is a beautiful unified structure to everything, so that one can remain pure and just use this structure. This approach avoids having to learn to much syntax. For example, in place of: x^2 /. x -> 5 One can use: ReplaceAll[Power[x,2],Rule[x,5]] (which can be obtained from Hold[x^2 /. x -> 5] // FullForm) Now, what's my point here? For the 95% of the program that one uses rarely, just stay in the full syntax to keep your mind straight. However, for the 5% of the program that one uses a lot, you can pull out of the box all of the Prefix, Infix, Postfix, etc., operators (@, @@, @@@, /@, &, //, ~, ...) that are useful to your personal purpose for using Mathematica. These syntax shortcuts can save you a lot of time. I also have a second point. Many of the new commands are really just shortcuts. If you find yourself using Total[] a lot, then it's a good command to know. But if you didn't know that command, you'd just go back to the stanby of Plus@@{1,2,3}. Many of the new commands are mostly useful to a small set of specialized users, IMHO, and there are a few new commands that are useful for my specialized applications, and I really appreciate them. In particular, all of the arcane formats in Import[] are really great for me because I use a lot of scientific and technical formats. The Dynamic[] command with the user interface elements was also a big boon for me. Now, there is the question of, What about the new Mathematica user? How should this person know about the basic commands without being overwhelmed with everything? In that regard, Wolfram might add another tab to its multidimensional Help screen, entitled something along the lines of, Solid Basics in Mathematica. > Entering ?[P*] gives a formated reference list of >> all Special Character names such as [Pi] which match. >> ?[*Phi] matches [CapitalPhi], [CurlyPhi] and [Phi]. > ---- MUCH snipped ---- > x [Equivalent] y is by default interpreted as Equivalent[x,y]. >> x [Xnor] y is by default interpreted as Xnor[x,y]. >> x [Function] y is by default interpreted as Function[x,y]. > Q.E.D. > I'm dazzled -- but also dismayed -- by your knowledge on these matters. > I saw a note the other day that the average reasonably well educated > English speaker has a total vocabulary in the range of 20,000 words, or > perhaps somewhat larger. Mathematica at this point seems well on the > way to having a comparable number of commands, symbols, notations, > operators, options, special characters, and so on in its own vocabulary. > Ordinary users of Mathematica may have to give up all the other activities in > their life, aside from eating and sleeping, just to learn Mathematica. complete list (hopefully _with definitions_ and in printable form), for > _all_ of the non-alphabetic operators and programming thingies > (whatever they're called technically) like ., ., ->, &, @, @, &&, &&&, etc, etc, etc that can appear in Mathematica Input cell commands? It would be very > useful. --AES [And, is HowTo itself now a Mathematica command or symbol?] === alternatively, Wolfram could simply document the product Mathematica ? Peter 2009/1/17 AES : > Entering ?[P*] gives a formated reference list of >> all Special Character names such as [Pi] which match. >> ?[*Phi] matches [CapitalPhi], [CurlyPhi] and [Phi]. > ---- MUCH snipped ---- > x [Equivalent] y is by default interpreted as Equivalent[x,y]. >> x [Xnor] y is by default interpreted as Xnor[x,y]. >> x [Function] y is by default interpreted as Function[x,y]. > Q.E.D. > I'm dazzled -- but also dismayed -- by your knowledge on these matters. > I saw a note the other day that the average reasonably well educated > English speaker has a total vocabulary in the range of 20,000 words, or > perhaps somewhat larger. Mathematica at this point seems well on the > way to having a comparable number of commands, symbols, notations, > operators, options, special characters, and so on in its own vocabulary. > Ordinary users of Mathematica may have to give up all the other activities in > their life, aside from eating and sleeping, just to learn Mathematica. complete list (hopefully _with definitions_ and in printable form), for > _all_ of the non-alphabetic operators and programming thingies > (whatever they're called technically) like ., ., ->, &, @, @, &&, &&&, etc, etc, etc that can appear in Mathematica Input cell commands? It would be very > useful. --AES [And, is HowTo itself now a Mathematica command or symbol?] -- === > Entering ?[P*] gives a formated reference list of > all Special Character names such as [Pi] which match. > ?[*Phi] matches [CapitalPhi], [CurlyPhi] and [Phi]. ---- MUCH snipped ---- x [Equivalent] y is by default interpreted as Equivalent[x,y]. > x [Xnor] y is by default interpreted as Xnor[x,y]. > x [Function] y is by default interpreted as Function[x,y]. Q.E.D. I'm dazzled -- but also dismayed -- by your knowledge on these matters. I saw a note the other day that the average reasonably well educated English speaker has a total vocabulary in the range of 20,000 words, or perhaps somewhat larger. Mathematica at this point seems well on the way to having a comparable number of commands, symbols, notations, operators, options, special characters, and so on in its own vocabulary. Ordinary users of Mathematica may have to give up all the other activities in their life, aside from eating and sleeping, just to learn Mathematica. complete list (hopefully _with definitions_ and in printable form), for _all_ of the non-alphabetic operators and programming thingies (whatever they're called technically) like ., ., ->, &, @, @, &&, &&&, etc, etc, etc that can appear in Mathematica Input cell commands? It would be very useful. --AES [And, is HowTo itself now a Mathematica command or symbol?] === Entering ?[P*] gives a formated reference list of > all Special Character names such as [Pi] which match. > ?[*Phi] matches [CapitalPhi], [CurlyPhi] and [Phi]. ---- MUCH snipped ---- x [Equivalent] y is by default interpreted as Equivalent[x,y]. > x [Xnor] y is by default interpreted as Xnor[x,y]. > x [Function] y is by default interpreted as Function[x,y]. Q.E.D. > I'm dazzled -- but also dismayed -- by your knowledge on these matters. You vastly over-estimate my faculties. You can say that of Michael Trott from Wolfram and his four volume The Mathematica GuideBook for ... books published by Springer-Verlag. > I saw a note the other day that the average reasonably well educated > English speaker has a total vocabulary in the range of 20,000 words, or > perhaps somewhat larger. Mathematica at this point seems well on the > way to having a comparable number of commands, symbols, notations, > operators, options, special characters, and so on in its own vocabulary. > Ordinary users of Mathematica may have to give up all the other activities > in their life, aside from eating and sleeping, just to learn Mathematica. complete list (hopefully _with definitions_ and in printable form), for > _all_ of the non-alphabetic operators and programming thingies > (whatever they're called technically) like ., ., ->, &, @, @, &&, &&&, etc, etc, etc that can appear in Mathematica Input cell commands? It would be very > useful. --AES I would refer you to the guide/Syntax page. But to get exactly what I think you want is easy enough. Just evaluate the following in version 6 or 7: Style[Grid[{#[[1]], Hyperlink[#[[2]], paclet:ref/ <> #[[2]]], ToExpression[#[[2]] <> ::usage]} & /@ Most[System`Dump`$functionNameTable[[1]]], Alignment -> {{Center, Left, Left}}, Frame -> All, Background -> {{Pink, None}, {{LightGreen, LightBlue}}}], FontFamily -> sans-serif, FontSize -> 11] [And, is HowTo itself now a Mathematica command or symbol?] > No, HowTo is just intended to be a moniker to allow for an easy search. Q.E.D. === Subject: Re: Taking LCM in a polynomial expression > I have a symbolic matrix that I invert. When I take each individual > entry of the resulting matrix, I get an expression of the form: > num1/den1 + num2/den1 + .... + num_n/den1 > where den1 is the determinant of the matrix. I'd like to get an > expression of the form: > Num/Den. I tried using Simplify (as well as multiplying the matrix by its > determinant), but it doesn't seem to help. Any suggestions? On a related note, the final Num is a polynomial in two variables - > say x,y. I'd like to arrange it in decreasing powers of x - like f1(y) > x^n + f2(y) x^n-1... + constant. What function should use? Is there > any way to both in a single step? You can use *Together* (or *Factor*) to get a single rational expression. You can use *TraditionalForm* to display polynomials in textbook fashion. For instance, In[1]:= expr = (x^3 + 2 x^2 - y)/(x^2 - 4 y^2) - (x + 2)/(x^2 - 4 y^2) Together[expr] Factor[expr] % // TraditionalForm Out[1]= 2 3 2 + x 2 x + x - y -(---------) + ------------- 2 2 2 2 x - 4 y x - 4 y Out[2]= 2 3 -2 - x + 2 x + x - y ---------------------- 2 2 x - 4 y Out[3]= 2 3 -2 - x + 2 x + x - y ---------------------- (x - 2 y) (x + 2 y) Out[4]= 3 2 x + 2 x - x - y - 2 --------------------- (x - 2 y) (x + 2 y) --Jean-Marc === Subject: Re: Taking LCM in a polynomial expression > Hi > I have a symbolic matrix that I invert. When I take each individual > entry of the resulting matrix, I get an expression of the form: > num1/den1 + num2/den1 + .... + num_n/den1 > where den1 is the determinant of the matrix. I'd like to get an > expression of the form: > Num/Den. I tried using Simplify (as well as multiplying the matrix by its > determinant), but it doesn't seem to help. Any suggestions? On a related note, the final Num is a polynomial in two variables - > say x,y. I'd like to arrange it in decreasing powers of x - like f1(y) > x^n + f2(y) x^n-1... + constant. What function should use? Is there > any way to both in a single step? Srikanth As mentioned in tutorial/PolynomialOrderings, in version 7 it's possible to control the sorting of polynomial terms/factors to some extent in TraditionalForm output: In[1]:= x y^2 + x^2 y + 1 // TraditionalForm[#, ParameterVariables :> {y}]& Out[1]//TraditionalForm= y x^2+y^2 x+1 Maxim Rytin m.r@inbox.ru === Subject: Re: Intermediate computational results > I have a mathematical expression and I have to demonstrate a real world > example - an actual computation using the formula. > For that purpose I'd like to show all intermediate steps, not just the > final result. > Is there a way to tell Mathematica to do one step at a time and not just > show the final result? For example A=B+CD > B=10 > C=11 > D=12 A=10+11x12=10+132=142 In other words I wouldn't like to type in all the equations with the > exact numerical values. AFAIK, there exists no built-in mechanism (as of Mathematica 6.0.3) that straightforwardly allow users to do step by step manipulations. (Step by step expressions can be generated by a combination of *Holdxxx* functions and/or replacement rules.) I believe that the easiest mechanism to manipulate and display intermediate expressions can be found in David Park's *Presentation* package. Check his web site at http://home.comcast.net/~djmpark/DrawGraphicsPage.html --Jean-Marc === Subject: Re: Intermediate computational results Trace or TracePrint will show intermediate steps, but they may be not quite what you want. > I have a mathematical expression and I have to demonstrate a real world > example - an actual computation using the formula. > For that purpose I'd like to show all intermediate steps, not just the > final result. > Is there a way to tell Mathematica to do one step at a time and not just > show the final result? For example A=B+CD > B=10 > C=11 > D=12 A=10+11x12=10+132=142 In other words I wouldn't like to type in all the equations with the > exact numerical values. === Subject: Re: Intermediate computational results Perhaps Trace does what you want. In[2]:= Trace[A=B+C*D /.{B->10,C->11,D->12}] Out[2]= {{B+C D/.{B->10,C->11,D->12},10+11 12,{11 12,132},10+132,142},A=142,142} Richard Hofler Professor Department of Economics -----Original Message----- === Subject: Intermediate computational results I have a mathematical expression and I have to demonstrate a real world example - an actual computation using the formula. For that purpose I'd like to show all intermediate steps, not just the final result. Is there a way to tell Mathematica to do one step at a time and not just show the final result? For example A=B+CD B=10 C=11 D=12 A=10+11x12=10+132=142 In other words I wouldn't like to type in all the equations with the exact numerical values. === Subject: Re: Intermediate computational results The Presentations package has routines EvaluateAt and EvaluateAtPattern for evaluating held expressions in a controlled manner. It also has facilities for creating formatted displays in any format, including graphics and dynamic elements, and hiding all the Input specifications. An example using a two column display with comments on one side and output on the other side (with tooltips that show the Input statements) will be posted on Peter Lindsay's site: Peter Lindsay at the Mathematical Institute in the University of St Andrews [ www.mcs.st-and.ac.uk ] has kindly undertaken to maintain an archive that provides downloadable notebooks and PDF files for various Presentations solutions that have appeared on MathGroup. http://blackbook.mcs.st-and.ac.uk/~Peter/djmpark/html/ David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have a mathematical expression and I have to demonstrate a real world example - an actual computation using the formula. For that purpose I'd like to show all intermediate steps, not just the final result. Is there a way to tell Mathematica to do one step at a time and not just show the final result? For example A=B+CD B=10 C=11 D=12 A=10+11x12=10+132=142 In other words I wouldn't like to type in all the equations with the exact numerical values. === Subject: Re: Intermediate computational results Trace[] ?? may help. Jens > I have a mathematical expression and I have to demonstrate a real world > example - an actual computation using the formula. > For that purpose I'd like to show all intermediate steps, not just the > final result. > Is there a way to tell Mathematica to do one step at a time and not just > show the final result? For example A=B+CD > B=10 > C=11 > D=12 A=10+11x12=10+132=142 In other words I wouldn't like to type in all the equations with the > exact numerical values. === Five usage messages show error icons in version 7 when evaluated. Two of them also display pink error boxes and also manifest in version 6. Demonstate the errors by evaluating the following: Length[Print[ToExpression[# <> ::usage]]; & /@ {FontName, $PrintServiceRequest, $PrintServiceResponse}] Oddly, evaluating ?Print afterwards causes the three without pink error boxes to have their error icons disappear. When the following is evaluated, notice how the three without pink error boxes have error icons appear and then disappear: Length[Information[#, LongForm -> False] & /@ {FontName, $PrintServiceRequest, $PrintServiceResponse}] Evaluate the following to see what the usage strings look like when fixed: StringReplace[FontName::usage, {Times-Roman->Times-Roman}] { Italic ->Italic}] StringReplace[InvokeServiceOperation::usage, {StyleBox[RowBox[{ , url , }], TI ] -> StyleBox[RowBox[{, url, }], TI, ShowStringCharacters->True](*for version 7*), StyleBox[RowBox[{, url, }], TI] -> StyleBox[RowBox[{, url, }], TI, ShowStringCharacters->True](*for version 6*)}] StringReplace[$PrintServiceRequest::usage, { Italic ->Italic}] StringReplace[$PrintServiceResponse::usage, { Italic ->Italic}] To fix the usage strings in the current session, evaluate: FontName::usage = StringReplace[FontName::usage, {Times-Roman->Times-Roman}]; { Italic ->Italic}]; InvokeServiceOperation::usage = StringReplace[InvokeServiceOperation::usage, {StyleBox[RowBox[{ , url , }], TI ] -> StyleBox[RowBox[{, url, }], TI, ShowStringCharacters->True](*for version 7*), StyleBox[RowBox[{, url, }], TI] -> StyleBox[RowBox[{, url, }], TI, ShowStringCharacters->True](*for version 6*)}]; $PrintServiceRequest::usage = StringReplace[$PrintServiceRequest::usage, { Italic ->Italic}]; $PrintServiceResponse::usage = StringReplace[$PrintServiceResponse::usage, { Italic ->Italic}]; Now evaluate again the following to check that there are no longer any error icons: Length[Information[#, LongForm -> False] & /@ {FontName, $PrintServiceRequest, $PrintServiceResponse}] Note that that the three which do have the extra spaces around the Italic value do not fail in version 6 because those usage messages in version 6 do not have extra spaces around the Italic value. Q.E.D. === Hi Albert, >I wonder what kind of fancy formatting/word processing stuff you are doing to see frequent crashes. Nothing so fancy really, that's the issue. I have a graphic which only takes half the page width and instead of putting it in the middle of the page and leave white spaces on wither side I was trying to save some magazine looks like. That I couldn't figure out how to achieve. In the process I was trying to use a 1x2 matrix as a workaround and found that this approach works for text/text, graphic/graphic but not text/graphic as my text got very poorly formatted without letting me do any further format edits. the other thing was the numbered equations which had a customized style - modified bracketing and additional text displayed. Those I finally managed to work out, but I had issues with the formatting as well - for instance Mathematica would format some of them with the Times New Roman italic font, others with the courier regular font, sizes were a bit different too and resizing the window resulted in my equations being modified automatically by mathematica with no way to undo the changes. Many times I was copy/pasting portions of my equations which resulted in mathematica crashing on me - for a moment I thought there was a problem with the copy paste routine but the next time it would do it without crashing, giving me a chance to hit save. And finally I noticed that if you have an expression with the text style formatting something as simple as 2x100 is displayed properly /a small x is automatically inserted by mathematica/ however if you have 2 100^2 it is displayed as 2100^2 - no solution for that so far. And in a different position if the same document the equation D=(100+100-50)(100-100+50)(-100+100+50) (100+100+50)=93750000 is displayed as D=(10 0+100-50)(100-100+50)(-100+100+50) (100+100+50)=93750000 On the screen it looks like there are 2 extra spaces inserted. Fixing it doesn't really work, because after saving, closing and reopening the document things revert back to their initial state I'm still working on reproducing some of the crashes but so far Im unable to do so >> Although Mathematica 7 is a very powerful peace of software as far as >> the computational part goes it turns out to be quite limited and >> unstable when it comes to word editing and processing, despite the >> claims in the help that it is almost as powerful as WinWord. >> For example it crashed multiple times on me while I was trying to setup >> the right fonts and sizes, as a result I lost all my work several >> times, it also messed up my fonts, sizes, styles, settings for the >> equations, its undo is totally useless and I couldn't figure out how to >> format a text and a graphic in two or more columns and display them side >> by side in a notebook as well as how to control what goes on what page >> and while printing to PDF often it wouldn't print all pages, but just >> the first 2-3. >> If I don't let Notebooks grow too large, the Mathematica Frontend has > been quite stable for me in the last years, so I wonder what kind of > fancy formatting/word processing stuff you are doing to see frequent > crashes... anyway, loosing work is something that should never ever > happen. Have you looked at the stuff David Park is doing with > Mathematica? I think if you don't try too much to force Mathematica > Notebooks to look like printed publications but concentrate on > presenting your content, you can achieve quite a lot (and much that is > not possible on paper!) without hitting Mathematicas dark corners... >> All that said I'm wondering what program to use to write my work in, and >> I'm asking for advice - is WinWord any better when it comes to handling >> equations? >> Any other choices? >> If you are after good word processing capabilities for content to be > printed only and good handling of equations _and_ to be absolutely sure > to not ever loose your work by software crashes again I think there is > still no alternative to TeX/Latex and a stable basic text editor. If you > really need that, there are WYSIWYG frontends for TeX/Latex nowadays but > I have never found these necessary when writing scientific content. >> What is the best way to export Mathematica 7 equations and graphics? >> TeXForm[] or Export[,TeX] for equations, and Export[,EPS] or > probably nowadays PDF for 2D Graphics will usually work well enough, > only for 3D graphics there seem to be problems with the efficiency of > the pdf export, you can find more information in the archives of this > group... hth, albert > === > Hi Albert, >> I wonder what kind of fancy formatting/word processing stuff you are >> doing to see frequent crashes. Nothing so fancy really, that's the issue. I have a graphic which only > takes half the page width and instead of putting it in the middle of the > page and leave white spaces on wither side I was trying to save some > magazine looks like. That I couldn't figure out how to achieve. In the > process I was trying to use a 1x2 matrix as a workaround and found that > this approach works for text/text, graphic/graphic but not text/graphic > as my text got very poorly formatted without letting me do any further > format edits. Have you tried using Grid? -- Helen Read University of Vermont === I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? Have you check the *TeX* family of tools and packages [1] (especially a look at *MikTeX*, one of ---if not--- the most popular distribution on this platform. If you wonder what TeX can do for you, check the following showcase [3]. Few words about my own experience. I use MacTeX [4] (on Mac OS X) both as a text editor and as a a consolidation tools for references, graphics, etc., and produce final reports, memos, papers, slides (except for interactive presentations), etc. in PDF format. graphics are made with Mathematica (and possibly other tools) and reworked if needed with Illustrator, bibliography are handled by EndNotes, and the final product is usually a PDF file. HTH, --Jean-Marc [1] http://www.tug.org/ [2] http://miktex.org/ [3] http://www.tug.org/texshowcase/ [4] http://www.tug.org/mactex/ === Did you perhaps mean TeXShop here? === > Did you perhaps mean TeXShop here? Oops! Of course, you are right: I was talking about *TeXShop* indeed [1]. --Jean-Marc [1] http://www.uoregon.edu/~koch/texshop/ === I wonder if the fact that I have both v 7 and 6.03 installed on my WinXP machine has anything to do with those stability issues I described earlier. In the other hand other people seemed to be experiencing similar problems, so I'm not sure As for the undo I think that it's a major limitation as so many other modern programs have unlimited undo implemented that have been around for quite some time now. And on top of that I've experienced situations in which little experimentation on my side results in a big mess up and to my frustration the undo command remained grey! The moral - BACK IT UP! PS> is there a way to make mathematica create a .bak file before overwriting the original one upon save? > to handle MathML and should be able to copy equations from Mathematica > while remaining their editability. Editing equations in Word isn't a > calming experience as getting into and out the equation object > requires several seconds of your valuable time, which is a pain in the > donkey if you have to do many small edits. Working in Mathematica is rather painless to me. Haven't had your > problems, but I miss a multiple undo. > >> Although Mathematica 7 is a very powerful peace of software as far as >> the computational part goes it turns out to be quite limited and >> unstable when it comes to word editing and processing, despite the >> claims in the help that it is almost as powerful as WinWord. >> For example it crashed multiple times on me while I was trying to setup >> the right fonts and sizes, as a result I lost all my work several >> times, it also messed up my fonts, sizes, styles, settings for the >> equations, its undo is totally useless and I couldn't figure out how to >> format a text and a graphic in two or more columns and display them side >> by side in a notebook as well as how to control what goes on what page >> and while printing to PDF often it wouldn't print all pages, but just >> the first 2-3. > All that said I'm wondering what program to use to write my work in, and >> I'm asking for advice - is WinWord any better when it comes to handling >> equations? >> Any other choices? > What is the best way to export Mathematica 7 equations and graphics? >> === The limited undo is extremely frustrating. I never experienced the font problems when i used to use Mathematica. For typesetting, nothing beats Latex, especially for journal submittal. LyX is a relatively user-friendly way of generating Latex output: http://www.lyx.org/ Matt === > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. If I don't let Notebooks grow too large, the Mathematica Frontend has been quite stable for me in the last years, so I wonder what kind of fancy formatting/word processing stuff you are doing to see frequent crashes... anyway, loosing work is something that should never ever happen. Have you looked at the stuff David Park is doing with Mathematica? I think if you don't try too much to force Mathematica Notebooks to look like printed publications but concentrate on presenting your content, you can achieve quite a lot (and much that is not possible on paper!) without hitting Mathematicas dark corners... > All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? If you are after good word processing capabilities for content to be printed only and good handling of equations _and_ to be absolutely sure to not ever loose your work by software crashes again I think there is still no alternative to TeX/Latex and a stable basic text editor. If you really need that, there are WYSIWYG frontends for TeX/Latex nowadays but I have never found these necessary when writing scientific content. > What is the best way to export Mathematica 7 equations and graphics? TeXForm[] or Export[,TeX] for equations, and Export[,EPS] or probably nowadays PDF for 2D Graphics will usually work well enough, only for 3D graphics there seem to be problems with the efficiency of the pdf export, you can find more information in the archives of this group... hth, albert === LaTeX works fine for me, in particular pdfTeX. You can export graphics as pdf files from Mathematica, and you can convert formulas to LaTeX form with the TeXForm[] command (although fine-tuning is usually necessary). If you use the RevTeX4 package, you easily get two-column pretty-printing. Roman. > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? === > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? Hello TL, I'm just beginning to use Mathematica 7 to write math texts, and so far it looks quite o.k. For more than 25 years I used (and I'm still using it) TeX. When writing Math stuff, my personal opinion is: Don't touch WinWord. For larger documents it is not usable, besides this the output generated by TeX (LaTeX) is by far better than WW does. For instance the algorithms for placing additions spaces in a paragraph to make it right-justified are rather simple in Word (and so the output is) TeX solves an optimization problem for every paragraph to make a pretty looking and harmonic spacing, it's by far better - not to mention stability and the ability to write works of several hundred pages. To export formulas etc. to TeX in Mathematica it's only TeXForm[#] :-). One last thing to remember: TeX is free, no Dollars, no Euros, no Pesos or whatever :-) But up to now also Mathematica 7 does a pretty good job, the problems you mentioned (crashes etc.) I did not have so far, and writing math-texts is very easy. Besides this one can have interactivity inside - this is really great. Mike === to handle MathML and should be able to copy equations from Mathematica while remaining their editability. Editing equations in Word isn't a calming experience as getting into and out the equation object requires several seconds of your valuable time, which is a pain in the donkey if you have to do many small edits. Working in Mathematica is rather painless to me. Haven't had your problems, but I miss a multiple undo. > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? === Mathematica or Word, IMHO should not ever be used for publication in a peer-reviewed journal. The process should rather be, in my mind, [1] Output graphics to EPS from Mathematica. [2] Output from Mathematica any relevant expressions to a LaTeX format (also code, if needed). [3] Use LaTeX for typesetting the document. I've never seen any journal that I've submitted, published in (Geophysical Research Letter, Journal of Geophysical Research, Geophysics Journal International, Computers and Geosciences), that accepts Mathematica notebooks. Most do have a LaTeX style and BibTeX style for proper formatting. === > Mathematica or Word, IMHO should not ever be used for publication in a > peer-reviewed journal. The process should rather be, in my mind, [1] Output graphics to EPS from Mathematica. > [2] Output from Mathematica any relevant expressions to a LaTeX format (a= lso > code, if needed). > [3] Use LaTeX for typesetting the document. I've never seen any journal that I've submitted, published in > (Geophysical Research Letter, Journal of Geophysical Research, > Geophysics Journal International, Computers and Geosciences), that > accepts Mathematica notebooks. Most do have a LaTeX style and BibTeX styl= e for > proper formatting. There are several tiers in the scientific publication world: o Traditional publishers of peer-reviewed archival journals (Wiley, Elsevier, Springer, etc). They now usually require LaTeX using their style macros. Nonconforming submissions are rejected. Figures must be in EPS on final submission but that may change. For C-R edited books, PDF is accepted for chapters, sometimes with backup LaTeX+EPS. o Low-cost, junk publishers of friendly-review journals, now proliferating in some regions, usually require Word with embedded figures. They lack in-house knowledge to process LaTeX. Those vanity journals are not generally included in citation indices, and do not count toward the h-index important in academic circles. o Electronic journals vary greatly in quality, from serious to junk. Generally they take PDF. In rapidly evolving areas, such as nanotech and CS, they are considered respectable and count toward the h-index. Summary: at all publishing levels, serious through junk, export mechanisms from Mathematica are essential. === LaTeX/pdfLaTeX & ASCII Editor (Textpad in my case). Jens > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? === I faced exactly the same troubles you describe. I do not know how to correct these inconveniencies caused by font changes and crashes...Please let me know if you are advised good recommendations. Tugrul fin > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? > Tugrul Temel ----------------------------------------------- Director and Associate Prof. of Economics ECOREC Economic Research & Consulting tel : +31 (0)20 683 63 79 email: temelt@xs4all.nl url : http://www.freewebs.com/tugrul/ ----------------------------------------------- === > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. ----SNIP---- All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? I faced exactly the same troubles you describe. I do not know how to > correct these inconveniencies caused by font changes and crashes...Please > let me know if you are advised good recommendations. There is definitely another (and much better) choice: 1) Do your calculations and create your _graphics_ (including animations or movies, if such are involved) in Mathematica, and export them to PDF files (or possibly QuickTime or other formats). (You'll have to work out for yourself which of the various export capabilities in Mathematica really work properly or consistently, recognizing that some of these will probably change or break with each new release of Mathematica; but that's part of the game and something you have to do with Mathematica in any case.) 2) Acquire Adobe Illustrator for editing, modifying, or touching up these exported graphics, including re-purposing them for use in different final documents (along with maybe a good graphics cataloging application if you're going to have a lot of such files). (Illustrator is very effective and easy to use for these tasks; it's WYSIWYG; it's easy to acquire the needed fluency in it; and it's both stable and very well documented.) 3) Acquire an up to date version of TeX, which will automatically include LaTeX, and will produce superb PDF output documents, with easily variable formatting, and with your PDF graphics automatically included or embedded in your documents in any way you like. (If you can cope with Mathematica, you will find Tex/LaTeX trivial to learn; they will produce superb documents; and their consistency and freedom from gotchas will amaze you. Joining TUG is a good way to start. Producing documents with TeX/LaTeX will be a joy compared with trying to produce them with Mathematica.) 4) The above steps are all you really need, but if you like you can also acquire a copy of Adobe Acrobat, to do misc tweaks and other things with your PDF documents. (Acrobat will also be easy to learn and well documented. You won't have to acquire it, but it will turn out to be useful in many ways.) Bottom lines: 1) If you do the above, you'll be using Mathematica for the one thing it's really good at -- and using other, much better tools for the tasks that Mathematica is not at all good at. 2) You'll have immensely more flexibility for making changes or tweaking things at each stage in the process, without going all the way back to the beginning, as well as great flexibility for re-using or re-purposing individual parts or components of your documents. And, your tools for doing this will be essentially WYSIWYG, and will have much better documentation. 3) You'll also be in the mainstream so far as document preparation, publication, and distribution in the real world is concerned. 4) And finally, you might note that the total cost of these additional tools (including their upgrades or support) will only be a fraction of you paid for Mathematica. === thread saying that for document preparation (where document can be taken broadly to include all kinds of documents and presentations), a modular or multi-tool approach generally involving TeX plus PDF is in every way preferable to any sort of Mathematica-only approach -- and I'm encouraged to see a number of other people independently saying more or less the same thing. I also gave a list of what seemed to me the main benefits of this modular or multi-tool approach, but I overlooked one. It's been added in below: ----------- > Bottom lines: 1) If you do the above, you'll be using Mathematica for the one thing > it's really good at -- and using other, much better tools for the tasks > that Mathematica is not at all good at. 2) You'll have immensely more flexibility for making changes or > tweaking things at each stage in the process, without going all the way > back to the beginning, as well as great flexibility for re-using or > re-purposing individual parts or components of your documents. And, > your tools for doing this will be essentially WYSIWYG, and will have > much better documentation. *** 2.5) You'll have meaningful backward compatibility or long-term *** stability, in the sense that if you want to go back and reuse or *** modify some project or set of files that you created say five or *** ten years ago, the file formats for your output documents will *** still be valid and usable, and the source files will likely be also *** still be usable with minimal modification. > 3) You'll also be in the mainstream so far as document preparation, > publication, and distribution in the real world is concerned. 4) And finally, you might note that the total cost of these additional > tools (including their upgrades or support) will only be a fraction of > you paid for Mathematica. ---------- === Subject: Re: Mathematica and Access I'm studying it! Ignacio Plazeta === Subject: Re: Mathematica and Access OK, I see how to access the Example databases, including the one that's in Access format. But how do I access my own Access .mdb database? When I run the OpenSQLConnection[] wizard and specify to use ODBC(DSN), I'm asked to enter the DSN. What's that? And where do I enter the actual location of my Access database? > >> I have to manage an huge database in Microsoft Access format. I have no experience with huge access databases (usually when databases > get huge I think the database-people try to avoid access, but 'huge' > might be relative...). Have you looked at the DatabaseLink > documentation? They have an example about how to handle an access > database via ODBC there, which does exactly what you seem to need. Just > search for ODBC in the documentation center. The documentation was > obviously done with version 5 but it still works with 7, except that the > example database is now here: > ../SystemFiles/Links/DatabaseLink/Examples/publisher.mdb the interesting thing is, that this works even without access being > installed. The downside is that some of the examples in the > documentation don't work, probably since pathes have changed... hth, albert > >> I'm trying to do the job using Mathematica because hard computational >> work is involved, but I'm unable to find the right way using >> Mathematca's help only. > Therefore, I export data from .MDB file in a TSV formatted one, precess >> them, import data in .MDB file again. > No doubt, it's a repetitive, slow, tedious method; I would love >> modify data (as an example, decrease by 10% prices of all books having >> been hanging for more than an year) directly within Mathematica Front >> End (or by means of a Kernel batch call). > Please can you suggest if it is feasible and, possibly point out a >> tutorial about that ? Does anyone got a try before ? > Best Regard > Ignacio > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Mathematica and Access > OK, I see how to access the Example databases, including the one that's > in Access format. But how do I access my own Access .mdb database? When I run the > OpenSQLConnection[] wizard and specify to use ODBC(DSN), I'm asked to > enter the DSN. What's that? And where do I enter the actual location > of my Access database? I have played with the connection wizard a little and found that it provides very simple access to an access database file when choosing 'Microsoft Access(ODBC)' as database type, not ODBC(DSN). You can then choose a filename. For my tests I copied the buildings.mdb to my desktop and chose that. This did not work with the default settings, only when choosing TransactionIsolationLevel to be ReadCommitted instead of the default ReadUncommited the connection could be established. So you may need to play with the connection options in the last dialog to find settings that result in a successful connection to your file which may or may not support some of the possibilities that access database files seem to provide... hth, albert === Subject: Re: Mathematica and Access > OK, I see how to access the Example databases, including the one that's > in Access format. But how do I access my own Access .mdb database? When I run the > OpenSQLConnection[] wizard and specify to use ODBC(DSN), I'm asked to > enter the DSN. What's that? And where do I enter the actual location > of my Access database? I think that the wizard is no big help for people not familiar with database terminology (which I am no expert either), for the ODBC case it seems easier to follow the instructions from the documentation which you find on this page: DatabaseLink/tutorial/DatabaseConnections#16139 and then search for: ODBC Connections it is quite straightforward to find that also when just searching for ODBC in the navigation bar. hth, albert === Subject: Re: Mathematica and Access I did that -- installing the example databases. In my folder $UserBaseDirectory/AddOns/DatabaseResources/Examples the only files I see relevant to the publisher database are publisher.lck, publisher.properties, publisher.script, and publisher.log. The Access database itself, publisher.mdb, remains in $InstallationDirectory/SystemFiles/Links/DatabaseLink/Examples. I have just detected that it not wrong pathes but wrong user input that > made the examples not work. You must install the example databases first > with DatabaseLink`DatabaseExamples` before the examples work. How to do > that is also explained in the DatabaseLink-Documentation. albert > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Using Coefficient on an equation Carlos, here may be what you're looking for: In[1]:= f=a*x^2+b*x+c==0 Out[1]= c+b x+a x^2==0 In[2]:= Coefficient[f,x^2] Out[2]= 0 In[3]:= Coefficient[f[[1]],x^2] Out[3]= a > If f=a*x^2+b*x+c, Coefficient[f,x^2] obviously returns a. > But if f=a*x^2+b*x+c==0, it returns 0. The problem arose using the Calculus`VariationalMethods` package. > It (unfortunately) returns the Euler-Lagrange equations as > such, so I have to remove the useless ==0 appendage for > Coefficient to work properly. Is there a simple direct way out? === Subject: Re: Using Coefficient on an equation f = a*x^2 + b*x + c == 0; First@Coefficient[f, x^2] a or Coefficient[First@f, x^2] a Bobby > If f=a*x^2+b*x+c, Coefficient[f,x^2] obviously returns a. > But if f=a*x^2+b*x+c==0, it returns 0. The problem arose using the Calculus`VariationalMethods` package. > It (unfortunately) returns the Euler-Lagrange equations as > such, so I have to remove the useless ==0 appendage for > Coefficient to work properly. Is there a simple direct way out? > -- DrMajorBob@longhorns.com === Subject: Using Coefficient on an equation If f=a*x^2+b*x+c, Coefficient[f,x^2] obviously returns a. But if f=a*x^2+b*x+c==0, it returns 0. The problem arose using the Calculus`VariationalMethods` package. It (unfortunately) returns the Euler-Lagrange equations as such, so I have to remove the useless ==0 appendage for Coefficient to work properly. Is there a simple direct way out? === Subject: Re: Using Coefficient on an equation > If f=a*x^2+b*x+c, Coefficient[f,x^2] obviously returns a. > But if f=a*x^2+b*x+c==0, it returns 0. The problem arose using the Calculus`VariationalMethods` package. > It (unfortunately) returns the Euler-Lagrange equations as > such, so I have to remove the useless ==0 appendage for > Coefficient to work properly. Is there a simple direct way out? Coefficient[f[[1]], x^2] In Mathematica, everything is an expression, therefore f[[1]] is the LHS of the equality and f[[2]] is the RHS. In[1]:= f = a*x^2 + b*x + c == 0; {f[[1]], f[[2]]} Coefficient[f[[1]], x^2] Out[2]= {c + b x + a x^2, 0} Out[3]= a --Jean-Marc === Subject: Mathematica Calls Home My firewall is detecting outbound Internet connection attempts by Mathematica 6.0.1. One kind of the attempts is being rated as high risk by my firewall. They occur at Mathematica start up and seem to be related to Java binaries. (I am allowing these attempts, however I do not know their purpose, but I do not care very much about it). The following is a bit more puzzling. Another kind of outbound connection attempts, rated as medium risk, takes place in occasions when saving my notebooks. Then Mathematica tries to connect to the IP 194.224.66.27 (DNS) on port 53. Till now, I have allowed this kind of connection too, but I wonder why Mathematica should make these Internet connections. Just when saving. Any advice? === Subject: Figures in a Mathematica 7.0 notebook I have just began to look at Mathematica 7.0 and it is very impressive. When looking at some of the very interesting projects that have been posted at Wolfram's homepage, I thought it would be useful to copy-and-paste some of the figures from these notebooks into my teaching material. After several attempts from different notebooks and different figures I found that the right-edge of the figure often was not completely copied (e.g. missing axis tic labels near the right edge) when pasting into Corel Draw X3. Note, I am running Mathematica 7.0 on a Windows Vista platform and the copy-and-paste operation did work ok when pasting into OpenOffice 3.0.0. I then did some experimenting with exporting Mathematica 7-0 figures using different formats. I found the *.EPS format was the best (at least for importing them into Corel Draw) --- the text and figure quality was excellent with no detectable loss of information. I hope that this information will be useful to others that may be working with Mathematica figures. --V. Stokes === Subject: Re: Figures in a Mathematica 7.0 notebook the PDF format is the best, when importing it into Corel. Jens > I have just began to look at Mathematica 7.0 and it is very impressive. > When looking at some of the very interesting projects that have been > posted at Wolfram's homepage, I thought it would be useful to > copy-and-paste some of the figures from these notebooks into my teaching > material. After several attempts from different notebooks and different > figures I found that the right-edge of the figure often was not > completely copied (e.g. missing axis tic labels near the right edge) > when pasting into Corel Draw X3. Note, I am running Mathematica 7.0 on a > Windows Vista platform and the copy-and-paste operation did work ok when > pasting into OpenOffice 3.0.0. I then did some experimenting with exporting Mathematica 7-0 figures > using different formats. I found the *.EPS format was the best (at least > for importing them into Corel Draw) --- the text and figure quality was > excellent with no detectable loss of information. I hope that this information will be useful to others that may be > working with Mathematica figures. --V. Stokes > === Subject: Interval arithmetic and Dependency problems I just started to have a look at Mathematica capabilities in Interval arithmetic. It seems that Mathematica does not consider the so called dependency problem (see for instance wikipedia on Interval arithmetic for an explanation). For example evaluate f[x_] := x^2 + x f[Interval[{-1, 1}]] and you get Interval[{-1, 2}] which is not really very good. The correct or, if you prefer, best result should be Interval[{-1/4,2}] since -1/4 and 2 are really the min and max values of f over the given interval. In other words Mathematica is not capable of calculating f[x] when x is an Interval and f is a general function. Yet Mathematica, according to documentation, is capable of calculating f[x] on an Interval, when f is restricted to a standard functions. For example the square function Interval[{-1, 1}]^2 gives the correct answer Interval[{0, 1}] But if the same square is expressed as a product, the result is not so good (tight): evaluating Interval[{-1, 1}] Interval[{-1, 1}] gives Interval[{-1, 1}] It seems to me that a further function should be implemented in Mathematica. Something called IntervalEvaluation or similar, with syntax like IntervalEvaluation[f[x],x,Interval[...]] Building this function should not be too difficult, using Maximize and Minimize on the given interval. Any comments? === Subject: Re: Chem PDB files, Export and Manipulation > I would like to use Mathematica 7.0's ability to import pdb files and > other (supported) chemistry related files into a Graphics3D object, to > be able to position and manipulate the resulting molecules and their > coordinates relative to other objects (Polygons, GraphicsComplexes, > etc.). How can this be done? Is it possible to manipulate a single atom's > position within Mathematica's objects, or does it need to be specified > in the pdb file beforehand? It is definitely possible, but for typical content of these files it might be somewhat difficult to locate the graphics primitives that you need to manipulate. This is not only because there might be plenty of them but also because the imported graphics make use of GraphicsComplex, which is reasonable and a good choice but makes the location probably somewhat more complex. With good knowledge and understanding of Mathematica basics (especially pattern matching I would guess) and some experience it should be possible, but I don't know of any easy klick and point way to do what you want for 3d graphics with many objects and GraphicsComplexes. > When imported into Mathematica, are pdb files scalable vectors, or > bitmaps? It seems that the resolution of the collective atoms > deteriorates considerably once you expand the original image (within > Mathematica, of course). Is it possible to export the resulting 3D > image to a vector image? Not being an expert for this kind of data I am left with the example data, which seem to be imported correctly as Mathematica graphic objects, which means they are mathematica expressions representing vector graphics. If you choose a vector image format as output Mathematica will usually export vector data and not converting to pixels, AFAIK. You might have seen the behavior you describe when looking at the documentation, in which most large graphics are converted to pixel formats to make the documentation more compact. If you reevaluate everything, the graphics should be rendering nice also when expanding the image, you can then also rotate and zoom... > The section dealing with Chemistry/Biology objects in the Mathematica > help is not very clear (understatement) on how to include and > manipulate the resulting molecules within other graphical objects. that is a typical problem with the help: it probably suggests that you are familiar with the mathematicas 'paradigms', especially this one: 'everything is an expression'. When understanding that the molecule-data is imported as a 3d-Graphics-object and that, of course :-), is an expression, you will understand that there is no need to handle or explain these in any special way. You can just use all the regular functions to manipulate expressions of any kind. To see them in 'expression format' you can look at them with InputForm or FullForm. Admittedly that is not much help for those who are not so familiar with all the details of Mathematica, so some examples in the documentation would be a big help, of course... > If anyone knows anything about this, I would appreciate your help! not too much, but I hope it still is of some help. I have included some code which shows how you can create an interface to interactively manipulate the position of one atom in one of the examples provided with mathematica, not a very realistic use case but probably a starting point.... albert Import something from the example data: pdb100d=Import[ExampleData/100d.pdb,ImageSize->300] There are 23 GraphicsComplexes in the graphics3d: Cases[pdb100d,GraphicsComplex[___],Infinity]//Length You can extract just the first of them: gc1=Cases[pdb100d,GraphicsComplex[___],Infinity][[1]]; and show only it alone: Graphics3D[gc1] Combining these with a manipulate you can find which of them is what is of interest to you. To do this, I extract the plotrange of the total view: prange=AbsoluteOptions[Graphics3D[Cases[pdb100d,GraphicsComplex[___],Infinit y]],PlotRange] ... and use that to fix the PlotRange: Manipulate[ Graphics3D[Cases[pdb100d,GraphicsComplex[___],Infinity][[k]],prange[[1]],Plo tLabel->k], {k,1,Length[Cases[pdb100d,GraphicsComplex[___],Infinity]],1} ] In the following, we would like to manipulate one of the atoms in the chain represented by graphics complex number 23: Graphics3D[Cases[pdb100d,GraphicsComplex[___],Infinity][[23]]] These are the coordinates of the first point in the GraphicsComplex, which happens to be the coordinate of the first atom of this chain: Cases[pdb100d,GraphicsComplex[___],Infinity][[23]][[1,1]] Making use of all the above, this will give you an interface to manipulate the coordinates of that first atom: With[{defaults=Cases[pdb100d,GraphicsComplex[___],Infinity][[23]][[1,1]]}, Manipulate[ Graphics3D[{ Delete[Cases[pdb100d,GraphicsComplex[___],Infinity],23], Dynamic[ReplacePart[Cases[pdb100d,GraphicsComplex[___],Infinity][[23]],{1,1} ->{x,y,z}]] }], {{x,defaults[[1]]},defaults[[1]]-1000,defaults[[1]]+1000}, {{y,defaults[[2]]},defaults[[2]]-1000,defaults[[2]]+1000}, {{z,defaults[[3]]},defaults[[3]]-1000,defaults[[3]]+1000} ] ] Some notes: 1) the Dynamic is only included for performance reasons -- but makes a big difference :-), 2) manipulating the coordinates of a graphics complex instead of coordinates of single graphics primitives has the advantage that the chain stays intact: the connection to the next atom is automatically changed, too. Of course that is not always what you want, so sometimes you would even need to pull some of the graphic primitives out of the graphics complex. === Subject: =?ISO-8859-1?Q?Re:__Perch=E8_non_parli=3F?= my mistake, speech works fine now. Peter 2009/1/11 peter : > me too - I can't get it to work either. I use OS X. I've posted a help > request to wolfram. Peter 2009/1/9 Chris Pemberton : > A popular story tells that Michelangelo, having just finished his > Moses, stepped back to admire his latest creation and, overwhelmed by > its beauty and perfection, threw his hammer at its right knee > exclaiming Perch=E8 non parli? (why don't you speak?). Well, if you are thinking of throwing your hammer at Mathematica > 7.0 ...hold on for a second....because Mathematica 7.0 can actually > SPEAK! And rather fluently too! > In fact not only it can read aloud any text you throw at it, but it > can articulate complex math formulae too. In other words it has the > capability to orally communicate with the user for mesages, help, > warnings, ect. Have you tried the speech capabilities of Mathematica 7.0 yet? > Well, if you have, chances are that you have been disappointed by the > poor quality of the default MS voices present on Windows XP machines > (I do not know about Vista). Never mind, because excellent and low > cost voices exist that can replace the default Windows voices. > Excellent voices from Neospeech or Acapela cost between 30$ and 50 $, > often in association with low cost TTS (text to speech) software. > I have been unable to get any speech output from Mathematica 7 in >> Linux. I hope it is supported soon. >> I conclude from your sales pitch that Mathematica uses the OS's native >> TTS capabilities, not some form of built-in TTS engine? >> If so, I suppose Wolfram could utilize the festival TTS engine in >> Linux. Not sure about the licensing. > Chris > > === Subject: Re: solution > Hello! I found out a solution for the Alt-Gr issue. Open /usr/local/Wolfram/Mathematica/7.0/SystemFiles/FrontEnd/ > TextResources/X/KeyEventTranslations.tr file on your system.(eg.: sudo > nano ..., paths may vary). Then somewhere under EventTranslations[{ type some newlines, then > paste this literally: Item[KeyEvent[ISO_Level3_Shift], > FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[], > Sequence[], After]}] > ], This code translates the Alt-Gr key(ISO_Level3_Shift) to produce > something in the notebook, which is in this case nothing, becase > Sequence[] evaluates to nothing, albeit its syntactically correct. Restart mathematica, and enjoy its once again slow interface under > Linux :( i used version Mathematica 7.0.0, kernel 2.6.27, 64bit, Arch Linux, X.org > v11.0. by the way: you can define shortcuts in this file easily. Your solution did not work for me (well, the space was gone, but an even more annoying beep replaced it) but the following, which is slightly more straightforward, works nicely AFAICS: Item[KeyEvent[ISO_Level3_Shift], FrontEndExecute[{}]], I'm sure there is something one can put inthe second argument instead of the rather silly FrontEndExecute[{}] with the effect of ignoring the KeyEvent, but I could not find any documentation on that... -- m === Subject: Bizarre Histogram behavior I have Mathematica versions 6 and 7 installed on my Intel MacBookPro. I am also using the Optica package that currently runs only under version 6. So I am running a notebook with Optica code with Version 6. I load the Histogram package with Needs[Histograms`] when I start the notebook. Then when I attempt to execute the Histogram function, I get the error message that says it can't find the Histogram symbol. Now, if I go to Help for the Histogram function, the first thing in the Examples section is Needs[Histograms`], which I execute in the Help notebook. Then the first example in this notebook works correctly, giving a histogram plot of the specified data. But what is bizarre is that the second example fails to plot. When I execute this cell Histogram[RandomReal[{0, 1}, {1000}]], the result is a long list of numbers with Histogram at the head. In the Help notebook, if I do ??Histogram, I get the result: Cell$$4753`Histogram. Why does my notebook not recognize Histogram[] after I load the package? Why does the Help example fail to plot the second example? Is there some interaction between the installation of Mathematica 6 and Mathematica 7 that now prevents Mathematica 6 from recognizing the Histogram package? This behavior is really bizarre. === Subject: Multiple PDF Pages using Export Hi All! I'm interested in generating one PDF graphic per page as in fourpages=Table[Graphics[Circle[], ImageSize -> {s, s}], {s, 100, 200, 25}] followed by something like Export[file.pdf, Table[{Page[i] -> fourcircles[[i]]}, {i, 1, 4}], PDF] Without the nonexistent function Page[i], i.e., just fourcircles[[i]], the four images are horizontally juxtaposed in the same page and not on separate pages. Another words, one table[[i]] graphic per one PDF page for four pages. Don J. Orser === Subject: Multiple Shooting Method Hi My linear forward shooting method does work but my system of equations is highly nonlinear and it does not converge on the right boundary condition for certain parameters. I suspect that if I use a multiple shooting algorithm it will alleviate this problem. I cant find an algorithm or mathematica example for this method. Can someone outline the basic algorithm for me? S === Subject: Re: Multiple Shooting Method http://en.wikipedia.org/wiki/Direct_multiple_shooting_method ?? Jens > Hi My linear forward shooting method does work but my system of equations > is highly nonlinear and it does not converge on the right boundary > condition for certain parameters. I suspect that if I use a multiple shooting algorithm it will > alleviate this problem. I cant find an algorithm or mathematica > example for this method. Can someone outline the basic algorithm for > me? > S > === What I find odd is using a text editor for this. Is TeX a version of HTML, then? Bobby > What you say is both true and non-true! A commercial package such as PC > TeX is a single application that includes the editor, previewer, etc. On the other hand, the origin of TeX is in the *nix world, so the > paradigm persists of a separate tool for each task: a text editor; the > executable TeX engine itself; and a previewer (from which one often does > the printing). The TeX engine may itself have a version that produces > pdf directly, or one may use a separate tool in the bundle that converts > the the standard TeX device-independent output .dvi file into pdf. The TeX engine is the analog of Mathematica's kernel; the editor and > previewer together form the analog of Mathematica's front end; and the > various TeX/LaTeX packages are analogs of specialized Mathematical > packages. With contemporary distributions, however, the separation into the > different tools is largely transparent to the user. The front-end editor > is, in a sense, the application, and you don't really have to care what > executable or batch file is doing what. About fonts: producing a high-quality font family that includes all the > necessary fonts for mathematics is no mean feat. That was a reason that > looked plain ugly as they tried to mix and match symbols with letters. > And among symbols I include upper & lower-case Greek, both upright and > slanted, Cyrillic, blackboard bold, Hebrew (for set theory's Aleph, > e.g.) The standard, default set of fonts is Computer Modern, which looks great > on-screen but can seem a bit spindly in print. Many folks who are > producing technical documents with mathematical symbols want a different > choice, and that's why the two most popular alternatives -- Times with > MathTimes and Lucida with Lucida Math -- were developed. To use those, > instead of Computer Modern, one simply includes a line or two of code in > the document to load some packages; then, provided you have the > underlying fonts, everything works transparently; you do have many > options available that you can set for these fonts though, and some even > for Computer Modern, e.g., just what font to use for script. (TeX is is used for many purposes far from math and science, and there > are fonts and supporting packages available for a huge number of world > languages.) It is NOT difficult at all to getting a working TeX system: my TeX-naive > Math 370 students all managed to do it in short order. But just like using Mathematica effectively takes some learning effort, > so using LaTeX effectively does, too. > Judging from your links, there IS no application that creates, edits, >> and maintains LaTex (and displays it; I forgot that part). >> It takes at least four different pieces of software? And dozens of >> extra, optional pieces? For one task? >> And you sometimes use a different package because it handles certain >> fonts, but the other package doesn't? >> Wow! That sounds like quite a briar patch you're suggesting. >> Anyway, www.tug.org/mactex/ isn't loading, and THAT'S not encouraging. >> I initially used TeX for early versions of my dissertation back in >> 1987-1989, but the writing went on hiatus when I was assigned to the >> Pentagon, dissertation unfinished. (Dr. Klingman, my adviser, was dying >> of brain cancer at the time, though I don't offer that as an excuse.) >> When I took up the struggle again in 1992, I used Word and its Equation >> Editor (later adding MathEdit because Equation Editor was only its >> stunted younger brother). It was a MUCH better experience than what I'd >> gone through with TeX, although I suppose TeX had improved in the >> meantime as well. Sadly, it was not long after finishing the >> dissertation that Word would no longer display the equations properly. >> (A year or two?) >> Still, my MS Thesis was accomplished (1983) with rub-off templates for >> equation symbols, so it was a very significant progression from that, >> to 1988 TeX, to 1992 MathEdit. >> Oh, and let's not forget the Wang workstations I used, 1984-1986, >> which handled equations better than anything I've seen since... until >> Mathematica. >> Another poster suggested LyX, and it looks very promising (though >> looks can be deceiving). It seems to do everything at once. >> Bobby > There are several distributions of TeX, which include the LaTeX macro > package along with scads of other packages that modify the default > behavior of, or add new functionality to, LaTeX. Some of these > distributions, except for Linux, include a front end editor that > integrates into the input -> dvi (or pdf) viewer -> print chain. For some recommendations, see the menu item About Math 370 at: http://bcrc.bio.umass.edu/courses/fall2008/math/math370/ And you may be interested in the items under LaTeX resources at that > site. For a more complete listing of TeX/LaTeX distributions http://www.latex-project.org/ftp.html and the links there. There are both free and commercial distributions. For an easy-to-install Windows distribution that includes a front end > editor, I recommend ProTeXt. Personally I most often use the free > MiKTeX > distribution (which is part of ProTeXt) together with the low-cost > front > end editor WinEdt (which is more powerful than the editor that comes > with ProTeXt but is more complicated to configure). Sometimes I use the > nicely integrated, commercial PCTeX system (www.pctex.com) just because > some of the LaTeX packages it includes make it much easier to use the > non-default Lucida fonts or the MathTime Pro fonts. >> What application creates, edits, and maintains LaTex? > Sign me curious, >> Bobby > If you want an interactive document, then there's little, if > anything, > that can touch Mathematica. If you want a more-or-less static document, then the gold standard in > the mathematical community, and in a good part of the scientific > community, is LaTeX. You can include any Mathematica-produced graphic > there by exporting it as EPS. And LaTeX documents today typically wind up as PDF, with embedded > hyperlinks and even animation and some interactive effects. > Although Mathematica 7 is a very powerful peace of software as far >> as >> the computational part goes it turns out to be quite limited and >> unstable when it comes to word editing and processing, despite the >> claims in the help that it is almost as powerful as WinWord. >> For example it crashed multiple times on me while I was trying to >> setup >> the right fonts and sizes, as a result I lost all my work several >> times, it also messed up my fonts, sizes, styles, settings for the >> equations, its undo is totally useless and I couldn't figure out >> how to >> format a text and a graphic in two or more columns and display them >> side >> by side in a notebook as well as how to control what goes on what >> page >> and while printing to PDF often it wouldn't print all pages, but >> just >> the first 2-3. > All that said I'm wondering what program to use to write my work >> in, and >> I'm asking for advice - is WinWord any better when it comes to >> handling >> equations? >> Any other choices? > What is the best way to export Mathematica 7 equations and graphics? > -- DrMajorBob@longhorns.com === What you say is both true and non-true! A commercial package such as PC TeX is a single application that includes the editor, previewer, etc. On the other hand, the origin of TeX is in the *nix world, so the paradigm persists of a separate tool for each task: a text editor; the executable TeX engine itself; and a previewer (from which one often does the printing). The TeX engine may itself have a version that produces pdf directly, or one may use a separate tool in the bundle that converts the the standard TeX device-independent output .dvi file into pdf. The TeX engine is the analog of Mathematica's kernel; the editor and previewer together form the analog of Mathematica's front end; and the various TeX/LaTeX packages are analogs of specialized Mathematical packages. With contemporary distributions, however, the separation into the different tools is largely transparent to the user. The front-end editor is, in a sense, the application, and you don't really have to care what executable or batch file is doing what. About fonts: producing a high-quality font family that includes all the necessary fonts for mathematics is no mean feat. That was a reason that looked plain ugly as they tried to mix and match symbols with letters. And among symbols I include upper & lower-case Greek, both upright and slanted, Cyrillic, blackboard bold, Hebrew (for set theory's Aleph, e.g.) The standard, default set of fonts is Computer Modern, which looks great on-screen but can seem a bit spindly in print. Many folks who are producing technical documents with mathematical symbols want a different choice, and that's why the two most popular alternatives -- Times with MathTimes and Lucida with Lucida Math -- were developed. To use those, instead of Computer Modern, one simply includes a line or two of code in the document to load some packages; then, provided you have the underlying fonts, everything works transparently; you do have many options available that you can set for these fonts though, and some even for Computer Modern, e.g., just what font to use for script. (TeX is is used for many purposes far from math and science, and there are fonts and supporting packages available for a huge number of world languages.) It is NOT difficult at all to getting a working TeX system: my TeX-naive Math 370 students all managed to do it in short order. But just like using Mathematica effectively takes some learning effort, so using LaTeX effectively does, too. > Judging from your links, there IS no application that creates, edits, > and maintains LaTex (and displays it; I forgot that part). It takes at least four different pieces of software? And dozens of > extra, optional pieces? For one task? And you sometimes use a different package because it handles certain > fonts, but the other package doesn't? Wow! That sounds like quite a briar patch you're suggesting. Anyway, www.tug.org/mactex/ isn't loading, and THAT'S not encouraging. I initially used TeX for early versions of my dissertation back in > 1987-1989, but the writing went on hiatus when I was assigned to the > Pentagon, dissertation unfinished. (Dr. Klingman, my adviser, was dying > of brain cancer at the time, though I don't offer that as an excuse.) > When I took up the struggle again in 1992, I used Word and its Equation > Editor (later adding MathEdit because Equation Editor was only its > stunted younger brother). It was a MUCH better experience than what I'd > gone through with TeX, although I suppose TeX had improved in the > meantime as well. Sadly, it was not long after finishing the > dissertation that Word would no longer display the equations properly. > (A year or two?) Still, my MS Thesis was accomplished (1983) with rub-off templates for > equation symbols, so it was a very significant progression from that, to > 1988 TeX, to 1992 MathEdit. Oh, and let's not forget the Wang workstations I used, 1984-1986, which > handled equations better than anything I've seen since... until > Mathematica. Another poster suggested LyX, and it looks very promising (though > looks can be deceiving). It seems to do everything at once. Bobby >> There are several distributions of TeX, which include the LaTeX macro >> package along with scads of other packages that modify the default >> behavior of, or add new functionality to, LaTeX. Some of these >> distributions, except for Linux, include a front end editor that >> integrates into the input -> dvi (or pdf) viewer -> print chain. > For some recommendations, see the menu item About Math 370 at: > http://bcrc.bio.umass.edu/courses/fall2008/math/math370/ > And you may be interested in the items under LaTeX resources at that >> site. > For a more complete listing of TeX/LaTeX distributions > http://www.latex-project.org/ftp.html > and the links there. > There are both free and commercial distributions. > For an easy-to-install Windows distribution that includes a front end >> editor, I recommend ProTeXt. Personally I most often use the free MiKTeX >> distribution (which is part of ProTeXt) together with the low-cost front >> end editor WinEdt (which is more powerful than the editor that comes >> with ProTeXt but is more complicated to configure). Sometimes I use the >> nicely integrated, commercial PCTeX system (www.pctex.com) just because >> some of the LaTeX packages it includes make it much easier to use the >> non-default Lucida fonts or the MathTime Pro fonts. > What application creates, edits, and maintains LaTex? Sign me curious, > Bobby >> If you want an interactive document, then there's little, if anything, >> that can touch Mathematica. > If you want a more-or-less static document, then the gold standard in >> the mathematical community, and in a good part of the scientific >> community, is LaTeX. You can include any Mathematica-produced graphic >> there by exporting it as EPS. > And LaTeX documents today typically wind up as PDF, with embedded >> hyperlinks and even animation and some interactive effects. > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to > setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out > how to > format a text and a graphic in two or more columns and display them > side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work > in, and > I'm asking for advice - is WinWord any better when it comes to > handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? > >> > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Judging from your links, there IS no application that creates, edits, and maintains LaTex (and displays it; I forgot that part). It takes at least four different pieces of software? And dozens of extra, optional pieces? For one task? And you sometimes use a different package because it handles certain fonts, but the other package doesn't? Wow! That sounds like quite a briar patch you're suggesting. Anyway, www.tug.org/mactex/ isn't loading, and THAT'S not encouraging. I initially used TeX for early versions of my dissertation back in 1987-1989, but the writing went on hiatus when I was assigned to the Pentagon, dissertation unfinished. (Dr. Klingman, my adviser, was dying of brain cancer at the time, though I don't offer that as an excuse.) When I took up the struggle again in 1992, I used Word and its Equation Editor (later adding MathEdit because Equation Editor was only its stunted younger brother). It was a MUCH better experience than what I'd gone through with TeX, although I suppose TeX had improved in the meantime as well. Sadly, it was not long after finishing the dissertation that Word would no longer display the equations properly. (A year or two?) Still, my MS Thesis was accomplished (1983) with rub-off templates for equation symbols, so it was a very significant progression from that, to 1988 TeX, to 1992 MathEdit. Oh, and let's not forget the Wang workstations I used, 1984-1986, which handled equations better than anything I've seen since... until Mathematica. Another poster suggested LyX, and it looks very promising (though looks can be deceiving). It seems to do everything at once. Bobby > There are several distributions of TeX, which include the LaTeX macro > package along with scads of other packages that modify the default > behavior of, or add new functionality to, LaTeX. Some of these > distributions, except for Linux, include a front end editor that > integrates into the input -> dvi (or pdf) viewer -> print chain. For some recommendations, see the menu item About Math 370 at: http://bcrc.bio.umass.edu/courses/fall2008/math/math370/ And you may be interested in the items under LaTeX resources at that > site. For a more complete listing of TeX/LaTeX distributions http://www.latex-project.org/ftp.html and the links there. There are both free and commercial distributions. For an easy-to-install Windows distribution that includes a front end > editor, I recommend ProTeXt. Personally I most often use the free MiKTeX > distribution (which is part of ProTeXt) together with the low-cost front > end editor WinEdt (which is more powerful than the editor that comes > with ProTeXt but is more complicated to configure). Sometimes I use the > nicely integrated, commercial PCTeX system (www.pctex.com) just because > some of the LaTeX packages it includes make it much easier to use the > non-default Lucida fonts or the MathTime Pro fonts. >> What application creates, edits, and maintains LaTex? > Sign me curious, >> Bobby > If you want an interactive document, then there's little, if anything, > that can touch Mathematica. If you want a more-or-less static document, then the gold standard in > the mathematical community, and in a good part of the scientific > community, is LaTeX. You can include any Mathematica-produced graphic > there by exporting it as EPS. And LaTeX documents today typically wind up as PDF, with embedded > hyperlinks and even animation and some interactive effects. > Although Mathematica 7 is a very powerful peace of software as far as >> the computational part goes it turns out to be quite limited and >> unstable when it comes to word editing and processing, despite the >> claims in the help that it is almost as powerful as WinWord. >> For example it crashed multiple times on me while I was trying to >> setup >> the right fonts and sizes, as a result I lost all my work several >> times, it also messed up my fonts, sizes, styles, settings for the >> equations, its undo is totally useless and I couldn't figure out how >> to >> format a text and a graphic in two or more columns and display them >> side >> by side in a notebook as well as how to control what goes on what page >> and while printing to PDF often it wouldn't print all pages, but just >> the first 2-3. > All that said I'm wondering what program to use to write my work in, >> and >> I'm asking for advice - is WinWord any better when it comes to >> handling >> equations? >> Any other choices? > What is the best way to export Mathematica 7 equations and graphics? -- DrMajorBob@longhorns.com === Personally, I find it's hard to beat Emacs with the AucTeX macros. If you want, you can have all the math bits converted to images and shown in the buffer alongside the text. (You can, of course, toggle the images back to the original source which, once you edit it, will be retypeset with the new math image displayed.) Jason Sent from my iPhone > What application creates, edits, and maintains LaTex? Sign me curious, > Bobby >> If you want an interactive document, then there's little, if >> anything, >> that can touch Mathematica. > If you want a more-or-less static document, then the gold standard in >> the mathematical community, and in a good part of the scientific >> community, is LaTeX. You can include any Mathematica-produced graphic >> there by exporting it as EPS. > And LaTeX documents today typically wind up as PDF, with embedded >> hyperlinks and even animation and some interactive effects. > Although Mathematica 7 is a very powerful peace of software as far > as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to > setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out > how to > format a text and a graphic in two or more columns and display > them side > by side in a notebook as well as how to control what goes on what > page > and while printing to PDF often it wouldn't print all pages, but > just > the first 2-3. All that said I'm wondering what program to use to write my work > in, and > I'm asking for advice - is WinWord any better when it comes to > handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? > > -- > DrMajorBob@longhorns.com > Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm === There are several distributions of TeX, which include the LaTeX macro package along with scads of other packages that modify the default behavior of, or add new functionality to, LaTeX. Some of these distributions, except for Linux, include a front end editor that integrates into the input -> dvi (or pdf) viewer -> print chain. For some recommendations, see the menu item About Math 370 at: http://bcrc.bio.umass.edu/courses/fall2008/math/math370/ And you may be interested in the items under LaTeX resources at that site. For a more complete listing of TeX/LaTeX distributions http://www.latex-project.org/ftp.html and the links there. There are both free and commercial distributions. For an easy-to-install Windows distribution that includes a front end editor, I recommend ProTeXt. Personally I most often use the free MiKTeX distribution (which is part of ProTeXt) together with the low-cost front end editor WinEdt (which is more powerful than the editor that comes with ProTeXt but is more complicated to configure). Sometimes I use the nicely integrated, commercial PCTeX system (www.pctex.com) just because some of the LaTeX packages it includes make it much easier to use the non-default Lucida fonts or the MathTime Pro fonts. > What application creates, edits, and maintains LaTex? Sign me curious, > Bobby >> If you want an interactive document, then there's little, if anything, >> that can touch Mathematica. > If you want a more-or-less static document, then the gold standard in >> the mathematical community, and in a good part of the scientific >> community, is LaTeX. You can include any Mathematica-produced graphic >> there by exporting it as EPS. > And LaTeX documents today typically wind up as PDF, with embedded >> hyperlinks and even animation and some interactive effects. > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? >> > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === What application creates, edits, and maintains LaTex? Sign me curious, Bobby > If you want an interactive document, then there's little, if anything, > that can touch Mathematica. If you want a more-or-less static document, then the gold standard in > the mathematical community, and in a good part of the scientific > community, is LaTeX. You can include any Mathematica-produced graphic > there by exporting it as EPS. And LaTeX documents today typically wind up as PDF, with embedded > hyperlinks and even animation and some interactive effects. > Although Mathematica 7 is a very powerful peace of software as far as >> the computational part goes it turns out to be quite limited and >> unstable when it comes to word editing and processing, despite the >> claims in the help that it is almost as powerful as WinWord. >> For example it crashed multiple times on me while I was trying to setup >> the right fonts and sizes, as a result I lost all my work several >> times, it also messed up my fonts, sizes, styles, settings for the >> equations, its undo is totally useless and I couldn't figure out how to >> format a text and a graphic in two or more columns and display them side >> by side in a notebook as well as how to control what goes on what page >> and while printing to PDF often it wouldn't print all pages, but just >> the first 2-3. > All that said I'm wondering what program to use to write my work in, and >> I'm asking for advice - is WinWord any better when it comes to handling >> equations? >> Any other choices? > What is the best way to export Mathematica 7 equations and graphics? > -- DrMajorBob@longhorns.com === I would recommend using TeX, or more specifically LaTeX ( http://www.latex-project.org/). It is not a word processor, it is a package forr typesetting that was specifically created for maths. It is not a WYSIWYG (what you see is what you get) editor. You use a normal text editor (one that comes with your OS or your favorite), and use a program to turn it into a pdf. Popular text editors are Vim (or GVim) and emacs. It takes a little bit to get used to it, but once you use it you'll never go back. Good luck. Sean > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? > === > [Unless your TeX input has some error, in which case the typeset > output > will only appear up a point where the error occurs; a description and > explanation of the error will appear in a third log window -- and > hitting some other key combo will take you back to the input window > **with the cursor positioned at the point or line where the error was > encountered.] This has been the case for many years. Amazing. That means they must have produced a mind-reading version of TeX that I am not aware of. In all versions that I know (and I have been using TeX,LateX,Ams-Latex etc for decades) the cursor will appear not at the place where the error (for example a missing right brace }) occurred but at the place where TeX first notices some inconsistency with its syntax - which is almost never the place where the error actually occurred. At that point you have got to manually find the actual error, which can be far from simple. The only TeX implementation that I know that partly gets around this problem is the Mac TeX system Textures (http://www.bluesky.com/products/products_frames.html ), which continually typesets your output as you type (without the need to hit any keys), which usually will make you aware of an error as soon as it occurs rather than much later, when you try to typeset the you course code. Moreover, Textures has several other nice features that are implemented only imperfectly in other versions. But there are major caveats - a Mac OS X version is still only in beta, years after Mac OS X occurred, and Textures costs hundreds of dollars. But, and here is something anyone considering TeX should carefully ponder upon. Before Mac OS X appeared, there were many persons (including myself) willing to pay hundreds of dollars for Textures and more for regular upgrades, in spite of the fact that lots of free TeX implementations have always existed on the Mac (I myself now use TeX Shop with Japanese PTex engine). This was because TeXtures avoids the huge amount of hassle that installing and using TeX is for any beginner and even for an experienced user. Then Blue Sky, the company that makes Textures, failed to come up with a Mac OS X compatible version and most users reluctantly drifted away to other programs. But if you look mailing lists where TeX on Mac OS is discussed you will find that many are intending to return (even though it will cost them money) as soon as a full featured version is again available. Which only proves that standard, free implementations of TeX are far form the sort of thing some make them out to be. I strongly recommend you to try TeX, but I suspect you will be soon back to using Mathematica (if not Word). Andrzej Kozlowski === > It is not a > WYSIWYG (what you see is what you get) editor. All modern TeX implementations allow you to type the TeX input into one window (the edit window); hit some key combination like cmd-T; and instantly see the typeset material fully formatted in final form in a second window (the typeset window). [Unless your TeX input has some error, in which case the typeset output will only appear up a point where the error occurs; a description and explanation of the error will appear in a third log window -- and hitting some other key combo will take you back to the input window **with the cursor positioned at the point or line where the error was encountered.] This has been the case for many years. === If you want an interactive document, then there's little, if anything, that can touch Mathematica. If you want a more-or-less static document, then the gold standard in the mathematical community, and in a good part of the scientific community, is LaTeX. You can include any Mathematica-produced graphic there by exporting it as EPS. And LaTeX documents today typically wind up as PDF, with embedded hyperlinks and even animation and some interactive effects. > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === > If you want a more-or-less static document, then the gold standard in > the mathematical community, and in a good part of the scientific > community, is LaTeX. You can include any Mathematica-produced graphic > there by exporting it as EPS. Or PDF, depending on the TeX implementation. > And LaTeX documents today typically wind up as PDF, with embedded > hyperlinks and even animation and some interactive effects. Which can, in addition, readily be changed, varied, added, removed, supplemented by editing the final PDF document itself, using Acrobat. === > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? Well, I'm certainly very sorry to hear about your experience. Yes, it is definitely true that Mathematica doesn't generally support multi-column page layout (I say generally because people occasionally find hacky ways to attempt this, but they're not very robust), and that Mathematica is limited to a single-level undo. As for the crashing/corruption problems you describe, I'm not sure that they are generally known, and I would encourage you to report any reproducible (or even semi-reproducible) examples you find to Wolfram Research Tech Support, or feel free to send them to me directly. I can't guarantee prompt responses to direct emails, but I will deal with them. I'd like to mention that Mathematica has a very convenient copy/paste facility which works with the Word 2007 Equation Editor (not with earlier versions of Word) which you may find useful, and you can also explicitly copy math as TeX or MathML for use in any other application which supports these forms. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. === Subject: Re: Using Coefficient on an equation f = a*x^2 + b*x + c == 0; Coefficient[f[[1]], x^2] a Bob Hanlon If f=a*x^2+b*x+c, Coefficient[f,x^2] obviously returns a. But if f=a*x^2+b*x+c==0, it returns 0. The problem arose using the Calculus`VariationalMethods` package. It (unfortunately) returns the Euler-Lagrange equations as such, so I have to remove the useless ==0 appendage for Coefficient to work properly. Is there a simple direct way out? -- Bob Hanlon === Subject: Re: usage of TrigToExp? Start from a fresh kernel. TrigToExp[Cos[2 x]] 1/2/E^(2*I*x) + (1/2)*E^(2*I*x) % // FullSimplify Cos[2*x] %% // ExpToTrig Cos[2*x] TrigToExp[Cos[y] Sin[x]] (1/4)*I*(E^((-I)*x) - E^(I*x))* (E^((-I)*y) + E^(I*y)) % // FullSimplify Sin[x]*Cos[y] %% // ExpToTrig Sin[x]*Cos[y] Perhaps you have something in $Post or have an older version and have executed the package Miscellaneous`RealOnly` Bob Hanlon Results from function TrigToExp seemed weird to me. Could anyone In[41]:= TrigToExp[Cos[2 x]] During evaluation of In[41]:= Nonreal::warning: Nonreal number encountered. Out[41]= Nonreal In[43]:= TrigToExp[Cos[y] Sin[x]] Out[43]= 0 Zatuch -- Bob Hanlon === Subject: Re: Mathematica 7 on an Asus Eee PC Laptop? > Was your test also with Linux? On 15 Jan., 12:09, Jean-Marc Gulliet Has anyone tried running Mathematica 7 on an Asus Eee PC Laptop unde= r >> Linux? > hi, I have a eeePC900 with eeebuntu (the last one), and Mathematica > run perfectly... >> Hi Andrea, > Just out of curiosity, have you run the benchmarks that come with >> Mathematica on the netbook? If so, could you, please, report the resul= ts >> and perhaps write a line or two about your overall experience with the >> system. > I am asking because I was wondering whether a netbook + a CAS >> (commercial or open source) could be a suitable replacement of a lapto= p >> in classroom setting (e.g. doing interactive presentations with some >> real-time computations or plots of simple expressions or models). > --Jean-Marc Hello I tested Mathematica for Students 7.0.0 on an ASUS EeePC and got 0.31 > for the Mathematica benchmark. For most situations this should be ok in a classroom setting. But I would prefer a larger than 10'' monitor. Norbert Marxer -- > Murray Eisenberg mur...@math.umas= s.edu > Mathematics & Statistics Dept. > Lederle Graduate Research Tower phone 413 549-1020 (H) > University of Massachusetts 413 545-2859 (= W) > 710 North Pleasant Street fax 413 545-1801 > Amherst, MA 01003-9305 Hello No, the test was only done on a machine with Windows XP: System: Microsoft Windows (32-bit) Mathematica Version: 7.0.0 Benchmark Result: 0.31 If you are interested in the individual results: Total: 275.22 s Individual Tests: {6.52, 2.55, 3.22, 18.88, 25.63, 1.78, 3.19, 10.75, 81.94, 5.78, 10.67, 9.28, 6.09, 34.02, 54.94} Norbert Marxer === Subject: Re: Mathematica 7 on an Asus Eee PC Laptop? Was your test also with Linux? > On 15 Jan., 12:09, Jean-Marc Gulliet Has anyone tried running Mathematica 7 on an Asus Eee PC Laptop under >> Linux? > hi, I have a eeePC900 with eeebuntu (the last one), and Mathematica > run perfectly... >> Hi Andrea, > Just out of curiosity, have you run the benchmarks that come with >> Mathematica on the netbook? If so, could you, please, report the results >> and perhaps write a line or two about your overall experience with the >> system. > I am asking because I was wondering whether a netbook + a CAS >> (commercial or open source) could be a suitable replacement of a laptop >> in classroom setting (e.g. doing interactive presentations with some >> real-time computations or plots of simple expressions or models). > --Jean-Marc Hello I tested Mathematica for Students 7.0.0 on an ASUS EeePC and got 0.31 > for the Mathematica benchmark. For most situations this should be ok in a classroom setting. But I would prefer a larger than 10'' monitor. Norbert Marxer > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Mathematica 7 on an Asus Eee PC Laptop? On 15 Jan., 12:09, Jean-Marc Gulliet Linux? hi, I have a eeePC900 with eeebuntu (the last one), and Mathematica > run perfectly... Hi Andrea, Just out of curiosity, have you run the benchmarks that come with > Mathematica on the netbook? If so, could you, please, report the results > and perhaps write a line or two about your overall experience with the > system. I am asking because I was wondering whether a netbook + a CAS > (commercial or open source) could be a suitable replacement of a laptop > in classroom setting (e.g. doing interactive presentations with some > real-time computations or plots of simple expressions or models). --Jean-Marc Hello I tested Mathematica for Students 7.0.0 on an ASUS EeePC and got 0.31 for the Mathematica benchmark. For most situations this should be ok in a classroom setting. But I would prefer a larger than 10'' monitor. Norbert Marxer === Subject: Debugging Mathematica Code (Mathematica 7) Hello Experts, I made my fist steps with the Mathematica (so called) debugger and stumbled immediately. Is there anywhrere a documentation of this tool that is worth it's name (a criterion which the Mathematica 7 documentatin on debug surely fails). I've tried a lot, but I'm still at the stage trial an error. Mike z === Subject: Re: Solving the Quintic: Correction to x^5 + 20 x + 32 == 0 root example > All of the roots are given by evaluating this: Module[{prim1, prim2, prim3, prim4, r1, r2, r3, r4}, > r1 = -(2500*5^(1/2) + 250* (50 - 10*5^(1/2))^(1/2) - > 750 *(50 + 10*5^(1/2))^(1/2))^(1/5); > r2 = (2500*5^(1/2) + 750 *(50 - 10*5^(1/2))^(1/2) + > 250 *(50 + 10*5^(1/2))^(1/2))^(1/5); > r3 = -(-2500*5^(1/2) + 750 *(50 - 10*5^(1/2))^(1/2) + > 250* (50 + 10*5^(1/2))^(1/2))^(1/5); > r4 = -(2500*5^(1/2) - 250* (50 - 10*5^(1/2))^(1/2) + > 750 *(50 + 10*5^(1/2))^(1/2))^(1/5); > prim1 = (-1 - 5^(1/2) + 2^(1/2)*I*(5 - 5^(1/2))^(1/2))/4; > prim2 = (-1 + 5^(1/2) - 2^(1/2)*I*(5 + 5^(1/2))^(1/2))/4; > prim3 = (-1 + 5^(1/2) + 2^(1/2)*I*(5 + 5^(1/2))^(1/2))/4; > prim4 = (-1 - 5^(1/2) - 2^(1/2)*I*(5 - 5^(1/2))^(1/2))/4; > {x -> #} & /@ ({{r1, r2, r3, r4}.{1, 1, 1, 1}, > {r1, r2, r3, r4}.{prim2, prim4, prim1, prim3}, > {r1, r2, r3, r4}.{prim3, prim1, prim4, prim2}, > {r1, r2, r3, r4}.{prim1, prim2, prim3, prim4}, > {r1, r2, r3, r4}.{prim4, prim3, prim2, prim1}}/5)] Further simplification is possible: 750 *(50 + 10*5^(1/2))^(1/2) - 250* (50 - 10*5^(1/2))^(1/2) -> 500*(125 - 10*5^(1/2))^(1/2) 750 *(50 - 10*5^(1/2))^(1/2) + 250 *(50 + 10*5^(1/2))^(1/2) -> 500*(125 + 10*5^(1/2))^(1/2) Also (5^(1/2))^5 can be factored out resulting in all of the roots given by evaluating this: Module[{prim1, prim2, prim3, prim4, r1, r2, r3, r4}, r1 = -5^(1/2)*(100 - 20*(25 - 2*5^(1/2))^(1/2))^(1/5); r2 = 5^(1/2)*(100 + 20*(25 + 2*5^(1/2))^(1/2))^(1/5); r3 = -5^(1/2)*(-100 + 20*(25 + 2*5^(1/2))^(1/2))^(1/5); r4 = -5^(1/2)*(100 + 20*(25 - 2*5^(1/2))^(1/2))^(1/5); prim1 = (-1 - 5^(1/2) + 2^(1/2)*I*(5 - 5^(1/2))^(1/2))/4; prim2 = (-1 + 5^(1/2) - 2^(1/2)*I*(5 + 5^(1/2))^(1/2))/4; prim3 = (-1 + 5^(1/2) + 2^(1/2)*I*(5 + 5^(1/2))^(1/2))/4; prim4 = (-1 - 5^(1/2) - 2^(1/2)*I*(5 - 5^(1/2))^(1/2))/4; {x -> #} & /@ ({{r1, r2, r3, r4}.{1, 1, 1, 1}, {r1, r2, r3, r4}.{prim2, prim4, prim1, prim3}, {r1, r2, r3, r4}.{prim3, prim1, prim4, prim2}, {r1, r2, r3, r4}.{prim1, prim2, prim3, prim4}, {r1, r2, r3, r4}.{prim4, prim3, prim2, prim1}}/5)] Q.E.D. === Subject: Re: Multiple Shooting Method http://en.wikipedia.org/wiki/Direct_multiple_shooting_method ?? Jens I have seen the wiki on the direct multiple shooting method but it requires guessing the intermediate values between the boundary points which I cant do. An example of this in Mathematica would help greatly. Hi My linear forward shooting method does work but my system of equations > is highly nonlinear and it does not converge on the right boundary > condition for certain parameters. I suspect that if I use a multiple shooting algorithm it will > alleviate this problem. I cant find an algorithm or mathematica > example for this method. Can someone outline the basic algorithm for > me? > S === Subject: Re: Multiple Shooting Method the algorithm compute the intermediate values and you just need a estimate, may be from a first run of the initial value solver over the full interval. Jens > http://en.wikipedia.org/wiki/Direct_multiple_shooting_method > ?? > Jens I have seen the wiki on the direct multiple shooting method but it > requires guessing the intermediate values between the boundary points > which I cant do. An example of this in Mathematica would help greatly. > > Hi > My linear forward shooting method does work but my system of equations > is highly nonlinear and it does not converge on the right boundary > condition for certain parameters. > I suspect that if I use a multiple shooting algorithm it will > alleviate this problem. I cant find an algorithm or mathematica > example for this method. Can someone outline the basic algorithm for > me? > S === Subject: DO and LISTPLOT Hallo, I use to run my routines in Mathematica 5.2. Now I have installed the 7.0. And this simple routine of making several plot one after the other seems not to work anylonger. Do[ ListPlot[AzScan[i], AxesLabel -> {[Beta][[Degree]], I[a.u.]}, BaseStyle -> {Large, FontFamily -> Arial, Bold}, PlotStyle -> {Red, PointSize[0.01]}, PlotLabel -> Azimuthal Scan], {i, 65, 160}] Does anyone have a clue what I am doing wrong? Luigi === Subject: Re: DO and LISTPLOT Do[ ListPlot[AzScan[i], AxesLabel -> {[Beta][[Degree]], I[a.u.]}, BaseStyle -> {Large, FontFamily -> Arial, Bold}, PlotStyle -> {Red, PointSize[0.01]}, PlotLabel -> Azimuthal Scan]//Print, {i, 65, 160}] ?? Jens > Hallo, > I use to run my routines in Mathematica 5.2. Now I have installed the > 7.0. And this simple routine of making several plot one after the > other seems not to work anylonger. Do[ ListPlot[AzScan[i], > AxesLabel -> {[Beta][[Degree]], I[a.u.]}, > BaseStyle -> {Large, FontFamily -> Arial, Bold}, > PlotStyle -> {Red, PointSize[0.01]}, > PlotLabel -> Azimuthal Scan], {i, 65, 160}] > Does anyone have a clue what I am doing wrong? Luigi > === Subject: image not displaying properly I am running Linux, distribution Ubuntu 8.10. I was using Mathematica 6.0 previously and was doing fine importing certain images (format PDF). However, these simple images do not import properly anymore in version 7.0. If you think you might have some insight, please reply to me and I can send you the image. I can't attach it here because of group policy. Ramiro === Subject: problem importing an image I am running Linux, distribution Ubuntu 8.10. I was using Mathematica 6.0 previously and was doing fine importing certain images (format PDF). However, these simple images do not import properly anymore in version 7.0. If you think you might have some insight, please reply to me and I can send you the image (its just about 5kb). Ramiro === Subject: newbie question about inserting values Hello all, Okay, take a look at this snippet from the book Mathematica Navigator. '***************************** p = x + Sin[y]; Consider the following example p/. x->y/.y->a y+ Sin[a] At each part of p, the rules are applied only once. Write then the following: p/.x->y/.y->a a+Sin[a] First x is replaced with y, and then y is replaced with a. Mathematica also has the command ReplaceRepeated, which is formed by //.. It applies the rules until the result no longer changes: p//.{x->y,y->a} a+Sin[a] ********************************** I'm having trouble understanding what the exact difference internally is between p/.x->y/.y->a and p//.{x->y,y->a} Patrick === Subject: Re: newbie question about inserting values try test[4] /. test[n_] /; n > 0 :> n*test[(n - 1)] and test[4] //. test[n_] /; n > 0 :> n*test[(n - 1)] Jens > Hello all, Okay, take a look at this snippet from the book Mathematica > Navigator. > '***************************** > p = x + Sin[y]; Consider the following example p/. x->y/.y->a y+ Sin[a] At each part of p, the rules are applied only once. Write then the > following: p/.x->y/.y->a a+Sin[a] First x is replaced with y, and then y is replaced with a. Mathematica > also has the command ReplaceRepeated, which is formed by //.. It > applies the rules until the result no longer changes: p//.{x->y,y->a} a+Sin[a] > ********************************** I'm having trouble understanding what the exact difference internally > is between p/.x->y/.y->a and p//.{x->y,y->a} Patrick > === Subject: Formatting in text cells ... Recently, (actually inspired by the What editor ... thread) I have had occasion to use Mathematica 7 as a text entry tool -- explanatory text followed by numbered equations, followed by more text & more numbered equations. By and large, it's proving an easier environment for this sort of task than MS Word (and equation editor), though not nearly as easy as WordPerfect's equation editor from 5.1 / 6 days. I have two (!) problems. 1. Text cells are just fine unless they include explanatory text with either super or subscripts. When these are involved, it seems that justification rules go out the window; one line might end halfway across the window while another might go all the way to the end of the window. I can get this effect simply by having something like Subscript[F, z] in the middle of a text cell, and on looking a little closer, commas appear to be the signal to start a new line irrespective of whether it's appropriate to do so. How can I get text cells to run to the end of the window when they are long enough to do so, and still contain symbols with super & subscripts? 2. Upon printing, some _parts_ cells which contain text as well as symbols and super & subscripts are printed with a darker background. Why is this, and more importantly, how do I get rid of it? Dave. === >I also gave a list of what seemed to me the main benefits of this >modular or multi-tool approach, but I overlooked one. It's been >added in below: >----------- >*** 2.5) You'll have meaningful backward compatibility or long-term >*** stability, in the sense that if you want to go back and reuse or >*** modify some project or set of files that you created say five or >*** ten years ago, the file formats for your output documents will >*** still be valid and usable, and the source files will likely be >*** also still be usable with minimal modification. Things probably won't be as rosy as you suggest above. In order to maintain backward compatibility or long-term stability you need be able to accomplish two things. Interpret the file formats as you indicate above and be able to read the physical media the files are stored on. Over a period of ten years, the requirement to be able to read the physical media is likely to be the issue. Looking back ten years ago, the primary medium for storing files were floppy disks. Today, none of the computers I use today can read a floppy disk regardless of file format. === Subject: Re: Interval arithmetic and Dependency problems >I just started to have a look at Mathematica capabilities in >Interval arithmetic. >It seems that Mathematica does not consider the so called dependency >problem (see for instance wikipedia on Interval arithmetic for an >explanation). >For example evaluate >f[x_] := x^2 + x f[Interval[{-1, 1}]] >and you get >Interval[{-1, 2}] This comes about due to Mathematica's pattern matching behavior and the way Mathematica treats a sum of intervals. Due to pattern matching, the f[Interval[{-1,1}]] evaluates to Interval[{-1,1}^2 + Interval[{-1,1}] Each term is independently evaluated and Mathematica assumes the terms to be independent when combing them into a single interval. This behavior is easily verified by doing Trace[f[Interval[{-1,1}]] Note, once Mathematica gets to Interval[{-1,1}]^2 + Interval[{-1,1}], that is doing a sum of intervals, the result has to be Interval[{1,2}] since there is nothing to require the same value to be chosen from each interval before doing the sum. That is f[Interval[{-1,1}]] says to do arithmetic on the entire interval, not a real variable selected from the specified interval. gives the correct answer >Interval[{0, 1}] >But if the same square is expressed as a product, the result is >not so good (tight): >evaluating Interval[{-1, 1}] Interval[{-1, 1}] >gives Interval[{-1, 1}] Which is correct. That is, you should not expect Mathematica to assume dependence in this case. >It seems to me that a further function should be implemented in >Mathematica. Something called IntervalEvaluation or similar, with >syntax like >IntervalEvaluation[f[x],x,Interval[...]] >Building this function should not be too difficult, using Maximize >and Minimize on the given interval. Certainly, this can be done. Whether it is preferable or not to the way Mathematica currently does interval arithmetic would depend on you needs and the problem you are trying to solve. The cost doing as you suggest is more computation and the wrong answer for some problems. === Subject: FullGraphics[] still does not work properly Consider the following: g = Plot[Sin[x], {x, 0.2, 10}] FullGraphics[g] Show[FullGraphics[g], AspectRatio -> 1/GoldenRatio] The generated plots are not the same. But the Documentation says: FullGraphics[g] should display the same as g, though it may have a different internal structure. Obviously FullGraphics[] does not work properly. :( === Subject: Re: Finding a sine wave Hi Hug, I think a direct method is much simpler than numerical iterations. Your model is: c0 Sin[c1 t+c2] You have 3 data points for 3 times. Therefore we can get rid of c0 by division e.g. the first 2 data points by the last. This leaves 2 data points and the model: Sin[c1 t+c2]. The data values must be between -1..1, this shows that there is a constrain on the original values. Now we take the ArcSin of the data values, this gives a model: c1 t + c2. Now the fit is trivial. c0 can be obtained from the original data values. Here is an example: d0 = {0.45, 0.86}; t = {0.5, 1.2} d = ArcSin /@ d0; cs = {c1, c2} /. Solve[{c1 t[[1]] + c2 == d[[1]], c1 t[[2]] + c2 == d[[2]]}, {c1, c2}][[1]]; Plot[Sin[cs.{t, 1}], {t, 0, 2 Pi/cs[[1]]}, Prolog -> {Red, Point[Transpose[{t, d0}]]}] hope this helps, Daniel > An experiment will give me three coordinates which lie on a sine wave. > I have to find the sine wave efficiently. There are three unknowns the > sine wave amplitude, A, the wavelength of the sine wave, L, and the > phase, ph. I also know that the wavelength is larger than the interval > containing my measurement points. I think this condition removes > possible multiple solutions. Below I give two methods which need improving. The first method uses > FindRoot. This methods works about 60% of the time. I give six > examples where it fails. The failure may be due to poor initial > guesses. In the second method I use FindFit. This is not quite the > correct method because I have an equal number of equations and > unknowns. Some of the failures here, I think, are due to there being > no error for the algorithm to work with. I give examples of failures. > I have also tried FindInstance, Reduce and NSolve but I don't think > these are appropriate. Here are some questions 1. I would really like a symbolic solution rather than an iterative > one. Is such a solution possible? > 2. Can anyone improve on the methods below to make them more robust? > 3. I have some control over my x-locations. How can I work out best x > locations given an estimate of the wavelength L? xx = Sort[Join[{0}, RandomReal[{0, 10}, 2]]] yy = RandomReal[{-25, 25}, 3] sol = FindRoot[{yy[[1]] - A*Sin[ph], > yy[[2]] - A*Sin[2*Pi*(xx[[2]]/L) + ph], > yy[[3]] - A*Sin[2*Pi*(xx[[3]]/L) + ph]}, {{A, > Max[Abs[yy]]}, {L, Max[xx]}, {ph, 0}}] Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, > Epilog -> {PointSize[0.02], (Point[#1] & ) /@ > Transpose[{xx, yy}]}, PlotRange -> {{0, 10}, {-25, 25}}] FindRootFailures = {{{0, 3.781264462608982, > 3.797055100562352}, {-22.948348087068737, 1.4581744078038472, > -14.242676740704574}}, {{0, 4.424069570670131, > 8.861716396743098}, {-6.444538773775843, -10.787309362608688, > 15.579334094330942}}, {{0, 4.424069570670131, > 8.861716396743098}, {-5.944536471563289, 10.627536107497393, > -21.294232497202316}}, {{0, 1.3680556047878967, > 8.546115267250002}, {4.128528863849845, 2.9017293848933923, > -22.51610539815371}}, {{0, 1.3738869718371616, > 5.689309423462079}, {20.553993773523437, -16.972841620064592, > 16.61185061676568}}, {{0, 1.0408828831133632, > 8.484645515699821}, {-3.7267589861478045, 4.1016610850387, > -24.600635061804443}}}; (({xx, yy} = #1; > sol = FindRoot[{yy[[1]] - A*Sin[ph], > yy[[2]] - A*Sin[2*Pi*(xx[[2]]/L) + ph], yy[[3]] - A*Sin[2*Pi*(xx[[3]]/L) + ph]}, {{A, > Max[Abs[yy]]}, {L, Max[xx]}, {ph, 0}}]; > Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, Epilog -> {PointSize[0.02], (Point[#1] & ) /@ > Transpose[{xx, yy}]}, > PlotRange -> {{0, 10}, {-25, 25}}]) & ) /@ > FindRootFailures xx = Sort[Join[{0}, RandomReal[{0, 10}, 2]]] yy = RandomReal[{-25, 25}, 3] sol = FindFit[ > Transpose[{xx, yy}], {A*Sin[2*Pi*(x/L) + ph], > Max[Abs[xx]] < L}, {A, L, ph}, x] Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, > Epilog -> {PointSize[0.02], (Point[#1] & ) /@ > Transpose[{xx, yy}]}, PlotRange -> {{0, 10}, {-25, 25}}] FindFitFailures = {{{0, 2.463263668380835, > 4.3190892163093615}, {-1.8407827676541144, -8.736574079785198, > 12.661520984622932}}, {{0, 3.894521446091823, > 9.937403619870642}, {12.381369822165155, 15.840399165432128, > -6.914634137727327}}, {{0, 8.087369725271945, > 8.343899312282815}, {24.73795103895976, -13.396248713970305, > 7.150470311065216}}, {{0, 1.5480031866178834, > 9.575255260205617}, {-8.163720246784278, 13.373468882892958, > -18.018462091502098}}, {{0, 0.6152784485896601, > 0.818296772602134}, {-1.858698140836046, 3.695113783904491, > -1.3186989232026658}}, {{0, 4.743093154057316, > 6.028314583406327}, {-16.60893277597446, -17.413392198343093, > -18.54081837965986}}}; (({xx, yy} = #1; > sol = FindFit[ > Transpose[{xx, yy}], {A*Sin[2*Pi*(x/L) + ph], > Max[Abs[xx]] < L}, {A, L, ph}, x]; > Plot[Evaluate[A*Sin[2*Pi*(x/L) + ph] /. sol], {x, 0, 10}, Epilog -> {PointSize[0.02], (Point[#1] & ) /@ > Transpose[{xx, yy}]}, > PlotRange -> {{0, 10}, {-25, 25}}]) & ) /@ > FindFitFailures === Subject: Re: ntdvmm error the problem comes from fpend[A_, B_] and fpendw[A_, B_]. E.g. look at: fpend[0.001,0.1]. The equation to solve reads: {-0.00001`+(w')[x]+(vz'')[x]==0, -2 w[x]-(-6+w[x] (3+2 w[x]+2 w[x]^2))/(2 (10+2 w[x]^2+w[x]^4))-(vz')[x]==0,vz[0]==0,(vz')[0]==0.001`,w[0.5`]==0.1`} note that we can easily solve the second eq. for (vz')[x]. If we differentiate the resulting expression we get vz'', what allowes us to eliminiate vz and get an equation for w: {-0.00001+3 (w')[x]+((-6+w[x] (3+2 w[x]+2 w[x]^2)) (4 w[x] (w')[x]+4 w[x]^3 (w')[x]))/(2 (10+2 w[x]^2+w[x]^4)^2)-((3+2 w[x]+2 w[x]^2) (w')[x]+w[x] (2 (w')[x]+4 w[x] (w')[x]))/(2 (10+2 w[x]^2+w[x]^4))==0,w[0.5]==0.1} NDSolve will solve this easily. Knowing w we can solve the equation for vz. Hope this helps, Daniel > Hi Im trying to solve two coupled nonlinear differential equations using > the shooting method (see variables A and B). The file is can be > downloaded at http://web.mit.edu/~shahriar/Public/submission.nb When I run it I keep getting the error > NDSolve::ntdvmm: Cannot solve to find an explicit formula for the > derivatives. NDSolve will try solving the system using a mass matrix > method. >> and then Mathematica hangs and doesnt do anything. > If I change Hz->0 for T, Mathematica solves it properly but it doesnt > seem to like it when Hz is nonzero. Any help on getting past this error will be greatly appreciated > S > === Subject: Re: Constrain independent variable in FindFit? Hi Pascal, you write that there is little agreement between the data and the model at early times. Well, simply eliminate the data for early times. hope this helps, Daniel > Hello. I am trying to fit two sets of data (two different quantities, both as > a function of time), whose models share common parameters, in a manner > similar to this MathGroup post: > http://forums.wolfram.com/mathgroup/archive/2008/Jan/msg00155.html I am using the FindFit commmand, and I already successfully specify > initial values of the input parameters (I can also constrain them, but > am not doing so currently). However, my model is ill-behaved for > early times, and the error from the early times outside my range of > interest prevents convergence to good parameter values. To avoid the > ill-behaved time values and achieve convergence, I would like to limit > the search for the fit to a particular range of times (say, t0 to t1). > Is it possible to constrain the range of independent variable values > for the FindFit function's search? My FindFit function looks something like this: > FindFit[newdat, {err[t]}, {{Gamma, 1}, {N0, 2*10^6}}, t], > where 'newdat' and 'err[t]' are basically as they are in the > aforementioned post except that 'newdat' begins at t=t0 instead of t=0 = and 'err[t]' has been weighted by the uncertainties in my data. I've already looked through Mathematica's documentation and through > MathGroup archives without much return. Hopefully someone can provide > -- > Pascal > Pascal Mickelson > mickelsp@rice.edu > === Subject: Re: Debugging Mathematica Code (Mathematica 7) No, there isn't a decent explanation. You can check prior posts by me and others on debugging, but this is the conclusion, basically. Anyway, the general feeling among knowledgeable users is that you do not really need a debugger. These users just sprinkle print statements here and there to see intermediate results. I additionally also use On[] and Off[] which help me see clearly the code flow. You don't really need much more. hth > Hello Experts, I made my fist steps with the Mathematica (so called) debugger and st= umbled > immediately. Is there anywhrere a documentation of this tool that is > worth it's name (a criterion which the Mathematica 7 documentatin on debu= g > surely fails). I've tried a lot, but I'm still at the stage trial an > error. > Mike === Subject: Re: Debugging Mathematica Code (Mathematica 7) the Wolfram Workbench has an excellent debugger and there are situations where you need it. BTW: What is so complicated ? - go to the Evaluation Menu and open the Debugger - now type into a notebook foo[0] = 1 foo[n_Integer] /; n > 0 := n*foo[n - 1] use the mouse and mark in foo[n_Integer] /; n > 0 := n*foo[n - 1] the foo[n - 1] expression. Go to the debugger window and use Break at selection Now the foo[n - 1] has a red frame. Finally go to the notebook window and enter foo[4] as an input. And ... ta ta ta The Stack window show the stack and all is as it should. Now press Continue ind the debugger menu to see the next step in the recursion ... Jens > No, there isn't a decent explanation. > You can check prior posts by me and others on debugging, but this is > the conclusion, basically. > Anyway, the general feeling among knowledgeable users is that you do > not really need a debugger. > These users just sprinkle print statements here and there to see > intermediate results. > I additionally also use On[] and Off[] which help me see clearly the > code flow. > You don't really need much more. hth > >> Hello Experts, > I made my fist steps with the Mathematica (so called) debugger and st= > umbled >> immediately. Is there anywhrere a documentation of this tool that is >> worth it's name (a criterion which the Mathematica 7 documentatin on debu= > g >> surely fails). I've tried a lot, but I'm still at the stage trial an >> error. > > Mike === Subject: Re: Debugging Mathematica Code (Mathematica 7) > Hello Experts, I made my fist steps with the Mathematica (so called) debugger and > stumbled > immediately. Is there anywhrere a documentation of this tool that is > worth it's name (a criterion which the Mathematica 7 documentatin on debug > surely fails). I've tried a lot, but I'm still at the stage trial an > error. > Mike > If you ever figure out how to use the Mathematica debugger, please post here and let me know. I could never ever figure it out. I tried. It is a mystery. I think the Mathematica experts would tell you that Mathematica do not require debugging. This might be true for the experts, but someone of us still need to use a debugger once in a while. I wish Mathematica would one day come with an easy to use debugger. --Nasser === Subject: Re: Mathematica Calls Home The Ip you gave does not seem to belong to WRI, or even to be valid. You could disconnect your pc from the net when using Mathematica and see what happens. hth My firewall is detecting outbound Internet connection attempts by > Mathematica 6.0.1. One kind of the attempts is being rated as high risk by my firewall. They > occur at Mathematica start up and seem to be related to Java binaries. (I= am > allowing these attempts, however I do not know their purpose, but I do no= t > care very much about it). The following is a bit more puzzling. Another kind of outbound connection > attempts, rated as medium risk, takes place in occasions when saving my > notebooks. Then Mathematica tries to connect to the IP 194.224.66.27 (DNS= ) > on port 53. Till now, I have allowed this kind of connection too, but I > wonder why Mathematica should make these Internet connections. Just when > saving. Any advice? === Subject: Re: Mathematica Calls Home >My firewall is detecting outbound Internet connection attempts by >Mathematica 6.0.1. Right. This is one of the features introduced in Mathematica by version 6. Among other things, by default, Mathematica accesses Wolfram's servers to update the online documentation or to access curated data used by some of the built-in functions. See the discussion that can be found by searching on tutorial/InternetConnectivity in the documentation center for more details. If you don't care to have Mathematica connect to the internet, this can be disabled in Mathematica's preferences. Of course, this will mean certain functionality of Mathematica will not be available to you. === Subject: Extract Integrate values Hello there, does anyone has an idea how i can extract integral output (i have several line of output for different conditions) and automatically make an expression which i can plot on a graph. Integrate output: { {0., t <= 87.5}, {2679.69- 61.25 t + 0.35 t^2, 87.5 < t <= 137.5}, {-10554.7 + 131.25 t - 0.35 t^2, 137.5 < t <= 155.}, {-6950.94 + 84.75 t - 0.2 t^2, 155. < t <= 187.5}, {5353.75- 46.5 t + 0.15 t^2, 187.5 < t <= 205.}, {-7253.75 + 76.5 t - 0.15 t^2, 205. < t <= 255.}, {2500., !(* TagBox[True, PiecewiseDefault, AutoDelete->False, DeletionWarning->True])} Manual typing of the above information to get it ploted: } If[t <= 87.5, 0, If[t <= 137.5, 2679.6874999999995- 61.24999999999999 t + 0.35 t^2, If[t <= 155, -10554.6875 + 131.25 t - 0.35 t^2, If[t <= 187.5, -6950.937500000001 + 84.75 t - 0.19999999999999996 t^2, If[t <= 205, 5353.750000000001 - 46.50000000000001 t + 0.15000000000000002 t^2, If[t <= 255, -7253.750000000001 + 76.50000000000001 t - 0.15000000000000002 t^2, 2500 ]]]]]]/31200 === Subject: Re: Extract Integrate values copy the ASCII code below, add a } at the end and f = Piecewise[{ {0., t <= 87.5}, {2679.69 - 61.25 t + 0.35 t^2, 87.5 < t <= 137.5}, {-10554.7 + 131.25 t - 0.35 t^2, 137.5 < t <= 155.}, {-6950.94 + 84.75 t - 0.2 t^2, 155. < t <= 187.5}, {5353.75 - 46.5 t + 0.15 t^2, 187.5 < t <= 205.}, {-7253.75 + 76.5 t - 0.15 t^2, 205. < t <= 255.}, {2500., !(* TagBox[True, PiecewiseDefault, AutoDelete->False, DeletionWarning->True])}}] Plot[f, {t, 50, 300}] Jens > Hello there, does anyone has an idea how i can extract integral output (i have > several line of output for different conditions) and automatically > make an expression which i can plot on a graph. Integrate output: > { > {0., t <= 87.5}, > {2679.69- 61.25 t + 0.35 t^2, 87.5 < t <= 137.5}, > {-10554.7 + 131.25 t - 0.35 t^2, 137.5 < t <= 155.}, > {-6950.94 + 84.75 t - 0.2 t^2, 155. < t <= 187.5}, > {5353.75- 46.5 t + 0.15 t^2, 187.5 < t <= 205.}, > {-7253.75 + 76.5 t - 0.15 t^2, 205. < t <= 255.}, > {2500., !(* > TagBox[True, > PiecewiseDefault, > AutoDelete->False, > DeletionWarning->True])} Manual typing of the above information to get it ploted: } > If[t <= 87.5, 0, > If[t <= 137.5, 2679.6874999999995- 61.24999999999999 t + 0.35 t^2, > If[t <= 155, -10554.6875 + 131.25 t - 0.35 t^2, > If[t <= 187.5, -6950.937500000001 + 84.75 t - > 0.19999999999999996 t^2, > If[t <= 205, > 5353.750000000001 - 46.50000000000001 t + > 0.15000000000000002 t^2, > If[t <= 255, -7253.750000000001 + 76.50000000000001 t - > 0.15000000000000002 t^2, 2500 > ]]]]]]/31200 > === Subject: Re: Intermediate computational results David Park's Presentations package does precisely that (plus much more) and is not very expensive. I think you should have a look at it. hth > I have a mathematical expression and I have to demonstrate a real world > example - an actual computation using the formula. > For that purpose I'd like to show all intermediate steps, not just the > final result. > Is there a way to tell Mathematica to do one step at a time and not just > show the final result? For example A=B+CD > B=10 > C=11 > D=12 A=10+11x12=10+132=142 In other words I wouldn't like to type in all the equations with the > exact numerical values. === Subject: Re: Interval arithmetic and Dependency problems [...] > For example evaluate f[x_] := x^2 + x > f[Interval[{-1, 1}]] and you get Interval[{-1, 2}] which is not really very good. [...] Intervals are assumed to be independent, say, like two independent variables. Therefore, what Mathematica computes in your example is In[1]:= Interval[{-1, 1}]^2 + Interval[{-1, 1}] Out[1]= Interval[{-1, 2}] You could think of the endpoints of the resulting interval as being the min and max values of a function of two variables over the region -1<=x|y<=1. In[2]:= Minimize[{x^2 + y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] Out[2]= {-1, {x -> 0, y -> -1}} In[3]:= Maximize[{x^2 + y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] Out[3]= {2, {x -> -1, y -> 1}} This also explains the difference between x^2 (one variable) and x*x which is rally computed as x*y (two independent variables). In[4]:= Minimize[{x*y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] Out[4]= {-1, {x -> -1, y -> 1}} In[5]:= Maximize[{x*y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] Out[5]= {1, {x -> -1, y -> -1}} --Jean-Marc === Subject: Re: Interval arithmetic and Dependency problems > I just started to have a look at Mathematica capabilities in Interval > arithmetic. It seems that Mathematica does not consider the so called dependency > problem (see for instance wikipedia on Interval arithmetic for an > explanation). The dependency problem is naturally present in interval arithmetic, as you Mathematica, but rather the _user_ of Mathematica, that needs to consider dependency when using interval arithmetic. > For example evaluate f[x_] := x^2 + x > f[Interval[{-1, 1}]] and you get Interval[{-1, 2}] which is not really very good. > The correct or, if you prefer, best result should be Interval[{-1/4,2}] since -1/4 and 2 are really the min and max values of f over the given > interval. function: f[x_] := (x + 1/2)^2 - 1/4 Then, using Mathematica, f[Interval[{-1, 1}]] yields Interval[{-1/4, 2}]. David === Subject: Re: Interval arithmetic and Dependency problems > I just started to have a look at Mathematica capabilities in Interval > arithmetic. It seems that Mathematica does not consider the so called dependency > problem > (see for instance wikipedia on Interval arithmetic for an > explanation). For example evaluate f[x_] := x^2 + x > f[Interval[{-1, 1}]] and you get Interval[{-1, 2}] which is not really very good. > The correct or, if you prefer, best result should be Interval[{-1/4,2}] since -1/4 and 2 are really the min and max values of f over the given > interval. In other words Mathematica is not capable of calculating f[x] when x > is an > Interval and f is a general function. > Yet Mathematica, according to documentation, is capable of > calculating f[x] on > an Interval, when f is restricted to a standard functions. > For example the square function Interval[{-1, 1}]^2 gives the correct answer Interval[{0, 1}] But if the same square is expressed as a product, the result is not > so good (tight): evaluating > Interval[{-1, 1}] Interval[{-1, 1}] gives > Interval[{-1, 1}] It seems to me that a further function should be implemented in > Mathematica. > Something called IntervalEvaluation or similar, with syntax like IntervalEvaluation[f[x],x,Interval[...]] Building this function should not be too difficult, using Maximize and > Minimize on the given interval. Any comments? > It may not be too difficult, but it would be far too slow. Interval arithmetic is primarily used for error estimation, and is actually used in many internal algorithms. What one needs to compute is upper bounds of functions on intervals, and performance is much more important than tightness. If you want to see this in practice take a look at my demonstration: http://demonstrations.wolfram.com/SolvingSystemsOfTranscendentalEquations/ This depends crucially on Mathematica's Interval arithmetic (thus proving that it is useful and properly implemented). Using Maximize and Minimize (or NMaximize and NMinimize for transcendental functions) will get you nowhere fast (or, more accurately, nowhere slow). Andrzej Kozlowski === Subject: Re: Interval arithmetic and Dependency problems Interval[{-1, 1}] Interval[{-1, 1}] is not equivalent to Interval[{-1, 1}]^2 In the product case there are two independent intervals and the product of these independent intervals can be anywhere on the Interval[{-1,1}]. With a single interval that is squared the result must be nonnegative. Nonetheless, I agree that there are opportunities to improve the interval calculations. Bob Hanlon I just started to have a look at Mathematica capabilities in Interval arithmetic. It seems that Mathematica does not consider the so called dependency problem (see for instance wikipedia on Interval arithmetic for an explanation). For example evaluate f[x_] := x^2 + x f[Interval[{-1, 1}]] and you get Interval[{-1, 2}] which is not really very good. The correct or, if you prefer, best result should be Interval[{-1/4,2}] since -1/4 and 2 are really the min and max values of f over the given interval. In other words Mathematica is not capable of calculating f[x] when x is an Interval and f is a general function. Yet Mathematica, according to documentation, is capable of calculating f[x] on an Interval, when f is restricted to a standard functions. For example the square function Interval[{-1, 1}]^2 gives the correct answer Interval[{0, 1}] But if the same square is expressed as a product, the result is not so good (tight): evaluating Interval[{-1, 1}] Interval[{-1, 1}] gives Interval[{-1, 1}] It seems to me that a further function should be implemented in Mathematica. Something called IntervalEvaluation or similar, with syntax like IntervalEvaluation[f[x],x,Interval[...]] Building this function should not be too difficult, using Maximize and Minimize on the given interval. Any comments? === Subject: Map onto one column of a matrix data = {{a, b}, {c, d}}; and we want to map a function onto just the second column, so we want to end up with {{a, f[b]}, {c, f[d]}}. The best way I've found to do this is with MapAt: MapAt[f, data, Table[{i, 2}, {i, Length@data}]] Is there a better way? I keep hoping there's some notation similar to what's used in Part that lets you refer to a whole column with All, -Daniel === Subject: bug in LinearProgramming This is a re-post because the original did not draw any comments. The data c = {1, 1}; m = {{1, 0}, {1, -2}, {-1, 1}}; b = {{1, 0}, {0, 1}, {0, 1}}; lu = {{0, 1}, {0, 1}}; d = {Reals, Reals}; used in LinearProgramming[c, m, b, lu, d] corresponds to the problem minimize x1+x2 subject to the constraints x1 == 1, x1-2*x2 >= 0, -x1+x2 >= 0 with real variables in the ranges 0 <= x1 <= 1, 0 <= x2 <= 1 It's clear that this problem has no solution, and Mathematica recognizes this fact. But when the domain of x2 is changed to Integers, Mathematica returns the solution x1 == 1., x2 == 1 This violates the constraint x1-2*x2 >= 0. **** earlier posting **** Here is a simple linear programming problem: c = {1, 1}; m = {{1, 0}, {1, -2}, {-1, 1}}; b = {{1, 0}, {0, 1}, {0, 1}}; lu = {{0, 1}, {0, 1}}; d = {Reals, Reals}; sol = LinearProgramming[c, m, b, lu, d] Mathematica 6 returns: LinearProgramming::lpsnf : No solution can be found that satisfies the constraints. which is obviously correct. But if I change the domain of the second variable, d = {Reals, Integers}; then Mathematica gives the solution sol = {1., 1}. The problem is that m.sol = {1., -1., 0.} violates the bound vector b (second component should be greater than 0). Is there a bug, or am I getting the syntax wrong? Veit Elser === Subject: Re: Weird self-fixing problem with cell styles I am also having the same problems. It is irritating to see that the styl= es > and fonts are constantly changed every time I run a code. To whom I shoul= d > report? support@wolfram.com Temel -----Original Message----- === > Subject: Re: Weird self-fixing problem with cell styles What happened was that something presumably changed the style sheet of > the notebook to another one. One possibility is that it was changed > somehow to the internal style sheet used by the Documentation Center > which has its styles set so that they do not appear in the > Format>Style menu. It is certainly possible that this--or something > like it--happened due to a bug. Of course if you can find the steps that caused this to happen, yoiu > shodl report it to Wolfram support so that they can investigate it... --David I was working on a Mathematica notebook when I suddenly found that I > could not use the different cell styles. (Section, Subsection, Tex, > Input, etc.) Several thins seemed broken: 1. On the toolbar, there is a popup menu for selecting a style; it was > empty - no choices. 2. The menu item Format > Style offered only one choice : Other... 3. The menu item Format > Screen Environment was disabled (grayed out). I blundered around trying to find an option that referred to cell > styles. In desperation I changed the Style Sheet, and changed it right > back again. And that fixed all the symptoms. I felt that I had been acting out an AI Koan, from that fine old (!!) > book _The New Hacker's Dictionary_, p. 404: A novice was trying to fix a broken Lisp machine by turning = th= > e > power off and on. Knight, seeing what the student was doing, spoke sternly. 'You > cannot fix a machine by just power-cycling it with no understanding of > what is going wrong.' Knight turned the machine off and on. The machine worked. I have an Apple Power PC running Mac OS X version 10.5.5; and > Mathematica 8.0.1.0. My notebook and stylesheet were originally writ= te= > n > with an older version, but I think they have been kept up to date as > needed. So what happened? And am I Knight, or am I the novice? -- > Christopher J. Henrich > chenr...@monmouth.comhttp://www.mathinteract.com === Subject: Re: Weird self-fixing problem with cell styles > I have an Apple Power PC running Mac OS X version 10.5.5; and > Mathematica 8.0.1.0. My notebook and stylesheet were originally written > with an older version, but I think they have been kept up to date as > needed. > So what happened? And am I Knight, or am I the novice? Using Mathematica 8.0.1.0 you probably just are a beta tester :-) sorry, nothing serious from me on this... albert Oops. 6.0.1.0 was what I meant. -- Christopher J. Henrich chenrich@monmouth.com http://www.mathinteract.com === Subject: Re: Multiple PDF Pages using Export > I'm interested in generating one PDF graphic per page as in fourpages=Table[Graphics[Circle[], ImageSize -> {s, s}], {s, 100, 200, = 25}] followed by something like Export[file.pdf, Table[{Page[i] -> fourcircles[[i]]}, {i, 1, 4}], PDF= ] Without the nonexistent function Page[i], i.e., just fourcircles[[i]], th= e > four images are horizontally juxtaposed in the same page and not > on separate pages. Another words, one table[[i]] graphic per one PDF page for four pages. Mathematica doesn't currently support multiple PDF pages through the Export[] function. The only way to get this behavior is to use NotebookPrint[], which has it's own limitations. Try something like this: nb = NotebookPut@ Notebook[Cell[BoxDataBox@ToBoxes@#, PageBreakBelow -> True] & /@ fourpages, PageHeaders -> {{None, None, None}, {None, None, None}}, PageFooters -> {{None, None, None}, {None, None, None}}] NotebookPrint[nb, /tmp/a.pdf] -Rob === Subject: Re: Multiple PDF Pages using Export Don, I don't think the functionality you want exists. I hope someone for my applications. I think I read somewhere that Mathematica only supports single page export in PDF (can't find it now) and this is indeed my experience. What do I do? I write 4 PDF files and then use the Adobe Acrobat assemble into a single PDF option. > Hi All! I'm interested in generating one PDF graphic per page as in fourpages=Table[Graphics[Circle[], ImageSize -> {s, s}], {s, 100, 200, 25}] followed by something like Export[file.pdf, Table[{Page[i] -> fourcircles[[i]]}, {i, 1, 4}], PDF] Without the nonexistent function Page[i], i.e., just fourcircles[[i]], the > four images are horizontally juxtaposed in the same page and not > on separate pages. Another words, one table[[i]] graphic per one PDF page for four pages. > Don J. Orser > === Subject: Dynamic, UpdateInterval and global variable Hello everybody, With Mathematica, I would like to have a Disk which evades from the origin in a Dynamic, with an UpdateInterval of 1 second. To fix the ideas the function aDisk[{x_, y_}] := Graphics[Disk[{x, y}, 0.2], PlotRange -> {{-2, 2}, {-2, 2}}, Axes -> True, AxesStyle -> RGBColor[0.47451, 0.482353, 0.47451]] will draw in disk of center {x,y}, radius 0.2, in a fixed PlotRange. Everything is fine. The following code: ListAnimate[ Map[aDisk, NestList[# + RandomReal[{0, 0.2}, 2] &, {0., 0.}, 10]]] does what I want in a ListAnimate. I would like the same in a Dynamic instruction. In the following lines the problem is the global variable pt. It seems that the option UdpdateInterval is not respected when a global variable is used: pt = {0, 0}; Dynamic[Refresh[pt = pt + RandomReal[{0, 0.2}, 2]; aDisk[pt], UpdateInterval -> 1]] Mathematica does not wait a second. The Disk evades quickly ... What should I write to see the disk going slowly up-right in a Dynamic ? I have tried with Module, DynamicModule, but nothing worked out. Antoine. === > Judging from your links, there IS no application that creates, edits, and= > maintains LaTex (and displays it; I forgot that part). It takes at least four different pieces of software? And dozens of extra,= > optional pieces? For one task? And you sometimes use a different package because it handles certain > fonts, but the other package doesn't? Wow! That sounds like quite a briar patch you're suggesting. Anyway,www.tug.org/mactex/isn't loading, and THAT'S not encouraging. I initially used TeX for early versions of my dissertation back in > 1987-1989, but the writing went on hiatus when I was assigned to the > Pentagon, dissertation unfinished. (Dr. Klingman, my adviser, was dying o= f > brain cancer at the time, though I don't offer that as an excuse.) When I= > took up the struggle again in 1992, I used Word and its Equation Editor = > (later adding MathEdit because Equation Editor was only its stunted > younger brother). It was a MUCH better experience than what I'd gone > through with TeX, although I suppose TeX had improved in the meantime as = > well. Sadly, it was not long after finishing the dissertation that Word = > would no longer display the equations properly. (A year or two?) That you had a better experience using Word+Equation Editor with the versions available in 1991 than with TeX (unless your dissertation had less that 15 equations in all) puts you in a very, very lonely class of people... -- m === For live documents nothing comes close to Mathematica. However, if you need to use a widely-accepted standard then LaTeX is the best solution. If you like to edit your LaTeX code directly then the WinEdt/MiKTeX combination is quite usable, but I much prefer to use a GUI to hide the LaTeX code. With this in mind, for the past 5 years or so I have used Publicon (www.wolfram.com/products/publicon) to create LaTeX files, but Publicon is I am concerned about its future. Recently, I have been looking at the free Lyx (http://wiki.lyx.org), and after a month of playing around with it I have nothing but praise for this wonderful piece of software. Also, transferring Publicon->Lyx via LaTeX seems to be robust. One could create a semi-live document by hot-linking the LaTeX to demonstrations (or whatever) running in Mathematica Player. For instance, static diagrams in the document could have interactive counterparts that run in Player. -- Stephen Luttrell West Malvern, UK > Although Mathematica 7 is a very powerful peace of software as far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out how to > format a text and a graphic in two or more columns and display them side > by side in a notebook as well as how to control what goes on what page > and while printing to PDF often it wouldn't print all pages, but just > the first 2-3. All that said I'm wondering what program to use to write my work in, and > I'm asking for advice - is WinWord any better when it comes to handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? === In the Windows world, BaKoMa TeX Word is WYSIWYG, has friendly installation, and now performs reasonably well. A bit more expensive than it used to be, but still very reasonable. Constantly updated. Very useful since you can both edit the WYSIWYG window or the basic LaTeX file simultaneously. Guy Lamouche >> [Unless your TeX input has some error, in which case the typeset >> output >> will only appear up a point where the error occurs; a description and >> explanation of the error will appear in a third log window -- and >> hitting some other key combo will take you back to the input window >> **with the cursor positioned at the point or line where the error was >> encountered.] > This has been the case for many years. Amazing. That means they must have produced a mind-reading version of > TeX that I am not aware of. In all versions that I know (and I have > been using TeX,LateX,Ams-Latex etc for decades) the cursor will appear > not at the place where the error (for example a missing right brace }) > occurred but at the place where TeX first notices some inconsistency > with its syntax - which is almost never the place where the error > actually occurred. At that point you have got to manually find the > actual error, which can be far from simple. The only TeX > implementation that I know that partly gets around this problem is the > Mac TeX system Textures > (http://www.bluesky.com/products/products_frames.html > ), which continually typesets your output as you type (without the > need to hit any keys), which usually will make you aware of an error > as soon as it occurs rather than much later, when you try to typeset > the you course code. Moreover, Textures has several other nice > features that are implemented only imperfectly in other versions. But > there are major caveats - a Mac OS X version is still only in beta, > years after Mac OS X occurred, and Textures costs hundreds of dollars. > But, and here is something anyone considering TeX should carefully > ponder upon. Before Mac OS X appeared, there were many persons > (including myself) willing to pay hundreds of dollars for Textures and > more for regular upgrades, in spite of the fact that lots of free TeX > implementations have always existed on the Mac (I myself now use TeX > Shop with Japanese PTex engine). This was because TeXtures avoids the > huge amount of hassle that installing and using TeX is for any > beginner and even for an experienced user. Then Blue Sky, the company > that makes Textures, failed to come up with a Mac OS X compatible > version and most users reluctantly drifted away to other programs. But > if you look mailing lists where TeX on Mac OS is discussed you will > find that many are intending to return (even though it will cost them > money) as soon as a full featured version is again available. Which > only proves that standard, free implementations of TeX are far form > the sort of thing some make them out to be. I strongly recommend you > to try TeX, but I suspect you will be soon back to using Mathematica > (if not Word). Andrzej Kozlowski > === TeX is NOT a version of HTML. Like HTML, though, it is a mark-up language; but this mark-up languages emphasizes especially logical mark-up (with the details as to how things should actually look handled by the relevant macros and packages that designers have created). For example (when using LaTeX): book style, e.g.). section{The first big thing} creates a numbered section header, with an appropriately larger and (perhaps) bolded title The first big thing, places appropriate spacing before and after the title, and creates a corresponding entry in a table of contents (in case one includes a command to include the contents). this is a emph{really} big idea is typeset so as to put the word really (by default) in italics. begin{equation} int_0^{infty} e^{-t^2},dt = frac{sqrt{pi}}{2} end{equation} creates a sequentially-numbered, centered equation displayed on a separate line saying the same thing as what the Mathematica front end renders as the value of: HoldForm[Integrate[Exp[-t^2], {t,0,[Infinity]}]==Sqrt[[Pi]]/2] LaTeX automatically justifies lines (including automatically hyphenating) and balancing lines on pages much the way a professional typesetter would do. To say more than this would go WAY beyond the proper topic of this newsgroup! Please take a look at the examples linked from he URLs I provided in my early posting. > What I find odd is using a text editor for this. Is TeX a version of HTML, then? Bobby >> What you say is both true and non-true! A commercial package such as >> PC TeX is a single application that includes the editor, previewer, etc. > On the other hand, the origin of TeX is in the *nix world, so the >> paradigm persists of a separate tool for each task: a text editor; >> the executable TeX engine itself; and a previewer (from which one >> often does the printing). The TeX engine may itself have a version >> that produces pdf directly, or one may use a separate tool in the >> bundle that converts the the standard TeX device-independent output >> .dvi file into pdf. > The TeX engine is the analog of Mathematica's kernel; the editor and >> previewer together form the analog of Mathematica's front end; and the >> various TeX/LaTeX packages are analogs of specialized Mathematical >> packages. > With contemporary distributions, however, the separation into the >> different tools is largely transparent to the user. The front-end >> editor is, in a sense, the application, and you don't really have to >> care what executable or batch file is doing what. > About fonts: producing a high-quality font family that includes all >> the necessary fonts for mathematics is no mean feat. That was a reason >> that Donald Knuth originally designed TeX, because so many journal >> letters. And among symbols I include upper & lower-case Greek, both >> upright and slanted, Cyrillic, blackboard bold, Hebrew (for set >> theory's Aleph, e.g.) > The standard, default set of fonts is Computer Modern, which looks >> great on-screen but can seem a bit spindly in print. Many folks who >> are producing technical documents with mathematical symbols want a >> different choice, and that's why the two most popular alternatives -- >> Times with MathTimes and Lucida with Lucida Math -- were developed. >> To use those, instead of Computer Modern, one simply includes a line >> or two of code in the document to load some packages; then, provided >> you have the underlying fonts, everything works transparently; you do >> have many options available that you can set for these fonts though, >> and some even for Computer Modern, e.g., just what font to use for >> script. > (TeX is is used for many purposes far from math and science, and there >> are fonts and supporting packages available for a huge number of world >> languages.) > It is NOT difficult at all to getting a working TeX system: my >> TeX-naive Math 370 students all managed to do it in short order. > But just like using Mathematica effectively takes some learning >> effort, so using LaTeX effectively does, too. > Judging from your links, there IS no application that creates, edits, > and maintains LaTex (and displays it; I forgot that part). > It takes at least four different pieces of software? And dozens of > extra, optional pieces? For one task? > And you sometimes use a different package because it handles certain > fonts, but the other package doesn't? > Wow! That sounds like quite a briar patch you're suggesting. > Anyway, www.tug.org/mactex/ isn't loading, and THAT'S not encouraging. > I initially used TeX for early versions of my dissertation back in > 1987-1989, but the writing went on hiatus when I was assigned to the > Pentagon, dissertation unfinished. (Dr. Klingman, my adviser, was > dying of brain cancer at the time, though I don't offer that as an > excuse.) When I took up the struggle again in 1992, I used Word and > its Equation Editor (later adding MathEdit because Equation Editor > was only its stunted younger brother). It was a MUCH better > experience than what I'd gone through with TeX, although I suppose > TeX had improved in the meantime as well. Sadly, it was not long > after finishing the dissertation that Word would no longer display > the equations properly. (A year or two?) > Still, my MS Thesis was accomplished (1983) with rub-off templates > for equation symbols, so it was a very significant progression from > that, to 1988 TeX, to 1992 MathEdit. > Oh, and let's not forget the Wang workstations I used, 1984-1986, > which handled equations better than anything I've seen since... until > Mathematica. > Another poster suggested LyX, and it looks very promising (though > looks can be deceiving). It seems to do everything at once. > Bobby > There are several distributions of TeX, which include the LaTeX macro >> package along with scads of other packages that modify the default >> behavior of, or add new functionality to, LaTeX. Some of these >> distributions, except for Linux, include a front end editor that >> integrates into the input -> dvi (or pdf) viewer -> print chain. > For some recommendations, see the menu item About Math 370 at: > http://bcrc.bio.umass.edu/courses/fall2008/math/math370/ > And you may be interested in the items under LaTeX resources at >> that site. > For a more complete listing of TeX/LaTeX distributions > http://www.latex-project.org/ftp.html > and the links there. > There are both free and commercial distributions. > For an easy-to-install Windows distribution that includes a front end >> editor, I recommend ProTeXt. Personally I most often use the free >> MiKTeX >> distribution (which is part of ProTeXt) together with the low-cost >> front >> end editor WinEdt (which is more powerful than the editor that comes >> with ProTeXt but is more complicated to configure). Sometimes I use the >> nicely integrated, commercial PCTeX system (www.pctex.com) just because >> some of the LaTeX packages it includes make it much easier to use the >> non-default Lucida fonts or the MathTime Pro fonts. > What application creates, edits, and maintains LaTex? Sign me curious, > Bobby >> If you want an interactive document, then there's little, if >> anything, >> that can touch Mathematica. > If you want a more-or-less static document, then the gold standard in >> the mathematical community, and in a good part of the scientific >> community, is LaTeX. You can include any Mathematica-produced graphic >> there by exporting it as EPS. > And LaTeX documents today typically wind up as PDF, with embedded >> hyperlinks and even animation and some interactive effects. > Although Mathematica 7 is a very powerful peace of software as > far as > the computational part goes it turns out to be quite limited and > unstable when it comes to word editing and processing, despite the > claims in the help that it is almost as powerful as WinWord. > For example it crashed multiple times on me while I was trying to > setup > the right fonts and sizes, as a result I lost all my work several > times, it also messed up my fonts, sizes, styles, settings for the > equations, its undo is totally useless and I couldn't figure out > how to > format a text and a graphic in two or more columns and display > them side > by side in a notebook as well as how to control what goes on what > page > and while printing to PDF often it wouldn't print all pages, but > just > the first 2-3. All that said I'm wondering what program to use to write my work > in, and > I'm asking for advice - is WinWord any better when it comes to > handling > equations? > Any other choices? What is the best way to export Mathematica 7 equations and graphics? > > >> > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === [Unless your TeX input has some error, in which case the typeset > output > will only appear up a point where the error occurs; a description and > explanation of the error will appear in a third log window -- and > hitting some other key combo will take you back to the input window > **with the cursor positioned at the point or line where the error was > encountered.] This has been the case for many years. Amazing. That means they must have produced a mind-reading version of > TeX that I am not aware of. In all versions that I know (and I have > been using TeX,LateX,Ams-Latex etc for decades) the cursor will appear = > not at the place where the error (for example a missing right brace }) = > occurred but at the place where TeX first notices some inconsistency > with its syntax - which is almost never the place where the error > actually occurred. At that point you have got to manually find the > actual error, which can be far from simple. The only TeX > implementation that I know that partly gets around this problem is the = > Mac TeX system Textures (http://www.bluesky.com/products/products_frames.= html > ), which continually typesets your output as you type (without the > need to hit any keys), which usually will make you aware of an error > as soon as it occurs rather than much later, when you try to typeset > the you course code. Moreover, Textures has several other nice > features that are implemented only imperfectly in other versions. But > there are major caveats - a Mac OS X version is still only in beta, > years after Mac OS X occurred, and Textures costs hundreds of dollars. = > But, and here is something anyone considering TeX should carefully > ponder upon. Before Mac OS X appeared, there were many persons > (including myself) willing to pay hundreds of dollars for Textures and = > more for regular upgrades, in spite of the fact that lots of free TeX > implementations have always existed on the Mac (I myself now use TeX > Shop with Japanese PTex engine). This was because TeXtures avoids the > huge amount of hassle that installing and using TeX is for any > beginner and even for an experienced user. Then Blue Sky, the company > that makes Textures, failed to come up with a Mac OS X compatible > version and most users reluctantly drifted away to other programs. But = > if you look mailing lists where TeX on Mac OS is discussed you will > find that many are intending to return (even though it will cost them > money) as soon as a full featured version is again available. Which > only proves that standard, free implementations of TeX are far form > the sort of thing some make them out to be. I strongly recommend you > to try TeX, but I suspect you will be soon back to using Mathematica > (if not Word). Have you tried installing TeXLive? -- m === Subject: Re: Torus radii & Meshes Hi Franco, you may add sections by more mesh functions: ParametricPlot3D[{{(3 + Cos[v]) Sin[u], (3 + Cos[v]) Cos[u], 4 + Sin[v]}}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, MeshFunctions -> {#4 &, #4 + 1 &, #5 &, #5 + 1 &}, Mesh -> {{{3 Pi/4, Directive[Red, Thick]}}}, PlotStyle -> {Green, Opacity[0.5]}] However, it may be easier to use Mesh->True: ParametricPlot3D[{{(3 + Cos[v]) Sin[u], (3 + Cos[v]) Cos[u], 4 + Sin[v]}}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, Mesh -> True, PlotStyle -> {Green, Opacity[0.5]}] hope this helps, Daniel > Hi everybody! I am trying to make a 3D plot of a torus highlighting its circular > sections. Now, I am not that trained with Mathematica, and all I've > succeeded in doing is to get the vertical section. I still miss the > horizontal one: ParametricPlot3D[ > { > {(3 + Cos[v]) Sin[u], > (3 + Cos[v]) Cos[u], > 4 + Sin[v]} > }, > {u, 0, 2 Pi}, > {v, 0, 2 Pi}, > MeshFunctions -> {#4 &}, Mesh -> {{{3 Pi/4, Directive[Red, Thick]}}}, > PlotStyle -> {Green, Opacity[0.5]}] > Another question. Is mathematica able to manipulate meshes? I mean, I > know I can import and plot 3D models (STL, Maya, and so on), but what > if I want to manipulate that data, getting adjacency matrices and > other information? Is there a tutorial on this issue? Franco > === Subject: Re: Using Coefficient on an equation the first example is wrong. Coefficient only works on polynomial or list of polynomials. It does not work on expressions with head Equal. Daniel > f = a*x^2 + b*x + c == 0; > First@Coefficient[f, x^2] a or Coefficient[First@f, x^2] a Bobby >> If f=a*x^2+b*x+c, Coefficient[f,x^2] obviously returns a. >> But if f=a*x^2+b*x+c==0, it returns 0. > The problem arose using the Calculus`VariationalMethods` package. >> It (unfortunately) returns the Euler-Lagrange equations as >> such, so I have to remove the useless ==0 appendage for >> Coefficient to work properly. Is there a simple direct way out? >> > === Subject: Fitting problem i have the following situation: 5 mathematical models describing the formation of different species. The models (so the species) are interdependent, means.. they all have the same parameters but some of the have also other additional parameter. Example: Model 1 has a parameter lifetime1... model 2 will include this parameter liftime1 and a new parameter lifetime2. My trouble is now to find best fit values for the parameters in all the models at the same time. I don't want to find a best fit for model 1 and then find out when doing best fit for model 2 that model 2 won't work with the parameter values found in the first run with model 1. So the fitting must consider all the models to find best fit values for the parameter. I wonder if this achievable with mathematica or if i would be better of with other software thank you for your help Ktota === Subject: simplify Hello. I have two expressions. ex1 = (S*(2*=EC^2 - 2*c*=EB^2*=F1^2*(1 + 2*c*=F1*(=F1 - Sqrt[1/c + =F1^2]= )) + =EB*=EC*(1 - 2*c*=F1^2 + 4*c^2*=F1^3*(-=F1 + Sqrt[1/c + =F1^2]= )))* BesselJ[1, r*=F1]*Cos[=E8])/ (4* Pi*=EC*(=EB + =EC)*(=EB*(1 + 6*c*=F1^2 + 4*c^2*=F1^3*(3*=F1 - 2*Sqrt[1/c + =F1^2])= + 8*c^3*=F1^5*(=F1 - Sqrt[1/c + =F1^2])) + 2*=EC*(1 + 4*c*=F1^2 + 4*c^3*=F1^5*(=F1 - Sqrt[1/c + =F1^2]) + c^2*(6*=F1^4 - 4*=F1^3*Sqrt[1/c + =F1^2])))); (*and*) ex2 = (S*(1 + c*=F1^2*(2 + c*=F1*(=F1 - Sqrt[1/c + =F1^2])))* (2*=EC^2 - 2*c*=EB^2*=F1^2*(1 + 2*c*=F1*(=F1 - Sqrt[1/c + =F1^2])= ) + =EB*=EC*(1 - 2*c*=F1^2*(1 + 2*c*=F1*(=F1 - Sqrt[1/c + =F1^2]))= ))* BesselJ[1, r*=F1]*Cos[=E8])/ (4* Pi*=EC*(=EB + =EC)*(2*=EC*(1 + c*=F1^2*(6 + c*=F1*(-5*Sqrt[1/c + =F1^2] + =F1*(15 + 2*c*=F1*(-8*Sqrt[1/c + =F1^2] + =F1*(12 + c*=F1*(-9*Sqrt[1/c + =F1^2] + =F1*(11 + 4*c*=F1*(=F1 - Sqrt[1/c + =F1^2]))))))))) + =EB*(1 + c*=F1^2*(8 + c*=F1*(-9*Sqrt[1/c + =F1^2] + =F1*(25 + 2*c*=F1*(-15*Sqrt[1/c + =F1^2] + =F1*(23 + 2*c*=F1*(-9*Sqrt[1/c + =F1^2] + =F1*(11 + 4*c*=F1*(=F1 - Sqrt[1/c + =F1^2]))))))))))); The two expressions are equivalent. Together[ex1 - ex2] 0 Simplify[ex1 == ex2] True But the first expression is simpler than the second one. Any suggestions to simplify the second expression? Dimitris === Subject: Re: Taking LCM in a polynomial expression === Subject: Chem PDB files, Export and Manipulation I would like to use Mathematica 7.0's ability to import pdb files and other (supported) chemistry related files into a Graphics3D object, to be able to position and manipulate the resulting molecules and their coordinates relative to other objects (Polygons, GraphicsComplexes, etc.). How can this be done? Is it possible to manipulate a single atom's position within Mathematica's objects, or does it need to be specified in the pdb file beforehand? When imported into Mathematica, are pdb files scalable vectors, or bitmaps? It seems that the resolution of the collective atoms deteriorates considerably once you expand the original image (within Mathematica, of course). Is it possible to export the resulting 3D image to a vector image? The section dealing with Chemistry/Biology objects in the Mathematica help is not very clear (understatement) on how to include and manipulate the resulting molecules within other graphical objects. If anyone knows anything about this, I would appreciate your help! Gideon === Subject: Re: vector-field plot You still have to provide x en y positions for your vectors. Or do you want p and q for that? === Subject: Test for composite digit Math folks, I am trying to write an algorithm which will test for a digit within a number being composite, i.e. {4, 6, 8, or 9} For example: Let's say I start with the number 844. The next number in my sequence will be the smallest number greater than 844 which satisfies: 1) a three digit number with first and third digits composite, and the second digit not composite, or a 2) a four digit number with first and third digits composite, and the second and fourth digits not composite. The answer will be 854, and I want the algorithm to be able to find this. I may then want to find a number of any specified arbitrary length with digits composite or not composite as desired. Diana === Subject: Re: Test for composite digit A less confusing version: Clear[allowed, ok3, better, stick, next3] allowed[n_Integer? Positive] := {{4, 6, 8, 9}, {0, 1, 2, 3, 5, 7}}[[Mod[n, 2, 1]]] minAllowed[n_Integer?Positive] := Min@allowed@n maxAllowed[n_Integer?Positive] := Max@allowed@n ok3[k_, {j_}] := MemberQ[allowed[j], k] better[k_, j_] := better[k, j] = {Min@Complement[allowed[j], Range[0, k]]} stick[d : {one_Integer, ___Integer}] /; ! ok3[one, {1}] := If[one > maxAllowed@1, minAllowed /@ Range[1 + Length@d], Join[better[one, 1], minAllowed /@ Range[2, Length@d]] ] stick[d : {one_Integer, two_Integer, ___Integer}] /; ! ok3[two, {2}] := If[ two > maxAllowed@2, Join[better[one, 1], minAllowed /@ Range[2, Length@d]], Join[{one}, better[two, 2], minAllowed /@ Range[3, Length@d]] ] stick[d : {__Integer}] /; Position[MapIndexed[ok3, d], False, 1, 1] == {} := d stick[d : {__Integer}] := Module[{k, bad = Position[MapIndexed[ok3, d], False, 1, 1][[1, 1]]}, k = d[[bad]]; If[ k > maxAllowed@bad, Join[Take[d, bad - 2], better[k, bad - 1], minAllowed /@ Range[bad, Length@d]], Join[Take[d, bad - 1], better[k, bad], minAllowed /@ Range[bad + 1, Length@d]] ] ] RandomInteger[{1, 7*10^5}] next2@% // Timing next3@%% // Timing 354808 {1.39235, 404040} {0.000342, 404040} Bobby > Something like this (naive but effective): Clear[ok1, composite, next1] > composite[n_] := n > 1 && ! PrimeQ@n > SetAttributes[composite, Listable] > ok1[n_] /; 1000 <= n <= 9999 := > Module[{digits = IntegerDigits[n]}, {True, False, True, False} == > composite@digits] > ok1[n_] /; 100 <= n <= 999 := > Module[{digits = IntegerDigits[n]}, {True, False, True} == > composite@digits] > next1[n_Integer] /; n < 10^4 := > Module[{k = n + 1}, While[k < 10^4 && ! ok1@k, k++]; k] test1 = Rest@NestList[next1, 844, 100] {854, 856, 858, 859, 874, 876, 878, 879, 904, 906, 908, 909, 914, > 916, 918, 919, 924, 926, 928, 929, 934, 936, 938, 939, 954, 956, 958, > 959, 974, 976, 978, 979, 4040, 4041, 4042, 4043, 4045, 4047, 4060, > 4061, 4062, 4063, 4065, 4067, 4080, 4081, 4082, 4083, 4085, 4087, > 4090, 4091, 4092, 4093, 4095, 4097, 4140, 4141, 4142, 4143, 4145, > 4147, 4160, 4161, 4162, 4163, 4165, 4167, 4180, 4181, 4182, 4183, > 4185, 4187, 4190, 4191, 4192, 4193, 4195, 4197, 4240, 4241, 4242, > 4243, 4245, 4247, 4260, 4261, 4262, 4263, 4265, 4267, 4280, 4281, > 4282, 4283, 4285, 4287, 4290, 4291} If you ALWAYS want to start with a composite digit and alternate, you > could generalize to Clear[composite, ok2] > composite[n_] := MemberQ[{4, 6, 8, 9}, n] > SetAttributes[composite, Listable] > ok2[digits_List] := > MatchQ[composite@ > digits, {PatternSequence[True, False] ..} | {PatternSequence[True, > False] .., True} | {True}] > ok2[n_Integer] := ok2@IntegerDigits@n > ok2[other_] = False; > next2[n_Integer] := Module[{k = n + 1}, While[! ok2@k, k++]; k] test2 = Rest@NestList[next2, 844, 100] {854, 856, 858, 859, 874, 876, 878, 879, 904, 906, 908, 909, 914, > 916, 918, 919, 924, 926, 928, 929, 934, 936, 938, 939, 954, 956, 958, > 959, 974, 976, 978, 979, 4040, 4041, 4042, 4043, 4045, 4047, 4060, > 4061, 4062, 4063, 4065, 4067, 4080, 4081, 4082, 4083, 4085, 4087, > 4090, 4091, 4092, 4093, 4095, 4097, 4140, 4141, 4142, 4143, 4145, > 4147, 4160, 4161, 4162, 4163, 4165, 4167, 4180, 4181, 4182, 4183, > 4185, 4187, 4190, 4191, 4192, 4193, 4195, 4197, 4240, 4241, 4242, > 4243, 4245, 4247, 4260, 4261, 4262, 4263, 4265, 4267, 4280, 4281, > 4282, 4283, 4285, 4287, 4290, 4291} test1 == test2 True All that gets very slow for large n, however, so (slightly awkward)... Clear[allowed, ok3, better, stick, next3] > allowed[n_Integer? > Positive] := {{4, 6, 8, 9}, {0, 1, 2, 3, 5, 7}}[[Mod[n, 2, 1]]] > ok3[k_, {j_}] := MemberQ[allowed[j], k] > better[k_, j_] := {Min@Complement[allowed[j], Range[0, k]]} > stick[d_List] /; VectorQ[d, IntegerQ] := > Module[{k, firstBad = Position[MapIndexed[ok3, d], False, 1, 1]}, > Which[ > firstBad == {}, d, > firstBad == {{1}}, > If[(k = d[[1]]) > Max@allowed@1, > Min /@ allowed /@ Range[1 + Length@d], > Join[better[k, 1], Min /@ allowed /@ Range[2, Length@d]] > ], > firstBad == {{2}}, If[ > (k = d[[2]]) > Max@allowed@2, > Join[{1 + d[[1]]}, Table[Min@allowed@k, {k, 2, Length@d}]], > Join[{d[[1]]}, better[k, 2], > Min /@ allowed /@ Range[3, Length@d]] > ], > True, firstBad = firstBad[[1, 1]]; If[ > (k = d[[firstBad]]) > Max@allowed@firstBad, > Join[Take[d, firstBad - 2], {1 + d[[firstBad + 1]]}, > Table[Min@allowed@k, {k, firstBad, Length@d}]], > Join[Take[d, firstBad - 1], better[k, firstBad], > Min /@ allowed /@ Range[firstBad + 1, Length@d]] > ] > ] > ] RandomInteger[{1, 7*10^5}] > next2@% // Timing > next3@%% // Timing 194872 {5.74494, 404040} {0.000277, 404040} Bobby >> Math folks, >> I am trying to write an algorithm which will test for a digit within a >> number being composite, i.e. {4, 6, 8, or 9} >> For example: >> Let's say I start with the number 844. The next number in my sequence >> will be the smallest number greater than 844 which satisfies: >> 1) a three digit number with first and third digits composite, and the >> second digit not composite, or a >> 2) a four digit number with first and third digits composite, and the >> second and fourth digits not composite. >> The answer will be 854, and I want the algorithm to be able to find >> this. >> I may then want to find a number of any specified arbitrary length >> with digits composite or not composite as desired. === Subject: Re: Test for composite digit Something like this (naive but effective): Clear[ok1, composite, next1] composite[n_] := n > 1 && ! PrimeQ@n SetAttributes[composite, Listable] ok1[n_] /; 1000 <= n <= 9999 := Module[{digits = IntegerDigits[n]}, {True, False, True, False} == composite@digits] ok1[n_] /; 100 <= n <= 999 := Module[{digits = IntegerDigits[n]}, {True, False, True} == composite@digits] next1[n_Integer] /; n < 10^4 := Module[{k = n + 1}, While[k < 10^4 && ! ok1@k, k++]; k] test1 = Rest@NestList[next1, 844, 100] {854, 856, 858, 859, 874, 876, 878, 879, 904, 906, 908, 909, 914, 916, 918, 919, 924, 926, 928, 929, 934, 936, 938, 939, 954, 956, 958, 959, 974, 976, 978, 979, 4040, 4041, 4042, 4043, 4045, 4047, 4060, 4061, 4062, 4063, 4065, 4067, 4080, 4081, 4082, 4083, 4085, 4087, 4090, 4091, 4092, 4093, 4095, 4097, 4140, 4141, 4142, 4143, 4145, 4147, 4160, 4161, 4162, 4163, 4165, 4167, 4180, 4181, 4182, 4183, 4185, 4187, 4190, 4191, 4192, 4193, 4195, 4197, 4240, 4241, 4242, 4243, 4245, 4247, 4260, 4261, 4262, 4263, 4265, 4267, 4280, 4281, 4282, 4283, 4285, 4287, 4290, 4291} If you ALWAYS want to start with a composite digit and alternate, you could generalize to Clear[composite, ok2] composite[n_] := MemberQ[{4, 6, 8, 9}, n] SetAttributes[composite, Listable] ok2[digits_List] := MatchQ[composite@ digits, {PatternSequence[True, False] ..} | {PatternSequence[True, False] .., True} | {True}] ok2[n_Integer] := ok2@IntegerDigits@n ok2[other_] = False; next2[n_Integer] := Module[{k = n + 1}, While[! ok2@k, k++]; k] test2 = Rest@NestList[next2, 844, 100] {854, 856, 858, 859, 874, 876, 878, 879, 904, 906, 908, 909, 914, 916, 918, 919, 924, 926, 928, 929, 934, 936, 938, 939, 954, 956, 958, 959, 974, 976, 978, 979, 4040, 4041, 4042, 4043, 4045, 4047, 4060, 4061, 4062, 4063, 4065, 4067, 4080, 4081, 4082, 4083, 4085, 4087, 4090, 4091, 4092, 4093, 4095, 4097, 4140, 4141, 4142, 4143, 4145, 4147, 4160, 4161, 4162, 4163, 4165, 4167, 4180, 4181, 4182, 4183, 4185, 4187, 4190, 4191, 4192, 4193, 4195, 4197, 4240, 4241, 4242, 4243, 4245, 4247, 4260, 4261, 4262, 4263, 4265, 4267, 4280, 4281, 4282, 4283, 4285, 4287, 4290, 4291} test1 == test2 True All that gets very slow for large n, however, so (slightly awkward)... Clear[allowed, ok3, better, stick, next3] allowed[n_Integer? Positive] := {{4, 6, 8, 9}, {0, 1, 2, 3, 5, 7}}[[Mod[n, 2, 1]]] ok3[k_, {j_}] := MemberQ[allowed[j], k] better[k_, j_] := {Min@Complement[allowed[j], Range[0, k]]} stick[d_List] /; VectorQ[d, IntegerQ] := Module[{k, firstBad = Position[MapIndexed[ok3, d], False, 1, 1]}, Which[ firstBad == {}, d, firstBad == {{1}}, If[(k = d[[1]]) > Max@allowed@1, Min /@ allowed /@ Range[1 + Length@d], Join[better[k, 1], Min /@ allowed /@ Range[2, Length@d]] ], firstBad == {{2}}, If[ (k = d[[2]]) > Max@allowed@2, Join[{1 + d[[1]]}, Table[Min@allowed@k, {k, 2, Length@d}]], Join[{d[[1]]}, better[k, 2], Min /@ allowed /@ Range[3, Length@d]] ], True, firstBad = firstBad[[1, 1]]; If[ (k = d[[firstBad]]) > Max@allowed@firstBad, Join[Take[d, firstBad - 2], {1 + d[[firstBad + 1]]}, Table[Min@allowed@k, {k, firstBad, Length@d}]], Join[Take[d, firstBad - 1], better[k, firstBad], Min /@ allowed /@ Range[firstBad + 1, Length@d]] ] ] ] RandomInteger[{1, 7*10^5}] next2@% // Timing next3@%% // Timing 194872 {5.74494, 404040} {0.000277, 404040} Bobby > Math folks, I am trying to write an algorithm which will test for a digit within a > number being composite, i.e. {4, 6, 8, or 9} For example: Let's say I start with the number 844. The next number in my sequence > will be the smallest number greater than 844 which satisfies: 1) a three digit number with first and third digits composite, and the > second digit not composite, or a > 2) a four digit number with first and third digits composite, and the > second and fourth digits not composite. The answer will be 854, and I want the algorithm to be able to find > this. I may then want to find a number of any specified arbitrary length > with digits composite or not composite as desired. > Diana > -- DrMajorBob@longhorns.com === Subject: Re: Test for composite digit > Math folks, I am trying to write an algorithm which will test for a digit within a > number being composite, i.e. {4, 6, 8, or 9} For example: Let's say I start with the number 844. The next number in my sequence > will be the smallest number greater than 844 which satisfies: 1) a three digit number with first and third digits composite, and the > second digit not composite, or a > 2) a four digit number with first and third digits composite, and the > second and fourth digits not composite. The answer will be 854, and I want the algorithm to be able to find > this. I may then want to find a number of any specified arbitrary length > with digits composite or not composite as desired. > Diana > This is how to split an integer into digits (not characters, but actual numbers): IntegerDigits[844] I am guessing that this is the help you need to write your code. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Stopping a running program a) your While[ 1==1, Print[Hi]] cause the kernel to send a lot of > data to the FrontEnd and the FrontEnd must format it again and > again for every new cell. So the FrontEnd is busy and it is > hard for it to send a Abort message to the Kernel. > I would suggest to use Dynamic[] to show the progress in a variable, i.e., > mymessage = Wait; > Dynamic[mymessage] i = 0; > While[True, > mymessage = If[EvenQ[i++], Humpty, Dumpty]; > ] b) if you do so, Alt-. as well as the menu entry > Evaluation | Abort Evaluation work c) if not, you have to press Alt-. several times and > hope the the FrontEnd will get it and that the buffer > with all the Print[] messages is not too full Sometimes if the FrontEnd will not respond to Alt-. or Abort Evaluation, you can shut down the kernel completely from Evaluation, Quit Kernel, Local. Of course, that clears everything that you had in memory. -- Helen Read University of Vermont === Subject: Re: Stopping a running program that is a bit rude, what is with killing the Kernel, the FrontEnd and reboot the computer ;-) Jens >> a) your While[ 1==1, Print[Hi]] cause the kernel to send a lot of >> data to the FrontEnd and the FrontEnd must format it again and >> again for every new cell. So the FrontEnd is busy and it is >> hard for it to send a Abort message to the Kernel. >> I would suggest to use Dynamic[] to show the progress in a variable, i.e., >> mymessage = Wait; >> Dynamic[mymessage] >> i = 0; >> While[True, >> mymessage = If[EvenQ[i++], Humpty, Dumpty]; >> ] >> b) if you do so, Alt-. as well as the menu entry >> Evaluation | Abort Evaluation work >> c) if not, you have to press Alt-. several times and >> hope the the FrontEnd will get it and that the buffer >> with all the Print[] messages is not too full Sometimes if the FrontEnd will not respond to Alt-. or Abort Evaluation, > you can shut down the kernel completely from Evaluation, Quit Kernel, > Local. Of course, that clears everything that you had in memory. -- > Helen Read > University of Vermont > === Subject: Re: Stopping a running program >> >> Sometimes if the FrontEnd will not respond to Alt-. or Abort Evaluation, >> you can shut down the kernel completely from Evaluation, Quit Kernel, >> Local. Of course, that clears everything that you had in memory. that is a bit rude, what is with killing the Kernel, the FrontEnd > and reboot the computer ;-) I like to show my students early in the year how to crash Mathematica, as a way of encouraging them to save their file while they work :-). -- Helen Read University of Vermont === Subject: Converting 2D Lists to 3D lists Hello Everyone, I want to know if there is a way to convert a 2D lists to 3D Lists. Below is the example list in list form: SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the second column. This is how it should look. {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, {0.5, -.75, 3}}} Is there any way I can do this? I have been trying to use Map and Insert but I am getting the wrong result. Insert[SampleList3d, x, {#, -1}] & /@ {1, 2} ; I get this result and this is not what I want: {{{{-1, 2}, {0, 1}, {3, 4}, x}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}}}, {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}, x}}} Karthik Sridhara === Subject: Re: Converting 2D Lists to 3D lists I want to know if there is a way to convert a 2D lists to 3D Lists. > Below is the example list in list form: SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, > {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; > This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, > {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the > second column. This is how it should look. > {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, > {0.5, -.75, 3}}} Is there any way I can do this? I have been trying to use Map and > Insert but I am getting the wrong result. Insert[SampleList3d, x, {#, -1}] & /@ {1, 2} ; I get this result and this is not what I want: > {{{{-1, 2}, {0, 1}, {3, 4}, > x}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}}}, {{{-1, 2}, {0, 1}, {3, > 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}, x}}} Karthik Sridhara Here is a rather inelegant way to accomplish this. I hope some one else can come up with a more elegant algorithm. SampleList3D={{{-1,2},{0,1},{3,4}},{{-3,-2},{-1.5,2.5},{0.5,-.75}}}; SampleList3D/.{{a_,b_},{c_,d_},{e_,f_}}->{{a,b,5},{c,d,5},{e,f,5}} SampleList3D /. {{a_, b_}, {c_, d_}, {e_, f_}} -> {{a, b, 5}, {c, d, 5}, {e, f, 5}}; SampleList3D /. {{{a_, b_}, {c_, d_}, {e_, f_}}, {{g_, h_}, {i_, j_}, {k_, l_}}} -> {{a, b, 5}, {c, d, 5}, {e, f, 5}, {g, h, 3}, {i, j, 3}, {k, l, 3}} Gary Boswell === Subject: Re: Converting 2D Lists to 3D lists {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; > This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, > {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the > second column. This is how it should look. > {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, > {0.5, -.75, 3}}} Among many other possible ways: In[1]:= lst = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -.75}}}; newlst = Map[Join[#, {5}] &, lst, {2}] newlst[[2, All, 3]] = 3; newlst Out[2]= {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, {0.5, -0.75, 5}}} Out[4]= {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, {0.5, -0.75, 3}}} -- Jean-Marc === Subject: Re: Converting 2D Lists to 3D lists Karthik, one convenient, if not very fast way for numerical lists is to use a rule like e.g.: to3D[list_, z_] := list /. {x_?NumericQ, y_?NumericQ} :> {x, y, z} slist = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -.75}}} {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}}} to3D[slist, 0] {{{-1, 2, 0}, {0, 1, 0}, {3, 4, 0}}, {{-3, -2, 0}, {-1.5, 2.5, 0}, {0.5, -0.75, 0}}} This is very useful for transforming sets of graphics primitives, since it works for points, lines and polygons straight away and you don=C2=B4t = have to worry about the structure of the set. Yves > Hello Everyone, I want to know if there is a way to convert a 2D lists to 3D Lists. > Below is the example list in list form: SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, > {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; > This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, > {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the > second column. This is how it should look. > {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, > {0.5, -.75, 3}}} Is there any way I can do this? I have been trying to use Map and > Insert but I am getting the wrong result. Insert[SampleList3d, x, {#, -1}] & /@ {1, 2} ; I get this result and this is not what I want: > {{{{-1, 2}, {0, 1}, {3, 4}, > x}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}}}, {{{-1, 2}, {0, 1}, {3, > 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}, x}}} > Karthik Sridhara > === Subject: Re: Converting 2D Lists to 3D lists Append[#,5] & /@ SampleList3D ?? Jens > Hello Everyone, I want to know if there is a way to convert a 2D lists to 3D Lists. > Below is the example list in list form: SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, > {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; > This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, > {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the > second column. This is how it should look. > {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, > {0.5, -.75, 3}}} Is there any way I can do this? I have been trying to use Map and > Insert but I am getting the wrong result. Insert[SampleList3d, x, {#, -1}] & /@ {1, 2} ; I get this result and this is not what I want: > {{{{-1, 2}, {0, 1}, {3, 4}, > x}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}}}, {{{-1, 2}, {0, 1}, {3, > 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}, x}}} > Karthik Sridhara > === Subject: Re: Computing nCr how? I would like to add one thing: since every Mathematica function's name tells you what the function does (there are no cryptic names such as Int for integration), it would be natural in this case to look for BinomialCoefficient or something similar, because the number the OP describes is the binomial coefficient! /Sigmund === Subject: Re: Computing nCr how? Why the obscure abbreviations Combin and Permut. Why not at least Combine and Permute, or even the more readable Combinations and Permutations? >> ... I cant find the function ...to compute nCr I remember my very first question with Mathematica was Where is Permut nPr ? > I was a little dismayed (and still am a little) that the program didn't have > the same function as found in Spreadsheets. I remember thinking that this > program must not have very many functions. (till I bought the book!) :>) Switching from a Spreadsheet to Mathematica, my very first two programs were: Combin[n_, k_] := Binomial[n, k] > Permut[n_, k_] := n!/(n - k)! However, for speed, I now use this: > Permut[a_, b_] := Pochhammer[1 + a - b, b] The second version is faster, but the first version will reduce here... > Permut[a, b]/a! > 1/(a - b)! >> I know this sounds simple but I cant find the function in mathematica >> to compute nCr (i.e. number of combination for n obj chosen in groups >> of r). Can anyone help? > -- 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 fax 413 545-1801 Amherst, MA 01003-9305 === Subject: how to find minimum value. Hi everyone, For instance, lets assume that we have an equation like a = Solve[x^2 + 3 x + 1 == 0] the solution gives 2 x values as {{x -> 1/2 (-3 - Sqrt[5])}, {x -> 1/2 (-3 + Sqrt[5])}} Which function can I use to find the min x? (Min[] or FindMimimum[] is not working) In my real question, I have more than 50 values. So I need to find a mathematica function to find the minimum value from 50 automatically. === Subject: Re: how to find minimum value. > For instance, lets assume that we have an equation like > a = Solve[x^2 + 3 x + 1 == 0] the solution gives 2 x values as {{x -> 1/2 (-3 - Sqrt[5])}, {x -> 1/2 (-3 + Sqrt[5])}} Which function can I use to find the min x? (Min[] or FindMimimum[] is not working) In my real question, I have more than 50 values. So I need to find a mathematica function to find the minimum value from 50 automatically. For the above example, Min[x /. a] (or x -> Min[x /. a] if you want a transformation rule) will suffice. However, it does handle neither complex values nor Root objects. I would recommend, therefore, using Min[Select[x /. a, Head[N[#]] =!= Complex &]] For instance, In[1]:= a = Solve[x^2 + 3 x + 1 == 0] Out[1]= {{x -> 1/2 (-3 - Sqrt[5])}, {x -> 1/2 (-3 + Sqrt[5])}} In[2]:= Min[x /. a] Out[2]= 1/2 (-3 - Sqrt[5]) In[3]:= Min[Select[x /. a, Head[N[#]] =!= Complex &]] Out[3]= 1/2 (-3 - Sqrt[5]) In[4]:= a = Solve[x^3 + 6 x^2 + 3 x + 1 == 0] Out[4]= {{x -> -2 - 3 (2/(11 - Sqrt[13]))^(1/3) - (1/2 (11 - Sqrt[13]))^( 1/3)}, {x -> -2 + 1/2 (1 + I Sqrt[3]) (1/2 (11 - Sqrt[13]))^(1/3) + ( 3 (1 - I Sqrt[3]))/(2^(2/3) (11 - Sqrt[13])^(1/3))}, {x -> -2 + 1/2 (1 - I Sqrt[3]) (1/2 (11 - Sqrt[13]))^(1/3) + ( 3 (1 + I Sqrt[3]))/(2^(2/3) (11 - Sqrt[13])^(1/3))}} In[5]:= Min[Select[x /. a, Head[N[#]] =!= Complex &]] Out[5]= -2 - 3 (2/(11 - Sqrt[13]))^(1/3) - (1/2 (11 - Sqrt[13]))^( 1/3) In[6]:= a = Solve[x^5 + 20 x^4 + 11 x^3 + 6 x^2 + 3 x + 1 == 0] Out[6]= {{x -> Root[1 + 3 #1 + 6 #1^2 + 11 #1^3 + 20 #1^4 + #1^5 &, 1]}, {x -> Root[1 + 3 #1 + 6 #1^2 + 11 #1^3 + 20 #1^4 + #1^5 &, 2]}, {x -> Root[1 + 3 #1 + 6 #1^2 + 11 #1^3 + 20 #1^4 + #1^5 &, 3]}, {x -> Root[1 + 3 #1 + 6 #1^2 + 11 #1^3 + 20 #1^4 + #1^5 &, 4]}, {x -> Root[1 + 3 #1 + 6 #1^2 + 11 #1^3 + 20 #1^4 + #1^5 &, 5]}} In[7]:= Min[Select[x /. a, Head[N[#]] =!= Complex &]] Out[7]= Root[1 + 3 #1 + 6 #1^2 + 11 #1^3 + 20 #1^4 + #1^5 &, 1] In[8]:= % // N Out[8]= -19.4499 -- Jean-Marc === Subject: Re: how to find minimum value. In[1]:= Solve[x^2+3 x+1==0] x/.% Min[%] Out[1]= {{x->1/2 (-3-Sqrt[5])},{x->1/2 (-3+Sqrt[5])}} Out[2]= {1/2 (-3-Sqrt[5]),1/2 (-3+Sqrt[5])} Out[3]= 1/2 (-3-Sqrt[5]) === Subject: Re: how to find minimum value. Min[x /. Solve[x^2 + 3 x + 1 == 0]] 1/2 (-3 - Sqrt[5]) Bobby > Hi everyone, For instance, lets assume that we have an equation like > a = Solve[x^2 + 3 x + 1 == 0] the solution gives 2 x values as {{x -> 1/2 (-3 - Sqrt[5])}, {x -> 1/2 (-3 + Sqrt[5])}} Which function can I use to find the min x? (Min[] or FindMimimum[] is > not working) In my real question, I have more than 50 values. So I need to find a > mathematica function to find the minimum value from 50 automatically. === Subject: Re: how to find minimum value. I'm not sure, that I understand you x^2 + 3 x + 1 == 0 is an equation, that has several solution but never a minimum, the equation is true or not but never minimal. Can you post your input to FindMinimum[] or NMinimize[] so that we can see *what* you want to minimize? Otherwise x /. Rest[FindMinimum[x^2 + 3 x + 1, x]][[1]] and x /. Rest[NMinimize[x^2 + 3 x + 1, x]][[1]] work as expected. Jens > Hi everyone, For instance, lets assume that we have an equation like > a = Solve[x^2 + 3 x + 1 == 0] the solution gives 2 x values as {{x -> 1/2 (-3 - Sqrt[5])}, {x -> 1/2 (-3 + Sqrt[5])}} Which function can I use to find the min x? (Min[] or FindMimimum[] is not working) In my real question, I have more than 50 values. So I need to find a mathematica function to find the minimum value from 50 automatically. === Subject: Re: how to find minimum value. Not sure I fully understand your question, but here is how to use FindMinimum[]. In[1]:= FindMinimum[x^2+3 x+1,x] Out[2]= {-1.25,{x->-1.5}} The minimum value is -1.25 and it occurs for x=-1.5. > Hi everyone, For instance, lets assume that we have an equation like > a = Solve[x^2 + 3 x + 1 == 0] the solution gives 2 x values as {{x -> 1/2 (-3 - Sqrt[5])}, {x -> 1/2 (-3 + Sqrt[5])}} Which function can I use to find the min x? (Min[] or FindMimimum[] is not working) In my real question, I have more than 50 values. So I need to find a mathematica function to find the minimum value from 50 automatically. > === Subject: Re: how to find minimum value. You want to find the smallest solution of the set of solutions of a specific equation? Min[ ] can be used only for real numbers and solutions are given as a set of rules. So, you have to convert the rules to numbers. You can do this with ReplaceAll (shortcut /.). See below. In[18]:= a = Solve[x^2 + 3 x + 1 == 0] Out[18]= {{x -> 1/2 (-3 - Sqrt[5])}, {x -> 1/2 (-3 + Sqrt[5])}} In[21]:= x /. a Out[21]= {1/2 (-3 - Sqrt[5]), 1/2 (-3 + Sqrt[5])} In[22]:= Min[x /. a] Out[22]= 1/2 (-3 - Sqrt[5]) > Hi everyone, For instance, lets assume that we have an equation like > a = Solve[x^2 + 3 x + 1 == 0] the solution gives 2 x values as {{x -> 1/2 (-3 - Sqrt[5])}, {x -> 1/2 (-3 + Sqrt[5])}} Which function can I use to find the min x? (Min[] or FindMimimum[] is no= t working) In my real question, I have more than 50 values. So I need to find a math= ematica function to find the minimum value from 50 automatically. > === Subject: Re: help with slow minimize Bobby, thank you for taking the time to help. Your first post (after some thinking) got me on the right track. And your second post was most helpful for simplifying the results and learning some new mathematica approaches. Ola ps. Of course you were right about the constants... > v1x, v1y, v2x, v2y, d1, d2 are constants. In that case, tell us their values. But never mind, try this: v1 = {v1x, v1y}; > v2 = {v2x, v2y}; > f[t_] = (1 - t)*v1 + t*v2; > g[t_] = Sqrt[f[t].f[t]] + (1 - t)*d1 + t*d2; g'[t] // Together // Numerator // FullSimplify; > solns = t /. Solve[% == 0, t] // FullSimplify {((v1x^2 - v1x v2x + > v1y (v1y - v2y)) (-(d1 - d2)^2 + (v1x - v2x)^2 + (v1y - > v2y)^2) + > Sqrt[-(d1 - > d2)^2 ((d1 - d2)^2 - (v1x - v2x)^2 - (v1y - v2y)^2) (v= 1y v2x - > v1x v2y)^2])/(((v1x - v2x)^2 + (v1y - > v2y)^2) (-(d1 - d2)^2 + (v1x - v2x)^2 + (v1y - > v2y)^2)), ((v1x^2 - v1x v2x + > v1y (v1y - v2y)) (-(d1 - d2)^2 + (v1x - v2x)^2 + (v1y - > v2y)^2) - > Sqrt[-(d1 - > d2)^2 ((d1 - d2)^2 - (v1x - v2x)^2 - (v1y - v2y)^2) (v= 1y v2x - > v1x v2y)^2])/(((v1x - v2x)^2 + (v1y - > v2y)^2) (-(d1 - d2)^2 + (v1x - v2x)^2 + (v1y - v2y)^2)= )} which might be more useful in the form soln2 = solns /. {d2 -> d + d1, v2x -> v1x + vx, v2y -> v1y + vy} // > FullSimplify {(-(v1x vx + v1y vy) (-d^2 + vx^2 + vy^2) + Sqrt[ > d^2 (v1y vx - v1x vy)^2 (-d^2 + vx^2 + vy^2)])/((vx^2 + > vy^2) (-d^2 + vx^2 + > vy^2)), -(((v1x vx + v1y vy) (-d^2 + vx^2 + vy^2) + Sqrt[ > d^2 (v1y vx - v1x vy)^2 (-d^2 + vx^2 + vy^2)])/((vx^2 + > vy^2) (-d^2 + vx^2 + vy^2)))} or mean = 1/2 Plus @@ soln2 // Simplify -((v1x vx + v1y vy)/(vx^2 + vy^2)) delta = Subtract @@ soln2 // Simplify (2 d^2 (v1y vx - v1x vy)^2)/((vx^2 + vy^2) Sqrt[ > d^2 (v1y vx - v1x vy)^2 (-d^2 + vx^2 + vy^2)]) soln3 = mean + delta {1, -1}/2 {-((v1x vx + v1y vy)/(vx^2 + vy^2)) + ( > d^2 (v1y vx - v1x vy)^2)/((vx^2 + vy^2) Sqrt[ > d^2 (v1y vx - v1x vy)^2 (-d^2 + vx^2 + vy^2)]), -(( > v1x vx + v1y vy)/(vx^2 + vy^2)) - ( > d^2 (v1y vx - v1x vy)^2)/((vx^2 + vy^2) Sqrt[ > d^2 (v1y vx - v1x vy)^2 (-d^2 + vx^2 + vy^2)])} For some values of the constants both results are complex (when vx^2 + = > vy^2 < d^2), Solve assumes all the variables could be complex anyway, and= > how do we know 0 < t < 1? We don't. These are the kind of issuesMinimizetried to deal with but couldn't, I = > suspect. Bobby > I am sorry if I was unclear. > The setup is as follows. > v0 = {0,0}, v1={v1x,v1y}, and v2={v2x,v2y} are three vertices for= ming > a triangle. > Then f[t] as defined above is a function that determines the distance > from the edge (v1-v2) to v0. As a function of t in [0,1]. > Added to that is a linear interpolation of the two values d1 and d2. > v1x, v1y, v2x, v2y, d1, d2 are constants. > So the expression is a function of one variable, t. > I want to find the minimal value and thought that mathematica would be > a good tool. > If I differentiate wrt t and set equal to zero I get a second order > equation in t. > Why is this so difficult tominimize? Or is it FullSimplify that is > difficult because > of me not placing enough constraints on the minimization? > Alternatively. Is Solve[D[..., t]==0, t] a better approach? > Ola >> You're hoping to choose ONE real variable tominimizea function of >> SEVEN= >> real variables?? >> And that means optimal t would work for ALL possible v1x, v1y, v2x, = >> v1y, = >> d1, and d2? >> OrMinimizeshould return a breakdown of all possible forms for the >> answer, with a t-value paired with different ranges of the other six >> variables in every case? >> Good luck with that! >> Bobby >> > Hi all, >> I am new to mathematica so bear with me. >> I have a relatively simple minimization problem: >> v1 = {v1x, v1y} >> v2 = {v2x, v2y} >> f[t_] := (1 - t)*v1 + t*v2 >>Minimize[{Sqrt[f[t].f[t]] + (1 - t)*d1 + t*d2, {t >= 0, t <= 1}}, >> t] // FullSimplify // Timing >> I have not yet been able to solve this on neither my Mac G5 nor my n= ew >> about two days. >> I assume I do something wrong? Can someone please give me a hint or >> explain why this problem is so difficult. >> I have already done the math by hand, and as I said it is >> straightforward, but I have more difficult minimizations I would lik= e >> mathematicahelpme with. >> Ola >> -- >> DrMajor...@longhorns.com -- > DrMajor...@longhorns.com === Subject: Re: numerical fourier transforms On Dec 30, 11:54 am, Jens-Peer Kuska you don't understand what {L_?Positive, [CapitalOmega]_?Positive} mean because you example call it with {-100, 100} > and -100 will never match _?Positive But FourierTransformApproximationList[ > {Sin[t] Exp[-t^2], t}, > {100, 1000}, 1024] work as it should. Jens > Hi All, > I will try to ask my question the most precise way I can, this time. > I am reading Trott's book on Numerics. > I need to evaluate very heavy numerical Fourier Transforms and > NFourierTransform is taking way too long. > So I found the code that Trott suggest for an approximation of a > FourierTransform, by making use of the Fractional Fourier Transform. > What do you think about this approach? Would you suggest the use of it > for numerical evaluation of fourier Trasforms of complicated > functions? > Here is the code, anyway: > FourierTransformApproximationList[{f_, t_Symbol}, {L_?Positive, > [CapitalOmega]_?Positive}, > n_Integer?Positive] := Module[{[ScriptF] = Function[t, f], = > [CapitalDelta]t = 2 L/n, fList, > fFFT, sFactor},(*list for the fractional Fourier transform*) > fList = Table[ Exp[2 I (2 - n) L [CapitalOmega] n^-2 r] [Script= F][- > L + > 2 L r/n], {r, n}]; (*carry out fractional Fourier tra= nsform*) > fFFT = Fourier[fList, FourierParameters -> {1, 2 L [CapitalOmega= ]/ > (n Pi)}]; > (*s-dependent prefactor*) > sFactor = > Table[[CapitalDelta]t/Sqrt[2 Pi] Exp[ > I (n^2 - 4) L [CapitalOmega] n^-2]* > Exp[2 I (2 - n) L [CapitalOmega] n^-2 s], {s, n}]; > (*return approximate Fourier transform*)sFactor fFFT] > My problem is that I don't understand it well enough to generalize it > for my problem. Indeed I don't understand how to pass the function as > an argument. > The provided exemple is: > (*exact continuous Fourier transform*) > approxFT = > FourierTransformApproximationList[{If[Abs[t] < 1, 1, 0], t}, {2, > 10}, 512]; > (*exact continuous Fourier transform*) > exactFT[[Omega]_] = > FourierTransform[If[Abs[t] < 1, 1, 0], t, [Omega]] // ExpToTrig // > Simplify > But how can I change the function? If I type for exemple: > approxFT = > FourierTransformApproximationList[ > Sin[t] Exp[-t^2] &[t], {-100, 100}, 1024]; > It doesn't work. My point is that I don't understand the {f_, > t_Symbol} pattern. > Davide Davide === Subject: Mathematica licensing certificate problem I just got my V7 update and I was looking at the License Certificate that came with it. It says in the Mathematica Service: section that I have Premier support (which is supposed to let me get support and updates from Wolfram), but it said instead Limited System Transfers permitted. Support and updates not included which is a bit confusing and completely contrary to the last License Certificate I received. This was an upgrade from a Personal Grid license (which is no longer a product), and in my case had a 2009 expiration in previous certificates I have received from Wolfram. Has anyone else gotten their V7 upgrades with similar wording on the License Certificate that you received about not being eligible for support and updates when they should have it? Has anyone else who had Personal Grid gotten their upgrade yet? Did it have the same wording as I got implying that support and updates are no longer available for the software? In other words, I am wondering if this mistake went out to only Personal Grid license updates or to other license types? I had requested a physical CD for the update, instead of a download, so that might also be pertinent. If people will let me know I will post a summary of results. I later spoke with several people at Wolfram, including Maggie Ruch at Wolfram, who is in charge of customer service, and she was very helpful in calming my fears about loosing support and update service, and ensured me that I still have the same support and update privileges I previously had and says there might have been a glitch in the way these certificates get printed. If anyone else has gotten a similar wording in their license certificate and who wants to make sure they still have their Premier Service, she suggested that they contact her at Wolfram and let her know you also got a similar mistake on your License Certificate. === Subject: Re: Non-deterministic numerical inaccuracies in $Version 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) No problem apparent. Bob Hanlon > Hi all, Last week Budgemano posted an issue which involved numerical > inaccuracies in Mathematica 7. Due to the xmas season it hasn't > received much attention, or so it seems. Meanwhile, I've been able to drill the problem down to the following > code: myMod := Module[ > {p}, > Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, > 0.67220312964800834576456745674567}, {-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, > 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250, ii++, > If[myMod =!= myMod, > Print[Iteration <> ToString[ii] <> fails comparison ]];] As you can see the module myMod is called twice every iteration. Its > calculations only involve constants, so the results should always be > the same. However, on my system (Mathematica 7.WinXP) the results > differ from one > call to the other at seemingly random times. This phenomenon crucially depends on the presence of the local > variable p (that isn't used!). With this variable it's there, without > it isn't. In M6 everything is OK, so this is a bug specific to > Mathematica 7. Could you check on the various platforms whether you can reproduce > this? > === Subject: Re: Non-deterministic numerical inaccuracies in It's apparently a 32bit windows xp issue with one of the newest Intel compilers. > Bob my mac is 32 bit and runs the code fine. > Peter 2009/1/1 David Bailey : >> $Version >> 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) >> No problem apparent. >> Bob Hanlon > I think I might be able to guess what this is connected with. 64-bit C > will use the XMM registers for floating point. These are 64-bits in > length. 32-bit C has to cater for much older hardware, and so will use > the old coprocessor registers. These are 80-bits in length. If the > kernel contains some code that saves these registers as 64-bit numbers = - > say in response to a random interupt - this will truncate the extra bit= s > when they are restored and make a tiny change in certain circumstances. > It would be interesting if someone at WRI would tell me if I have > guessed correctly! > David Bailey >http://www.dbaileyconsultancy.co.uk === Subject: Re: Non-deterministic numerical inaccuracies in Bob my mac is 32 bit and runs the code fine. Peter 2009/1/1 David Bailey : >> $Version >> 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) >> No problem apparent. >> Bob Hanlon I think I might be able to guess what this is connected with. 64-bit C > will use the XMM registers for floating point. These are 64-bits in > length. 32-bit C has to cater for much older hardware, and so will use > the old coprocessor registers. These are 80-bits in length. If the > kernel contains some code that saves these registers as 64-bit numbers - > say in response to a random interupt - this will truncate the extra bits > when they are restored and make a tiny change in certain circumstances. It would be interesting if someone at WRI would tell me if I have > guessed correctly! David Bailey > http://www.dbaileyconsultancy.co.uk === Subject: Re: Non-deterministic numerical inaccuracies in > Bob my mac is 32 bit and runs the code fine. > Peter 2009/1/1 David Bailey : > $Version >> 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) >> No problem apparent. > Bob Hanlon > I think I might be able to guess what this is connected with. 64-bit C >> will use the XMM registers for floating point. These are 64-bits in >> length. 32-bit C has to cater for much older hardware, and so will use >> the old coprocessor registers. These are 80-bits in length. If the >> kernel contains some code that saves these registers as 64-bit numbers - >> say in response to a random interupt - this will truncate the extra bits >> when they are restored and make a tiny change in certain circumstances. >> It would be interesting if someone at WRI would tell me if I have >> guessed correctly! >> David Bailey >> http://www.dbaileyconsultancy.co.uk > Does it use an x86 chip (I am not sure)? Also, the details of the C compiler may vary between operating systems. A long time ago, I used to work on a Fortran compiler, and the fact that the coprocessor registers held more bits that the variables whose value they represented, caused some subtle problems! I am, of course, only guessing, but it is hard to see how else a bug like this would arise! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Non-deterministic numerical inaccuracies in > $Version 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) No problem apparent. > Bob Hanlon > I think I might be able to guess what this is connected with. 64-bit C will use the XMM registers for floating point. These are 64-bits in length. 32-bit C has to cater for much older hardware, and so will use the old coprocessor registers. These are 80-bits in length. If the kernel contains some code that saves these registers as 64-bit numbers - say in response to a random interupt - this will truncate the extra bits when they are restored and make a tiny change in certain circumstances. It would be interesting if someone at WRI would tell me if I have guessed correctly! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: How to define regions for variables in NonLinearRegress? > I'm using version 5.0 (more precisely {5.0 for Microsoft Windows (November Yaron I am afraid not. According to the online help for 6.0, the syntax with constraints is a new feature introduced with this version. > I'm running a non linear regression , and would like to understand how I > can > constraint the acceptable region for variables i.e. starting from > ---------------------- Example start ------------------- > In[1]:= >> In[2]:= >> n[4]:= > Out[4]= > -------------------- Example end ------------------------- >> I'd like to specify conditions on theta1,theta2,theta3 - for example: > 1) Theta1 > 4 > 2) Theta1+Theta2 < 16 >> Depending on what version of Mathematica you use --- I believe something >> prior to version 6.0 since the package NonLinearFit is deprecated --- you >> could use the function *FindFit* that accepts constraints on the variables. >> FindFit[data,{expr,cons},pars,vars] finds a best fit subject to the >> parameter constraints cons. >> For instance, >> In[1]:= {$Version, $ReleaseNumber} >> Out[1]= {6.0 for Mac OS X x86 (64-bit) (May 21, 2008), 3} >> In[2]:= (* Find a constrained fit : *) >> In[3]:= model = a Cos[[Omega] t]; >> data = Table[{t, Cos[2.1 t]}, {t, 0, 10, .25}] + RandomReal[.1, 41]; >> In[5]:= (* Fit to the model with positive amplitude and frequency >> between 1 and 2 : *) >> In[6]:= fit = >> FindFit[data, {model, {a > 0, 1 < [Omega] < 2}}, {a, [Omega]}, t] >> Out[6]= {a -> 0.856484, [Omega] -> 2.} >> -- Jean-Marc -- Jean-Marc === Subject: Re: How to define regions for variables in NonLinearRegress? Yaron > I'm using version 5.0 (more precisely {5.0 for Microsoft Windows > (November > > Yaron I am afraid not. According to the online help for 6.0, the syntax with > constraints is a new feature introduced with this version. > I'm running a non linear regression , and would like to understand how > I > can > constraint the acceptable region for variables i.e. starting from > ---------------------- Example start ------------------- > In[1]:= >> In[2]:= >> n[4]:= > Out[4]= > -------------------- Example end ------------------------- >> I'd like to specify conditions on theta1,theta2,theta3 - for example: > 1) Theta1 > 4 > 2) Theta1+Theta2 < 16 >> Depending on what version of Mathematica you use --- I believe something >> prior to version 6.0 since the package NonLinearFit is deprecated --- > you >> could use the function *FindFit* that accepts constraints on the > variables. >> FindFit[data,{expr,cons},pars,vars] finds a best fit subject to the >> parameter constraints cons. >> For instance, >> In[1]:= {$Version, $ReleaseNumber} >> Out[1]= {6.0 for Mac OS X x86 (64-bit) (May 21, 2008), 3} >> In[2]:= (* Find a constrained fit : *) >> In[3]:= model = a Cos[[Omega] t]; >> data = Table[{t, Cos[2.1 t]}, {t, 0, 10, .25}] + RandomReal[.1, 41]; >> In[5]:= (* Fit to the model with positive amplitude and frequency >> between 1 and 2 : *) >> In[6]:= fit = >> FindFit[data, {model, {a > 0, 1 < [Omega] < 2}}, {a, [Omega]}, t] >> Out[6]= {a -> 0.856484, [Omega] -> 2.} >> -- Jean-Marc > > -- > Jean-Marc > === Subject: Re: How to define regions for variables in NonLinearRegress? have you also an example that is more instructive ? Jens > Hi All > I'm running a non linear regression , and would like to understand how I can > constraint the acceptable region for variables i.e. starting from > ---------------------- Example start ------------------- > In[1]:= In[2]:= n[4]:= > Out[4]= > -------------------- Example end ------------------------- I'd like to specify conditions on theta1,theta2,theta3 - for example: > 1) Theta1 > 4 > 2) Theta1+Theta2 < 16 etc. Any pointers would be most welcome. === Subject: Re: How to define regions for variables in NonLinearRegress? I'm using version 5.0 (more precisely {5.0 for Microsoft Windows (November Yaron I'm running a non linear regression , and would like to understand how I >> can >> constraint the acceptable region for variables i.e. starting from >> ---------------------- Example start ------------------- >> In[1]:= >> In[2]:= >> n[4]:= >> Out[4]= >> -------------------- Example end ------------------------- >> I'd like to specify conditions on theta1,theta2,theta3 - for example: >> 1) Theta1 > 4 >> 2) Theta1+Theta2 < 16 Depending on what version of Mathematica you use --- I believe something > prior to version 6.0 since the package NonLinearFit is deprecated --- you > could use the function *FindFit* that accepts constraints on the variables. > FindFit[data,{expr,cons},pars,vars] finds a best fit subject to the > parameter constraints cons. For instance, In[1]:= {$Version, $ReleaseNumber} Out[1]= {6.0 for Mac OS X x86 (64-bit) (May 21, 2008), 3} In[2]:= (* Find a constrained fit : *) In[3]:= model = a Cos[[Omega] t]; > data = Table[{t, Cos[2.1 t]}, {t, 0, 10, .25}] + RandomReal[.1, 41]; In[5]:= (* Fit to the model with positive amplitude and frequency > between 1 and 2 : *) In[6]:= fit = > FindFit[data, {model, {a > 0, 1 < [Omega] < 2}}, {a, [Omega]}, t] Out[6]= {a -> 0.856484, [Omega] -> 2.} -- Jean-Marc === Subject: Re: How to define regions for variables in NonLinearRegress? > I'm running a non linear regression , and would like to understand how I can > constraint the acceptable region for variables i.e. starting from > ---------------------- Example start ------------------- > In[1]:= In[2]:= n[4]:= > Out[4]= > -------------------- Example end ------------------------- I'd like to specify conditions on theta1,theta2,theta3 - for example: > 1) Theta1 > 4 > 2) Theta1+Theta2 < 16 Depending on what version of Mathematica you use --- I believe something prior to version 6.0 since the package NonLinearFit is deprecated --- you could use the function *FindFit* that accepts constraints on the variables. FindFit[data,{expr,cons},pars,vars] finds a best fit subject to the parameter constraints cons. For instance, In[1]:= {$Version, $ReleaseNumber} Out[1]= {6.0 for Mac OS X x86 (64-bit) (May 21, 2008), 3} In[2]:= (* Find a constrained fit : *) In[3]:= model = a Cos[[Omega] t]; data = Table[{t, Cos[2.1 t]}, {t, 0, 10, .25}] + RandomReal[.1, 41]; In[5]:= (* Fit to the model with positive amplitude and frequency between 1 and 2 : *) In[6]:= fit = FindFit[data, {model, {a > 0, 1 < [Omega] < 2}}, {a, [Omega]}, t] Out[6]= {a -> 0.856484, [Omega] -> 2.} -- Jean-Marc === Subject: Re: How to define regions for variables in NonLinearRegress? ---------------------- Example start ------------------- > In[1]:= In[2]:= n[4]:= > Out[4]= > -------------------- Example end ------------------------- It looks like something is missing in the above example (at least neither my newsreader nor Google Groups show anything). -- Jean-Marc === Subject: Re: Can mathematica save restart file for Simplify? I was wondering if mathematica can save restart file for Simplify. I am using v6.03 with Win XP pro. > Though I have been running Simplify for about two months, I have not > reached to an answer. > Now I am afraid that some day I might encounter sudden power loss. > I thought that if mathematica can save restart file for Simplify, this > will surely be an powerful insurance. Can someone help me on this issue? -Toshi > I am afraid your calculation will have achieved nothing but warm your office! Simplify and FullSimplify are often very effective, but on larger expressions they can just get stuck. How big is your expression - if it is of a size that can be posted here (in InputForm please) someone will probably have some suggestions. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Speeding-up FindInstance Bruce, The following function creates ONE column with p elements, of which k are 1, k are -1, and the rest are zero: Clear[sorted] sorted[p_][k_] /; 2 k <= p := Join[ConstantArray[-1, k], ConstantArray[0, p - 2 k], ConstantArray[1, k]] So here are all the length-10 columns made up of 0, 1, -1 that add to zero: p = 10 sorted[p] /@ Range[p/2 // Floor] 10 {{-1, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {-1, -1, 0, 0, 0, 0, 0, 0, 1, 1}, {-1, -1, -1, 0, 0, 0, 0, 1, 1, 1}, {-1, -1, -1, -1, 0, 0, 1, 1, 1, 1}, {-1, -1, -1, -1, -1, 1, 1, 1, 1, 1}} Each such column can be permuted, as in sorted[10][3] // Permutations // Length 4200 Adding permutations over all columns listed above, there are, for each column, this many choices: Length@Permutations@# & /@ (sorted[p] /@ Range[p/2 // Floor]) Total@% {90, 1260, 4200, 3150, 252} 8952 With n columns, there would be 8952^n possible X matrices. For your small example with {n,p} = {5,3}, the total is 50^3 or 125000. It is surprising, with so many to choose from, that FindInstance couldn't find ONE!! Bobby > Re Mathematica 7.0. Let X be an n-by-p array of indexed x-variables, e.g., x[1,1], x[1,2], > etc. I seek x-values in {-1, 0, 1} so that all column sums are zero and no > column is the zero vector. The code below for a 5x3 problem runs forever. What is a faster way to Bruce {n,p} = {5,3}; X=Array[x,{n,p}]; Z = Flatten[X]; > FindInstance[And@@Join[Map[#==0&,Total@X], > Map[#>0&,Map[Abs,Total@X,{2}]], > Map[Abs@#<=1&,Z]],Z,Integers] === Subject: Re: Speeding-up FindInstance > Re Mathematica 7.0. Let X be an n-by-p array of indexed x-variables, e.g., x[1,1], x[1,2], etc. I seek x-values in {-1, 0, 1} so that all column sums are zero and no column is the zero vector. > Bruce {n,p} = {5,3}; X=Array[x,{n,p}]; Z = Flatten[X]; > FindInstance[And@@Join[Map[#==0&,Total@X], > Map[#>0&,Map[Abs,Total@X,{2}]], > Map[Abs@#<=1&,Z]],Z,Integers] I trust this is a simplified example of a harder class of problem? For this specific setup you could just take a row of -1's, a row of 1's, and all other rows just 0's. Anyway, you'll want to make it explicitly a linear problem. This means the absolute values need to go away. You can do this be defining a second set of shadow variables, and imposing constraints that force them to be the absolute values of the desired set. The code below will do this, with a slight catch. It remains not quite an integer linear program due to use of inequations (linear forms set not_equal to one). There might be a better way to do it but I've not stumbled across it as yet (still working on coffee #2). {n, p} = {5, 3}; X = Array[x, {n, p}]; absX = Array[ax, {n, p}]; Z = Flatten[X]; aZ = Flatten[absX]; In[40]:= constraints = Join[Map[# == 0 &, Total@X], Map[# >= 1 &, Total@absX], Thread[aZ >= Z], Thread[aZ >= -Z], Map[-1 <= # <= 1 &, Z], Thread[aZ + Z != 1], Map[0 <= # <= 1 &, aZ]] Out[40]= {x[1, 1] + x[2, 1] + x[3, 1] + x[4, 1] + x[5, 1] == 0, x[1, 2] + x[2, 2] + x[3, 2] + x[4, 2] + x[5, 2] == 0, x[1, 3] + x[2, 3] + x[3, 3] + x[4, 3] + x[5, 3] == 0, ax[1, 1] + ax[2, 1] + ax[3, 1] + ax[4, 1] + ax[5, 1] >= 1, ax[1, 2] + ax[2, 2] + ax[3, 2] + ax[4, 2] + ax[5, 2] >= 1, ax[1, 3] + ax[2, 3] + ax[3, 3] + ax[4, 3] + ax[5, 3] >= 1, ax[1, 1] >= x[1, 1], ax[1, 2] >= x[1, 2], ax[1, 3] >= x[1, 3], ax[2, 1] >= x[2, 1], ax[2, 2] >= x[2, 2], ax[2, 3] >= x[2, 3], ax[3, 1] >= x[3, 1], ax[3, 2] >= x[3, 2], ax[3, 3] >= x[3, 3], ax[4, 1] >= x[4, 1], ax[4, 2] >= x[4, 2], ax[4, 3] >= x[4, 3], ax[5, 1] >= x[5, 1], ax[5, 2] >= x[5, 2], ax[5, 3] >= x[5, 3], ax[1, 1] >= -x[1, 1], ax[1, 2] >= -x[1, 2], ax[1, 3] >= -x[1, 3], ax[2, 1] >= -x[2, 1], ax[2, 2] >= -x[2, 2], ax[2, 3] >= -x[2, 3], ax[3, 1] >= -x[3, 1], ax[3, 2] >= -x[3, 2], ax[3, 3] >= -x[3, 3], ax[4, 1] >= -x[4, 1], ax[4, 2] >= -x[4, 2], ax[4, 3] >= -x[4, 3], ax[5, 1] >= -x[5, 1], ax[5, 2] >= -x[5, 2], ax[5, 3] >= -x[5, 3], -1 <= x[1, 1] <= 1, -1 <= x[1, 2] <= 1, -1 <= x[1, 3] <= 1, -1 <= x[2, 1] <= 1, -1 <= x[2, 2] <= 1, -1 <= x[2, 3] <= 1, -1 <= x[3, 1] <= 1, -1 <= x[3, 2] <= 1, -1 <= x[3, 3] <= 1, -1 <= x[4, 1] <= 1, -1 <= x[4, 2] <= 1, -1 <= x[4, 3] <= 1, -1 <= x[5, 1] <= 1, -1 <= x[5, 2] <= 1, -1 <= x[5, 3] <= 1, ax[1, 1] + x[1, 1] != 1, ax[1, 2] + x[1, 2] != 1, ax[1, 3] + x[1, 3] != 1, ax[2, 1] + x[2, 1] != 1, ax[2, 2] + x[2, 2] != 1, ax[2, 3] + x[2, 3] != 1, ax[3, 1] + x[3, 1] != 1, ax[3, 2] + x[3, 2] != 1, ax[3, 3] + x[3, 3] != 1, ax[4, 1] + x[4, 1] != 1, ax[4, 2] + x[4, 2] != 1, ax[4, 3] + x[4, 3] != 1, ax[5, 1] + x[5, 1] != 1, ax[5, 2] + x[5, 2] != 1, ax[5, 3] + x[5, 3] != 1, 0 <= ax[1, 1] <= 1, 0 <= ax[1, 2] <= 1, 0 <= ax[1, 3] <= 1, 0 <= ax[2, 1] <= 1, 0 <= ax[2, 2] <= 1, 0 <= ax[2, 3] <= 1, 0 <= ax[3, 1] <= 1, 0 <= ax[3, 2] <= 1, 0 <= ax[3, 3] <= 1, 0 <= ax[4, 1] <= 1, 0 <= ax[4, 2] <= 1, 0 <= ax[4, 3] <= 1, 0 <= ax[5, 1] <= 1, 0 <= ax[5, 2] <= 1, 0 <= ax[5, 3] <= 1} In[41]:= Timing[ result = FindInstance[constraints, Join[Z, aZ], Integers]] Out[41]= {24.8062, {{x[1, 1] -> 1, x[1, 2] -> 1, x[1, 3] -> 1, x[2, 1] -> 1, x[2, 2] -> 1, x[2, 3] -> 1, x[3, 1] -> 0, x[3, 2] -> 0, x[3, 3] -> -1, x[4, 1] -> -1, x[4, 2] -> -1, x[4, 3] -> -1, x[5, 1] -> -1, x[5, 2] -> -1, x[5, 3] -> 0, ax[1, 1] -> 1, ax[1, 2] -> 1, ax[1, 3] -> 1, ax[2, 1] -> 1, ax[2, 2] -> 1, ax[2, 3] -> 1, ax[3, 1] -> 0, ax[3, 2] -> 0, ax[3, 3] -> 1, ax[4, 1] -> 1, ax[4, 2] -> 1, ax[4, 3] -> 1, ax[5, 1] -> 1, ax[5, 2] -> 1, ax[5, 3] -> 0}}} In[42]:= X /. result Out[42]= {{{1, 1, 1}, {1, 1, 1}, {0, 0, -1}, {-1, -1, -1}, {-1, -1, 0}}} An alternative is to make it a quadratic program, using squares instead of emulating absolute values. For this particular example the timing seems about the same. I have no idea what to expect in general. In[47]:= constraints2 = Join[Map[# == 0 &, Total@X], Thread[Total[X^2] >= 1], Map[-1 <= # <= 1 &, Z]] Out[47]= {x[1, 1] + x[2, 1] + x[3, 1] + x[4, 1] + x[5, 1] == 0, x[1, 2] + x[2, 2] + x[3, 2] + x[4, 2] + x[5, 2] == 0, x[1, 3] + x[2, 3] + x[3, 3] + x[4, 3] + x[5, 3] == 0, x[1, 1]^2 + x[2, 1]^2 + x[3, 1]^2 + x[4, 1]^2 + x[5, 1]^2 >= 1, x[1, 2]^2 + x[2, 2]^2 + x[3, 2]^2 + x[4, 2]^2 + x[5, 2]^2 >= 1, x[1, 3]^2 + x[2, 3]^2 + x[3, 3]^2 + x[4, 3]^2 + x[5, 3]^2 >= 1, -1 <= x[1, 1] <= 1, -1 <= x[1, 2] <= 1, -1 <= x[1, 3] <= 1, -1 <= x[2, 1] <= 1, -1 <= x[2, 2] <= 1, -1 <= x[2, 3] <= 1, -1 <= x[3, 1] <= 1, -1 <= x[3, 2] <= 1, -1 <= x[3, 3] <= 1, -1 <= x[4, 1] <= 1, -1 <= x[4, 2] <= 1, -1 <= x[4, 3] <= 1, -1 <= x[5, 1] <= 1, -1 <= x[5, 2] <= 1, -1 <= x[5, 3] <= 1} In[49]:= Timing[result2 = FindInstance[constraints2, Z, Integers]] Out[49]= {23.4654, {{x[1, 1] -> -1, x[1, 2] -> -1, x[1, 3] -> -1, x[2, 1] -> -1, x[2, 2] -> -1, x[2, 3] -> -1, x[3, 1] -> 0, x[3, 2] -> 0, x[3, 3] -> 0, x[4, 1] -> 1, x[4, 2] -> 1, x[4, 3] -> 1, x[5, 1] -> 1, x[5, 2] -> 1, x[5, 3] -> 1}}} Daniel Lichtblau Wolfram Research === Subject: Re: Speeding-up FindInstance > Re Mathematica 7.0. Let X be an n-by-p array of indexed x-variables, e.g., x[1,1], > x[1,2], etc. I seek x-values in {-1, 0, 1} so that all column sums are zero and > no column is the zero vector. The code below for a 5x3 problem runs forever. What is a faster way Bruce {n,p} = {5,3}; X=Array[x,{n,p}]; Z = Flatten[X]; > FindInstance[And@@Join[Map[#==0&,Total@X], > Map[#>0&,Map[Abs,Total@X,{2}]], > Map[Abs@#<=1&,Z]],Z,Integers] > FindInstance is not the right tool to use for this sort of thing. It uses mainly algebraic algorithms, which are not really suited to what is essentially a combinatorial problem. This particular one is easiest done by hand, but if you must use Mathematica then Transpose[NestList[RotateRight, {1, 1, -1, -1, 0}, 2]] {{1, 0, -1}, {1, 1, 0}, {-1, 1, 1}, {-1, -1, 1}, {0, -1, -1}} will give you one solution. Andrzej Kozlowski === Subject: Re: Speeding-up FindInstance > Re Mathematica 7.0. Let X be an n-by-p array of indexed x-variables, > e.g., x[1,1], x[1,2], etc. I seek x-values in {-1, 0, 1} so that all column sums > are zero and no column is the zero vector. The code below for a 5x3 problem runs forever. Bruce {n,p} = {5,3}; X=Array[x,{n,p}]; Z = Flatten[X]; > FindInstance[And@@Join[Map[#==0&,Total@X], > Map[#>0&,Map[Abs,Total@X,{2}]], > Map[Abs@#<=1&,Z]],Z,Integers] {n,p} = {5,3} Z = Array[z,n] Timing[Z/.FindInstance[Tr@Z == 0 && Z.Z > 0 && Max@Abs@Z == 1, Z, Integers, p]] {5,3} {z[1],z[2],z[3],z[4],z[5]} {3.36 Second,{{0,-1,0,1,0},{0,0,0,-1,1},{0,0,0,1,-1}}} === Subject: Re: Speeding-up FindInstance > Re Mathematica 7.0. Let X be an n-by-p array of indexed x-variables, e.g., x[1,1], x[1,2], etc. I seek x-values in {-1, 0, 1} so that all column sums are zero and no column > is the zero vector. The code below for a 5x3 problem runs forever. What is a faster way to get a Bruce {n,p} = {5,3}; X=Array[x,{n,p}]; Z = Flatten[X]; > FindInstance[And@@Join[Map[#==0&,Total@X], > Map[#>0&,Map[Abs,Total@X,{2}]], > Map[Abs@#<=1&,Z]],Z,Integers] Bruce, Assuming I have understood correctly the requirements, the following function should do what you are looking for on version 6 and 7 alike in a very reasonable amount of time, even for large matrices (1/10 of a second for a 1000 by 500 matrix on my not-so-fast-anymore system). My interpretation is as follows: ..1 We can work on the columns only since there exist no particular constraints for the rows. ..2 A column is made of -1, 0, or 1 only. ..3 Not all components of a column can be zero (i.e. we exclude the null vector). ..4 It follows that a column is made of some zeros (not all but possibly none) and an equal amount of negative one and one. ..5 Finally, we want some randomness for the distribution of the values. The following function 'f', therefore, create a vector (a row vector by the way Mathematica interprets one-dimensional lists) that is made of pairs of {-1, 1}. The number of pairs (between one and half the number of required rows, rounded to the lowest integer if needed) is randomly determined for each vector, then the list of pairs is flatten and padded with enough zeros to yield a one dimensional list of length n. Then a random permutation is drawn from the vector and we the overall process continues until we have built enough columns. Well, I hope this makes sense! In[1]:= f[n_Integer /; n > 1, p_Integer /; p > 0] := Transpose[ Table[ RandomSample[ PadRight[ Flatten[Table[{-1, 1}, {RandomInteger[{1, IntegerPart[n/2]}]}]], n]] , {p}] ] m = f[5, 3] Count[Transpose[m], _?(VectorQ[#, (# == 0 &)] &)] Total[m] Dimensions[m] TableForm[m] Out[2]= {{1, -1, 1}, {-1, 0, -1}, {0, 1, -1}, {1, 0, 0}, {-1, 0, 1}} Out[3]= 0 Out[4]= {0, 0, 0} Out[5]= {5, 3} Out[6]//TableForm= 1 -1 1 -1 0 -1 0 1 -1 1 0 0 -1 0 1 In[7]:= f[27, 13] Count[Transpose[m], _?(VectorQ[#, (# == 0 &)] &)] Total[m] Out[7]= {{0, -1, 1, 1, -1, 0, -1, 0, 0, 0, -1, 0, 0}, {0, 1, 1, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0}, {0, 1, 1, -1, 1, 0, 1, 0, 0, 0, 0, 0, -1}, {0, -1, 1, 1, 0, -1, 1, 0, 0, -1, 0, 0, 0}, {0, 1, 1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0}, {0, 1, -1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}, {0, 0, 1, 1, 1, -1, 0, 0, 0, 0, 1, -1, 0}, {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, {0, -1, -1, -1, 0, 1, -1, 0, 0, 0, 0, 0, 0}, {0, -1, -1, 0, -1, 0, -1, 1, -1, 0, 0, 0, 0}, {0, -1, -1, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1}, {-1, -1, -1, -1, 0, 0, 1, 0, 1, 0, 0, 0, 0}, {0, 1, 1, -1, 0, 0, -1, 0, 1, 0, 0, 0, 0}, {0, -1, -1, 1, 0, 0, -1, 1, 0, 0, 0, 0, 0}, {0, -1, -1, 0, -1, 0, 1, -1, 0, 0, 0, 0, 1}, {0, -1, -1, 1, 0, 0, -1, 0, 0, 0, -1, 0, 0}, {0, 1, 1, -1, 0, 1, 1, 0, 0, 0, 0, 1, 0}, {0, 1, -1, 1, 0, 1, -1, -1, 0, 0, 0, 0, 0}, {0, -1, 1, -1, -1, 0, 1, 0, -1, 0, 0, 0, 0}, {0, -1, -1, -1, 0, 0, -1, 0, 0, 0, 0, -1, 0}, {0, -1, -1, 1, 0, 0, -1, 1, -1, 0, -1, 0, 0}, {0, 1, 1, -1, 0, 0, 1, 0, 0, 0, -1, 0, 0}, {0, 1, 0, -1, 1, 0, 0, -1, 1, 0, 1, -1, 0}, {0, 0, 1, 1, 0, -1, 1, 0, 0, 0, 1, 0, 0}, {1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, -1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0}, {0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1}} Out[8]= 0 Out[9]= {0, 0, 0} In[10]:= Timing[m = f[1000, 500]][[1]] Count[Transpose[m], _?(VectorQ[#, (# == 0 &)] &)] Count[Total[m], _Except[0]] Out[10]= 0.106797 Out[11]= 0 Out[12]= 0 -- Jean-Marc === Subject: Combining Plots with Different Ordinate Axes in Mathematica Hi All, I'd like to combine two plots in Mathematica that have different x axes, but have similar y axes. In the first plot, the x range runs from 0 to 1.9, while in the second plot the x values run from 2.5 to 3.5. I'd like to combine these plots together, and have one set of x values displayed on the top edge of a frame, and the other set of x values displayed on the bottom edge of the frame. Both plots can have a common y axis. --Buz === Subject: PasteButton question I'm just starting to use PasteButton. (I'm using V7 for XP Pro.) It works fine but I'd like to fine tune it. A toy example illustrates the issue: PasteButton[press, Panel[Labeled[Grid[{{1, 2}, {3, 4}}], Label, Top]]] When the button is pressed, the panel is returned and the label is highlighted (selected?). I'd rather have the point set just after the panel. Is that possible? Mark === Subject: Re: how to find minimum value. a = Solve[x^2 + 3 x + 1 == 0] {{x -> (1/2)*(-3 - Sqrt[5])}, {x -> (1/2)*(Sqrt[5] - 3)}} Select[a, #[[1, 2]] == Min[a[[All, 1, 2]]] &][[1]] {x -> (1/2)*(-3 - Sqrt[5])} or Min[x /. Solve[x^2 + 3 x + 1 == 0]] (1/2)*(-3 - Sqrt[5]) Bob Hanlon > Hi everyone, For instance, lets assume that we have an equation like > a = Solve[x^2 + 3 x + 1 == 0] the solution gives 2 x values as {{x -> 1/2 (-3 - Sqrt[5])}, {x -> 1/2 (-3 + Sqrt[5])}} Which function can I use to find the min x? (Min[] or FindMimimum[] is > not working) In my real question, I have more than 50 values. So I need to find a > mathematica function to find the minimum value from 50 automatically. > === Subject: Re: Combining Plots with Different Ordinate Axes in In both plots you used, but didn't define, vSqueezeSeps. Did you mean vSqueezeEnergies? Bobby > Hi Bobby, > That code worked on my Mac. Unfortunately, I tried to make use of the > code with ListPlot, but couldn't get the ticks to tick marks and tick > labels to show up on the top edge of the frame. Here's what I tried: hSlideSeps = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, > 1.2, 1.3, 1.4, > 1.5, 1.6, 1.7, 1.8, 1.9} vSlideSeps = {2., 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3., 3.1, > 3.2, 3.3, 3.4, > 3.5, 3.6, 3.7, 3.8, 3.9} hSlideEnergies={1.933, 1.933, 1.933, 1.934, 1.934, 1.935, 1.937, 1.938, > 1.94, 1.941, 1.942, > 1.944, 1.946, 1.947, 1.949, 1.95, 1.951, 1.952, 1.954, 1.955} vSqueezeEnergies={0.99, 0.269, 0.456, 1.044, 1.186, 1.313, 1.437, 1.548, > 1.643, 1.721, 1.783, > 1.832, 1.87, 1.898, 1.918, 1.933, 1.943, 1.95, 1.955, 1.958} range1 = {0, 1.9}; > range2 = {2.0, 3.9}; > map = Interpolation[Transpose@{range1, range2}, InterpolationOrder -> 1]; With[ > {range3 = Flatten@{x, range1}, > top = {#, Round[map@#, 0.01]} & /@ Range[Sequence @@ range1, 0.5]}, > plot1 = ListPlot[Transpose[{vSqueezeSeps, hSlideEnergies}], Joined - > > True]; > plot2 = ListPlot[Transpose[{vSqueezeSeps, vSqueezeEnergies}], > Joined -> True]; > Show[plot2, plot1, PlotRange -> All, Axes -> False, PlotRange -> All, > Frame -> True, FrameTicks -> {{Automatic, Automatic}, {Automatic, > top}}]] > Am I doing something dumb? > --Buz > For instance, >> range1 = {0, 1.9}; >> range2 = {2.5, 3.5}; >> map = Interpolation[Transpose@{range1, range2}, >> InterpolationOrder -> 1]; >> With[{range3 = Flatten@{x, range1}, >> top = {#, Round[map@#, 0.01]} & /@ Range[Sequence @@ range1, 0.5]}, >> p1 = Plot[Sin[x], range3, PlotStyle -> Red]; >> p2 = Plot[Cos[map@x], range3, PlotStyle -> Blue]; >> Show[p1, p2, PlotRange -> All, Axes -> False, PlotRange -> All, >> Frame -> True, >> FrameTicks -> {{Automatic, Automatic}, {Automatic, top}}] >> ] >> ?? >> Bobby > Hi All, >> I'd like to combine two plots in Mathematica that have different x > axes, but have similar y axes. >> In the first plot, the x range runs from 0 to 1.9, while in the second > plot the x values run from 2.5 to 3.5. >> I'd like to combine these plots together, and have one set of x values > displayed on the top edge of a frame, and the other set of x values > displayed on the bottom edge of the frame. >> Both plots can have a common y axis. > --Buz > --DrMajorBob@longhorns.com > -- DrMajorBob@longhorns.com === Subject: Re: Combining Plots with Different Ordinate Axes in Hi Bobby, That code worked on my Mac. Unfortunately, I tried to make use of the code with ListPlot, but couldn't get the ticks to tick marks and tick labels to show up on the top edge of the frame. Here's what I tried: hSlideSeps = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9} vSlideSeps = {2., 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3., 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9} hSlideEnergies={1.933, 1.933, 1.933, 1.934, 1.934, 1.935, 1.937, 1.938, 1.94, 1.941, 1.942, 1.944, 1.946, 1.947, 1.949, 1.95, 1.951, 1.952, 1.954, 1.955} vSqueezeEnergies={0.99, 0.269, 0.456, 1.044, 1.186, 1.313, 1.437, 1.548, 1.643, 1.721, 1.783, 1.832, 1.87, 1.898, 1.918, 1.933, 1.943, 1.95, 1.955, 1.958} range1 = {0, 1.9}; range2 = {2.0, 3.9}; map = Interpolation[Transpose@{range1, range2}, InterpolationOrder -> 1]; With[ {range3 = Flatten@{x, range1}, top = {#, Round[map@#, 0.01]} & /@ Range[Sequence @@ range1, 0.5]}, plot1 = ListPlot[Transpose[{vSqueezeSeps, hSlideEnergies}], Joined - > True]; plot2 = ListPlot[Transpose[{vSqueezeSeps, vSqueezeEnergies}], Joined -> True]; Show[plot2, plot1, PlotRange -> All, Axes -> False, PlotRange -> All, Frame -> True, FrameTicks -> {{Automatic, Automatic}, {Automatic, top}}]] Am I doing something dumb? --Buz > For instance, range1 = {0, 1.9}; > range2 = {2.5, 3.5}; > map = Interpolation[Transpose@{range1, range2}, > InterpolationOrder -> 1]; With[{range3 = Flatten@{x, range1}, > top = {#, Round[map@#, 0.01]} & /@ Range[Sequence @@ range1, 0.5]}, > p1 = Plot[Sin[x], range3, PlotStyle -> Red]; > p2 = Plot[Cos[map@x], range3, PlotStyle -> Blue]; > Show[p1, p2, PlotRange -> All, Axes -> False, PlotRange -> All, > Frame -> True, > FrameTicks -> {{Automatic, Automatic}, {Automatic, top}}] > ] ?? Bobby >> Hi All, >> I'd like to combine two plots in Mathematica that have different x >> axes, but have similar y axes. >> In the first plot, the x range runs from 0 to 1.9, while in the >> second >> plot the x values run from 2.5 to 3.5. >> I'd like to combine these plots together, and have one set of x >> values >> displayed on the top edge of a frame, and the other set of x values >> displayed on the bottom edge of the frame. >> Both plots can have a common y axis. >> --Buz > > -- > DrMajorBob@longhorns.com === Subject: Re: Combining Plots with Different Ordinate Axes in For instance, range1 = {0, 1.9}; range2 = {2.5, 3.5}; map = Interpolation[Transpose@{range1, range2}, InterpolationOrder -> 1]; With[{range3 = Flatten@{x, range1}, top = {#, Round[map@#, 0.01]} & /@ Range[Sequence @@ range1, 0.5]}, p1 = Plot[Sin[x], range3, PlotStyle -> Red]; p2 = Plot[Cos[map@x], range3, PlotStyle -> Blue]; Show[p1, p2, PlotRange -> All, Axes -> False, PlotRange -> All, Frame -> True, FrameTicks -> {{Automatic, Automatic}, {Automatic, top}}] ] ?? Bobby > Hi All, I'd like to combine two plots in Mathematica that have different x > axes, but have similar y axes. In the first plot, the x range runs from 0 to 1.9, while in the second > plot the x values run from 2.5 to 3.5. I'd like to combine these plots together, and have one set of x values > displayed on the top edge of a frame, and the other set of x values > displayed on the bottom edge of the frame. Both plots can have a common y axis. > --Buz > -- DrMajorBob@longhorns.com === Subject: Re: Combining Plots with Different Ordinate Axes in Buz, you're going to have to combine two aspects: 1. To get the upper axis you want, use have to manually specify Ticks->. 2. To get your second graph onto your first, when you do the Plot[] of that graph, transform the coordinates with Rescale[]. All of this is a little bit of a hassle, and if you're not familiar with these commands, set aside 60 min to figure them out. > Hi All, I'd like to combine two plots in Mathematica that have different x > axes, but have similar y axes. In the first plot, the x range runs from 0 to 1.9, while in the second > plot the x values run from 2.5 to 3.5. I'd like to combine these plots together, and have one set of x values > displayed on the top edge of a frame, and the other set of x values > displayed on the bottom edge of the frame. Both plots can have a common y axis. > --Buz === Subject: Sound Spectrogram over time, in 3D, using Fourier? I'm rather new to Mathematica, and am attempting to make a 3D plot showing how the frequency profile of a sound sample changes over time. I've imported a .5 second audio file: wave = Import[clip.wav,Data] which returns a list of amplitude values of the wave (The file is sampled at 44.1 kHz, so there are about 22k numbers in the list). I can get a nice 2D plot of the frequency spectrum for the length of the whole clip with: ListLinePlot[Take[Abs[Fourier[wave]],650],PlotRange -> {0,2.5}] where 650 is the max frequency shown (in Hz I think?) and 0-2.5 is the intensity range (I'm not sure what these values mean, but I'd like to see it in dB). What I would like to do is plot a 3 second long clip in 3D and show how the frequency profile changes over those 3 seconds, so x=frequency, y=intensity, z=time. I understand that my above 2D plot is one fat slice, and that I need to make hundreds or thousands of similar slices over the 3 second clip to make the 3D plot, I'm just not sure how to do it. J === Subject: Re: Sound Spectrogram over time, in 3D, using Fourier? Bobby > Hi Justin, A couple of remarks with respect to your question: 1. Fourier returns the discrete fourier transform (DFT) of a list of > numbers. There is no way the Fourier function could know how these > were sampled. The same list of numbers may be the result of sampling > at a rate of one sample a day or at 44.1 KHz or whatever. Therefore, > you cannot interpret the output in terms of frequencies. At least, not > directly. If you know the duration of your set of samples (T) then a > number at position s of the output list corresponds to a frequency of > (s-1)/T Hz. 2. The value of a Fourier result at position s equals the complex > conjugated value at position n-s+2 for 1<=s<=n/2, with n the number of > samples. Look for instance at this: res = Fourier[Table[Sin[2 [Pi] 1 t], {t, 0, 1, 1/99}]] Table[Conjugate[res[[i]]] - res[[Length[res] - i + 2]], {i, 2, Length > [res]/2}] The DC term (the average value) of your samples is at position 1. So, > the result can be expressed as the first n/2 complex numbers, the > remainder of the output is redundant. Therefore, the highest > representable frequency is n/2/T (Nyquist frequency). It therefore > makes no sense to plot the whole range of the output of Fourier[ ]. > Half of it suffices. If Fs is the sample frequency, then n = Fs T and > the highest representable frequency equals Fs/2. BTW: note that n/2 complex numbers contain the same amount of > information as n real numbers, so no information is lost in the > transformation. 3. The size of the numbers in the output depends on the choice of the > normalization term in the fourier transform. Look for > FourierParameters in the documentation. 4. The decibel scale is a relative scale in which values are related > to a given reference level. You have to provide this reference level > yourself (it will have a dB level of 0). Given a certain ref power > level P0, the value of a power level P1 in dB is given by 10*Log10[P1/ > P0]. Often, power is related to the amplitude squared so the value of > P1 in dB will be 20* Log10[A1/A0] when using amplitudes. 5. As to the 3D plot: should not be too difficult. Collect a number of > DFTs of some windows in your data set. Add them all to a list and you > have a 3D set that can be plotted by ListPlot3D. > I'm rather new to Mathematica, and am attempting to make a 3D plot >> showin= > g how the frequency profile of a sound sample changes over time. I've > impor= > ted a .5 second audio file: >> wave = Import[clip.wav,Data] >> which returns a list of amplitude values of the wave (The file is >> sampled= > at 44.1 kHz, so there are about 22k numbers in the list). I can get a > n= > ice 2D plot of the frequency spectrum for the length of the whole clip > with= > : >> ListLinePlot[Take[Abs[Fourier[wave]],650],PlotRange -> {0,2.5}] >> where 650 is the max frequency shown (in Hz I think?) and 0-2.5 is the >> in= > tensity range (I'm not sure what these values mean, but I'd like to see > it = > in dB). >> What I would like to do is plot a 3 second long clip in 3D and show how >> t= > he frequency profile changes over those 3 seconds, so x=frequency, y=in= > tensity, z=time. >> I understand that my above 2D plot is one fat slice, and that I need to >> m= > ake hundreds or thousands of similar slices over the 3 second clip to > make = > the 3D plot, I'm just not sure how to do it. >> J -- DrMajorBob@longhorns.com === Subject: Re: Sound Spectrogram over time, in 3D, using Fourier? A couple of remarks with respect to your question: 1. Fourier returns the discrete fourier transform (DFT) of a list of numbers. There is no way the Fourier function could know how these were sampled. The same list of numbers may be the result of sampling at a rate of one sample a day or at 44.1 KHz or whatever. Therefore, you cannot interpret the output in terms of frequencies. At least, not directly. If you know the duration of your set of samples (T) then a number at position s of the output list corresponds to a frequency of (s-1)/T Hz. 2. The value of a Fourier result at position s equals the complex conjugated value at position n-s+2 for 1<=s<=n/2, with n the number of samples. Look for instance at this: res = Fourier[Table[Sin[2 [Pi] 1 t], {t, 0, 1, 1/99}]] Table[Conjugate[res[[i]]] - res[[Length[res] - i + 2]], {i, 2, Length [res]/2}] The DC term (the average value) of your samples is at position 1. So, the result can be expressed as the first n/2 complex numbers, the remainder of the output is redundant. Therefore, the highest representable frequency is n/2/T (Nyquist frequency). It therefore makes no sense to plot the whole range of the output of Fourier[ ]. Half of it suffices. If Fs is the sample frequency, then n = Fs T and the highest representable frequency equals Fs/2. BTW: note that n/2 complex numbers contain the same amount of information as n real numbers, so no information is lost in the transformation. 3. The size of the numbers in the output depends on the choice of the normalization term in the fourier transform. Look for FourierParameters in the documentation. 4. The decibel scale is a relative scale in which values are related to a given reference level. You have to provide this reference level yourself (it will have a dB level of 0). Given a certain ref power level P0, the value of a power level P1 in dB is given by 10*Log10[P1/ P0]. Often, power is related to the amplitude squared so the value of P1 in dB will be 20* Log10[A1/A0] when using amplitudes. 5. As to the 3D plot: should not be too difficult. Collect a number of DFTs of some windows in your data set. Add them all to a list and you have a 3D set that can be plotted by ListPlot3D. > I'm rather new to Mathematica, and am attempting to make a 3D plot showin= g how the frequency profile of a sound sample changes over time. I've impor= ted a .5 second audio file: wave = Import[clip.wav,Data] which returns a list of amplitude values of the wave (The file is sampled= at 44.1 kHz, so there are about 22k numbers in the list). I can get a n= ice 2D plot of the frequency spectrum for the length of the whole clip with= : ListLinePlot[Take[Abs[Fourier[wave]],650],PlotRange -> {0,2.5}] where 650 is the max frequency shown (in Hz I think?) and 0-2.5 is the in= tensity range (I'm not sure what these values mean, but I'd like to see it = in dB). What I would like to do is plot a 3 second long clip in 3D and show how t= he frequency profile changes over those 3 seconds, so x=frequency, y=in= tensity, z=time. I understand that my above 2D plot is one fat slice, and that I need to m= ake hundreds or thousands of similar slices over the 3 second clip to make = the 3D plot, I'm just not sure how to do it. > J === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica no problems with this code below on my system: 7.0 for Mac OS X x86 (32-bit) (November 10, 2008) Peter 2008/12/31 DrMajorBob : > I had no failures on my iMac Leopard system: $Version 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) myMod := Module[{p}, > Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, > 0.67220312964800834576456745674567}, {-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, > 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250000, ii++, > If[myMod =!= myMod, > Print[Iteration <> ToString[ii] <> fails comparison ]];] (no prints) Bobby >> Hi all, >> Last week Budgemano posted an issue which involved numerical >> inaccuracies in Mathematica 7. Due to the xmas season it hasn't >> received much attention, or so it seems. >> Meanwhile, I've been able to drill the problem down to the following >> code: >> myMod := Module[ >> {p}, >> Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, >> 0.67220312964800834576456745674567}, {-0.5359693986690249`, >> -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, >> -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, >> 0.2715072333003815`, 0.7842300557273234`}] >> For[ii = 1, ii <= 250, ii++, >> If[myMod =!= myMod, >> Print[Iteration <> ToString[ii] <> fails comparison ]];] >> As you can see the module myMod is called twice every iteration. Its >> calculations only involve constants, so the results should always be >> the same. However, on my system (Mathematica 7.WinXP) the results differ >> from one >> call to the other at seemingly random times. >> This phenomenon crucially depends on the presence of the local >> variable p (that isn't used!). With this variable it's there, without >> it isn't. In M6 everything is OK, so this is a bug specific to >> Mathematica 7. >> Could you check on the various platforms whether you can reproduce >> this? > > -- > DrMajorBob@longhorns.com === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica I had no failures on my iMac Leopard system: $Version 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) myMod := Module[{p}, Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, 0.67220312964800834576456745674567}, {-0.5359693986690249`, -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250000, ii++, If[myMod =!= myMod, Print[Iteration <> ToString[ii] <> fails comparison ]];] (no prints) Bobby > Hi all, Last week Budgemano posted an issue which involved numerical > inaccuracies in Mathematica 7. Due to the xmas season it hasn't > received much attention, or so it seems. Meanwhile, I've been able to drill the problem down to the following > code: myMod := Module[ > {p}, > Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, > 0.67220312964800834576456745674567}, {-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, > 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250, ii++, > If[myMod =!= myMod, > Print[Iteration <> ToString[ii] <> fails comparison ]];] As you can see the module myMod is called twice every iteration. Its > calculations only involve constants, so the results should always be > the same. However, on my system (Mathematica 7.WinXP) the results differ > from one > call to the other at seemingly random times. This phenomenon crucially depends on the presence of the local > variable p (that isn't used!). With this variable it's there, without > it isn't. In M6 everything is OK, so this is a bug specific to > Mathematica 7. Could you check on the various platforms whether you can reproduce > this? -- DrMajorBob@longhorns.com === Subject: CreatePalette question I've just started using CreatePalette. It works fine, but I'd like to fine tune it a bit. (FYI, I'm using V7 for XP Pro 32.) In particular, I'd like the created palette to just close without asking if one wants to save it (after one uses it or moves it). The help page says that CreatePalette can take any notebook option. And Options[Notebook] returns a list that contains ClosingSaveDialog -> True which sounds like it might be what I'm looking for. I say sounds like because I can't find any documentation for it. (When I cut it from the list and paste it into an input cell it turns blue.) Moreover, when I add it as an option to CreatePalette it turns red. And (not surprisingly) it doesn't seem to work. So, is there a way to do what I want? Mark === Subject: Problem with NMinimize I have a data set tprLrG ={T, ps, rl, rg} and a Module psrlrg[Tx_,T0_,r0= _,anf_] to calculate psc, rlc, rgc basing on T and 3 parameters: T0, r0 and anf. The module psrlrg[Tx,T0,r0,anf] run perfectly if one have relevant values of T0, r0 and anf. The value of psc, rlc, rgc are get from psrlrg[tprLrG[[i,1]],T0, r0,anf][[-3]], psrlrg[tprLrG[[i,1]],T0,r0,anf][[-2]], psrlrg[tprLrG[[i,1]],T0, r0,anf][[-1]] respectively. I want to minimize the (1-psc/ ps)^2 + (1- rlc/rl)^2 + (1- rgc/rg)^2 to find optimum parameters T0, r0 and anf by defining: f[T0_, r0_,anf_]:=Total[Table[(1-(psrlrg[tprLrG[[i,1]],T0,r0,anf][[-3]])/tprLrG[[i,2 ]])^2+(1-(psrlrg[tprLrG[[i,1]],T0,r0,anf][[-2]])/tprLrG[[i,3]])^2+(1-(psrlrg[ tprLrG[[i,1]],T0,r0,anf][[-1]])/tprLrG[[i,4]])^2,{i,Length[tprLrG]}]]; and using NMinimize as: toiuu=NMinimize[{f[T0, r0,anf],120=A3T0=A3160,10=A3 r0=A315,0.8=A3anf=A31.40},{T0,r0,anf}]; {T02, r02,anf2}={T0, r0,anf}/.Last[toiuu] When I run the code, I get results as {T0, r0,anf}={160.,10.,1.37797}. It means that NMinimize take the boundary of T0, r0 and find one value of anf = 1.37797. The result is not correct. They should be {T0,r0,anf}={150.16,13.487,0.9876}. It should be notice that the random values of {T0, r0,anf} or during search for value of {T0, r0,anf}, the module psrlrg[Tx,T0,r0,anf] may not give the real number of psc, rlc, rgc as expected if values of {T0, r0,anf} are not relevant. In case of {T0, r0, anf} are not relevant or psc, rlc, rgc are not the real numbers, I have to search for other values of {T0, r0,anf}. I do not know how to solve this problem in NMinimize. I also not sure that NMinimize or other commands will help to find the parameters. Please tell me how to modify the code to get correct results. Lai Ngoc Anh === Subject: Fourier[TriangleWave] TriangleWave and SquareWave are both functions introduced in M7, with similar usage. However, if you try to do a DFT of a list of TriangleWave values as in Fourier[Table[TriangleWave[ t], {t, 0, 2 [Pi], 2 [Pi]/99}]] you get an error message. The same problem exists for SawtoothWave. With SquareWave and Sin: Fourier[Table[SquareWave[ t], {t, 0, 2 [Pi], 2 [Pi]/99}]] Fourier[Table[Sin[ t], {t, 0, 2 [Pi], 2 [Pi]/99}]] it works as expected. If you use //N everything is fine. Is there anything in the properties of these wave functions that should make these differences in handling by Fourier reasonable or expected? === Subject: Re: BarChart Hello Sjoerd, Jens-Peer and Ray, I can use them all in different aspects of what I want. with friendly greetings, P_ter === Subject: Graph of some built-in functions blows up Mathematica V7 Hello Mathematica UG: $Version = 7.0 for Microsoft Windows (32-bit) (November 10, 2008) The following commands are from a notebook downloaded from this Mathworld page: http://mathworld.wolfram.com/DeltaFunction.html (f0 = {1/Pi [Epsilon]/(x^2 + [Epsilon]^2), [Epsilon] Abs[ x]^([Epsilon] - 1), 1/2/Sqrt[Pi [Epsilon]] Exp[-x^2/4/[Epsilon]], 1/Pi/x Sin[x/[Epsilon]], 1/[Epsilon] AiryAi[x/[Epsilon]], 1/[Epsilon] Re[BesselJ[1/[Epsilon], (x + 1)/[Epsilon]]], Abs[1/[Epsilon] Exp[-x^2/[Epsilon]] LaguerreL[n, 2 x/[Epsilon]]]}) // ColumnForm // TraditionalForm << Graphics`Colors` (* gets deprecation errors in V7 *) Show[GraphicsArray[ Block[{$DisplayFunction = Identity}, Partition[ Plot[Evaluate[ Table[# /. {[Epsilon] -> e, n -> 1}, {e, .1, .2, .02}]], {x, -3, 3}, PlotRange -> 3}}, {Automatic, All}], AxesLabel -> TraditionalForm /@ {x, HoldForm[#] /. n -> 1}, PlotStyle -> {Red, Orange, Yellow, Green, Blue, Violet}] & /@ f0, 3, 3, {1, 1}, {}]]] (*,GraphicsSpacing->{-.15,.2} *)] It runs for a while then a box comes up titled Formatting Notebook contents. Then Mathematica blows up. This same code does run in Mathematica V6. Since it does not issue an error message, I am not sure how to isolate what is wrong other than removing the functions from f0, one-by-one. If anyone has another approach to take, I would appreciate any advice. TIA. Roger Williams Franklin Laboratory === Subject: Re: Converting 2D Lists to 3D lists One way: In[152]= newlist=Map[Riffle[#,5,3] &,SampleList3D,{2}] Out[152]= {{{-1,2,5},{0,1,5},{3,4,5}},{{-3,-2,5},{-1.5,2.5,5},{0.5,-0.75,5}}} In[153]= newlist2= newlist;newlist2[[2,All,3]]={3,3,3};newlist2 Out[153]= {{{-1,2,5},{0,1,5},{3,4,5}},{{-3,-2,3},{-1.5,2.5,3},{0.5,-0.75,3}}} Tom Dowling > Hello Everyone, I want to know if there is a way to convert a 2D lists to 3D Lists. > Below is the example list in list form: SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, > {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; > This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, > {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the > second column. This is how it should look. > {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, > {0.5, -.75, 3}}} Is there any way I can do this? I have been trying to use Map and > Insert but I am getting the wrong result. Insert[SampleList3d, x, {#, -1}] & /@ {1, 2} ; I get this result and this is not what I want: > {{{{-1, 2}, {0, 1}, {3, 4}, > x}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}}}, {{{-1, 2}, {0, 1}, {3, > 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}, x}}} > Karthik Sridhara === Subject: Re: Converting 2D Lists to 3D lists There are many ways to do this and you will get many responses. Here is one way, using two steps: sublistChanger[inList_,trailingNumber_]:=Map[{#[[1]],#[[2]],trailingNumber}& ,inList] Map[sublistChanger[#,5]&,SampleList3D] and for your second problem, {sublistChanger[SampleList3D[[1]],5],sublistChanger[SampleList3D[[2]],3]} Michael > Hello Everyone, I want to know if there is a way to convert a 2D lists to 3D Lists. > Below is the example list in list form: SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, > {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; > This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, > {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the > second column. This is how it should look. > {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, > {0.5, -.75, 3}}} Is there any way I can do this? I have been trying to use Map and > Insert but I am getting the wrong result. Insert[SampleList3d, x, {#, -1}] & /@ {1, 2} ; I get this result and this is not what I want: > {{{{-1, 2}, {0, 1}, {3, 4}, > x}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}}}, {{{-1, 2}, {0, 1}, {3, > 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}, x}}} > Karthik Sridhara === Subject: Re: Converting 2D Lists to 3D lists Karthik, I think these show you how to do it: In[12]:= SampleList3D={{{-1,2},{0,1},{3,4}},{{-3,-2},{-1.5,2.5},{0.5,-.75}}} Out[12]= {{{-1,2},{0,1},{3,4}},{{-3,-2},{-1.5,2.5},{0.5,-0.75}}} In[18]:= Map[Append[#,5]&,SampleList3D,{2}] Out[18]= {{{-1,2,5},{0,1,5},{3,4,5}},{{-3,-2,5},{-1.5,2.5,5},{0.5,-0.75,5}}} In[19]:= ReplacePart[%,{2,2,3}->3] Out[19]= {{{-1,2,5},{0,1,5},{3,4,5}},{{-3,-2,5},{-1.5,2.5,3},{0.5,-0.75,5}}} > Hello Everyone, I want to know if there is a way to convert a 2D lists to 3D Lists. > Below is the example list in list form: SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, > {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; > This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, > {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the > second column. This is how it should look. > {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, > {0.5, -.75, 3}}} Is there any way I can do this? I have been trying to use Map and > Insert but I am getting the wrong result. Insert[SampleList3d, x, {#, -1}] & /@ {1, 2} ; I get this result and this is not what I want: > {{{{-1, 2}, {0, 1}, {3, 4}, > x}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}}}, {{{-1, 2}, {0, 1}, {3, > 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}, x}}} > Karthik Sridhara === Subject: Re: Converting 2D Lists to 3D lists SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -.75}}}; Apply[{##, 5} &, SampleList3D, {2}] {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, {0.5, -0.75, 5}}} Map[Append[#, 5] &, SampleList3D, {2}] {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, {0.5, -0.75, 5}}} Map[Insert[#, 5, 3] &, SampleList3D, {2}] {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, {0.5, -0.75, 5}}} % == %% == %%% True Table[Apply[{##, {5, 3}[[n]]} &, SampleList3D[[n]], {1}], {n, 2}] {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, {0.5, -0.75, 3}}} Table[{##, {5, 3}[[n]]} & @@@ SampleList3D[[n]], {n, 2}] {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, {0.5, -0.75, 3}}} % == %% True Bob Hanlon > Hello Everyone, I want to know if there is a way to convert a 2D lists to 3D Lists. > Below is the example list in list form: SampleList3D = {{{-1, 2}, {0, 1}, {3, 4}}, {{-3, -2}, {-1.5, 2.5}, > {0.5, -.75}}} I want the list to be intact but add 5 at the end of each sublist; > This is how I want it to look: {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 5}, {-1.5, 2.5, 5}, > {0.5, -.75, 5}}} I also want to be able do the same as above but add 3 this time to the > second column. This is how it should look. > {{{-1, 2, 5}, {0, 1, 5}, {3, 4, 5}}, {{-3, -2, 3}, {-1.5, 2.5, 3}, > {0.5, -.75, 3}}} Is there any way I can do this? I have been trying to use Map and > Insert but I am getting the wrong result. Insert[SampleList3d, x, {#, -1}] & /@ {1, 2} ; I get this result and this is not what I want: > {{{{-1, 2}, {0, 1}, {3, 4}, > x}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}}}, {{{-1, 2}, {0, 1}, {3, > 4}}, {{-3, -2}, {-1.5, 2.5}, {0.5, -0.75}, x}}} > Karthik Sridhara === Subject: Problem in Dot Product of 4x4 Matrices with Transcendental I'm a student studying in the Mechanical Engineering Department of Technical University of Istanbul (ITU). === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 On Dec 30 2008, 4:53 am, Sjoerd C. de Vries > Hi all, Last week Budgemano posted an issue which involved numericalinaccuraci= esin Mathematica 7. Due to the xmas season it hasn't > received much attention, or so it seems. Meanwhile, I've been able to drill the problem down to the following > code: myMod := Module[ > {p}, > Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, > 0.67220312964800834576456745674567}, {-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, > 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250, ii++, > If[myMod =!= myMod, > Print[Iteration <> ToString[ii] <> fails comparison ]];] As you can see the module myMod is called twice every iteration. Its > calculations only involve constants, so the results should always be > the same. However, on my system (Mathematica 7.WinXP) the results differ = from one > call to the other at seemingly random times. > I believe I can tell you exactly why this is happening. It is not caused by Mathematica. Google says that Mathematica uses the Intel Math-Kernel-Library. We use the M.K.L. in our programs too, and we see the same stuff. The bad news is that it is a consequence of the M.K.L. which can't be avoided. The good news is that you should not care about it. If the difference seems important then you are doing something wrong. of many functions in their M.K.L. Basic-Linear-Algebra-System (B.L.A.S.). One version works if the memory blocks that store the data begin at a memory address that is a multiple of 16. This is faster. If the data does not begin at a multiple of 16. All memory blocks begin at a multiple of 8. The algorithms for the multiple of 16 are the same as the non- multiple of 16, but the code is different. The fast code uses the SSE registers. The slow code uses the FPU registers. Programs do not have any choice about where memory blocks begin. When you use new to get an array in C++ the computer will pick some memory block somewhere. Sometimes it begins at a memory address that is divisible by 16. When that array is used by the B.L.A.S. in the M.K.L. then the fast code is used. Other times the slow code is used because the memory address is not divisible by 16. Memory addresses are randomly chosen by the computer's memory allocater. The B.L.A.S. algorithm is always the same. The only difference is in the lowest order digits. The FPU registers dont work the same as the SSE registers exactly. If you see big important differences between the two results it means your results are algorithm or a sensitive matrix. While you use a program that uses the Math-Kernel-Library you will always see the non-deterministic numerical inaccuracies if you use linear algebra and floating point numbers. This is not caused by Mathematica, they are victims of Intel also!! On the 64-bit Intel CPU, there are no FPU registers, so there are not two different implementations in the M.K.L. for functions. The bug does not appear on 64-bit. There is a different M.K.L. library from Intel for the 64-bit CPU. And also it only is manufactured for Linux and Windows, not Mac. === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 What makes you think that this is a bug? Is there really a guarantee that the execution of Mathematica code is deterministic (especially, involving machine-precision)? I am no expert in floating point numbers, but I am aware that dealing with them can easily become tricky. Have a look at the following quotations and their sources: > We shall discuss the following myths, among others: [...] Arithmetic > operations are deterministic; that is, if I do z=x+y in two places in > the same program and my program never touches x and y in the > meantime, then the results should be the same. from The pitfalls of verifying floating-point computations http://hal.archives-ouvertes.fr/hal-00128124 > Incidentally, some people think that the solution to such anomalies > is never to compare floating-point numbers for equality, but instead > to consider them equal if they are within some error bound E. This is > hardly a cure-all because it raises as many questions as it answers. > What should the value of E be? If x < 0 and y > 0 are within E, > should they really be considered to be equal, even though they have > different signs? Furthermore, the relation defined by this rule, a ~ > b |a - b| < E, is not an equivalence relation because a ~ b and b ~ > c does not imply that a ~ c. from What Every Computer Scientist Should Know About Floating-Point Arithmetic http://docs.sun.com/source/806-3568/ncg_goldberg.html Luis. > Hi all, Last week Budgemano posted an issue which involved numerical > inaccuracies in Mathematica 7. Due to the xmas season it hasn't > received much attention, or so it seems. Meanwhile, I've been able to drill the problem down to the following > code: myMod := Module[ {p}, Dot[{0.5018839897852984567457648, > 0.544293499215831476457645674576, > 0.67220312964800834576456745674567}, {-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, > 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250, ii++, If[myMod =!= myMod, Print[Iteration > <> ToString[ii] <> fails comparison ]];] As you can see the module myMod is called twice every iteration. Its > calculations only involve constants, so the results should always be > the same. However, on my system (Mathematica 7.WinXP) the results > differ from one call to the other at seemingly random times. This phenomenon crucially depends on the presence of the local > variable p (that isn't used!). With this variable it's there, without > it isn't. In M6 everything is OK, so this is a bug specific to > Mathematica 7. Could you check on the various platforms whether you can reproduce > this? === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 What makes you think that this is a bug? Is there really a guarantee that the execution of Mathematica code is deterministic (especially, involving machine-precision)? I am no expert in floating point numbers, but I am aware that dealing with them can easily become tricky. Have a look at the following quotations and their sources: > We shall discuss the following myths, among others: [...] Arithmetic > operations are deterministic; that is, if I do z=x+y in two places in > the same program and my program never touches x and y in the > meantime, then the results should be the same. from The pitfalls of verifying floating-point computations http://hal.archives-ouvertes.fr/hal-00128124 > Incidentally, some people think that the solution to such anomalies > is never to compare floating-point numbers for equality, but instead > to consider them equal if they are within some error bound E. This is > hardly a cure-all because it raises as many questions as it answers. > What should the value of E be? If x < 0 and y > 0 are within E, > should they really be considered to be equal, even though they have > different signs? Furthermore, the relation defined by this rule, a ~ > b |a - b| < E, is not an equivalence relation because a ~ b and b ~ > c does not imply that a ~ c. from What Every Computer Scientist Should Know About Floating-Point Arithmetic http://docs.sun.com/source/806-3568/ncg_goldberg.html Luis. > Hi all, Last week Budgemano posted an issue which involved numerical > inaccuracies in Mathematica 7. Due to the xmas season it hasn't > received much attention, or so it seems. Meanwhile, I've been able to drill the problem down to the following > code: myMod := Module[ {p}, Dot[{0.5018839897852984567457648, > 0.544293499215831476457645674576, > 0.67220312964800834576456745674567}, {-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, > 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250, ii++, If[myMod =!= myMod, Print[Iteration > <> ToString[ii] <> fails comparison ]];] As you can see the module myMod is called twice every iteration. Its > calculations only involve constants, so the results should always be > the same. However, on my system (Mathematica 7.WinXP) the results > differ from one call to the other at seemingly random times. This phenomenon crucially depends on the presence of the local > variable p (that isn't used!). With this variable it's there, without > it isn't. In M6 everything is OK, so this is a bug specific to > Mathematica 7. Could you check on the various platforms whether you can reproduce > this? === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 I learned from WRI's Arnoud Buzing that they're currently thinking of a compiler issue. === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 > What makes you think that this is a bug? Is there really a guarantee > that the execution of Mathematica code is deterministic (especially, > involving machine-precision)? I am no expert in floating point numbers, > but I am aware that dealing with them can easily become tricky. > Have a look at the following quotations and their sources: > >> We shall discuss the following myths, among others: [...] Arithmetic >> operations are deterministic; that is, if I do z=x+y in two places in >> the same program and my program never touches x and y in the >> meantime, then the results should be the same. First, the bug manifests itself as a variation at the same place in the code - the loop goes round and the results vary - so I don't think this caveat applies. Furthermore, I think the reason that z=x+y could generate slightly different results at two different points in a C or Fortran program, would be as a result of some sort of reordering of the code by an optimiser, and would not apply here. I certainly think this is a bug, and I can even guess what may have happened - see my reply to a later post on this issue! David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 Works fine on a Mac Pro with Mathematica V7.0 on Mac OS X 10.5.6 with dual Intel Xeon's. Would guess this is specific to the Intel floating point routines on Windows XP, so maybe this is a bug in Intel's code and not Wolfram's, but if that were true why does Mathematica V6 work fine? But since Vista does not show it, this makes me think even more about the Intel floating point code. Even tried bumping up the number of iterations to over 1 million and no difference on the Mac at all. -Bob === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 work fine on Windows Vista 64 Bit. Jens > Hi all, Last week Budgemano posted an issue which involved numerical > inaccuracies in Mathematica 7. Due to the xmas season it hasn't > received much attention, or so it seems. Meanwhile, I've been able to drill the problem down to the following > code: myMod := Module[ > {p}, > Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, > 0.67220312964800834576456745674567}, {-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, > 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250, ii++, > If[myMod =!= myMod, > Print[Iteration <> ToString[ii] <> fails comparison ]];] As you can see the module myMod is called twice every iteration. Its > calculations only involve constants, so the results should always be > the same. However, on my system (Mathematica 7.WinXP) the results differ from one > call to the other at seemingly random times. This phenomenon crucially depends on the presence of the local > variable p (that isn't used!). With this variable it's there, without > it isn't. In M6 everything is OK, so this is a bug specific to Mathematica 7. Could you check on the various platforms whether you can reproduce > this? === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 In my platform 7.0 for Microsoft Windows (32-bit) (November 10, 2008) what you found is exactly reproduced. I also noticed that Block and With never give rise to the same problem, so that this error appears to be specific to Module. In particular, probably, to the part of the internal code which creates local variables. > .... > Could you check on the various platforms whether you can reproduce this? === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 code: myMod := Module[ > {p}, > Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, > 0.67220312964800834576456745674567}, {-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, > -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, > 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250, ii++, > If[myMod =!= myMod, > Print[Iteration <> ToString[ii] <> fails comparison ]];] As you can see the module myMod is called twice every iteration. Its > calculations only involve constants, so the results should always be > the same. However, on my system (Mathematica 7.WinXP) the results differ from > one > call to the other at seemingly random times. This phenomenon crucially depends on the presence of the local > variable p (that isn't used!). With this variable it's there, without > it isn't. In M6 everything is OK, so this is a bug specific to Mathematica 7. Could you check on the various platforms whether you can reproduce > this? Hi Sjoerd, I have tested the code on two platforms. The results are as follows: ..1 Mathematica 6.0.3 64-bit Intel Mac OS X Leopard 10.5.6: the first as well as consecutive evaluations of the loop does not yield any numerical difference. ..2 However, Mathematica 7.0 32-bit Windows XP Pro. SP3 generates numerous *random* differences run after run. -- Jean-Marc In[1]:= {$Version, $ReleaseNumber} myMod := Module[{p}, Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, 0.67220312964800834576456745674567}, {-0.5359693986690249`, -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250, ii++, If[myMod =!= myMod, Print[Iteration <> ToString[ii] <> fails comparison ]];] Out[1]= {6.0 for Mac OS X x86 (64-bit) (May 21, 2008), 3} In[4]:= For[ii = 1, ii <= 250, ii++, If[myMod =!= myMod, Print[Iteration <> ToString[ii] <> fails comparison ]];] {$Version, $ReleaseNumber} myMod := Module[{p}, Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, 0.67220312964800834576456745674567}, {-0.5359693986690249`, -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250, ii++, If[myMod =!= myMod, Print[Iteration <> ToString[ii] <> fails comparison ]];] {7.0 for Microsoft Windows (32 - bit) (November 10, 2008), 0} Iteration 2 fails comparison Iteration 8 fails comparison Iteration 19 fails comparison Iteration 21 fails comparison Iteration 61 fails comparison Iteration 150 fails comparison Iteration 154 fails comparison Iteration 162 fails comparison Iteration 189 fails comparison Iteration 201 fails comparison Iteration 220 fails comparison Iteration 224 fails comparison Iteration 229 fails comparison Iteration 230 fails comparison Iteration 237 fails comparison Iteration 249 fails comparison For[ii = 1, ii <= 250, ii++, If[myMod =!= myMod, Print[Iteration <> ToString[ii] <> fails comparison ]];] Iteration 7 fails comparison Iteration 20 fails comparison Iteration 36 fails comparison Iteration 41 fails comparison Iteration 52 fails comparison Iteration 60 fails comparison Iteration 64 fails comparison Iteration 111 fails comparison Iteration 114 fails comparison Iteration 119 fails comparison Iteration 143 fails comparison Iteration 146 fails comparison Iteration 162 fails comparison Iteration 163 fails comparison Iteration 164 fails comparison Iteration 185 fails comparison Iteration 236 fails comparison Iteration 238 fails comparison Iteration 239 fails comparison Iteration 244 fails comparison Iteration 245 fails comparison Iteration 249 fails comparison === Subject: Re: v.7: Printing large tables is broken? > In v.6 =9Awhen passing to printer large tables (in height) the page > breaks were correctly inserted on cell edges and cells on each printed > page occupied so much space as it is possible. But in v.7 cells do not > occupy all possible page area in spite of very low printing margins > specified. I spend some time trying to fix it by modifying Printing > Settings but I have failed. Try to print output of the following code (for example, to Acrobat > Distiller virtual printer): Grid[Table[{some text}, {1000}], Frame -> All] I specified printing margins in 10 millimeters but on the bottom of > every page still present substantial free space (about 65 millimeters)... > I think, this is a bug of v.7. In v.6 it was not. > Has anyone any idea how to fix this? I have found a workaround for this bug: we need to specify negative bottom margin: SetOptions[EvaluationNotebook[], PrintingOptions -> {PrintingMargins -> {{0, 0}, {-165, 35}}}] But it is only a workaround and the bug is still here... :( === Subject: Re: Aspect Ratio > including Text[] in various fonts. I will try it. My goal here is that I want to use Inset[] to compose various 2D and > 3D > graphics together. > You can (in V7, at least) also use Rasterize[.., RasterSize], although you have to be careful about the various XXXPadding options to Graphics. In[130]:= r1 = Graphics[Rectangle[{0, 0}, {1, 10}]]; In[131]:= r2 = Graphics[Rectangle[{0, 0}, {1, 2}]]; In[132]:= Rasterize[r1, RasterSize] Out[132]= {46, 432} In[133]:= Rasterize[Show[r1, ImagePadding -> 0, PlotRangePadding -> 0], RasterSize] Out[133]= {43, 432} In[134]:= Rasterize[Show[r2, ImagePadding -> 0, PlotRangePadding -> 0], RasterSize] Out[134]= {216, 432} This should generally be more robust than most other methods I can think of, though a bit slower than some other methods, since it has to ask the frontend for information about the rendered result instead of using information available to the kernel. The kernel has no idea about things like font metrics and so this is probably a better approach if you're interested in (styled) text. Brett Champion Wolfram Research === Subject: Re: Aspect Ratio including Text[] in various fonts. I will try it. My goal here is that I want to use Inset[] to compose various 2D and 3D graphics together. Nathan This message and any attachments, may contain confidential and/or legally privileged information. If you are not the intended recipient of the message by the original sender, please destroy it. Message and attachments copyright =A9 2008, all rights reserved. Any unauthorized dissemination, distribution or copying is strictly forbidden -----Original Message----- === Subject: Re: Aspect Ratio Here are two methods. The first depends on knowing precisely the structure of the Graphics object (not likely in practice). r1 = Graphics[Rectangle[{0, 0}, {1, 10}]]; r2 = Graphics[Rectangle[{0, 0}, {1, 2}]]; r1[[1, -1]] r2[[1, -1]] {1, 10} {1, 2} The second method doesn't have THAT flaw, but it could return coordinates from embedded rectangles OTHER than the one you want. (Depending on how you derived the object in the first place.) Cases[{r1, r2}, r_Rectangle :> Last@r, Infinity] {{1, 10}, {1, 2}} Bobby > Here is a simple question - is there a way to find out the aspect > ratio of a graphics object? So if I have r1 = Graphics[Rectangle[{0,0},{1,10}]] > r2 = Graphics[Rectangle[{0,0},{1,2}]] I want to recover {1,10} from r1, and {1,2} from r2. > Nathan This message and any attachments, may contain confidential and/or > legally privileged information. If you are not the intended recipient > of the message by the original sender, please destroy it. Message and > attachments copyright =A9 2008, all rights reserved. Any unauthorized > dissemination, distribution or copying is strictly forbidden > -- DrMajorBob@longhorns.com === Subject: Re: Aspect Ratio Here are two methods. The first depends on knowing precisely the structure of the Graphics object (not likely in practice). r1 = Graphics[Rectangle[{0, 0}, {1, 10}]]; r2 = Graphics[Rectangle[{0, 0}, {1, 2}]]; r1[[1, -1]] r2[[1, -1]] {1, 10} {1, 2} The second method doesn't have THAT flaw, but it could return coordinates from embedded rectangles OTHER than the one you want. (Depending on how you derived the object in the first place.) Cases[{r1, r2}, r_Rectangle :> Last@r, Infinity] {{1, 10}, {1, 2}} Bobby > Here is a simple question - is there a way to find out the aspect > ratio of a graphics object? So if I have r1 = Graphics[Rectangle[{0,0},{1,10}]] > r2 = Graphics[Rectangle[{0,0},{1,2}]] I want to recover {1,10} from r1, and {1,2} from r2. > Nathan This message and any attachments, may contain confidential and/or > legally privileged information. If you are not the intended recipient > of the message by the original sender, please destroy it. Message and > attachments copyright =A9 2008, all rights reserved. Any unauthorized > dissemination, distribution or copying is strictly forbidden === Subject: Aspect Ratio Here is a simple question - is there a way to find out the aspect ratio of a graphics object? So if I have r1 = Graphics[Rectangle[{0,0},{1,10}]] r2 = Graphics[Rectangle[{0,0},{1,2}]] I want to recover {1,10} from r1, and {1,2} from r2. Nathan This message and any attachments, may contain confidential and/or legally privileged information. If you are not the intended recipient of the message by the original sender, please destroy it. Message and attachments copyright =A9 2008, all rights reserved. Any unauthorized dissemination, distribution or copying is strictly forbidden === Subject: Re: Aspect Ratio Natha, You could try the following: In[6]:= AbsoluteOptions[r1, AspectRatio] Out[6]= {AspectRatio -> 10.} In[8]:= AbsoluteOptions[r1, PlotRange] Out[8]= {PlotRange -> {{0., 1.}, {0., 10.}}} Checking to see whether it works for composites: In[25]:= r3 = Graphics[Rectangle[{0, 0}, {10, 1}]]; In[26]:= r4 = Show[r1, r3]; In[27]:= AbsoluteOptions[r4, AspectRatio] Out[27]= {AspectRatio -> 1.} In[28]:= AbsoluteOptions[r4, PlotRange] Out[28]= {PlotRange -> {{0., 10.}, {0., 10.}}} > Here is a simple question - is there a way to find out the aspect > ratio of a graphics object? So if I have r1 = Graphics[Rectangle[{0,0},{1,10}]] > r2 = Graphics[Rectangle[{0,0},{1,2}]] I want to recover {1,10} from r1, and {1,2} from r2.