m-129 Clear[y]; will clear y[0] y[0]=1; Clear[y]; Simplify[DSolve[{y''[t]==y[t],y[0]==1},y[t],t]] {{y[t] -> C[2]/E^t - E^t*(C[2] - 1)}} Bob Hanlon > DSolve[{y''[t] == y[t], y[0] = 1}, y, t] and end up setting y[0] to 1, instead of DSolve[{y''[t] == y[t], y[0] == 1}, y, t] However Clear[ y , y[0] , y* ] fails to Clear y[0] (not a symbol or a string) and I need to exit the > program and start again. > f[x_]:=f[x]=x^2; f/@Range[0,2]; ?f Off[RuleDelayed::rhs]; Unset/@(#[[1]]&/@Drop[DownValues[f],-1]); On[RuleDelayed::rhs]; ?f Bob Hanlon > Hi Group, Is there a straightforward way to Clear only definitions that take > certain kinds of arguments? For example, I might have f[x_]:=x^2 > f[0]=1 > f[1]=1 > f[2]=7 > ... and want to clear all f[number] definitions but not the DelayedSet > definition. (Note that the number of f[number] definitions will vary, > as will the numbers that each one takes as an argument.) My goal is to clear 'memorized' definitions after an optimization run, > where the memorized definitions are generated by a f[x_]:=f[x]=x^2 type of function, without clearing the function itself. Gareth Russell > Columbia University Gareth, f[x_] := x^2 f[0] = 1 f[1] = 1 f[2] = 7 DownValues[f] {HoldPattern[f[0]] :> 1, HoldPattern[f[1]] :> 1, HoldPattern[f[2]] :> 7, HoldPattern[f[x_]] :> x^2} DownValues[f] = Last[DownValues[f]] HoldPattern[f[x_]] :> x^2 David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Hi Group, Is there a straightforward way to Clear only definitions that take certain kinds of arguments? For example, I might have f[x_]:=x^2 f[0]=1 f[1]=1 f[2]=7 ... and want to clear all f[number] definitions but not the DelayedSet definition. (Note that the number of f[number] definitions will vary, as will the numbers that each one takes as an argument.) My goal is to clear 'memorized' definitions after an optimization run, where the memorized definitions are generated by a f[x_]:=f[x]=x^2 type of function, without clearing the function itself. Gareth Russell Columbia University this is the only support address I find in the Wolfram webpage. If I need to redirect this question to someone else, please let me know. Here is the question: I want to plot the following data set on a Log-Linear format: { {{0., 1}, ErrorBar[{0., 0.}]}, {{0.13, 0.899147}, ErrorBar[{-0.0158522, 0.0158522}]}, {{0.37, 0.585022}, ErrorBar[{-0.0403446, 0.0403446}]}, {{0.7, 0.391931}, ErrorBar[{-0.0720489, 0.0720489}]}, {{1.11, 0.319891}, ErrorBar[{-0.0331414, 0.0331414}]}, {{3.07, 0.0951042}, ErrorBar[{-0.0216138, 0.0216138}]}, {{5.97, 0.0720401}, ErrorBar[{-0.0100861, 0.0100861}]}, {{22.24, 0.0461106}, ErrorBar[{-0.0158478, 0.0158478}]} } I know I have to use MultipleListPlot to plot this, but the problem is that Mathematica will return a Linear-Linear plot rather than a Log-Linear plot. By the way, I am using Mathematica 4.1. A.Carabe Hi All I'm a new user of Mathematica.The problem is that I started using Mathematica from the middle not the beginning. Anyway, My problem is: I have two Matrices Temperature= T = [Ax8] Radial position = RR = [1x8] as an example, let A=1, instead of Plotting T vs. RR at xy-axes, I want to map the data in a cylinderical Coordinates as a contour mapping, whic means I need to copy my data to N times. My proposed procedure is to do the following: Generate a position matrix, [x,y], as follows: Do [x,y] RR=0,1,.145, Theta = 0,360,M ( M is the step 360/N) x = RR*Cos(theta) y = RR*Sin(theta) and T=T @ RR I would like to know: 1. if this is the easy way to do it ? 2. How can translate it to Mathematica Code? Hopefully it is clear! Othman > Newbie. > Acidently input > DSolve[{y''[t] == y[t], y[0] = 1}, y, t] and end up setting y[0] to 1, instead of DSolve[{y''[t] == y[t], y[0] == 1}, y, t] However Clear[ y , y[0] , y* ] fails to Clear y[0] (not a symbol or a string) and I need to exit the > program and start again. Clear[y] does not clear y[0]? If I observed that behaviour, I'd reinstall Mathematica. In[1]:= y[0] = 1; y[0] Clear[y]; y[0] Out[2]= 1 Out[4]= y[0] -- Peter Pein Berlin Hi Joseph, Enter y[0]=. to clear the definition of y[0]. In[42]:= y[0]=. In[44]:= DSolve[{y''[t][Equal]y[t],y[0]==1},y,t] Out[44]//InputForm= {{y -> Function[{t}, -((-E^(2*t) - C[2] + E^(2*t)*C[2])/E^t)]}} /J.M. > Newbie. > Acidently input > DSolve[{y''[t] == y[t], y[0] = 1}, y, t] and end up setting y[0] to 1, instead of DSolve[{y''[t] == y[t], y[0] == 1}, y, t] However Clear[ y , y[0] , y* ] fails to Clear y[0] (not a symbol or a string) and I need to exit the > program and start again. > Hi Joseph, > > Enter y[0]=. to clear the definition of y[0]. > > In[42]:= > y[0]=. > > In[44]:= > DSolve[{y''[t][Equal]y[t],y[0]==1},y,t] > > Out[44]//InputForm= > {{y -> Function[{t}, > -((-E^(2*t) - C[2] + E^(2*t)*C[2])/E^t)]}} > > /J.M. Joseph You could close the InsertPageBreak cell. It wouldn't be _zero_ height, but it would be close and not that noticeable in printouts. > Is there a SetOption type command -- sort of a SetStyle command -- > that I can put at the beginning of a notebook so that all cells of a > given style (all Subsections, maybe) in that notebook will have a > PageBreakAbove inserted in them? Or an inconspicuous command I can put into any non-Input cell that will > force the same thing? Or a force a page break here, and don't print yourself Input cell I > can insert where wanted? I know how to edit notebook style sheets to accomplish the first option > above -- but I don't want to change the default style sheet, and I'd > just as soon not use a custom style sheet for every notebook. And InsertPageBreak[]:=StylePrint[ ,Output,PageBreakAbove->True]; accomplishes the third option, but I haven't figured out how to not have > this line appear in the resulting printout, along with an unwanted blank > print line. -- Chris Chiasson http://chrischiasson.com/ 1 (810) 265-3161 Is there a SetOption type command -- sort of a SetStyle command -- that I can put at the beginning of a notebook so that all cells of a given style (all Subsections, maybe) in that notebook will have a PageBreakAbove inserted in them? Or an inconspicuous command I can put into any non-Input cell that will force the same thing? Or a force a page break here, and don't print yourself Input cell I can insert where wanted? I know how to edit notebook style sheets to accomplish the first option above -- but I don't want to change the default style sheet, and I'd just as soon not use a custom style sheet for every notebook. And InsertPageBreak[]:=StylePrint[ ,Output,PageBreakAbove->True]; accomplishes the third option, but I haven't figured out how to not have this line appear in the resulting printout, along with an unwanted blank print line. You can use UnitStep (or Which) and FunctionInterpolation to make a new interpolating function. > Is there a way to combine two InterpolatingFunctions which share a > common boundary, and are C0 continuous at the common boundary (the > values are continuous but the derivatives are NOT continuous at the > common boundary)? For example, I'm trying to combine the following: a1=NDSolve[large differential equation system, {t,0,10}] {{e2f -> InterpolatingFunction[{{0., 10.}}, <>], E2F -InterpolatingFunction[{{0., 10.}}, <>], etc...}} a2=NDSolve[large differential equation system, {t,10,20}] > {{e2f -> InterpolatingFunction[{{10., 20.}}, <>], E2F -InterpolatingFunction[{{10., 20.}}, <>], etc...}} and the combine a1 and a2 so that I get the following: > a3=Merge[a1,a2] > {{e2f -> InterpolatingFunction[{{0., 20.}}, <>], E2F -InterpolatingFunction[{{0., 20.}}, <>], etc...}} I've read that the InterpolatingFunction internals may be version > specific, and I can't quite infer what they all mean. I'm using > Mathematica version 5.0 -Kerry Kim -- Chris Chiasson http://chrischiasson.com/ 1 (810) 265-3161 Hi Kerry and Chris, If your functions are only C0 at the boundary, then FunctionInterpolation will distort the merged function near the boundary. In version 5.1 there is Piecewise that takes care of this problem. However, depending of what you want to do with the merged function, there may be a much simplier solution: a3[x_]= If[x<=10,a1[x],a2[x]] > You can use UnitStep (or Which) and FunctionInterpolation to make a > new interpolating function. >>Is there a way to combine two InterpolatingFunctions which share a >>common boundary, and are C0 continuous at the common boundary (the >>values are continuous but the derivatives are NOT continuous at the >>common boundary)? >> >>For example, I'm trying to combine the following: >> >>a1=NDSolve[large differential equation system, {t,0,10}] >> >>{{e2f -> InterpolatingFunction[{{0., 10.}}, <>], E2F -> >>InterpolatingFunction[{{0., 10.}}, <>], etc...}} >> >>a2=NDSolve[large differential equation system, {t,10,20}] >>{{e2f -> InterpolatingFunction[{{10., 20.}}, <>], E2F -> >>InterpolatingFunction[{{10., 20.}}, <>], etc...}} >> >>and the combine a1 and a2 so that I get the following: >>a3=Merge[a1,a2] >>{{e2f -> InterpolatingFunction[{{0., 20.}}, <>], E2F -> >>InterpolatingFunction[{{0., 20.}}, <>], etc...}} >> >>I've read that the InterpolatingFunction internals may be version >>specific, and I can't quite infer what they all mean. I'm using >>Mathematica version 5.0 >> >>-Kerry Kim >> >> > My question is, wheather it is possible to find analytical form of equation (EC) describing crossing of these two (F1 and F2) functions. Another thing is, if I have this equation (EC) is it possible to plot surfaces of F1 and F2, only up to values less or equal to this function (EC)? (So that plotted are only lower part of these functions (F1&F2)) I hope it is understandable > The variable ordering underlying method 2 is undocumented but hardly > accidental. While the literature on handling (nonpolynomial) > algebraics > is, I think, a bit scant, there is some folklore to this, and the > cognoscenti would not regard that approach as a hack. In essence > approach (3) is equivalent to approach (2), with (for purposes of this > problem) a small improvement. In making new variables by hand we can > force the ordering. This is advantageous insofar as we can eliminate > numeric algebraics as well as the other ones. I may at some point > try to > remedy the obscurity of Mathematica GroebnerBasis handling of > algebraics > by adding a remark to the appropriate advanced documentation. > I did not mean to suggest that this behaviur was accidental and I realised that it was essentially equivalent to method 3. I used the word hack in a sense that I once learned on this list form David Withoff (who used it once to refer to something in my posting), by which I think he meant something relying on undocumented features that may equally well not have been there (and may not be there in a future implementation). Obviously this feature is undocumented. That it might not have been there seems to me to be sufficiently demonstrated by the fact that none of the two other programs that compute Groebner bases that I have checked do that(or at least not when one uses the command Groebner basis). If not exactly a hack then at least this involves some abuse of nomenclature. Andrzej Kozlowski >>gremlins also got into method 3. In fact I like this solution best and >> it is the only method that seems to me mathematically fully >>satisfactory. I would dismiss method 2 as basically a hack relying on >>the internals of the Mathematica implementation of Groebner basis: as >>far as I know mathematical Groebner basis is not supposed to work >>with expression of this kind. >>Mathod 1 is of course classical (discussed for example in 1991 Henri >>Cohen's A Course in Computational Algebraic Number Theory on page >>100) but I don't like the fact that you have to (or at least it seems >>to me you have to) guess the degree of the polynomial used in >>Recognize. > I forgot to add that actually there can be no guarantee that the > solution found with method 1 is the correct one; it could actually be a > different algebraic number very close to the correct one. I believe > that only the elimination method (whether accomplished by Groebner > basis or Resultant) gives a solution that is guaranteed to be exact and > does not rely on accidental properties of a particular implementation > of Groebner basis. Andrzej > [...] The variable ordering underlying method 2 is undocumented but hardly accidental. While the literature on handling (nonpolynomial) algebraics is, I think, a bit scant, there is some folklore to this, and the cognoscenti would not regard that approach as a hack. In essence approach (3) is equivalent to approach (2), with (for purposes of this problem) a small improvement. In making new variables by hand we can force the ordering. This is advantageous insofar as we can eliminate numeric algebraics as well as the other ones. I may at some point try to remedy the obscurity of Mathematica GroebnerBasis handling of algebraics by adding a remark to the appropriate advanced documentation. There is a reason that approach 1, via approximate number recognition, might be regarded as superior in many cases. Simply put, it is easy for a Groebner basis computation of the sort used in methds (2-3) to become intractable. The general feeling is that Dixon resultants are better suited than Groebner bases for this sort of elimination. But they too can be overwhelmed by the computational complexity. What is nowadays emerging are methods that guess a solution and then attempt to validate a posteriori. In a sense this is to hybrid computation what predictor-corrector is to purely numeric methods. So a reasonable question is how one might certify the result of the approximate number recognition method. There are a couple of methods I can think of (and I'd be curious to hear about others). One is to construct a priori bounds on the closeness of nearby algebraics based on the degree and coefficient sizes of the minimal polynomials that define them. This is, to my mind, quite difficult. But if done, certification becomes quite easy once you check agreement to sufficiently many digits. Another method I use for this sort of thing is to take the result and, with the input, form a Groebner basis. So one might do GroebnerBasis[{expr,minpoly}] If the result is {1} then we found the wrong minpoly. If not, they are consistent and either there is another root to expr remarkably close to the one we sought, or else we found the correct one. The first case is easy to check. The obvious questions are: (1) Why is this Groebner basis any different/preferable to that of methods (2-3)? (2) Why might it be any more effective than methods (2-3)? The answer to both is that generally it is computationally more efficient, because it has an explicit polynomial that can represent or possibly factor the one determined by the original expression alone. When one can find a root and putative minimal polynomial by approximate or other means, then augmenting the original defining equation with that will generally allow for a faster Groebner basis computation. This is particularly true when we found the wrong value: if the algebraic system is inconsistent, Groebner basis computations tend to be faster than otherwise. I discussed some ideas along these lines at http://www.math.ufl.edu/~white/talks.html A Mathematica notebook (~1.2 Mb) of the slideshow for that talk may be found at http://download.wolfram.com/?key=J5XQCP The problem at hand was to find the boundary curve of the planar map given by trigpoly[n_, a_, b_] = Cos[n a] + Cos[n b] + Cos[n (a - b)]; x[a_, b_] = trigpoly[1, a, b]; y[a_, b_] = trigpoly[5, a, b]; To see what this looks like, one can do as below. pointlist[m_] := Table[2*Pi*{Random[], Random[]}, {2^m}] points2k = pointlist[12]; data[{point__}] := {x[point], y[point]}; datalist2k = Map[data, points2k]; ListPlot[datalist2k]; Finding the boundary curve can be cast in a few ways involving algebraic systems. Details depend on the trig-to-algebraic encoding and on whether one looks at a vanishing Jacobian or a Lagrange multiplier optimization. For n=3 several formulations of the problem are tractable using GroebnerBasis, and one played a role in a number theory Ph.D thesis a few years ago (not mine). For n=4 Robert Lewis' program Fermat was able to handle one formulation using a Dixon resultant. I don't think I ever got GroebnerBasis to handle that case but I'm not certain I exhausted all possibilities prior to exhausting my patience. At n=5 Fermat ran out of memory. I'm doubt it's tractable for Groebner bases, either in Mathematica or elsewhere. There is a paper based on this work: D.L. (2005) Computing curves bounding trigonometric planar maps: conference proceedings). A discussion of a posteriori verification follows figure 10. The Mathematica notebook, at around 1.7 Mb, is not much larger than that for the talk, because most of the size of each is in the graphics. Anyone interested in the computational details behind this sort of work can download a copy from http://download.wolfram.com/?key=D421SU Daniel Lichtblau Wolfram Research For instance: Catch@Scan[If[#>5,Throw[Done],Print@#]&,Range@10] 1 2 3 4 5 Done Scan could be replaced by Map, or another looping structure. This is more natural, however, despite the indexing: i = 1 While[i < 5, Print@i; i++]; Done 1 2 3 4 5 Done Bobby > > I want to do some mapping (/@) related operations since I don't want to use > for/while loops because of all the index mayhem. > > The problem is that I don't need the map operation to continue once some > condition is met. > > Is there a way to stop the mapping operation so it will not continue, thus > saving valuable calculation time (since there is no need to continue). > > for example (not useful though) > > Print[#]&/@Range[10] > and stop printing if #>5 > > > If it isn't possible to do it with map, what are my other options? > > > Guy > > > > > -- DrBob@bigfoot.com I want to do some mapping (/@) related operations since I don't want to use for/while loops because of all the index mayhem. The problem is that I don't need the map operation to continue once some condition is met. Is there a way to stop the mapping operation so it will not continue, thus saving valuable calculation time (since there is no need to continue). for example (not useful though) Print[#]&/@Range[10] and stop printing if #>5 If it isn't possible to do it with map, what are my other options? Guy Catch[ If[# > 5, Throw[#], Print[#]; #]] & /@ Range[10] ??? Jens Guy Israeli schrieb im > > I want to do some mapping (/@) related > operations since I don't want to use > for/while loops because of all the index mayhem. > > The problem is that I don't need the map > operation to continue once some > condition is met. > > Is there a way to stop the mapping operation so > it will not continue, thus > saving valuable calculation time (since there is > no need to continue). > > for example (not useful though) > > Print[#]&/@Range[10] > and stop printing if #>5 > > > If it isn't possible to do it with map, what are > my other options? > > > Guy > > I see no reason to put magnitude and phase on separate plots. Combining them saves space and makes it easier to relate magnitude and phase effects at the same frequency. With the approximation methods, a chart gets too busy if you combine them, but there's no reason to use those methods, either, so...? Bobby > >> David Park >> djmp@earthlink.net >> http://home.earthlink.net/~djmp/ >> >> >> > > David; > > Nice work. > > few comments (this is on 5.1): > > The x-axis (the frequency axis) usually has the values displayed all > as powers of 10. i.e. as in 10^-2, 10^-1, 10^0, 10^1, etc... > > Your output shows these as 10^-2, 0.1, 0, 10, but then uses 10^2 after > that, I think it is better to have all these shown in one format which > is 10^n. > > You might want to label the x-axis also as 'frequency (rad/sec)' as > that is the standard instead of 's'. > > The 'standard' also is to show the phase and magnitude on separate > plots and not on the same one. > > You might want to label the y-axis as 'Phase(degrees)' and > 'Magnitude(db)' instead of just 'db' and 'phase'. > > Is the BodePlot[] function supposed to be inside one of your packages? > I had to cut/paste the code from the news server posting to define it > even though I just downloaded your packages and loaded > Needs[DrawGraphics`DrawingMaster`] > Needs[Graphics`Graphics`] > > > Nasser > > > > -- DrBob@bigfoot.com > David Park > djmp@earthlink.net > http://home.earthlink.net/~djmp/ > > > David; Nice work. few comments (this is on 5.1): The x-axis (the frequency axis) usually has the values displayed all as powers of 10. i.e. as in 10^-2, 10^-1, 10^0, 10^1, etc... Your output shows these as 10^-2, 0.1, 0, 10, but then uses 10^2 after that, I think it is better to have all these shown in one format which is 10^n. You might want to label the x-axis also as 'frequency (rad/sec)' as that is the standard instead of 's'. The 'standard' also is to show the phase and magnitude on separate plots and not on the same one. You might want to label the y-axis as 'Phase(degrees)' and 'Magnitude(db)' instead of just 'db' and 'phase'. Is the BodePlot[] function supposed to be inside one of your packages? I had to cut/paste the code from the news server posting to define it even though I just downloaded your packages and loaded Needs[DrawGraphics`DrawingMaster`] Needs[Graphics`Graphics`] Nasser That's why I'd use the equivalent f@@@{{1,1},{2,2}}. It's a situation that comes up fairly often. Bobby > David, > > In any other context than Mathematica (and presumably APL), > f @@ # & /@ > > would have a totally different meaning! My brain starts to run out of > stack space when I try to process strings of operators like that. > > David Bailey > http://www.dbaileyconsultancy.co.uk > > > > -- DrBob@bigfoot.com David, In any other context than Mathematica (and presumably APL), f @@ # & /@ would have a totally different meaning! My brain starts to run out of stack space when I try to process strings of operators like that. David Bailey http://www.dbaileyconsultancy.co.uk f[x_,y_]=x+y Apply[f,{{1,1},{2,2},{2,5}},1] > >g[x_]:=x^2; >g/@{1,2,3} results in{1,4,9} > >similarly, how to map f[x_,y_]:=x+y; >to {1,1},{2,2}? > >it seems that f/@{{1,1},{2,2}} doesn't work. > >Thx. >Xun > > > > > > > > Alejandro, One way to handle this is to convert your data to log values for x, then plot with MultipleListPlot and then use a LogScale for the frame edge. There are other more fancy ways if you want to add fitted curves. I don't think you want the first data point at x = 0, because you can't fit that on a log scale. Needs[Graphics`MultipleListPlot`] Needs[Graphics`Graphics`] Needs[Graphics`Colors`] data = {{{0., 1}, ErrorBar[{0., 0.}]}, {{0.13, 0.899147}, ErrorBar[{-0.0158522, 0.0158522}]}, {{0.37, 0.585022}, ErrorBar[{-0.0403446, 0.0403446}]}, {{0.7, 0.391931}, ErrorBar[{-0.0720489, 0.0720489}]}, {{1.11, 0.319891}, ErrorBar[{-0.0331414, 0.0331414}]}, {{3.07, 0.0951042}, ErrorBar[{-0.0216138, 0.0216138}]}, {{5.97, 0.0720401}, ErrorBar[{-0.0100861, 0.0100861}]}, {{22.24, 0.0461106}, ErrorBar[{-0.0158478, 0.0158478}]}}; data2 = Drop[data, 1] /. {{x_, y_}, err_ErrorBar} :> {{Log[10, x], y}, err}; MultipleListPlot[data2, Frame -> True, FrameTicks -> {LogScale, Automatic, None, Automatic}, FrameLabel -> {x, y}, Axes -> False, PlotLabel -> Log-Linear Multiple List Plot, Background -> Linen, ImageSize -> 450]; David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ this is the only support address I find in the Wolfram webpage. If I need to redirect this question to someone else, please let me know. Here is the question: I want to plot the following data set on a Log-Linear format: { {{0., 1}, ErrorBar[{0., 0.}]}, {{0.13, 0.899147}, ErrorBar[{-0.0158522, 0.0158522}]}, {{0.37, 0.585022}, ErrorBar[{-0.0403446, 0.0403446}]}, {{0.7, 0.391931}, ErrorBar[{-0.0720489, 0.0720489}]}, {{1.11, 0.319891}, ErrorBar[{-0.0331414, 0.0331414}]}, {{3.07, 0.0951042}, ErrorBar[{-0.0216138, 0.0216138}]}, {{5.97, 0.0720401}, ErrorBar[{-0.0100861, 0.0100861}]}, {{22.24, 0.0461106}, ErrorBar[{-0.0158478, 0.0158478}]} } I know I have to use MultipleListPlot to plot this, but the problem is that Mathematica will return a Linear-Linear plot rather than a Log-Linear plot. By the way, I am using Mathematica 4.1. A.Carabe David, Strange how one person gets used to one construction and another to another construction. Would adding a pair of parentheses make it clearer to people reading the code? (f @@ # &) /@ {{1, 1}, {2, 2}} Or spelling it out in more detail? data = {{1, 1}, {2, 2}}; Map[Apply[f, #] &, data] Or Map[Function[{list}, Apply[f, list]], data] David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ David, In any other context than Mathematica (and presumably APL), f @@ # & /@ would have a totally different meaning! My brain starts to run out of stack space when I try to process strings of operators like that. David Bailey http://www.dbaileyconsultancy.co.uk Clear[f,g] f[x_]:=g[x] g[x_]:=g[x]=x^2 f/@Range@10 {1,4,9,16,25,36,49,64,81,100} Clear@g g[x_]:=x^3 f/@Range@10 {1,8,27,64,125,216,343,512,729,1000} Bobby >> Hi Group, >> >> Is there a straightforward way to Clear only definitions that take >> certain kinds of arguments? For example, I might have >> >> f[x_]:=x^2 >> f[0]=1 >> f[1]=1 >> f[2]=7 >> ... >> >> and want to clear all f[number] definitions but not the DelayedSet >> definition. (Note that the number of f[number] definitions will vary, >> as will the numbers that each one takes as an argument.) >> >> My goal is to clear 'memorized' definitions after an optimization run, >> where the memorized definitions are generated by a >> >> f[x_]:=f[x]=x^2 >> >> type of function, without clearing the function itself. >> >> Gareth Russell >> Columbia University >> > You can see all the assignments in DownValues[g], and you could remove > the parts of that list that you did not want and then execute > DownValues[g]:=..... > > However, I think it might be easier to rearrange your problem a bit. If > you 'remember' your answers in another function - g, then you can write > f as > > f[x_] := If[NumberQ[g[x]], g[x], g[x] = x^2] > > Then you can just use Clear[g] when you want to start the next problem. > > David Bailey > http://www.dbaileyconsultancy.co.uk > > > > -- DrBob@bigfoot.com > Hi Group, > > Is there a straightforward way to Clear only definitions that take > certain kinds of arguments? For example, I might have > > f[x_]:=x^2 > f[0]=1 > f[1]=1 > f[2]=7 > ... > > and want to clear all f[number] definitions but not the DelayedSet > definition. (Note that the number of f[number] definitions will vary, > as will the numbers that each one takes as an argument.) > > My goal is to clear 'memorized' definitions after an optimization run, > where the memorized definitions are generated by a > > f[x_]:=f[x]=x^2 > > type of function, without clearing the function itself. > > Gareth Russell > Columbia University > One idea is to modify the DownValues of f directly: DownValues[f] = DeleteCases[DownValues[f], RuleDelayed[a_, _] /; FreeQ[a, Pattern]] Carl Woll > Hi Group, Is there a straightforward way to Clear only definitions that take > certain kinds of arguments? For example, I might have f[x_]:=x^2 > f[0]=1 > f[1]=1 > f[2]=7 > ... and want to clear all f[number] definitions but not the DelayedSet > definition. (Note that the number of f[number] definitions will vary, > as will the numbers that each one takes as an argument.) My goal is to clear 'memorized' definitions after an optimization run, > where the memorized definitions are generated by a f[x_]:=f[x]=x^2 type of function, without clearing the function itself. Gareth Russell > Columbia University > You can see all the assignments in DownValues[g], and you could remove the parts of that list that you did not want and then execute DownValues[g]:=..... However, I think it might be easier to rearrange your problem a bit. If you 'remember' your answers in another function - g, then you can write f as f[x_] := If[NumberQ[g[x]], g[x], g[x] = x^2] Then you can just use Clear[g] when you want to start the next problem. David Bailey http://www.dbaileyconsultancy.co.uk Needs[Graphics`]; data={ {{0.,1},ErrorBar[{0.,0.}]}, {{0.13,0.899147},ErrorBar[{-0.0158522,0.0158522}]}, {{0.37,0.585022},ErrorBar[{-0.0403446,0.0403446}]}, {{0.7,0.391931},ErrorBar[{-0.0720489,0.0720489}]}, {{1.11,0.319891},ErrorBar[{-0.0331414,0.0331414}]}, {{3.07,0.0951042},ErrorBar[{-0.0216138,0.0216138}]}, {{5.97,0.0720401},ErrorBar[{-0.0100861,0.0100861}]}, {{22.24,0.0461106},ErrorBar[{-0.0158478,0.0158478}]} }; MultipleListPlot[ Rest[data]/.{{x_,y_},eb_}:>{{Log[10,x],y},eb}, Frame->True,Axes->False,ImageSize->400, FrameTicks->{LogScale,Automatic}]; Bob Hanlon this is the only support address I find in the Wolfram webpage. If I > need to redirect this question to someone else, please let me know. > Here is the question: > I want to plot the following data set on a Log-Linear format: { > {{0., 1}, ErrorBar[{0., 0.}]}, > {{0.13, 0.899147}, ErrorBar[{-0.0158522, 0.0158522}]}, > {{0.37, 0.585022}, ErrorBar[{-0.0403446, 0.0403446}]}, > {{0.7, 0.391931}, ErrorBar[{-0.0720489, 0.0720489}]}, > {{1.11, 0.319891}, ErrorBar[{-0.0331414, 0.0331414}]}, > {{3.07, 0.0951042}, ErrorBar[{-0.0216138, 0.0216138}]}, > {{5.97, 0.0720401}, ErrorBar[{-0.0100861, 0.0100861}]}, > {{22.24, 0.0461106}, ErrorBar[{-0.0158478, 0.0158478}]} > } I know I have to use MultipleListPlot to plot this, but the problem is > that Mathematica will return a Linear-Linear plot rather than a > Log-Linear plot. By the way, I am using Mathematica 4.1. A.Carabe > I have problems manipulating powers. Here are wo of my common problems. 1) Collecting terms under a power In[1]:=f[x_, y_] := (x - b*x)^a Collect[f[x, y], x] Out[2]=(x - b x)^a The only thing I can get to work is this In[9]:=PowerExpand[Collect[PowerExpand[f[x, y]^(1/a)], x]^a] Out[9]=(1 - b)^a x^a but that seems very convoluted, and I hope there is an easier way, because I need to work with large complicated expressions. 2) Splitting a sum in a power In[14]:=(xi^(1/2) + xi^(1/2 + a^2) where I would like to split the summ in the second exponent, and collect the Sqrt[x]. In[15]:=Collect[%, Sqrt[xi]] Out[15]=xi + xi^(1/2 + a^2) even if I substitue manulally Mathematica puts recombines the exponentials % /. {xi^(1/2 + a^2) -> Sqrt[xi]*xi^(a^2)} Collect[%, Sqrt[xi]] xi + xi^(1/2 + a^2) I hope there is a better way of doing these basic manipulations, any hep is appreciated Marc at least you can do a indefined integration with eqn = a(1 - 2*x^2)^2 == -z^2: repl = Solve[eqn, x] // FullSimplify; lstInteg = integ /. repl // FullSimplify; lstDt = ((Map[Dt[#, Constants -> {a}] &, repl, {2}]) //. Verbatim[Dt][q_, Constants -> _] :> Dt[q]) /. ({_ -> b_}) :> b /. Dt[z] -> 1 Integrate[#, z] & /@ FullSimplify[#, a > 0] & /@ lstInteg*lstDt if you insert the transformed boundaries you may get a solution, if you look carefull to your integration path and the potential singularities inside. Jens Valeri Astanoff schrieb im > Help needed : > I can't - and Mathematica 5.0 can't either - > integrate this : > > > In[1]:= > Integrate[x^2 / E^(a*(1 - 2*x^2)^2), {x, 0, 1}, > Assumptions -> a >= 0] > > Out[1]= > (2*Integrate`TableDump`c$70*E^Integrate`TableDump`c$70^2 > - Sqrt[Pi]*Erfi[Integrate`TableDump`c$70])/E^(5*a)/ > (4*Integrate`TableDump`c$70^3) > > > > v.a. > Not even simple e^-x^2 can be integrated exactly between finite intervals. You could try writing a function of a that will return a numerical value of the integral (just use NIntegrate). Sebastjan Mathemahomies, I have a beast of a function (though continuously differentiable) that I need to prove is strictly decreasing in a certain range (which I *know* it is just from plotting it). Every combination I can think of of Reduce and Solve and Simplify with assumptions leaves Mathematica spinning its wheels indefinitely. Do you have any ideas for cajoling Mathematica into crunching through this? Here's the function: f[x_,n_] := 9/2/c[x,n]^2*(n+1)b[x,n]^2 (x-d[x,n])(x-x*d[x,n]+d[x,n]+ d[x,n]^2+n (d[x,n]-1) (x+d[x,n])) where a[x_,n_] := 9*(n+1)^2 + Sqrt[3(n+1)^3 (x^2 (n-1) + 27(n+1))]; b[x_,n_] := (a[x,n](n-1) x^2)^(1/3); c[x_,n_] := -3^(2/3) x^2 (n^2-1) + 3^(1/3)(x^2(n^2-1) (9 + 9n + Sqrt[3(n+1) (x^2(n-1) + 27(n+1))]))^(2/3); d[x_,n_] := c[x,n] / (3 b[x,n] (n+1)); Show that f[x,n] is strictly decreasing for x in (0,(n-1)/n) for all integers n >= 2. Note that the limit of f[x,n] as x->0 is (n-1)/(2(n+1)) > 0 and f[(n-1)/n,n] == 0. So it would suffice to show that f' has no roots in (0,(n-1)/n). PS: I have a cool prize for information leading to a solution! (whether or not it actually involves Mathematica) -- Sowmya: Is this guy a mathematician? Terence: Worse, an economist. At least mathematicians are honest about their disdain for the real world. ----- Original Message ----- > > Consider: > > In[1]:= f = StringReplace[#, s__ ~~ 1 :> f[s]]&; > > In[2]:= f[11] // FullForm > > Out[2]//FullForm= 1.0011 > > (.00 is the symbol with code 0). This happens only with recursive > definitions: Mathematica prepends the result returned from the recursive > call to the existing string instead of replacing a part of it. > > Maxim Rytin > m.r@inbox.ru There is indeed a bug in recursive string pattern matching, it will be fixed in the next release. Oyvind Tafjord Wolfram Research Consider: In[1]:= f = StringReplace[#, s__ ~~ 1 :> f[s]]&; In[2]:= f[11] // FullForm Out[2]//FullForm= 1.0011 (.00 is the symbol with code 0). This happens only with recursive definitions: Mathematica prepends the result returned from the recursive call to the existing string instead of replacing a part of it. Maxim Rytin m.r@inbox.ru Nasser, As I said in the earlier posting, the BodePlot routine is in the DrawGraphics Help under Examples, LogPlots & Bode Plots. It is not a built-in routine in DrawGraphics, but the code is there in the example and can be copied and modified if desired. The BodePlot allows plot options to be passed and these can override the built-in options. Thus you could pass FrameLabel -> {frequency (rad/sec),...} if you wished. You could modify the nformat routine for the horizontal ticks, but I don't think that 10^(-1), 10^0, and 10^1 look that great. Everyone to their own choice. It is certainly much more compact to plot phase and magnitude on the same plot. Why repeat the whole frequency scale? Also it shows the relation between the phase and magnitude more clearly. Separate plots could be made by splitting the code and either using GraphicsArray or using two side by side Rectangles. Much better would be one Rectangle above another. In that case I would leave the ticks off the individual plots and use XSymbolicScale to label the frequency values on the lower plot only, and YTickLine to label the magnitude and phase values just outside the Rectangles. The light grid lines would carry the frequencies values up through both rectangles. By leaving the ticks and labels off the internal Rectangle plots you can easily make them perfectly align. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ > David Park > djmp@earthlink.net > http://home.earthlink.net/~djmp/ > > > David; Nice work. few comments (this is on 5.1): The x-axis (the frequency axis) usually has the values displayed all as powers of 10. i.e. as in 10^-2, 10^-1, 10^0, 10^1, etc... Your output shows these as 10^-2, 0.1, 0, 10, but then uses 10^2 after that, I think it is better to have all these shown in one format which is 10^n. You might want to label the x-axis also as 'frequency (rad/sec)' as that is the standard instead of 's'. The 'standard' also is to show the phase and magnitude on separate plots and not on the same one. You might want to label the y-axis as 'Phase(degrees)' and 'Magnitude(db)' instead of just 'db' and 'phase'. Is the BodePlot[] function supposed to be inside one of your packages? I had to cut/paste the code from the news server posting to define it even though I just downloaded your packages and loaded Needs[DrawGraphics`DrawingMaster`] Needs[Graphics`Graphics`] Nasser Hi Alejandro, > this is the only support address I find in the Wolfram > webpage. If I need to redirect this question to someone else, > please let me know. > Here is the question: > I want to plot the following data set on a Log-Linear format: { > {{0., 1}, ErrorBar[{0., 0.}]}, > {{0.13, 0.899147}, ErrorBar[{-0.0158522, 0.0158522}]}, > {{0.37, 0.585022}, ErrorBar[{-0.0403446, 0.0403446}]}, > {{0.7, 0.391931}, ErrorBar[{-0.0720489, 0.0720489}]}, > {{1.11, 0.319891}, ErrorBar[{-0.0331414, 0.0331414}]}, > {{3.07, 0.0951042}, ErrorBar[{-0.0216138, 0.0216138}]}, > {{5.97, 0.0720401}, ErrorBar[{-0.0100861, 0.0100861}]}, > {{22.24, 0.0461106}, ErrorBar[{-0.0158478, 0.0158478}]} } I know I have to use MultipleListPlot to plot this, but the > problem is that Mathematica will return a Linear-Linear plot > rather than a Log-Linear plot. By the way, I am using Mathematica 4.1. Have you tried scaling {Log[10, #[[1]], #[[2]], #[[3]]}& /@ yourdata? You can then use MultipleListPlot with FrameTicks->{LogScale, Automatic, None, None} Dave. I am using the ANOVA function on a data set I am currently analyzing. It has been working well, but for a particular factor in the data I received the following warning: in: ANOVA[data, CellMeans -> True, SignificanceLevel -> 0.05] out: DesignedRegress::badfit: Warning: unable to find a fit that is better than the mean response. I know that the means are quite similar for this data the across the two levels of the factor, but otherwise the factor and dependent variable are identical to all other factors I have been analyzing. The factor is in True/False form and the dependent variable contains reals. The format of data is the same as I have been using for all other ANOVAs I've run, namely data=MapThread[{#1, #2} &, {factor, dependentvariable}]. Does anyone know what this warning means? Lee Following is my input directly from the text and the output returned. I am using Mathematica Version 5.0. How can I find a list of error messages and their meanings? What does this particular error message mean? After the error message is more ... I infer that there is more information available. If so, how do I access it? I looked in the online help and there is no entry for error messages. In[23]:= << Graphics`SurfaceOfRevolution`; In[24]:= main = SurfaceOfRevolution[f[x], {x, 0, 3.1}, RevolutionAxis [Rule] {1, 0, 0}, PlotPoints[Rule] {20, 30}]; In[25]:= cap = SurfaceOfRevolution[f[x], {x, 3.1, 3.25}, RevolutionAxis [Rule] {1, 0, 0}, PlotPoints[Rule] {5, 30}]; In[29]:= Show[main, cap] Show::gcomb: An error was encountered in combining the graphics objects in Show[<<2>>] . More· Out[29]= Show[SurfaceOfRevolution[f[x], {x, 0, 3.1}, RevolutionAxis -> {1, 0, 0}, PlotPoints -> {20, 30}], SurfaceOfRevolution[f[x], {x, 3.1, 3.25}, RevolutionAxis -> {1, 0, 0}, PlotPoints -> {5, 30}]] I have checked the runs test, and it seems I have missed one step as a preparation. Now I have arranged all the observed and predicted values to the third column (third in the brackets) to the second column I inserted 1 for the observed values, 2 for the predicted values by the model (second in the brackets), and the first column contains the id for each case. For each id I would like to know whether there is a systematic bias between observed and predicted values or not. Basically, I am expecting nonsignificant runs test result, because that would prove me, that the model fitted well. I hope could make clear my question now and would appreciate any help, hint and comment on the matter. Attila Csukas Here is the new data : {{id, run, obspred}, {2, 1, 116.9}, {2, 1, 122.1}, {2, 1, 126.1}, {2, 1, 131.1}, {2, 1, 137.1}, {2, 1, 141.1}, {2, 1, 148.3}, {2, 1, 161.2}, {2, 1, 165.9}, {2, 1, 167.8}, {2, 1, 168}, {2, 1, 170.1}, {2, 2, 116.486}, {2, 2, 122.073}, {2, 2, 127.074}, {2, 2, 131.598}, {2, 2, 135.899}, {2, 2, 140.88}, {2, 2, 149.053}, {2, 2, 160.338}, {2, 2, 166.697}, {2, 2, 168.316}, {2, 2, 168.617}, {2, 2, 168.67}, {4, 1, 120.8}, {4, 1, 128.2}, {4, 1, 134.5}, {4, 1, 138.9}, {4, 1, 145.2}, {4, 1, 153.7}, {4, 1, 163.7}, {4, 1, 170.1}, {4, 1, 172.1}, {4, 1, 174.4}, {4, 1, 177.3}, {4, 1, 177.3}, {4, 2, 121.477}, {4, 2, 127.612}, {4, 2, 133.438}, {4, 2, 139.369}, {4, 2, 146.045}, {4, 2, 154.016}, {4, 2, 162.616}, {4, 2, 169.62}, {4, 2, 173.697}, {4, 2, 175.536}, {4, 2, 176.255}, {4, 2, 176.518}, {7, 1, 111.8}, {7, 1, 115.5}, {7, 1, 122.1}, {7, 1, 126.8}, {7, 1, 132.4}, {7, 1, 136.4}, {7, 1, 139.1}, {7, 1, 145.3}, {7, 1, 152.1}, {7, 1, 161}, {7, 1, 163.2}, {7, 1, 164.1}, {7, 2, 110.578}, {7, 2, 116.887}, {7, 2, 122.456}, {7, 2, 127.377}, {7, 2, 131.743}, {7, 2, 135.698}, {7, 2, 139.616}, {7, 2, 144.669}, {7, 2, 152.685}, {7, 2, 160.428}, {7, 2, 163.488}, {7, 2, 164.176}} >> >> I am facing to a new problem and if it is possible would like >> to ask some help from experts as you are. >> I have observed values (second in the brackets) for three ids >> (first in the brackets) and also have predicted values (third >> in the brackets) estimated by a model. I would like to use runs >> test to prove that the model fitted well, that is there is no >> significant difference between observed and predicted values >> for each id. >> >> Does anybody know how can it be done? Any help is appreciated! >> >> Out[10] = {{id,obs,pred}, >> {2,116.9,116.486}, {2,122.1,122.073}, {2,126.1,127.074}, >> {2,131.1,131.598}, {2,137.1,135.899}, {2,141.1,140.88 }, >> {2,148.3,149.053}, {2,161.2,160.338}, {2,165.9,166.697}, >> {2,167.8,168.316}, {2,168. ,168.617}, {2,170.1,168.67 }, >> {4,120.8,121.477}, {4,128.2,127.612}, {4,134.5,133.438}, >> {4,138.9,139.369}, {4,145.2,146.045}, {4,153.7,154.016}, >> {4,163.7,162.616}, {4,170.1,169.62 }, {4,172.1,173.697}, >> {4,174.4,175.536}, {4,177.3,176.255}, {4,177.3,176.518}, >> {7,111.8,110.578}, {7,115.5,116.887}, {7,122.1,122.456}, >> {7,126.8,127.377}, {7,132.4,131.743}, {7,136.4,135.698}, >> {7,139.1,139.616}, {7,145.3,144.669}, {7,152.1,152.685}, >> {7,161. ,160.428}, {7,163.2,163.488}, {7,164.1,164.176}} >> >> One of the mathgroup contributors had comments on Wald-Wolfowitz >> test but I have difficulties with the application for the above >> data. [...] > > Me too. Runs of *what* ? > > Hi John, actually, I can't help you with your problem but add a related one: I used to put my companies logo into the page header by adding Cell[GraphicsData[PostScript, -some postscript data-], Graphics] to the header. With Mathematica 4.1, this worked fine, with 5.0 Mathematica crashes when I try to print the notebook. My conclusion: There is something wrong with the printing in the newer versions. But I don't have a clue what this could be :-(( Bye Peter I have not been able to print from Mathematica 5.1.0 -- every time I try > to print it gives A system error has occurred, please try again or > restart your computer and try again -- restarting the computer does not > help. I could print from Mathematica 4.1 on this same computer and OS and > printer without any problems, and I can print from all the other > programs on this computer -- this printing problem only happens with > Mathematica 5.1.0. I'm using Windows XP sp-2 and printing to an HP inkjet printer. > John R. > Hi Rose, are you claiming that the order of the character you enter in a string appears different on output? I think the characters appear in thesame order you entered it. Anyway, if you want to reverse the character order of every string in the output, you could use $PrePrint: $PrePrint = (# /. x_String :> StringReverse[x]) & If you do not like reversed strings, you can clear $PrePrint by: $PrePrint = . > hi > when i assign a hebrew letters to a string, like this: > a=.... hebrew letters; > i could not see it formaly (in appearance) from right to left as the hebrew fonts need, but in reverse. > there is in the directory of mathematica a file ISO-8859-8 which is for hebrew fonts, > i try: > $CharacterEncoding =ISO-8859-8; a= .... but the letters inside the quoting still appear from left to right. or it is not possible, but it is possible under visual basic when i want to make a variable like this: a$=letters here go from right to left; > HI, i am a beginner. Will u please tell me how to plot hyperbola,parabola,ellipse and circle in their standard forms x^2/a^2 + y^2/b^2 = 1 x^2/a^2 -- y^2/b^2 ==1 etc. Also how do you plot a general curve (y versus x), say x^2 +3 x^2 y^3 +67 x^4 y^2 +34==0 *without solving explicitly for y* ( or x) Please help