A26 ==== f[c] == (c+b)/.ru[c] == (c+b)/.c->x == x+b == b+xBobby Treat-----Original Message-----f[c] = b+c?What gives?Lawrence-- Lawrence A. Walker Jr.http://www.kingshonor.com ==== Sorry; disregard my earlier answer. ru[c] isn't defined, so thatobviously wasn't the correct sequence of events. Here's the right one:f[c] == HoldPattern[(a+b)/.ru[a]]/.x->c == (a+b)/.ru[a] == (a+b)/.a->x == x + b == b + xThe substitution of c for x occurs before the rule ru[a] is evaluated,so there's no x in the expression to replace. Instead, there's an Ôa'to replace with x.If the other sequence had been correct, you have no rule for evaluatingru[c], so it would have remained just that -- ru[c]. When the kerneltried to apply it as a rule to (a+b), there would have been an error.That didn't happen, so that wasn't the sequence of events.Bobby Treat-----Original Message-----f[c] = b+c?What gives?Lawrence-- Lawrence A. Walker Jr.http://www.kingshonor.com ==== You really should read about the difference between := (SetDelayed) and = (Set).When you enter your definitionf[x_]:=(a+b) /. ru[a]the right hand side is not evaluated. So next when you evaluate f[c] you get(a+b)/.ru[a] and only now ru[a] is evaluated, thus giving you (a+b)/.a->x which is b+xThere are several ways to get what you want. One is to use = instead of :=, another to force evaluation of the right hand side withf[x_]:=Evaluate[(a+b) /. ru[a]]yet another to insert the actual rule in the definition of f:f[x_]:=(a+b) /. a->xAndrzej KozlowskiToyama International UniversityJAPANOn Wednesday, September 25, 2002, at 02:50 PM, Lawrence A. Walker Jr. > For the life of me I am not sure why the following is not working in my> v. 4.2:> ru[a]=a->x;> f[x_]:=(a+b) /. ru[a];> Why do I get> f[c] = b+x> and not> f[c] = b+c?> What gives?> Lawrence> -- > Lawrence A. Walker Jr.> http://www.kingshonor.com ==== Well,I have written the following notebook with MathematicaIn[78]:=a=Sqrt[4*Pi/Sqrt[3]]In[79]:=fcom[k_,mu_]:= (( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*(1-Exp[-I*k*(a-mu)])/( I*k)+ Exp[-I*mu*2* Pi/a]*((1-Exp[-I*(k+2*Pi/a)*(a-mu)])/(I*(k+2*Pi/a))+( 1-Exp[-I*(k-2*Pi/a)*(a-mu)])/(I*(k-2*Pi/a)))+ Exp[-I*mu*4* Pi/a]*((1-Exp[-I*(k+4*Pi/a)*(a-mu)])/(I*(k+4*Pi/a))+( 1-Exp[-I*(k+2*Pi/a)*(a-mu)])/(I*(k+2*Pi/a)))+( 1-Exp[-I*(k-2*Pi/a)*(a-mu)])/(I*(k-2*Pi/a))+( 1-Exp[-I*(k-4*Pi/a)*(a-mu)])/(I*(k-4*Pi/a)))/(3*a)In[80]:=f0[ k_,mu_]:=((1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*(a-mu)+ Exp[-I*mu*2* Pi/a]*((1-Exp[-I*2*Pi/a*(a-mu)])/(I*(2*Pi/a))+( 1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a)))+ Exp[-I*mu*4* Pi/a]*((1-Exp[-I*(4*Pi/a)*(a-mu)])/(I*(4*Pi/a))+( 1-Exp[-I*(2*Pi/a)*(a-mu)])/(I*(2*Pi/a)))+( 1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a))+( 1-Exp[-I*(-4*Pi/a)*(a-mu)])/(I*(-4*Pi/a)))/(3*a)In[81]:=fp1[k _,mu_]:=(( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*(1-Exp[-I*2*Pi/a*(a-mu )])/( I*2*Pi/a)+ Exp[-I*mu*2*Pi/a]*((1-Exp[-I*(4*Pi/a)*(a-mu)])/(I*(4*Pi/a))+( a-mu))+ Exp[-I*mu*4* Pi/a]*((1-Exp[-I*(6*Pi/a)*(a-mu)])/(I*(6*Pi/a))+( 1-Exp[-I*(4*Pi/a)*(a-mu)])/(I*(4*Pi/a)))+( a-mu)+(1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a)))/(3*a)In[82] :=fm1[k_,mu_]:=(( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*( 1-Exp[I*2*Pi/a*(a-mu)])/(-I*2*Pi/a)+ Exp[-I*mu*2*Pi/a]*((a-mu)+(1-Exp[-I*(-4*Pi/a)*(a-mu)])/(I*(-4 *Pi/a)))+ Exp[-I*mu*4*Pi/a]*((1-Exp[-I*(2*Pi/a)*(a-mu)])/(I*(2*Pi/a))+( a-mu))+( 1-Exp[-I*(-4*Pi/a)*(a-mu)])/(I*(-4*Pi/a))+( 1-Exp[-I*(-6*Pi/a)*(a-mu)])/(I*(-6*Pi/a)))/(3*a)In[83]:=fp2[k _,mu_]:=(( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*(1-Exp[-I*4*Pi/a*(a-mu )])/( I*4*Pi/a)+ Exp[-I*mu*2* Pi/a]*((1-Exp[-I*(6*Pi/a)*(a-mu)])/(I*(6*Pi/a))+(1-Exp[-I*( 2*Pi/a)*(a-mu)])/(I*(2*Pi/a)))+ Exp[-I*mu*4* Pi/a]*((1-Exp[-I*(8*Pi/a)*(a-mu)])/(I*(8*Pi/a))+( 1-Exp[-I*(6*Pi/a)*(a-mu)])/(I*(6*Pi/a)))+( 1-Exp[-I*(2*Pi/a)*(a-mu)])/(I*(2*Pi/a))+(a-mu))/(3*a)In[84]:= fm2[k_,mu_]:=(( 1+Exp[-I*mu*2*Pi/a]+Exp[-I*mu*4*Pi/a])*( 1-Exp[I*4*Pi/a*(a-mu)])/(-I*4*Pi/a)+ Exp[-I*mu*2* Pi/a]*((1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a))+( 1-Exp[-I*(-6*Pi/a)*(a-mu)])/(I*(-6*Pi/a)))+ Exp[-I*mu*4* Pi/a]*((a-mu)+(1-Exp[-I*(-2*Pi/a)*(a-mu)])/(I*(-2*Pi/a)))+( 1-Exp[-I*(-6*Pi/a)*(a-mu)])/(I*(-6*Pi/a))+( 1-Exp[-I*(-8*Pi/a)*(a-mu)])/(I*(-8*Pi/a)))/(3*a)In[85]:=Lp[0| N[0],mu_]:=f0[0,mu]In[86]:=Lp[2*Pi/a|N[2*Pi/a],mu_]:=fp1[2*Pi /a,mu]In[87]:=Lp[-2*Pi/a|-N[2*Pi/a],mu_]:=fm1[2*Pi/a,mu]In[88 ]:=Lp[4*Pi/a|N[4*Pi/a],mu_]:=fp2[4*Pi/a,mu]In[89]:=Lp[-4*Pi/a |-N[4*Pi/a],mu_]:=fm2[-4*Pi/a,mu]In[90]:=Lp[k_,mu_]:=fcom[k, mu]In[91]:=Ll[k_,mu_]:=0/;mu>=aIn[92]:=Ll[k_,mu_]:=0/;mu<=- aIn[93]:=Ll[k_,mu_]:=Lp[k,mu]/;0<=muMonteCarlo,MaxPoints->100000000,Compiled->False]but this is not enough to ensure convergence of the integration. Notice that I have inserted some points in the integration path in order to avoid problems with numerical divergences which Mathematica detects in fcom[k,mu] (but these divergences do not really exist, analitically) Does somebody has a smart suggestion to perform this computation?Fabio ==== =In a presentation I wish to use Plot to generate a sequence of frames andthen animate them. The problem is that the audience sees the animationtwice. Once when the frames are being generated and then again after I haveclosed the group and double clicked on the top graphic. However, the firstshowing during generation is enough (but uncontrolled). Is it possible to tidy up the generation of the graphic so that it becomesthe animation?I have tried the followingDo[Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}},ImageSize -> 400]; SelectionMove[EvaluationNotebook[], All, GeneratedCell];FrontEndExecute[{FrontEnd`SelectionAnimate[0.1 ]}]; FrontEndExecute[{FrontEndToken[Clear]}], {t, 0, 15, 0.1}]This works but the cell dividing line ßashes on and off spoiling theanimation and if there is anything in the cell below this jumps up and down.Is there a proper way of doing this?Hugh Goyder ==== =I need to program the following recursion scheme for time seriesforecasting (The Innovation Algorithm).I will write it in pseudo-Mathematica notation. K is the given m x mautocovariance (numerical) matrix of the processv[0] = K[[1,1]];H[n,n-k] = (v[k])^(-1) (K[[n+1,k+1]] - Sum[(H[k,k-j] H[n,n-j] v[j]),{j,0,k-}]) for k=0,1,...,n-1v[n] = K[[n+1,n+1]] -Sum[(H[n,n-j])^2 v[j],{j,0,n-1}]The scheme should be solved in the order v[0], H[1,1], v[1], H[2,2],H[2,1], v[2], H[3,3], H[3,2], H[3,1], ...I have already tried to program it in a straght-forward way, but ashave no experience with recursive functions with two variables, itdoesn't seem to work properly and is also very slow. Any help would beRobertReply-To: murray@math.umass.edu ==== =I don't understand the problem. Say I enter the 2D form for the reciprocal of the square root of a^2 + b^2, but I enter it in Standard Form (i.e., using the Control key with / to form the fraction, and the Control key with 2 to get the square root symbol).If then I click anywhere within the subexpression inside the square root, then with 2 to three clicks the entire expression under the square root will be highlighted. I can then do a copy-and-paste to put that into any cell, in the usual way -- with keyboard key combinations, right-click context menu, or Mathematica Edit menu.Isn't that GUI enough?Would you REALLY want to be able to DRAG the highlighted expression to a new place? Think of how much of a mess this could cause through inadvertent movement of the mouse after highlighting some subexpression. In fact, I hate Microsoft Word's doing just that!>>I'm a poor physicist trying to figure out how to sort out the>>physical from the non-physical solutions to a problem. To do>>that, I need to be able to look at an expression and pick out a>>subexpression, the part under the radical.> GRAY:> This points up the need, which I've been aware of for years, to be> able to select any part of an expression and drag it to a new line for> further processing. Mathematica and the other CAS I'm familiar with are still> pretty much stuck with a command line interface. They need a true> GUI with extensive interaction.> When I can see on the screen exactly what I want to do, why> should I have to type a bunch of stuff in to access what I want?> Maybe we'll see this in version 5? 6? Never?> -- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375 ==== => I'm a poor physicist trying to figure out how to sort out the> physical from the non-physical solutions to a problem. To do> that, I need to be able to look at an expression and pick out a> subexpression, the part under the radical.GRAY: This points up the need, which I've been aware of for years, to beable to select any part of an expression and drag it to a new line forfurther processing. Mathematica and the other CAS I'm familiar with are stillpretty much stuck with a command line interface. They need a trueGUI with extensive interaction. When I can see on the screen exactly what I want to do, whyshould I have to type a bunch of stuff in to access what I want? Maybe we'll see this in version 5? 6? Never?Reply-To: murray@math.umass.edu ==== =I get the same result in 4.2 (under Windows). Not sure why. But you could try this modification: PlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur]; Pause[dur], {i, Length[L]}]Then PlaySeq[{224, 256, 384}, 3]seems to work as expected, prolonging the notes before the last one to their full expected duration.> PlayTone[F_, dur_] := Play[Sin[2*Pi*F*t], {t, 0, dur}]> allows me to play a sine wave of frequency F and duration dur> PlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur], {i, Length[L]}]> should allow me to play a sequence of tones> with a given list of frequencies L> and all the same duration dur.> It does not work at least in 4.1> all tones but the last one are much shorter than dur.> any help?> -- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375 ==== =this is almost the solution.but it creates some artificial rests.when the sounds are created, there is some silence between the different notes.when after creation one clicks the play sound icon of the group with all the sounds, these rests disappear.is there a way of Play creating ghte waves, but NOT playing them,and then, doubleclicking the sound icon,hearing the sound without rests immediately?> I get the same result in 4.2 (under Windows). Not sure why. But you > could try this modification:> PlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur];> Pause[dur], {i, Length[L]}]> Then> PlaySeq[{224, 256, 384}, 3]> seems to work as expected, prolonging the notes before the last one to > their full expected duration.>>PlayTone[F_, dur_] := Play[Sin[2*Pi*F*t], {t, 0, dur}]>>allows me to play a sine wave of frequency F and duration dur>>PlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur], {i, Length[L]}]>>should allow me to play a sequence of tones>>with a given list of frequencies L>>and all the same duration dur.>>It does not work at least in 4.1>>all tones but the last one are much shorter than dur.>>any help?> -- --Erich Neuwirth, Computer Supported Didactics Working GroupVisit our SunSITE at http://sunsite.univie.ac.at ==== =PlayTone[F_, dur_] := Play[Sin[2*Pi*F*t], {t, 0, dur}]allows me to play a sine wave of frequency F and duration durPlaySeq[L_, dur_] := Do[PlayTone[L[[i]], dur], {i, Length[L]}]should allow me to play a sequence of toneswith a given list of frequencies Land all the same duration dur.It does not work at least in 4.1all tones but the last one are much shorter than dur.any help?-- --Erich Neuwirth, Computer Supported Didactics Working GroupVisit our SunSITE at http://sunsite.univie.ac.at ==== =using Set (=) instead of SetDelayed (:=) in f[x_]:=(a+b) /. ru[a]; will give you what you desire.Matthias Bode.-----Ursprí.b9ngliche Nachricht-----Gesendet: Mittwoch, 25. September 2002 07:51An: mathgroup@smc.vnet.netBetreff: Strange ReplaceAll behaviorFor the life of me I am not sure why the following is not working in my v. 4.2:ru[a]=a->x;f[x_]:=(a+b) /. ru[a];Why do I getf[c] = b+xand notf[c] = b+c?What gives?Lawrence-- Lawrence A. Walker Jr.http://www.kingshonor.com ==== =If you want to do it with the mouse, it's not that difficult. I clickwithin the part I want and double-click until the part is selected.(Each double-click expands the selection by one level of nesting.) Thenpush Ctrl-C, click where you want to put the result, and push Ctrl-V.Does that help any?Bobby-----Original Message-----able to select any part of an expression and drag it to a new line forfurther processing. Mathematica and the other CAS I'm familiar with arestillpretty much stuck with a command line interface. They need a trueGUI with extensive interaction. When I can see on the screen exactly what I want to do, whyshould I have to type a bunch of stuff in to access what I want? Maybe we'll see this in version 5? 6? Never? ==== =I met a critical problem for running Mathematica 4.1 on MacOS X 10.2.(OSX native version) I hope such a problem is suitable to be posted tothis ML.What happens is the following. When Mathematica 4.1 installed in HDDis started, a window quickly appears saying that A serious error has occured while Mathematica was starting up. Mathematica will probably not function properly until this problem is resolved. ... The Mathematica fonts are not properly installed in your system. Without these fonts, typeset mathematical expressions cannot be displayed properly.This message is correct. If I chose Continue Anyway, mathematicalexpressins are totally broken.What is strange is that when I start Mathematica 4.1 by double clickingMathematica in CDROM, it works without any problem. Further more,Once Mathematica 4.1 is correctly started in this way, I can restart Mathematicadirectly from double clicking Mathematica in HDD, which is the installed one.Once CDROM is ejected, the error appears again.It is clearly font related problem but I do not know how to solve. If someoneknow how to manage, please let me know.-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-I met a critical problem for running Mathematica 4.1 on MacOS X 10.2.(OSX native version) I hope such a problem is suitable to be posted tothis ML.What happens is the following. When Mathematica 4.1installed in HDDis started, a window quickly appears saying that A serious error has occured while Mathematica was starting up. Mathematica will probably not function properly until this problem is resolved. ... The Mathematica fonts are not properly installed in your system. Without these fonts, typeset mathematical expressions cannot be displayed properly.This message is correct. If I chose Continue Anyway, mathematicalexpressins are totally broken.What is strange is that when I start Mathematica 4.1 by double clickingMathematica in CDROM, it works without any problem. Further more,Once Mathematica 4.1 is correctly started in this way, I can restartMathematicadirectly from double clicking Mathematica in HDD, which is theinstalled one.Once CDROM is ejected, the error appears again.It is clearly font related problem but I do not know how to solve. Ifsomeoneknow how to manage, please let me know.-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--- Apple-Mail-2-977368608-- ==== =Toshinao,Try reinstalling Mathematica from the CD.---Selwyn Hollis> I met a critical problem for running Mathematica 4.1 on MacOS X 10.2.> (OSX native version) I hope such a problem is suitable to be posted to> this ML.> What happens is the following. When Mathematica 4.1 installed in HDD> is started, a window quickly appears saying that> A serious error has occured while Mathematica was starting up.> Mathematica will probably not function properly until this problem is> resolved.> ...> The Mathematica fonts are not properly installed in your system.> Without these fonts, typeset mathematical expressions cannot be> displayed properly.> This message is correct. If I chose Continue Anyway, mathematical> expressins are totally broken.> What is strange is that when I start Mathematica 4.1 by double clicking> Mathematica in CDROM, it works without any problem. Further more,> Once Mathematica 4.1 is correctly started in this way, I can restart > Mathematica> directly from double clicking Mathematica in HDD, which is the > installed one.> Once CDROM is ejected, the error appears again.> It is clearly font related problem but I do not know how to solve. If > someone> know how to manage, please let me know.> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> I met a critical problem for running Mathematica 4.1 on MacOS X 10.2.> (OSX native version) I hope such a problem is suitable to be posted to> this ML.> What happens is the following. When Mathematica 4.1installed in HDD> is started, a window quickly appears saying that> A serious error has occured while Mathematica was starting up.> Mathematica will probably not function properly until this problem is> resolved.> ...> The Mathematica fonts are not properly installed in your system.> Without these fonts, typeset mathematical expressions cannot be> displayed properly.> This message is correct. If I chose Continue Anyway, mathematical> expressins are totally broken.> What is strange is that when I start Mathematica 4.1 by double clicking> Mathematica in CDROM, it works without any problem. Further more,> Once Mathematica 4.1 is correctly started in this way, I can restart> Mathematica> directly from double clicking Mathematica in HDD, which is the> installed one.> Once CDROM is ejected, the error appears again.> It is clearly font related problem but I do not know how to solve. If> someone> know how to manage, please let me know.> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-> --Apple-Mail-2-977368608--> ==== =The reason why InequalitySolve returns it's answer in what sometimes turns out to be unnecessarily complicated form is that the underlying algorithm, Cylindrical Agebraic Decomposition (CAD) returns its answers in this form. Unfortunately it seems to me unlikely that a simplification of the kind you need can be can be accomplished in any general way. To see why observe the following. First of all:In[1]:=FullSimplify[x > 0 || x == 0]Out[1]=x >= 0This is fine. However:In[2]:=FullSimplify[x > 0 && x < 2 || x == 0 && x < 2]Out[2]=x == 0 || 0 < x < 2Of course what you would like is simply 0 <= x < 2. One reason why you can't get it is that while Mathematica can perform a LogicalExpand, as in:In[3]:=LogicalExpand[(x > 0 || x == 0) && x < 2]Out[3]=x == 0 && x < 2 || x > 0 && x < 2There i no LogicalFactor or anything similar that would reverse what LogicalExpand does. if there was then you could perform the sort of simplifications you need for:In[4]:=FullSimplify[(x > 0 || x == 0) && x < 2]Out[4]=0 <= x < 2However, it does not seem to me very likely that such logical factoring can be performed by a general enough algorithm (though I am no expert in this field). In any case, certainly Mathematica can't do this.I also noticed that Mathematica seems unable to show that the answer it returns to your problem is actually equivalent to your simpler one. In fact this looks like a possible bug in Mathematica. Let's first try the function ImpliesQ from the Experimental context:<< Experimental`Now Mathematica correctly gives:In[6]:=ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[6]=TrueHowever:In[7]:=ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[7]=FalseThat simply means that ImpliesQ cannot show the implication, not that it does not hold. ImpliesQ relies on CAD, as does FullSimplify. Switching to FullSimplify we see that:In[8]:=FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[8]=TruewhileIn[9]:=FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[9]=y4 >= -1 && y6 <= y5 <= 1 + y4 + y6On the other hand, taking just the individual summands of Or as hypotheses;In[10]:=FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[10]=TrueIn[11]:=FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6 ]Out[11]=TrueIn fact FullSimplify is unable to use Or in assumptions, which can be demonstrated on an abstract example:In[12]:=FullSimplify[C,(A||B)&&(C)]Out[12]=TrueIn[13] :=FullSimplify[C,LogicalExpand[(A||B)&&(C)]]Out[13]=CThis could be fixed by modifying FullSimplify:In[14]:=Unprotect[FullSimplify];In[14]:= FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify[exp r,y]];In[15]:=Protect[FullSimplify];Now at least we get as before:In[16]:=FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[16]=Truebut also:In[17]:=FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6, y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]Out[17]=TrueThis seems to me a possible worthwhile improvement in FullSimplify, though of course not really helpful for your problem.Andrzej KozlowskiToyama International UniversityJAPAN> I have a set of inequalities that I solve with InequalitySolve. But > then> it gives a complete set of solutions, but not in the way I would like > it> to be! :-) For example, the simple following calculation will give:> In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6 >= > -1};> InequalitySolve[ineq,{y4,y6,y5}]> Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6> the result is good, but I would like it to be in the simpler but> equivalent form> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6> How can I tell InequalitySolve to do that? It is simple for this > example,> but for a large set of simple inequalities InequalitySolve gives lines > and> lines of results instead of a simple result.> Vincent Bouchard ==== = I have been trying to integrate the following : Integrate[Cosh[2 Abs[x-y]] 2 y, {y,0,1/2}, Assumptions->{Im[x]==0,x>0}] However, Mathematica chokes and simply returns the integral as it is. However, if I split up the integral into two portions, it quickly gives me an answer for the parts. Is there something implicit that I am missing in the Assumptions ?MS.-- 12:02am up 5:06, 1 user, load average: 0.54, 0.22, 0.08 ==== =The modification to FullSimplify that I sent earlier works correctly only for assumptions of the form Or[a,b] (and even then not is not always what one would like). For what it's worth here is a better (but slow) version:In[1]:=Unprotect[FullSimplify];In[2]:=FullSimplify[ expr_, x_ || y__] := FullSimplify[ FullSimplify[expr, x] || FullSimplify[expr, Or[y]]];In[3]:=Protect[FullSimplify];For example:In[4]:=FullSimplify[Sqrt[(x - 1)^2] + Sqrt[(x - 2)^2] + Sqrt[(x - 3)^2], x > 1 || x > 2 || x > 3]Out[4]=-1 + x + Abs[-3 + x] + Abs[-2 + x] || -3 + 2*x + Abs[-3 + x] || 3*(-2 + x)Andrzej KozlowskiToyama International UniversityJAPAN> The reason why InequalitySolve returns it's answer in what sometimes > turns out to be unnecessarily complicated form is that the underlying > algorithm, Cylindrical Agebraic Decomposition (CAD) returns its > answers in this form. Unfortunately it seems to me unlikely that a > simplification of the kind you need can be can be accomplished in any > general way. To see why observe the following. First of all:> In[1]:=> FullSimplify[x > 0 || x == 0]> Out[1]=> x >= 0> This is fine. However:> In[2]:=> FullSimplify[x > 0 && x < 2 || x == 0 && x < 2]> Out[2]=> x == 0 || 0 < x < 2> Of course what you would like is simply 0 <= x < 2. One reason why you > can't get it is that while Mathematica can perform a LogicalExpand, > as in:> In[3]:=> LogicalExpand[(x > 0 || x == 0) && x < 2]> Out[3]=> x == 0 && x < 2 || x > 0 && x < 2> There i no LogicalFactor or anything similar that would reverse what > LogicalExpand does. if there was then you could perform the sort of > simplifications you need for:> In[4]:=> FullSimplify[(x > 0 || x == 0) && x < 2]> Out[4]=> 0 <= x < 2> However, it does not seem to me very likely that such logical > factoring can be performed by a general enough algorithm (though I am > no expert in this field). In any case, certainly Mathematica can't do > this.> I also noticed that Mathematica seems unable to show that the answer > it returns to your problem is actually equivalent to your simpler one. > In fact this looks like a possible bug in Mathematica. Let's first try > the function ImpliesQ from the Experimental context:> << Experimental`> Now Mathematica correctly gives:> In[6]:=> ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 > <= 1 + y4 + y6]> Out[6]=> True> However:> In[7]:=> ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + > y4 + y6]> Out[7]=> False> That simply means that ImpliesQ cannot show the implication, not that > it does not hold. ImpliesQ relies on CAD, as does FullSimplify. > Switching to FullSimplify we see that:> In[8]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + > y4 + y6]> Out[8]=> True> while> In[9]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 > <= 1 + y4 + y6]> Out[9]=> y4 >= -1 && y6 <= y5 <= 1 + y4 + y6> On the other hand, taking just the individual summands of Or as > hypotheses;> In[10]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[10]=> True> In[11]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 ]> Out[11]=> True> In fact FullSimplify is unable to use Or in assumptions, which can be > demonstrated on an abstract example:> In[12]:=> FullSimplify[C,(A||B)&&(C)]> Out[12]=> True> In[13]:=> FullSimplify[C,LogicalExpand[(A||B)&&(C)]]> Out[13]=> C> This could be fixed by modifying FullSimplify:> In[14]:=> Unprotect[FullSimplify];> In[14]:=> FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify[ex > pr,y]];> In[15]:=> Protect[FullSimplify];> Now at least we get as before:> In[16]:=> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + > y4 + y6]> Out[16]=> True> but also:> In[17]:=> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 > <= 1 + y4 + y6]> Out[17]=> True> This seems to me a possible worthwhile improvement in FullSimplify, > though of course not really helpful for your problem.> Andrzej Kozlowski> Toyama International University> JAPAN>> I have a set of inequalities that I solve with InequalitySolve. But >> then>> it gives a complete set of solutions, but not in the way I would like >> it>> to be! :-) For example, the simple following calculation will give:>> In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6 >>= -1};>> InequalitySolve[ineq,{y4,y6,y5}]>> Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||>> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6>> the result is good, but I would like it to be in the simpler but>> equivalent form>> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6>> How can I tell InequalitySolve to do that? It is simple for this >> example,>> but for a large set of simple inequalities InequalitySolve gives >> lines and>> lines of results instead of a simple result.>> Vincent Bouchard>> ==== =>-----Original Message----->Sent: Wednesday, September 25, 2002 7:51 AM>For the life of me I am not sure why the following is not >working in my >v. 4.2:>ru[a]=a->x;>f[x_]:=(a+b) /. ru[a];>Why do I get>f[c] = b+x>and not>f[c] = b+c?>What gives?>Lawrence>-- >Lawrence A. Walker Jr.>http://www.kingshonor.comLawrence, in your definition of f, x doesn't show up explicitely. So, in theevaluation sequence, when the definition for f[c] is applied, no x appearsat rhs i.e.(a + b) /. ru[a] and such c cannot be inserted. The result is the same asdirectly executingIn[11]:= (a + b) /. ru[a]Out[11]= b + xIf you don't like this, you have to make explicit the Value of ru[a] in thedefiniton of f. One way to do so is to use Set instead of SetDelayed:In[9]:= f[x_] = (a + b) /. ru[a]Out[9]= b + xIn[10]:= f[c]Out[10]= b + cThe drawback of this that not only the value of ru[a] is inserted but alsothe whole expression including ReplaceAll is evaluated. If this is notwanted, you have to insert the value of ru[a] into the unevaluated rhs atthe definition. The general means for this are function application, With orReplace:In[7]:= (g[x_] := (a + b) /. #) &[ru[a]]In[8]:= g[c]Out[8]= b + cIn[16]:= Clear[g]In[20]:=Unevaluated[g[x_] := (a + b) /. rule] /. rule -> ru[a]In[21]:= g[c]Out[21]= b + cHere we have to prevent evaluation of the defintion before our rule isinserted, this is achieved by Unevaluated.With is a bit more complicated, since the scoping rules for SetDelayed wouldnot allow the substition of an expression at rhs containing a patternvariable (the pattern variable is renamed in this case). A simple answer tothis is to also substitute the argument variable (the pattern): In[31]:= Clear[g]In[32]:=With[{rule = ru[a], arg = x_}, g[arg] := (a + b) /. rule]In[33]:= g[c]Out[33]= b + c--Hartmut Wolf ==== =Hartmut,I add an explicit illustration to your ingenious solution using With.Hartmut's solution: Clear[g]; ru[a] = a -> x; With[{rule = ru[a], arg = x_}, g[arg] := a + b /. rule]; g[ c] b + cWhy is arg = x_ needed?Without it we get Clear[g]; With[{rule=ru[a]}, g[x_]:=a+b/.rule]; g [c] b+xThe reason for this shows in ?g Global`g g[x$_] := a + b /. a -> xThe x in x_ has been changed to x$ and there is no x$ on the right side.This is a general feature of scoping. Taking it further we get Clear[g]; With[{rule=ru[a]},g[x_]:=a+x/.rule]; g [c] c+x ?g Global`g g[x$_] := a + x$ /. a -> x--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198>-----Original Message----->Sent: Wednesday, September 25, 2002 7:51 AM> >For the life of me I am not sure why the following is not>working in my>v. 4.2:> >ru[a]=a->x;>f[x_]:=(a+b) /. ru[a];> >Why do I get>f[c] = b+x> >and not>f[c] = b+c?> >What gives?> >Lawrence> >-->Lawrence A. Walker Jr.>http://www.kingshonor.com>> Lawrence,> in your definition of f, x doesn't show up explicitely. So, in the> evaluation sequence, when the definition for f[c] is applied, no x appears> at rhs i.e.> (a + b) /. ru[a] and such c cannot be inserted. The result is the same as> directly executing> In[11]:= (a + b) /. ru[a]> Out[11]= b + x> If you don't like this, you have to make explicit the Value of ru[a] inthe> definiton of f. One way to do so is to use Set instead of SetDelayed:> In[9]:= f[x_] = (a + b) /. ru[a]> Out[9]= b + x> In[10]:= f[c]> Out[10]= b + c> The drawback of this that not only the value of ru[a] is inserted but also> the whole expression including ReplaceAll is evaluated. If this is not> wanted, you have to insert the value of ru[a] into the unevaluated rhs at> the definition. The general means for this are function application, Withor> Replace:> In[7]:= (g[x_] := (a + b) /. #) &[ru[a]]> In[8]:= g[c]> Out[8]= b + c> In[16]:= Clear[g]> In[20]:=> Unevaluated[g[x_] := (a + b) /. rule] /. rule -> ru[a]> In[21]:= g[c]> Out[21]= b + c> Here we have to prevent evaluation of the defintion before our rule is> inserted, this is achieved by Unevaluated.> With is a bit more complicated, since the scoping rules for SetDelayedwould> not allow the substition of an expression at rhs containing a pattern> variable (the pattern variable is renamed in this case). A simple answerto> this is to also substitute the argument variable (the pattern):> In[31]:= Clear[g]> In[32]:=> With[{rule = ru[a], arg = x_}, g[arg] := (a + b) /. rule]> In[33]:= g[c]> Out[33]= b + c> --> Hartmut Wolf ==== =TryIn[1]:=M={{1,2,3},{4,5,6},{7,8,9}};In[2]:=Export[ test.csv,M,CSV];Also, avoid using names with capital initial, since these are usuallyreserved for Mathematica functions.Tomas GarzaMexico City----- Original Message -----> M={{1,2,3},{4,5,6},{7,8,9}};> TableForm[M]> 1 2 3> 4 5 6> 7 8 9> The commands like Put or Write create files with a standard Mathematica> matrix notation with braces, I get the the same result with Save As/Copy> Robert ==== =I would appreciate if someone could tell me how to put my output forexample a matrix in TableForm as a space-delimited ASCII file inMathematica 3.0.for example:M={{1,2,3},{4,5,6},{7,8,9}};TableForm[M]1 2 34 5 67 8 9The commands like Put or Write create files with a standard Mathematicamatrix notation with braces, I get the the same result with Save As/CopyRobert ==== =Much longer. At least 10 times as long. Not sure because I quit. As I readBobby Treat's response, one of my processors had been laboring for more thanthree days to generate all the digits. (I had not considered to display orprint all of them. Why on Earth would I want to do that?) So I started over,asking RealDigits to skip most of the digits.Tom Burton> So would it take about the same amont of time for the complete printout> of digits? Of course it would take a few additional seconds to format> the output...> Or does Mathematica take alot less time when it truncates the output?>>> Could you tell me the CPU you used and its speed etc...i am curious,> other programs out there.>>> I used one processor of a dual 1GH Mac and got the same answer with the>> following speed:>>> 4.2 for Mac OS X (June 4, 2002)>> oldmax = $MaxPrecision>> 6>> 1. 10>> $MaxPrecision = Infinity>> Infinity>> With[{n = 2^26}, Timing[>> pd = RealDigits[N[Pi, n + 1], 10, 20,>> 19 - n]; ]]>> {28794.1 Second, Null}>> MaxMemoryUsed[]>> 512055204>> pd>> {{3, 3, 8, 6, 3, 2, 2, 0, 8, 9, 6, 2, 2, 3,>> >> 4, 0, 9, 8, 0, 3}, -67108844}>>> Tom Burton> ==== =Often posters to MathGroup copy and paste in the complete cell expression,including the In and Out numbers, when posting to MathGroup.I wonder if this is the best method because one can't then just copy out allthe statements and paste them into a Mathematica notebook. All the statementnumbers have to be edited out and if there are many statement definitionsthis is an extended task for any responder. This, of course, decreases thechances for a response. A better method is for the poster to just copy andpaste the CONTENTS of each cell. This is more work for the poster, but itmay pay off in better responses.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ ==== = David,I agree with you that it makes responding and using easier if the In and Outnumbers are not included.An easier way to do this, rather than copying the contents of the cells, isUsually a little manual reformating is needed to distinguish text, input andoutput --- I try to use one tab indent for input and two tabs indent foroutput, plus some blank line adjustment.I wonder if anyone has a way of automatically achieving this reformating.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> Often posters to MathGroup copy and paste in the complete cell expression,> including the In and Out numbers, when posting to MathGroup.> I wonder if this is the best method because one can't then just copy outall> the statements and paste them into a Mathematica notebook. All thestatement> numbers have to be edited out and if there are many statement definitions> this is an extended task for any responder. This, of course, decreases the> chances for a response. A better method is for the poster to just copy and> paste the CONTENTS of each cell. This is more work for the poster, but it> may pay off in better responses.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ ==== =copying and pasting is straightforward. I always run my notebooks this way,because showing the In[x], Out[x] does not seem to provide me with muchbeyond clutter.Kevin> Often posters to MathGroup copy and paste in the complete cell expression,> including the In and Out numbers, when posting to MathGroup.> I wonder if this is the best method because one can't then just copy outall> the statements and paste them into a Mathematica notebook. All thestatement> numbers have to be edited out and if there are many statement definitions> this is an extended task for any responder. This, of course, decreases the> chances for a response. A better method is for the poster to just copy and> paste the CONTENTS of each cell. This is more work for the poster, but it> may pay off in better responses.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ ==== =>In a presentation I wish to use Plot to generate a sequence of frames and>then animate them. The problem is that the audience sees the animation>twice. Once when the frames are being generated and then again after I have>closed the group and double clicked on the top graphic. However, the first>showing during generation is enough (but uncontrolled).>Hugh GoyderThis creates a graphics cell from a graphics expression.GraphicCell[graphics_] := Cell[GraphicsData[PostScript, DisplayString[graphics]],Graphics]cellgroup.Block[{$ DisplayFunction=Identity, graphs}, graphs = Table[GraphicCell[ Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1, 1}}, ImageSize -> 400]], {t,0,15,.1}]; NotebookWrite[EvaluationNotebook[],Cell[CellGroupData[graphs, Closed]]]; SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndExecute[{FrontEndToken[EvaluationNotebook[], SelectionAnimate]}] ]------------------------------------------------------------ --Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== = Actually, the reason why ImpliesQ (and FullSimplify) fail toprove the implication is not that the hypothesis is a disjunction.To use the cylindrical algebraic decomposition algorithm theyneed to know that the assumptions imply that all variables arereal. The assumptions mechanism infers variable domains in a purelysyntactical way, i.e. v is assumed to be real if there is an Element[v, Reals] statement or v appears in an inequality.It does not attempt to analyze assumptions further, to figureout that, say y6 >= -1 implies that y6 is real, and then ifwe have y5 == y6 then y5 must be real too. Doing such an analysisin general would require solving the assumptions over complexnumbers, and then finding out which variables need to be real.This would be in general too time consuming to do, but analyzing linear dependencies like the ones in your example is a possiblefuture improvement.ImpliesQ cannot prove the implication here, because it knows onlythat y6 is real.In[1]:= <= -1 && y5 == y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6] Out[2]= False If we add an explicit assumption that y4 and y5 are real, ImpliesQ (and FullSimplify) can prove this implication, and the full version of your example.In[3]:= ImpliesQ[Element[y4|y5, Reals] && y4 == -1 && y6 >= -1 && y5 ==y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6] Out[3]= True In[4]:= ImpliesQ[Element[y4|y5, Reals] && (y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6), y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6] Out[4]=True In[5]:= FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,Element[y4|y5, Reals] && (y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6)] Out[5]=True Adam StrzebonskiWolfram Research > On second thoughts I realized that there seems to be an inherent> ambiguity about what one coudl mean by using alternatives (statements> joned by Or) assumptions. In fact it now seems to me that the> reasonable intertpretation for ImpliesQ and FullSimplify ought to> perhaps be different. It seems to me that ImpliesQ[Or[a,b],c] ought to> return True if aand only if ImpliesQ[a,c] and ImpliesQ[b,c] both return> True. If so this could be acomplished by adding the rule> ImpliesQ[Or[a,b],c] = And[ImpliesQ[a,c],ImpliesQ[b,c]]. That could then> be used in proving that the two answers to the system of inequalities> that of Vincent's original posting are equivalent. On the other hand> probably FullSimplify[a, Or[p,q]] ought to return> Or[FullSimplify[a,p],FullSimplify[a,q]] (or do nothing as it doe snow).> The first approach would seem to be consistent with the way> FullSimplify works with domain specifications but would however have> the strange effect of returning True if just one of the alternatives> were true and the other false. So perhaps after all it is best to> leave FullSimplify as it is. However, it seems to me that ImpliesQ> shoud be able to handle such cases (?)> Andrzej Kozlowski> Toyama International University> JAPAN>The modification to FullSimplify that I sent earlier works correctly>only for assumptions of the form Or[a,b] (and even then not is not>always what one would like). For what it's worth here is a better (but>slow) version:> > In[1]:=>Unprotect[FullSimplify];> > In[2]:=>FullSimplify[expr_, x_ || y__] := FullSimplify[> FullSimplify[expr, x] || FullSimplify[expr, Or[y]]];> > In[3]:=>Protect[FullSimplify];> > For example:> > In[4]:=>FullSimplify[Sqrt[(x - 1)^2] + Sqrt[(x - 2)^2] +> Sqrt[(x - 3)^2], x > 1 || x > 2 || x > 3]> > Out[4]=>-1 + x + Abs[-3 + x] + Abs[-2 + x] ||> -3 + 2*x + Abs[-3 + x] || 3*(-2 + x)> > Andrzej Kozlowski>Toyama International University>JAPAN> >> The reason why InequalitySolve returns it's answer in what sometimes>> turns out to be unnecessarily complicated form is that the underlying>> algorithm, Cylindrical Agebraic Decomposition (CAD) returns its>> answers in this form. Unfortunately it seems to me unlikely that a>> simplification of the kind you need can be can be accomplished in any>> general way. To see why observe the following. First of all:> In[1]:=>> FullSimplify[x > 0 || x == 0]> Out[1]=>> x >= 0> This is fine. However:> In[2]:=>> FullSimplify[x > 0 && x < 2 || x == 0 && x < 2]> Out[2]=>> x == 0 || 0 < x < 2> Of course what you would like is simply 0 <= x < 2. One reason why>> you can't get it is that while Mathematica can perform a>> LogicalExpand, as in:>> In[3]:=>> LogicalExpand[(x > 0 || x == 0) && x < 2]> Out[3]=>> x == 0 && x < 2 || x > 0 && x < 2> There i no LogicalFactor or anything similar that would reverse>> what LogicalExpand does. if there was then you could perform the sort>> of simplifications you need for:> In[4]:=>> FullSimplify[(x > 0 || x == 0) && x < 2]> Out[4]=>> 0 <= x < 2> However, it does not seem to me very likely that such logical>> factoring can be performed by a general enough algorithm (though I>> am no expert in this field). In any case, certainly Mathematica can't>> do this.> I also noticed that Mathematica seems unable to show that the answer>> it returns to your problem is actually equivalent to your simpler>> one. In fact this looks like a possible bug in Mathematica. Let's>> first try the function ImpliesQ from the Experimental context:> << Experimental`> Now Mathematica correctly gives:> In[6]:=>> ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5>> <= 1 + y4 + y6]> Out[6]=>> True> However:> In[7]:=>> ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&>> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +>> y4 + y6]> Out[7]=>> False> That simply means that ImpliesQ cannot show the implication, not that>> it does not hold. ImpliesQ relies on CAD, as does FullSimplify.>> Switching to FullSimplify we see that:>> In[8]:=>> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1>> &&>> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +>> y4 + y6]> Out[8]=>> True> while> In[9]:=>> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5>> <= 1 + y4 + y6]> Out[9]=>> y4 >= -1 && y6 <= y5 <= 1 + y4 + y6> On the other hand, taking just the individual summands of Or as>> hypotheses;>> In[10]:=>> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]> Out[10]=>> True> In[11]:=>> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 == -1 && y6 >= -1 && y5 == y6 ]>> Out[11]=>> True> In fact FullSimplify is unable to use Or in assumptions, which can be>> demonstrated on an abstract example:>>> In[12]:=>> FullSimplify[C,(A||B)&&(C)]> Out[12]=>> True> In[13]:=>> FullSimplify[C,LogicalExpand[(A||B)&&(C)]]> Out[13]=>> C> This could be fixed by modifying FullSimplify:> In[14]:=>> Unprotect[FullSimplify];> In[14]:=>> FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify[e>> xpr,y]];> In[15]:=>> Protect[FullSimplify];> Now at least we get as before:> In[16]:=>> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1>> &&>> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 +>> y4 + y6]> Out[16]=>> True> but also:> In[17]:=>> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5>> <= 1 + y4 + y6]> Out[17]=>> True> This seems to me a possible worthwhile improvement in FullSimplify,>> though of course not really helpful for your problem.>>> Andrzej Kozlowski>> Toyama International University>> JAPAN>>> I have a set of inequalities that I solve with InequalitySolve. But> then> it gives a complete set of solutions, but not in the way I would> like it> to be! :-) For example, the simple following calculation will give:>> In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6>= -1};> InequalitySolve[ineq,{y4,y6,y5}]>> Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6>> the result is good, but I would like it to be in the simpler but> equivalent form>> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6>> How can I tell InequalitySolve to do that? It is simple for this> example,> but for a large set of simple inequalities InequalitySolve gives> lines and> lines of results instead of a simple result.>>> Vincent Bouchard>>>> > ==== =On second thoughts I realized that there seems to be an inherent ambiguity about what one could mean by using alternatives (statements joned by Or) assumptions. In fact it now seems to me that the reasonable intertpretation for ImpliesQ and FullSimplify ought to perhaps be different. It seems to me that ImpliesQ[Or[a,b],c] ought to return True if aand only if ImpliesQ[a,c] and ImpliesQ[b,c] both return True. If so this could be acomplished by adding the ruleImpliesQ[Or[a,b],c] = And[ImpliesQ[a,c],ImpliesQ[b,c]]. That could then be used in proving that the two answers to the system of inequalities that of Vincent's original posting are equivalent. On the other hand probably FullSimplify[a, Or[p,q]] ought to return Or[FullSimplify[a,p],FullSimplify[a,q]] (or do nothing as it doe snow). The first approach would seem to be consistent with the way FullSimplify works with domain specifications but would however have the strange effect of returning True if just one of the alternatives were true and the other false. So perhaps after all it is best to leave FullSimplify as it is. However, it seems to me that ImpliesQ shoud be able to handle such cases (?)Andrzej KozlowskiToyama International UniversityJAPAN> The modification to FullSimplify that I sent earlier works correctly > only for assumptions of the form Or[a,b] (and even then not is not > always what one would like). For what it's worth here is a better (but > slow) version:> In[1]:=> Unprotect[FullSimplify];> In[2]:=> FullSimplify[expr_, x_ || y__] := FullSimplify[> FullSimplify[expr, x] || FullSimplify[expr, Or[y]]];> In[3]:=> Protect[FullSimplify];> For example:> In[4]:=> FullSimplify[Sqrt[(x - 1)^2] + Sqrt[(x - 2)^2] +> Sqrt[(x - 3)^2], x > 1 || x > 2 || x > 3]> Out[4]=> -1 + x + Abs[-3 + x] + Abs[-2 + x] ||> -3 + 2*x + Abs[-3 + x] || 3*(-2 + x)> Andrzej Kozlowski> Toyama International University> JAPAN>> The reason why InequalitySolve returns it's answer in what sometimes >> turns out to be unnecessarily complicated form is that the underlying >> algorithm, Cylindrical Agebraic Decomposition (CAD) returns its >> answers in this form. Unfortunately it seems to me unlikely that a >> simplification of the kind you need can be can be accomplished in any >> general way. To see why observe the following. First of all:>> In[1]:=>> FullSimplify[x > 0 || x == 0]>> Out[1]=>> x >= 0>> This is fine. However:>> In[2]:=>> FullSimplify[x > 0 && x < 2 || x == 0 && x < 2]>> Out[2]=>> x == 0 || 0 < x < 2>> Of course what you would like is simply 0 <= x < 2. One reason why >> you can't get it is that while Mathematica can perform a >> LogicalExpand, as in:>> In[3]:=>> LogicalExpand[(x > 0 || x == 0) && x < 2]>> Out[3]=>> x == 0 && x < 2 || x > 0 && x < 2>> There i no LogicalFactor or anything similar that would reverse >> what LogicalExpand does. if there was then you could perform the sort >> of simplifications you need for:>> In[4]:=>> FullSimplify[(x > 0 || x == 0) && x < 2]>> Out[4]=>> 0 <= x < 2>> However, it does not seem to me very likely that such logical >> factoring can be performed by a general enough algorithm (though I >> am no expert in this field). In any case, certainly Mathematica can't >> do this.>> I also noticed that Mathematica seems unable to show that the answer >> it returns to your problem is actually equivalent to your simpler >> one. In fact this looks like a possible bug in Mathematica. Let's >> first try the function ImpliesQ from the Experimental context:>> << Experimental`>> Now Mathematica correctly gives:>> In[6]:=>> ImpliesQ[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 >> <= 1 + y4 + y6]>> Out[6]=>> True>> However:>> In[7]:=>> ImpliesQ[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 &&>> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + >> y4 + y6]>> Out[7]=>> False>> That simply means that ImpliesQ cannot show the implication, not that >> it does not hold. ImpliesQ relies on CAD, as does FullSimplify. >> Switching to FullSimplify we see that:>> In[8]:=>> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 >> &&>> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + >> y4 + y6]>> Out[8]=>> True>> while>> In[9]:=>> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 >> <= 1 + y4 + y6]>> Out[9]=>> y4 >= -1 && y6 <= y5 <= 1 + y4 + y6>> On the other hand, taking just the individual summands of Or as >> hypotheses;>> In[10]:=>> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6]>> Out[10]=>> True>> In[11]:=>> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 == -1 && y6 >= -1 && y5 == y6 ]>> Out[11]=>> True>> In fact FullSimplify is unable to use Or in assumptions, which can be >> demonstrated on an abstract example:>> In[12]:=>> FullSimplify[C,(A||B)&&(C)]>> Out[12]=>> True>> In[13]:=>> FullSimplify[C,LogicalExpand[(A||B)&&(C)]]>> Out[13]=>> C>> This could be fixed by modifying FullSimplify:>> In[14]:=>> Unprotect[FullSimplify];>> In[14]:=>> FullSimplify[expr_,Or[x_,y__]]:=Or[FullSimplify[expr,x], FullSimplify[e >> xpr,y]];>> In[15]:=>> Protect[FullSimplify];>> Now at least we get as before:>> In[16]:=>> FullSimplify[y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 >> &&>> y6 <= y5 <= 1 + y4 + y6, y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + >> y4 + y6]>> Out[16]=>> True>> but also:>> In[17]:=>> FullSimplify[y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6,>> y4 == -1 && y6 >= -1 && y5 == y6 || y4 > -1 && y6 >= -1 && y6 <= y5 >> <= 1 + y4 + y6]>> Out[17]=>> True>> This seems to me a possible worthwhile improvement in FullSimplify, >> though of course not really helpful for your problem.>> Andrzej Kozlowski>> Toyama International University>> JAPAN> I have a set of inequalities that I solve with InequalitySolve. But > then> it gives a complete set of solutions, but not in the way I would > like it> to be! :-) For example, the simple following calculation will give:>> In[1]:= ineq = {y4 >= -1, y5 >= -1, y6 + y4 >= y5 - 1, y5 >= y6, y6 >= -1};> InequalitySolve[ineq,{y4,y6,y5}]>> Out[1]:= y4 == -1 && y6 >= -1 && y5 == y6 ||> y4 > -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6>> the result is good, but I would like it to be in the simpler but> equivalent form>> y4 >= -1 && y6 >= -1 && y6 <= y5 <= 1 + y4 + y6>> How can I tell InequalitySolve to do that? It is simple for this > example,> but for a large set of simple inequalities InequalitySolve gives > lines and> lines of results instead of a simple result.>>> Vincent Bouchard>> ==== =Hallo!,My name is Nagesh and pursuing research studies in Refrigeration. At present I am writing a Dynamic Refrigeration System Simulation Package. I am using Mathematica as a programming language for the same since last one year. I don't have any programming experience before this. I have following querries:-1. Is any body here have expertise or information about the capability of Mathematica as a system simulation tool?2. Is is possible to program a user friendly interface for my system simulation package with Mathematica or I have to use some other software?3. My refrigeration system simulation package is likely to have approximately 60 First order Differential equations. Is is possible to solve these in Mathematica ? If yes then can anybody here guide me about this further.I am explaining below in short about the objectives I want to fulfill from coding out of my main input file1. Example from Main Input File ( this will contain about 200-250 variables which will be entered by the user of this package)Below is examples of two variables entered into this file, which will be used in other analysis files for further evaluation.2. Example from other analysis file ( there will be about 20-25 other such component analysis files ) where the above mentioned variables from main input file will be used for further evaluations:-Below is one example from this file explaining how the variables from main input file will be used in other files.I hope that this short information will be useful for guiding me to solve the following problems that I am facing. I am facing follwing problems or objectives:-1. My 1st Objective:- The user of this package must be able to change only the value of the variable in the main input file but he must not be able to change the name of the variable itself. For example he must be able to change the value of the variable but he must not be able to change the name of this variable itself.Here our problem is how to achieve or program it so that our objective will be fullfilled.2. My 2nd Objective:- How I can program the main input file so that it will be user friendly in terms of its visuals and satisfying the constraint mentioned above in objective1.3. My 3rd Objective:- How can I program the optional values for each variable in the main input file ? so that there will be always a value assigned to each variable listed in main input file whenever the user opens up this file. If user want to change the values of some variables then he can change them and run the simulation otherwise the simulation run will be done with optional values assigned to each variable in the input file.4. My 4th Objective:- How can I program the check for correctness of the input values supplied by the package user ?I will be very greatful to you for helping and suggesting some technique or method to solve some of my above mentioned programming problems.Can anybody here guide me about the above mentioned programming problems ?Nagesh Rajepandhare ==== =I want to add a further suggestion:Probably each differential equation logically belongs to one of the definedclasses in the sense, that it helps to define the behaviour of thecomponent.In this case, each differential equation should be stored in one of thesesclasses as textstring in a form appropriate for the execution inMathematica.Hermann Schmitt----- Original Message -----> Is any body here have expertise or information about the capability of> Mathematica as a system simulation tool?> Mr. Kuska answers:> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> My comment:> That is: He sees the simulation system merely as a set of differential> equations.> The question of Mr. Nagesh:> My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?> The answer of Mr. Kuska is:> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> My comment:> This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.> Nagesh understand it and is it sufficient to check, if all inputs are> numerical?> Additionally I think, it is not userfriendly to see the input merely as a> set of 200-250 numbers.> My suggestion is, that JLink is used, a suggestion Mr. Kusk takes into> consideration, too.> But further I suggest, that classes are defined in Java, which representthe> parts of the system.> Constructors of the classes should build objects with default values.> Graphical user interfaces> should give the opportunity to change the data fields in the objects and> check the input for correctness.> The system should give the opportunity, to store the objects on harddisk> (serialization).> accessed directly.> >My name is Nagesh and pursuing research studies in Refrigeration. At>> present I am writing a Dynamic Refrigeration System SimulationPackage.> I>> am using Mathematica as a programming language for the same since last> one>> year. I don't have any programming experience before this. I have> following>> querries:->> 1. Is any body here have expertise or information about the capability> of>> Mathematica as a system simulation tool?> > Since the most system simulation tools are simply solving a system of>ordinary differntial equations it is simple to do this with NDSolve[].> >2. Is is possible to program a user friendly interface for my system>> simulation package with Mathematica or I have to use some other> software?> > Write a MathLink or J/Link frontend that launch the kernel. But you>should keep>in mind that the user interface is typical 80-90 % of your code.>If you just whant to solve some ode's it is probably easyer to>include one of the excelent ode-solvers from netlib in your C-code>than to call Mathematica to do that. As long as you dont wish to change>the ode's very often (than Mathematica is more ßexible) you should>not use Mathematica.> >3. My refrigeration system simulation package is likely to have>> approximately 60 First order Differential equations. Is is possible to>> solve these in Mathematica ?> > Sure.>> If yes then can anybody here guide me about>> this further.> > Write down the equations and call NDSolve[].> > >I am explaining below in short about the objectives I want to fulfill> from>> coding out of my main input file>1. Example from Main Input File ( this will contain about 200-250> variables>> which will be entered by the user of this package)> > This sounds like a *very* userfiendly interface ;-)> > >Below is examples of two variables entered into this file, which willbe>> used in other analysis files for further evaluation.>2. Example from other analysis file ( there will be about 20-25 other> such>> component analysis files ) where the above mentioned variables frommain>> input file will be used for further evaluations:->Below is one example from this file explaining how the variables from> main>> input file will be used in other files.>I hope that this short information will be useful for guiding me to> solve>> the following problems that I am facing. I am facing follwing problems> or>> objectives:->1. My 1st Objective:- The user of this package must be able to change> only>> the value of the variable in the main input file but he must not beable> to>> change the name of the variable itself. For example he must be able to>> change the value of the variable but he must not be able tochange> the>> name of this variable itself.>> Here our problem is how to achieve or program it so that our objective> will>> be fullfilled.> > Options with defaulf values ? or something like> > {aParam,bParam}={ODEParameter1,ODEParameter2} /.> userRules /.> {ODEParameter1->1,ODEParameter2->2}> > >2. My 2nd Objective:- How I can program the main input file so that it> will>> be user friendly in terms of its visuals and satisfying the constraint>> mentioned above in objective1.> > What is *userfiendly* in a file with 250 variables ???> > >3. My 3rd Objective:- How can I program the optional values for each>> variable in the main input file ? so that there will be always a value>> assigned to each variable listed in main input file whenever the user> opens>> up this file. If user want to change the values of some variables then> he>> can change them and run the simulation otherwise the simulation runwill> be>> done with optional values assigned to each variable in the input file.> > See above.> > >4. My 4th Objective:- How can I program the check for correctness ofthe>> input values supplied by the package user ?> > And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> > Jens> ==== =I have developed one package where it is included a functions forsolving System of ODE. You can downloaded from:http://web.usal.es/~guillerm/biokmod.The functions are: SystemDSolve and SystemNDSolve Guillermo Sanchez> I want to add a further suggestion:> Probably each differential equation logically belongs to one of the defined> classes in the sense, that it helps to define the behaviour of the> component.> In this case, each differential equation should be stored in one of theses> classes as textstring in a form appropriate for the execution in> Mathematica.> Hermann Schmitt> ----- Original Message -----> > I agree with Mr. Kuska, that the system Mr Nagesh describes is not>userfriendly. But I think, the suggestions of Mr. Kuska do not make it> more>userfriendly, rather the opposite is true.> > Mr. Nagesh asks> > Is any body here have expertise or information about the capability of>Mathematica as a system simulation tool?>Mr. Kuska answers:>Since the most system simulation tools are simply solving a system of>ordinary differntial equations it is simple to do this with NDSolve[].> > My comment:> > That is: He sees the simulation system merely as a set of differential>equations.> > The question of Mr. Nagesh:> > My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?>The answer of Mr. Kuska is:>And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> > My comment:> > This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.>Nagesh understand it and is it sufficient to check, if all inputs are>numerical?> > Additionally I think, it is not userfriendly to see the input merely as a>set of 200-250 numbers.> > My suggestion is, that JLink is used, a suggestion Mr. Kusk takes into>consideration, too.> > But further I suggest, that classes are defined in Java, which represent> the>parts of the system.> > Constructors of the classes should build objects with default values.>Graphical user interfaces> > should give the opportunity to change the data fields in the objects and>check the input for correctness.> > The system should give the opportunity, to store the objects on harddisk>(serialization).> > accessed directly.> > > > >> My name is Nagesh and pursuing research studies in Refrigeration. At>>present I am writing a Dynamic Refrigeration System Simulation> Package.> I>>am using Mathematica as a programming language for the same since last> one>>year. I don't have any programming experience before this. I have> following>>querries:->>1. Is any body here have expertise or information about the capability> of>>Mathematica as a system simulation tool?>Since the most system simulation tools are simply solving a system of>> ordinary differntial equations it is simple to do this with NDSolve[].>> 2. Is is possible to program a user friendly interface for my system>>simulation package with Mathematica or I have to use some other> software?>Write a MathLink or J/Link frontend that launch the kernel. But you>> should keep>> in mind that the user interface is typical 80-90 % of your code.>> If you just whant to solve some ode's it is probably easyer to>> include one of the excelent ode-solvers from netlib in your C-code>> than to call Mathematica to do that. As long as you dont wish to change>> the ode's very often (than Mathematica is more ßexible) you should>> not use Mathematica.>> 3. My refrigeration system simulation package is likely to have>>approximately 60 First order Differential equations. Is is possible to>>solve these in Mathematica ?>Sure.>>If yes then can anybody here guide me about>>this further.>Write down the equations and call NDSolve[].>> I am explaining below in short about the objectives I want to fulfill> from>>coding out of my main input file>> >> 1. Example from Main Input File ( this will contain about 200-250> variables>>which will be entered by the user of this package)>This sounds like a *very* userfiendly interface ;-)>> Below is examples of two variables entered into this file, which will> be>>used in other analysis files for further evaluation.>> >> 2. Example from other analysis file ( there will be about 20-25 other> such>>component analysis files ) where the above mentioned variables from> main>>input file will be used for further evaluations:->> >> Below is one example from this file explaining how the variables from> main>>input file will be used in other files.>> >> I hope that this short information will be useful for guiding me to> solve>>the following problems that I am facing. I am facing follwing problems> or>>objectives:->> >> 1. My 1st Objective:- The user of this package must be able to change> only>>the value of the variable in the main input file but he must not be> able> to>>change the name of the variable itself. For example he must be able to>>change the value of the variable but he must not be able to> change> the>>name of this variable itself.>>Here our problem is how to achieve or program it so that our objective> will>>be fullfilled.>Options with defaulf values ? or something like>{aParam,bParam}={ODEParameter1,ODEParameter2} /.>> userRules /.>> {ODEParameter1->1,ODEParameter2->2}>> 2. My 2nd Objective:- How I can program the main input file so that it> will>>be user friendly in terms of its visuals and satisfying the constraint>>mentioned above in objective1.>What is *userfiendly* in a file with 250 variables ???>> 3. My 3rd Objective:- How can I program the optional values for each>>variable in the main input file ? so that there will be always a value>>assigned to each variable listed in main input file whenever the user> opens>>up this file. If user want to change the values of some variables then> he>>can change them and run the simulation otherwise the simulation run> will> be>>done with optional values assigned to each variable in the input file.>See above.>> 4. My 4th Objective:- How can I program the check for correctness of> the>>input values supplied by the package user ?>And @@ (NumericQ /@ {aListOfAllYourNumericParameters})>> > > Jens> > ==== =I agree with Mr. Kuska, that the system Mr Nagesh describes is notuserfriendly. But I think, the suggestions of Mr. Kuska do not make it moreuserfriendly, rather the opposite is true.Mr. Nagesh asksIs any body here have expertise or information about the capability ofMathematica as a system simulation tool?Mr. Kuska answers:Since the most system simulation tools are simply solving a system ofordinary differntial equations it is simple to do this with NDSolve[].My comment:That is: He sees the simulation system merely as a set of differentialequations.The question of Mr. Nagesh:My 4th Objective:- How can I program the check for correctness of the input values supplied by the package user ?The answer of Mr. Kuska is:And @@ (NumericQ /@ {aListOfAllYourNumericParameters})My comment:This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.Nagesh understand it and is it sufficient to check, if all inputs arenumerical?Additionally I think, it is not userfriendly to see the input merely as aset of 200-250 numbers.My suggestion is, that JLink is used, a suggestion Mr. Kusk takes intoconsideration, too.But further I suggest, that classes are defined in Java, which represent theparts of the system.Constructors of the classes should build objects with default values.Graphical user interfacesshould give the opportunity to change the data fields in the objects andcheck the input for correctness.The system should give the opportunity, to store the objects on harddisk(serialization).accessed directly.>My name is Nagesh and pursuing research studies in Refrigeration. At>present I am writing a Dynamic Refrigeration System Simulation Package.I>am using Mathematica as a programming language for the same since lastone>year. I don't have any programming experience before this. I havefollowing>querries:->1. Is any body here have expertise or information about the capabilityof>Mathematica as a system simulation tool?> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].>2. Is is possible to program a user friendly interface for my system>simulation package with Mathematica or I have to use some othersoftware?> Write a MathLink or J/Link frontend that launch the kernel. But you> should keep> in mind that the user interface is typical 80-90 % of your code.> If you just whant to solve some ode's it is probably easyer to> include one of the excelent ode-solvers from netlib in your C-code> than to call Mathematica to do that. As long as you dont wish to change> the ode's very often (than Mathematica is more ßexible) you should> not use Mathematica.>3. My refrigeration system simulation package is likely to have>approximately 60 First order Differential equations. Is is possible to>solve these in Mathematica ?> Sure.>If yes then can anybody here guide me about>this further.> Write down the equations and call NDSolve[].> > I am explaining below in short about the objectives I want to fulfillfrom>coding out of my main input file> > 1. Example from Main Input File ( this will contain about 200-250variables>which will be entered by the user of this package)> This sounds like a *very* userfiendly interface ;-)> > Below is examples of two variables entered into this file, which will be>used in other analysis files for further evaluation.> > 2. Example from other analysis file ( there will be about 20-25 othersuch>component analysis files ) where the above mentioned variables from main>input file will be used for further evaluations:-> > Below is one example from this file explaining how the variables frommain>input file will be used in other files.> > I hope that this short information will be useful for guiding me tosolve>the following problems that I am facing. I am facing follwing problemsor>objectives:-> > 1. My 1st Objective:- The user of this package must be able to changeonly>the value of the variable in the main input file but he must not be ableto>change the name of the variable itself. For example he must be able to>change the value of the variable but he must not be able to changethe>name of this variable itself.>Here our problem is how to achieve or program it so that our objectivewill>be fullfilled.> Options with defaulf values ? or something like> {aParam,bParam}={ODEParameter1,ODEParameter2} /.> userRules /.> {ODEParameter1->1,ODEParameter2->2}> > 2. My 2nd Objective:- How I can program the main input file so that itwill>be user friendly in terms of its visuals and satisfying the constraint>mentioned above in objective1.> What is *userfiendly* in a file with 250 variables ???> > 3. My 3rd Objective:- How can I program the optional values for each>variable in the main input file ? so that there will be always a value>assigned to each variable listed in main input file whenever the useropens>up this file. If user want to change the values of some variables thenhe>can change them and run the simulation otherwise the simulation run willbe>done with optional values assigned to each variable in the input file.> See above.> > 4. My 4th Objective:- How can I program the check for correctness of the>input values supplied by the package user ?> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})>> Jens ==== =See my comments in the following text!Hermann Schmitt----- Original Message -----> > Is any body here have expertise or information about the capability of>Mathematica as a system simulation tool?>Mr. Kuska answers:>Since the most system simulation tools are simply solving a system of>ordinary differntial equations it is simple to do this with NDSolve[].> > My comment:> > That is: He sees the simulation system merely as a set of differential>equations.> hmm, since the original poster write> My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations.> it seems not completly wrong to assume that the system consists of> of ode's ..Yout should not ignore the word merely.It is not enough to have a set 60 differential equations and a set of200-250 numbers. That is not simulation system, which can be used by userswith the exception, perhaps, of the programmer of the system himself.How does e.g. the user know what meaning a number in the set has, ought hecount the numbers from the beginning?Your nice command shows only, if there is an input, which is not a number.But I think the user would like to know, which of the 200 elements are notnumbers.The only good of your command is, that it looks nice and shows yourknowledge!> > The question of Mr. Nagesh:> > My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?>The answer of Mr. Kuska is:>And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> > My comment:> > This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.>Nagesh understand it and is it sufficient to check, if all inputs are>numerical?> It seems you have a deeper knowlege about the things that Mr. Nagesh> understand. You know him personally ? It is not very polite to> make speculations *what* a other person understand.> And no it is not sufficent to check that all parameters are numbers.> Typical paramters described by intervals, where the assumptions of> a model are valid. But for this checks one needs more knowlege> about the meaning of the parameters. And one needs the knowlege about> the differntial equations, to find out the eigenvalues of the jacobian> ...> > Additionally I think, it is not userfriendly to see the input merely asa>set of 200-250 numbers.> > My suggestion is, that JLink is used, a suggestion Mr. Kusk takes into>consideration, too.> That will be fast as lightning !> > But further I suggest, that classes are defined in Java, which representthe>parts of the system.> That is notable nonsense! When the differntial equations should be> solved with Mathematica, the parts can't be Java classes. Mathematica's> NDSolve[] need a explicit expression to integrate the equations.That's not nonsense, the Mathematica program does not fetch the classes butthe numbers in the classes (or better in the objects).the Java classes in textform. They can then be fetched from the Mathematicaprogram and transformed into expressions by the Command ToExpression.The aim is, to have a clear separation of the system into components, whichare manageable and understandable.> OK you can call a Java class member from Mathematica but this will> be incredible slow when the right hand side is evaluated 200-300> times and every evaluation make several callbacks to the Java source.> Event handler of the Java main program (without some modification in> the event loop) while it is evaluating an other command.My idea is to fetch the values once from the Java objects at the beginning.200-250 numbers is not so much..> > Constructors of the classes should build objects with default values.> That's a great idea. If a simulation run should be documented, one> always> need the full listing of the Java source to find the actual parameter> settings.That is not my opinion. I think not every user of the simulation systemshould have to know Java and Mathematica.The user must look for the values in the objects. And the values are in theobjects, if they come from the constructor or from the graphical userinterface.I think, there should be listings of the objects including names of thevariables. In the objects the values are in an meaningful environment.>Graphical user interfaces>should give the opportunity to change the data fields in the objects and>check the input for correctness.> *and* what has a GUI for 200-250 variables to do with Mathematica ?> BTW one has typical much less variables because many parameters> are fixed and it make no sense to change, for example, material> constants of materials that can't exchanged> > The system should give the opportunity, to store the objects on harddisk>(serialization).> > accessed directly.>> Can you be so kind, to explain *how* your posting help a person that> ask How can I build a simulation system with Mathematica ?> You *can* say Don't use Mathematica, use Java! but this has nothing> to do with the question or with my reply.It is you, who proposes to solve the problem with C/C++ and not to useMathematica (see below!)My point of view is:Use Mathematica, for what Mathemtica is good, and Java, for what Java isgood.Mathematica is not so good as Java for data entry and Java is better thanMathematica to represent the simulation system (by objects).> But I still would suggest to use C/C++ and a numerical> ode-solver, make a fancy GUI/Script> interface and don't use Mathematica for such a simple task.> The ode-solver is the smallest part of such a simulation system.> Jens> > >> My name is Nagesh and pursuing research studies in Refrigeration. At>>present I am writing a Dynamic Refrigeration System SimulationPackage.>I>>am using Mathematica as a programming language for the same sincelast>one>>year. I don't have any programming experience before this. I have>following>>querries:->>1. Is any body here have expertise or information about thecapability>of>>Mathematica as a system simulation tool?>Since the most system simulation tools are simply solving a systemof>> ordinary differntial equations it is simple to do this with NDSolve[].>> 2. Is is possible to program a user friendly interface for my system>>simulation package with Mathematica or I have to use some other>software?>Write a MathLink or J/Link frontend that launch the kernel. But you>> should keep>> in mind that the user interface is typical 80-90 % of your code.>> If you just whant to solve some ode's it is probably easyer to>> include one of the excelent ode-solvers from netlib in your C-code>> than to call Mathematica to do that. As long as you dont wish tochange>> the ode's very often (than Mathematica is more ßexible) you should>> not use Mathematica.>> 3. My refrigeration system simulation package is likely to have>>approximately 60 First order Differential equations. Is is possibleto>>solve these in Mathematica ?>Sure.>>If yes then can anybody here guide me about>>this further.>Write down the equations and call NDSolve[].>> I am explaining below in short about the objectives I want tofulfill>from>>coding out of my main input file>> >> 1. Example from Main Input File ( this will contain about 200-250>variables>>which will be entered by the user of this package)>This sounds like a *very* userfiendly interface ;-)>> Below is examples of two variables entered into this file, whichwill be>>used in other analysis files for further evaluation.>> >> 2. Example from other analysis file ( there will be about 20-25other>such>>component analysis files ) where the above mentioned variables frommain>>input file will be used for further evaluations:->> >> Below is one example from this file explaining how the variablesfrom>main>>input file will be used in other files.>> >> I hope that this short information will be useful for guiding me to>solve>>the following problems that I am facing. I am facing follwingproblems>or>>objectives:->> >> 1. My 1st Objective:- The user of this package must be able tochange>only>>the value of the variable in the main input file but he must not beable>to>>change the name of the variable itself. For example he must be ableto>>change the value of the variable but he must not be able tochange>the>>name of this variable itself.>>Here our problem is how to achieve or program it so that ourobjective>will>>be fullfilled.>Options with defaulf values ? or something like>{aParam,bParam}={ODEParameter1,ODEParameter2} /.>> userRules /.>> {ODEParameter1->1,ODEParameter2->2}>> 2. My 2nd Objective:- How I can program the main input file so thatit>will>>be user friendly in terms of its visuals and satisfying theconstraint>>mentioned above in objective1.>What is *userfiendly* in a file with 250 variables ???>> 3. My 3rd Objective:- How can I program the optional values for each>>variable in the main input file ? so that there will be always avalue>>assigned to each variable listed in main input file whenever theuser>opens>>up this file. If user want to change the values of some variablesthen>he>>can change them and run the simulation otherwise the simulation runwill>be>>done with optional values assigned to each variable in the inputfile.>See above.>> 4. My 4th Objective:- How can I program the check for correctness ofthe>>input values supplied by the package user ?>And @@ (NumericQ /@ {aListOfAllYourNumericParameters})>> > > Jens>>Reply-To: kuska@informatik.uni-leipzig.de ==== => I agree with Mr. Kuska, that the system Mr Nagesh describes is not> userfriendly. But I think, the suggestions of Mr. Kuska do not make it more> userfriendly, rather the opposite is true.> Mr. Nagesh asks> Is any body here have expertise or information about the capability of> Mathematica as a system simulation tool?> Mr. Kuska answers:> Since the most system simulation tools are simply solving a system of> ordinary differntial equations it is simple to do this with NDSolve[].> My comment:> That is: He sees the simulation system merely as a set of differential> equations.hmm, since the original poster writeMy refrigeration system simulation package is likely to have approximately 60 First order Differential equations.it seems not completly wrong to assume that the system consists ofof ode's ..> The question of Mr. Nagesh:> My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?> The answer of Mr. Kuska is:> And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> My comment:> This is a nice command and shows the knowledge of Mr.Kuska. But does Mr.> Nagesh understand it and is it sufficient to check, if all inputs are> numerical?It seems you have a deeper knowlege about the things that Mr. Nagesh understand. You know him personally ? It is not very polite tomake speculations *what* a other person understand.And no it is not sufficent to check that all parameters are numbers.Typical paramters described by intervals, where the assumptions ofa model are valid. But for this checks one needs more knowlege about the meaning of the parameters. And one needs the knowlege aboutthe differntial equations, to find out the eigenvalues of the jacobian...> Additionally I think, it is not userfriendly to see the input merely as a> set of 200-250 numbers.> My suggestion is, that JLink is used, a suggestion Mr. Kusk takes into> consideration, too.That will be fast as lightning ! > But further I suggest, that classes are defined in Java, which represent the> parts of the system.That is notable nonsense! When the differntial equations should besolved with Mathematica, the parts can't be Java classes. Mathematica'sNDSolve[] need a explicit expression to integrate the equations.OK you can call a Java class member from Mathematica but this willbe incredible slow when the right hand side is evaluated 200-300times and every evaluation make several callbacks to the Java source.Event handler of the Java main program (without some modification inthe event loop) while it is evaluating an other command.> Constructors of the classes should build objects with default values.That's a great idea. If a simulation run should be documented, onealwaysneed the full listing of the Java source to find the actual parametersettings. > Graphical user interfaces> should give the opportunity to change the data fields in the objects and> check the input for correctness.*and* what has a GUI for 200-250 variables to do with Mathematica ?BTW one has typical much less variables because many parametersare fixed and it make no sense to change, for example, materialconstants of materials that can't exchanged> The system should give the opportunity, to store the objects on harddisk> (serialization).> accessed directly.> Can you be so kind, to explain *how* your posting help a person thatask How can I build a simulation system with Mathematica ?You *can* say Don't use Mathematica, use Java! but this has nothingto do with the question or with my reply. But I still would suggest to use C/C++ and a numerical ode-solver, make a fancy GUI/Scriptinterface and don't use Mathematica for such a simple task.The ode-solver is the smallest part of such a simulation system. Jens> >My name is Nagesh and pursuing research studies in Refrigeration. At>> present I am writing a Dynamic Refrigeration System Simulation Package.> I>> am using Mathematica as a programming language for the same since last> one>> year. I don't have any programming experience before this. I have> following>> querries:->> 1. Is any body here have expertise or information about the capability> of>> Mathematica as a system simulation tool?> > Since the most system simulation tools are simply solving a system of>ordinary differntial equations it is simple to do this with NDSolve[].> >2. Is is possible to program a user friendly interface for my system>> simulation package with Mathematica or I have to use some other> software?> > Write a MathLink or J/Link frontend that launch the kernel. But you>should keep>in mind that the user interface is typical 80-90 % of your code.>If you just whant to solve some ode's it is probably easyer to>include one of the excelent ode-solvers from netlib in your C-code>than to call Mathematica to do that. As long as you dont wish to change>the ode's very often (than Mathematica is more ßexible) you should>not use Mathematica.> >3. My refrigeration system simulation package is likely to have>> approximately 60 First order Differential equations. Is is possible to>> solve these in Mathematica ?> > Sure.>> If yes then can anybody here guide me about>> this further.> > Write down the equations and call NDSolve[].> > >I am explaining below in short about the objectives I want to fulfill> from>> coding out of my main input file>1. Example from Main Input File ( this will contain about 200-250> variables>> which will be entered by the user of this package)> > This sounds like a *very* userfiendly interface ;-)> > >Below is examples of two variables entered into this file, which will be>> used in other analysis files for further evaluation.>2. Example from other analysis file ( there will be about 20-25 other> such>> component analysis files ) where the above mentioned variables from main>> input file will be used for further evaluations:->Below is one example from this file explaining how the variables from> main>> input file will be used in other files.>I hope that this short information will be useful for guiding me to> solve>> the following problems that I am facing. I am facing follwing problems> or>> objectives:->1. My 1st Objective:- The user of this package must be able to change> only>> the value of the variable in the main input file but he must not be able> to>> change the name of the variable itself. For example he must be able to>> change the value of the variable but he must not be able to change> the>> name of this variable itself.>> Here our problem is how to achieve or program it so that our objective> will>> be fullfilled.> > Options with defaulf values ? or something like> > {aParam,bParam}={ODEParameter1,ODEParameter2} /.> userRules /.> {ODEParameter1->1,ODEParameter2->2}> > >2. My 2nd Objective:- How I can program the main input file so that it> will>> be user friendly in terms of its visuals and satisfying the constraint>> mentioned above in objective1.> > What is *userfiendly* in a file with 250 variables ???> > >3. My 3rd Objective:- How can I program the optional values for each>> variable in the main input file ? so that there will be always a value>> assigned to each variable listed in main input file whenever the user> opens>> up this file. If user want to change the values of some variables then> he>> can change them and run the simulation otherwise the simulation run will> be>> done with optional values assigned to each variable in the input file.> > See above.> > >4. My 4th Objective:- How can I program the check for correctness of the>> input values supplied by the package user ?> > And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> > Jens>Reply-To: kuska@informatik.uni-leipzig.de ==== => My name is Nagesh and pursuing research studies in Refrigeration. At> present I am writing a Dynamic Refrigeration System Simulation Package. I> am using Mathematica as a programming language for the same since last one> year. I don't have any programming experience before this. I have following> querries:-> 1. Is any body here have expertise or information about the capability of> Mathematica as a system simulation tool?Since the most system simulation tools are simply solving a system ofordinary differntial equations it is simple to do this with NDSolve[].> 2. Is is possible to program a user friendly interface for my system> simulation package with Mathematica or I have to use some other software?Write a MathLink or J/Link frontend that launch the kernel. But youshould keepin mind that the user interface is typical 80-90 % of your code.If you just whant to solve some ode's it is probably easyer toinclude one of the excelent ode-solvers from netlib in your C-codethan to call Mathematica to do that. As long as you dont wish to changethe ode's very often (than Mathematica is more ßexible) you shouldnot use Mathematica.> 3. My refrigeration system simulation package is likely to have> approximately 60 First order Differential equations. Is is possible to> solve these in Mathematica ?Sure. > If yes then can anybody here guide me about> this further.Write down the equations and call NDSolve[].> I am explaining below in short about the objectives I want to fulfill from> coding out of my main input file> 1. Example from Main Input File ( this will contain about 200-250 variables> which will be entered by the user of this package)This sounds like a *very* userfiendly interface ;-)> Below is examples of two variables entered into this file, which will be> used in other analysis files for further evaluation.> 2. Example from other analysis file ( there will be about 20-25 other such> component analysis files ) where the above mentioned variables from main> input file will be used for further evaluations:-> Below is one example from this file explaining how the variables from main> input file will be used in other files.> I hope that this short information will be useful for guiding me to solve> the following problems that I am facing. I am facing follwing problems or> objectives:-> 1. My 1st Objective:- The user of this package must be able to change only> the value of the variable in the main input file but he must not be able to> change the name of the variable itself. For example he must be able to> change the value of the variable but he must not be able to change the> name of this variable itself.> Here our problem is how to achieve or program it so that our objective will> be fullfilled.Options with defaulf values ? or something like{aParam,bParam}={ODEParameter1,ODEParameter2} /. userRules /. {ODEParameter1->1,ODEParameter2->2}> 2. My 2nd Objective:- How I can program the main input file so that it will> be user friendly in terms of its visuals and satisfying the constraint> mentioned above in objective1.What is *userfiendly* in a file with 250 variables ???> 3. My 3rd Objective:- How can I program the optional values for each> variable in the main input file ? so that there will be always a value> assigned to each variable listed in main input file whenever the user opens> up this file. If user want to change the values of some variables then he> can change them and run the simulation otherwise the simulation run will be> done with optional values assigned to each variable in the input file.See above.> 4. My 4th Objective:- How can I program the check for correctness of the> input values supplied by the package user ?And @@ (NumericQ /@ {aListOfAllYourNumericParameters})> Jens ==== =You would need to make assumptions about y, and you can't. The functionand the limits have to take care of that, and when you try to do that,you end up with an expression that has different antiderivatives ondifferent regions, for different values of x. So, you have to break itup. The assumption x > 0 implies that x is real, so Im[x]==0 isunnecessary.one = Integrate[Cosh[2 (y - x)] 2 y, {y, Min[x, 1/2], 1/2}, Assumptions -> {x > 0}];two = Integrate[Cosh[2 (x - y)] 2 y, {y, 0, Min[x, 1/2]}, Assumptions -> {x > 0}];one + two // FullSimplifyPlot[{one, two, one + two}, {x, 0, 1/2}]; (1/4)*E^(-1 - 2*x)*(E + (-2 + E)*E^(4*x))Bobby Treat-----Original Message----- there something implicit that I am missing in the Assumptions ?MS.-- 12:02am up 5:06, 1 user, load average: 0.54, 0.22, 0.08Reply-To: spammers-go-here@yahoo.com ==== =you want to suppress.For instance try dividing by zero: 1/0 !(Power::infy ((:)( )) Infinite expression !(1/0) encountered.) ComplexInfinity Off[Power::infy]Then try dividing by zero again. 1/0 ComplexInfinity--Steve LuttrellWest Malvern, UK> Dear Mathgroup,>> I have a function defined as>> f = Compile[{{arg1, _Real, 2}, {arg2, _Real}, {arg3, _Real}, Module[ {},> expr]]>> and I want to use a a non-Real assignment to arg2 called x, Mathematica> real, but it still returns the correct symbolic expression for f. How do I> assignment a little more thoroughly inside Compile?>> Yas> ==== =Hi,Mathematica functions such as LinearSolve, LinearProgramming,FindMinimum and many others, sometimes cannot perform therequested task. (The linear system of equations has no solution, thelinear program has no feasible points, etc.)and then returns the expression it tried to evaluate. This happens,for example, with LinearSolve[{{1, 2}, {3, 4}, {5, 6}}, {-1, 2, -3}].This may be reasonable when only one such calculation is performed.But, suppose we write a program that has to solve many linearprograms, some of them without a feasible solution. When there isno solution, we want to take an appropriate action.What is the recommended way of calling a function likeLinearProgramming and getting an indication that somethingIt is possible to catch errors using ÔCheck'. But, as far as Iusing ÔOff'.of the expression returned to see if it the name of the function called.For example:Off[LinearSolve::nosol] ;If[ SameQ[ Head[sol = LinearSolve[...]] , LinearSolve] , (* The calculation failed. *) , (* sol is a solution. *) ](Note that we have to put sol = LinearSolve[...] insidesol = LinearSolve[...] ;If[ SameQ[Head[sol],LinearSolve] , ... , ... ]then in case of failure, the failed calculation will beattempted again!)Is there a cleaner solution?Uri------------------------------------------------- --------------------| Prof. Uri Zwick | http://www.cs.tau.ac.il/~zwick || Dept. of Computer Science | zwick@post.tau.ac.il || ISRAEL | FAX: +972 3 6409357 |------------------------------------------------------------ ---------Reply-To: drbob@bigfoot.com ==== =Mihajlo's method doesn't work well with small sample sizes, so I'd suggest this:<< Statistics`DescriptiveStatistics`xlist = 0.202 + 1.618 Table[0.001 Random[] + Random[Integer, {3, 17}], {20}];error = 0.5;xxlist = Mean /@ Split[Sort[xlist], #2 - #1 < error &];Fit[xxlist, {1, x, x^2}, x];{a, b, c} = CoefficientList[%, x];{Mod[a, b], b}gaps = Subtract @@@ Transpose@{Rest@xxlist, Drop[xxlist, -1]};ratios = gaps/Min@gaps;gcd[ratios_List] := Module[{n = 2, k}, While[n < 10 && (k = n/GCD @@ Round[n*ratios]) .89.81« n, n++]; k ]b2 = Min[gaps]/gcd@ratios;{a2 = Mean@Mod[xxlist, b2], b2}{1.18984, 1.39711} (* Mihajlo's method with Mean in place of First *){0.207753, 1.6175} (* better *)With as few as four samples, this often returns the right period, while the other method rarely gets it right even with 20 samples.You shouldn't make the error estimate too small --- a fourth of the period is about right. (But you don't know the period in advance.) A more complete method would adjust the error estimate after estimating the period, to see if the answer changes.BobbyOn Sun, 9 Feb 2003 04:50:32 -0500 (EST), Scott A Centoni > The following response from Mihajlo Vanevic has solved my problem, and I > thought it would be helpful to others as well:>>Ok, now I get it... ;o)>>But if you know that your error is, say, less than 0.01,>try this dirty (but rather fast) approach:>>In[]:=>xlist = 0.202 + 1.618 Table[0.001 Random[] + Random[Integer, {3, 17}], > {100}];>>In[]:=>error = 0.01;>>In[]:=>xxlist = First /@ Split[Sort[xlist], #2 - #1 < error &];>>In[]:=>Fit[xxlist, {1, x, x^2}, x]>> Mihajlo Vanevic> mvane@EUnet.yu> 2003-02-07>>************************************************* *************>* At 2003-02-07, 03:07:00>**************************************************** **********>>>that my sample fake data set is misleading, I should have specified it>>as>>xlist = 0.202 + 1.618 Table[0.001 Random[] +>>Random[Integer,{3,17}],{100}]>>to make it crystal clear that no correlation between successive items > in>>the list is implied and that the order is completely irrelevant.>I have a list of coordinates where I want to find the period and > offset>(modulo the period). To illustrate, let's create the fake data set>>xlist = 0.202+1.618(0.001 Random[ ] + Range[3, 17])>>I want a function that will return>>periodicity[xlist]>>{1.618,0.202}>>_pace_ an error in the third decimal place. Note that the order of > the>data in the list is irrelevant; it's to be considered a set, not a > vector.>>My first thought is to turn this into a sum of delta functions>>xfunc = Plus@@(DiracDelta[x-#]&/@xlist)>>and then Fourier transform this>>kfunc = FourierTransform[xfunc,x,k]>>and find the first nontrivial peak. Does someone have a better way? > Or>if not, what's the best way of locating the peak?>>Scott>>*********************************************** ***************>>>>>-- ==== =====The reason why the graphs seem to be non-aligned is that the tick labels areof different length (i.e., the plots are aligned; it is the axes that arenot vertically aligned). Viz., 0.9 has three positions, whereas -0.5 hasfour. Try, for example,In[1]:=plots = Table[Plot[Sin[i*x], {x, 1, Pi}, Ticks -> None], {i, 1, 3}];Show[GraphicsArray[ Partition[plots, 1], GraphicsSpacing -> {1, -0.1}]]The axes are now aligned as you wish.One way to deal with the problem is to redefine the ticks on the verticalaxes using strings instead of numbers so that all the tick labels have thesame length.Tomas GarzaMexico City----- Original Message -----> x axis spanning the whole x resolution and y axis only one third of y> resolution?> Cyril Fischer>> ==== => I have a complex-valued function f(z).> If z = x + I y, suppose f(z) has a finite number of simple zeros> in the rectangle a < x < b, c < y < d. (and no poles).> I can start FindRoot somewhere and it will likely find a root.> But, my question is:> is there a (best?) systematic way to use Mathematica to find> all the roots in the region?A method using the Cauchy integral formula for finding roots on asegment may be found athttp://forums.wolfram.com/mathgroup/archive/2001/Jun/ msg00444.htmlIt is not hard to modify this technique to work with a rectangle.Daniel LichtblauWolfram Research ==== =Here is one approach, which is far form perfect, but probably could be developed to do what you want.The idea is basically to parse your expression before applying plotting lines and replace things like{LineColor[Red], ColoredLine[{0, 1}, {1, 1}]}byBlock[{currentcolor=Red}, ColoredLine[{0, 1}, {1, 1}]Here is a function that will do this, at least in simple cases:SetAttributes[ff,HoldAll]ff[expr_]:=Hold[expr]/. HoldPattern[{y___,LineColor[c_],x___}]:>Block[{currentcolor=c },{y,x}]/;FreeQ[HoldPattern[{x,y}],LineColor]Using your definitions both: {ColoredLine[{0, 0}, {1, 0}], LineColor[Red], ColoredLine[{0, 1}, {1, 1}], LineColor[Blue], ColoredLine[{0, 2}, {1, 2}]}]and {ColoredLine[{0, 0}, {1, 0}], {LineColor[Red], ColoredLine[{0, 1}, {1, 1}]}, ColoredLine[{0, 2}, {1, 2}]}]seem now to work correctly.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> Dear MathGroup,>> I am working on an application where I define a number of graphical > objects,> which can then be used like graphical primitives. I also want to define> graphical primitives that will control the color, position and size of > some> of these objects. The use of color is slightly complicated because the > color> that is set may be used for lines, or in SurfaceColor or in EdgeForm > and it> may be lightened or darkened.>> My basic approach is to store the value of the directives in internal> variables and then the graphical primitives use these values.>> But it is difficult to make it all behave just like regular Mathematica> graphical directives.>> 1) The list of primitives must be HoldFirst. Premature evaluation will > cause> the last instance of a programmed directive to be used for all cases.> 2) The default values of any primitives must be set before the > primitives> are evaluated else whatever is left over from the last plot will be > used.>> I can pretty much handle those problems. The last problem is more > difficult> and is the core of my question.>> 3) Regular graphics directives are nested in the sense that if one is > set> inside brackets, {directive,... }, then, after exiting the brackets, > the> directive reverts to the value existing before the brackets were > entered.>> Is it possible to program that behavior?>> Here is an example. It could be done with regular Mathematica > directives,> but it was picked to be a simple example. In my actual cases I have to > use> programming. The extra graphical primitive is a ColoredLine. The color > to be> LineColor. The value is stored in currentcolor.>> Needs[Graphics`Colors`]>> currentcolor = Black;> ColoredLine[start_, end_] := {currentcolor, Line[{start, end}]}> LineColor[color_] := (currentcolor = color; Sequence[])>> Show[Graphics[> {LineColor[Black], Sequence @@ primitives}], opts]>> In the following use everything works.>> {ColoredLine[{0, 0}, {1, 0}],> LineColor[Red],> ColoredLine[{0, 1}, {1, 1}],> LineColor[Blue],> Coloredline[{0, 2}, {1, 2}]},> Background -> Linen,> ImageSize -> 400];>> But if I use nesting it, of course, doesn't work like regular > Mathematica> directives. The color does not revert to Black.>> {ColoredLine[{0, 0}, {1, 0}],> {LineColor[Red],> ColoredLine[{0, 1}, {1, 1}]},> Coloredline[{0, 2}, {1, 2}]},> Background -> Linen,> ImageSize -> 400];>> It appears that I need to somehow implement a recursive evaluation of > the> primitives list. Any ideas on how I could do that.>> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/>>> ==== =I made a number of changes. I believe the programmed directives now behaveexactly like regular graphics directives. Here is a toy example.Needs[Graphics`Colors`]currentcolor = Black;currentwidth = 1;ColoredLine[start_, end_] := {currentcolor, AbsoluteThickness[currentwidth], Line[{start, end}]}LineColor[color_] := (currentcolor = color; {});LineThickness[width_] := (currentwidth = width; {}); Module[{blockprimitives = Hold[primitives], STOP}, blockprimitives = blockprimitives //. HoldPattern[p : {s_, x___}] /; s =!= STOP [And] å FreeQ[Hold[p], LineColor | LineThickness, {3}] :>Block[{currentcolor = currentcolor, currentwidth = currentwidth}, {STOP, s, x}]; blockprimitives = blockprimitives /. STOP -> Sequence[]; currentcolor = Black; currentwidth = 1; Show[Graphics[ Sequence @@ blockprimitives], opts]]1) We have to reset the current directives after making the Blocksubstitutions because they get evaluated somewhere along the line.2) We need ReplaceRepeated to get all levels. A STOP argument is added atthe head of the list to prevent repeated Blocks of the same list.3) We keep the directives in the primitives list.4) We set the primitive values to the current values when entering theBlock.Here are several examples. The lines are stacked vertically in order ofdrawing. {ColoredLine[{0, 0}, {1, 0}], LineColor[Red], ColoredLine[{0, 1}, {1, 1}], LineColor[Blue], LineThickness[2], ColoredLine[{0, 2}, {1, 2}]}, Background -> Linen]; {ColoredLine[{0, 0}, {1, 0}], {LineColor[Red], ColoredLine[{0, 1}, {1, 1}], {LineColor[Blue], ColoredLine[{0, 1.1}, {1, 1.1}], LineColor[Green], LineThickness[2], ColoredLine[{0, 1.2}, {1, 1.2}]}, ColoredLine[{0, 1.4}, {1, 1.4}]}, ColoredLine[{0, 2}, {1, 2}], LineColor[DarkSeaGreen], ColoredLine[{0, 2.5}, {1, 2.5}]}];David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ SetAttributes[ff,HoldAll]ff[expr_]:=Hold[expr]/.HoldPattern[{ y___,LineColor[c_],x___}]:>Block[{currentcolor=c},{y,x}]/; FreeQ[HoldPattern[{x,y}],LineColor]Using your definitions both: {ColoredLine[{0, 0}, {1, 0}], LineColor[Red], ColoredLine[{0, 1}, {1, 1}], LineColor[Blue], ColoredLine[{0, 2}, {1, 2}]}]and {ColoredLine[{0, 0}, {1, 0}], {LineColor[Red], ColoredLine[{0, 1}, {1, 1}]}, ColoredLine[{0, 2}, {1, 2}]}]seem now to work correctly.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== =There is a explanation of the difference between Interpolate, Fit and NonlinearFit, along with a discussion of when to use each in the online Mathematica library.http://library.wolfram.com/examples/curvefit/Ian>>> Another in a series of potentially simple questions:>> What is the difference between using Fit and Interpolation?> f[x_]=Fit[data, {1,x},x]> -or-> f[x_]=Interpolation[data][x]>> I do know that Fit can take arguments for the independant variables> form like:> f[x_]=Fit[data, {1,x},x]> f[x_]=Fit[data, {1,x,x^2},x]> but that's a bit of guesswork if you have a limited set of points, no?>> Also, is there a function in Mathematica that allows me to swap> dependent and independent variables? e.g. x=2.5y --> y=x/2.5>>> David Seruyange> Student ==== =Interpolation[data][x] is perfectly good syntax. For instance:data = {#, #^3 + Random[]} & /@ Range[0, 5, 0.2];x=3;Interpolation[data][x]27.9333BobbyOn Tue, 4 Feb 2003 02:23:45 -0500 (EST), Bill Rowe What is the difference between using Fit and Interpolation?>> f[x_]=Fit[data, {1,x},x] -or-f[x_]=Interpolation[data][x]>> There are several differences between the expressions above>> First, Interpolation[data][x] isn't correct syntax. It should be > Interpolation[data]. Interpolation returns a pure function of data. By > default that is a 3rd order polynominal that passes through each of the > points specified by the variable data.>> In contrast, Fit[data,{1,x},x] returns a best fit *line* for the points > specified by data. The result is not a pure function but an expression. > The result is a least squares fit to the data and will not pass through > the points specified unless they lie exactly on a line.>> The two functions, Interpolation and Fit, are intended for different > purposes.>> Suppose you had a list of data points that were known to be accurate to > the precesion specified and wanted to estimate the value of the unknown > function at an intermediate point. For this you would use interpolation > since you want the result to pass through each of the data points you > started with.>> Now suppose you had a list of data points where each data point you have > is really the sum of a true value and a random error. The best result > would ideally subtract out the error and yeild the true values. So, you > would definitely not want the result to pass through the points with > error. For this problem you would use Fit.>>-- majort@cox-internet.comBobby R. Treat ==== = I want to produce a table of text output (in the same notebookmy code is in). The output consists of many rows of numbers, each rowcontaining the same number of numbers. For example the entire outputmight consist of 500 rows each having 7 columns. It is important forunderstanding the output to have well-formatted columns of a constantwidth regardless of the number of digits in each number (which will beno more than say 9). In the columns the numbers should beright-aligned. Print does not seem to have enough control to do this. It'smuch less ßexible than the print statement in C. What I need issomething like that. I've been reading the book, sections 2.7, 2.8,etc., and it looks like I will have to write an actual (small) programto do this. I'd appreciate any suggestions or leads to a package where allthis is already done. Many thanks.Steve Gray ==== =I'm trying to map (interpolate) temperatures from one 2D set of pointsto another for a finite element application. The initial set ofpoints is {x1,y1,t1} and the second set is {X1,Y1,T1}, and I know allthe values except for T1. I have connectivity data for the new mesh{X1,Y1}, but not for the original mesh (x1,y1).I have downloaded the ExtendGraphics package, and it has a functions(TriangularInterpolate) which should do exactly what I need. No erroris given when I initially use it(interpFunc=TriangularInterpolate[nodeTemp], where nodeTemp is a3-column matrix). However, when I invoke it again (interpFunc[x1,y1]),I get a series of errors, primarily about reaching the recursion oriteration limits. Could this have to do with the size of the initialmatrix (~15,000 sets of data), or is there a different problem? Itonly seems to work correctly when the point is outside of the initialregion, or if all the nearest nodes have the same temperature.After this setback, I planned to use the Delaunay function in the samepackage to help write my own interpolation routine. Using thisfunction should return three sets of data: the Convex Hull, AdjacencyMatrix and the Triangles. However, it appears that only the ConvexHull and the Triangles are returned; to effectively write aninterpolation routine, the Adjacency Matrix is crucial. How can I getthis data from the Delaunay function?Any advice on solving this problem is greatly appreciated, whether youcan suggest an alternative approach or provide a means to use these ==== =Hola Emilio,The problem, I'm pretty sure, lies in the preliminary loading of packagessuch as Calculus` and Graphics`. I loaded mathStatica` in a fresh sessionand everything went OK. When I tried to load it after previously havingloaded the other packages, it gave the same error as you report (in fact itadvises that mathStatica should be loaded first of all in a fresh session).Same with Combinatorica (in this case, it is not an error but a warning(symbol may shadow or be shadowed etc.).If you are going to use mathStatica or Combinatorica, cancel your autoloadsso that they will not interfere.Tomas GarzaMexico City----- Original Message -----> in context !(DiscreteMath`Combinatorica`) may shadow or be shadowedby > other definitions.> *)> (*> Star::shdw: Symbol !(Star) appears in multiple contexts > !({DiscreteMath`Combinatorica`, Graphics`MultipleListPlot`}); > definitions in context !(DiscreteMath`Combinatorica`) may shadow orbe > shadowed by other definitions.> *)> (*> Vertices::shdw: Symbol !(Vertices) appears in multiple contexts> !({DiscreteMath`Combinatorica`, Geometry`Polytopes`});definitions > in context !(DiscreteMath`Combinatorica`) may shadow or be shadowedby > other definitions.> *)>> And when loading mathStatica with <> (*> Grad::shdw: Symbol !(Grad) appears in multiple contexts !(> [LeftSkeleton] 1 [RightSkeleton]); definitions in context > !(mathStatica`Code`mScode`) may shadow or be shadowed by other > definitions.> *)> (*> Hessian::shdw: Symbol !(Hessian) appears in multiple contexts!({> mathStatica`Code`mScode`, Personal`PVectorCalculus`});definitions > in context !(mathStatica`Code`mScode`) may shadow or be shadowed by> other definitions.> *)> (*> M::shdw: Symbol !(M) appears in multiple contexts > !({mathStatica`Code`mScode`, DiscreteMath`Combinatorica`}); > definitions in context !(mathStatica`Code`mScode`) may shadow or be> shadowed by other definitions.> *)>> Please, any help on how to solve it? There are not any other explicit> packages loaded but I have the following in autoload -> Calculus,> Graphics, Statistics, and Personal (this with some private utilities).> Emilio Martin-Serrano>>>> ___________________________________>> ==== =Kyriakos,original programming - much depends how much you want to do). In generalwe want to model built in function behaviour by returning univaluated whensomething goes wrong.(1) Options[f]:= {Diameter->1,Shape-> Circle}; f[x_, opts___?OptionQ]:= Module[{shp, diam}, {shp,diam}= {Shape,Diameter}/. Flatten[{opts}]/.Options[f]; If[ MatchQ[{shp,diam}, {Circle,_?Positive}|{Ellipsis,{_?Positive,_?Positive}}], program[x,opts], Message[f::bdshpdiam] ]] f::bdshpdiam= The values of the options Shape and Diameterincompatible.;TEST. f[aa] program[aa] f[aa, Diameter->{2,3}] f::bdshpdiam: The values of the options Shape and Diameterincompatible.(2)Here is an example of a ßexible trechnique that allows us to monitor theevaluation process and act on what happens. middle[x___]:=With[{result=middle1[x]},result/;result=!=$ Failed]We now test all aspects of the input and on-going evaluation and act on whatwe find. middle1[x___]:= Module[{tag}, Catch[If[ Length[{x}] ==== 1, If[OddQ[Length[x]],Throw[x[[Ceiling[Length[x]/2]]],tag], Message[middle::nodd];Throw[$Failed, tag]], Message[middle::argx,middle, Length[{x}]];Throw[$Failed,tag] ], tag] ] middle::nodd = The argument of middle is expected to be normal with an odd numberof elements;TEST middle[{1,2}] middle::nodd: The argument of middle is expected to be normal withan odd number of elements middle[{1,2}] middle[1,2] middle::argx: middle called with 2 arguments; 1 argument isexpected. middle[1,2] middle[p[1,2,3]] 2--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> Dear all,>> Suppose I create a function f[x_,opts___]> with options> Shape in {Circle, Ellipsis} and Diameter in R+, DiameterLong in R+,> DiameterShort in R+> Say that the defaults are> Options[x]={Shape->Circle, Diameter->1.}>> The option Diameter makes sence only when Shape->Circle, and> The options DiameterShort/Long make sense only when Shape->Ellipsis>> Is there a quick way to tell Mathematica to warn if these conditions are> not satisfied? I could write a series of boolean tests, but I waswondering> if there is a more elegant way.>> Best,>> Kyriakos>> _____+**+____+**+___+**+__+**+_>> Kyriakos Chourdakis> Lecturer in Financial Economics>> URL: http://www.qmw.ac.uk/~te9001> tel: (++44) (+20) 7882 5086> Dept of Economics> University of London, QM> London E1 4NS> U.K.> ==== =Trybase = 2; number = 11111111;ToExpression[ToString@Evaluate@base <> ^^ <> ToString@Evaluate@number]or>it seems I have a simple problem, but I cannot find a (simple)solution:>>if I type 2^^1000111 mathematica calculates the correct dec. number>>but if I type: base=2; number=1000111; base^^number all I get is a error>>So a function Convert[number_,base_] for base convertions cannot work ...>Any ideas>Thx>Werner>-->>**************************************** ***********************************>Prof. Mag. Werner CYRMON>HTBLuVA Wr. Neustadt Abt. EDVO>http://edvowww.htlwrn.ac.at/cyx>************************ ***************************************************>If you can imagine it, you can do it! Walt Disney>****************************************************** *********************>Want to learn math with fun or calculating some stuff online:>Look at http://Onlinemath.htlwrn.ac.at******************************* ******************************* ==== =Werner,Imagine typing in and you can do it! Convert[number_,base_]:= ToExpression[ToString[base]<>^^<>ToString[number]]Test: base=2; number=1000111; Convert[number,base] 71 --Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> Hi> it seems I have a simple problem, but I cannot find a (simple)solution:>> if I type 2^^1000111 mathematica calculates the correct dec. number>> but if I type: base=2; number=1000111; base^^number all I get is a error>> So a function Convert[number_,base_] for base convertions cannot work ...> Any ideas> Thx> Werner> -->>********************************************************* ******************> Prof. Mag. Werner CYRMON> HTBLuVA Wr. Neustadt Abt. EDVO> http://edvowww.htlwrn.ac.at/cyx>***************************** **********************************************> If you can imagine it, you can do it! Walt Disney>****************************************************** *********************> Want to learn math with fun or calculating some stuff online:> Look at http://Onlinemath.htlwrn.ac.at>Approved: Steven M. Christensen , Moderator ==== =What's the best way (simple, general and without dummy functions) to define in mathematica 4.2 a differential operator?For example, how can I evaluate laplacian operator in spherical coordinates ? (without using ad-hoc packages... i want to enter expression of d/dx, d/dy, d/dz and mathematica must compute (d/dx)^2+(d/dy)^2+(d/dz)^2)How can i evaluate powers,product etc... of operators ?Help me, thanksPaolo Zavarise ==== =Cyril,There is a package available at MathSourcehttp://library.wolfram.com/database/MathSource/717/ called MongoArray which deals with problems of this kind. Perhaps you liketo try that out. The package isn't perfect however, in the sense that itrestricts somewhat the range for own creative design(Gestaltungs.87spielraum) from what we are used to with Mathematica's plotfunctions.For years I plan to polish that up, but it's to far down on my prioritylist. Nonetheless I'd like to hear from your experiences with it, may be Ican give you a direct hint then.--Hartmut>-----Original Message----->Sent: Tuesday, February 04, 2003 8:22 AM>To: mathgroup@smc.vnet.net>Hi, >How can I (vertically) align several Plots (graphs) in the>GraphicsArray to have y axis in the same x position?>Somehing like >plots = Table[Plot[Sin[i x], {x, 1, [Pi]}], {i, 1, 3}];>Show[GraphicsArray[Partition[plots, 1], GraphicsSpacing -> {1, -0.1}]]And how can I impose the AspectRatio of the individual graphs to have>x axis spanning the whole x resolution and y axis only one third of y>resolution?>Cyril Fischer> ==== =while doing some crypto stuff with affine ciphers, we need to find matrixinverse mod some N.Sometimes, the plaintext-ciphertext pairs do not allow for inversion when Nis composite.We can write the matrix as a linear combination of the factor of N andproceed to find an invertible matrix.Here are the steps to such a task.***(* Problem III.2, #23 a., b. and c. Wilson Figueroa *)matlist[n_, p_] := Map[Partition[#, n] &, Flatten[ Outer[List, Apply[Sequence, Table[Range[0, p - 1], {n^2}]]], n^2 - 1]]p = {{3, 3}, {2, 5}};c = {{17, 8}, {8, 29}};Inverse[c, Modulus -> 30]aa = matlist[2, 3];a0 = {{7, 9}, {6, 9}};a = Table[(3*a0 + 10*aa[[i]]), {i, 1, Length[aa]}];b = Table[Mod[a[[i]], 3], {i, 1, Length[a]}];d = Table[GCD[Det[b[[i]]], 3], {i, 1, Length[b]}];dd = Flatten[Position[d, 1]]e = Table[a[[dd[[i]]]], {i, 1, Length[dd]}];g = Table[Mod[e[[i]], 30], {i, 1, Length[e]}];h = g.p;w = Table[Mod[h[[i]], 30], {i, 1, Length[h]}];x = Flatten[Position[w, {{17, 8}, {8, 29}}]]y = Table[g[[x[[i]]]], {i, 1, Length[x]}]Table[MatrixForm[y[[i]]], {i, 1, Length[y]}](* Verify Result *)z = Table[Mod[y[[i]].p, 30], {i, 1, Length[y]}]Table[MatrixForm[z[[i]]], {i, 1, Length[z]}]***My question is, can this process be automated for various N?When N = 26, we would have A = 2 a0 + 13 a1When N = 30, we have A = 3 a0 + 10 a1, (as shown above), etc.Hope that is clear and thanks for any inputs, Flip ==== =Displayed characters are not matching typed characters on a version 3.0Mathematica help! Example:When I type a bracket, a H is comming up. ==== => A method using the Cauchy integral formula for finding roots on a> segment may be found at http://forums.wolfram.com/mathgroup/archive/2001/Jun/msg00444 .html It is not hard to modify this technique to work with a rectangle. Daniel Lichtblau> Wolfram Researchwith relatively minor modification, it works perfectly for my problem.alan ==== =If the only shapes are Circle and Ellipse, then I would merge the two options into a single option.Diameter->d gives a Circle. Diameter->{dshort, dlong} gives an ellipse.Another technique would be to make the diameter(s) a parameter of the shape.Shape->Circle[d] and Shape->Ellipse[dshort, dlong]>Dear all,Suppose I create a function f[x_,opts___]>with options>Shape in {Circle, Ellipsis} and Diameter in R+, DiameterLong in R+,>DiameterShort in R+>Say that the defaults are>Options[x]={Shape->Circle, Diameter->1.}The option Diameter makes sence only when Shape->Circle, and>The options DiameterShort/Long make sense only when Shape->EllipsisIs there a quick way to tell Mathematica to warn if these conditions are>not satisfied? I could write a series of boolean tests, but I was wondering>if there is a more elegant way.Best,Kyriakos_____+**+____+**+___+**+__+**+_Kyriakos Chourdakis>Lecturer in Financial EconomicsURL: http://www.qmw.ac.uk/~te9001>tel: (++44) (+20) 7882 5086>Dept of Economics>University of London, QM>London E1 4NS>U.K.----------------------------------------------------- ---------Omega ConsultingThe final answer to your Mathematica needshttp://omegaconsultinggroup.com ==== =I have a list of coordinates where I want to find the period and offset (modulo the period). To illustrate, let's create the fake data setxlist = 0.202+1.618(0.001 Random[ ] + Range[3, 17])I want a function that will returnperiodicity[xlist]{1.618,0.202}_pace_ an error in the third decimal place. Note that the order of the data in the list is irrelevant; it's to be considered a set, not a vector.My first thought is to turn this into a sum of delta functionsxfunc = Plus@@(DiracDelta[x-#]&/@xlist)and then Fourier transform thiskfunc = FourierTransform[xfunc,x,k]and find the first nontrivial peak. Does someone have a better way? Or if not, what's the best way of locating the peak?ScottReply-To: rolf@mertig.com ==== =Grid[Table[Random[],{500},{7}], ColumnAlignments->Right]will do what you want.Rolf MertigMertig Consultinghttp://www.mertig.com ==== ========================= I want to produce a table of text output (in the same notebookmy code is in). The output consists of many rows of numbers, each rowcontaining the same number of numbers. For example the entire outputmight consist of 500 rows each having 7 columns. It is important forunderstanding the output to have well-formatted columns of a constantwidth regardless of the number of digits in each number (which will beno more than say 9). In the columns the numbers should beright-aligned. Print does not seem to have enough control to do this. It'smuch less ßexible than the print statement in C. What I need issomething like that. I've been reading the book, sections 2.7, 2.8,etc., and it looks like I will have to write an actual (small) programto do this. I'd appreciate any suggestions or leads to a package where allthis is already done. Many thanks.Steve Gray ==== =Steve,I'd suggest that you format the output using the TableForm command inthe first instance. Then select the cell containing the output table,open the Option Inspector (on the Format menu), then Formatting Options,then Table/Matrix/Palette Formatting, and start fiddling around.You can make the same formatting selections by setting options forTableForm, but the Option Inspector is a lot easier.Good luckMark Westwood> I want to produce a table of text output (in the same notebook> my code is in). The output consists of many rows of numbers, each row> containing the same number of numbers. For example the entire output> might consist of 500 rows each having 7 columns. It is important for> understanding the output to have well-formatted columns of a constant> width regardless of the number of digits in each number (which will be> no more than say 9). In the columns the numbers should be> right-aligned.> Print does not seem to have enough control to do this. It's> much less ßexible than the print statement in C. What I need is> something like that. I've been reading the book, sections 2.7, 2.8,> etc., and it looks like I will have to write an actual (small) program> to do this.> I'd appreciate any suggestions or leads to a package where all> this is already done.> Many thanks.> Steve Gray ==== =Have a look at TableForm. Here is a small example of what I think you mightwant to do:TableForm[{{1,2.34},{-5.6789,0}},TableAlignments->Right]-- Steve LuttrellWest Malvern, UK I want to produce a table of text output (in the same notebook> my code is in). The output consists of many rows of numbers, each row> containing the same number of numbers. For example the entire output> might consist of 500 rows each having 7 columns. It is important for> understanding the output to have well-formatted columns of a constant> width regardless of the number of digits in each number (which will be> no more than say 9). In the columns the numbers should be> right-aligned.> Print does not seem to have enough control to do this. It's> much less ßexible than the print statement in C. What I need is> something like that. I've been reading the book, sections 2.7, 2.8,> etc., and it looks like I will have to write an actual (small) program> to do this.> I'd appreciate any suggestions or leads to a package where all> this is already done.> Many thanks. Steve Gray ==== =Actually, you may format your output to any extent of embellishment desired. Suppose, e.g., you have the following table as the result of your calculations:In[1]:=result = Table[Random[Real, {0, 10000}], {10}, {7}];The display (omitted here) shows a variety of numbers, with one, two, three or four integers, and ditto for decimals. You might simply takeIn[2]:=TableForm[result]and obtain a table with constant-width columns and numbers right-aligned. However, this is not too nice, since numbers with one integer take the same space as numbers with four integers. So you might want to go much further and format your numbers so that, for example, only two decimals are shown, and integral parts are separated with commas in groups of three, say. To start with, then, define a function, say imp, which will preserve only two decimals and perform the grouping, separating with commas in groups of three:In[3]:=imp[x_] := NumberForm[x, {12, 2}, NumberPadding -> {, 0}, DigitBlock -> 3, ExponentFunction -> (Null & )];and apply it to your resultIn[4]:=c = Map[imp, result, {2}] Then the following will produce a very nice tableIn[5]:= ColumnAlignments -> {Right}]]]You may change the font, add column headings or row titles, or whatever other features you wish.Of course, you may have to spend a few hours understanding what is going on (as I had to do at one time or another), but I think it will be worth your effort.Tomas GarzaMexico City----- Original Message -----> no more than say 9). In the columns the numbers should be> right-aligned.> Print does not seem to have enough control to do this. It's> much less ßexible than the print statement in C. What I need is> something like that. I've been reading the book, sections 2.7, 2.8,> etc., and it looks like I will have to write an actual (small) program> to do this.> I'd appreciate any suggestions or leads to a package where all> this is already done.> Many thanks. Steve Gray> ==== =Steve,CellPrint is more likely than Print to do what you want:data= {{1.234,345.000006},{1.3,1.2}};CellPrint[Cell[BoxData[GridBox [data, ColumnAlignments -> {Right},GridFrame -> True,You will find the options for GridBox in the help browser.They can be applied interactively to a selected displayed grid using theOption InspectorAllan---------------------Allan HayesMathematica Training and Consu