I have the following problem with Mathematica. I need to make an animation and I use For[i=1, i<=n ListPlot[.....]; i++] which creates n plots. After that I double click on the grouping bracket to the right of the plots to close the group and animate it. Is there any possibility to make the animation avoiding the ploting of all n plots? Luiza Bondar ==== The easiest way is to take advantage of Mathematica's ImplicitPlot[] function. See the help documentation for more info. But after loading the package it is straight forward. In[1]:= << Graphics`ImplicitPlot` In[2]:= ImplicitPlot[x == y^2,{x,-10,10}] Don't forget the double equal sign. This is a common mistake to make when beginning. Adam Smith > I'm just a beginner with Mathematica and I'd like to > know if it's possible to plot the parabola x=y^2 in > the range -10 to 10. I'm trying using y=Sqrt[x] but > that doesn't work for negative x. > Many thanks in advance, > Ruben __________________________________ > Do you Yahoo!? > New Yahoo! Photos - easier uploading and sharing. > http://photos.yahoo.com/ ==== Ruben, One other method is... ParametricPlot[{y^2, y}, {y, -10, 10}, Frame -> True, FrameLabel -> {x, y}]; David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Sender: steve@smc.vnet.net Approved: Steven M. Christensen , Moderator ==== you should try it with *small* numbers < 10-6 on you axes to see the same effect. It is a bug in the formating of exponents on graphics. I guss the frontend hangs up when it tyr to get the font metric of you X-fonts. Jens problem arises whenever I try to plot a graph with large numbers. For > example ListPlot[{{1, 1}, {1*^6, 2}}] Then Mathematica hangs while rendering this plot. It stays > (apparently) forever saying Running...Rendering...Untitled-1 and I > have no way to stop it without killing the whole Mathematica. If I > take a look at the processor activity I see that is the X server who > is taking all the processor time. What is it doing? Is this a > problem of Mathematica or of the X server? Have somebody experienced the > same problem? BTW, if I write instead P = ListPlot[{{1, 1}, {1*^6, 2}}, DisplayFunction->Identity] > Export[p.eps, P] the EPS file is generated flawlessly and can be viewed without > problems outside Mathematica. I have also made some 'experiments' (I have to admit that I'm a > physicist) and found that the maximum number that can be plotted lies > around 975609.78. Any idea about what does it mean? ==== >Method 1 (Delayed Definition) >eq[a_] := y''[x] + a^2*y[x] == 0; >sol[a_] := NDSolve[{eq[a], y[0] == 1, y'[0] == -1}, y, {x, 0, 10}] >sol[a] > NDSolve::ndnum: Encountered non-numerical value As we have already seen, you can use either an immediate or a delayed assignment as long as you provide a numerical value to all of the parameters included in your ODE. The immediate assignment is fast, but requires that you input the numerical values directly ode[a_] := y''[x] + a^2*y[x] == 0; f[x_] = y[x] /. NDSolve[ {ode[1], y[0] == 1,y'[0] == -1}, y[x], {x, 0, 10}][[1]] data = Table[{x, f[x]} , {x, 0, 1, 10^-3}] -table here - Since you want a procedure that accepts the parameter a and the initial values as arguments you can use a (rather inefficient) delayed assignment ode[a_] := y''[x] + a^2*y[x] == 0; f[a_, {y0_,yp0_}, x_] := y[x] /. NDSolve[ {ode[1], y[0] == y0,y'[0] == yp0}, y[x], {x, 0, 10}][[1]] data[a_, {y0_,yp0_}] := Table[{x, f[a, {y0,yp0}, x]} /. x -> t, {t, 0, 1, 10^-3}] data[1,{1,-1}] -table here - To overcame the efficiency problems we can use a mixed assignment, by decoupling the parameters a, y0 e yp0 from the variable x. A pure function and the notation f[params][vars] come in handy: ode[a_] := y''[x] + a^2*y[x] == 0; f[a_, {y0_,yp0_}] := y /. NDSolve[ {ode[1], y[0] == y0,y'[0] == yp0}, y, {x, 0, 10}][[1]] data[a_, {y0_,yp0_}] := ( g = f[a, {y0,yp0}]; Table[{x, g} , {x, 0, 1, 10^-3}] ) data[1,{1,-1}] -table here - So, my question to the group is: is there a neater way to do this? cheers, Peltio -- ==== evaluate it when you *have* a numerical value for a eq[a_?NumericQ] := y''[x] + a^2*y[x] == 0 sol[a_?NumericQ] := NDSolve[{eq[a], y[0] == 1, y'[0] == -1}, y, {x, 0, 10}] and sol[15] will work. Jens I have a serious problem with NDSolve. Method 1 (Delayed Definition) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > In[1]: eq[a_] := y''[x] + a^2*y[x] == 0; In[2]: sol[a_] := NDSolve[{eq[a], y[0] == 1, y'[0] == -1}, y, {x, 0, 10}] In[3]: sol[a] NDSolve::ndnum: Encountered non-numerical value for a derivative at > !(x) == !(5.840380984046049`*^-301). Out[3]:{{y -> InterpolatingFunction[{{0., 0.}}, <>]}} In[4]: f[x_, a_] := y[x] /. sol[a][[1]] In[5]: f[1, 1] In[6]:Plot[f[x, 2], {x, 0, 10}] [PLOT HERE] > Out[6] - Graphics - In[7] f[x, a] NDSolve::ndnum: Encountered non-numerical value for a derivative at > !(x) == !(5.840380984046049`*^-301). Out[7] InterpolatingFunction[{{0., 0.}}, <>][x] In[8] Table[{x, f[x, 1]}, {x, 0, 10}] General::ivar: !(0) is not a valid variable. > NDSolve::dsvar: !(0) cannot be used as a variable. [SNIPPED] > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Example 2 (Immediate Definition) In[1]: eq[a_] := y''[x] + a^2*y[x] == 0; In[2]: sol[a_] := NDSolve[{eq[a], y[0] == 1, y'[0] == -1}, y, {x, 0, 10}] In[3]: sol[a] NDSolve::ndnum: Encountered non-numerical value for a derivative at > !(x) == !(5.840380984046049`*^-301). Out[3]:{{y -> InterpolatingFunction[{{0., 0.}}, <>]}} In[4]: f[x_, a_] = y[x] /. sol[a][[1]] NDSolve::ndnum: Encountered non-numerical value for a derivative at > !(x) == !(5.840380984046049`*^-301). Out[5]: InterpolatingFunction[{{0., 0.}}, <>][x] In[6]: f[1, 1] InterpolatingFunction::dmval: Input value !({1}) lies outside the > range > of data in the interpolating function. Extrapolation will be used. Out[6]: 0 In[7]: Table[{x, f[x, 1]}, {x, 0, 10}] > InterpolatingFunction::dmval: Input value !({1}) lies outside the > range > of data in the interpolating function. Extrapolation will be used. > InterpolatingFunction::dmval: Input value !({2}) lies outside the > range > of data in the interpolating function. Extrapolation will be used. > [snip] Out[7]: {{0, 1.}, {1, 0.}, {2, -1.}, {3, -2.}, {4, -3.}, {5, -4.}, {6, -5.}, > {7, -6.}, {8, > -7.}, {9, -8.}, {10, -9.}} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Immediate or Delayed Definitions in NDSolve?? thx in advance -- > extrabyte > http://extrabyte.splinder.it > http://www.hardwarenonsolo.3go.it ==== sorry there were some typos that were not there in the original notebook. First I defined beta2 via beta1 hence there is no recursion and the pQ1 in the output I wanted to get. Nevertheless, using your code (with little modification, i.e rr=q*q1 +q2) yields the same result, i.e. Mathematica running ad infinitum. foc[f_,x_] := Map[(D[f,#]==0)&,x] ll = 80; kk = 80; alpha1= 3/4; alpha2 = 1- alpha1; beta1 = 1/3; beta2 = 1 - beta1; q1 = l1^alpha1*k1^alpha2; q2 = (ll-l1)^beta1*(kk-k1)^beta2; rr = p*q1 + q2; Flatten[Solve[foc[rr,{l1,k1}],{k1,l1}]] Perhaps you have some other clues besides the obvious candidates. Andreas I have a bizarre Problem. In trying to run this standard economics > maximization problem Mathematica runs ad infinitum. Same if instead of > Solve I use NSolve. Same if I split up the problem in doing first the > partial derivatives etc. It is definitely a Solve/NSolve problem, but I > can't believe that it is not able to do this numerical stories on such a > standard problem with so well-behaved functions. Foc[f_,x_]:=Map[(D[f,#]==0)&,x] Parameters: > L=80; K=80; alpha1= 3/4; alpha2 = 1- alpha1; beta1 = 1/3; beta2=1 - > beta2; Q1 = L1^alpha1 K1^alpha2 > Q2 = (L-L1)^beta1 (K-K1)^beta2 > R = pQ1 + Q2 > Out = Flatten[Solve[FOC,[R,{L1,K1}],{K1,L1}]] Curiously it works for alpha1 = 2/3 but for alpha1 = 3/4 as above, or any > other value such as alpha1 = 0.7 alpha2 = 0.3 I should be grateful if anybody could give me a hint on the sources of this > problem, and on how to be able to use any type of exponents. Andreas I think if you type it in correctly you can get a result. Your >equations contain an infinite recursion (defining beta2 in terms of >itself). Also your Solve input is not well formed. Also use of a >variable called Out in Mathematica is, well, a very bad idea. foc[f_,x_] := Map[(D[f,#]==0)&,x] >ll = 80; >kk = 80; >alpha1= 3/4; >alpha2 = 1- alpha1; >beta1 = 1/3; >beta2 = 1 - beta1; >q1 = l1^alpha1*k1^alpha2; >q2 = (ll-l1)^beta1*(kk-k1)^beta2; >rr = q1 + q2; In[39]:= InputForm[out = Flatten[Solve[foc[rr,{l1,k1}],{k1,l1}]]] Out[39]//InputForm= >{k1 -> (10827737831833600 - 457019805007872* > Root[-346487610618675200 + 18280792200314880*#1 - >380849837506560*#1^2 + > 3967185807360*#1^3 - 20662426080*#1^4 + 43046721*#1^5 & , 1, 0] >+ > 7140934453248*Root[-346487610618675200 + 18280792200314880*#1 - > 380849837506560*#1^2 + 3967185807360*#1^3 - 20662426080*#1^4 + > 43046721*#1^5 & , 1, 0]^2 - 49589822592* > Root[-346487610618675200 + 18280792200314880*#1 - >380849837506560*#1^2 + > 3967185807360*#1^3 - 20662426080*#1^4 + 43046721*#1^5 & , 1, >0]^3 + > 129140163*Root[-346487610618675200 + 18280792200314880*#1 - > 380849837506560*#1^2 + 3967185807360*#1^3 - 20662426080*#1^4 + > 43046721*#1^5 & , 1, 0]^4)/8796093022208, > l1 -> Root[-346487610618675200 + 18280792200314880*#1 - > 380849837506560*#1^2 + 3967185807360*#1^3 - 20662426080*#1^4 + > 43046721*#1^5 & , 1, 0]} >Daniel Lichtblau >Wolfram Research ==== >-----Original Message----- >Sent: Sunday, December 14, 2003 12:23 PM >To: mathgroup@smc.vnet.net >-----Original Message----- >To: mathgroup@smc.vnet.net >>Sent: Thursday, December 11, 2003 11:28 AM >>To: mathgroup@smc.vnet.net >>Consider >>In[1]:= >>Module[ >> {L={0,0}}, >> L[[1]]=Sequence[1,1]; >> L[[2]]=2; >> L[[2]] >>] >>Out[1]= >>1 >>The first part assignment constructs a list >{Sequence[1,1],0}. Then an >>interesting thing happens: part extraction functions (Part >and others) >>think that the second element of this list is 1, while part >assignment >>(Set) decides that the second element is 0. >>Maxim Rytin >> Maxim, >> obviously you like to live on the edge. Unless you complain, >this is a bold >> way to learn. Observe: >> In[32]:= L = {0, 0}; >> L[[1]] = Sequence[1, 1]; >> L[[2]] = 2; >> L[[2]] >> Out[35]= 1 >> In[36]:= ?L >> Global`L >> L = {Sequence[1, 1], 2} >> In[48]:= Attributes[Set] >> Out[48]= {HoldFirst, Protected, SequenceHold} >> (Look up what SequenceHold means!) >> As mostly, you do have alternatives: >> In[38]:= L = {0, 0}; >> L = ReplacePart[L, Unevaluated[Sequence[1, 1]], 1]; >> L[[2]] = 2; >> L[[2]] >> Out[41]= 2 >> In[42]:= ?L >> Global`L >> L = {1, 2, 0} >> -- >> Hartmut Wolf So you think SequenceHold is the explanation? Let's see if it >has any relation >to my example. > Well, yes, I thought so, and still do. Proceeding analytically, let's just make a more simple example, a model, which has less complications than the operational semantics of Set. For that I define some pseudoSet with an operator that is free for user definition, but has the same grouping properties as Set, I take RightTee: In[16]:= Clear[a, b, c] In[17]:= Attributes[RightTee] = {HoldFirst, SequenceHold}; In[18]:= RightTee[a_, b_, c___] := Print[lhs: , HoldComplete[a], [RightTee] rhs: , HoldComplete[b], , HoldComplete[c]] In[19]:= a [RightTee] Sequence[b, c] lhs: HoldComplete[a] [RightTee] rhs: HoldComplete[Sequence[b, c]], HoldComplete[] In[20]:= a [RightTee] b [RightTee] c lhs: HoldComplete[b] [RightTee] rhs: HoldComplete[c], HoldComplete[] lhs: HoldComplete[a] [RightTee] rhs: HoldComplete[Null], HoldComplete[] This is a consequence of the grouping properties (right associative) the result of the rightmost assignment (value of b Null) is assigned to a In[21]:= Sequence[a, b] [RightTee] c lhs: HoldComplete[Sequence[a, b]] [RightTee] rhs: HoldComplete[c], HoldComplete[] In[55]:= RightTee[a, b, c] lhs: HoldComplete[a] [RightTee] rhs: HoldComplete[b], HoldComplete[c] Here you see clearly see how slots are filled and SequenceHold is in fact Now we clear the SequenceHold attribute: In[22]:= ClearAttributes[RightTee, SequenceHold] In[23]:= a [RightTee] Sequence[b, c] lhs: HoldComplete[a] [RightTee] rhs: HoldComplete[b], HoldComplete[c] In[24]:= Sequence[a, b] [RightTee] c lhs: HoldComplete[a] [RightTee] rhs: HoldComplete[b], HoldComplete[c] This is the same as the previous result, such also quite different from the corresponding expression with the SequenceHold attribute. (I continue below) >First assignment: L[[1]]=Sequence[1,1], or >Set[Part[L,1],Sequence[1,1]]. >SequenceHold simply determines that it is not converted to >Set[Part[L,1],1,1]. >Curiously enough, in this case it doesn't make any difference, >since the latter >evaluates exactly the same way. Second assignment: L[[2]]=2, or Set[Part[L,2],2]. Here L is >not evaluated >(because assigment treats Part in a special way -- if there >were another >non-holding function instead of Part, L would be evaluated), >so there's simply >no Sequence objects here and SequenceHold can't have any effect. So references to SequenceHold here are just fancy words -- remove the >SequenceHold attribute of Set and verify that the result will >be exactly the >same. The evaluation rules just don't say anything explicitly about >how assignments >should be performed for parts of lists like {Sequence[1,1],0} >(that is, after I >assign a Sequence object to one of the list elements). The >current approach has >its logic too, but it can be misleading, for example, >L[[Length@L]]=elem may >result in an error. Maxim Rytin This of course is not all of Set. Just repeated: In[37]:= Clear[a, b, c] In[38]:= a = Sequence[b, c] Out[38]= Sequence[b, c] In[39]:= ?a Global`a a = Sequence[b, c] In[40]:= ?b Global`b In[41]:= Clear[a, b, c] In[42]:= a = b = c Out[42]= c In[43]:= ?a Global`a a = c In[44]:= ?b Global`b b = c In[45]:= Clear[a, b, c] In[46]:= Sequence[a, b] = c Set::write: Tag Sequence in HoldForm[a, b] is Protected. Out[46]= c In[47]:= ?a Global`a Now In[49]:= Clear[a, b, c] In[50]:= Set[a, b, c] Out[50]= Sequence[b, c] This result clearly has nothing to do with SequenceHold, and (as you might see from the pseudoassignment this is *not* reached as intermediary from In[38], it just happens to give the same result). Now, anyways, Set is a proper form of the language, and certainly lies at the heart of the implementation, and certainly it must be performance In[38] and In[42], has no semantics. Instead of an error, it shows this behaviour, is tolerant, but you have to ask the implementor (God himself), why this is so. (My guess is: just to bypass parts from the evaluation loop for Set, hence in reality the were no attributes for Set, as there are no (explicit) UpValues for Part, all this presumably would be hardwired at a low level. Perhaps) In[51]:= ?a Global`a a = Sequence[b, c] In[52]:= ?b Global`b Let's look again at your first question: >> In[32]:= L = {0, 0}; >> L[[1]] = Sequence[1, 1]; >> L[[2]] = 2; >> L[[2]] >> Out[35]= 1 >> In[36]:= ?L >> Global`L >> L = {Sequence[1, 1], 2} We certainly agree that after the second assignment L[[1]]= Sequence[1,1] has the value {Sequence[1,1], 0}, (it would have the same value after the assignment Set[L[[1]],1,1], but that is, as shown, a different story). Now why does L[[2]] = 2, overwrite that 0, and not the second 1 from Sequence[1,1]? This simply is because of the HoldFirst property of Set (such L ist *not* evaluated, does *not* result to {1, 1, 0}[[2]] at lhs, and as a special form behaves like an Upvalue for Part just redefining the second slot, and leaving everthing else untouched (of course, we might say), hence the result. Contrary to that, L = L evaluates L at rhs to {1, 1, 0}, this then is assigned to the symbol L completely overwriting its previous value. Thereafter L[[2]]=2 of course results in {1, 2, 0} Whereas in L[[2]], when evaluated, L first results in {1,1,2}, and {1,1,2}[[2]] then in turn gives 1 (and not 2). You may detect more (seemingly) strange behaviour for Set, as (if e.g. matrix A is properly set up) A[[1, 1]] = something gives a correct assignment, whereas A[[1]][[1]] = something doesn't. This also is due to HoldFirst and the UpValue behaviour for Part. All this, after you respect the Attributes (you always have to), and consider the needs for an efficient implementation, is not very surprising. Perhaps we may regret that WRI is a bit reserved on these and similar questions, but this should not become a problem of usage. My advice was, and is: avoid that! (because, as said, it's outside of the programming language specification and semantics). -- Hartmut Wolf ==== Here is something mysterious: --> 3233692799 -->{2002, 6, 21, 23, 59, 59} Ähm, 2002=2000 ...??? Is this only on my computer? Why? Platform: Windows Hmm, I'm thankful for any suggestions to deal with this. marko ==== Greetings. This is my first question: I am trying to form a 4-tensor, H, whose (i,j,k,l) components are given by H(i,j,k,l) = M(i,j)A(k,l) where M and A are 2-Tensors (Matrices). This is what I have been doing so far: L1 = Array[M, {3, 3}] L2 = Array[A,{3,3}] H = Table[L1[i,j]*L2[k,l] {i,3},{j,3},{k,3},{l,3}] The last statement gives a long output, but not the the correct result. I want to be able to say H[[1,3,2,1]] and get M[1,3]A[2,1] as output. Can someone familiar with tensor manipulation in Mathematica tell me how to do this ? ------------- This is my second question: I want to assign a matrix, A, that has three rows and three columns and each element is identified by A[i,j] L1 = Array[A,{3,3}] works, but the array is called L and not A. I tried A = Array[A,{3,3}] and that, as expected, gave me a warning about recursions. Ashok ==== Jean-Michel Collard a .8ecrit dans le message de > Can someone explain me this particular behavior : x+I*y /. I -> -I x-I y (* ok *) > 3+I /. I-> -I 3+I (* ????? false *) > J.-M. > Ce qui peut .90tre fait : 3+I /. 3+I->3-I On obtient 3-I Question : existe-t-il un forum Mathematica en fran.8dais Merci Jean Pellegri ==== Background: I've read the early NETLink docs, as well as the JavaLink docs. I am familiar with modern OO environments [Eiffel, Java, C++, Lisp/CLOS, ScriptX, Beta] and functional environments [Mathematica, Haskell, ML]. Question: Is it possible to COMPLETELY do .NET programming from within Mathematica? [And ultimately, to write an interactive .NET programming tool inside Mathematica, that would convert my mathematically-rigorous representation of algorithms into .NET code, that could be analyzed from Mathematica.] Never touch C#, yet accomplish the following: 1. Create new types (abstract interfaces) and new classes. The hard part: these must INHERIT from fundamental classes provided in the .NET Common Language Runtime (CLR). 2. Add methods to those classes. Ambiguous whether I mean that the methods are running on Mathematica Ideally, some methods would be on one, some on the other -- that is, during debugging, could replace a NET/MSIL method with a callback into Math'a. [Obscure Tech Details: CLR's Profiler interface has logic to force a method to be re-JIT'ed, and a hook by which a program could supply a new Sequence of CLR byte-codes as the method body; use this to inject a callback into Math'a, with some unique identifier to indicate WHICH method is being called...] 3. Create new objects, query and change the fields on those objects. Yes, This is what NET/Link provides. 4. Managing references to NET objects. Yes, KeepNETObject and ReleaseNETObject. Question: If one has one NET object (A), that refers to other NET objects, is it sufficient to Keep/Release A? In particular, consider an A that is a collection of objects that are used by a given document or computation - I would create and Keep an empty A as each document is opened; that A would be filled as the document details are read in / or as a user creates them; when that document is closed I would Release A - I don't want to have to manage any other references but that one. NOTE: Can't use NETBlock, because the document lives in its own modeless window - multiple documents might be simultaneously open. - - - - - In summary, I have questions about Mathematica as a .NET programming environment; (3) will surely be covered well by documentation as it is created, but that is only the tip of what a .NET programmer can do - kind of like Visual Basic before .NET came along - Object-Oriented in the limited sense of making method calls on existing classes, but not a real O-O environment, because couldn't create -and inherit- new classes; cannot extend a concept by subclassing it; no notion of abstract types (Interfaces). if NET/Link makes Mathematica capable of more than that, then I would love to see examples of how to do so! -- ToolmakerSteve ==== The basic Mathematica system requires a list format for making matrix entries which is more cumbersome and harder to understand than some other system's notation. Has anyone written a Mathematica Method to simplify matrix entry? Harold ==== I've discovered one potential solution to items (1) and (2) in my preceding message. URL: The .NET Code Document Object Model (CodeDOM) classes allow you to create assemblies on the fly. ... Good - maybe NETLink doesn't have to do anything special; just call these built-in NET classes to generate code. NOTE: doesn't do the most general case of (2), which is dynamic replacement of a method in a running assembly. But it is much simpler than tackling the general case, which involves the .NET Profiling API. URL: http://msdn.microsoft.com/msdnmag/issues/03/09/NETProfilingAPI/ Time permitting, I'll experiment with the CodeDOM approach, and provide a NETLink example. -- ToolmakerSteve ==== My most disastrous presentation began when I arrived a comfortable 20 minutes early to test my Toshiba (windows) portable with an unknown projector. I just got my first opening mathematica slide on the screen looking good when someone came running in yelling that he had to test his laptop, right now, as he was the first speaker of the session. Of course after much fiddling to get this guy hooked up, it turned out he was in the wrong room, and it was now show time for me. Having projected my title slide perfectly I had no inkling that trouble was brewing. My text and equations projected fine, but the graphics (containing all my nice animated results) were displayed as empty boxes, which greatly impressed the audience. The next day, I returned to the lecture hall and reverse engineered the situation and found that had I not panicked, one more press of the function key F5 would have caused it to try another resolution/refresh rate that would have enabled the projector to synch the graphics and the text. So the moral of the story is your rehearsal should include the entire show, or failing that, at least slides that contain both text and graphics, and when all else fails toggle your laptop's external monitor function key (probably F5). PS. the zoom button on the bottom left corner (of most notebooks by default ) (or the Format, Magnification menu item) is great for last minute resizing in response to complaints from the back row. Christopher Purcell Sensors & Actuators Group DRDC-Atlantic, 9 Grove St., PO Box 1012, Dartmouth NS B2Y 3Z7 Canada > I make a slide show using Mathematica and the Mathematica Slide Show > palette > on my laptop at home. > I then fly with my laptop to the other side of the world, plug into the > projection system and attempt to show my presentation. The problems > 1. How do I ensure that my presentation will fit the screen? > 2. How do I know what font size to use when making the presentation? > 3. How do I stop myself putting too many lines on a slide when > constructing > the slide? > 4. How do I stop myself making graphics that are too wide or too tall? In general how do I know that when I make my presentation it will be > the > same size as the screen onto which it is projected and not either a > postage > stamp size or too big for the screen? Microsoft PowerPoint is good at giving you a preview and then mapping > the > slide you have made into the projection system (but a disaster with > equations). Mathematica does not enable you to do this. The only rule for making slides, I know, is that you can have a > maximum of > ten lines per slide. I can vary the following: My font size. Note difficulty with text in graphics. > My screen area - using the Windows Control Panel / Display Properties / > Screen Area (typical size 1024 by 768). > The size of the notebook - bottom bar of window. Should I use the Mathematica SlideShow environment or is the > Mathematica > Presentation environment better? What approach should I take if I am not to have a presentation > disaster? > Hugh Goyder ==== > I'm just a beginner with Mathematica and I'd like to > know if it's possible to plot the parabola x=y^2 in > the range -10 to 10. I'm trying using y=Sqrt[x] but > that doesn't work for negative x. Probably the simplest way to do this is to use ParametricPlot as in ParametricPlot[{t^2, t}, {t, -10, 10}]; -- ==== I've decided to try and learn how to use TeX. When I converted a notebook to LaTeX I continually got !Undefined control sequence messages whenever and alignment marker occurred in the original notebook. Also capital E was converted as small e. This is all done using V5 on Mac OS X.3 teTeX and TeXshop. The solution is probably very obvious but thanks for your patience. Mike ==== I get a problem that I have to write a friendly GUI users_form for a difficult mathematica file (nb file) that was written by some one else. Can I just call Mathematica 4.0 kernel to open a nb_file and calculate the result using DLL method or OLE method?? I try to understand what mathlink is for...... Is mathlink can do my job??? is it only for using that C source code to be calculated in mathematica?? ==== *when* will you learn the syntax of a While[] function. In any other programming language it is a very bad practice to have tests with side effects. If you use the correct version of While[] with a comma Compile[{}, Module[{cnt = 0}, While[cnt < 1, cnt++]; cnt]][] and Compile[{}, Module[{cnt}, Do[cnt = 0; While[cnt < 1, cnt++], {10^5}]; 0]][] // Timing you will see that the results are correct *and* compile is faster. I agree with you that the behaviour of While[] in you examples is a bug because the Mathematica compiler will save the changed variable in the While[] test on the stack and restore it. How ever in Mathematicas programming language (where you can define function on fly) it is not always sure when the compiler has to use a stack ... Jens >-----Original Message----- >Sent: Wednesday, December 10, 2003 10:02 AM >To: mathgroup@smc.vnet.net > >Consider > >In[1]:= >Compile[{}, > Module[{x=0}, > While[ > x++; > EvenQ[x] > ]; > x > ] >][] > >Out[1]= >3 > >incorrect. The more I think about this wonderful sentence from Compile >reference -- The number of times and the order in which objects are >evaluated by Compile may be different from ordinary >Mathematica code -- >the less I understand it. It can mean that if compiled evaluation fails >at some point, Mathematica stops and starts over with the >ordinary code. >But equally well it can be interpreted to mean that Compile may ignore >all the rules of the standard evaluator, including operators precedence >order. > >Of course, in a sense Compile is still in the development stage; for >instance, I don't like the fact that Do[0,{i,1},{j,i,1}] cannot be >compiled because of i in the second iterator, but in this case >Mathematica just gives a message, reverts to uncompiled >evaluation and I >can see what is going on, while if an expression is compiled and >evaluated differently from uncompiled version, I'm at a loss what went >wrong. > >Actually restarting the evaluation can be quite confusing too, >since you >can't tell at which point Mathematica begins the re-evaluation using >uncompiled code, so if the code has side effects then the result is >unpredictable, as in the example below: > >In[1]:= >Module[{L={}}, > Compile[{}, > AppendTo[L,{1}]; > AppendTo[L,{2}]; > Append[L,{3}]; > AppendTo[L,{3}]; > L > ][] >] > >Compile::cpts: The result after evaluating Insert[L$11, {3}, -1] > should be a tensor. Non-tensor lists are not supported at present; >evaluation will > proceed with the uncompiled function. > >CompiledFunction::cfse: Compiled expression {{1}, {2}} should be a >machine-size real number. > >CompiledFunction::cfex: > External evaluation error at instruction 4; proceeding with >uncompiled evaluation. > >Out[1]= {{1}, {2}, {1}, {2}, {3}} > >Maxim Rytin > > Compile translates a subset of Mathematica to intermediate code for virtual > machine which definitely is different from the Mathematica Interpreter, such > unavoidably different results will come up. This is not conceiled from WRI. > Instead, run-time will shorten for problems suitable to compilation. Such code to be Compiled has, in a sense, to be regarded as a different > language: the syntax is not quite the same, nor the semantics. So code which > is interpreted, has yet to be debugged for Compile (which, for shure, often > is not quite such easy!). And after it compiles, not not to be forgotten: > checked for correctness (in the Range of intented application)! You just > can't leave that out, as you cannot for C, Fortran, ..., whatever, and no > one would complain. If I do that with your code, I get: In[5]:= > Compile[{}, Module[{x = 0}, While[x++; > EvenQ[x],]; > x]][] Out[5]= 1 and In[26]:= > Module[{Llama = {}}, Compile[{{L, _Integer, 2}}, AppendTo[L, {1}]; > AppendTo[L, {2}]; > Append[L, {3}]; > AppendTo[L, {3}]; > L][Unevaluated[Llama]]] CompiledFunction::cfta: Argument !(Llama$27) at position !(1) > should > be a rank !(2) tensor of !(machine-size integer)s. Out[26]= {{1}, {2}, {3}} Both results are correct, although, the second example is far off the > specification of Compile! -- > Hartmut Wolf run-time will shorten? As in an old joke, allows you to get incorrect > results faster? (Incorrect in the sense of the uncompiled While semantics, of > course). Actually if you do run some tests, you will see that one-argument While > can take more time compiled than uncompiled: In[1]:= > Module[{cnt}, > Do[cnt = 0; While[cnt++; cnt < 1], {10^5}]; 0 > ] // Timing Out[1]= > {1.813 Second, 0} In[2]:= > Compile[{}, > Module[{cnt}, > Do[cnt = 0; While[cnt++; cnt < 1], {10^5}]; 0 > ]][] // Timing Out[2]= > {10.015 Second, 0} What is really important is this: suppose I give you two examples and ask you > how they'll work: Compile[{}, > Module[{cnt = 0}, > While[cnt++; cnt < 1]; cnt > ] > ][] and Compile[{}, > Module[{cnt = -1}, > While[cnt++; cnt < 1]; cnt > ] > ][] It's impossible to answer without running both examples and learning about this > quirk in the While evaluation. I don't know what you mean in your message by > debugged for Compile and checked for correctness, but are you sure that's > how you're supposed to learn a programming language? I know that While[cond] > will evaluate this way when compiled and While[cond,body] will evaluate that way > because I tried it? Sorry, that's ridiculous. Try looking at the bigger picture -- suppose you have to develop a large > application (and then have to locate such glitches in thousands lines of code). > How can you > be sure that something else but similar won't come up? As to the second example, I'm saying that in case of side effects result will be > unpredictable and you give me an example without side effects. Okay...I guess. Maxim Rytin ==== your irregular domain is a typical application for a finite element program you should use this method because NDSolve[] will not do that for you. Jens I would like to solve membrane oscillation between two square shaped fixed boundaries > with NDSolve. > D[u[x, y, t], {t, 2}] == D[u[x, y, t], {x, 2}] + D[u[x, y, t], {y, 2}] + f[x, y, t], > where f is an external force. The boundary condition for the outside square is given by > u[x, -1, t] == 0, u[x, 1, t] == 0, u[-1, y, t] == 0, u[1, y, t] == 0. How can I give the boundary condition for the square inside? I tried > If[y>-0.5 && y<0.5, u[0.5, y, t]==0] etc. but this didn't work. Masu ==== 2.)Your membrane pde is of elliptic type. Then theory says that for > elliptic pde ONLY ONE boundary can be given except you place a > singularity within the center of the inner boundary domain. Well, could you tell me the more detail. Physically, it is possible to > make a membrane between two squares and it is also possible to have it > vibrate. The boundary condition can be more than two. The problem is that NDSolve cannot solve problems with 2 different boundary conditions for an elliptic pde. Sure, it is however possible to solve such problems using other numerical methods, like boundary element method, finite element method, collocation methods. >3.)Your problem has been solved and published, see below: >page 263, chapter 5.2, Boundary problems with two closed boundaries > You are correct. My example did not use NDSolve. Since I told you that NDSolve cannot work for 2 boundaries, I just wanted to give you an example how to use collocation methods to solve such problems. More details are in my book >1.)NDSolve is not well suited to solve part de. It can do this for >very few pde. Combined with 3), can I understand that it is impossible to impose > two boundary condition in NDSolve? Yes, you may assume that it is impossible to impose two boundary conditions in NDSolve !! To solve the problem you may use either : 1)numerical integration using finite differences or finite elements or collocation methods 2) assume a closed expression with many unknown parameters and include a singularity in the center of the inner domain. Since Cartesian solution of the membrane equation has singularities only in the infinity point, it may be usefull to solve the problem in polar coordinates and write up a Bessel function solution, see the example in codes 44,45,46, and 47. Due to the Bessel function Y one then has a singularity at the origin and one may use outer collocation methods. Your problem is interesting and I will try to have time and solve it. May be you hear from me within several days. Greetings to your wonderful country (I have been there as Guestprofessor in Sendai, Kyoto and > Yama Masu