Subject: Re: MLGetByteString assuming, that you are useing the same header for Windows and Linux, define MLPROTOTYPES under Linux. Jens OT schrieb im >I found a little inconsistency in Mathematica 5.1 >MathLink about the > function MLGetByteString, since looking in the > Help Browser I found both > these two different prototypes: > int MLGetByteString( MLINK link, unsigned char > **s, long *n, long spec) > int MLGetByteString( MLINK link, const unsigned > char** sp, long* n, long > spec) > prototype was right, and > the code works perfectly under Windows XP; > problems arise when I try to > compile the same C code on a different computer > running Linux and > Mathematica 5.0, since I get several warnings > when compiling. > It seems that the right prototype for > MLGetByteString under Linux is the > second one. > Now, my question is: how can I wright a code > suitable for both the platform? > It's not beautiful to see all these warnings... > andrea === Subject: Re: arrange lists side by side Here is a shorter solution: In[1]:= a = {28, 30, 17}; In[2]:= b = {1, 2, 9, 4, 5, 7, 3, 8}; In[3]:= MapIndexed[{#1, a[[Mod[#2[[1]], Length[a], 1]]]} &, b] Out[3]= {{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 28}, {8, 30}} >-----Original Message----- === >Subject: arrange lists side by side >is there a way to spread out a small list over a bigger list recurrently >like >this: >a={28, 30, 17}; >b={1, 2, 9, 4, 5, 7, 3, 8}; >to give the output: >{{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; >the number of items in b do not neccesary multiples of the number of >items >in a >mark >okay this is my approach >a={28,30,17}; >b={1,2,9,4,5,7,3,8}; >aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] >Out[]= >{{28,30,17},{28,30,17}} >frc=Mod[Length[b],Length[a]]; >gg=Flatten[Join[aa,Part[a,{1,frc}]]]; >Transpose[Join[{b},{gg}]] >Out[]= >{{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} >---------------------------------------------------------------------- === Subject: Re: GUIKit problem Make sure you do not run on a wireless connection. J.87nos > Using GUIKit 1.0.2 with Mathematica 5.1 under Linux, I am getting > apparently > randomly the following error messages with GUIRun and GUIRunModal, > even on > basic (and correct !) exemples. > ShareFrontEnd::openx: A connection to the front end could not be > established > GUIObject::nvalid: The GUI definition resolved to an invalid runtime. > Any idea of what can happen ? > Yves === Subject: Re: something like dB I don't think that dB is properly a 'Unit'. It is a function that returns a pure number. We could define the function and it's inverse as follows. dB[p_, p0_] := 10 Log[10, p/p0] inversedB[dB_, p0_] := p0 10^(dB/10) Then, installing the Units package, we have... Needs[Miscellaneous`Units`] dB[100 Watt, 1 Watt] 20 inversedB[20, 1 Watt] 100 Watt dB[125.5 Joule/Minute, Watt] Convert[%, 1] (10*Log[(125.5*Joule)/(Minute*Watt)])/Log[10] 3.20492 inversedB[3.204924754334133`, Watt] Convert[%, Joule/Minute] 2.09167 Watt (125.5*Joule)/Minute It is only sloppyness to say that something is x dB. (Maybe I'll hear differently from other responders.) In any case, if you use 0.0 dB then the 0.0 will be retained, but if you write exact 0 anything Mathematica always returns 0. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ In engineering, we always like values such as power be represented in dB form. I can make dB as a Unit, but things go to strange when 0 dB occurs: Times[0, dB] will give 0 no matter dB is ReadProtected or not. I have tried to define a upvalue for dB: dB /: Times[0, dB] = 1; but Mathematica do not allow this cause dB is not a function. I can define a new rule for Times: Times[0, dB] = 1, but this may slow down the kernel. Anybody know how ? === Subject: Re: Slow performance on OS X? I have the exact same machine you describe and I have never seen problems like this (at least 5.0 & 5.1, I don't have 4.1.5 or 4.2 handy). Try quitting & moving your ~/Library/Mathematica folder to your desktop to see if the problem still happens. Look at the CPU usage with the 'top' command or /Applications/Utilities/ActivityMonitor.app. Does Mathematica use excessive amounts of CPU time? -Rob === Subject: Re: Slow performance on OS X? > I have the exact same machine you describe and I have never seen > problems like this (at least 5.0 & 5.1, I don't have 4.1.5 or 4.2 > handy). Try quitting & moving your ~/Library/Mathematica folder to > your desktop to see if the problem still happens. > Look at the CPU usage with the 'top' command or > /Applications/Utilities/ActivityMonitor.app. Does Mathematica use > excessive amounts of CPU time? No. CPU usage remains minimal. It takes 45-60 seconds for Mathematica to start, during which time Activity Monitor frequently shows the process as hung. Opening a short, 3-line Mathematica file takes about 20 seconds. This is on a nearly new system. I don't have slow-downs with any other apps. Ken Bowman === Subject: Re: Re: Using BarChart in a Widget > Hi David, > Perhaps you could tell me what's wrong with the bar orientation in the > following: > GUIRun[Widget[Panel, { > Widget[MathPanel, {preferredSize -> > Widget[Dimension, {width -> 300, > height -> 300}]}, Name -> zplot, > WidgetLayout -> {Stretching -> {True, Maximize}}], > BindEvent[componentResized, Script[updateZernikes[]]], > Script[updateZernikes[] := Block[{$DisplayFunction = Identity}, > Needs[Graphics`Graphics`]; > expr = Show[ToExpression[ > Graphics`Graphics`BarChart][bardata = Table[Random[] - 0.5, { > 13}], BarOrientation -> Horizontal]]; > SetPropertyValue[{zplot, > mathCommand}, ToString[expr, InputForm]]] > ] > } > ] > ] > The problem is that the bars are display vertically, even though I > specify BarOrientation -> Horizontal! > Brett Patterson I notice that you are trying to work around the issue that a single evaluation of a Mathematica expression when loading new symbols with Needs, does not provide those symbols during the evaluation (hence the use of ToExpression[Graphics`Graphics`BarChart]) The problem you are running into is that there are other symbols in that expression that are in the Graphics` context and you would need to explicitly use full contexts for all of them. Fortunately, the recommended way of loading packages that are needed in GUIKit Scripts is to load them in separate Script[]s so that subsequent Scripts will know about those symbols and there is no need for explicit contexts. This is identical to how you would load packages and use them with webMathematica and jsp pages. So I would suggest the following form which eliminates the need for any full contexts and makes all the Graphics` contexted symbols known: GUIRun[ Widget[Panel, { Script[Needs[Graphics`Graphics`]], Widget[MathPanel, {preferredSize -> Widget[Dimension, {width -> 300, height -> 300}]}, Name -> zplot, WidgetLayout -> {Stretching -> {True, Maximize}}], BindEvent[componentResized, Script[updateZernikes[]]], Script[updateZernikes[] := Block[{$DisplayFunction = Identity}, expr = Show[BarChart[bardata = Table[Random[] - 0.5, {13}], BarOrientation -> Horizontal]]; SetPropertyValue[{zplot, mathCommand}, ToString[expr, InputForm]]]] }] ] Jeff Adams Wolfram Research === Subject: Re: Using BarChart in a Widget Hi Jeff, In the interim, I did find a solution to the problem I had by using the IncludedScriptContexts option. However, your suggestion is clearly preferable by not exposing the GUI to the Global Mathematica context-space. I did try to implement something along the same lines myself, by putting the Needs commands in the same Script as my function definitions. This did not work, unless I also used the ToExpression[`] syntax, which was both ugly and non-obvious. In fact, I consider it highly counter-intuitive that the Needs command only works when it is in a *separate* Script. One other thing you may be able to help me with: can you tell me where I can find documentation on all the available widgets, their properties, and events. For example, the MathPanel widget, or the Dimensions widget, or the mathCommand property of the MathPanel widget. I have only learnt about these from examples, and I really don't know what their full functionality is. Brett Patterson University of Strathclyde Glasgow, Scotland UK === Subject: Re: Using BarChart in a Widget > Hi David, > Perhaps you could tell me what's wrong with the bar orientation in the > following: > GUIRun[Widget[Panel, { > Widget[MathPanel, {preferredSize -> > Widget[Dimension, {width -> 300, > height -> 300}]}, Name -> zplot, > WidgetLayout -> {Stretching -> {True, Maximize}}], > BindEvent[componentResized, Script[updateZernikes[]]], > Script[updateZernikes[] := Block[{$DisplayFunction = Identity}, > Needs[Graphics`Graphics`]; > expr = Show[ToExpression[ > Graphics`Graphics`BarChart][bardata = Table[Random[] - 0.5, { > 13}], BarOrientation -> Horizontal]]; > SetPropertyValue[{zplot, > mathCommand}, ToString[expr, InputForm]]] > ] > } > ] > ] > The problem is that the bars are display vertically, even though I > specify BarOrientation -> Horizontal! > Brett Patterson Once again, it would seem that the symbol BarOrientation is being moved into a private context (I think this is a GUIKit bug), so the answer is much the same - replace the symbol BarOrientation with ToExpression[Graphics`Graphics`BarOrientation] or use my SWP! David Bailey dbaileyconsultancy.co.uk === Subject: Re: Converting a mapping into a well-defined function >> then the module converts the mapping A into a well-defined function: >> A(a)=5, A(b)=27, A(c)=4, A(d)=9, A(e)=94. Here's a variation that constructs the function itself. teach[tuples_List, f_Symbol] := Module[{h}, Clear@f; h[z : {a_, _}] := (h[{a, _}] = Sequence[]; f[a] = Last@z; z); h /@ tuples ] data={{a,5},{b,27},{a,14},{c,4},{e,94},{b,6},{d,9},{e,4}}; teach[data,f] {{a,5},{b,27},{c,4},{e,94},{d,9}} f/@{a,b,c,d,e} {5,27,4,9,94} ??f (suppressed) I prefer the function rather than the list version, myself, but this gives both. Bobby > -----Urspr.9fngliche Nachricht----- > Von: Gilmar [mailto:gilmar.rodriguez@nwfwmd.state.fl.us] > Gesendet: Mittwoch, 27. April 2005 03:54 > An: mathgroup@smc.vnet.net > Betreff: Converting a mapping into a well-defined function > I need to build a module that takes a non-empty set A > (whose elements are 2-tuples), and appends (or not) those 2-tuples > to a set B according to the following criteria: > (1.) if the abscissa of a 2-tuple in A is unique (among the abscissas > of all the other 2-tuples in A), then the module appends that 2-tuple > to the set B. > (2.) if there are n 2-tuples in A that share the same abscissa, then > the module appends the first of those 2-tuples to B (first here means > the first of such n 2-tuple encountered, as you read A from left to > right),but does not append the rest to B. > (3.) the module does not attempt to sort the set B, after the appending > process is completed. > Example: > If A = {{a,5},{b,27},{a,14},{c,4},{e,94},{b,6},{d,9},{e,4}} > then > B=Module[A]={{a,5},{b,27},{c,4},{d,9},{e,94}}. > Another way to re-phrase the above example; > if A defines a mapping: > A(a)=5, A(b)=27, A(a)=14, A(c)=4, A(e)=94, A(b)=6, A(d)=9, A(e)=4 > them the module converts the mapping A into a well-defined function: > A(a)=5, A(b)=27, A(c)=4, A(d)=9, A(e)=94. > Gilmar, > this certainly is a case for Carl Woll's OrderedUnion (which deservedly re-occurs at least twice a year in this group), and similar solutions. > As your solution has a property you didn't state explicitely, but which may be exploited, namely that your result is (canonically) ordered by the abszissa, I will use this opportunity to explain the Sort-Split metaphor, which is simple and effective: > In[23]:= Sort[A, OrderedQ[{#1, #2}[[{1, 2}, 1]]] &] > Out[23]= > {{a, 5}, {a, 14}, {b, 27}, {b, 6}, {c, 4}, {d, 9}, {e, 94}, {e, 4}} > Out[24]= > {{{a, 5}, {a, 14}}, {{b, 27}, {b, 6}}, {{c, 4}}, {{d, 9}}, {{e, 94}, {e, 4}}} > In[25]:= First /@ % > Out[25]= > {{a, 5}, {b, 27}, {c, 4}, {d, 9}, {e, 94}} > In[23] sorts A according to the ordering of the abszissa, and this is a stable sort, i.e. with same abszissa the elements occur in their original order. Split and First then picks out the first elements with equal abzissa, and this is what you wanted. > The same idea can be persued with Ordering (which is faster than Sort). But Ordering is not stable, however its has the property -- which I called weakly stable -- that the first element of equals in A comes first in ordering, and the last as last. Other elemnts in between may be permuted. But this is good enough for us: > In[26]:= absz = A[[All, 1]]; > orda = Ordering[absz]; > A[[takes]] > Out[29]= > {{a, 5}, {b, 27}, {c, 4}, {d, 9}, {e, 94}} > -- > Hartmut Wolf -- DrBob@bigfoot.com === Subject: Re: Polar Plots don't seem to work >>I'm on Linux using Mathematica 5.0.1.0. >>When I try to make a polar plot, no graphics is shown. This is what I see: >> In[1]:= PolarPlot[Sin[t], {t, 0, 2*[Pi]}] >> Out[1]= PolarPlot[Sin[t],{t,0,2 [Pi]}] >>Mathematica simply repeats what I told it without displaying a graphic. Even the >>polar plot in the help browser topic doesn't work. >>Any ideas why Mathematica isn't showing me polar plots? Do I need to explicitly >>display something? >>Pete > PolarPlot belongs in an add-on package, you must load it before using it > thus: > < Note: If you have already tried to use PolarPlot in the current session, > then you must quit the kernel before loading the package. even after loading the package, a Remove[Global`PolarPlot]; should be sufficient. > David Bailey > dbaileyconsultancy.co.uk -- Peter Pein Berlin === Subject: Re: arrange lists side by side Hi mark you can try t use this code Thread[List[Take[Nest[Join[a, #] &, a, Floor[Length[b]/Length[a]]], Length[ b]], b]] Then for a = {28, 30, 17}; b = {1, 2, 9, 4, 5, 7, 3, 8}; you will get {{28, 1}, {30, 2}, {17, 9}, {28, 4}, {30, 5}, {17, 7}, {28, 3}, {30, 8}} yehuda > Hi > is there a way to spread out a small list over a bigger list recurrently like > this: > a={28, 30, 17}; > b={1, 2, 9, 4, 5, 7, 3, 8}; > to give the output: > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; > the number of items in b do not neccesary multiples of the number of items > in a > mark > okay this is my approach > a={28,30,17}; > b={1,2,9,4,5,7,3,8}; > aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] > Out[]= > {{28,30,17},{28,30,17}} > frc=Mod[Length[b],Length[a]]; > gg=Flatten[Join[aa,Part[a,{1,frc}]]]; > Transpose[Join[{b},{gg}]] > Out[]= > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} > ---------------------------------------------------------------------- === Subject: Re: arrange lists side by side a = {28, 30, 17}; b = {1, 2, 9, 4, 5, 7, 3, 8}; Transpose@{b, PadRight[a, Length@b, a]} {{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 28}, {8, 30}} That requires knowing Length@b >= Lenght@a, but this does not: a={28,30,17}; b={1,2,9,4,5,7,3,8}; Transpose@{PadRight[b,Max[Length/@{a,b}],b],PadRight[a,Max[Length/@{a,b}],a] } {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} a={28,30,17,20,1,2,9,4,3,7,12}; b={1,2,9,4,5,7,3,8}; Transpose@{PadRight[b,Max[Length/@{a,b}],b],PadRight[a,Max[Length/@{a,b}],a] } {{1,28},{2,30},{9,17},{4,20},{5,1},{7,2},{3,9},{8,4},{1,3},{2,7},{9,12}} Bobby > Hi > is there a way to spread out a small list over a bigger list recurrently like > this: > a={28, 30, 17}; > b={1, 2, 9, 4, 5, 7, 3, 8}; > to give the output: > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; > the number of items in b do not neccesary multiples of the number of items > in a > mark > okay this is my approach > a={28,30,17}; > b={1,2,9,4,5,7,3,8}; > aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] > Out[]= > {{28,30,17},{28,30,17}} > frc=Mod[Length[b],Length[a]]; > gg=Flatten[Join[aa,Part[a,{1,frc}]]]; > Transpose[Join[{b},{gg}]] > Out[]= > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} > ---------------------------------------------------------------------- -- DrBob@bigfoot.com === Subject: Re: arrange lists side by side > Hi > is there a way to spread out a small list over a bigger list > recurrently like > this: > a={28, 30, 17}; > b={1, 2, 9, 4, 5, 7, 3, 8}; > to give the output: > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; > the number of items in b do not neccesary multiples of the > number of items > in a > mark > okay this is my approach > a={28,30,17}; > b={1,2,9,4,5,7,3,8}; > aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] > Out[]= > {{28,30,17},{28,30,17}} > frc=Mod[Length[b],Length[a]]; > gg=Flatten[Join[aa,Part[a,{1,frc}]]]; > Transpose[Join[{b},{gg}]] > Out[]= > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} > ---------------------------------------------------------------------- In[8]:= Thread[{b, PadRight[a, Length[b], a]}] Out[8]= {{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 28}, {8, 30}} J.87nos ---------------------------------------------- Trying to argue with a politician is like lifting up the head of a corpse. (S. Lem: His Master Voice) === Subject: Re: arrange lists side by side a={28,30,17}; b={1,2,9,4,5,7,3,8}; Thread[{b,Take[Flatten[ Table[a,{Ceiling[Length[b]/Length[a]]}]], Length[b]]}] {{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 28}, {8, 30}} Bob Hanlon === > Subject: arrange lists side by side > Hi > is there a way to spread out a small list over a bigger list recurrently like > this: > a={28, 30, 17}; > b={1, 2, 9, 4, 5, 7, 3, 8}; > to give the output: > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; > the number of items in b do not neccesary multiples of the number of items > in a > mark > okay this is my approach > a={28,30,17}; > b={1,2,9,4,5,7,3,8}; > aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] > Out[]= > {{28,30,17},{28,30,17}} > frc=Mod[Length[b],Length[a]]; > gg=Flatten[Join[aa,Part[a,{1,frc}]]]; > Transpose[Join[{b},{gg}]] > Out[]= > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} ----------------------------------------------------------------- ----- === Subject: Re: Can't Get a numric answer for this This is difficult to look at the problem with no exact example or problem description at hand. yehuda > Can anybody tell me why I can't get a number for the limit here? > When I try to take a limit of a trigonometric function, I can't get a > numeric answer even if I append the // N command. > I get a very long answer full of trigonometric functions over and > over. > One person suggested a corrupt Mathematica file and another person > suggest that Mathematica has a memory leak. > Does anybody have any ideas on this? Is there any way to post a > bitmap of the symbolic code in a message to this newsgroup? I'd like > to post the output but I have no idea how to do it. > [The group does not take attachmenets. Post them somewhere on > the net or if you need to you can send them to me and I will do > that - moderator] === Subject: Re: Can't Get a numric answer for this >> Does anybody have any ideas on this? Is there any way to post a >> bitmap of the symbolic code in a message to this newsgroup? I'd like >> to post the output but I have no idea how to do it. > Does anybody have any ideas on this? Is there any way to post a > bitmap of the symbolic code in a message to this newsgroup? I'd like > to post the output but I have no idea how to do it. That was my question? How can I post a copy of the symbolic output? [If you do not have a web server where you can put files for users of this group to download, I can do that. Just send the files to me along with an email describing the files and I will make them available - Steve Christensen, Moderator, steve@smc.vnet.net] === Subject: Re: Can't Get a numric answer for this > Can anybody tell me why I can't get a number for the limit here? > When I try to take a limit of a trigonometric function, I can't get a > numeric answer even if I append the // N command. > I get a very long answer full of trigonometric functions over and > over. > One person suggested a corrupt Mathematica file and another person > suggest that Mathematica has a memory leak. > Does anybody have any ideas on this? Is there any way to post a > bitmap of the symbolic code in a message to this newsgroup? I'd like > to post the output but I have no idea how to do it. > [The group does not take attachmenets. Post them somewhere on > the net or if you need to you can send them to me and I will do > that - moderator] have you tried < Hello All, > This is got to be a silly question but I just can't think of the right > key words that can help me find a solution on this list. I was trying > to save the definitions and contents of variables by using the Save > command, and I cannot find a way to clear what I have saved. > So now when I type > !!test > Mathematica gives the list of variables and definitions that I no > longer need. I tried ClearAll, quitting kernel, closing Mathematica and > reopening it but none worked. > Carol === Subject: Re: Clearing the definitions saved by using the Save command > Hello All, > This is got to be a silly question but I just can't think of the right > key words that can help me find a solution on this list. I was trying > to save the definitions and contents of variables by using the Save > command, and I cannot find a way to clear what I have saved. > So now when I type > !!test > Mathematica gives the list of variables and definitions that I no > longer need. I tried ClearAll, quitting kernel, closing Mathematica and > reopening it but none worked. > Carol Hi Carol, !!test shows the contents of the file where you saved your definitions. To get rid of it either delete it by mean of your OS or enter DeleteFile[Directory[]<>test] in your Mathematica session. To delete the definition assigned to a symbol either use Clear[symbolname] or Remove[symbolname] example: In[1]:= f[x_] := Sin[Pi*x]; In[2]:= ??f Global`f f[x_]:=Sin[[Pi] x] In[3]:= Save[test, f]; Remove[f]; In[5]:= ??f Information::notfound: Symbol f not found. More... In[6]:= !!test f[x_] := Sin[Pi*x] In[7]:= DeleteFile[test] In[8]:= !!test General::noopen: Cannot open test. More... -- Peter Pein Berlin === Subject: Re: Clearing the definitions saved by using the Save command > I was > trying to save the definitions and contents of variables by using > the Save command, and I cannot find a way to clear what I have > saved. > So now when I type > !!test > Mathematica gives the list of variables and definitions that I no > longer need. I tried ClearAll, quitting kernel, closing Mathematica > and reopening it but none worked. !!test only *displays* the contents of the file test that you previously created. Simply delete the file. For getting the variables back into the kernel, you have to use Get[]. Marcus -- The truth isn't quite the sort of thing one tells to a nice, sweet, refined girl. -- Oscar Wilde === Subject: Re: Clearing the definitions saved by using the Save command !! is a short cut for *show file*, delete the file and mathematica can't no longer show it. Jens schrieb im Newsbeitrag > Hello All, > This is got to be a silly question but I just > can't think of the right > key words that can help me find a solution on > this list. I was trying > to save the definitions and contents of > variables by using the Save > command, and I cannot find a way to clear what I > have saved. > So now when I type > !!test > Mathematica gives the list of variables and > definitions that I no > longer need. I tried ClearAll, quitting kernel, > closing Mathematica and > reopening it but none worked. > Carol === Subject: Re: something like dB Defining an upvalue: dB/:Times[0,dB]=1 worked for me with 5.1, and 0 dB does indeed then avaluate to 1. However, I am not sure it is a good idea to do that sort of thing because it could lead to confusion. I would always use CircleTimes to define a multiplication that wasn't! David Bailey dbaileyconsultancy.co.uk === Subject: Re: something like dB HoldForm[0*dB] ?? Jens Zhengji Li schrieb im > In engineering, we always like values such as > power be represented > in dB form. > I can make dB as a Unit, but things go to > strange when 0 dB occurs: > Times[0, dB] will give 0 no matter dB is > ReadProtected or not. > I have tried to define a upvalue for dB: > dB /: Times[0, dB] = 1; but > Mathematica do not allow > this cause dB is not a > function. > I can define a new rule for Times: Times[0, > dB] = 1, but this may > slow down the > kernel. Anybody know how ? === Subject: Re: Problem running notebook in batch mode > I have a large notebook I would like to run in batch mode. Following the > instruction found at > http://library.wolfram.com/mathgroup/archive/1998/Apr/msg00243.html > I have gotten a long way(this works for simple notebooks). However, in my > case, I am getting a bunch of errors I don't get when using the kernel > directly. Specifically, SparseArray is acting up. Is there anyone who has > successfully gotten a large notebook to run in batch mode? > -Jeroen It is very hard to see why SparseArray would act differently depending on how the calculation was launched! Can you tell where in the .M file the mistake happens? It used to be the case that AutoGeneratedPackage would create an incorrect .M file unless you did a notebook save twice in succession - I am wondering if that problem is still present! David Bailey dbaileyconsultancy.co.uk === Subject: Re: Problem running notebook in batch mode has you something in your notebook, that uses graphics ? or typesetting ?? ... Jens Student, T.U.E. schrieb im Newsbeitrag > I have a large notebook I would like to run in > batch mode. Following the > instruction found at > http://library.wolfram.com/mathgroup/archive/1998/Apr/msg00243.html > I have gotten a long way(this works for simple > notebooks). However, in my > case, I am getting a bunch of errors I don't get > when using the kernel > directly. Specifically, SparseArray is acting > up. Is there anyone who has > successfully gotten a large notebook to run in > batch mode? > -Jeroen === Subject: Re: arrange lists side by side Your problem immediately made me think of MapIndexed[ ] which uses a second parameter (#2) to refer to the position of each element that's being Mapped onto. There's an inelegant detail with subtracting 1 and adding 1, as well as needing Sequence[] to get the bracketing as desired. >is there a way to spread out a small list over a bigger list recurrently like >this: >a={28, 30, 17}; >b={1, 2, 9, 4, 5, 7, 3, 8}; >to give the output: >{{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; >the number of items in b do not neccesary multiples of the number of items >in a >mark >okay this is my approach >a={28,30,17}; >b={1,2,9,4,5,7,3,8}; >aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] >Out[]= >{{28,30,17},{28,30,17}} >frc=Mod[Length[b],Length[a]]; >gg=Flatten[Join[aa,Part[a,{1,frc}]]]; >Transpose[Join[{b},{gg}]] >Out[]= >{{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} >---------------------------------------------------------------------- === Subject: is this solvable? a'[t] + b'[t]== -p1 a[t] - p2 b[t] where {a[0]== a0, b[0]== b0} is this solvable in Mathematica? If so, how will I go about doing so? let's assume a[0]== a0, and b[0]==b0 if symbolic solution isn't possible, then intial conditions of a[0]== 1, and b[0]==0.5 couild be used...(or any other numbers for that matter) === Subject: Re: is this solvable? > a'[t] + b'[t]== -p1 a[t] - p2 b[t] > where {a[0]== a0, b[0]== b0} > is this solvable in Mathematica? If so, how will I go about doing so? > let's assume a[0]== a0, and b[0]==b0 > if symbolic solution isn't possible, then intial conditions of > a[0]== 1, and b[0]==0.5 couild be used...(or any other numbers for that > matter) Yes, I guess you'll get infinitely many solutions. Your system is obviously underestimated. I would say, the best you can expect, is to get b[t] in dependence on a[t]. -- Peter Pein Berlin === Subject: Re: Programming > if a Mathemamtica program is executed, Mathematica separates in the output > the text of the program from the error messages. > The conseqence is, that sometimes it is difficult, to find the statement, > which belongs to an error message. > Is it possible to suppress this separation? > Or is there any method, which helps to find the statement which belongs to > an error message? > Hermann Schmitt That is actually the biggest complaint I get, year after year, from students once they learn to program Modules to build nontrivial programs. Their question is typically: where is the line number? I tell them there is no number. In[] and Out[] are useless in a modularized program since they change with each invokation. The smarter ones ask: where is the debugger? I tell them there is no easy to use debugger. A front end pointer (or color marker) to where the error occurs in the source should not be too difficult - and would be greatly appreciated by beginning (and expert) users. === Subject: Re: Programming > if a Mathemamtica program is executed, Mathematica separates in the output > the text of the program from the error messages. > The conseqence is, that sometimes it is difficult, to find the statement, > which belongs to an error message. > Is it possible to suppress this separation? > Or is there any method, which helps to find the statement which belongs to > an error message? > Hermann Schmitt Some time ago, I added a simple debugger called M-Debug to MathSource. By default it breaks when an error message is generated (and not suppressed by Off) and you can see what caused thee error. David Bailey dbaileyconsultancy.co.uk === Subject: Re: Programming that is a new and strange behaviour, because Plot[a*Sin[x], {x, 0, Pi}] will copy the messages in your notbeook Plot::plnr: aSin[x] is not a machine-size real number at x = 1.308996938995747`*^-7. and what stand a the begin of the message ?? Plot::plnr does this eventual mean, that the function Plot[] had generated the message ?? When you write you own function like myFunction::bad = This is bad myFunction[x_] := If[x > 1, Message[myFunction::bad]; x, x] the message is placed in your notbeook and it is up to you, to find out that myFunction::bad is a message from myFunction. Jens Hermann Schmitt schrieb > if a Mathemamtica program is executed, > Mathematica separates in the output > the text of the program from the error messages. > The conseqence is, that sometimes it is > difficult, to find the statement, > which belongs to an error message. > Is it possible to suppress this separation? > Or is there any method, which helps to find the > statement which belongs to > an error message? > Hermann Schmitt === Subject: CellularAutomaton[rule, init] The first two definitions of CellularAutomaton[ ] are as follows: CellularAutomaton[rule, init, t] generates a list representing the evolution of the cellular automaton with the specified rule from initial condition init for t steps. CellularAutomaton[rule, init] gives the result of evolving init for one step. This works: In[]= CellularAutomaton[110,{1},1] but this produces an error message saying that three or four arguments are expected: In[]= CellularAutomaton[110,{1}] === Subject: Keeping Further Examples Open In Help Browser MathGroup: I run Mathematica 5.0.1.0 on Windows XP Pro. I am trying to force Help Browser to display Further Examples automatically. Using a copy of RefGuide.nb as my testbed, I was able to force Further Examples to display when RefGuide.nb is opened by itself. But, when I access RefGuide.nb functions using Help Browser, all Further Examples initially display closed, and automatically reclose, as usual. To keep Further Examples displayed, I replaced CellGroupData[{...}, Closed] by CellGroupData[{...}, Open], wherever it appears in RefGuide.nb. Does anyone know how to make Help Browser observe the CellGroupData[{...}, Open] commands? Harold === Subject: Re: Keeping Further Examples Open In Help Browser There's not a supported way to do this. -Rob P.S. If you wanted to live dangerously you might consider modifying (a copy of) your RefGuide.nb file such that the Further Examples cells had a style other than ExampleSection along with your CellGroupData[{...}, Open] trick. That should achieve your desired result in current versions of Mathematica (but may break at any point in the future). === Subject: Re: Not An Integer? Mathematica doesn't complain about EITHER expression, at this machine (with version 5.1.1). It shouldn't in previous versions either, but maybe it does; I don't know. 5.1.1 does complain about this one, which is almost identical to the first: Device[x_] = sigs[[Floor[x]]] + (x - Floor[x])(sigs[[Ceiling[ x]]] - sigs[[Floor[x]]]) That's because the right-hand side is computed immediately, when x has no value, so Floor[x] can't be computed. That wouldn't be a problem in itself; it's Part that complains, because the index is not an integer. This expression is OK, though: Device[x_] = Which[x .89ÅÛ 1, 0, x .89Å´ 255, 100, True, sigs[[Floor[x]]] + (x - Floor[x])(sigs[[Ceiling[ x]]] - sigs[[Floor[x]]])] That's because, as Help says: If any of the test_i evaluated by Which give neither True nor False, then a Which object containing these remaining elements is returned unevaluated. The first test is inconclusive, so Which and the rest of its arguments remain unevaluated. It might be better if Part had a similar behavior. Bobby > Mathematica grumps about Floor[x] not being an integer in this expression: > Device[x_] := sigs[[Floor[x]]] + (x - Floor[x])(sigs[[Ceiling[ > x]]] - sigs[[Floor[x]]]) > but it does NOT grump about Floor[x] not being an integer in this expression: > Device[x_] := Which[x <= 1, > 0, x .89Å´ 255, 100, True, sigs[[Floor[x]]] + (x - Floor[x])(sigs[[Ceiling[ > x]]] - sigs[[Floor[x]]])] > Why should the Which[..] construct make a difference? > -----Original Message----- === > Subject: Re: Not An Integer? > Floor[x] is NOT an integer, unless x is a NUMBER. > Bobby >> I'm trying to use some of the NumericalMath approximations such as >> MiniMaxApproximation and RationalInterpolation with a function that >> includes array references of the form Array[[Floor[x]]]. The function >> plots and evaluates just fine but the NumericalMath functions are >> reporting the error: >> Part::pspec: Part specification Floor[x] is neither an integer nor a >> list of integers. >> whereas the documentation states that Floor[x] IS an integer. >> What am I missing? -- DrBob@bigfoot.com === Subject: Re: Not An Integer? Mathematica grumps about Floor[x] not being an integer in this expression: Device[x_] := sigs[[Floor[x]]] + (x - Floor[x])(sigs[[Ceiling[ x]]] - sigs[[Floor[x]]]) but it does NOT grump about Floor[x] not being an integer in this expression: Device[x_] := Which[x <= 1, 0, x ú 255, 100, True, sigs[[Floor[x]]] + (x - Floor[x])(sigs[[Ceiling[ x]]] - sigs[[Floor[x]]])] Why should the Which[..] construct make a difference? -----Original Message----- === Subject: Re: Not An Integer? Floor[x] is NOT an integer, unless x is a NUMBER. Bobby > I'm trying to use some of the NumericalMath approximations such as > MiniMaxApproximation and RationalInterpolation with a function that > includes array references of the form Array[[Floor[x]]]. The function > plots and evaluates just fine but the NumericalMath functions are > reporting the error: > Part::pspec: Part specification Floor[x] is neither an integer nor a > list of integers. > whereas the documentation states that Floor[x] IS an integer. > What am I missing? -- DrBob@bigfoot.com === Subject: Re: arrange lists side by side > Hi > is there a way to spread out a small list over a bigger list recurrently > like > this: > a={28, 30, 17}; > b={1, 2, 9, 4, 5, 7, 3, 8}; > to give the output: > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; > the number of items in b do not neccesary multiples of the number of > items > in a > mark > okay this is my approach > a={28,30,17}; > b={1,2,9,4,5,7,3,8}; > aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] > Out[]= > {{28,30,17},{28,30,17}} > frc=Mod[Length[b],Length[a]]; > gg=Flatten[Join[aa,Part[a,{1,frc}]]]; > Transpose[Join[{b},{gg}]] > Out[]= > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} > ---------------------------------------------------------------------- Undoubtedly you will get a lot of responses. Here is one more. Transpose[ PadRight[ {{}}, {2, Length[b]}, {b,a} ] ] Carl Woll === Subject: Re: arrange lists side by side > Hi > is there a way to spread out a small list over a bigger list recurrently like > this: > a={28, 30, 17}; > b={1, 2, 9, 4, 5, 7, 3, 8}; > to give the output: > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; > the number of items in b do not neccesary multiples of the number of items > in a > mark > okay this is my approach > a={28,30,17}; > b={1,2,9,4,5,7,3,8}; > aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] > Out[]= > {{28,30,17},{28,30,17}} > frc=Mod[Length[b],Length[a]]; > gg=Flatten[Join[aa,Part[a,{1,frc}]]]; > Transpose[Join[{b},{gg}]] > Out[]= > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} > ---------------------------------------------------------------------- There are many ways to do this. Three are: MapIndexed[{#1,a[[Mod[#2[[1]],Length[a],1]]]}&,b] Transpose@Prepend[Partition[a,Length[b],1,{1,Length[a]}],b] Inner[List,b,PadRight[a,Length[b],a],List] -- Peter Pein Berlin === Subject: Re: arrange lists side by side ForcePairs[lst1_, lst2_] /; Length[lst1] < Length[lst2] := Module[{k}, k = Quotient[Length[lst2], Length[lst1]] + 1; ll = Take[Join @@ Table[lst1, {k}], Length[lst2]]; Transpose[{ll, lst2}] ] ForcePairs[lst1_, lst2_] /; Length[lst1] > Length[lst2] := Reverse /@ ForcePairs[lst2, lst1] ForcePairs[lst1, lst2] := Transpose[{lst1, lst2}] ForcePairs[b, a] {{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 28}, {8, 30}} ??? Jens schrieb im Newsbeitrag > Hi > is there a way to spread out a small list over a > bigger list recurrently like > this: > a={28, 30, 17}; > b={1, 2, 9, 4, 5, 7, 3, 8}; > to give the output: > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; > the number of items in b do not neccesary > multiples of the number of items > in a > mark > okay this is my approach > a={28,30,17}; > b={1,2,9,4,5,7,3,8}; > aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] > Out[]= > {{28,30,17},{28,30,17}} > frc=Mod[Length[b],Length[a]]; > gg=Flatten[Join[aa,Part[a,{1,frc}]]]; > Transpose[Join[{b},{gg}]] > Out[]= > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} > ---------------------------------------------------------------------- === Subject: Not getting numeric answer to simple division Does anyone know how to get a numeric answer to a simple division problem? Even if I have a very complex problem, the moment I place the division symbol '/' into the equation, my answer always comes out as a/b in some form. Paul === Subject: Re: Not getting numeric answer to simple division Hi Paul: I am a little bit unsure of what is going on, but I will start by suggesting that you use the numeric operator N. Consider the fraction 3/7. There are two forms for the numeric operator. Prefix N[] displaying 50 digits: N[3/7,50] Postfix //N: 3/7//N Good luck Dan === Subject: Re: Not getting numeric answer to simple division > Does anyone know how to get a numeric answer to a simple division problem? > Even if I have a very complex problem, the moment I place the division > symbol '/' into the equation, my answer always comes out as a/b in > some form. > Paul 1./Pi gives 1./Pi? -- Peter Pein Berlin === Subject: Re: Not getting numeric answer to simple division Use N In[58]:= N[1+1/2] Out[58]= 1.5 > Does anyone know how to get a numeric answer to a simple division problem? > Even if I have a very complex problem, the moment I place the division > symbol '/' into the equation, my answer always comes out as a/b in > some form. > Paul -- Chris Chiasson http://chrischiasson.com Kettering University Mechanical Engineering Graduate Student 1 810 265 3161 === Subject: Re: Not getting numeric answer to simple division > Does anyone know how to get a numeric answer to a simple division problem? > Even if I have a very complex problem, the moment I place the division > symbol '/' into the equation, my answer always comes out as a/b in > some form. > Paul I presume you mean that something like 2/3 comes back unchanged - as a fraction. Mathematica will never make approximations unless you ask it to, so try: 2/3 //N David Bailey dbaileyconsultancy.co.uk === Subject: Re: odd mathematica blindspot >In[1]:= Off[Solve::ifun]; >In[2]:= sol[a_, b_] := Solve[a^x == b, x] >In[3]:= sol[(9999999999/10000000000), .5] >Out[3]= {] > You really ought to lean how to cut-and-paste or otherwise copy > correctly. This is at least the second typo in a handful of posts, and > the last caused no end of confusion becasue you claimed no solution for > a problem that manifestly gave a solution. well, I disagree - the original message: http://forums.wolfram.com/mathgroup/archive/2005/Apr/msg00808.html shows Solve[(9999999999/10000000000)^x == .5, x] which has no solution. In responses, people automatically substituted .5 for 1/2, and hence got solutions. I do apologize in retrospect for the typos though - unfortunately I'm in an environment where mathematica is on one machine (windows) and my email is on another (solaris). Hence, no cut and paste, and a bunch of retyping. that is exceedingly nice to know. I'm *still* wanting a quick mathematica cheat sheet that describes all of the ins and outs of Mathematica's syntax though - the integrated help that comes with it does not focus on datastructure interaction *at all* - it just gives bits and pieces of it, and IMO not nearly enough examples... Ed === Subject: Re: odd mathematica blindspot In Solve[a^x==b,x] with a and b symbols you get an exact symbolic solution This will also be with your function definition for sol sol[a_,b_]:=Solve[a^x==b,x] if you call it with symbols sol[a,b] you will get the same solution. As for the numerical example of mixing exact representation of (9999999999/10000000000) together with 0.5 and it implication, well this was already answered on previos posts. As in any other programming environments you need to get used to Mathematica's convention and use it correctly in order to get along. yy[[0]] means the HEAD of yy which is List. so yy[[0]]{x} means List[Times[List,x]] which makes no sense you may see it by yy[[0]]{x} // FullForm In order to get the values you can always type something like {x,y}/.yy or {x,y}/.yy[[1]] for the first result you can do assignment as well with {a,b}={x,y}/.y[[1]] This is actually a double assignment. a will be assigned the value 1 and b will be assigned the value 1 yehuda > First Mathematica solves it with no problem. I wonder which version > you are using. I tested it on ver. 5.1 on Win XP. > Second, the (rather simple) problem is > Solve[a^x==b,x] will return > {{x->Log[b]/Log[a]}} > so if you assign > sol = Solve[a^x==b,x]; > you can check it for many values of a and b which in your case will lead to > sol={{x->-Log[2]/Log[(999999999999/10000000000000)]}} > to extract this value you need to use replacement rules > x/. sol[[1]] will give you the number > x/.sol will give you the number as a list of a single element. > .... because the problem is so simple, that's why its a blindspot > in mathematica IMO. > Anyways, I tried it again - > Mathematica 5.1 for Linux > -- Terminal graphics initialized -- > In[1]:= Off[Solve::ifun]; > In[2]:= sol[a_, b_] := Solve[a^x == b, x] > In[3]:= sol[(9999999999/10000000000), .5] > Out[3]= {] > In[4]:= sol[5,15]; > {{ x -> Log[15]/Log[5] }} > The really odd thing is that it doesn't come up with a *symbolic* solution, > it just says that none exists. Perhaps it is evaluating (9.../10....) as one, > and hence triggering Solve to make the problem insoluble. > Perhaps there's an issue of precision? However, FindRoot works perfectly fine > on the same expression, so its a bit strange. > btw - the notation for extraction of elements is rather.. odd. Is it basically an > array of array of arrays? I would expect: > yy = {{ x -> 1, y -> 1}, { x -> 2, y -> 2 }} > to be accessed via: > yy[[0]]{x} > and the keys of the solution to be accessed by: > keys(yy[[0]]) > or somesuch. > Is there a good tutorial somewhere on the use of datastructures in mathematica? > sort of a pocketguide on getting around? > Ed === Subject: Re: Re: odd mathematica blindspot > Bcc: === > Subject: Re: odd mathematica blindspot >>Hi Ed, >>By definition, 9999999999999/10000000000000 is an exact rational number, whereas 0.5 is an approximate real number: > Well, that's completely unintuitive.. I understand it, but it still rubs me the > wrong way for some reason. '.5' on paper means that to me - .5 - not .4999999999 > or .50000000001 or whatever internal representation the computer chooses. That's the key: what does it mean to the software or hardware? As a machine number it means a base 2 representation. No harm thus far, because .5 can be exactly represented in base 2. But it also means that further numeric manipulation might be done using machine arithmetic. I'll try to point out the source of the trouble in the example that failed. It was Solve[(9999999999999/10000000000000)^x == .5, x] An intermediate step involved computing Log[9999999999999/10000000000000, .5] The problem is that the first argument is very close to 1, and the presence of .5 coerces the entire computation to machine arithmetic, so se get a result that suffers quite a bit (quite a few bits) from cencellation error. Why? Because we had to compute Log[N[9999999999999/10000000000000]] This is only valid to about three decimal places. When we use the result in Solve, it is discarded in the verification process because the residual is deemed too large. You can see the result if you do Solve[..., VerifySolutions->False] There are ways to work around this. For example, you might use exact or higher precision inputs. I'm looking into the possibility of having Solve convert explicitly to rationals when it is working with transcendental equations. This ploy certainly will address your particular example but I cannot guarantee we will go this route, because it has the potential to break more than it fixes. > In fact, > that's why I got Mathematica in the first place, to get away from this approximate > stuff. > Why couldn't mathematica treat .5 as a string, make the internal calculation > and turn .5 into 5/10? Or, barring that, is there a conversion function for this > (going back and forth between rational and approximate real? > Ed You might want to read up on the basic evaluation semantics of Mathematica. It has a parser, as do all programming languages. It does not convert numbers to strings (quite the contrary). If you want to do that you use the function ToString[...]. If you want to numeric inputs to be made into fractions you can use Rationalize[...,0] (the second argument is a tolerance which says, in effect, to rationalize everything no matter how bad the approximation may be). Needless to say, if your intent is to sue exact arithmetic, by all means you can do so. Just don't expect the program to convert approximate numbers for you unless you ask it to. Daniel Lichtblau Wolfram Research === Subject: Re: odd mathematica blindspot === > Subject: Re: Re: odd mathematica blindspot >>Hi Ed, >>By definition, 9999999999999/10000000000000 is an exact rational number, whereas 0.5 is an approximate real number: > Well, that's completely unintuitive.. I understand it, but it still rubs me the > wrong way for some reason. '.5' on paper means that to me - .5 - not .4999999999 > or .50000000001 or whatever internal representation the computer chooses.. In fact, > that's why I got Mathematica in the first place, to get away from this approximate > stuff. So, why do you use it any more?? Take 1/2 in place of 0.5 and be happy. > Why couldn't mathematica treat .5 as a string, make the internal calculation > and turn .5 into 5/10? Or, barring that, is there a conversion function for this > (going back and forth between rational and approximate real? In[1]:= Rationalize[0.5] Out[1]= 1/2 see the Mathematica book, chapter 3.2.2. (it should be on your hard disk, accessible by the help browser) > Ed -- Peter Pein Berlin === Subject: Re: Re: odd mathematica blindspot Rationalize[0.5] 1/2 %//N 0.5 Bob Hanlon === > Subject: Re: odd mathematica blindspot === > Subject: Re: odd mathematica blindspot > Hi Ed, > > By definition, 9999999999999/10000000000000 is an exact rational number, whereas 0.5 is an approximate real number: > Well, that's completely unintuitive.. I understand it, but it still rubs me the > wrong way for some reason. '.5' on paper means that to me - .5 - not .4999999999 > or .50000000001 or whatever internal representation the computer chooses.. In fact, > that's why I got Mathematica in the first place, to get away from this approximate > stuff. > Why couldn't mathematica treat .5 as a string, make the internal calculation > and turn .5 into 5/10? Or, barring that, is there a conversion function for this > (going back and forth between rational and approximate real? > Ed === Subject: gridlines Mathematica Help states that you can color the Gridlines within a plot by utilizing the RGBColor cmd. I have tried a few different ways but cannot get the gridlines to turn red. Anyone know the appropriate syntax to make the grid line red? MJ === Subject: Re: gridlines Plot[x^2, {x, 0, 3}, GridLines -> {{Automatic, RGBColor[0, 1, 0]}, { Automatic, RGBColor[0, 0, 1]}}] > Mathematica Help states that you can color the Gridlines within a plot > by utilizing the RGBColor cmd. I have tried a few different ways but > cannot get the gridlines to turn red. > Anyone know the appropriate syntax to make the grid line red? > MJ -- Chris Chiasson http://chrischiasson.com Kettering University Mechanical Engineering Graduate Student 1 810 265 3161 === Subject: Re: gridlines not red but you will see how to do it Plot[Sin[x], {x, 0, 2Pi}, GridLines -> {Table[{Pi*i/4, {Hue[i/4], AbsoluteThickness[i]}}, {i, 0, 8}], Automatic}] Jens Mike schrieb im Newsbeitrag > Mathematica Help states that you can color the > Gridlines within a plot > by utilizing the RGBColor cmd. I have tried a > few different ways but > cannot get the gridlines to turn red. > Anyone know the appropriate syntax to make the > grid line red? > MJ === Subject: Re: can Mathematica be useful for this? > Hi there! > I need to check the answer of many probability problems. > Most of them are quite simple but calculating them by hand is tedious. > They are like this: > It's necessary to choose a person for a mission overseas. If you choose > him randomly the probability that he speaks a foreign languague is: > S=Spanish; F=French; G=German > P(S)=0.33; P(F)=0,26; P(G)=0.2; > P(S and F)=0.15; P(F and G)=0.05; P(S and G)=0.1 > P(S and F and G)=0.02 > -What is the probability that he just speaks one foreign language? > -What is the probability that he doesn't speak any? > Could be Mathematica useful for solving this kind of problems? You can use the inclusion-exclusion principle: In[1]:= SetAttributes[p, Orderless] p[] = 1.; p[F] = .26; p[G] = .2; p[S] = .33; p[F, G] = .05; p[F, S] = .15; p[G, S] = .1; p[F, G, S] = .02; In[10]:= <p,0->_}] p@@@convert[#]&/@prob {p[1,0,0]+p[1,0,1]+p[1,1,0]+p[1,1,1],p[0,1,0]+p[0,1,1]+ p[1,1,0]+p[1,1,1],p[0,0,1]+p[0,1,1]+p[1,0,1]+p[1,1,1],p[1,1,0]+p[1,1,1], p[0,1,1]+p[1,1,1],p[1,0,1]+p[1,1,1],p[1,1,1]} The equation to be solved: eqn=Thread[%=={1/3,26/100,2/10,15/100,5/100,1/10,2/100}]; Plus the condition that all p's sum to 1: Solve for p: sol=Solve[Append[eqn, Total[unknown]==1],unknown] {{p[0,0,0]->73/150,p[0,0,1]->7/100,p[0,1,0]->2/25,p[0,1,1]->3/100,p[1, 0,0]->31/300,p[1,0,1]->2/25,p[1,1,0]->13/100,p[1,1,1]->1/50}} Hence the probability that the person doesn't speak any is p[0,0,0]=73/150, and the probability that he speaks one only is p[0,0,1]+p[1,0,0]+p[0,1,0]/.sol {19/75} K. Zhang === Subject: Re: can Mathematica be useful for this? > algebra simplifications is great. ... > I have found a case where FullSimplify doesn't evaluate numerically: > FullSimplify[p[F], p[F] == 1/10] > -->p[F] > So I have to write: > FullSimplify[p[F]+0., p[F] == 1/10] > 0.1 > Is there another way for obtaining a numeric result with FullSimplify? Hi Pedrito, Mathematica in general considers expressions with a smaller LeafCount (see docs) to me simpler. Now have a look at the following: In[1]:= {TreeForm[p[f]],LeafCount[p[F]]} Out[1]= {p[f],2} In[2]:= {TreeForm[1/10],LeafCount[1/10]} Out[2]= {Rational[1,10],3} For Mathematica, 1/10 is 50% more complicated than p[F]. I'm not sure which of the following you had in mind: In[3]:= {p[F]/.p[F]->1/10,N[1/10],1./10} Out[3]= {1/10, 0.1`, 0.1`} As you can see, Reals are considered even simpler: In[4]:= FullSimplify[p[F],p[F]==.1] Out[4]= 0.1 This is because In[5]:= LeafCount[.1] Out[5]= 1 You can read about this in the help (ComplexityFunction). -- Peter Pein Berlin === Subject: Re: Working with huge text files with mathematica >> Hi Everybody, >> I face a problem when try to read in a huge data file with my >> Mathematica5.1 >> The file is approx. 4Gb large and was created by another Mathematica >> application (So, I think Mathematica should be able to handle it). >> Now, if I try to use Read on a stream from this file and it returns >> EndOfFile and nothing else! >> I checked the file with the HexEdit (an editor for huge files) and it >> is not >> corrupt and has actually the data I need. >> A similar file (from the same application) but 1Gb works perfectly. >> Any ideas? >> Does Mathematica have an internal limit for the file size (and if yes, >> can >> one somehow override this option) ? >> I would appreciate any feedback! > It would seem from what others have written that there is a 2G limit on > the size of files that can be read by Mathematica under Windows. This > must be a bug in Mathematica - Windows itself can exceed this limit. > Rather than changing operating systems or splitting the file, you might > want to try using J/Link and reading the file via Java. For best > performance, you might find it was better to read the file in > substantial chunks and buffer it inside Mathematica, however. > David Bailey > dbaileyconsultancy.co.uk Here's my attempt to do it with J/Link. Creating a test file: sz = 10^6; chunks = Ceiling[2^31 / sz]; L = Table[Random[Integer, {0, 255}], {sz}]; f = OpenWrite[/math/2gb, BinaryFormat -> True]; Do[BinaryWrite[f, L], {chunks}] Close[f]; And now reading it back (note that the read buffer has to be created on the Java side): <{{a,{RGBColor[1,0,0]}},...},{...}} For example : Plot[Sin[x], {x, 0, 2*Pi}, GridLines -> {({#1, {RGBColor[1, 0, 0], Dashing[{0.01}]}} & ) /@ Range[0, 2*Pi, Pi/4], Automatic}]; F.Jaccard -----Message d'origine----- DeÊ: Mike [mailto:jenningsmca_REMOVETHIS@hotmail.com] Envoy.8eÊ: vendredi, 29. avril 2005 09:22 ËÊ: mathgroup@smc.vnet.net ObjetÊ: gridlines Mathematica Help states that you can color the Gridlines within a plot by utilizing the RGBColor cmd. I have tried a few different ways but cannot get the gridlines to turn red. Anyone know the appropriate syntax to make the grid line red? MJ === Subject: Re: is this solvable? As you have two searched functions a[t] and b[t], you should have 2 differential equations. Let us say you have a equation2 you just forgotten to give us. Then the correct way to obtain a symbolic solution is : DSolve[{a'[t] + b'[t] == (-p1)*a[t] - p2*b[t], equation2, a[0] == a0, b[0] == b0}, {a[t], b[t]}, t] F.Jaccard -----Message d'origine----- DeÊ: ames_kin@yahoo.com [mailto:ames_kin@yahoo.com] Envoy.8eÊ: vendredi, 29. avril 2005 09:22 ËÊ: mathgroup@smc.vnet.net ObjetÊ: is this solvable? a'[t] + b'[t]== -p1 a[t] - p2 b[t] where {a[0]== a0, b[0]== b0} is this solvable in Mathematica? If so, how will I go about doing so? let's assume a[0]== a0, and b[0]==b0 if symbolic solution isn't possible, then intial conditions of a[0]== 1, and b[0]==0.5 couild be used...(or any other numbers for that matter) === Subject: Re: Re: NIntegrate and NDSolve You have a PDE with one dependant variable and three independant variables. I count three*2 (one integration and one differentiation each) = 6 boundary conditions that are needed, but I am not sure. You possibly need something like: NDSolve[{eqns&&bcs},u,{r,0rmax},{[Theta],0,[Theta]max},{z,0,zmax}] > I have now added limits to the equation and have converted as much of > the equation to constants as possible ... the exact equation is here : > http://mffm.ee.unsw.edu.au/~flatmax/temp_110.gif > I would like to solve for 'sigma[r,theta,z]' ... when the equation is > set to zero ... > i.e. http://mffm.ee.unsw.edu.au/~flatmax/temp_110.gif == 0 > I guess I will have to use boundary values in some way ... is that > correct ? > Also what method would be used ? NDSolve NIntegrate ???? Something else > ???? > Matt > > I have an equation which depends on the integral and differential > of an unknown function f[x,y,z]. > > I would like to solve this equation analytically, however am happy with a > numerical solution if that is necessary. > > The equation contains the unknown (f[x,y,z]) which I would like to solve > for and has integrals of differentials like this : > > Integral [ d f[x,y,z] / dz , dx] > Integral [ d f[x,y,z] / dx , dz] > > What are the limits of integration? > Carl Woll > -- > http://www.flatmax.org > Public Projects : > http://sourceforge.net/search/?type_of_search=soft&words=mffm -- Chris Chiasson http://chrischiasson.com Kettering University Mechanical Engineering Graduate Student 1 810 265 3161 === Subject: Re: Re: NIntegrate and NDSolve I have now added limits to the equation and have converted as much of the equation to constants as possible ... the exact equation is here : http://mffm.ee.unsw.edu.au/~flatmax/temp_110.gif I would like to solve for 'sigma[r,theta,z]' ... when the equation is set to zero ... i.e. http://mffm.ee.unsw.edu.au/~flatmax/temp_110.gif == 0 I guess I will have to use boundary values in some way ... is that correct ? Also what method would be used ? NDSolve NIntegrate ???? Something else ???? Matt > I have an equation which depends on the integral and differential > of an unknown function f[x,y,z]. > I would like to solve this equation analytically, however am happy with a > numerical solution if that is necessary. > The equation contains the unknown (f[x,y,z]) which I would like to solve > for and has integrals of differentials like this : > Integral [ d f[x,y,z] / dz , dx] > Integral [ d f[x,y,z] / dx , dz] > What are the limits of integration? > Carl Woll -- http://www.flatmax.org Public Projects : http://sourceforge.net/search/?type_of_search=soft&words=mffm === Subject: Re: I wonder where did you get the second definition from. Look carefully in the help and the examples therein. CellularAutomaton[] needs at least 3 arguments: Rule number, initial condition and number of steps. Think of it as a modified NestList[]. yehuda > The first two definitions of CellularAutomaton[ ] are as follows: > CellularAutomaton[rule, init, t] generates a list representing the evolution > of the cellular automaton with the specified rule from initial condition init > for t steps. > CellularAutomaton[rule, init] gives the result of evolving init for one step. > This works: > In[]= CellularAutomaton[110,{1},1] > but this produces an error message saying that three or four arguments are expected: > In[]= CellularAutomaton[110,{1}] === Subject: Re: Neither mine nor the latest version of the documentation seems to mention that two parameter form: http://documents.wolfram.com/mathematica/functions/CellularAutomaton http://documents.wolfram.com/v5/Built-inFunctions/ListsAndMatrices/Structure Manipulation/CellularAutomaton.html > The first two definitions of CellularAutomaton[ ] are as follows: > CellularAutomaton[rule, init, t] generates a list representing the evolution > of the cellular automaton with the specified rule from initial condition init > for t steps. > CellularAutomaton[rule, init] gives the result of evolving init for one step. > This works: > In[]= CellularAutomaton[110,{1},1] > but this produces an error message saying that three or four arguments are expected: > In[]= CellularAutomaton[110,{1}] -- Chris Chiasson http://chrischiasson.com Kettering University Mechanical Engineering Graduate Student 1 810 265 3161 === Subject: Re: Re: arrange lists side by side >-----Original Message----- === >Subject: Re: arrange lists side by side >> Hi >> is there a way to spread out a small list over a bigger list >recurrently >> like >> this: >> a={28, 30, 17}; >> b={1, 2, 9, 4, 5, 7, 3, 8}; >> to give the output: >> {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; >> the number of items in b do not neccesary multiples of >the number of >> items >> in a >> mark >> okay this is my approach >> a={28,30,17}; >> b={1,2,9,4,5,7,3,8}; >> aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] >> Out[]= >> {{28,30,17},{28,30,17}} >> frc=Mod[Length[b],Length[a]]; >> gg=Flatten[Join[aa,Part[a,{1,frc}]]]; >> Transpose[Join[{b},{gg}]] >> Out[]= >> {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} >---------------------------------------------------------------------- >Undoubtedly you will get a lot of responses. Here is one more. >Transpose[ PadRight[ {{}}, {2, Length[b]}, {b,a} ] ] >Carl Woll my first idea, quite similar, was this: In[5]:= Transpose[{b, PadRight[{}, Length[b], a]}] Out[5]= {{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 28}, {8, 30}} This however is a bit obfuscated: In[15]:= First@ListCorrelate[b, a, {1, Length[a]}, a, List, List] Out[15]= {{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 28}, {8, 30}} or this In[30]:= Transpose@Prepend[Partition[a, Length[b], Length[b], {1, 1}, a], b] Out[30]= {{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, 28}, {8, 30}} -- Hartmut === Subject: Re: is this solvable? I don't know if you have enough equations. See this example on SOS math: http://www.sosmath.com/diffeq/system/linear/eigenvalue/eigenvalue.html It seems like you know something about the addition of the two derivatives, but given a point in {a, b} space... you wouldn't have enough information to calculate the velocity of your solution's point in time t. That's just my guess. > a'[t] + b'[t]== -p1 a[t] - p2 b[t] > where {a[0]== a0, b[0]== b0} > is this solvable in Mathematica? If so, how will I go about doing so? > let's assume a[0]== a0, and b[0]==b0 > if symbolic solution isn't possible, then intial conditions of > a[0]== 1, and b[0]==0.5 couild be used...(or any other numbers for that > matter) -- Chris Chiasson http://chrischiasson.com Kettering University Mechanical Engineering Graduate Student 1 810 265 3161 === Subject: Re: is this solvable? there is no general solution, because you have two unknowns and only one equation. Jens schrieb im Newsbeitrag > a'[t] + b'[t]== -p1 a[t] - p2 b[t] > where {a[0]== a0, b[0]== b0} > is this solvable in Mathematica? If so, how will > I go about doing so? > let's assume a[0]== a0, and b[0]==b0 > if symbolic solution isn't possible, then intial > conditions of > a[0]== 1, and b[0]==0.5 couild be used...(or any > other numbers for that > matter) === Subject: Re: gridlines >-----Original Message----- === >Subject: gridlines >Mathematica Help states that you can color the Gridlines within a plot >by utilizing the RGBColor cmd. I have tried a few different ways but >cannot get the gridlines to turn red. >Anyone know the appropriate syntax to make the grid line red? Mike, possibility one: define your own gridlines, and you can give each an individual color (this case is mentioned in help) If the automatic grid positions are good for you, then this is more convenient: Plot[Sin[10 Pi t], {t, 0, 1}, GridLines -> {{Automatic, Hue[0]}, {Automatic, Hue[0]}}] -- Hartmut === Subject: Re: gridlines Plot[(x - 3/2)(x - 4), {x, 0, 5}, GridLines -> {Table[{n, {Red}}, {n, 0, 5}], Table[{n, {Red}}, {n, -2, 6}]}, PlotRange -> {-2.2, 6.2}, Frame -> True, Axes -> False]; Bob Hanlon === > Subject: gridlines > Mathematica Help states that you can color the Gridlines within a plot > by utilizing the RGBColor cmd. I have tried a few different ways but > cannot get the gridlines to turn red. > Anyone know the appropriate syntax to make the grid line red? > MJ === Subject: Re: Not getting numeric answer to simple division Exact numbers produce exact results 3/2 3/2 Use N 3/2//N 1.5 Or, use at least one inexact number 3./2 1.5 3/2. 1.5 Bob Hanlon === > Subject: Not getting numeric answer to simple division > Does anyone know how to get a numeric answer to a simple division problem? > Even if I have a very complex problem, the moment I place the division > symbol '/' into the equation, my answer always comes out as a/b in > some form. > Paul === Subject: Re: Not getting numeric answer to simple division Paul, Is this what you mean? 3/2 N[%] 3/2 1.5 If you want decimal answers, just use N on your expression. David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Does anyone know how to get a numeric answer to a simple division problem? Even if I have a very complex problem, the moment I place the division symbol '/' into the equation, my answer always comes out as a/b in some form. Paul === Subject: Re: gridlines Mike, The style has to be inclosed in {}. Needs[Graphics`Colors`] Plot[Sqrt[x], {x, 0, 5}, GridLines -> {Table[{i, {Red}}, {i, 1, 5}], Table[{i, {Red}}, {i, 0.5, 2, 0.5}]}]; But what is more important, the plotted curve or the grid lines? Under the assumption that the curve is more important the grid lines should be put in with as light a touch as possible, what Edward Tufte calls the minimum effective difference. So something like the following might be better. Plot[Sqrt[x], {x, 0, 5}, Frame -> True, GridLines -> {Table[{i, {Gainsboro}}, {i, 0, 5}], Table[{i, {Gainsboro}}, {i, 0.0, 2, 0.5}]}, PlotLabel -> Use Light Touch on Grid Lines, Background -> Linen, ImageSize -> 450]; David Park djmp@earthlink.net http://home.earthlink.net/~djmp/ Mathematica Help states that you can color the Gridlines within a plot by utilizing the RGBColor cmd. I have tried a few different ways but cannot get the gridlines to turn red. Anyone know the appropriate syntax to make the grid line red? MJ === Subject: GridLines and ImplicitPlot I can't seem to be able to use the GridLines->Automatic command with ImplicitPlot. The help browser says that ImplicitPlot accepts all the usual Plot options. Any ideas? S Jonak Maintain an even strain. === Subject: Summation problem Why can't Mathematica sum: Sum[I^n/n,{n,1,Infinity}] and gives the (incorrect) answer, that this is divergent while it can do: Sum[I^(n+1)/n,{n,1,Infinity}] correctly? Jaroslaw Piskorski === Subject: Re: compiling the python mathlink module on python 2.3+ Actually Mitch, I was to hear some suggestions coming from this group as well... I've posted this problem before, but alas, no response what so ever... the interface to python looks well developed, and i'm very eager to use it, though compiling is easy, but doesnt result in a workable module. I hardly have any experience compiling extensions, and do not have the feeling the developers of the module are catching up with this list too often... So, no, i have no idea what we could do with it... which is a real pity! i have to bring up the fact that python 2.4 is compiled with the free MS compiler, and 2.2 isnt. That might be an issue with your compiling trouble. The error message isnt too informative either: > import mathlink Fatal Python error: Error initializing mathlink extension module This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. So support team? Any ideas? === Subject: Re: Re: arrange lists side by side Sorry, this is the right way to tell the joke (see below): >-----Original Message----- === >Subject: RE: Re: arrange lists side by side >>-----Original Message----- === >>Subject: Re: arrange lists side by side > Hi > is there a way to spread out a small list over a bigger list >>recurrently > like > this: > a={28, 30, 17}; > b={1, 2, 9, 4, 5, 7, 3, 8}; > to give the output: > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}}; > the number of items in b do not neccesary multiples of >>the number of > items > in a > mark > okay this is my approach > a={28,30,17}; > b={1,2,9,4,5,7,3,8}; > aa={};aa=Table[Join[aa,a],{i,Length[b]/Length[a]}] > Out[]= > {{28,30,17},{28,30,17}} > frc=Mod[Length[b],Length[a]]; > gg=Flatten[Join[aa,Part[a,{1,frc}]]]; > Transpose[Join[{b},{gg}]] > Out[]= > {{1,28},{2,30},{9,17},{4,28},{5,30},{7,17},{3,28},{8,30}} > >>---------------------------------------------------------------------- >>Undoubtedly you will get a lot of responses. Here is one more. >>Transpose[ PadRight[ {{}}, {2, Length[b]}, {b,a} ] ] >>Carl Woll >my first idea, quite similar, was this: >In[5]:= Transpose[{b, PadRight[{}, Length[b], a]}] >Out[5]= >{{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, >28}, {8, 30}} >This however is a bit obfuscated: >In[15]:= First@ListCorrelate[b, a, {1, Length[a]}, a, List, List] >Out[15]= >{{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, >28}, {8, 30}} Perhaps this was more appropriate: ListCorrelate[b, a, {1, Length[a]}, a, List, Sequence] >or this >In[30]:= >Transpose@Prepend[Partition[a, Length[b], Length[b], {1, 1}, a], b] >Out[30]= >{{1, 28}, {2, 30}, {9, 17}, {4, 28}, {5, 30}, {7, 17}, {3, >28}, {8, 30}} >Hartmut === Subject: I spotted something :) Mac -only http://www.apple.com/downloads/macosx/spotlight/ wolframnotebookindexerpluginforspotlight.html J.87nos -------- At a risk of being called sexist, ageist and French, if you put multimedia, a leather skirt and lipstick on a grandmother and take her to a night club, she's still not going to get lucky. -- Jean Louis Gassee (of Be) on Windows 2000 being multimedia. === Subject: Re: is this solvable? a'[t] + b'[t] == -p1 a[t] - p2 b[t] is a result of operating on two odes that have 3 variables. { a'[t] == -p1 a[t] - p3 c[t] b'[t] == p3 c[t] - p2 b[t] } adding the two equations allows me to get rid of p3 c[t] terms. ( Above system comes from a piece wise defined ODE system after a certain time point.) but the problem was that I end up with the a'[t]+ b'[t] dan's suggestion of setting b[t]-> b0 allows a particular form of solutions to be found using the normal DSolve syntax. In comp.soft-sys.math.mathematica you write: >a'[t] + b'[t]== -p1 a[t] - p2 b[t] >where {a[0]== a0, b[0]== b0} >is this solvable in Mathematica? If so, how will I go about doing so? >let's assume a[0]== a0, and b[0]==b0 >if symbolic solution isn't possible, then intial conditions of >a[0]== 1, and b[0]==0.5 couild be used...(or any other numbers for that >matter) Can you give me a bit more information about your problem? I don't think I understand enough about what you are doing to try to offer ideas. === Subject: books on writing packages I'd like to learn to write my own packages for both research and teaching purposes. Is there any good books or references on package authoring? === Subject: Re: something like dB >It is only sloppyness to say that something is x dB. (Maybe I'll >hear differently from other responders.) In any case, if you use >0.0 dB then the 0.0 will be retained, but if you write exact 0 >anything Mathematica always returns 0. No, it isn't just sloppyness to use dB. For example, it is perfectly logical to talk of an attenuation or gain of say 3 dB which would mean for attenuation half of the input power is lost. Linear amplifiers increase power by a fixed ratio for a given setting and attenuators decrease power by a fixed ratio. This is made even more useful by measuring power levels in units like dBm. Here the m tells me the power level is referenced to 1 mW. So, 0 dBm would be 1 mW of power. And with an input of 0 dBm and an amplifer with a gain of 30 dB, I can easily determine the output power is 30 dBm or equivalently 1 Watt. -- To reply via email subtract one hundred and four