A125 === Subject: Re: Dynamic, UpdateInterval and global variable I guess what is happening is that Mathematica tries every second to make a full update. But because the value of aDisk is changeing all the time, it will never finish the first update. To slow down this, you may delete Refresh and put a Pause statement instead: Dynamic[pt = pt + RandomReal[{0, 0.2}, 2]; Pause[1]; aDisk[pt]] hope this helps, Daniel > 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. > === Subject: Re: 0^0 = 1? > 0^0 means the limit if both base and exponent go to zero. No, that is not how 0^0 is defined. Does 2+2 mean the limit as both > summands go to 2? The value may happen to be the same in that case, but > that is not how 2+2 is defined. The value of x^y for cardinal numbers x and y is the cardinality of the > set of mappings from y into x. In the case where x and y are the empty > set, there is exactly one such mapping. Hence, 0^0 = 1. That's a definition from set theory. I doubt it plays nice in the complex plane. The definition of Power we go by is ower[a,b] == Exp[Log[a]*b] Among other advantages, it means branch cuts for Power are inherited from Log. > It's a theorem of ZF (as stated in Suppes, _Axiomatic_Set_Theory_) that > m^0 = 1 for every cardinal number m. I think the setting of cardinal numbers is not really a good choice for symbolic computation. > Another way is to notice that 0^0 represents an empty product, whose > value is the identity element in the monoid of the integers (or the > reals). In[1]:= Product[0,{k,0}] Out[1]= 1 This and the ZF result are arguments for making 0^0 equal to one. They are not in any sense proofs that it must be one, given that Power lives in the setting of functions of complex variables. > One might also consider the series expansion for Exp[0], which reduces to 1 = 0^0/0! + (lots of terms that all reduce to zero). This point is questionable, since one does not in general encounter the formula with a term x0^0 (where x0 is the point of expansion). > Having x^y be discontinuous at (0,0) does not cause problems any more > than having the Sign function be discontinuous at 0 causes problems. That's a matter of opinion. Clearly we do not at this time agree with you on this. > Anyone who works with limits should be aware that you can't just blindly > assume continuity when evaluating limits. You have to consider the > actual definition of the limit. True, but I don't see any relevance to this particular issue. The question at hand is whether or not 0^0 should be assigned a concrete value. If it is given a value, then since limits of x^y depend on how x,y respectively approach 0, they might or might not equal that value (so there is no underlying assumption of continuity). But that is already the case, and the question at hand is whether the undefined value should in fact be defined. Daniel Lichtblau Wolfram Research === Subject: Timing of N[ Factorial[4000000], 18] How long does it take Mathematica 7 to compute N[ Factorial[4000000], 18] With the old version of Mathematica I have it takes a very long time, and I was wondering if Mathematica 7 is much better. You might ask why I wanted to do that. Well I wanted to see how quickly Stirling's formula approaches Factorial[n] for large n. ------------------------ Ted Ersek === Subject: Re: What is QGamma[q,z] I had trouble with this because the only definitions I could find involved things like Subscript[(q;q), Infinity] and I had no idea what that was. I have since learned that this is called a q-series as defined at http://mathworld.wolfram.com/q-Series.html I often look (out of curiosity) at the definition of special functions in Mathematica. In almost every case I can see that a function is the solution to a certain differential equation, a definite integral, or something else I am familiar with. Even the very general AppellF1 function is defined as a double infinite series, and I know what that is. ----------- Ted Ersek === Subject: Problem with spline function object in Mathematica 6 Here is a description of what I am trying to do. I have a tabulated monotonically increasing function (imagine mass contained in concentric balls with increasing radius). I need to obtain an interpolating function which preserves the monotonicity. I also need the derivative of the original function - the density (and it needs to be positive everywhere). For that I use spline as polynomial interpolations do not satisfy these requirements. I was able to obtain the derivative of the spline object via a method described before on MathGroup. As I need the density as a function of distance and the spline function object is a parametric object in the end I need the inverse functions which give me the parameter in terms of the distance. The current problem I have is that the spline object is only correctly evaluated if the argument is a number. If it is a symbol it automatically evaluates to the same symbol. I am providing an arbitrary table for the original function. Here is my current code: SplineTable={{0,0},{1,1},{2,8},{3,27},{4,64}}; Spl=SplineFit[SplineTable,Cubic]; derivSpline=ReplacePart[Spl,Map[Append[Rest[#]*{1,2,3},0]&,Spl[[4]],{2}],4]; dMdr[x_]:=Last[derivSpline[x]]/First[derivSpline[x]]; drdt[x_] := First[derivSpline[x]]; sol3 = NDSolve[{param[0]==0,(param'[x]-(1/drdt[param[x]]))==0},param,{x,0,4}] So again the problem I have is that drdt[param[x]] evaluates to param[x] automatically (and immediately gives a division by 0 error in NDSolve) instead of attempting to evaluate param[x] to a number first. The same happens with dMdr[x]. My goal in the end will be to evaluate dMdr[param[x]] correctly when supplied with x. I would also appreciate to know if there is an easier way to get the derivative in terms of distance from the original table while satisfying the physical requirements. === Subject: Has anyone tried to use MathLink to receive real-time market data Hello All: One of the great new things in Mathematica > 6 is the curated data. Defintely having access to the curated historical data is a great feature, however, providing access to analyze real-time would take this feature to the next level. I was wondering if anyone has used Mathematica (via MathLink I assume) to access the free real-time feeds from OpenTick (check their website). I would love to see this kind of thing as a permanent feature of Mathematica, and am contemplating submitting it as a feature request....would anyone else use something like this? Would love to hear your thoughts. t. === Subject: Re: Debugging Mathematica Code (Mathematica 7) On 22 Jan., 12:57, Jens-Peer Kuska I have never had such a problem but you should open the > debugger controls always before you send a > code piece to the kernel. I really suggest the Wolfram Workbench debugger ! > It works more like one would expect it > if one use a compiled language like C++. Have a look athttp://www.wolfram.com/broadcast/screencasts/workbench/debu= gging/ BTW We have stopped to make bugs in > out not to be useful at all ;-) Jens On 20 Jan., 12:57, Jens-Peer Kuska > >> 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 a= nd= > 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= d= > ebu= >>> g >>>> surely fails). I've tried a lot, but I'm still at the stage trial a= n >>>> error . >>>> Mike Hi Jens, but: Sometimes it works, sometimes not. I used step and step in , > to see waht the code does, but it seems that frequent swithceing > breakpoint on and of irritates the debugger and it's behavior gets a > bit, say, probabilisitc, and therefore I was looking for documentation > (for it could be my fault in missusing the tool without knowing there > is a missuse). So I returned to the insertion of Print-Statements. But I would like more to have a debugger which works well - it's more > easy and comfortable like the print-statement workaround. > Mike workbench (which up to now I do not own or use - but it seems to be a good tool). But first... I=B4m now going to a one week vacation (Toscana in winter could be good, too :-) ) Mike === Subject: two graphs have different color on surface I have tried to produce a graph where the color on the surface depends on the value of z. When I tried doing it in two different ways, the color are different on the two graphs even though as far as I can fee they should be the same. The code are as below ComplexColorPlot[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunction -> (ColorData[ Rainbow ][ Re@func[#1 + I*#2]] &) ] ] ComplexColorPlot2[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunction -> (ColorData[ Rainbow ][#3] &) ] ] ComplexColorPlot[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] ComplexColorPlot2[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] I expect the functions ComplexColorPlot2 and ComplexColorPlot to produce identical color graphs when given identical inputs but they dont. And I'm at loss as to why they dont. My ultimate objective is to have the color reflect the value of Im[func [x+I*y]] but I'm great difficulties in achieving it. === Subject: NIntegrate and Plot Hello. I have the following function fun[r_, t_] := -(((-3 + 4*t^2 + 8*t^4 - 8*t^3*Sqrt[1 + t^2])* BesselJ[1, r*t])/(3 + 14*t^2 + 24*t^4 + 16*t^6 - 16*t^3*Sqrt[1 + t^2] - 16*t^5*Sqrt[1 + t^2])) How can I achieve better performance in the following task Plot[NIntegrate[fun[r, t], {t, 0, Infinity}], {r, 0, 3}] === Subject: Re: Map onto one column of a matrix if you represent the matrix as a table/relation (Database` package of Roman E. Maeder) you could use his overloaded Table function. The solution is very elegant, but you need to name the columns (e.g. x,y or col1, col2 ). After naming the columns you use those names as function argumnets and don't need pure functions. You never need positional notiation. In[1]:= << Database` In[2]:= rel = newRelation[{x, y}, {{a, b}, {c, d}}]; In[3]:= Table[ {x, f[y]}, rel ] Out[3]= {{a, f[b]}, {c, f[d]}} Drago Ganic data = {{a, b}, {c, d}}; MapAt[f, #, {-1}] & /@ data data /. {q_, r_?AtomQ} :> {q, f[r]} Jens > >> >> 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: Re: Basic questions on list manipulation in the What you want is basically the relational database update/modify operator in Mathematica and this whole area is IMHO Mathematica's weakness since V1. There is no build-in function for this and related operations and area of computer science (DatabaseLink` stores the data externally, so I don't count it here). The list structure and operations are too general for a large class of applications and a less general but powerfull structure for tables/relations is needed. Mathematica Journal and the chapter Databases in his books: - The Mathematica Programmer, 1994 - Computer Science with Mathematica, 2000 In those books the (same) package Database` is developed and documented. Maeder showed the way how this operation should be implemented in Mathematica , but did not work out the details (operators like Sort, Group, Delete, Insert etc.) In your example (and ever imaginable similar example according to relational database theory), the data should be presented in a table form (matrix with header row) which lists all the attributes of your entities and where some attributes identify your entities (so called keys) while all other just describe it. But it is important that for many purposes keys can be used as all other attributes. For example the set to be updated can be defined in any way, not only via the key. In your example sym would be the key (e.g. Name), where val1, val2 and val3 would be the other attributes (e.g. height, weight, salary etc.). We load the package: In[1]: = < 100 not just simple ones like sym == sym1 Drago Ganic > For instance, ct = {{sym1 -> {val1 -> 20, val2 -> 300, > val3 -> 1000}}, {sym2 -> {val1 -> 50, val2 -> 500, > val3 -> 20000}}}; changeVal[ct_, who_, class_, amt_] := > ct /. Rule[who, {a___, Rule[class, _], b___}] :> > Rule[who, {a, Rule[class, amt], b}] ct = changeVal[ct, sym2, val1, hello ] {{sym1 -> {val1 -> 20, val2 -> 300, > val3 -> 1000}}, {sym2 -> {val1 -> hello , val2 -> 500, > val3 -> 20000}}} If you don't like the assignment construct ct = changeVal[..] , an > alternative is ct = {{sym1 -> {val1 -> 20, val2 -> 300, > val3 -> 1000}}, {sym2 -> {val1 -> 50, val2 -> 500, > val3 -> 20000}}}; Clear[changeVal] > SetAttributes[changeVal, HoldFirst] > changeVal[ct_, who_, class_, amt_] := > ct = ct /. > Rule[who, {a___, Rule[class, _], b___}] :> > Rule[who, {a, Rule[class, amt], b}] changeVal[ct, sym2, val1, hello ]; > ct {{sym1 -> {val1 -> 20, val2 -> 300, > val3 -> 1000}}, {sym2 -> {val1 -> hello , val2 -> 500, > val3 -> 20000}}} If you want changeVal to treat ct as a global, not an argument (never > recommended), then: ct = {{sym1 -> {val1 -> 20, val2 -> 300, > val3 -> 1000}}, {sym2 -> {val1 -> 50, val2 -> 500, > val3 -> 20000}}}; Clear[changeVal] > changeVal[who_, class_, amt_] := > ct = ct /. > Rule[who, {a___, Rule[class, _], b___}] :> > Rule[who, {a, Rule[class, amt], b}] changeVal[sym2, val1, hello ]; > ct {{sym1 -> {val1 -> 20, val2 -> 300, > val3 -> 1000}}, {sym2 -> {val1 -> hello , val2 -> 500, > val3 -> 20000}}} Bobby >> >> I have some basic questions about using lists in Mathematica. >> Specifically I have a table that serves as sort of a database with the >> following structure: >> >> ct = { >> { sym1 -> {val1->20, val2->300, val3->1000, ... }, >> { sym2 -> {val1->50, val2->500, val3->20000,...}, >> ... >> } >> >> sym1, sym2, ... are people and val1, val2 ... represent attributes of >> each person. >> >> Now I'm trying to go in and modify values. I can do it, but I think >> not well and I think with a programming language mindset instead of >> a Mathematica mindset. >> >> Here is my specific question. In order to change a specific value in >> the list above (valxxx) for a given individual (symxxx), I created >> this function: >> >> changeVal[ who_, class_, amnt_ ] := ( >> ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]] = >> ReplacePart[ ct[[ Position[ ct, who ][[ 1, 1 ]], 2 ]], >> Position[ ct[[ Position[ ct, who ][[ 1, 1 ]] ]], class ][[ 1, >> 2 ]] -> (class -> amnt) ] >> ); >> >> Now I know there is a better way than that using list manipulation and >> patterns. Can some of you experienced pros help me out? I call this >> write only code because I don't know that I could explain it once >> it's written. >> >> Perhaps a more fundamental question: is this the right way to store >> data in lists? Or would it be better to just have the values and >> reference them by index number? >> >> >> -- > DrMajorBob@longhorns.com > === Subject: ?1/2 I found it in another forum as a simplification chalenge and considered it quite interesting. The following expression is equal to 1/2. In[58]:= ex1 = ArcCsch[2]/(ArcSinh[2] - ArcCsch[2])/Sin[Pi*(ArcCsch[2]/(ArcSinh [2] - ArcCsch[2]))]; In[62]:= N[ex1, 50] Out[62]= 0.50000000000000000000000000000000000000000000000000 In[61]:= Developer`ZeroQ[ex1 - 1/2] Out[61]= True Nevertheless, no matter what I tried I was not able to simplify ex1 directly to 1/2. Any ideas? Dimitris === Subject: Re: ordering terms for display 1 + x + x^2 // TraditionalForm x^2 + x + 1 David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have a few mathematica expressions. say like 1 + x + x^2 I want these to be displayed in reverse order, so that I can copy them for use in latex. === Subject: Re: ordering terms for display > I have a few mathematica expressions. say like 1 + x + x^2 I want these to be displayed in reverse order, so that I can copy them > for use in latex. > In[66]:= 1+x+x^2//TraditionalForm Out[66]//TraditionalForm= ! (TraditionalForm `x ^2 + x + 1 ) Dimitris === Subject: Re: ordering terms for display TraditionalForm[] will do it and 1 + x + x^2 // TeXForm does it already Jens > I have a few mathematica expressions. say like 1 + x + x^2 I want these to be displayed in reverse order, so that I can copy them > for use in latex. === Subject: Re: ordering terms for display > I have a few mathematica expressions. say like 1 + x + x^2 I want these to be displayed in reverse order, so that I can copy them > for use in latex. Use, display, or convert your expressions in *TraditionalForm*. For instance, In[16]:= 1 + x + x^2 // TraditionalForm Out[16]//TraditionalForm= x^2+x+1 Then, you can copy and paste the resulting output cell(s) as usual (if you use the context menu, select Copy As... LaTeX). --Jean-Marc === Subject: Remove In/out names in Kernel / text session Hi MathGroup Is there a way to suppress printing of In[]/Out[] names when running only the kernel in a text session ? That is, when in type (in a Linux shell) math < foo.m I would like to see only the output line by line, not the In[]:=, Out []:= === Subject: Re: Mathematica Animation Drives Me Crazy! This may be a platform dependent problem. In any case, I'm working on a 32-bit Windows Vista, Version 7. Here are some typical results of repeated Trigger activation (Trigger controls omitted) with the first form of the Trigger example: Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], Dynamic[n], Dynamic[nevals], Dynamic[nlist]}] 4,10,{0,1,1,1,2,2,2,3,3,4} 10,23,{0,1,1,1,2,2,2,3,3,3,3,4,4,4,5,6,7,7,8,8,9,10,10} 10,13,{0,1,2,3,4,5,6,7,8,9,9,10,10} 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} 10,15,{0,1,1,2,3,4,5,6,7,7,8,8,9,10,10} 1,2,{0,1} Notice that in the first and last case the animation 'froze' at n = 4 and n = 1. The first number is the last value of n, the second number is the number of values that were actually produced (it should be equal to 11) and the third item is the list of values produced, which should be {0,1,2,3,4,5,6,7,8,9,10}. I would be very thankful if users on Windows Vista could try this out. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have never ending problems with Mathematica animation since Version 6. This takes the forms: 1) Sometimes (maybe about 10% if the time) an animation will 'stick' without finishing or repeating. 2) It does not seem possible to control the actual number of points or evaluations in the animation. 3) The documentation for the control of timing and precise steps is quite poor and this may be a reflection of actual buggy animation routines. Here is an example using Trigger, which is a kind of once-through animation. I am using an integer range, 0 to 10 in steps of 1. I would therefore like to have exactly 11 evaluations. But I always get an extra evaluation at the end, and even worse I often obtain repeat evaluations for some intermediate value. The following displays the value of n, the number of evaluations, and the actual list of n values for the evaluations. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] The following uses DisplayAllSteps -> True but seems to have the same problem. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}, DisplayAllSteps -> True], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] Do other users see these kind of problems, especially repeat evaluations for some values of n? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Which editor do you use for math >My advice? Stick to Mathematica and/or Word. (Unless you're willing >to learn LaTeX from the ground up, the hard way.) >I spent several hours last night sleuthing how to use Mac fonts in >LyX, which led to using them in TeXShop, which led to indecipherable >instructions for using LyX with XeTex, which led to utter confusion. Well since LyX is neither LaTeX nor TeXShop, I can see how this path would lead to confusion. LyX is designed to allow you to create documents without knowing LaTeX. Usage of TeXShop requires knowledge of LaTeX or TeX. XeTeX is a command line utility that extends TeX to allow usage of Mac fonts. Since TeXShop is basically an editor combined with a GUI for the Unix tools used to convert TeX source code into the final document, configuring TeXShop to use xetex instead of another tex tool is relatively simple. Currently, I've no idea how to configure LyX to make use of xetex. >I found a LyX document that explained and demonstrated how to do >this; but that document explained exactly nothing and could not be >typeset, neither with LaTeX NOR XeTeX. Trying to do so popped up >error messages (like the ones mentioned below). >Explanations (and ERROR messages) FREQUENTLY repeated the equivalent >of, If you use *nix, you'll be able to figure this out. No need to >explain it, or Make like Sherlock Holmes, and look for clues. >Apparently, the developers of this stuff MAY be a lot wise-a**es >who'd rather, really, have nobody else use their code. >Or, at least, they can't be bothered with meaningful documentation >or installers that do the full job. The thing is, both TeX and LaTeX existed much earlier than things like Word. They were created as Unix tools and still reflect those roots. The primary installation tools are other Unix tools. Installers that don't explicitly use the command line are typically a GUI wrapper for lower level Unix tools. Likewise, the main documentation for TeX are man pages and texdoc documents accessed using the command line. Obviously, converting this documentation to something like the online documentation found in Word or Mathematica is quite a bit of effort. If you are to effectively make use of LaTeX you will definitely want to get a book written about using LaTeX. Like Mathematica, LaTeX will require quite a bit of study/usage before you will really be comfortable using it. I believe the payoff for learning LaTeX warrants the effort. === Subject: Re: solution I did like liquid.phy adding (* Key Alt-Gr *) Item[KeyEvent[ ISO_Level3_Shift ], FrontEndExecute[{FrontEnd`NotebookWrite [FrontEnd`InputNotebook[], ]}] ], just after EventTranslations[{ in the configuration file /usr/local/Wolfram/Mathematica/7.0/SystemFiles/FrontEnd/TextResources/ X/KeyEventTranslations.tr It works and does not make any sound! i use version Mathematica 7.0.0, 32bit, Kubuntu 8.10 Enjoy it! B. === Subject: Re: message-driven function: more explanation > Hi Bert, nothing exotic here. The return value is a function that consits of a > Well, there is one thing which may be mildly exotic for those not familiar with it: the function is returned is wrapped by a closure, which is why it is able to retain the value of the counter variable. (The closure is not air-tight, though: In[1]:= f[a_] := Module[{aa = a, ff}, ff[i_] := (aa += i; aa); ff ]; In[2]:= q = f[0] Out[2]= ff$14 In[3]:= q[2] Out[3]= 2 In[4]:= aa$14 = 0; In[5]:= q[3] Out[5]= 3 Can one get a really closed closure?) -- m === Subject: Re: message-driven function: more explanation > In the book Programming Paradigms with Mathematica > http://library.wolfram.com/infocenter/MathSource/1847/ > in the notebook Hw21.nb there is following function: Clear[makeCounter]; > makeCounter::usage= makeCounter[] returns a message-driven function > which manipulates a hidden counter variable. The initial value > of the counter variable may be set via an optional argument to > makeCounter (default is 0). Valid messages for the function are > ++ (increment), -- (decrement), value , and reset . > For example, ctr = makeCounter[100]; ctr[ value ] returns 100. ; makeCounter[ > defaultValue_Integer:0 > ] := > Module[ > { counter = defaultValue, > changeCounter > }, > changeCounter[msg_String: ++ ] := > Switch[msg, > ++ , > counter = counter + 1; counter, > -- , > counter = counter - 1; counter, > value , > counter, > reset , > counter = defaultValue; counter, > _, > Print[ Unknown message to counter: , msg]; > counter > ]; > changeCounter > ]; ctr = makeCounter[100] > ctr[ value ] > ctr[ ++ ] gives as output changeCounter$723 > 100 > 101 Where can I find more explanation of this type of message-driven function ? I think the tricky part here is not that the function is message driven, but how it uses the Module variables so you can create many independent that the symbols in the list in the first argument of Module are meant to be local variables. So usually after the body of Module has finished, they will 'disappear'. It is an additional feature of Module that you can return local variables or expressions containing local variables, which is done here. These (local!) variables will then survive, even though they are now 'out of scope'. On the Mathematica side you can learn more about this by searching the documentation for Module and of view (which I am no expert for), I think this special behavior of Module is used here to mimic something that is known as a 'closure' in other programming languages, so you might want to search the web (or CS books) for 'closures' and learn whether my mentioning of them in this context was correct... hth, albert === Subject: problem with NDSolve in version 7 vs. version 6 I have a particular problem that may have further ramifications. I have a demonstration on line at Wolfram http://demonstrations.wolfram.com/RestrictedThreeBodyProblem/ In version 6 the plot from NDSolve will behave properly up to time = 53, but in version 7 it fails at much earlier times. The same result (version 7 not giving a good calculation at later times compared to version 6) shows up at other Jacobian constants . (The same result is shown in Player 6 vs Player 7). I have posted the attachment on http://home.comcast.net/~rmlurie/ as a pdf file called Comparison of ver 6 and ver 7. Robert M Lurie rmlurie at alum.mit.edu === Subject: Re: Frames on Density Plots in Version 7 With Mathematica 7.0 under Windows XP, for me BOTH plots are missing the upper frame line but have the ticks there. > When I submitted this to support they said they couldn't reproduce the > problem. It may be platform dependent. (I'm working on Windows 32-bit > Vista.) In the following plots the upper frame line is missing but the > ticks are present. DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] In Version 6 the first one displays correctly, and the second plot doesn't > exist. This problem is easily corrected by adding an ImagePadding option, but still > it would be annoying to casual users. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ -- 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: Frames on Density Plots in Version 7 > When I submitted this to support they said they couldn't reproduce the > problem. It may be platform dependent. (I'm working on Windows 32-bit > Vista.) In the following plots the upper frame line is missing but the > ticks are present. DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] Hi David, I cannot reproduce the issue you mentioned with Mathematica 7.0 on 32-bit Intel Windows XP Pro SP3 (both frames are displayed correctly, no missing frame line). --Jean-Marc === Subject: Re: Frames on Density Plots in Version 7 David, Looks like a platform dependency, both sets of output fine on my system. Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com Mathematica 7.0.0 for Mac OS X x86 (64 - bit) (21st November, 2008) MacOS X V 10.5.6 > When I submitted this to support they said they couldn't reproduce the > problem. It may be platform dependent. (I'm working on Windows 32-bit > Vista.) In the following plots the upper frame line is missing but > the > ticks are present. DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] In Version 6 the first one displays correctly, and the second plot > doesn't > exist. This problem is easily corrected by adding an ImagePadding option, > but still > it would be annoying to casual users. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Frames on Density Plots in Version 7 David, In my case 7.0 for Microsoft Windows (32-bit) (November 10, 2008) the frame is fine. However, only the righthand half of the leading zeros of the numbers on the y-axis is visible. > When I submitted this to support they said they couldn't reproduce the > problem. It may be platform dependent. (I'm working on Windows 32-bit > Vista.) In the following plots the upper frame line is missing but the > ticks are present. DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] In Version 6 the first one displays correctly, and the second plot doesn'= t > exist. This problem is easily corrected by adding an ImagePadding option, but st= ill > it would be annoying to casual users. David Park djmp...@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Extracting Graphics3D from Plots a problem I have been struggling for quite a while is how to extract a ma= nipulatable Graphics3D object from the result of e.g. a Plot3D or Revolutio= nPlot3D call. By manipulatable I mean an object I can rotate or translat= e using RotationTransform and then combine with other objects such as Cy= linder . What I do not intend to do is use Epilog in a Plot3D call. The first good news is that there's enormous power built into the new (as of v6) graphics structure, and the second is that there are tools of enormous power to retrieve and manipulate its components. The bad news is that all those are largely undocumented, practically encrypted. > I am actually looking for the CORRECT Mathematica-way, i.e. the one antic= ipated by the Wolfram people and not some workaround that might fail in fut= ure versions of Mathematica. I won't take responsibility for CORRECTNESS or the projected lifetime of the methods, especially considering the level of Wolfram's documentation, but here are some notes I took at the Graphics school last summer in Champaign. (* Starting with an example of Plot3D from the Doc Center: *) p3D = Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}] (* The internal structure of p3D can be exposed with *) InputForm[p3D] // Short[#, 20] & (* So the plot is itself a Graphics3D object with the GraphicsComplex first argument, and, just to emphasize its nature, can be reproduced by *) Graphics3D[First[p3D]] (* The function Normal[] is useful for disassembling the GraphicsComplex into graphics primitives. *) Normal[p3D] // InputForm // Short[#, 20] & (* Knowing the structure, you can isolate, manipulate and display its parts. In the following example, all the Polygons are removed *) DeleteCases[p3D, _Polygon, Infinity] (* The basic types of graphics objects, if they're present, can be easily extracted: *) (points = Cases[Normal[p3D] , _Point, Infinity] // Flatten // First) // Short[#, 10] & (lines = Cases[Normal[p3D] , _Line, Infinity] // Flatten // First) // Short[#, 10] & (polygons = Cases[Normal[p3D] , _Polygon, Infinity]) // Short[#, 10] & (* and the parts can be manipulated as Graphics primitives. *) Graphics3D[lines] Graphics3D[Rotate[lines, Pi/6, {0.7, 0.7, 0.7}]] (* While Normal[] is handy for accessing the primitives, you can get to the underlying form of GraphicsComplex by frontal assault. The raw list of nodes in the GraphicsComplex can be retrieved by the following Replace[]:*) (nl = First[p3D] /. GraphicsComplex[nodelist_, rest___] -> nodelist) // Short[#, 20] & (* Here, nodelist is the raw list of (in this case 3D) points, and rest is the description of the way the primitives are constructed from the node list. The extracted variable can be used as an argument to new or independent primitives: *) Graphics3D[Point[nl]] (* or it can be manipulated by a lower level transformations. *) r = RotationTransform[Pi/6, {1, -1, 0}] Graphics3D[Point[r@nl]] (* or the transformed result can be directly injected into a reconstructed GraphicsComplex *) Graphics3D[ First[p3D] /. GraphicsComplex[nodelist_, rest___] -> GraphicsComplex[r[nodelist], rest] ] (* Putting it all together for your example: *) img = Import[ ExampleData/rose.gif ]; imgS = Rasterize[img, Data , RasterSize -> {32, 32}]/255.0; Graphics3D[ First[ Plot3D[ Sin[x y], {x, 0, 3}, {y, 0, 3} , ColorFunction -> (RGBColor[ imgS[[1 + Round[10 #1], 1 + Round[10 #2]]]] &) , ColorFunctionScaling -> False, Mesh -> False, PlotPoints -> 32] ] /. GraphicsComplex[nodelist_, rest___] -> GraphicsComplex[ RotationTransform[Pi/6, {1, -1, 0}][nodelist], rest] ] Hth, Fred Klingener === Subject: Re: Extracting Graphics3D from Plots It's not difficult as long as you pay attention to the InputForm of your Graphic3D object. Usually it will contain a GraphicsComplex primitive, which makes this particularly easy. Here is an example Here is a Grpahics3D object from the Documentation obtained by using RevolutionPlot3D gr = RevolutionPlot3D[t^4 - t^2, {t, 0, 1}] Here is the rotation transform: tt = RotationTransform[Pi/3, {0, 1, 0}]; Now rotate gr: gr1 = gr /. v__GraphicsComplex :> GeometricTransformation[v, tt]; Now show it with the option PlotRange set to All: Show[gr1, PlotRange -> All] Andrzej Kozlowski a problem I have been struggling for quite a while is how to extract > a manipulatable Graphics3D object from the result of e.g. a Plot3D > or RevolutionPlot3D call. By manipulatable I mean an object I can > rotate or translate using RotationTransform and then combine with > other objects such as Cylinder . What I do not intend to do is use > Epilog in a Plot3D call. I am actually looking for the CORRECT Mathematica-way, i.e. the one > anticipated by the Wolfram people and not some workaround that might > fail in future versions of Mathematica. Somewhat related is another question. Is it possible to put a > texture on a Cylinder , Tube or Cone ? I do know how to place > an image onto the surface of a Plot3D output (in a seemingly correct > Mathematica way, see below). > Ernst img = Import[ ExampleData/rose.gif ] imgS = Rasterize[img, Data , RasterSize -> {32, 32}]/255.0; Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, = ColorFunction -> (RGBColor[ > imgS[[1 + Round[10 #1], 1 + Round[10 #2]]]] &), = ColorFunctionScaling -> False, Mesh -> False, PlotPoints -> 32] === Subject: Re: Extracting Graphics3D from Plots a) surf = Cases[ Plot3D[Sin[x*y], {x, 0, Pi}, {y, 0, Pi}], _GraphicsComplex, Infinity]; and Manipulate[ Graphics3D[ {surf, Sphere[Append[pnt, z], 1]}], {{pnt, {0, 0}}, Slider2D}, {{z, 0}, -2, 2}] b) Epilog work only with 2d graphics never with 3d c) MathGL3d can do textures but Mathematica not Jens a problem I have been struggling for quite a while is how to extract a manipulatable Graphics3D object from the result of e.g. a Plot3D or RevolutionPlot3D call. By manipulatable I mean an object I can rotate or translate using RotationTransform and then combine with other objects such as Cylinder . What I do not intend to do is use Epilog in a Plot3D call. I am actually looking for the CORRECT Mathematica-way, i.e. the one anticipated by the Wolfram people and not some workaround that might fail in future versions of Mathematica. Somewhat related is another question. Is it possible to put a texture on a Cylinder , Tube or Cone ? I do know how to place an image onto the surface of a Plot3D output (in a seemingly correct Mathematica way, see below). > Ernst img = Import[ ExampleData/rose.gif ] imgS = Rasterize[img, Data , RasterSize -> {32, 32}]/255.0; Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, = ColorFunction -> (RGBColor[ > imgS[[1 + Round[10 #1], 1 + Round[10 #2]]]] &), = ColorFunctionScaling -> False, Mesh -> False, PlotPoints -> 32] === Subject: Re: Extracting Graphics3D from Plots Call the 3D graphic (like the one in your example) g then: {GeometricTransformation[g /. Graphics3D -> List, RotationTransform[30 Degree, {1, 0, 1}]], Cylinder[]} // Graphics3D shows that you can rotate the result and combine it with a cylinder. a problem I have been struggling for quite a while is how to extract a ma= nipulatable Graphics3D object from the result of e.g. a Plot3D or Revolutio= nPlot3D call. By manipulatable I mean an object I can rotate or translat= e using RotationTransform and then combine with other objects such as Cy= linder . What I do not intend to do is use Epilog in a Plot3D call. I am actually looking for the CORRECT Mathematica-way, i.e. the one antic= ipated by the Wolfram people and not some workaround that might fail in fut= ure versions of Mathematica. Somewhat related is another question. Is it possible to put a texture = on a Cylinder , Tube or Cone ? I do know how to place an image onto = the surface of a Plot3D output (in a seemingly correct Mathematica way, see= below). > Ernst img = Import[ ExampleData/rose.gif ] imgS = Rasterize[img, Data , RasterSize -> {32, 32}]/255.0; Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, = ColorFunction -> (RGBColor[ > imgS[[1 + Round[10 #1], 1 + Round[10 #2]]]] &), = ColorFunctionScaling -> False, Mesh -> False, PlotPoints -> 32] === Subject: hotkeys / inkey hi, i've been told that mathematica 6 (which actually i don't own, i can seldom use it at campus) can accept input by pressing a key without pressing return, (something similar to the inkey$ command of gwbasic). could you please explain me how to do with a simple example? mind that i'm not at all an expert user of mathematica language. it could be enough if you could show me how to obtain a string, displayed on an output cell of the notebook adding the carachters i type without waiting for the return ... by the way, if i look for this feature for other systems, which term should check? hotkeys? thank you very much anm === Subject: Re: Problem with spline function object in Mathematica 6 > Here is my current code: > SplineTable={{0,0},{1,1},{2,8},{3,27},{4,64}}; > Spl=SplineFit[SplineTable,Cubic]; > derivSpline=ReplacePart[Spl,Map[Append[Rest[#]*{1,2,3},0]&,Spl[[4]],{2}],4]; > dMdr[x_]:=Last[derivSpline[x]]/First[derivSpline[x]]; > drdt[x_] := First[derivSpline[x]]; > sol3 = NDSolve[{param[0]==0,(param'[x]-(1/drdt[param[x]]))==0},param,{x,0,4}] So again the problem I have is that drdt[param[x]] evaluates to param[x] > automatically (and immediately gives a division by 0 error in NDSolve) instead > of attempting to evaluate param[x] to a number first. > The same happens with dMdr[x]. My goal in the end will be to evaluate > dMdr[param[x]] correctly when supplied with x. Add a test _?NumericQ to the parameters of the functions so they are called only when the arguments are numeric. dMdr[x_?NumericQ] := Last[derivSpline[x]]/First[derivSpline[x]]; drdt[x_?NumericQ] := First[derivSpline[x]]; For instance, In[1]:= Needs[ Splines` ] SplineTable = {{0, 0}, {1, 1}, {2, 8}, {3, 27}, {4, 64}}; Spl = SplineFit[SplineTable, Cubic]; derivSpline = ReplacePart[Spl, Map[Append[Rest[#]*{1, 2, 3}, 0] &, Spl[[4]], {2}], 4]; dMdr[x_?NumericQ] := Last[derivSpline[x]]/First[derivSpline[x]]; drdt[x_?NumericQ] := First[derivSpline[x]]; sol3 = NDSolve[{param[0] == 0, (param'[x] - (1/drdt[param[x]])) == 0}, param, {x, 0, 4}] Out[7]= {{param->InterpolatingFunction[{{0.,4.}},<>]}} --Jean-Marc === Subject: Re: 0^0 = 1? >>> 0^0 means the limit if both base and exponent go to zero. >> No, that is not how 0^0 is defined. Does 2+2 mean the limit as both >> summands go to 2? The value may happen to be the same in that case, but >> that is not how 2+2 is defined. >> The value of x^y for cardinal numbers x and y is the cardinality of the >> set of mappings from y into x. In the case where x and y are the empty >> set, there is exactly one such mapping. Hence, 0^0 = 1. > That's a definition from set theory. I doubt it plays nice in the > complex plane. The definition of Power we go by is > ower[a,b] == Exp[Log[a]*b] > Among other advantages, it means branch cuts for Power are inherited > from Log. Branch cuts at 0 are not particularly relevant here, since Exp[-oo*0] = Exp[anything*0] = Exp[0] = 1. >> It's a theorem of ZF (as stated in Suppes, _Axiomatic_Set_Theory_) that >> m^0 = 1 for every cardinal number m. > I think the setting of cardinal numbers is not really a good choice for > symbolic computation. Because it doesn't support your preferred answer? We define other operations (addition and multiplication, for example) by starting with the cardinals, then extending to the integers, the rationals, the reals, and then the complex numbers. At each stage, we want the new definition to be consistent with the old. >> Another way is to notice that 0^0 represents an empty product, whose >> value is the identity element in the monoid of the integers (or the >> reals). >> In[1]:= Product[0,{k,0}] >> Out[1]= 1 > This and the ZF result are arguments for making 0^0 equal to one. They > are not in any sense proofs that it must be one, given that Power > lives in the setting of functions of complex variables. The ZF result is indeed a proof in the context of the cardinal numbers. The empty product result applies to any monoid. The complex numbers are a monoid. The symbol 0 in Mathematica represents the complex number 0, and as you can see, Mathematica agrees that the empty product yields the complex number 1. >> One might also consider the series expansion for Exp[0], which reduces to >> 1 = 0^0/0! + (lots of terms that all reduce to zero). > This point is questionable, since one does not in general encounter the > formula with a term x0^0 (where x0 is the point of expansion). It is not questionable. The series expansion for Exp[x] is Sum[x^k/k!,{k,0,Infinity}] whether one normally encounters it in that form or not. >> Having x^y be discontinuous at (0,0) does not cause problems any more >> than having the Sign function be discontinuous at 0 causes problems. > That's a matter of opinion. Clearly we do not at this time agree with > you on this. But no one has presented an example of an actual problem that is caused by the definition. Discontinuous functions exist. That's the basic reason that we need to study limits in the first place. >> Anyone who works with limits should be aware that you can't just blindly >> assume continuity when evaluating limits. You have to consider the >> actual definition of the limit. > True, but I don't see any relevance to this particular issue. The > question at hand is whether or not 0^0 should be assigned a concrete > value. If it is given a value, then since limits of x^y depend on how > x,y respectively approach 0, they might or might not equal that value > (so there is no underlying assumption of continuity). But that is > already the case, and the question at hand is whether the undefined > value should in fact be defined. We don't assign a value to 0^0. We simply look at the definition and notice what it says for the case of 0^0. The definition makes no statement at all about limits, and therefore thinking that the definition has implications regarding limits is a misconception. -- Dave Seaman Third Circuit ignores precedent in Mumia Abu-Jamal ruling. === Subject: Re: Timing of N[ Factorial[4000000], 18] About 5 sec on an iMac with 2.33 GHz Intel Core 2 Duo $Version 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) Timing[N[Factorial[4000000], 18]] {4.844104999999956, 5.4678775615144509794160360 7630299100641970199064388473`18.*^24671065} Bob Hanlon How long does it take Mathematica 7 to compute N[ Factorial[4000000], 18] With the old version of Mathematica I have it takes a very long time, and I was wondering if Mathematica 7 is much better. You might ask why I wanted to do that. Well I wanted to see how quickly Stirling's formula approaches Factorial[n] for large n. ------------------------ Ted Ersek === Subject: Re: Has anyone tried to use MathLink to receive real-time Another way would be through Mathematica's built-in J/Link (I think). That is, I have webMathematica getting webpages using some Java. That Java code right now is running on a server but I believe that in theory (though I have not tested) that Mathematica directly supports Java. I also thought that the Wolfram databases were updated every 15 min. I thought I read that somewhere. The market data would not be one day old in this case. Both of my comments above are in the category of what I believe rather than what I know and have tested . > Hello All: One of the great new things in Mathematica > 6 is the curated data. > Defintely having access to the curated historical data is a great > feature, however, providing access to analyze real-time would take > this feature to the next level. I was wondering if anyone has used > Mathematica (via MathLink I assume) to access the free real-time feeds > from OpenTick (check their website). I would love to see this kind of thing as a permanent feature of > Mathematica, and am contemplating submitting it as a feature > request....would anyone else use something like this? Would love to hear your thoughts. > t. > === Subject: Re: ?1/2 Rationalize[N[ex1]] ?? Robert -----Original Message----- === Subject: ?1/2 I found it in another forum as a simplification chalenge and considered it quite interesting. The following expression is equal to 1/2. In[58]:= ex1 = ArcCsch[2]/(ArcSinh[2] - ArcCsch[2])/Sin[Pi*(ArcCsch[2]/(ArcSinh [2] - ArcCsch[2]))]; In[62]:= N[ex1, 50] Out[62]= 0.50000000000000000000000000000000000000000000000000 In[61]:= Developer`ZeroQ[ex1 - 1/2] Out[61]= True Nevertheless, no matter what I tried I was not able to simplify ex1 directly to 1/2. Any ideas? Dimitris === Subject: Re: Has anyone tried to use MathLink to receive real-time market data > Hello All: One of the great new things in Mathematica > 6 is the curated data. > Defintely having access to the curated historical data is a great > feature, however, providing access to analyze real-time would take > this feature to the next level. I was wondering if anyone has used > Mathematica (via MathLink I assume) to access the free real-time feeds > from OpenTick (check their website). I would love to see this kind of thing as a permanent feature of > Mathematica, and am contemplating submitting it as a feature > request....would anyone else use something like this? Would love to hear your thoughts. > t. Seems to me that there are so many better ways of doing, that it would not really add anything. Gary === I have been using Adobe FrameMaker for this purpose for years. I thought it worth mentioning since no one else has yet done so. FrameMaker provides the conveniences of a word processor type environment (WYSIWYG, automatic numbering of references, cross referencing for figures, equation numbers, templates for multicolumn camera-ready papers and other report formats, etc.) that I find useful when writing a paper. It has its own equation editor, so I don't think you could cut and paste directly from Mathematica--though I don't know if that is possible with the alternatives either. I can't compare this option to the more frequently mentioned TeX-related ones. I'd be interested in comments from anyone who is familiar with both. John 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: Re: Frames on Density Plots in Version 7 > When I submitted this to support they said they couldn't reproduce the > problem. It may be platform dependent. (I'm working on Windows 32-bit > Vista.) In the following plots the upper frame line is missing but the > ticks are present. DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] Both of them display the frame correctly on my 32-bit Vista machine at home. The upper frame line goes missing on my XP machine in my office. -- Helen Read University of Vermont === Subject: Re: Frames on Density Plots in Version 7 > When I submitted this to support they said they couldn't reproduce the > problem. It may be platform dependent. (I'm working on Windows 32-bit > Vista.) In the following plots the upper frame line is missing but the > ticks are present. DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] In Version 6 the first one displays correctly, and the second plot doesn'= t > exist. This problem is easily corrected by adding an ImagePadding option, but st= ill > it would be annoying to casual users. David Park djmp...@comcast.net http://home.comcast.net/~djmpark/ I do not reproduceyour results with Mathematica 7.0 on 32-bit Intel Windows XP Pro SP3 (both frames are displayed correctly, no missing frame line). === Subject: Re: Non-deterministic numerical inaccuracies in Mathematica 7 >> >> 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. >> I think we should care about it! Lots of programs have different behaviours depending on a real number threshold, and this behaviour means that there is the possibility of a test flipping different ways on different runs of a program! This could be a debugging nightmare, and will be in the back of people's minds whenever anything 'strange' happens. Would it not be possible to revert to the previous, slightly less optimal, library until (presumably) the library is fixed? David Bailey http://www.dbaileyconsultancy.co.uk === Subject: iterative method? How to find x_(n+1)=(a*x_n+b*y_n)/c*x_n , y_(n+1)=d*x_n*y_n using mathematica? I want to find a list of x and y when n=1,2,...,50 so I defined the function as f[{x_,y_}]:={a*x_n+b*y_n)/c*x_n,d*x_n*y_... } and then use the function NestList[f,{2,5},50] with initial value of x is 2 and y is 5 with this, I got the list of 50 values of (x,y). The problem is I want to plot graphs of x against n and y against n, n from 1 to 50 because I want to see what happened if n goes to infinity. But if use the method I just mentioned, I can only plot x against y. So do anyone have a clever method?? Btw...a,b,c and d are constants and given and x_n is supposed to be x (subscript n)...same case with x_(n+1) and the others === Subject: NestList How to find x_(n+1)=(a*x_n+b*y_n)/c*x_n , y_(n+1)=d*x_n*y_n? I want to find a list of x and y when n=1,2,...,50 so I defined the function as f[{x_,y_}]:={a*x_n+b*y_n)/c*x_n,d*x_n*y_... } and then use the function NestList[f,{2,5},50] with initial value of x is 2 and y is 5 with this, I got the list of 50 values of (x,y). The problem is I want to plot graphs of x against n and y against n, n from 1 to 50 because I want to see what happened if n goes to infinity. But if use the method I just mentioned, I can only plot x against y. So do anyone have a clever method?? Btw...a,b,c and d are constants and given and x_n is supposed to be x (subscript n)...same case with x_(n+1) and the others === Subject: Re: Why does the Shooting Method fail? The shooting method can fail for non-linear differential equations because the solution becomes singular for some values of the initial conditions. In such cases, quasi-linearization is a better approach. http://library.wolfram.com/conferences/conference98/abstracts/iterative_solu tion.html > Hi I have a set of coupled nonlinear differential equations with boundary > conditions that I am solving using the shooting method. The > mathematica notebook can be downloaded at http://web.mit.edu/~shahriar/Public/submission2.nb In the line where eqn2 is defined I show that if eta' is 0.1 the > shooting method works and the boundary conditions of vz[xend]==0 and w > [xend]==0 is satisfied. If I change the eta' to 0.01 (which is a case > I do want) I dont get it to converge to these boundary conditions. I have tried numerous things like changing the stepsize, number of > steps and even reverse shooting and it doesnt work. I have even > changed the range for the variables A and B that determine the > starting slope of vz[x] and w[x] but that doesnt do much. I would greatly appreciate it if someone can help me on this matter. === Subject: Re: ordering terms for display > 1 + x + x^2 // TraditionalForm > x^2 + x + 1 David Park > djmp...@comcast.nethttp://home.comcast.net/~djmpark/ > I have a few mathematica expressions. say like 1 + x + x^2 I want these to be displayed in reverse order, so that I can copy them > for use in latex. > equations? === Subject: Re: Timing of N[ Factorial[4000000], 18] > How long does it take Mathematica 7 to compute > N[ Factorial[4000000], 18] With the old version of Mathematica I have it takes a very long time, > and I was wondering if Mathematica 7 is much better. You might ask why > I wanted to do that. Well I wanted to see how quickly Stirling's > formula approaches Factorial[n] for large n. In[1]:= N[Factorial[4000000], 18] // Timing Out[1]= {18.532, 5.46787756151445098*10^24671065} Mathematica 7.0.0 32-bit Windows XP Pro SP3 (MathematicaMark7: 0.41) --Jean-Marc === Subject: Re: Timing of N[ Factorial[4000000], 18] > How long does it take Mathematica 7 to compute > N[ Factorial[4000000], 18] With the old version of Mathematica I have it takes a very long time, > and I was wondering if Mathematica 7 is much better. You might ask why > I wanted to do that. Well I wanted to see how quickly Stirling's > formula approaches Factorial[n] for large n. I don't have Mathematica 7, but here's my benchmark: In[1]:= $Version In[2]:= Timing[N[ Factorial[4000000], 18]] 24671065 Out[2]= {18.6842 Second, 5.46787756151445098 10 } Scott -- Scott Hemphill hemphill@alumni.caltech.edu This isn't flying. This is falling, with style. -- Buzz Lightyear === Subject: Re: Timing of N[ Factorial[4000000], 18] $Version 7.0 for Microsoft Windows (32-bit) (November 10, 2008) {7.55, 5.46787756151445098*10^24671065} Robert -----Original Message----- === Subject: How long does it take Mathematica 7 to compute N[ Factorial[4000000], 18] With the old version of Mathematica I have it takes a very long time, and I was wondering if Mathematica 7 is much better. You might ask why I wanted to do that. Well I wanted to see how quickly Stirling's formula approaches Factorial[n] for large n. ------------------------ Ted Ersek === Subject: Re: Timing of N[ Factorial[4000000], 18] $Version 7.0 for Microsoft Windows (32-bit) (November 10, 2008) Timing[N[Factorial[4000000],18]] {6.047,5.46787756151445098*10^24671065} > How long does it take Mathematica 7 to compute > N[ Factorial[4000000], 18] With the old version of Mathematica I have it takes a very long time, > and I was wondering if Mathematica 7 is much better. You might ask why > I wanted to do that. Well I wanted to see how quickly Stirling's > formula approaches Factorial[n] for large n. ------------------------ > Ted Ersek -- 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: Weirdness from double integrals? I'm new to Mathematica 7 (fiddling with a trial version) and I've bumped into something that's confusing me. Just to make sure I understand Mathematica, I'm playing with finding the gravitational field around extended objects using integration. So far I've had no problem (e.g., lines, rings, planes, even Newton's shell theorem popped out easily enough), but I'm getting something that's confusing about double definite integration the Integrate that's leaving me puzzled. Here's the (cleaned-up) transcript from math: In[1]:= p = {0, 0, h} Out[1]= {0, 0, h} In[2]:= s = {x, y, 0} Out[2]= {x, y, 0} In[3]:= q = p - s Out[3]= {-x, -y, h} In[4]:= dm = rho (* dx dy *) Out[4]= rho In[5]:= integrand = -G * dm * q/(q.q)^(3/2) G rho x G rho y G h rho Out[5]= {-----------------, -----------------, -(-----------------)} 2 2 2 3/2 2 2 2 3/2 2 2 2 3/2 (h + x + y ) (h + x + y ) (h + x + y ) In[7]:= Integrate[integrand, {x, -x0, x0}, {y, -y0, y0}] Out[7]= {0, 0, 0} In[9]:= Integrate[Integrate[integrand, {x, -x0, x0}, Assumptions -> x0 > 0 && h > 0], {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] x0 y0 Out[9]= {0, 0, -2 G rho (Pi - 2 ArcCot[----------------------])} 2 2 2 h Sqrt[h + x0 + y0 ] It would seem to me, less assumptions, that Out[7] and Out[9] should be the same, but Out[7] is clearly wrong (read: not what I expected :-) -- while the x and y components of the integration are zero by symmetry, the z component clearly should not be. Out[9] looks correct, but I thought these would have been the same computation; converting In[7] to traditional form in the front end appears to confirm my understanding that it does indeed represent a double definite integral over the integrand. So what is there about doing double definite integrals with Integrate that I'm missing? Why aren't these computations the same? -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis He who can, does. He who cannot, teaches. -- George Bernard Shaw === Subject: Re: two graphs have different color on surface and David Park. It seems my mistake is not to take into account the ColorFunctionScale- >False option and to do manual rescaling. I have the following functions I have ComplexColorPlotReIm which shows the Re value via the vertical Z value and the Im value via the color. This allows me to see the complex values on a single graph. ComplexColorPlotReRe[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunction -> (ColorData[ Rainbow ][#3] &) ] ] ComplexColorPlotReIm[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunctionScaling -> False, ColorFunction -> (ColorData[ Rainbow ][ Rescale[Im@func[#1 + I*#2], {-1, 1}]] &) ] ] ComplexColorPlotImIm[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Im[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunction -> (ColorData[ Rainbow ][#3] &) ] ] ComplexColorPlotReRe[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] ComplexColorPlotReIm[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] ComplexColorPlotImIm[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] === Subject: Re: two graphs have different color on surface Steven, I would suggest using ColorFunctionScaling -> False, and Rescale to control precisely how the color function is working. Here is plot statement that plots the Im part of the function, and also color according to the Im part. The purpose of this to see if we are getting precisely what we want. ComplexColorPlot3[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Im[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunctionScaling -> False, ColorFunction -> (ColorData[ Rainbow ][ Rescale[Im@func[#1 + I*#2], {-1, 1}]] &)]] ComplexColorPlot3[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, Mesh -> None] And there the coloring property tracks the height of the Im surface. Then we change to a Re surface and an Im coloring. ComplexColorPlot4[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunctionScaling -> False, ColorFunction -> (ColorData[ Rainbow ][ Rescale[Im@func[#1 + I*#2], {-1, 1}]] &)]] ComplexColorPlot4[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, Mesh -> None] I think that is your plot. However, I don't especially like this because two comparable things, the Re and Im parts of the function, are represented in entirely different manners in the graphic. It might be better to do Re and Im surface plots side by side. Or possibly a polar density plot of the modulus with argument contour lines on top of it. The Presentations package has technology for representing such multivalued functions on a Riemann surface without any branch line discontinuities. The function is single valued and continuous everywhere on the surface. The Sqrt case is one example given in the documentation. Needs[ Presentations`Master` ] DynamicModule[{zpt = {1.5, 0}, w, root}, Module[ {f = Function[z, Sqrt[z]], sqrtz, z, zcenter = 0}, sqrtz = Multivalues[Null, {Sqrt[z], -Sqrt[z]}, z]; Row[ {Draw2D[ {ComplexPolarDensityDraw[ Abs[f[z]], {z, ComplexPolar[0, - [Pi]], ComplexPolar[3, [Pi]], zcenter}, ColorFunctionScaling -> False, ColorFunction -> (ColorData[ GrayYellowTones ][ Rescale[#, {0, Sqrt[3]}]] &), Mesh -> {Sqrt /@ Range[.5, 3, .5]}, MeshFunctions -> (Abs[Sqrt[#1]] &), PlotPoints -> {5, 10} 4, MaxRecursion -> 0, PlotRange -> {0, 3}], Dynamic@ Arrow[{zpt, zpt + 1/2 ToCoordinates[ root = Extract[ CalculateMultivalues[sqrtz][ToComplex[zpt]], {1, 1}]]}], Locator[Dynamic[zpt], Graphics[{CirclePoint[{0, 0}, 3, Black, Red]}]]}, Frame -> True, FrameLabel -> {Re, Im}, PlotRange -> 3, PlotLabel -> Row[{f[ z ], as a Rieman Surface }], Background -> None, ImageSize -> 350], Dynamic@Column[ {ComplexArgumentPanel[ToComplex[zpt], {True, True, False}, Row[{ z , Spacer[20]}], {Left, Center}, ImageSize -> {185, 42}], ComplexArgumentPanel[root, {True, True, False}, Row[{f[ z ]}], {Left, Center}, ImageSize -> {185, 42}]}](* Column *)}, Spacer[20]](* Row *) ] ] This gives a polar density plot of the Modulus as a background. There is a red CirclePoint locator that has an arrow attached to it. The arrow represents the value of the complex function at the locator. The values of z and Sqrt[z] are also dynamically displayed to the right of the graphic in both Cartesian and polar form. Initially the arrow points to the right. If you drag the locator around the origin once, the arrow will point to the left. One has to circle the origin twice to get back to the original value. One does not actually 'see' the Riemann surface, only its effects. One can move anywhere around it, recapture both values of Sqrt[z] and get back to the original point without any jumps, artifacts or discontinuities. Just like Riemann said. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have tried to produce a graph where the color on the surface depends on the value of z. When I tried doing it in two different ways, the color are different on the two graphs even though as far as I can fee they should be the same. The code are as below ComplexColorPlot[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunction -> (ColorData[ Rainbow ][ Re@func[#1 + I*#2]] &) ] ] ComplexColorPlot2[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunction -> (ColorData[ Rainbow ][#3] &) ] ] ComplexColorPlot[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] ComplexColorPlot2[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] I expect the functions ComplexColorPlot2 and ComplexColorPlot to produce identical color graphs when given identical inputs but they dont. And I'm at loss as to why they dont. My ultimate objective is to have the color reflect the value of Im[func [x+I*y]] but I'm great difficulties in achieving it. === Subject: Re: two graphs have different color on surface > I have tried to produce a graph where the color on the surface depends > on the value of z. When I tried doing it in two different ways, the > color are different on the two graphs even though as far as I can fee > they should be the same. The code are as below ComplexColorPlot[func_, {xmin_, xmax_}, {ymin_, ymax_}, > opts___?OptionQ] := Module[{x, y}, > Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, > ColorFunction -> (ColorData[ Rainbow ][ > Re@func[#1 + I*#2]] &) ] ] ComplexColorPlot2[func_, {xmin_, xmax_}, {ymin_, ymax_}, > opts___?OptionQ] := Module[{x, y}, > Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, > ColorFunction -> (ColorData[ Rainbow ][#3] &) ] ] ComplexColorPlot[Sqrt, {-1, 1}, {-1, 1}, > ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] ComplexColorPlot2[Sqrt, {-1, 1}, {-1, 1}, > ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] I expect the functions ComplexColorPlot2 and ComplexColorPlot to > produce identical color graphs when given identical inputs but they > dont. And I'm at loss as to why they dont. My ultimate objective is to have the color reflect the value of Im[func > [x+I*y]] but I'm great difficulties in achieving it. The issue might be due to color scaling, assuming that both color functions are really the same thing but written differently. Set the option ColorFunctionScaling to True or False in both plot functions to see how the graphs are rendered. ComplexColorPlot[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunction -> (ColorData[ Rainbow ][Re@func[#1 + I*#2]] &), ColorFunctionScaling -> False]] ComplexColorPlot2[func_, {xmin_, xmax_}, {ymin_, ymax_}, opts___?OptionQ] := Module[{x, y}, Plot3D[Re[func[x + I y]], {x, xmin, xmax}, {y, ymin, ymax}, opts, ColorFunction -> (ColorData[ Rainbow ][#3] &), ColorFunctionScaling -> False]] ComplexColorPlot[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] ComplexColorPlot2[Sqrt, {-1, 1}, {-1, 1}, ViewPoint -> {1.227, -1.942, 3.028}, PlotPoints -> {50, 50}] HTH, --Jean-Marc === Subject: Mathematica and LyX - Graphics and equations I unintentionally started a fierce discussion recently about the best editor for math stuff. Many people responded with a number of suggestions and among them one particular solution seemed to prevail - LaTeX. I decided to give it a try and installed the MiKTeX Win version along with the LyX fronted for it, since I have absolutely no experience with LaTeX. It's almost a week now that I'm struggling to produce anything usable with LyX and I have to admit I have mixed feelings about it. It's really easy to produce good quality documents with the default settings/templates. When something however doesn't look right I feel like my hands are tied together - usually there's no user control over it. I'm still not giving it up though and I'd like to ask a couple of questions about the Mathematica/LyX interaction. 1) What is the best way to export graphics from Mathematica? I currently use eps format, but there seems to be a weird bug with it - I'm not sure whether it's a Mathematica or LyX or LaTeX issue - for example I have 2 vectors in my graphic and the head of the last one drawn is not displayed in the final PDF version of my document. I found a workaround for it by drawing objects twice in the graphic that way if some parts of the object is missing it wouldn't matter since the one underneath will be fine. 2) How do I export the equations from Mathematica? Even though there is an Export to LaTeX option in Mathematica I couldn't succeed in just pasting the content in LyX - so much junk comes along with the equation that cleaning it up usually takes more time than just typing it fresh in LyX 3) And finally could someone please provide detailed instructions of how to setup LyX to interact directly with the Mathematica kernel so I can have some semi live math environment. May be that way the equations will come in the right form TL === Subject: Length distribution of random secants on a unit square I need to work with the length distribution of random secants (of two random points on the perimeter) on a unit square. It's easy to generate some random data and a histogram. I used the following code (Mathematica 7.0): len = Norm[(First[#] - Last[#])] &; corners = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; p[t_] := Block[{n, r}, n = Mod[IntegerPart[t], 4]; r = FractionalPart[t]; corners[[n + 1]] + r dir[[n + 1]] ] Histogram[ Table[len[{p[RandomReal[{0, 4}]], p[RandomReal[{0, 4}]]}], {100000}], PlotRange -> All] The histogram shows a small increase close to 1, a big peak at 1 and some kind of exponential decay to Sqrt[2] (= maximum). Does anybody know how to calculate this distribution exactly? What about moving from a unit square to a random rectangle or a random === Subject: Re: Mathematica Animation Drives Me Crazy! I get behavior similar to yours (i.e., repeat evaluations) on a Windows XP system with Mathematica 7.0 Asim === Subject: Re: Mathematica Animation Drives Me Crazy! So far I've received one confirmation of this from a Windows Vista user. But for him it occurred at a much lower frequency than for me. I get repeats and 'freezes' about 90% of the time. If there are other users on Windows Vista I would certainly appreciate them trying it. I have had a number of responses from people with non-Vista operation systems who have no problem (other than the repeat final value, which I also consider to be a bug.) David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ This may be a platform dependent problem. In any case, I'm working on a 32-bit Windows Vista, Version 7. Here are some typical results of repeated Trigger activation (Trigger controls omitted) with the first form of the Trigger example: Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], Dynamic[n], Dynamic[nevals], Dynamic[nlist]}] 4,10,{0,1,1,1,2,2,2,3,3,4} 10,23,{0,1,1,1,2,2,2,3,3,3,3,4,4,4,5,6,7,7,8,8,9,10,10} 10,13,{0,1,2,3,4,5,6,7,8,9,9,10,10} 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} 10,15,{0,1,1,2,3,4,5,6,7,7,8,8,9,10,10} 1,2,{0,1} Notice that in the first and last case the animation 'froze' at n = 4 and n = 1. The first number is the last value of n, the second number is the number of values that were actually produced (it should be equal to 11) and the third item is the list of values produced, which should be {0,1,2,3,4,5,6,7,8,9,10}. I would be very thankful if users on Windows Vista could try this out. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have never ending problems with Mathematica animation since Version 6. This takes the forms: 1) Sometimes (maybe about 10% if the time) an animation will 'stick' without finishing or repeating. 2) It does not seem possible to control the actual number of points or evaluations in the animation. 3) The documentation for the control of timing and precise steps is quite poor and this may be a reflection of actual buggy animation routines. Here is an example using Trigger, which is a kind of once-through animation. I am using an integer range, 0 to 10 in steps of 1. I would therefore like to have exactly 11 evaluations. But I always get an extra evaluation at the end, and even worse I often obtain repeat evaluations for some intermediate value. The following displays the value of n, the number of evaluations, and the actual list of n values for the evaluations. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] The following uses DisplayAllSteps -> True but seems to have the same problem. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}, DisplayAllSteps -> True], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] Do other users see these kind of problems, especially repeat evaluations for some values of n? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Mathematica Animation Drives Me Crazy! > This may be a platform dependent problem. In any case, I'm working on a > 32-bit Windows Vista, Version 7. Here are some typical results of repeated Trigger activation (Trigger > controls omitted) with the first form of the Trigger example: Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, > calcnevals[] := > If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; > nlist = Append[nlist, n]]; > {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], > Dynamic[n], Dynamic[nevals], Dynamic[nlist]}] 4,10,{0,1,1,1,2,2,2,3,3,4} > 10,23,{0,1,1,1,2,2,2,3,3,3,3,4,4,4,5,6,7,7,8,8,9,10,10} > 10,13,{0,1,2,3,4,5,6,7,8,9,9,10,10} > 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} > 10,15,{0,1,1,2,3,4,5,6,7,7,8,8,9,10,10} > 1,2,{0,1} Notice that in the first and last case the animation 'froze' at n = 4 and n > = 1. The first number is the last value of n, the second number is the > number of values that were actually produced (it should be equal to 11) and > the third item is the list of values produced, which should be > {0,1,2,3,4,5,6,7,8,9,10}. I would be very thankful if users on Windows Vista could try this out. Hi David, FWIW, Mathematica 7.0 on 32-bit Windows XP Pro SP3, here is a sample of the sequences returned: 0,0,{} 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} (*...*) --Jean-Marc === Subject: Re: Mathematica Animation Drives Me Crazy! David same results with 64-bit iMac as with 32-bit Macbook. Peter 2009/1/24 David Park : > This may be a platform dependent problem. In any case, I'm working on a > 32-bit Windows Vista, Version 7. Here are some typical results of repeated Trigger activation (Trigger > controls omitted) with the first form of the Trigger example: Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, > calcnevals[] := > If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; > nlist = Append[nlist, n]]; > {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], > Dynamic[n], Dynamic[nevals], Dynamic[nlist]}] 4,10,{0,1,1,1,2,2,2,3,3,4} > 10,23,{0,1,1,1,2,2,2,3,3,3,3,4,4,4,5,6,7,7,8,8,9,10,10} > 10,13,{0,1,2,3,4,5,6,7,8,9,9,10,10} > 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} > 10,15,{0,1,1,2,3,4,5,6,7,7,8,8,9,10,10} > 1,2,{0,1} Notice that in the first and last case the animation 'froze' at n = 4 and n > = 1. The first number is the last value of n, the second number is the > number of values that were actually produced (it should be equal to 11) and > the third item is the list of values produced, which should be > {0,1,2,3,4,5,6,7,8,9,10}. I would be very thankful if users on Windows Vista could try this out. > David Park > djmpark@comcast.net > http://home.comcast.net/~djmpark/ > I have never ending problems with Mathematica animation since Version 6. > This takes the forms: 1) Sometimes (maybe about 10% if the time) an animation will 'stick' without > finishing or repeating. 2) It does not seem possible to control the actual number of points or > evaluations in the animation. 3) The documentation for the control of timing and precise steps is quite > poor and this may be a reflection of actual buggy animation routines. Here is an example using Trigger, which is a kind of once-through animation. > I am using an integer range, 0 to 10 in steps of 1. I would therefore like > to have exactly 11 evaluations. But I always get an extra evaluation at the > end, and even worse I often obtain repeat evaluations for some intermediate > value. The following displays the value of n, the number of evaluations, and > the actual list of n values for the evaluations. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] The following uses DisplayAllSteps -> True but seems to have the same > problem. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}, DisplayAllSteps -> True], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] Do other users see these kind of problems, especially repeat evaluations for > some values of n? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > === Subject: Re: Mathematica Animation Drives Me Crazy! > This may be a platform dependent problem. In any case, I'm working on a > 32-bit Windows Vista, Version 7. Here are some typical results of repeated Trigger activation (Trigger > controls omitted) with the first form of the Trigger example: Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, > calcnevals[] := > If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; > nlist = Append[nlist, n]]; > {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], > Dynamic[n], Dynamic[nevals], Dynamic[nlist]}] 4,10,{0,1,1,1,2,2,2,3,3,4} > 10,23,{0,1,1,1,2,2,2,3,3,3,3,4,4,4,5,6,7,7,8,8,9,10,10} > 10,13,{0,1,2,3,4,5,6,7,8,9,9,10,10} > 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} > 10,15,{0,1,1,2,3,4,5,6,7,7,8,8,9,10,10} > 1,2,{0,1} Notice that in the first and last case the animation 'froze' at n = 4 and n > = 1. The first number is the last value of n, the second number is the > number of values that were actually produced (it should be equal to 11) and > the third item is the list of values produced, which should be > {0,1,2,3,4,5,6,7,8,9,10}. I would be very thankful if users on Windows Vista could try this out. Here are the results of 10 consecutive trials (Mathematica 7, Windows Vista). 10,14,{0,1,2,3,4,4,4,5,6,7,8,9,10,10} 10,15,{0,1,2,3,3,4,4,4,5,6,7,8,9,10,10} 0,1,{0} 10,15,{0,1,2,3,4,5,5,5,5,6,7,8,9,10,10} 0,1,{0} 10,14,{0,1,2,3,3,4,4,5,6,7,8,9,10,10} 0,1,{0} 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} 0,1,{0} 10,14,{0,1,2,2,2,3,4,5,6,7,8,9,10,10} -- Helen Read University of Vermont === Subject: Re: Mathematica Animation Drives Me Crazy! hi David, I'm copying this to mathgroup - may be of interest, may be platform dependent issue. Peter __ I get ,10,12,{0,1,2,3,4,5,6,7,8,9,10,10}} repeatedly for both of your programs on my macbook Peter 2009/1/22 David Park : > I have never ending problems with Mathematica animation since Version 6. > This takes the forms: 1) Sometimes (maybe about 10% if the time) an animation will 'stick' without > finishing or repeating. 2) It does not seem possible to control the actual number of points or > evaluations in the animation. 3) The documentation for the control of timing and precise steps is quite > poor and this may be a reflection of actual buggy animation routines. Here is an example using Trigger, which is a kind of once-through animation. > I am using an integer range, 0 to 10 in steps of 1. I would therefore like > to have exactly 11 evaluations. But I always get an extra evaluation at the > end, and even worse I often obtain repeat evaluations for some intermediate > value. The following displays the value of n, the number of evaluations, and > the actual list of n values for the evaluations. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] The following uses DisplayAllSteps -> True but seems to have the same > problem. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}, DisplayAllSteps -> True], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] Do other users see these kind of problems, especially repeat evaluations for > some values of n? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > === Subject: Re: Which editor do you use for math This is a bit off-topic - apologies in advance. Included below is a nearly minimal file demonstrating how to use any Mac font with XeLaTeX. If you save the text below as a file named temp.tex you can produce a PDF file by typing xelatex temp.tex The magic required to use any system-installed Mac font is the fontspec package. The setmainfont command sets the default font for the document. (There are other commands for setting the default monospace font, etc.) If you want to change the font within your document, you need to use the fontspec command. Changing the size can be done by changing the value of Size=NN to another value. If you have TeXLive installed, you should be able to get documentation for the fontspec package by typing texdoc fontspec at the command line. But, I agree, it does take some sleuthing to figure this out. Jason usepackage[]{fontspec} defaultfontfeatures{Mapping=tex-text} setmainfont{Book Antiqua} begin{document} The quick brown fox jumped over the lazy dog. fontspec[SizeFeatures={{Size=16}}]{Hoefler Text} The quick brown fox jumped over the lazy dog. fontspec[SizeFeatures={{Size=18}}]{Arial Narrow} The quick brown fox jumped over the lazy dog. end{document} > My advice? Stick to Mathematica and/or Word. (Unless you're willing to > learn LaTeX from the ground up, the hard way.) I spent several hours last night sleuthing how to use Mac fonts in > LyX, > which led to using them in TeXShop, which led to indecipherable > instructions for using LyX with XeTex, which led to utter confusion. I > found a LyX document that explained and demonstrated how to do > this; > but that document explained exactly nothing and could not be typeset, > neither with LaTeX NOR XeTeX. Trying to do so popped up error messages > (like the ones mentioned below). Explanations (and ERROR messages) FREQUENTLY repeated the equivalent > of, > If you use *nix, you'll be able to figure this out. No need to > explain > it, or Make like Sherlock Holmes, and look for clues. Apparently, the developers of this stuff MAY be a lot wise-a**es who'd > rather, really, have nobody else use their code. Or, at least, they can't be bothered with meaningful documentation or > installers that do the full job. Bobby >> [...] >>> >>> LaTeX had all kinds of problems. Figures never appeared where you >>> wanted them. >> >> Thus the h! flag. Most of the GUI frontends to LaTeX now allow for >> easy specification of where you want the figures, and the degree of >> their floatiness . >> >>> Quite often they ended up bunched together at the end of >>> a chapter. You needed a kludge like the here.sty style file. Using >>> different fonts was next to impossible. LaTeX2e that appeared later >>> improved that (so I have heard). However, years later, when I >>> tried to >>> typeset my plain LaTeX based thesis once again, I couldn't get it to >>> compile with the then current 2e version. So much for compatibility. >> >> This may still be a problem. >> >>> Equations of more than average complexity easily filled up half a >>> page >>> of code rubbish and were a pain to debug. >> >> No problem with, e.g., LyX and its instant preview . >> >>> Spellchecking less than >>> basic. Try to write a multiple language peace and spellcheck that in >>> LaTeX. >> >> This is no problem now. >> >>> Virtually no picture tools. No tracked changes. No >>> collaboration tools etc etc. >> >> All of that is quite easy now. >> >>> I don't want to start a flame war. Just balancing the discussion >>> somewhat. I am well aware of many or most of the problems of Word. >>> >>> >>> >> >> Points taken! All of the desktop publishing paradigms can *really* >> be worked on. >> >> >> -- > DrMajorBob@longhorns.com > -- Dr J. McKenzie Alexander Department of Philosophy, Logic and Scientific Method London School of Economics and Political Science Houghton Street, London WC2A 2AE Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm === Subject: Re: Which editor do you use for math on the Mac I use: MacTex-2008 [ www.tug.org/mactex/ ] which includes ConTeXt, XeTeX. For creating diagrams I use: Mathematica incorporating Presentations [ home.comcast.net/~djmpark/Mathematica.html ] and export to PDF for graphics editing I use GraphicConverter [ www.lemkesoft.com/ ]. Peter 2009/1/24 Bill Rowe : > >>My advice? Stick to Mathematica and/or Word. (Unless you're willing >>to learn LaTeX from the ground up, the hard way.) > >>I spent several hours last night sleuthing how to use Mac fonts in >>LyX, which led to using them in TeXShop, which led to indecipherable >>instructions for using LyX with XeTex, which led to utter confusion. Well since LyX is neither LaTeX nor TeXShop, I can see how this > path would lead to confusion. LyX is designed to allow you to > create documents without knowing LaTeX. Usage of TeXShop > requires knowledge of LaTeX or TeX. XeTeX is a command line > utility that extends TeX to allow usage of Mac fonts. Since > TeXShop is basically an editor combined with a GUI for the Unix > tools used to convert TeX source code into the final document, > configuring TeXShop to use xetex instead of another tex tool is > relatively simple. Currently, I've no idea how to configure LyX > to make use of xetex. > >>I found a LyX document that explained and demonstrated how to do >>this; but that document explained exactly nothing and could not be >>typeset, neither with LaTeX NOR XeTeX. Trying to do so popped up >>error messages (like the ones mentioned below). > >>Explanations (and ERROR messages) FREQUENTLY repeated the equivalent >>of, If you use *nix, you'll be able to figure this out. No need to >>explain it, or Make like Sherlock Holmes, and look for clues. > >>Apparently, the developers of this stuff MAY be a lot wise-a**es >>who'd rather, really, have nobody else use their code. > >>Or, at least, they can't be bothered with meaningful documentation >>or installers that do the full job. The thing is, both TeX and LaTeX existed much earlier than > things like Word. They were created as Unix tools and still > reflect those roots. The primary installation tools are other > Unix tools. Installers that don't explicitly use the command > line are typically a GUI wrapper for lower level Unix tools. > Likewise, the main documentation for TeX are man pages and > texdoc documents accessed using the command line. Obviously, > converting this documentation to something like the online > documentation found in Word or Mathematica is quite a bit of effort. If you are to effectively make use of LaTeX you will definitely > want to get a book written about using LaTeX. Like Mathematica, > LaTeX will require quite a bit of study/usage before you will > really be comfortable using it. I believe the payoff for > learning LaTeX warrants the effort. > === Subject: Re: Which editor do you use for math If you are to effectively make use of LaTeX you will definitely > want to get a book written about using LaTeX. Like Mathematica, > LaTeX will require quite a bit of study/usage before you will > really be comfortable using it. I believe the payoff for > learning LaTeX warrants the effort. I'd just add that you might also want to acquire a copy of Knuth's original users guide for TeX, not only for getting a very readable introduction to the basic concepts of TeX itself, but even more just for the pleasure of reading or scanning it and getting a near-personal encounter with a genuine genius, as well as adding a true classic to your library. (Of course it may also make you weep, which you compare Knuth's approach to user documentation to Wolfram's current approach.) Last I looked there was one used copy of the original spiralbound paperback TeXBook for sale on amazon for $25. Given the tattered condition of my original copy, I nearly bought it. The current hardbound version seems to be retitled as Computers & Typesetting, Volume A: The TeXbook (Computers & Typesetting Series) (Hardcover) and costs a little more. I'm guessing it contains essentially the same material as the original. === Subject: mathematica's syntax is very like lisp language mathematica's syntax is very like lisp language. is there any relation between mathematica and lisp ? === Subject: Re: mathematica's syntax is very like lisp language beside the fact the the creators know LISP, not. Especial a LISP list is very different from a Mathematica List[]. Jens > mathematica's syntax is very like lisp language. is there any relation between mathematica and lisp ? === Subject: Re: mathematica's syntax is very like lisp language > mathematica's syntax is very like lisp language. is there any relation between mathematica and lisp ? Two things come to my mind: ..1 The REPL: Read-Eval-Print Loop [1]. ..2 To some extent, at the conceptual level: in Mathematica, everything is an expression. A Mathematica expression is made of a head (that can also be itself an expression) followed by zero, one, or more elements, i.e. head[element_1, element_2, ...]. AFAIR, in LISP, everything/most of the things (this must be checked since I am not sure how this is true with object oriented extension and LISP's macro mechanism) is a symbolic expression of the form (fun arg_1 arg_2 ...). (In Mathematica, *everything* is an expression is to be taken literally: input and output cells are expressions, notebooks are expressions too that can be manipulated as any other expressions.) --Jean-Marc [1] Read-eval-print loop , from Wikipedia, the free encyclopedia, http://en.wikipedia.org/wiki/REPL === Subject: Re: Length distribution of random secants on a unit square > I need to work with the length distribution of random secants (of two > random points on the perimeter) on a unit square. It's easy to > generate some random data and a histogram. I used the following code > (Mathematica 7.0): len = Norm[(First[#] - Last[#])] &; > corners = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; > dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; p[t_] := Block[{n, r}, > n = Mod[IntegerPart[t], 4]; > r = FractionalPart[t]; > corners[[n + 1]] + r dir[[n + 1]] > ] Histogram[ > Table[len[{p[RandomReal[{0, 4}]], p[RandomReal[{0, 4}]]}], {100000}], > PlotRange -> All] The histogram shows a small increase close to 1, a big peak at 1 and > some kind of exponential decay to Sqrt[2] (= maximum). Does anybody know how to calculate this distribution exactly? What > about moving from a unit square to a random rectangle or a random I don't have an analytical solution. But I have a faster way to generate the random draws: ran = Norm /@ (Subtract @@@ Partition[ RandomChoice[{{z, 0}, {1, z}, {z, 1}, {0, z}}, 2*10^5] /. z :> RandomReal[], 2]); Here's another way that's a bit slower, but it can be applied to other shapes: xcoord = Interpolation[{{0, 0}, {1, 1}, {2, 1}, {3, 0}, {4, 0}}, InterpolationOrder -> 1]; ycoord = Interpolation[{{0, 0}, {1, 0}, {2, 1}, {3, 1}, {4, 0}}, InterpolationOrder -> 1]; ran1 = Norm /@ (Subtract @@@ Partition[ {xcoord[#], ycoord[#]} & /@ RandomReal[{0, 4}, 2*10^5], 2]); --Mark === Subject: two plots in Mathemtica 7. Bug? when I execute << ComputationalGeometry`;nodes = Table[Random[], {20}, {2}]; DiagramPlot[nodes] ; PlanarGraphPlot[nodes] in Mathematica 7 I only get the latter (the Delaunay diagram), while, IIRC, Mathematica 6 showed both. I found that I could get both plots if I add a second semi-column between the plot statement. In this case they are put side by side rather than above each other, with the semi-columns between them. A bug? === Subject: Re: two plots in Mathemtica 7. Bug? > when I execute << ComputationalGeometry`;nodes = Table[Random[], {20}, {2}]; > DiagramPlot[nodes] ; PlanarGraphPlot[nodes] in Mathematica 7 I only get the latter (the Delaunay diagram), while, > IIRC, Mathematica 6 showed both. I found that I could get both plots if > I add a second semi-column between the plot statement. In this case > they are put side by side rather than above each other, with the > semi-columns between them. A bug? A semicolon suppresses graphics output, just like it suppresses text output. So the behavior of the semicolon is now more consistent no matter what it refers to. I think this is true in version 6 and newer. But your comment about the two semicolons producing side by side plots completely stumps me. I tried it on my Mac with version 7 and it too gives side-by-side (though much smaller) plots of the two planar graphs. If you just put the first DiagramPlot[] command on its own line (without the semicolon) and you get both plots. e.g. << ComputationalGeometry`; nodes = Table[Random[], {20}, {2}]; DiagramPlot[nodes] PlanarGraphPlot[nodes] -Bob === Subject: Re: two plots in Mathemtica 7. Bug? > when I execute << ComputationalGeometry`;nodes = Table[Random[], {20}, {2}]; > DiagramPlot[nodes] ; PlanarGraphPlot[nodes] in Mathematica 7 I only get the latter (the Delaunay diagram), while, This is the correct --=and expected--- behavior since Mathematica 6.0, for a ; semicolon prevent the display of results returned by expressions and graphics are no longer side-effects: graphics outputs are the result of evaluation, so they can be turn on or off as any other expressions. > IIRC, Mathematica 6 showed both. No, see above for explanation. Also, to display graphics in coupound expressons, you must use Print[]. > I found that I could get both plots if > I add a second semi-column between the plot statement. In this case > they are put side by side rather than above each other, with the > semi-columns between them. A bug? Not sure about that one. Anyway, either of below examples will display both graphs in separate output cells. << ComputationalGeometry`; nodes = Table[Random[], {20}, {2}]; DiagramPlot[nodes] PlanarGraphPlot[nodes] << ComputationalGeometry`; nodes = Table[Random[], {20}, {2}]; Print[DiagramPlot[nodes]] ; PlanarGraphPlot[nodes] --Jean-Marc === Subject: Re: Non-deterministic numerical inaccuracies in >>> >>> 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. First I should point out that the above remark was not mine. It was in a note I had at least in part quoted. That said, I neither fully agree nor disagree with it. If small machine arithmetic fuzz is bedeviling your code, you almost certainly are doing something a bit unsafe. > I think we should care about it! Lots of programs have different > behaviours depending on a real number threshold, and this behaviour > means that there is the possibility of a test flipping different ways on > different runs of a program! One has to be careful about choosing the threshold, etc. A few bits for BLAS machine arithmetic tolerance seems not unreasonable to me. > This could be a debugging nightmare, and will be in the back of people's > minds whenever anything 'strange' happens. Would it not be possible to revert to the previous, slightly less > optimal, library until (presumably) the library is fixed? David Bailey > http://www.dbaileyconsultancy.co.uk My understranding is that the library vendors do not regard it as broken, so I am not optimistic that the library itself will change. We have made some effort to align machine floats to 16 bits so this particular behavior should stabilize in a future release. I am not really competent to discuss the issues involved in going to a different library. Maybe others can address that. I can only voice my suspicion that it would be difficult, and offer dubious gain. Daniel Lichtblau Wolfram Research === Subject: Re: Mathematica Animation Drives Me Crazy! Windows Vista Ultimate 64Bit 4Gigs Version 7 The same hiccups -----Original Message----- === Subject: Mathematica Animation Drives Me Crazy! So far I've received one confirmation of this from a Windows Vista user. But for him it occurred at a much lower frequency than for me. I get repeats and 'freezes' about 90% of the time. If there are other users on Windows Vista I would certainly appreciate them trying it. I have had a number of responses from people with non-Vista operation systems who have no problem (other than the repeat final value, which I also consider to be a bug.) David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ This may be a platform dependent problem. In any case, I'm working on a 32-bit Windows Vista, Version 7. Here are some typical results of repeated Trigger activation (Trigger controls omitted) with the first form of the Trigger example: Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], Dynamic[n], Dynamic[nevals], Dynamic[nlist]}] 4,10,{0,1,1,1,2,2,2,3,3,4} 10,23,{0,1,1,1,2,2,2,3,3,3,3,4,4,4,5,6,7,7,8,8,9,10,10} 10,13,{0,1,2,3,4,5,6,7,8,9,9,10,10} 10,12,{0,1,2,3,4,5,6,7,8,9,10,10} 10,15,{0,1,1,2,3,4,5,6,7,7,8,8,9,10,10} 1,2,{0,1} Notice that in the first and last case the animation 'froze' at n = 4 and n = 1. The first number is the last value of n, the second number is the number of values that were actually produced (it should be equal to 11) and the third item is the list of values produced, which should be {0,1,2,3,4,5,6,7,8,9,10}. I would be very thankful if users on Windows Vista could try this out. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have never ending problems with Mathematica animation since Version 6. This takes the forms: 1) Sometimes (maybe about 10% if the time) an animation will 'stick' without finishing or repeating. 2) It does not seem possible to control the actual number of points or evaluations in the animation. 3) The documentation for the control of timing and precise steps is quite poor and this may be a reflection of actual buggy animation routines. Here is an example using Trigger, which is a kind of once-through animation. I am using an integer range, 0 to 10 in steps of 1. I would therefore like to have exactly 11 evaluations. But I always get an extra evaluation at the end, and even worse I often obtain repeat evaluations for some intermediate value. The following displays the value of n, the number of evaluations, and the actual list of n values for the evaluations. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] The following uses DisplayAllSteps -> True but seems to have the same problem. Module[{n = 0, nevals = 0, nlist = {}, calcnevals}, calcnevals[] := If[n == 0, nevals = 1; nlist = {n}, nevals = nevals + 1; nlist = Append[nlist, n]]; {Trigger[Dynamic[n, (n = #; calcnevals[]) &], {0, 10, 1}, DisplayAllSteps -> True], Dynamic[n], Dynamic[nevals], Dynamic[nlist]} ] Do other users see these kind of problems, especially repeat evaluations for some values of n? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: VectorPlot3D and VectorStyle In the Help for VectorPlot3D WRI uses the example: Plot a field with arbitrary three dimensional shapes: VectorPlot3D[{y, -x, z}, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, VectorPoints -> 5, PlotRange -> All, VectorStyle -> {{Graphics3D[Cylinder[{{0, 0, 0}, {1, 0, 0}}, 0.7]], Graphics3D[Cone[{{-0.5, 0, 0}, {1.5, 0, 0}}, 0.7]]}}, VectorScale -> {Automatic, Scaled[0.3]}, VectorColorFunction -> Hue] But nowhere, as far as I can find, do they explain the syntax for the VectorStyle option (other than giving two predefined types on the VectorStyle Help page.) Specially, is it possible to supply an entirely new graphic for the arrows without any remnant of the original Arrow? And, especially, is it possible to eliminate the original shaft? (I won't make any puns.) David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Frames on Density Plots in Version 7 I have the same problem (both plots missing the upper frame line) with Mathematica 7.0 under Windows XP Home SP2. Richard Hofler ________________________________ === Subject: Frames on Density Plots in Version 7 With Mathematica 7.0 under Windows XP, for me BOTH plots are missing the upper frame line but have the ticks there. > When I submitted this to support they said they couldn't reproduce the > problem. It may be platform dependent. (I'm working on Windows 32-bit > Vista.) In the following plots the upper frame line is missing but the > ticks are present. DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] In Version 6 the first one displays correctly, and the second plot doesn't > exist. This problem is easily corrected by adding an ImagePadding option, but still > it would be annoying to casual users. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ -- 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: Frames on Density Plots in Version 7 I saw the top frames missing on the same Windows XP Pro SP3, Mathematica 7.0. So this is beginning to sound like a Windows graphics driver issue. >> When I submitted this to support they said they couldn't reproduce the >> problem. It may be platform dependent. (I'm working on Windows 32-bit >> Vista.) In the following plots the upper frame line is missing but the >> ticks are present. >> >> DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] >> >> VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] >> >> In Version 6 the first one displays correctly, and the second plot doesn'= > t >> exist. >> >> This problem is easily corrected by adding an ImagePadding option, but st= > ill >> it would be annoying to casual users. >> >> David Park >> >> djmp...@comcast.net >> >> http://home.comcast.net/~djmpark/ I do not reproduceyour results with Mathematica 7.0 on > 32-bit Intel Windows XP Pro SP3 (both frames are displayed correctly, no > missing frame line). > -- 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: Frames on Density Plots in Version 7 > When I submitted this to support they said they couldn't reproduce the > problem. It may be platform dependent. (I'm working on Windows 32-bit > Vista.) In the following plots the upper frame line is missing but the > ticks are present. DensityPlot[x y, {x, 0, 1}, {y, 0, 1}] VectorDensityPlot[{Sin[x], Cos[y]}, {x, 0, 2 [Pi]}, {y, 0, 2 [Pi]}] In Version 6 the first one displays correctly, and the second plot doesn'= t > exist. This problem is easily corrected by adding an ImagePadding option, but st= ill > it would be annoying to casual users. David Park djmp...@comcast.net http://home.comcast.net/~djmpark/ On my machine (32-bit Windows XP SP3, notebook Lenovo R500) both upper frame lines are missing. === Subject: Re: Mathematica and LyX - Graphics and equations >I decided to give it a try and installed the MiKTeX Win version along >with the LyX fronted for it, since I have absolutely no experience with >LaTeX. But LyX really isn't a front end for LaTeX. LyX is a document processor that can both import and export LaTeX. That is, you don't create a document in LyX by entering LaTeX code into the window opens when you select File->New. >It's almost a week now that I'm struggling to produce anything usable >with LyX and I have to admit I have mixed feelings about it. It's >really easy to produce good quality documents with the default >settings/templates. When something however doesn't look right I feel >like my hands are tied together - usually there's no user control over >it. I'm still not giving it up though and I'd like to ask a couple of >questions about the Mathematica/LyX interaction. I can answer some of your questions from the perspective of LaTeX which I use but not LyX. >1) What is the best way to export graphics from Mathematica? I generally use PDF. But I've obtained good results with both EPS and PDF >2) How do I export the equations from Mathematica? I generally use TeXForm and simply copy and paste the result into the document I am working on. For example doing: In[3]:= f == Sum[Subscript[x, n], {n, k}] // TeXForm Out[3]//TeXForm= f= sum _n^k x_n gives a result that can be pasted directly into LaTeX document. >3) And finally could someone please provide detailed instructions of >how to setup LyX to interact directly with the Mathematica kernel so >I can have some semi live math environment. May be that way the >equations will come in the right form Given what LyX is, I doubt this is easily doable if at all. === Subject: Re: Mathematica and LyX - Graphics and equations >3) And finally could someone please provide detailed instructions of >how to setup LyX to interact directly with the Mathematica kernel so >I can have some semi live math environment. May be that way the >equations will come in the right form Given what LyX is, I doubt this is easily doable if at all. The last remark needs fact-checking. It actually works - within limits. It's a fun feature, but I don't really use it much. What you have to do to make it work depends on your platform. On Mac OS X, I first created a little script /usr/local/bin/math containing the following two lines: #!/bin/sh /Applications/Mathematica.app/Contents/MacOS/MathKernel $@ The purpose of this is simply to make the command math appear in the path visible to LyX, and point to the Mathematica Kernel (so obviously this is Mac specific, and I don't know the PC equivalent). Then whenever you have a calculation that you want to do in LyX, do the following: * Open a math environment. * Type the Mathematica expression you want to evaluate (e.g.: Sin[.2]) * Highlight the expression * While you are still in that math box, go to Edit > Math > Use Computer Algebra System > Mathematica * Magically, an equals sign and the result of the evaluation will appear in the LyX math box. In general, in particular when graphics is involved, I would just work with the Mathematica Notebook and the LyX editor side by side, and copy/paste between the two. In LyX 1.6, you can paste graphics into LyX from the clipboard. Equations in Mathematica's TeXForm can be pasted directly into LyX math environments. In the other direction, you can copy LaTeX from LyX into Mathematica as follows: * enter the desired math expression in LyX (e.g., sin alpha) * select all the _contents_ of the math box, but not the math box object itself (i.e., stop highlighting when you reach the end of the math inset). * Copy * Paste literally into a Mathematica Cell, perhaps wrapped by something like ToExpression[ sin alpha , TeXForm] (where the pasted text goes between the quotation marks) * The result can then be used in Mathematica Labels etc. Although LyX has a non-LaTeX internal file format, everything it does goes through LaTeX, and in particular all its equations can be understood by other LaTeX-aware programs. One may still ask why anyone would you use LyX instead of Mathematica to write equations. I think this has already been addressed, and it may really be a matter of taste - but it's worth pointing out that LyX has unlimited Undo and version control (there's more, but I better stop here). As for the customization of the LyX output, it's true that this isn't trivial if you don't know much LaTeX. The LyX-users mailing list would be a place to start, they are very helpful... Jens === Subject: Re: iterative method? If you've written Mathematica code and are trying to explain it, why not copy/paste it into e-mail so that we have it right??? Highlight the code, select Edit>Copy As>Plain Text and paste into e-mail. (This works for almost everything.) Asspming I've read your post properly, here's a possible solution for {a,b,c,d}={.1,.2,.3,.4}: Clear[f] f[a_, b_, c_, d_][{x_, y_}] := {(b + a x)/(c x), d x y} pairs = NestList[f[.1, .2, .3, .4], {2, 5}, 50]; Now this plots the x values: ListPlot@pairs[[All, 1]] This plots the y values: ListPlot@pairs[[All, 2]] and this plots both at once: ListPlot@Transpose@pairs Warning: if a, b, c, d are undefined or exact (but not integers), the x and y values get complicated. For instance, this is nestng only TEN deep, not 50, and I've added Simplify to each step: Clear[f] f[a_, b_, c_, d_][{x_, y_}] := Simplify /@ {(b + a x)/(c x), d x y} pairs = NestList[f[Pi, E, Log[10], Sqrt[5]], {2, 5}, 10]; Last@pairs {(2 [Pi]^10 + E^5 Log[10]^4 (5 [Pi] + Log[100]) + E [Pi]^8 ( [Pi] + Log[1000000000000000000]) + E^4 [Pi]^2 Log[ 10]^3 (20 [Pi] + Log[1000000000000000000000000000000]) + E^3 [Pi]^4 Log[ 10]^2 (21 [Pi] + 4 Log[1000000] + 2 Log[100000000] + Log[1000000000000000000000000000000]) + E^2 [Pi]^6 Log[ 10] (8 [Pi] + Log[100000000000000000000000000000000000000000000000000000000]) )/(Log[10] (2 [Pi]^9 + E^5 Log[10]^4 + E^3 [Pi]^3 Log[ 10]^2 (15 [Pi] + 4 Log[1000000] + 2 Log[100000000]) + E^4 [Pi] Log[10]^3 (10 [Pi] + Log[10000000000]) + E [Pi]^7 ( [Pi] + Log[10000000000000000]) + E^2 [Pi]^5 Log[ 10] (7 [Pi] + Log[1000000000000000000000000000000000000000000]))), (1/( Log[10]^8 Log[100])) 31250 (2 [Pi]^9 + E^5 Log[10]^4 + E^3 [Pi]^3 Log[ 10]^2 (15 [Pi] + 4 Log[1000000] + 2 Log[100000000]) + E^4 [Pi] Log[10]^3 (10 [Pi] + Log[10000000000]) + E [Pi]^7 ( [Pi] + Log[10000000000000000]) + E^2 [Pi]^5 Log[ 10] (7 [Pi] + Log[1000000000000000000000000000000000000000000]))} And here's another example: Clear[f] f[a_, b_, c_, d_][{x_, y_}] := FullSimplify /@ {(b + a x)/(c x), d x y} pairs = NestList[f[a, b, c, d], {2, 5}, 20]; Last@pairs {(a^19 (2 a + b) + 2 a^17 b (19 a + 9 b) c + 34 a^15 b^2 (9 a + 4 b) c^2 + 80 a^13 b^3 (17 a + 7 b) c^3 + 455 a^11 b^4 (8 a + 3 b) c^4 + 2002 a^9 b^5 (3 a + b) c^5 + 858 a^7 b^6 (7 a + 2 b) c^6 + 264 a^5 b^7 (13 a + 3 b) c^7 + 165 a^3 b^8 (6 a + b) c^8 + 10 a b^9 (11 a + b) c^9 + 2 b^10 c^10)/(c (a^18 (2 a + b) + a^16 b (36 a + 17 b) c + 8 a^14 b^2 (34 a + 15 b) c^2 + 35 a^12 b^3 (32 a + 13 b) c^3 + 91 a^10 b^4 (30 a + 11 b) c^4 + 143 a^8 b^5 (28 a + 9 b) c^5 + 132 a^6 b^6 (26 a + 7 b) c^6 + 66 a^4 b^7 (24 a + 5 b) c^7 + 15 a^2 b^8 (22 a + 3 b) c^8 + b^9 (20 a + b) c^9)), (1/(c^19)) 5 (a^18 (2 a + b) + a^16 b (36 a + 17 b) c + 8 a^14 b^2 (34 a + 15 b) c^2 + 35 a^12 b^3 (32 a + 13 b) c^3 + 91 a^10 b^4 (30 a + 11 b) c^4 + 143 a^8 b^5 (28 a + 9 b) c^5 + 132 a^6 b^6 (26 a + 7 b) c^6 + 66 a^4 b^7 (24 a + 5 b) c^7 + 15 a^2 b^8 (22 a + 3 b) c^8 + b^9 (20 a + b) c^9) d^20} Bobby > How to find x_(n+1)=(a*x_n+b*y_n)/c*x_n , y_(n+1)=d*x_n*y_n using > mathematica? > I want to find a list of x and y when n=1,2,...,50 > so I defined the function as f[{x_,y_}]:={a*x_n+b*y_n)/c*x_n,d*x_n*y_... > } > and then use the function NestList[f,{2,5},50] with initial value of x > is 2 and y is 5 > with this, I got the list of 50 values of (x,y). > The problem is I want to plot graphs of x against n and y against n, n > from 1 to 50 because I want to see what happened if n goes to infinity. > But if use the method I just mentioned, I can only plot x against y. > So do anyone have a clever method?? > Btw...a,b,c and d are constants and given and x_n is supposed to be x > (subscript n)...same case with x_(n+1) and the others > -- DrMajorBob@longhorns.com === Subject: Re: Length distribution of random secants on a unit When the two points lie on the same side (1/4 of the time) With[{d = RandomReal[]}, Show[ RegionPlot[Tooltip[Abs[x1 - x2] <= d], {x1, 0, 1}, {x2, 0, 1}], Plot[{x1 - d, d + x1}, {x1, 0, 1}, PlotStyle -> {Darker[Blue], Red}, PlotRange -> {0, 1}]]] Integrating over the valid region to obtain the CDF Assuming[{0 <= d <= 1}, FullSimplify[Integrate[1, {x, 0, 1}, {y, Max[0, x - d], Min[1, d + x]}]]] Piecewise[{{3/4, 2*d == 1}, {1, d == 1}, {(-(-2 + d))*d, 0 < d < 1/2 || 1/2 < d < 1}}, 0] The CDF for this case is then dist1CDF[d_] = Piecewise[{{1, d >= 1}, {((2 - d))*d, 0 < d < 1}}, 0] Piecewise[{{1, d >= 1}, {(2 - d)*d, 0 < d < 1}}, 0] Similarly, when the two points lie on adjacent sides (1/2 of the time) With[{d = Sqrt[2]*RandomReal[]}, Show[ RegionPlot[Tooltip[Sqrt[x^2 + y^2] < d], {x, 0, 1}, {y, 0, 1}], Plot[Sqrt[d^2 - x^2], {x, 0, 1}, PlotStyle -> Red, PlotRange -> {0, 1}] ]] dist2CDF[d_] = FullSimplify[Piecewise[{ {1, d >= Sqrt[2]}, {Integrate[1, {x, 0, d}, {y, 0, Sqrt[d^2 - x^2]}, Assumptions -> {0 < d <= 1}], 0 < d <= 1}, {Integrate[1, {x, 0, 1}, {y, 0, Min[1, Sqrt[d^2 - x^2]]}, Assumptions -> {1 < d < Sqrt[2]}], 1 < d < Sqrt[2]}}]] Piecewise[{{1, d >= Sqrt[2]}, {(d^2*Pi)/4, Inequality[0, Less, d, LessEqual, 1]}, {Sqrt[-1 + d^2] + (1/2)*d^2*(ArcCsc[d] - ArcCsc[d/Sqrt[-1 + d^2]]), 1 < d < Sqrt[2]}}, 0] When the two points lie on opposite sides (1/4 of the time) With[{d = (Sqrt[2] - 1)*RandomReal[] + 1}, Show[ RegionPlot[Tooltip[Sqrt[(x2 - x1)^2 + 1] < d], {x1, 0, 1}, {x2, 0, 1}], Plot[{x1 - Sqrt[d^2 - 1], Sqrt[d^2 - 1] + x1}, {x1, 0, 1}, PlotStyle -> {Darker[Blue], Red}, PlotRange -> {0, 1}]]] Assuming[{1 <= d <= Sqrt[2]}, FullSimplify[Integrate[1, {x1, 0, 1}, {x2, Max[0, x1 - Sqrt[d^2 - 1]], Min[1, Sqrt[d^2 - 1] + x1]}]]] Piecewise[{{3/4, 2*d == Sqrt[5]}, {1, d == Sqrt[2]}, {1 - d^2 + 2*Sqrt[-1 + d^2], 1 < d < Sqrt[5]/2 || Sqrt[5]/2 < d < Sqrt[2]}}, 0] dist3CDF[d_] = Piecewise[{ {1, d >= Sqrt[2]}, {1 - d^2 + 2*Sqrt[-1 + d^2], 1 < d < Sqrt[2]}}] Piecewise[{{1, d >= Sqrt[2]}, {1 - d^2 + 2*Sqrt[-1 + d^2], 1 < d < Sqrt[2]}}, 0] The CDF for the distribution is then distCDF[d_] = FullSimplify[PiecewiseExpand[ dist1CDF[d]/4 + dist2CDF[d]/2 + dist3CDF[d]/4]] Piecewise[{{1, d >= Sqrt[2]}, {(2 + Pi)/8, d == 1}, {(1/8)*d*(4 + d*(-2 + Pi)), 0 < d < 1}, {1/2 + Sqrt[-1 + d^2] + (1/4)*d^2*(-1 + ArcCsc[d] - ArcCsc[d/Sqrt[-1 + d^2]]), 1 < d < Sqrt[2]}}, 0] Comparing with the experimental data len = Norm[(First[#] - Last[#])] &; corners = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; p[t_] := Block[{n, r}, n = Mod[IntegerPart[t], 4]; r = FractionalPart[t]; corners[[n + 1]] + r dir[[n + 1]]] Show[Histogram[Table[len[{p[RandomReal[{0, 4}]], p[RandomReal[{0, 4}]]}], {100000}], Automatic, ProbabilityDensity ], Plot[distPDF[d], {d, 0, Sqrt[2]}, PlotStyle -> {AbsoluteThickness[2], Red}, PlotRange -> {0, 2.4}]] Bob Hanlon I need to work with the length distribution of random secants (of two random points on the perimeter) on a unit square. It's easy to generate some random data and a histogram. I used the following code (Mathematica 7.0): len = Norm[(First[#] - Last[#])] &; corners = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; p[t_] := Block[{n, r}, n = Mod[IntegerPart[t], 4]; r = FractionalPart[t]; corners[[n + 1]] + r dir[[n + 1]] ] Histogram[ Table[len[{p[RandomReal[{0, 4}]], p[RandomReal[{0, 4}]]}], {100000}], PlotRange -> All] The histogram shows a small increase close to 1, a big peak at 1 and some kind of exponential decay to Sqrt[2] (= maximum). Does anybody know how to calculate this distribution exactly? What about moving from a unit square to a random rectangle or a random === >Although Mathematica 7 is a very powerful peace of software [...] Hi to everybody (recursively) I want ask a related wolfram softwares question Due to next job opportunities offered to my brother, we are looking for best (visual wysiwyg is better) software to writing math (and physics) books. tried yesterday latest Publicon release http://www.wolfram.com/products/publicon/index.html but not very impressed. Knows anyone a better software, or how combining LaTeX typesetting and hopefully enter formulas in visual mode? What kind of software are using you? It seems that texmacs is a powerfull wysiwyg eitor, anyone use? === There is a program called TeXmacs, which blends elements of Emacs and TeX: http://www.texmacs.org/ I've played around with it in the past, but never considered it for any serious use. I found the documentation to be lacking, and it has a peculiar file format and imperfect TeX/LaTeX compatibility ÷ so if a project got corrupted (or if development stopped on the program), you'd be out of luck. Besides, computers are so fast these days that the the time it takes to run a document through LaTeX and refresh the PDF (or postscript) display are negligible, anyway. Jason >> It seems that texmacs is a powerfull wysiwyg eitor, anyone >> use? Do you perhaps mean TeXShop, as part of the MacTeX distribution on the > TeX Users Group CD? > -- Dr J. McKenzie Alexander Department of Philosophy, Logic and Scientific Method London School of Economics and Political Science Houghton Street, London WC2A 2AE Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm === > hopefully enter formulas in visual mode? You know, you don't have to use TeX for very long before you'll find you can read mathematical expressions right from the TeX source file, just as if they were already translated into mathematical notation, and also also enter them into the source file (compose them) fluently straight from the keyboard, as if you were writing them out. Just as a trivial example, you can read sqrt{ x^2 over alpha + beta^3} just as you'd read the corresponding math, and type it also, with hands on keyboard, no clicking and dragging each item with the mouse. Working with more complex structures soon becomes equally easy. > It seems that texmacs is a powerfull wysiwyg eitor, anyone > use? Do you perhaps mean TeXShop, as part of the MacTeX distribution on the TeX Users Group CD? === > It seems that texmacs is a powerfull wysiwyg eitor, anyone > use? Do you perhaps mean TeXShop, as part of the MacTeX distribution on the > TeX Users Group CD? GNU TeXmacs [1] exists for real but the macs ending does not stand for Mac but for macros :-) GNU TeXmacs is a free wysiwyw (what you see is what you want) editing platform with special features for scientists. [...] The software includes a text editor with support for mathematical formulas, a small technical picture editor and a tool for making presentations from a laptop. Moreover, TeXmacs can be used as an interface for many external systems for computer algebra, numerical analysis, statistics, etc. [...] TeXmacs runs on all major Unix platforms and Windows. Documents can be saved in TeXmacs, Xml or Scheme format and printed as Postscript or Pdf files. Converters exist for TeX/LaTeX and Html/Mathml. [1] --Jean-Marc [1] GNU TeXmacs , http://www.texmacs.org/ === > I have been using Adobe FrameMaker for this purpose for years. I thought it > worth mentioning since no one else has yet done so. FrameMaker provides the conveniences of a word processor type environment > (WYSIWYG, automatic numbering of references, cross referencing for figures, > equation numbers, templates for multicolumn camera-ready papers and other > report formats, etc.) that I find useful when writing a paper. It has its > own equation editor, so I don't think you could cut and paste directly from > Mathematica--though I don't know if that is possible with the alternatives > either. I have never had need for TeX since I don't publish papers (I'm a full time Senior Lecturer with a heavy teaching load; research is not part of my job). For many years, I've used MS Word with a rather old version of MathType for writing quizzes, tests, etc. But Word 2007 understands MathML, so it's now possible to copy and paste directly from Mathematica into Word, and then edit if needed using Word's Equation tools. The results are quite nice, and I'll probably ditch MathType entirely and go with the Mathematica -> Word route, which I find easier than putting in integrals (etc.) directly in Word. -- Helen Read University of Vermont === Subject: Re: Length distribution of random secants on a unit I did not copy the definition of distPDF distPDF[d_] = FullSimplify[D[distCDF[d], d]] Bob Hanlon When the two points lie on the same side (1/4 of the time) With[{d = RandomReal[]}, Show[ RegionPlot[Tooltip[Abs[x1 - x2] <= d], {x1, 0, 1}, {x2, 0, 1}], Plot[{x1 - d, d + x1}, {x1, 0, 1}, PlotStyle -> {Darker[Blue], Red}, PlotRange -> {0, 1}]]] Integrating over the valid region to obtain the CDF Assuming[{0 <= d <= 1}, FullSimplify[Integrate[1, {x, 0, 1}, {y, Max[0, x - d], Min[1, d + x]}]]] Piecewise[{{3/4, 2*d == 1}, {1, d == 1}, {(-(-2 + d))*d, 0 < d < 1/2 || 1/2 < d < 1}}, 0] The CDF for this case is then dist1CDF[d_] = Piecewise[{{1, d >= 1}, {((2 - d))*d, 0 < d < 1}}, 0] Piecewise[{{1, d >= 1}, {(2 - d)*d, 0 < d < 1}}, 0] Similarly, when the two points lie on adjacent sides (1/2 of the time) With[{d = Sqrt[2]*RandomReal[]}, Show[ RegionPlot[Tooltip[Sqrt[x^2 + y^2] < d], {x, 0, 1}, {y, 0, 1}], Plot[Sqrt[d^2 - x^2], {x, 0, 1}, PlotStyle -> Red, PlotRange -> {0, 1}] ]] dist2CDF[d_] = FullSimplify[Piecewise[{ {1, d >= Sqrt[2]}, {Integrate[1, {x, 0, d}, {y, 0, Sqrt[d^2 - x^2]}, Assumptions -> {0 < d <= 1}], 0 < d <= 1}, {Integrate[1, {x, 0, 1}, {y, 0, Min[1, Sqrt[d^2 - x^2]]}, Assumptions -> {1 < d < Sqrt[2]}], 1 < d < Sqrt[2]}}]] Piecewise[{{1, d >= Sqrt[2]}, {(d^2*Pi)/4, Inequality[0, Less, d, LessEqual, 1]}, {Sqrt[-1 + d^2] + (1/2)*d^2*(ArcCsc[d] - ArcCsc[d/Sqrt[-1 + d^2]]), 1 < d < Sqrt[2]}}, 0] When the two points lie on opposite sides (1/4 of the time) With[{d = (Sqrt[2] - 1)*RandomReal[] + 1}, Show[ RegionPlot[Tooltip[Sqrt[(x2 - x1)^2 + 1] < d], {x1, 0, 1}, {x2, 0, 1}], Plot[{x1 - Sqrt[d^2 - 1], Sqrt[d^2 - 1] + x1}, {x1, 0, 1}, PlotStyle -> {Darker[Blue], Red}, PlotRange -> {0, 1}]]] Assuming[{1 <= d <= Sqrt[2]}, FullSimplify[Integrate[1, {x1, 0, 1}, {x2, Max[0, x1 - Sqrt[d^2 - 1]], Min[1, Sqrt[d^2 - 1] + x1]}]]] Piecewise[{{3/4, 2*d == Sqrt[5]}, {1, d == Sqrt[2]}, {1 - d^2 + 2*Sqrt[-1 + d^2], 1 < d < Sqrt[5]/2 || Sqrt[5]/2 < d < Sqrt[2]}}, 0] dist3CDF[d_] = Piecewise[{ {1, d >= Sqrt[2]}, {1 - d^2 + 2*Sqrt[-1 + d^2], 1 < d < Sqrt[2]}}] Piecewise[{{1, d >= Sqrt[2]}, {1 - d^2 + 2*Sqrt[-1 + d^2], 1 < d < Sqrt[2]}}, 0] The CDF for the distribution is then distCDF[d_] = FullSimplify[PiecewiseExpand[ dist1CDF[d]/4 + dist2CDF[d]/2 + dist3CDF[d]/4]] Piecewise[{{1, d >= Sqrt[2]}, {(2 + Pi)/8, d == 1}, {(1/8)*d*(4 + d*(-2 + Pi)), 0 < d < 1}, {1/2 + Sqrt[-1 + d^2] + (1/4)*d^2*(-1 + ArcCsc[d] - ArcCsc[d/Sqrt[-1 + d^2]]), 1 < d < Sqrt[2]}}, 0] Comparing with the experimental data len = Norm[(First[#] - Last[#])] &; corners = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; p[t_] := Block[{n, r}, n = Mod[IntegerPart[t], 4]; r = FractionalPart[t]; corners[[n + 1]] + r dir[[n + 1]]] Show[Histogram[Table[len[{p[RandomReal[{0, 4}]], p[RandomReal[{0, 4}]]}], {100000}], Automatic, ProbabilityDensity ], Plot[distPDF[d], {d, 0, Sqrt[2]}, PlotStyle -> {AbsoluteThickness[2], Red}, PlotRange -> {0, 2.4}]] Bob Hanlon I need to work with the length distribution of random secants (of two random points on the perimeter) on a unit square. It's easy to generate some random data and a histogram. I used the following code (Mathematica 7.0): len = Norm[(First[#] - Last[#])] &; corners = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; p[t_] := Block[{n, r}, n = Mod[IntegerPart[t], 4]; r = FractionalPart[t]; corners[[n + 1]] + r dir[[n + 1]] ] Histogram[ Table[len[{p[RandomReal[{0, 4}]], p[RandomReal[{0, 4}]]}], {100000}], PlotRange -> All] The histogram shows a small increase close to 1, a big peak at 1 and some kind of exponential decay to Sqrt[2] (= maximum). Does anybody know how to calculate this distribution exactly? What about moving from a unit square to a random rectangle or a random -- Bob Hanlon === Subject: Re: iterative method? > How to find x_(n+1)=(a*x_n+b*y_n)/c*x_n , y_(n+1)=d*x_n*y_n using > mathematica? > I want to find a list of x and y when n=1,2,...,50 > so I defined the function as f[{x_,y_}]:={a*x_n+b*y_n)/c*x_n,d*x_n*y_... } > and then use the function NestList[f,{2,5},50] with initial value of x is 2 > and y is 5 > with this, I got the list of 50 values of (x,y). > The problem is I want to plot graphs of x against n and y against n, n from 1 > to 50 because I want to see what happened if n goes to infinity. But if use > the method I just mentioned, I can only plot x against y. > So do anyone have a clever method?? > Btw...a,b,c and d are constants and given and x_n is supposed to be x > (subscript n)...same case with x_(n+1) and the others You could use recursive definitions for x_n and y_n. For instance, ClearAll[x, y]; x[1] = 2; y[1] = 5; x[n_Integer /; n > 1] := x[n] = (a*x[n - 1] + b*y[n - 1])/(c*x[n - 1]) y[n_Integer /; n > 1] := y[n] = d*x[n - 1]*y[n - 1] Block[{a = 2, b = 3, c = 5, d = 7}, Print[Table[{x[n], y[n]}, {n, 1, 5}]]; Print[ListLogPlot[Table[{n, x[n]}, {n, 1, 30}], Filling -> Bottom]]; Print[ListLogPlot[Table[{n, y[n]}, {n, 1, 30}], Filling -> Bottom]]; ] --Jean-Marc === Subject: Re: iterative method? a = .2; b = .1; c = .9; d = .49; n=10; (* reduced from 50 for example *) initial={2,5}; f[{x_, y_}] := {(a*x + b*y)/c*x, d*x*y} data = NestList[f, initial, n]; ListLinePlot[Transpose[data]] Bob Hanlon How to find x_(n+1)=(a*x_n+b*y_n)/c*x_n , y_(n+1)=d*x_n*y_n using mathematica? I want to find a list of x and y when n=1,2,...,50 so I defined the function as f[{x_,y_}]:={a*x_n+b*y_n)/c*x_n,d*x_n*y_... } and then use the function NestList[f,{2,5},50] with initial value of x is 2 and y is 5 with this, I got the list of 50 values of (x,y). The problem is I want to plot graphs of x against n and y against n, n from 1 to 50 because I want to see what happened if n goes to infinity. But if use the method I just mentioned, I can only plot x against y. So do anyone have a clever method?? Btw...a,b,c and d are constants and given and x_n is supposed to be x (subscript n)...same case with x_(n+1) and the others === Subject: Re: Weirdness from double integrals? > I'm new to Mathematica 7 (fiddling with a trial version) and I've bumped > into something that's confusing me. Just to make sure I understand Mathematica, I'm playing with finding the > gravitational field around extended objects using integration. So far > I've had no problem (e.g., lines, rings, planes, even Newton's shell > theorem popped out easily enough), but I'm getting something that's > confusing about double definite integration the Integrate that's leaving > me puzzled. Here's the (cleaned-up) transcript from math: In[1]:= p = {0, 0, h} Out[1]= {0, 0, h} In[2]:= s = {x, y, 0} Out[2]= {x, y, 0} In[3]:= q = p - s Out[3]= {-x, -y, h} In[4]:= dm = rho (* dx dy *) Out[4]= rho In[5]:= integrand = -G * dm * q/(q.q)^(3/2) G rho x G rho y G h rho > Out[5]= {-----------------, -----------------, -(-----------------)} > 2 2 2 3/2 2 2 2 3/2 2 2 2 3/2 > (h + x + y ) (h + x + y ) (h + x + y ) In[7]:= Integrate[integrand, {x, -x0, x0}, {y, -y0, y0}] Out[7]= {0, 0, 0} In[9]:= Integrate[Integrate[integrand, {x, -x0, x0}, Assumptions -> x0 0 && h > 0], {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] x0 y0 > Out[9]= {0, 0, -2 G rho (Pi - 2 ArcCot[----------------------])} > 2 2 2 > h Sqrt[h + x0 + y0 ] It would seem to me, less assumptions, that Out[7] and Out[9] should be > the same, but Out[7] is clearly wrong (read: not what I expected :-) > -- while the x and y components of the integration are zero by symmetry, > the z component clearly should not be. Out[9] looks correct, but I > thought these would have been the same computation; converting In[7] to > traditional form in the front end appears to confirm my understanding > that it does indeed represent a double definite integral over the > integrand. So what is there about doing double definite integrals with Integrate > that I'm missing? Why aren't these computations the same? > -- > Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ > San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis > He who can, does. He who cannot, teaches. > -- George Bernard Shaw > There are many subtleties to this. First, if you do an explicit multiple integral (that is, using ont Integrate rather than iterating several of them), then the GenerateConditions option is only used for the last integration. This is documented but certainly constitutes fine print . For the GenerateConditions->False behavior of prior integrals, it is common that they might give a spurious zero due to splitting ranges and making conflicting hidden assumptions on parameters that cause results to be not everywhere applicable. One possible way around might be to set GenerateConditions->True so that it will be in effect for all levels of the integration. Integrate[integrand[[3]], {x, -x0, x0}, {y, -y0, y0}, GenerateConditions -> True] Problem now is Mathematica 7 claims this diverges. I need to look into this more closely, but offhand I have to say this looks like a bug in convergence testing. As you have found, best is to give applicable assumptions. This variant gives a useful result. Integrate[integrand[[3]], {x, -x0, x0}, {y, -y0, y0}, Assumptions -> {x0 > 0, y0 > 0, h > 0] If instead I only specify Element[h, Reals] I still get what is perhaps a valid result, but longer and expressed in terms of complex logs; I think Daniel Lichtblau Wolfram Research === Subject: Re: Weirdness from double integrals? > There are many subtleties to this. First, if you do an explicit multiple > integral (that is, using ont Integrate rather than iterating several of > them), then the GenerateConditions option is only used for the last > integration. This is documented but certainly constitutes fine print . > For the GenerateConditions->False behavior of prior integrals, it is > common that they might give a spurious zero due to splitting ranges and > making conflicting hidden assumptions on parameters that cause results to > be not everywhere applicable. One possible way around might be to set GenerateConditions->True so that > it will be in effect for all levels of the integration. Integrate[integrand[[3]], {x, -x0, x0}, {y, -y0, y0}, > GenerateConditions -> True] Problem now is Mathematica 7 claims this diverges. I need to look into > this more closely, but offhand I have to say this looks like a bug in > convergence testing. Okay, so there _is_ something goofy going on here. > As you have found, best is to give applicable assumptions. This variant > gives a useful result. -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis Only love is worth the risk -- Oleta Adams === Subject: Re: Weirdness from double integrals? > I'm new to Mathematica 7 (fiddling with a trial version) and I've bumped > into something that's confusing me. Just to make sure I understand Mathematica, I'm playing with finding the > gravitational field around extended objects using integration. So far > I've had no problem (e.g., lines, rings, planes, even Newton's shell > theorem popped out easily enough), but I'm getting something that's > confusing about double definite integration the Integrate that's leaving > me puzzled. Here's the (cleaned-up) transcript from math: In[1]:= p = {0, 0, h} Out[1]= {0, 0, h} In[2]:= s = {x, y, 0} Out[2]= {x, y, 0} In[3]:= q = p - s Out[3]= {-x, -y, h} In[4]:= dm = rho (* dx dy *) Out[4]= rho In[5]:= integrand = -G * dm * q/(q.q)^(3/2) G rho x G rho y G h rho > Out[5]= {-----------------, -----------------, -(-----------------)} > 2 2 2 3/2 2 2 2 3/2 2 2 2 3/2 > (h + x + y ) (h + x + y ) (h + x + y ) In[7]:= Integrate[integrand, {x, -x0, x0}, {y, -y0, y0}] Out[7]= {0, 0, 0} In[9]:= Integrate[Integrate[integrand, {x, -x0, x0}, Assumptions -> x0 0 && h > 0], {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] x0 y0 > Out[9]= {0, 0, -2 G rho (Pi - 2 ArcCot[----------------------])} > 2 2 2 > h Sqrt[h + x0 + y0 ] It would seem to me, less assumptions, that Out[7] and Out[9] should be > the same, but Out[7] is clearly wrong (read: not what I expected :-) > -- while the x and y components of the integration are zero by symmetry, > the z component clearly should not be. Out[9] looks correct, but I > thought these would have been the same computation; converting In[7] to > traditional form in the front end appears to confirm my understanding > that it does indeed represent a double definite integral over the integrand. So what is there about doing double definite integrals with Integrate > that I'm missing? Why aren't these computations the same? > Several things might occur here. First, platform/system dependency since on my system the results are identical. Second, to get consistent results, you should apply the same assumptions to each computation. Third, keep in mind that Mathematica has its own way to do things and in the case of multiple integration the leftmost variable written in the Integrate command is indeed the outermost integration variable in the mathematical expression. In other words, In[7] integrates first for y from -y0 to y0, then for x from -x0 to x0. To get the same result as in In[9], you must write Integrate[integrand, {y, -y0, y0}, {x, -x0, x0}] Having said that, here is what I got on my system: In[1]:= p = {0, 0, h} Out[1]= {0, 0, h} In[2]:= s = {x, y, 0} Out[2]= {x, y, 0} In[3]:= q = p - s Out[3]= {-x, -y, h} In[4]:= dm = rho Out[4]= rho In[5]:= integrand = -G*dm*q/(q.q)^(3/2) Out[5]= G rho x G rho y G h rho {-----------------, -----------------, -(-----------------)} 2 2 2 3/2 2 2 2 3/2 2 2 2 3/2 (h + x + y ) (h + x + y ) (h + x + y ) In[6]:= Integrate[integrand, {x, -x0, x0}, {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] Out[6]= x0 y0 {0, 0, -4 G rho ArcTan[----------------------]} 2 2 2 h Sqrt[h + x0 + y0 ] In[7]:= Integrate[integrand, {y, -y0, y0}, {x, -x0, x0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] Out[7]= x0 y0 {0, 0, -2 G rho (Pi - 2 ArcCot[----------------------])} 2 2 2 h Sqrt[h + x0 + y0 ] In[8]:= Integrate[ Integrate[integrand, {x, -x0, x0}, Assumptions -> x0 > 0 && h > 0], {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] Out[8]= x0 y0 {0, 0, -2 G rho (Pi - 2 ArcCot[----------------------])} 2 2 2 h Sqrt[h + x0 + y0 ] In[9]:= $Version Out[9]= 6.0 for Mac OS X x86 (64-bit) (May 21, 2008) --Jean-Marc === Subject: Re: NestList > How to find x_(n+1)=(a*x_n+b*y_n)/c*x_n , y_(n+1)=d*x_n*y_n? > I want to find a list of x and y when n=1,2,...,50 > so I defined the function as f[{x_,y_}]:={a*x_n+b*y_n)/c*x_n,d*x_n*y_... } > and then use the function NestList[f,{2,5},50] with initial value of x is 2 > and y is 5 > with this, I got the list of 50 values of (x,y). > The problem is I want to plot graphs of x against n and y against n, n from 1 > to 50 because I want to see what happened if n goes to infinity. But if use > the method I just mentioned, I can only plot x against y. > So do anyone have a clever method?? > Btw...a,b,c and d are constants and given and x_n is supposed to be x > (subscript n)...same case with x_(n+1) and the others Why not using recursive definitions? For instance, ClearAll[x, y]; x[1] = 2; y[1] = 5; x[n_Integer /; n > 1] := x[n] = (a*x[n - 1] + b*y[n - 1])/(c*x[n - 1]) y[n_Integer /; n > 1] := y[n] = d*x[n - 1]*y[n - 1] Block[{a = 2, b = 3, c = 5, d = 7}, Print[Table[{x[n], y[n]}, {n, 1, 5}]]; Print[ListLogPlot[Table[{n, x[n]}, {n, 1, 30}], Filling -> Bottom]]; Print[ListLogPlot[Table[{n, y[n]}, {n, 1, 30}], Filling -> Bottom]]; ] --Jean-Marc === Subject: Re: NestList You got the hard bit already; now, with x={x_1,...x_50}, y={y_1,...,y_50} : either ListPlot[{x,y},Joined->True] or xdata=Transpose[{Range[50],x}] ydata=Transpose[{Range[50],y}] ListPlot[{xdata,ydata},Joined->True] -Francesco > How to find x_(n+1)=(a*x_n+b*y_n)/c*x_n , y_(n+1)=d*x_n*y_n? > I want to find a list of x and y when n=1,2,...,50 > so I defined the function as f[{x_,y_}]:={a*x_n+b*y_n)/c*x_n,d*x_n*y_... } > and then use the function NestList[f,{2,5},50] with initial value of x is 2 and y is 5 > with this, I got the list of 50 values of (x,y). > The problem is I want to plot graphs of x against n and y against n, n from 1 to 50 because I want to see what happened if n goes to infinity. But if use the method I just mentioned, I can only plot x against y. > So do anyone have a clever method?? > Btw...a,b,c and d are constants and given and x_n is supposed to be x (subscript n)...same case with x_(n+1) and the others > === Subject: Re: Weirdness from double integrals? p = {0, 0, h}; s = {x, y, 0}; q = p - s; dm = rho; integrand = -G*dm*q/(q.q)^(3/2); They give identical results when both have the same assumptions Integrate[integrand, {x, -x0, x0}, {y, -y0, y0}, Integrate[Integrate[integrand, {x, -x0, x0}, Assumptions -> x0 > 0 && h > 0], {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] True Bob Hanlon I'm new to Mathematica 7 (fiddling with a trial version) and I've bumped into something that's confusing me. Just to make sure I understand Mathematica, I'm playing with finding the gravitational field around extended objects using integration. So far I've had no problem (e.g., lines, rings, planes, even Newton's shell theorem popped out easily enough), but I'm getting something that's confusing about double definite integration the Integrate that's leaving me puzzled. Here's the (cleaned-up) transcript from math: In[1]:= p = {0, 0, h} Out[1]= {0, 0, h} In[2]:= s = {x, y, 0} Out[2]= {x, y, 0} In[3]:= q = p - s Out[3]= {-x, -y, h} In[4]:= dm = rho (* dx dy *) Out[4]= rho In[5]:= integrand = -G * dm * q/(q.q)^(3/2) G rho x G rho y G h rho Out[5]= {-----------------, -----------------, -(-----------------)} 2 2 2 3/2 2 2 2 3/2 2 2 2 3/2 (h + x + y ) (h + x + y ) (h + x + y ) In[7]:= Integrate[integrand, {x, -x0, x0}, {y, -y0, y0}] Out[7]= {0, 0, 0} In[9]:= Integrate[Integrate[integrand, {x, -x0, x0}, Assumptions -> x0 > 0 && h > 0], {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] x0 y0 Out[9]= {0, 0, -2 G rho (Pi - 2 ArcCot[----------------------])} 2 2 2 h Sqrt[h + x0 + y0 ] It would seem to me, less assumptions, that Out[7] and Out[9] should be the same, but Out[7] is clearly wrong (read: not what I expected :-) -- while the x and y components of the integration are zero by symmetry, the z component clearly should not be. Out[9] looks correct, but I thought these would have been the same computation; converting In[7] to traditional form in the front end appears to confirm my understanding that it does indeed represent a double definite integral over the integrand. So what is there about doing double definite integrals with Integrate that I'm missing? Why aren't these computations the same? -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis He who can, does. He who cannot, teaches. -- George Bernard Shaw === === === Subject: Partial derviatives in mathematica Hi all, i got thi Newton-Raphson mathematica code: Code: F[{x_, y_}] = {f1[{x, y}], f2[{x, y}]}; jacobian[{x_, y_}] = Transpose[{ [PartialD]x F[{x, y}], [PartialD]y F [{x, y}]}]; MatrixForm[jacobian[{x, y}]]; NewtonSystem[X0_, max_] := Module[{}, n = 2; k = 0; Dp = {0, 0}; P0 = X0; F0 = F[P0]; Print[ F[ , P0, ]= , N[F0, 3]]; P1 = P0; F1 = F0; While[k < max, k = k + 1; P0 = P1; F0 = F1; J0 = jacobian[P0]; det = Det[J0]; If[det == 0, Dp = {0, 0}, Dp = Inverse[J0].F0]; P1 = P0 - Dp; F1 = F[P1]; Print[ F[ , P1, ]= , N[F1, 3]];];]; where f1[x, y] and f2[x, y] are defined in this way Code: f1[{x_, y_}] = n/x - Sum[y*Exp[-y*A*t[i]]*T[i+1], {i, 0, n-1}]; f2[{x_, y_}] = n/y - Sum[A*t[i], {i, 0, n-1}] - Sum[x*Exp[-y*A*t[i]]*T [i+1], {i, 0, n-1}] + Sum[y*x*A*t[i]*Exp[-y*A*t[i]]*T[i+1], {i, 0, n-1}]; T[i] e t[i] are functions defined point-by-point (from T[1] to T[50] and from t[0] to t[49]) with this syntax: Code: t[0] = *un certo numero*; t[1] = *un altro numero*; t[2] = *ancora un altro numero*; ... T[1] = *numero*; T[2] = *altro numero* ... I got an error on the second line Code: jacobian[{x_, y_}] = Transpose[{ [PartialD]x F[{x, y}], [PartialD]y F [{x, y}]}]; Mathematica's kernel warns me with this message when i try to insert it: Code: Syntax::sntxf: jacobian[{x_, y_}] = Transpose[{ cannot be followed by [PartialD]x F[{x, y}], [PartialD]y F[{x, y}]}]; . This line should define a 2-variables function named jacobian, that is a jacobian matrix. I'm not a Mathematica-guru, but the code should work anyway. What's wrong there? f1 and f2 seem well defined (i.e., when i write them Mathematica doesn't say nothing bad): === Subject: Re: Partial derviatives in mathematica > jacobian[{x_, y_}] = Transpose[{ [PartialD]x F[{x, y}], [PartialD]y F > [{x, y}]}]; Mathematica's kernel warns me with this message when i try to insert > it: Code: Syntax::sntxf: jacobian[{x_, y_}] = Transpose[{ cannot be followed > by > [PartialD]x F[{x, y}], [PartialD]y F[{x, y}]}]; . On my system (v6.0), I have got the more meaningful message: Derivative::novar: ¶x cannot be interpreted. A partial derivative requires a subscript differentiation variable. >> The variable must passed as a *subscript* (shortcut Ctrl+-, control + dash keys) to the symbol partial d. In[1]:= F[{x_, y_}] = {f1[{x, y}], f2[{x, y}]}; In[2]:= jacobian[{x_,y_}]=Transpose[{ ! ( *SubscriptBox[ (¶ ), (x )] (F[{x, y}] ) ), ! ( *SubscriptBox[ (¶ ), (y )] (F[{x, y}] ) )}]; (* jacobian[{x_, y_}] = Transpose[{D[F[{x, y}], x], D[F[{x, y}], y]}]; *) In[3]:= MatrixForm[jacobian[{x, y}]] Out[3]//MatrixForm= ({1, 0}) ({0, 1}) f1 [{x, y}] f1 [{x, y}] ({1, 0}) ({0, 1}) f2 [{x, y}] f2 [{x, y}] --Jean-Marc === Subject: Re: Destructuring arguments to pure functions? I'm curious what you all think of this idea: Unprotect[Integer]; 1[x_] := x[[1]] 2[x_] := x[[2]] 3[x_] := x[[3]] 4[x_] := x[[4]] 5[x_] := x[[5]] 6[x_] := x[[6]] 7[x_] := x[[7]] 8[x_] := x[[8]] 9[x_] := x[[9]] Protect[Integer]; and then 1@# + 2@# & /@ testList It seems to be very slow in the current version of Mathematica but it seems like a concise/elegant way to avoid the clunky yet oft-typed # [[n]] (ie, replacing it with n@# or n[#]). Perhaps more generally, other sensible behavior could be defined for expressions with non-symbols as the Head for which the meaning is currently undefined. > I hate using #[[1]] etc. to access elements of list arguments to pure > functions, so I've been looking for a way around that. One way is to simply stop using pure functions in those cases, and use > locally bound function definitions, like testList = Flatten[Table[{x, y}, {x, 1, 100}, {y, 1, 100}], 1]; (Example 1) Module[{fun}, > fun[{x_, y_}] := x + y; > Map[fun, testList]] This turns out to be significantly faster than any other method I've > tried, but it seems clunky and requires Module. Another way is to use RuleDelayed: (Example 2) Map[# /. {x_, y_} :> x + y &, testList] but this is about 5 times slower than example 1. Binding the rule with > Module: (Example 3) Module[{fun = {x_, y_} :> x + y}, > Map[# /. fun &, testList]] Is only marginally slower than example 1, but still requires Module or > With. Strangely (to me), I found that binding the rule as a pure > function: (Example 4) Module[{fun = # /. {x_, y_} :> x + y &}, > Map[fun, testList]] is about the same speed as example 2, or 5 times slower than example > 1. I don't understand why there should be so much of a difference > there. Finally, doing this with Part: (Example 5) Map[#[[1]] + #[[2]] &, testList] is 2-3 times faster than using destructuring in example 1. Clearly, I need to give up some performance to get the clarity of > destructuring, but is there a better way than example 1? === Subject: Mathematica web site documentation new feature?? I was looking at the Wolfram web site for new features of Mathematica version 7, and noticed something that I have not seen before. For example on the page talking about the new SpokenString[] function (see http://www.wolfram.com/products/mathematica/newin7/content/SpeechOutput/ and click on the Speak any math formula link, it brings up a browser window with an example of the SpokenString function and shows the Mathematica code as an image (like all other Mathematica code that I can think of in a web page), but when you click on the command image, up pops a dialog box with the actual Mathematica code needed to execute the command. Is this something brand new? Would it be possible to have the same thing for a plot image to bring up the code that generated the plot, or any Mathematica expression that is an image on a web page bring up the ACTUAL Mathematica code that it represents? This is so simple and so intuitive, and so wonderful. How long has something like this been around? Is this really brand new for the version 7 info on the Wolfram web site? Are there other web sites that do something similar?? Comments??? -Bob === Subject: Re: Remove In/out names in Kernel / text session > Hi MathGroup Is there a way to suppress printing of In[]/Out[] names when running > only the kernel in a text session ? That is, when in type (in a Linux shell) > math < foo.m > I would like to see only the output line by line, not the In[]:=, Out > []:= > Use the -noprompt option when invoking the mathematica kernel from the command line. See also http://reference.wolfram.com/mathematica/ref/program/math.html === Subject: How to tell that PlotRange->Automatic has excluded points Hello MathGroup: I have seen lots of discussion about post-V5 PlotRange issues with multiple plots. I just re-read the help on the default PlotRange setting (i.e. AUtomatic) and I have been thinking about the phrase sufficiently far out in the distribution . I ran into this again on a fairly simple single plot: ListPlot@Table[N@Sum[1/(q^3 Sin[q]^2), {q, 1, n}], {n, 100, 500}] So what I am trying to figure out: Is there a way to tell before the plot is rendered that values in the range will be sufficiently far out to have been excluded? Of course I can always run with PlotRange->All to determine this myself. But I am thinking that there is some rule in Mathematica V7 that the plot functions use to determine this [e.g. more than 2 stddevs from the mean]. Any help in this regard is appreciated. Often I prefer the result produced by Automatic, but there are times when I want to know that these exclusions should not be done. Roger Williams Franklin Laboratory === Subject: Re: message-driven function: more explanation to my knowledge, there is no 100% closed closure in Mathematica. Instead, we may bury names arbitrarily deep into contexts. E.g. we may bury the counter in MyContext`: f1[] := Module[{MyContext`co}, MyContext`co = 0; Function[{}, ++MyContext`co] ] Daniel >> Hi Bert, >> >> nothing exotic here. The return value is a function that consits of a >> Well, there is one thing which may be mildly exotic > for those not familiar with it: the function is > returned is wrapped by a closure, which is why it > is able to retain the value of the counter variable. (The closure is not air-tight, though: In[1]:= f[a_] := Module[{aa = a, ff}, > ff[i_] := (aa += i; aa); > ff > ]; In[2]:= q = f[0] Out[2]= ff$14 In[3]:= q[2] Out[3]= 2 In[4]:= aa$14 = 0; In[5]:= q[3] Out[5]= 3 Can one get a really closed closure?) -- m > === Subject: Re: 0^0 = 1? > The arguments being exchanged about this are essentially pointless, > except to elucidate what those various starting points are and what > each > implies about 0^0. None of them leads to a definitive conclusion > about > this or that being the value of 0^0. Amen! To this let us add the distinction between the word undefined , which means that we assign no meaning to the term or collection of symbols, and the word (often misspelled indeterminant ) indeterminate . The latter is properly used only in the context of a limit, but is often used loosely of collections of symbols like 0^0 . When we say 0^0 is indeterminate , we really mean that Limit [u[x]^v[x], x -> a], where both Limit[u[x], x -> a] = 0 and Limit[v [x], x -> a] = 0, cannot be evaluated without further analysis of u, v, and the relationship between them. --Lou Talman Department of Mathematical and Computer Sciences Metropolitan State College of Denver === Subject: Re: 0^0 = 1? Because it doesn't support your preferred answer? We define other operations (addition and multiplication, for > example) by > starting with the cardinals, then extending to the integers, the > rationals, the reals, and then the complex numbers. At each stage, we > want the new definition to be consistent with the old. That is not the point. The point is that the original reason why the axiomatic approach to the so called foundations of mathematics was adopted around the turn of the 19 and 20 century (Cantor's theory of cardinal numbers, Zermelo-Frankel axioms, Peano's axioms for arithmetic etc) were summed up in Hilbert's first and second problems. In other words, it was the hope that one could reduce all mathematics to a certain system of axioms and then establish the consistency of this system and thus the consistency of all of mathematics. The theorems of Goedel (and to some extent Cohen's solution of the continuum hypothesis) showed that this hope was futile. One consequence is that there is no advantage at all in starting with abstractions such as sets or cardinals or even the God given (according to Kronecker) integers. We are just as well or badly off if we take real or even complex numbers as the starting point. In fact this approach has the great advantage of being much closer to our physical intuition. This is not just my opinion. Most mathematicians today do not care about the foundations of mathematics , except as another area of pure mathematics, or relatively little usefulness. One of the greatest living mathematicians, V.I. Arnold has been very vocal in opposing the axiomatic approach to mathematics as very harmful. An example of his views (quite widely shared) can be seen in this (somewhat abridged) translation of an essay on the teaching of mathematics: http://pauli.uni-muenster.de/~munsteg/arnold.html Of course this does not mean that Arnold's views have to be viewed as some kind of holy writ, but only that in your statement we define... etc. the we refers to a finite subset of the total set of all mathematicians, and one of rather small cardinality. In a computer program of course practical considerations should take priority. Now, I indeed do not see any problems with 0^0 returning 1. However, presumably in such cases one would also want 0.^0. to return 1, which actually could cause problems, since such expressions can precision arithmetic. Returning 1. in such situations rather than Indeterminate could be very misleading. Of course problems of this type are inevitable with fixed precision arithmetic no matter what conventions we adopt, but there is no point adding to them for no good reason. Andrzej Kozlowski > >>> Another way is to notice that 0^0 represents an empty product, whose >>> value is the identity element in the monoid of the integers (or the >>> reals). > >>> In[1]:= Product[0,{k,0}] > >>> Out[1]= 1 > >> This and the ZF result are arguments for making 0^0 equal to one. >> They >> are not in any sense proofs that it must be one, given that Power >> lives in the setting of functions of complex variables. The ZF result is indeed a proof in the context of the cardinal > numbers. > The empty product result applies to any monoid. The complex numbers > are > a monoid. The symbol 0 in Mathematica represents the complex > number 0, > and as you can see, Mathematica agrees that the empty product yields > the > complex number 1. > >>> One might also consider the series expansion for Exp[0], which >>> reduces to > >>> 1 = 0^0/0! + (lots of terms that all reduce to zero). > >> This point is questionable, since one does not in general encounter >> the >> formula with a term x0^0 (where x0 is the point of expansion). It is not questionable. The series expansion for Exp[x] is Sum[x^k/k!,{k,0,Infinity}] whether one normally encounters it in that form or not. > >>> Having x^y be discontinuous at (0,0) does not cause problems any >>> more >>> than having the Sign function be discontinuous at 0 causes problems. > >> That's a matter of opinion. Clearly we do not at this time agree with >> you on this. But no one has presented an example of an actual problem that is > caused > by the definition. Discontinuous functions exist. That's the basic > reason that we need to study limits in the first place. > >>> Anyone who works with limits should be aware that you can't just >>> blindly >>> assume continuity when evaluating limits. You have to consider the >>> actual definition of the limit. > >> True, but I don't see any relevance to this particular issue. The >> question at hand is whether or not 0^0 should be assigned a concrete >> value. If it is given a value, then since limits of x^y depend on how >> x,y respectively approach 0, they might or might not equal that value >> (so there is no underlying assumption of continuity). But that is >> already the case, and the question at hand is whether the undefined >> value should in fact be defined. We don't assign a value to 0^0. We simply look at the definition > and > notice what it says for the case of 0^0. The definition makes no > statement at all about limits, and therefore thinking that the > definition > has implications regarding limits is a misconception. -- > Dave Seaman > Third Circuit ignores precedent in Mumia Abu-Jamal ruling. > > === Subject: Re: 0^0 = 1? >>> 0^0 means the limit if both base and exponent go to zero. >> No, that is not how 0^0 is defined. Does 2+2 mean the limit as both >>> summands go to 2? The value may happen to be the same in that case, but >>> that is not how 2+2 is defined. >> The value of x^y for cardinal numbers x and y is the cardinality of the >>> set of mappings from y into x. In the case where x and y are the empty >>> set, there is exactly one such mapping. Hence, 0^0 = 1. > That's a definition from set theory. I doubt it plays nice in the >> complex plane. The definition of Power we go by is >> ower[a,b] == Exp[Log[a]*b] >> Among other advantages, it means branch cuts for Power are inherited >> from Log. Branch cuts at 0 are not particularly relevant here, since Exp[-oo*0] = > Exp[anything*0] = Exp[0] = 1. >> It's a theorem of ZF (as stated in Suppes, _Axiomatic_Set_Theory_) that >>> m^0 = 1 for every cardinal number m. > I think the setting of cardinal numbers is not really a good choice for >> symbolic computation. Because it doesn't support your preferred answer? No, because it doesn't yield practical results. Mathematica's approach to mathematics must be relevant to the needs of applications for it to thrive. We define other operations (addition and multiplication, for example) by > starting with the cardinals, then extending to the integers, the > rationals, the reals, and then the complex numbers. At each stage, we > want the new definition to be consistent with the old. >> Another way is to notice that 0^0 represents an empty product, whose >>> value is the identity element in the monoid of the integers (or the >>> reals). >> In[1]:= Product[0,{k,0}] >> Out[1]= 1 > This and the ZF result are arguments for making 0^0 equal to one. They >> are not in any sense proofs that it must be one, given that Power >> lives in the setting of functions of complex variables. The ZF result is indeed a proof in the context of the cardinal numbers. No, it's a proof from a particular idea of cardinals that emerges from a particular axiomatization. Cardinal numbers existed for millennia before their axiomatization. Things like the ZF axioms are not especially relevant to applied math: there's nothing we would change if they'd never been formulated. > The empty product result applies to any monoid. The complex numbers are > a monoid. The symbol 0 in Mathematica represents the complex number 0, > and as you can see, Mathematica agrees that the empty product yields the > complex number 1. >> One might also consider the series expansion for Exp[0], which reduces to >> 1 = 0^0/0! + (lots of terms that all reduce to zero). > This point is questionable, since one does not in general encounter the >> formula with a term x0^0 (where x0 is the point of expansion). It is not questionable. The series expansion for Exp[x] is Sum[x^k/k!,{k,0,Infinity}] whether one normally encounters it in that form or not. Ok, now you're talking analysis. But here, there's a fundamental distinction between a variable whose value is zero right now and a constant whose value is zero . So the analyst encountering x^y at (0,0) starts asking questions. If y is constant, x variable, well, 1 is a good convention. But if it's the other way around, 0 is good. If they are both variable, more information is needed. And if they are both constant, the question is Why are you talking to an analyst when a different kind of math is needed? ;-) >> Having x^y be discontinuous at (0,0) does not cause problems any more >>> than having the Sign function be discontinuous at 0 causes problems. > That's a matter of opinion. Clearly we do not at this time agree with >> you on this. But no one has presented an example of an actual problem that is caused > by the definition. Discontinuous functions exist. That's the basic > reason that we need to study limits in the first place. >> Anyone who works with limits should be aware that you can't just blindly >>> assume continuity when evaluating limits. You have to consider the >>> actual definition of the limit. > True, but I don't see any relevance to this particular issue. The >> question at hand is whether or not 0^0 should be assigned a concrete >> value. If it is given a value, then since limits of x^y depend on how >> x,y respectively approach 0, they might or might not equal that value >> (so there is no underlying assumption of continuity). But that is >> already the case, and the question at hand is whether the undefined >> value should in fact be defined. We don't assign a value to 0^0. We simply look at the definition and > notice what it says for the case of 0^0. A definition, not the definition. 0^0 represents one of those special cases where mathematics is not unified, and different points of view suggest different results. The applied mathematician gets to choose what works in the problem domain. But Mathematica can't read your mind here. > The definition makes no > statement at all about limits, and therefore thinking that the definition > has implications regarding limits is a misconception. For your kind of math, this may be true. But limits are fundamental to analysis. -- John Doty, Noqsi Aerospace, Ltd. http://www.noqsi.com/ -- The axiomatic method of mathematics is one of the great achievements of our culture. However, it is only a method. Whereas the facts of mathematics once discovered will never change, the method by which these facts are verified has changed many times in the past, and it would be foolhardy to expect that changes will not occur again at some future date. - Gian-Carlo Rota === Subject: Re: 0^0 = 1? >>> [...] >>> The value of x^y for cardinal numbers x and y is the cardinality of the >>> set of mappings from y into x. In the case where x and y are the empty >>> set, there is exactly one such mapping. Hence, 0^0 = 1. > >> That's a definition from set theory. I doubt it plays nice in the >> complex plane. The definition of Power we go by is >> ower[a,b] == Exp[Log[a]*b] >> Among other advantages, it means branch cuts for Power are inherited >> from Log. Branch cuts at 0 are not particularly relevant here, since Exp[-oo*0] = > Exp[anything*0] = Exp[0] = 1. I vastly prefer to keep -Infinity*0, and it's exponential, as undefined (Indeterminate, in Mathematica). >>> It's a theorem of ZF (as stated in Suppes, _Axiomatic_Set_Theory_) that >>> m^0 = 1 for every cardinal number m. > >> I think the setting of cardinal numbers is not really a good choice for >> symbolic computation. Because it doesn't support your preferred answer? Because it is quite difficult to use for math computation. I do not wish to spend time rehashing mathematics foundations disputes of 100 years ago, at least not when immersed in the Mathematica kernel. Even if I wanted to do that, I doubt I'd find the time. > We define other operations (addition and multiplication, for example) by > starting with the cardinals, then extending to the integers, the > rationals, the reals, and then the complex numbers. At each stage, we > want the new definition to be consistent with the old. > [...] >> This and the ZF result are arguments for making 0^0 equal to one. They >> are not in any sense proofs that it must be one, given that Power >> lives in the setting of functions of complex variables. The ZF result is indeed a proof in the context of the cardinal numbers. > The empty product result applies to any monoid. The complex numbers are > a monoid. The symbol 0 in Mathematica represents the complex number 0, > and as you can see, Mathematica agrees that the empty product yields the > complex number 1. As best I can tell, this is fine if you restrict exponents to natural numbers. If you are saying that this exponentiation extends to arbitrary complex-valued exponents, then maybe so but it's not obvious to me. >>> Having x^y be discontinuous at (0,0) does not cause problems any more >>> than having the Sign function be discontinuous at 0 causes problems. > >> That's a matter of opinion. Clearly we do not at this time agree with >> you on this. But no one has presented an example of an actual problem that is caused > by the definition. Discontinuous functions exist. That's the basic > reason that we need to study limits in the first place. One place I think it would it would cause problems is in Mathematica Limit and Series code. Things that do not evaluate to Indeterminate are often taken as correct limiting values. This is one reason that having values at discontinuities e.g. on branch cuts requires careful treatment, special code, is a source of bugs, etc. While I have not tried the experiment, I would venture to guess that making 0^0 evaluate to 1 would bring substantial new troubles to that part of the code base. As I alluded above, this sort of change incurs a development cost that can be rather steep, and for no gain I can discern. >>> [...] > We don't assign a value to 0^0. We simply look at the definition and > notice what it says for the case of 0^0. The definition makes no > statement at all about limits, and therefore thinking that the definition > has implications regarding limits is a misconception. Again, this seems fine in a setting of power sets of natural numbers. It does not play nice with a^b = Exp[Log[a]*b]. I think that gets me back to where I began in this thread. Daniel Lichtblau Wolfram Research === Subject: Re: 0^0 = 1? Let me repeat in a much more explicit form what I implied in an earlier post about 0^0: there are several possible definitions, each defensible from a certain starting point. Therefore there is NO single acceptable definition. The arguments being exchanged about this are essentially pointless, except to elucidate what those various starting points are and what each implies about 0^0. None of them leads to a definitive conclusion about this or that being the value of 0^0. >>> 0^0 means the limit if both base and exponent go to zero. >> No, that is not how 0^0 is defined. Does 2+2 mean the limit as both >>> summands go to 2? The value may happen to be the same in that case, but >>> that is not how 2+2 is defined. >> The value of x^y for cardinal numbers x and y is the cardinality of the >>> set of mappings from y into x. In the case where x and y are the empty >>> set, there is exactly one such mapping. Hence, 0^0 = 1. > That's a definition from set theory. I doubt it plays nice in the >> complex plane. The definition of Power we go by is >> ower[a,b] == Exp[Log[a]*b] >> Among other advantages, it means branch cuts for Power are inherited >> from Log. Branch cuts at 0 are not particularly relevant here, since Exp[-oo*0] = > Exp[anything*0] = Exp[0] = 1. >> It's a theorem of ZF (as stated in Suppes, _Axiomatic_Set_Theory_) that >>> m^0 = 1 for every cardinal number m. > I think the setting of cardinal numbers is not really a good choice for >> symbolic computation. Because it doesn't support your preferred answer? We define other operations (addition and multiplication, for example) by > starting with the cardinals, then extending to the integers, the > rationals, the reals, and then the complex numbers. At each stage, we > want the new definition to be consistent with the old. >> Another way is to notice that 0^0 represents an empty product, whose >>> value is the identity element in the monoid of the integers (or the >>> reals). >> In[1]:= Product[0,{k,0}] >> Out[1]= 1 > This and the ZF result are arguments for making 0^0 equal to one. They >> are not in any sense proofs that it must be one, given that Power >> lives in the setting of functions of complex variables. The ZF result is indeed a proof in the context of the cardinal numbers. > The empty product result applies to any monoid. The complex numbers are > a monoid. The symbol 0 in Mathematica represents the complex number 0, > and as you can see, Mathematica agrees that the empty product yields the > complex number 1. >> One might also consider the series expansion for Exp[0], which reduces to >> 1 = 0^0/0! + (lots of terms that all reduce to zero). > This point is questionable, since one does not in general encounter the >> formula with a term x0^0 (where x0 is the point of expansion). It is not questionable. The series expansion for Exp[x] is Sum[x^k/k!,{k,0,Infinity}] whether one normally encounters it in that form or not. >> Having x^y be discontinuous at (0,0) does not cause problems any more >>> than having the Sign function be discontinuous at 0 causes problems. > That's a matter of opinion. Clearly we do not at this time agree with >> you on this. But no one has presented an example of an actual problem that is caused > by the definition. Discontinuous functions exist. That's the basic > reason that we need to study limits in the first place. >> Anyone who works with limits should be aware that you can't just blindly >>> assume continuity when evaluating limits. You have to consider the >>> actual definition of the limit. > True, but I don't see any relevance to this particular issue. The >> question at hand is whether or not 0^0 should be assigned a concrete >> value. If it is given a value, then since limits of x^y depend on how >> x,y respectively approach 0, they might or might not equal that value >> (so there is no underlying assumption of continuity). But that is >> already the case, and the question at hand is whether the undefined >> value should in fact be defined. We don't assign a value to 0^0. We simply look at the definition and > notice what it says for the case of 0^0. The definition makes no > statement at all about limits, and therefore thinking that the definition > has implications regarding limits is a misconception. > -- 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: Timing of N[ Factorial[4000000], 18] $Version Timing[N[Factorial[4000000], 18]] 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) {4.09643, 5.46787756151445098*10^24671065} This was on a 2.8GHz iMac WHILE running Rybka Aquarium 3's infinite analysis of a chess position, in a Parallels WinXP window. Computers are getting kinda fast, don't you think? Bobby > >> $Version >> 7.0 for Microsoft Windows (32-bit) (November 10, 2008) >> >> Timing[N[Factorial[4000000],18]] >> {6.047,5.46787756151445098*10^24671065} >> In[1]:= Timing[N[Factorial[4000000],18]] > Out[1]= {6.334,5.46787756151445098*10^24671065} > In[2]:= $Version > Out[2]= 6.0 for Microsoft Windows (32-bit) (June 19, 2007) > -- DrMajorBob@longhorns.com === Subject: Re: Timing of N[ Factorial[4000000], 18] $Version 7.0 for Mac OS X x86 (64-bit) (November 11, 2008) Timing[N[Factorial[4000000],18]] {3.49545,5.46787756151445098*10^24671065} Peter 2009/1/25 Murray Eisenberg : > $Version > 7.0 for Microsoft Windows (32-bit) (November 10, 2008) Timing[N[Factorial[4000000],18]] > {6.047,5.46787756151445098*10^24671065} > >> How long does it take Mathematica 7 to compute >> N[ Factorial[4000000], 18] >> >> With the old version of Mathematica I have it takes a very long time, >> and I was wondering if Mathematica 7 is much better. You might ask why >> I wanted to do that. Well I wanted to see how quickly Stirling's >> formula approaches Factorial[n] for large n. >> >> ------------------------ >> Ted Ersek >> >> -- > 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: Timing of N[ Factorial[4000000], 18] > How long does it take Mathematica 7 to compute > N[ Factorial[4000000], 18] With the old version of Mathematica I have it takes a very long time, > and I was wondering if Mathematica 7 is much better. You might ask why > I wanted to do that. Well I wanted to see how quickly Stirling's > formula approaches Factorial[n] for large n. > In[1]:= Timing[N[Factorial[4000000], 18]] Out[1]= {7.515, 5.46787756151445098*10^24671065} === Subject: Re: Timing of N[ Factorial[4000000], 18] > $Version >7.0 for Microsoft Windows (32-bit) (November 10, 2008) Timing[N[Factorial[4000000],18]] >{6.047,5.46787756151445098*10^24671065} > In[1]:= Timing[N[Factorial[4000000],18]] Out[1]= {6.334,5.46787756151445098*10^24671065} In[2]:= $Version Out[2]= 6.0 for Microsoft Windows (32-bit) (June 19, 2007) === Subject: Additive inverses of lists? Is this a known no-no, or did I find something new? (I obviously originally tried it in the graphical front end; I'm only doing it from the command line interface for demonstration.) max@boron:~% math Mathematica 7.0 for Linux x86 (32-bit) Copyright 1988-2008 Wolfram Research, Inc. In[1]:= StreamPlot[-{x, y}, {x, -3, 3}, {y, -3, 3}] zsh: segmentation fault math Interestingly enough if the StreamPlot is not involved, nothing but happens: In[1]:= -{a, b} Out[1]= {-a, -b} And plotting {-x, -y} instead of -{x, y} works fine: In[1]:= StreamPlot[{-x, -y}, {x, -3, 3}, {y, -3, 3}] Out[1]= -Graphics- -- Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis Only love is worth the risk -- Oleta Adams === Subject: Re: Additive inverses of lists? > Is this a known no-no, or did I find something new? (I obviously > originally tried it in the graphical front end; I'm only doing it from > the command line interface for demonstration.) This seems to be new and this also works on Windows :-) > max@boron:~% math > Mathematica 7.0 for Linux x86 (32-bit) > Copyright 1988-2008 Wolfram Research, Inc. In[1]:= StreamPlot[-{x, y}, {x, -3, 3}, {y, -3, 3}] > zsh: segmentation fault math Upon evaluation of the above line from within the front end, Visual Studio Just-in-Time debugger traps the following error: An unhandled win32 exception occurred in MathKernel.exe [4060] Forcing the evaluation of the expression -{x, y} yields the expected behavior and plot, though. StreamPlot[Evaluate[-{x, y}], {x, -3, 3}, {y, -3, 3}] In[5]:= {$Version, $ReleaseNumber} Out[5]= { 7.0 for Microsoft Windows (32-bit) (November 10, 2008) , 0} > Interestingly enough if the StreamPlot is not involved, nothing but happens: In[1]:= -{a, b} Out[1]= {-a, -b} And plotting {-x, -y} instead of -{x, y} works fine: In[1]:= StreamPlot[{-x, -y}, {x, -3, 3}, {y, -3, 3}] Out[1]= -Graphics- --Jean-Marc === === === === === Subject: Re: A question about Mathematica Hi Mohammed, You may e.g. use Eliminate to change variables. Unfortunately I can not read your input. But here is another example: Given: eq = {(x - 1)^2 + (y - 3)^2 == 1, y/x == 2 + x} we ewant to change variables to r and v: r == x^2 + y^2, v == y/x. This can e.g. be done by: Eliminate[Join[eq, {r == x^2 + y^2, v == y/x}], {x, y}] For more elaborate cases we have GroebnerBasis , but this needs a bit theory. hope this helps, Daniel I found this email address from www.mathematica-users.org as the reference > that I can ask my questions about mathematica. > I have not used Mathematica yet. but for one of the tasks in my research I > have been told that Mathematica can be useful. > My question is following: *I have couple of first order differential equations, and I want to change > some variables, which I know would simplified the equations. I was > wondering if you can help me with it. The equations are: > m dot U + mQW + mg sin{ theta} + dot Q ( lambda_a eta_a + lambda_f > eta_f ) + 2Q( lambda_a dot eta_a + lambda_f dot eta_f ) = F_x > m dot W - mQU - mg cos{ theta} + lambda_a ddot eta_a + lambda_f ddot > eta_f - Q^2 ( lambda_a eta_a + lambda_f eta_f ) = F_z > (I_{yy} + eta_a^2 + eta_f^2) dot Q + ( dot U + QW)( lambda_a eta_a + > lambda_f eta_f ) + 2Q( eta_a dot eta_a + eta_f dot eta_f) - psi_a > ddot eta_a - psi_f ddot eta_f = M > ddot eta_f + ( dot W - QU) lambda_f - dot Q psi_f + 2 zeta omega_f dot > eta_f + ( omega_f^2 - Q^2) eta_f = N_f > ddot eta_a + ( dot W - QU) lambda_a - dot Q psi_a + 2 zeta omega_a dot > eta_a + ( omega_a^2 - Q^2) eta_a = N_a and my change of variable is: tan{alpha} = W/U > V_T^2 = U^2 + W^2 === Subject: Re: NIntegrate and Plot Hi Dimitris, integrate your function before plotting it: Integrate[fun[r, t], {t, 0, Infinity}, Assumptions -> {r >= 0}] hope this helps, Daniel > Hello. I have the following function fun[r_, t_] := -(((-3 + 4*t^2 + 8*t^4 - 8*t^3*Sqrt[1 + t^2])* > BesselJ[1, r*t])/(3 + 14*t^2 + 24*t^4 + 16*t^6 - > 16*t^3*Sqrt[1 + t^2] - 16*t^5*Sqrt[1 + t^2])) How can I achieve better performance in the following task Plot[NIntegrate[fun[r, t], {t, 0, Infinity}], {r, 0, 3}] === Subject: Re: Which editor do you use for math particularly for those who find LateX too restrictive (LateX provides one with a lot of pre-defined constructions but as always in such cases at the cost of forcing one to do things the way the creators of LateX decided was the most desirable.) However, my main point was different. I do have Gratzler's book and I sometimes use it, unlike Spivak's book I can't imagine anyone reading it just for the jokes ;-) Andrzej Kozlowski > Unless I'm mistaken, Spivak's book is about the amstex macro, not the I highly recommend instead Graetzer's More Math into LaTeX , 4th ed. > >> To anyone who is thinking of using TeX to write some serious >> mathematics I would also recommend Michael Spivak's The Joy of >> sometimes is more flexible than LateX). >> Spivak's book is very clear and witty, and, for a mathematician, much >> more accessible than Knuth's rather incomprehensible manual. Yes, the >> title is rather 1980s and yes, it meant to remind you of what it >> probably reminds you (if you are old enough, that is). >> >> As for Donald Knuth, I think the Art of Computer Programing does him >> more justice as a genius and this book: >> >> http://www.press.uchicago.edu/presssite/metadata.epl?mode=synopsis&bookkey=22 258 >> >> as a writer. >> >> Andrzej Kozlowski >> >> >> >> >> >>> >>>> If you are to effectively make use of LaTeX you will definitely >>>> want to get a book written about using LaTeX. Like Mathematica, >>>> LaTeX will require quite a bit of study/usage before you will >>>> really be comfortable using it. I believe the payoff for >>>> learning LaTeX warrants the effort. >>> I'd just add that you might also want to acquire a copy of Knuth's >>> original users guide for TeX, not only for getting a very readable >>> introduction to the basic concepts of TeX itself, but even more just >>> for >>> the pleasure of reading or scanning it and getting a near-personal >>> encounter with a genuine genius, as well as adding a true classic to >>> your library. >>> >>> (Of course it may also make you weep, which you compare Knuth's >>> approach >>> to user documentation to Wolfram's current approach.) >>> >>> Last I looked there was one used copy of the original spiralbound >>> paperback TeXBook for sale on amazon for $25. Given the tattered >>> condition of my original copy, I nearly bought it. The current >>> hardbound >>> version seems to be retitled as Computers & Typesetting, Volume A: >>> The >>> TeXbook (Computers & Typesetting Series) (Hardcover) and costs a >>> little >>> more. I'm guessing it contains essentially the same material as the >>> original. >>> >> >> -- > 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: Which editor do you use for math Unless I'm mistaken, Spivak's book is about the amstex macro, not the I highly recommend instead Graetzer's More Math into LaTeX , 4th ed. > To anyone who is thinking of using TeX to write some serious > mathematics I would also recommend Michael Spivak's The Joy of > sometimes is more flexible than LateX). > Spivak's book is very clear and witty, and, for a mathematician, much > more accessible than Knuth's rather incomprehensible manual. Yes, the > title is rather 1980s and yes, it meant to remind you of what it > probably reminds you (if you are old enough, that is). As for Donald Knuth, I think the Art of Computer Programing does him > more justice as a genius and this book: http://www.press.uchicago.edu/presssite/metadata.epl?mode=synopsis&bookkey=22 258 as a writer. Andrzej Kozlowski > >>> If you are to effectively make use of LaTeX you will definitely >>> want to get a book written about using LaTeX. Like Mathematica, >>> LaTeX will require quite a bit of study/usage before you will >>> really be comfortable using it. I believe the payoff for >>> learning LaTeX warrants the effort. >> I'd just add that you might also want to acquire a copy of Knuth's >> original users guide for TeX, not only for getting a very readable >> introduction to the basic concepts of TeX itself, but even more just >> for >> the pleasure of reading or scanning it and getting a near-personal >> encounter with a genuine genius, as well as adding a true classic to >> your library. >> >> (Of course it may also make you weep, which you compare Knuth's >> approach >> to user documentation to Wolfram's current approach.) >> >> Last I looked there was one used copy of the original spiralbound >> paperback TeXBook for sale on amazon for $25. Given the tattered >> condition of my original copy, I nearly bought it. The current >> hardbound >> version seems to be retitled as Computers & Typesetting, Volume A: The >> TeXbook (Computers & Typesetting Series) (Hardcover) and costs a >> little >> more. I'm guessing it contains essentially the same material as the >> original. >> -- 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: Which editor do you use for math To anyone who is thinking of using TeX to write some serious mathematics I would also recommend Michael Spivak's The Joy of sometimes is more flexible than LateX). Spivak's book is very clear and witty, and, for a mathematician, much more accessible than Knuth's rather incomprehensible manual. Yes, the title is rather 1980s and yes, it meant to remind you of what it probably reminds you (if you are old enough, that is). As for Donald Knuth, I think the Art of Computer Programing does him more justice as a genius and this book: http://www.press.uchicago.edu/presssite/metadata.epl?mode=synopsis&bookkey=2 2258 as a writer. Andrzej Kozlowski > >> >> If you are to effectively make use of LaTeX you will definitely >> want to get a book written about using LaTeX. Like Mathematica, >> LaTeX will require quite a bit of study/usage before you will >> really be comfortable using it. I believe the payoff for >> learning LaTeX warrants the effort. I'd just add that you might also want to acquire a copy of Knuth's > original users guide for TeX, not only for getting a very readable > introduction to the basic concepts of TeX itself, but even more just > for > the pleasure of reading or scanning it and getting a near-personal > encounter with a genuine genius, as well as adding a true classic to > your library. (Of course it may also make you weep, which you compare Knuth's > approach > to user documentation to Wolfram's current approach.) Last I looked there was one used copy of the original spiralbound > paperback TeXBook for sale on amazon for $25. Given the tattered > condition of my original copy, I nearly bought it. The current > hardbound > version seems to be retitled as Computers & Typesetting, Volume A: The > TeXbook (Computers & Typesetting Series) (Hardcover) and costs a > little > more. I'm guessing it contains essentially the same material as the > original. > === Subject: Permutations... Given 4 elements (1 2 3 4) we have 6 translatios: 1 2 3 4 1 3 2 4 1 4 2 3 2 1 3 4 3 1 2 4 4 3 2 1 Each translation can generate 4 rotations: 1 2 3 4 1 3 2 4 1 4 2 3 2 3 4 1 3 2 4 1 4 2 3 1 3 4 1 2 4 1 3 2 3 1 4 2 4 1 2 3 4 1 3 2 3 1 4 2 etc. Then: Translations = (4-1)! = 6 Rotations = 4 per translation Permutations = Trans * Rot = 4! = 24 With Mathematica: Permutations[Range[4]] prints all 24 Permutations How can I get the 6 Translations and the 18 Rotations separately? Bruno === Subject: Newbie Question - Change 3D Bar Chart Background Color I am struggling in changing the background (the X and Y plane) in this example from blue to any other color. BarChart3D[{1, 2, 3}] Also I **believe** I have looked ever where in the documentation about the available options for BarChart3D.... Where would I find a comprehensive recap of what can be done? Tim