A53 === Is there a reason for this strange behavior of TrigExpand?All of these expressions simplify both the numerator and denominator.(Cos[t]^2 + Sin[t]^2 is replaced by 1.)expr = (1 + Cos[t]^2 + Sin[t]^2)/(2 + Cos[t]^2 + Sin[t]^2);TrigExpand[expr]2/3expr = (1 + f[t] + Cos[t]^2 + Sin[t]^2)/(2 + f[t] + Cos[t]^2 + Sin[t]^2);TrigExpand[expr](2 + f[t])/(3 + f[t])expr = (1 + Cos[t] + Cos[t]^2 + Sin[t]^2)/(2 + f[t] + Cos[t]^2 + Sin[t]^2);TrigExpand[expr](2 + Cos[t])/(3 + f[t])But the following leaves the denominator untouched.expr = (1 + Cos[t] + Cos[t]^2 + Sin[t]^2)/(2 + Cos[t] + Cos[t]^2 + Sin[t]^2);TrigExpand[expr](2 + Cos[t])/(2 + Cos[t] + Cos[t]^2 + Sin[t]^2)On the other hand, Simplify, which uses the trig identities works.expr = (1 + Cos[t] + Cos[t]^2 + Sin[t]^2)/(2 + Cos[t] + Cos[t]^2 + Sin[t]^2);Simplify[expr](2 + Cos[t])/(3 + Cos[t])David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ ==== I'm also using 4.2.0, and on my machine the Limit package gives 0 for both, like yours, but without the package loaded, it leaves both forms unevaluated (unlike your experience). Weirder and weirder.BobbyOn Sun, 26 Jan 2003 18:44:27 -0500 (EST), David W. Cantrell > I just noticed something strange, closely related to the original > question> in this thread, which I can't explain. Using version 4.2.0 for Windows: Limit[(Exp[-x]-Exp[-2x])/(Exp[-x]+Exp[-2x]), x-> Infinity] does not give an answer (although the built-in Limit function _should_> of course be able to do so) but, merely using an alternative notation, Limit[(E^(-x)-E^(-2x))/(E^(-x)+E^(-2x)), x-> Infinity] yields, incorrectly, 0 . [The correct answer is 1 .] The reason I think of these notations as alternatives is that both> Exp[x] and E^x have FullForm of Power[E, x]. So what's going on? Why does the first not give an answer, while the> second gives a wrong answer? BTW, using the Standard Add-on Package Calculus`Limit`, _both_ give the> incorrect answer 0 . PLEASE do not respond with workarounds. I know several already, the> easiest of which is to just do the problem in my head! David Cantrell-- majort@cox-internet.comBobby R. Treat ==== Selwyn,things aren't, what they appear to be:In[2]:= Through[{InputForm, Floor}[#]] & /@ {3.0000000000000000, 3.00000000000000000}Out[2]= {{3., 3}, {2.999999999999999999999999999991459`17.6021, 2}}You're right, of course, perhaps, except for wow.--Hartmut>-----Original Message----->Sent: Saturday, January 25, 2003 7:27 AM>To: mathgroup@smc.vnet.net>Wow. But apparently it has nothing to do with Log. Look:Floor[3.0000000000000000] 3Floor[3.00000000000000000] 2--->Selwyn Hollis> With Mathematica 4.1 on Windows98:> N[Log[8]/Log[2]]> 3.> Floor[N[Log[8]/Log[2]]]> 2> Beware!>>Reply-To: kuska@informatik.uni-leipzig.de ==== Esc pd Esc Ctrl_ xEsc is the Escape key, Ctrl the Ctrl-Key and Ctrl_ meanthe bot keys must be pressed at the same time. Jens How do you enter the partial derivative shown at: www.previze.com/ partialderivative.gif> Reply-To: kuska@informatik.uni-leipzig.de ==== that is called webMathematica -- have a look at the WRI web-site. Jens What's the best/simplest way to encode or format a Mathematica notebook> to make it available on a web site? (as a downloadable source file> only, sufficiently brief that file compression is not needed, nothing> live or intended for online execution, no need for Output cells or> graphics outputs in the online file, but intended to be dowbnloaded and> executed by users on multiple platforms, with header and text cells kept> distinct from Input cells) --> Power tends to corrupt. Absolute power corrupts absolutely.> Lord Acton (1834-1902)> Dependence on advertising tends to corrupt. Total dependence on> advertising corrupts totally. (today's equivalent)Reply-To: kuska@informatik.uni-leipzig.de ==== Solve[Exp[-(x - m1)/(2s1)]/Sqrt[s1] == Exp[-(x - m2)/(2s2)]/Sqrt[s2], x]?? Jens Can anyone please tell me how to find the intersection of two gaussians?> Is there any standard method to do that?> Vaidyanathan. --> Vaidyanathan Ramadurai> Graduate Student> http://www4.ncsu.edu/~vramadu ==== Selwyn, Diana,You might also (or instead of showing the MagnificationPopUp) like to set WindowSize width -> Fit height -> FitSo that the window size adjusts to fit the contents; otherwise if themagnification is made greater than 1 we need to add ResizeArea to theWindowFrameElements so as to be able to do this manually.Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> Diana, A major improvement to the palette is to set these options: WindowElements->MagnificationPopUp> WindowFrameElements->{CloseBox, ZoomBox} You can do this with a text editor or with the Options Inspector. If> you do it with a text editor, delete the cache ID line (as instructed> in the comments at the top). To use the Options Inspector, it's easiest if you close all notebooks> and other palettes first. Open the Options Inspector, and then click on> the title bar of the palette. The title bar of the Options Inspector> should then read Options for BasicInput.nb. Now select Show Option> Values for notebook. Then under Notebook Options > File Options, set Editable -> True. Next,> under Notebook Options > Window Properties, choose the desired values> for WindowElements and WindowFrameElements. Finally, go back and to Notebook Options > File Options, and set> Editable -> False. Et voila! ----> Selwyn Hollis> Folks,> I have used Mathematica for about two months, and it appears that the> BasicInput.nb palette had shrunk, in that the walls of the window have> come> in. I can't, therefore, access all of the icons that I want.> Is there a way to fix this, other than re-installing the application?> Diana> --> ==== =================================================> God made the integers, all else is the work of man.> L. Kronecker, Jahresber. DMV 2, S. 19.>Reply-To: kuska@informatik.uni-leipzig.de ==== what manyTable[f[i,4],{i,1,4}]produce ? Jens I have a function f[a_,b_] defined some way. i want to fix one argument,> and then generate an array of values where the other argument varies. How> can I do this? For example, I want: {f[1, 4], f[2, 4], f[3, 4], f[4, 4]} Is there an easy way to do this?> ==== >-----Original Message----->Sent: Sunday, January 26, 2003 11:23 AM>To: mathgroup@smc.vnet.net> I have a function f[a_,b_] defined some way. i want to fix one>argument,> and then generate an array of values where the other >argument varies.>How> can I do this?> For example, I want:> {f[1, 4], f[2, 4], f[3, 4], f[4, 4]}> Is there an easy way to do this?> Zachary,> Table[f[x,4],{x,1,4}]> {f[1, 4], f[2, 4], f[3, 4], f[4, 4]}> Or, for irregular values or a known list of values:> f[x,#]&/@{ 1, 2.3, 8,-3+I, Pi,a}> {f[x, 1], f[x, 2.3], f[x, 8], f[x, -3 + I], f[x, Pi],> f[x, a]}Good lord. I didn't expect this many responses :) Anyway, >the Table method>seems the simplest. Now I extend on this a little bit. Is >there any way I>can apply FullSimplify to the result before it gets inserted >into the array?>Zachary,to molest you further...In[5]:= Thread[f[{1, 2, 3.5, 4}, 4]]Out[5]= {f[1, 4], f[2, 4], f[3.5, 4], f[4, 4]}In[7]:= ArcTan[{1, 2, 3.5, 4}, 4]Out[7]= {ArcTan[4], ArcTan[2], 0.8519663271732721`, Pi/4}...as this didn't show up among the responses. The second, utmost simple,form applies to function having the Listable attribute.As to your last question, it's not quite clear to me, what do you meanbefore it gets inserted into the array. If you do that, you risk to missall simplifications with the arguments inserted. Compare:In[17]:= FullSimplify[Thread[Log[#1]/Log[#2] &[{1, 2, 3.5, 4}, 4]]]Out[17]= {0, 1/2, 0.9036774610288021`, 1}This simplifies the result: as a list is simple enough, all elements aresimplified.In[16]:= Thread[Evaluate[FullSimplify[Log[#1]/Log[#2]]] &[{1, 2, 3.5, 4},4]]Out[16]= {0, Log[2]/Log[4], 0.9036774610288021`, 1}This simplifies the function expression before it is applied, such not allsimplifications of interest can be done (in this case). However it might bethat this last step ist not needed nor desired, then this might be moreperformant, esp. if the list is quite long.--HartmutIn[11]:= Thread[FullSimplify[Log[#1]/Log[#2] &[{1, 2, 3.5, 4}, 4]]]Out[11]= {0, 1/2, 0.9036774610288021`, 1}Reply-To: kuska@informatik.uni-leipzig.de ==== With[{x=10}, First /@ FactorInteger[10]]may help you. Jens All, I know that I can generate the divisors of any integer with the Divisors> command. I would like to start with x = 10, for example, and generate the> divisors of x, and then determine the sum of the divisors. I would then> like to increment x, up to 100, for example. > Diana --> ==== =================================================> God made the integers, all else is the work of man.> L. Kronecker, Jahresber. DMV 2, S. 19.Reply-To: kuska@informatik.uni-leipzig.de ==== AFIK there is no posibility to connect to a kernel thatis already listen to a parent link. The kernel can connectto a second frontend like program but a second frontend can notconnect to a kernel that is already running and know nothingabout the new link. The only way to tell the kernelthat i has to listen to a parent link is the command linebut if the kernel is already running ou can't send a newcommand line to it. Jens > How does one determine whether an instance of the Mathematica Kernal is> running via Mathlink , or even Visual Basic. I only want to keep one> connect to this instance not start up a new instance. All I can think of is> keep the MLINK variable as a global and check that it does not equal zero. that will connect to this. > --> Daniel HeneghanReply-To: kuska@informatik.uni-leipzig.de ==== Mathematica can't do Gouraud shading because it assign the colorsper polygon and not per vertex. You can try to make a huge number of PlotPoints to obtain so manypolygons that the difference is invisible or you can use MathGL3dhttp://phong.informatik.uni-leipzig.de/~kuska/ mathgl3dv3/id3.htm Jens i'm looking for a function to plot a cone with a interpolated gouraud> shading in Mathematica.> I tried with another system, but the> result is awful, because the circle of the cone is squared. thanks.Reply-To: kuska@informatik.uni-leipzig.de ==== without the t I want to plot 3D Data (Curves) and export it to vrml. IÇve found this nice> MathGL3D Tool, but canÇt manage to change the scales of the axes, as one can> do with BoxRatios for ordinary Mathematica Graphics3D. for example: Show[Graphics3D[{Line[{{0, 0, 0}, {1, 1, 0.1}}]}, BoxRatios -> {1, 1, 1}]] shows a scaled Plot, but MVShow3D[Graphics3D[{Line[{{0, 0, 0}, {1, 1, 0.1}}]}, BoxRatios -> {1, 1,> 1}]] doesnÇt.> Is there an easy way to create scaled Plots in MathGL3D?You will not happy with it, butMVShow3D[Graphics3D[{Line[{{0, 0, 0}, {1, 1, 0.1}}]}, BoxRatios -> {.1, .1, 1}]]should do it. How about exporting axes and text to vrml? It is not possible with MathGL3d. > Are there easier ways than> tool?Why not use LiveGraphics3D http://wwwvis.informatik.uni-stuttgart.de/~kraus/ LiveGraphics3D/index.htmlby Martin Kraus orJavaView http://www-sfb288.math.tu-berlin.de/vgp/javaview/on the www-page. It has the advantage that the visitor don't needa VRML browser. ==== In version 4.2.1.1 for Mac OS X both return the same result: the original expression rewritten in two dimensional form> I just noticed something strange, closely related to the original > question> in this thread, which I can't explain. Using version 4.2.0 for Windows: Limit[(Exp[-x]-Exp[-2x])/(Exp[-x]+Exp[-2x]), x-> Infinity] does not give an answer (although the built-in Limit function _should_> of course be able to do so) but, merely using an alternative notation, Limit[(E^(-x)-E^(-2x))/(E^(-x)+E^(-2x)), x-> Infinity] yields, incorrectly, 0 . [The correct answer is 1 .] The reason I think of these notations as alternatives is that both> Exp[x] and E^x have FullForm of Power[E, x]. So what's going on? Why does the first not give an answer, while the> second gives a wrong answer? BTW, using the Standard Add-on Package Calculus`Limit`, _both_ give the> incorrect answer 0 . PLEASE do not respond with workarounds. I know several already, the> easiest of which is to just do the problem in my head! ==== Mathematica is NOT giving wrong answers in this case.> It is assuming (non-zero) real parameters and giving the right> answer in that case. Whether Mathematica is or is not giving a wrong answer in the case> result = Integrate[ Abs[Sin[k x]]^2, {x,0,1}]; N[ result /. k->I+1 ]> depends upon whether it is or is not appropriate for Mathematica to> make a default assumption that k is a nonzero real. IMO, that could be> debated.It would be extremely silly to defend this as a default assumption,since in all other cases Mathematica goes through a lot of troubleto single out cases like Im[k] == 0 in its answers. > But surely, as I noted previously in this thread, Mathematica -- at> least version 4.2 for Windows -- does give a wrong answer for> result = Integrate[ Abs[Sin[k x]]^2, {x,0,1}, Assumptions- Element[k, Complexes]; N[ result /. k->I+1 ]. I do not see how the> incorrectness of this can be debated (other than to say that> Mathematica should be allowed to ignore an _explicitly stated_> assumption!)Coming to think of it, Mathematica could of course also ignore _any_explicitly stated fact in its input and give the default result 42to all questions! But version 4.2 is probably still lacking one orderof magnitude in wisdom to do this. :-)-- Jos < Jos.Bergervoet@philips .n_o_spa_m. com > ==== I realize that we're dealing with the vagaries of internal arithmetic, but it is highly disquieting that 3.000... (with any number of zeros) would ever be anything but the binary ßoating-point number .11 * 2^2 !Selwyn> Selwyn, things aren't, what they appear to be: In[2]:= Through[{InputForm, Floor}[#]] & /@> {3.0000000000000000, 3.00000000000000000}> Out[2]= {{3., 3},> {2.999999999999999999999999999991459`17.6021, 2}} You're right, of course, perhaps, except for wow. --> -----Original Message-----> Sent: Saturday, January 25, 2003 7:27 AM> To: mathgroup@smc.vnet.net> Wow. But apparently it has nothing to do with Log. Look:> Floor[3.0000000000000000]> 3> Floor[3.00000000000000000]> 2> ---> Selwyn Hollis> With Mathematica 4.1 on Windows98:> N[Log[8]/Log[2]]> 3.> Floor[N[Log[8]/Log[2]]]> 2> Beware!> ==== Diana: Look up DivisorSigma. Table[DivisorSigma[1,x],{x,10,100}] willgive you what you want directly, I believe. Best, HarveyHarvey P. DaleUniversity Professor of Philanthropy and the LawDirector, National Center on Philanthropy and the LawNew York University School of LawRoom 206A110 West 3rd StreetNew York, N.Y. 10012-1074-----Original Message-------God made the integers, all else is the work of man.L. Kronecker, Jahresber. DMV 2, S. 19. ==== Im using Mathematica 4.2 on my MacOSX notebook but still have 4.0 on mydesktop. I have encountered a strange thing which is causing meproblems. I have defined the wavefunction in momentum space for a shoin 4.0 when i evaluate for the ground state I get the answer I wouldexpect. In 4.2 the answer is the same but I get an Integer 1 appearing whichmakes it very difficult to manipulate the result to the form I want.I have attached the Notebook content below. This is the 4.0 version butwith the 4.2 result copied across.Any comments/help?DonNotebook[{Cell[BoxData[ ([CurlyPhi]_[Gamma]_[ p_] := (([ImaginaryI]^(-[Gamma])) (((@[Pi]2^[Gamma] ([Gamma]!))/a)))^(-(1/2)) ([ExponentialE]^(((-p^2) a^2)/2)) HermiteH[[Gamma], a p])], Input],Cell[BoxData[ (In 4.0)], Input],Cell[CellGroupData[{Cell[BoxData[ ([CurlyPhi]_0[p])], Input],Cell[BoxData[ (TraditionalForm`[ExponentialE]^((-(1/2)) a^2 p^2)/(@(1/a) @[Pi]%4))], Output]}, Open ]],Cell[BoxData[ ([ExponentialE]^((-(1/2)) a^2 p^2)/(@(1/a) @[Pi]%4))], Text],Cell[BoxData[ (In 4.2)], Input],Cell[CellGroupData[{Cell[BoxData[ (TraditionalForm`[CurlyPhi]_0[p])], Input],Cell[BoxData[ (TraditionalForm`[ExponentialE]^((-(1/2)) a^2p^2)/@1[@[Pi]/a])], Output]}, Open ]]},ScreenRectangle->{{0, 1056}, {0, 772}},WindowSize->{520, 650},WindowMargins->{{28, Automatic}, {-30, Automatic}},MacintoshSystemPageSetup-><00<0001804P000000 ]P2:?oQon82n@960dL5:0?l0080001804P000000]P2:0010000I00000400` <300000Gd000400@ 0000000000000004P801T1T000000000000000000000000000000000000000 0000>] ==== If I enter Sum[p^i, {i, 0, Infinity}] Mathematica says, it is 1/(1-p), but doesn't say something about the domain for p: 1/(1-p) is only valid for-1=1 and p<=-1?PS: you can find a nice animation for the geometric series at http://www.matheprisma.de/Module/Craps/summe.htm-- Frank Bu¤, fb@frank-buss.dehttp://www.frank-buss.de, http://www.it4-systems.de ==== hi,maybe it's a foolish question, but i'm new to mathematica:i want to plot (using Plot3D of course) at least 2 3D-functions into thesame diagram. how to i have to handle this?thanx in regard.lhuv ==== I'm relatively new using mathematica 4.2 .I have a set of integro-differential equations to solve.Does anyone have an idea how to proceed? ==== I'm student and using mathematica 4.0.At the moment I have to write a report for my university. I want to useLaTeX to write this document. Since I do a lot of calculations withmathematica I use the TexForm[...] (//HoldForm) command to get a latexoutput. I just have to copy/paste the output; it works quite well.But then I wanted to include some plots from mathematica in my latexdocument. If I apply it to Plot[...]: e.g.: TeXForm[Plot[Sin[x], {x, -Pi,Pi}]] I get a strange outputs.Is it possible to get a LaTeX package, which compiles these instructions? Oris this output just nonsense? Are there other possibilities than using copyas bitmap to get my plot into the latex document?Perhaps anyone had similar problems or knows a useful link.Jochen ==== Have a look at the Utilities`Notation` pckage which does what you want todo. You can find it in the Help Browser under Addons -> Extras -> Utilities.--Steve LuttrellWest Malvern, UK I would like to define a new operator called # on mathematica with> some properties and make theoritical calculations with it. For example> I'd like to calculate (a # b)^n then. Is there any means to do that ? ==== Unfortunately, # (Slot in Mathematica, q.v.) is already taken. You mustchoose another symbol which doesn't belong to the list of reserved names,and then you can do what you say. TypeInformation[#] to see the meaning of #.Tomas GarzaMexico City----- Original Message ----- ==== *not* with # (or Slot[1])But the Notation package may help youto define a other symbol as operator. Jens > I would like to define a new operator called # on mathematica with> some properties and make theoritical calculations with it. For example> I'd like to calculate (a # b)^n then. Is there any means to do that ? ==== Nathan,You can define your own operators but not using #. # is a reserved symbol inMathematica and stands for a slot in a pure function.However, you have many other choices. For a fanciful example...CirclePlus[a_, b_] := Plus @@ Flatten[Divisors /@ {a, b}](10[CirclePlus]12)^397336CirclePlus can also be entered as esc c + esc.Or you can make up your own name.zawak[a_, b_] := Plus @@ Flatten[Divisors /@ {a, b}](10~zawak~12)^397336where ~ ~ turns zawak into an infix operator.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== Friedrich Laher schrieb:> Zachary Turner schrieb:Apparently Mathematica randomly returns roots a root of a complex number.>Is there a way I can write my own function that will return a set consisting>of all n roots of a given complex number. For example, Root[z,n] = {a set>consisting of n elements} > LstOfRoots[z_, n_] :=> Module[{a = Abs[z]^(1/n), f}, f[i_] := a Root[#^n - 1, i]; Map[f, > Range[n]]]I am ashamed to admit that the above one is only valid for real zHere is a more general solution - assuming an natural n.The exponential form is best for calculating roots.LstOfRoots[z_, n_] := Block[{az = Arg[z], r = Abs[z]^(1/n), j, ang = [ImaginaryI](az + 2[Pi] j)/n}, Table[r [ExponentialE]^ang, {j, 0, n - 1}]}]I1st tried the names arg and abs ang ( angle ) and r ( radius )but that is rejected by mathematica. ==== Being at a stage were all editing is finished, Springer's schedule is to publish the Programmingvolume and the Graphics volume within the next few months andwithin three months after their publication the Numericsvolume and the Symbolics volume.My editor, Wayne Yuhasz might beable to give you a more concrete publication date.Michael Trott ==== How would you let mathematica be more verbose aka Show work for simple series and sigma notation.Mr. Lingwood ==== If I could have mathematica on a palmtop I would be a truly fulfilled human being. [setting: a cocktail party] Girl: ...so in the limit you'd find that... Me: well let's plot that [whips out palmtop with mathematica] Girl: [swoons]It's clearly possible in principle since modern palmtops are morepowerful than desktop machines that ran mathematica just fine severalyears ago.But has anyone made this work in practice?Daniel-- Daniel Reeves -- http://ai.eecs.umich.edu/people/dreeves/ Sowmya: Is this guy a mathematician?Terence: Worse, an economist. At least mathematicians are honest about their disdain for the real world. ==== One possibility:In[1]:=g1 = Plot[x^2, {x, 0, 5}];In[2]:=< thank you!Reply-To: kuska@informatik.uni-leipzig.de ==== Needs[Graphics`FilledPlot `]Block[{$DisplayFunction = Identity}, g1 = FilledPlot[x^2, {x, 2, 4}]; g2 = Plot[x^2, {x, 0, 5}]; ]Show[g2, g1] Jens i'm relatively new using mathematica 4.2. the other day, i came across what> seemed to be a simple problem, but i couldn't figure out how to do it. say i was plotting y=x^2, and i wanted to shade the region under the graph> only between x=2 to x=4 over a range of {x, 0, 5}, is there a way to do> this? i tried FilledPlot, but it filled the entire area under the graph. thank you! ==== Occasionally Mathematica 4.2 under MacOS 9.2.2 gives me the following warning:Unable to open fileFiles:SystemFiles:FrontEnd:TextResources:Macintosh: UnicodeLanguageFontMapping.tr[snip]However, Find shows that the file is there, in the Mathematica 4.2 Files folder. There are actually 5 files by the same name, all underTextResources.The warning is harmless but annoying. Never had it under 4.1, although exactly the same files are there. (Kept 4.1 because the 4.2 front end is ßakier, crashing often and leaving a running kernel)Question: how can I turn off this warning? Is it related to the factthat both 4.1 and 4.2 are installed? ==== Todd,I have a further question on a different type of table.I have written a program to generate a multiplication table forZ_5[i], or the multiplication table of the additive integer group offive letters for complex numbers.The program is as follows:Z5[x_,y_,z_,w_] = (x + yi)(z + wi)Mod[Array[Z5,{5,5,5,5},{0,0,0,0}]//TableForm(The i in the command above is actually the symbol for the imaginarynumber i.)When I go to try to export the file to a csv file with the followingcommand,Export[C:Z5-i-notAField.csv,Mod[Array[ Z5,{5,5,5,5},{0,0,0,0}],I get a bunch of formating characters in the CSV file, and can't useit.Can you tell me how I should change the program or restate the exportcommand?Diana> Diana, Did you do this? << DiscreteMath`Combinatorica`> A5 = AlternatingGroup[5]> mult[x_?PermutationQ, y_?PermutationQ] := Permute[x, y]> MultiplicationTable[A5, mult] // TableForm> Export[C:tableDELETETHISLATER.csv, MultiplicationTable[A5, mult], CSV] It works fine for me. I hope you didn't type all that other stuff with the> quotes in by hand, as it appears from your posting. Do you know that dummy = MultiplicationTable[A5, mult] // TableForm> Export[C:tableDELETETHISLATER.csv, dummy], CSV] won't work, but (dummy = MultiplicationTable[A5, mult] )// TableForm> Export[C:tableDELETETHISLATER.csv, dummy], CSV] will? Todd Rose Steve,> Well, it took me a few days to catch on to how to extrapolate list data> from> the table output. I was finally able to take your program, and apply it to> the Cayley Table for A_5.> To keep the size to a minimum for the newsgroup post, I have pasted my> notebook file to export the Cayley Table for A_4.> The notebook command looks like:> Export[C:cayley4table.csv, {{1, 2, 3, 4, 5, 6,> 7, 8, 9, 10, 11, 12}, {2, 3, 1, 7, 9, 8, 10,> 12, 11, 4, 5, 6}, {3, 1, 2, 10, 11, 12> , 4, 6, 5, 7, 9, 8}, {4, 6, 5, 1, 3, 2, 11,> 10> , 12, 8, 7, 9}, {5, 4, 6, 8, 7, 9, > 1, 2, 3, 11, 12, 10}, {6, 5, 4, 11, 12, 10, > 8, 9, 7, 1, 3, 2}, {7, 8, 9, 2, 1, 3, > 5, 4, 6, 12, 10, 11}, {8, 9, 7, 5, 6, 4, 12,> 11> , 10, 2, 1, 3}, {9, 7, 8, 12, 10, 11> , 2, 3, 1, 5, 6, 4}, {10, 12, 11, 3, 2, 1,> 9,> 7, 8, 6, 4, 5}, {11, 10, 12, 6, 4, 5> , 3, 1, 2, 9, 8, 7}, {12, 11, 10, 9, 8, 7, > 6, 5, 4, 3, 2, 1}}, CSV]> Diana> Here is a little example of how to export in a format that Excel can> read:> Export[C:table.csv, {{1, 2}, {3, 4}}, CSV]> Steve Luttrell> Math friends,> If I program Mathematica to calculate a Cayley Table for A_5, for> example,> and it displays on the screen in the notebook, I have not been able to> figure out how to paste the values into Excel without all the extra> formatting, such as quote marks. Has someone worked this out?> For example, the Cayley Table for A_5 copies as follows into Excel...> !(*> TagBox[GridBox[{> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,> 12,> 13,> 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,> 24,> 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,> 35,> 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,> 46,> 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,> 57,> 58, 59, 60},> {2, 3, 1, 7, 9, 8, 10, 12, 11, 4, 5,> 6,> 14,> 15, 13, 19, 21, 20, 22, 24, 23, 16, 17,> 18,> 37, 39, 38, 40, 42, 41, 46, 47, 48, 43,> 44,> 45, 49, 51, 50, 52, 54, 53, 58, 59, 60,> 55,> 56, 57, 25, 26, 27, 28, 29, 30, 31, 32,> 33,> 34, 35, 36},> {3, 1, 2, 10, 11, 12, 4, 6, 5, 7, 9,> 8,> 15,> 13, 14, 22, 23, 24, 16, 18, 17, 19, 21,> 20,> 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,> 59,> 60, 25, 27, 26, 28, 30, 29, 34, 35, 36,> 31,> 32, 33, 37, 39, 38, 40, 42, 41, 46, 47,> 48,> 43, 44, 45},> {4, 6, 5, 1, 3, 2, 11, 10, 12, 8, 7,> 9,> 25,> 27, 26, 28, 30, 29, 34, 35, 36, 31, 32,> 33,> 13, 15, 14, 16, 18, 17, 22, 23, 24, 19,> 20,> 21, 50, 49, 51, 55, 56, 57, 52, 53, 54,> 58,> 60, 59, 38, 37, 39, 43, 44, 45, 40, 41,> 42,> 46, 48, 47},> {5, 4, 6, 8, 7, 9, 1, 2, 3, 11, 12,> 10,> 26,> 25, 27, 31, 32, 33, 28, 29, 30, 34, 36,> 35,> 38, 37, 39, 43, 44, 45, 40, 41, 42, 46,> 48,> 47, 13, 14, 15, 16, 17, 18, 19, 20, 21,> 22,> 23, 24, 50, 51, 49, 55, 57, 56, 58, 60,> 59,> 52, 53, 54},> and so on...> ==== If I enter Sum[p^i, {i, 0, Infinity}] Mathematica says, it is 1/(1-p), but doesn't say something about the domain for p: 1/(1-p) is only valid for-1=1 and p<=-1?PS: you can find a nice animation for the geometric series at ==== ====> Jos R Bergervoet result = Integrate[ Abs[Sin[k x]]^2, {x,0,1}]> N[ result /. k->I+1 ]> (* Analytical approach gives 0.261044 + 0.616283 I, WRONG !!! *)> k=I+1; NIntegrate[ Abs[Sin[k x]^2], {x,0,1}]> (* Numerical check gives 0.679391 *)> ...> What should I do to circumvent such errors?> One thing that works in Mathematica (as well as in the other CAS) is to> Integrate[ Abs[Sin[(a+b*I) x]]^2, {x,0,1}].> This gives (a*Sinh[2*b] - b*Sin[2*a]) / (4*a*b),> which agrees with your result below. But again it is wrong! It only is correct if a and b happen> to be real quantities, which is nowhere stated!Well, let me state it now here:I was merely trying to provide a workaround which would give you acorrect result in the event that your coefficient k was complex. (I wasnot trying in any way to exonerate Mathematica!) In that event, k may bewritten, _without loss of generality_, as a+b*I, where a and b are bothREAL.> So the main question still is: Why is Mathematica making> these very silly errors? One could expect it from an early> version of a product, but that is not what Mathematica 4.x> is!Yes, the main question remains.David ==== Clean those wiper blades :) For large positive x, the dominant term isE^(-x), hence 3. I'm not sure why Mathematica cannot find the limit directlyof your expression, but if you Simplify first, you do indeed get 3.Tom Burton > Hey all - I'm taking a basic calculus course that uses Mathematica.> We have been studying limits and I have been using the Limit function> to check if my answers are correct.> We were given the following function and asked to determine a limit:> (3E^(-x) - E^(-3x)) / (E^(-3x) + E^(-x)) Usually the approach is to select the dominant terms, factor and then> determine the limit. My initial reason had me select -E^(-3x) in the> numerator and E^(-3x) in the denominator. Factoring the terms would> yield -1, thus the limit for x->infinity. But I plotted the function> and the real answer is somewhere near 3.> I then tried to use the Limit function which is not producing an> answer (perhaps I'm not sure of the usage). Any help is greatly appreciated, David Seruyange ==== If you multiplicate your function by 1 in an intelligent way, hereE^(3x)/E^(3x), you will more easily be able to study your limits by hand.Mathematica also appreciates the simplification before you ask the limit !Here with Mathematica :In[7]:=f[x_] = Simplify[(3/E^x - E^(-3*x))/(E^(-3*x) + E^(-x))]Out[7]=(-1 + 3*E^(2*x))/(1 + E^(2*x))In[8]:=Limit[f[x], x -> Infinity]Out[8]=3In[9]:=Limit[f[x], x -> -Infinity]Out[9]=-1The Plot confirms this facts !In[5]:=Plot[(3/E^x - E^(-3*x))/(E^(-3*x) + E^(-x)), {x, -100, 100}]Meilleures salutationsFlorian Jaccardprofesseur de Math.8ematiquesEICN-HES-----Message d'origine-----Envoy.8e : mar., 21. janvier 2003 13:40è : mathgroup@smc.vnet.netObjet : Problem with Limits; basic calculusHey all - I'm taking a basic calculus course that uses Mathematica.We have been studying limits and I have been using the Limit functionto check if my answers are correct.We were given the following function and asked to determine a limit:(3E^(-x) - E^(-3x)) / (E^(-3x) + E^(-x))Usually the approach is to select the dominant terms, factor and thendetermine the limit. My initial reason had me select -E^(-3x) in thenumerator and E^(-3x) in the denominator. Factoring the terms wouldyield -1, thus the limit for x->infinity. But I plotted the functionand the real answer is somewhere near 3.I then tried to use the Limit function which is not producing ananswer (perhaps I'm not sure of the usage).Any help is greatly appreciated,David Seruyange ==== I strongly suggest that you buy the following book:Mathematical Statistics with Mathematica Authors Colin Rose Murray D. Smith there you'll find the answer you looking for and more.cheersyannis-----Mensaje original-----Enviado el: martes 21 de enero de 2003 13:40Para: mathgroup@smc.vnet.netAsunto: Moments of the multivariate normal distributionI am trying to use mathematica to define moment generating function ofa multivariate normal distribution with mean 0 and variance T,[N(0,T)]. I would like to be able to find the nth moment for thisdistribution.For simplicity I would like define m = exp[1/2 b'T b]= f(b), where bis a q*1 vector with elements (b1 b2 b3 b4 ... bq) (b' is 1*q), and Tis a q*q matrix with elementst11 t12 t13 ... t1qt21 t22 t23 ... t2q . . . . . . . . . . . .tq1 tq2 tq3 tqq I have looked through the online manual and have only found out how todefine a matrix or vector of specific integer size.I have found the first moment which disapears at b=0 to be m*b'*T.I have also found the second moment to be m*T + m*T*b*b'T.I am having a very hard problem finding the next moment (let alone thenext ten). I would like to use mathematica to get all the momnets Icare to look at. I would be greatful for any help!!Chris Johnsoncjque@umich.eduReply-To: Mark Coleman ==== I'm working one some webMathematica applications for finance and finance that I will soon be putting online. In the course of designing my web site, I came to realize that I need an interesting mathematically-oriented logo. Can anyone point me to an interesting/cool Mathematica graphic (that is not copyrighted), or better yet, the code for such a graphic? Ideally 3-D...Many thanks!Mark ==== >-----Original Message----->Sent: Tuesday, January 21, 2003 1:40 PM>To: mathgroup@smc.vnet.net>Hey all - I'm taking a basic calculus course that uses Mathematica. >We have been studying limits and I have been using the Limit function>to check if my answers are correct.>We were given the following function and asked to determine a limit:>(3E^(-x) - E^(-3x)) / (E^(-3x) + E^(-x))Usually the approach is to select the dominant terms, factor and then>determine the limit. My initial reason had me select -E^(-3x) in the>numerator and E^(-3x) in the denominator. Factoring the terms would>yield -1, thus the limit for x->infinity. But I plotted the function>and the real answer is somewhere near 3.>I then tried to use the Limit function which is not producing an>answer (perhaps I'm not sure of the usage).Any help is greatly appreciated, David Seruyange>David,as you told, factor and determine the limit:In[1]:= expr = (3E^(-x) - E^(-3x))/(E^(-3x) + E^(-x));In[9]:= Limit[expr, x -> -Infinity]Out[9]= -1In[10]:= Limit[Factor[expr], x -> Infinity]Out[10]= 3You might be interested in the identityIn[11]:= Factor[expr] === Together[TrigToExp[2Tanh[x] + 1]]Out[11]= TrueWhat you have to look for is the appropriate form to simplify.--HartmutReply-To: kuska@informatik.uni-leipzig.de ==== since xy is a varaible and not a function and you can onlymap functions xy[f_, t_] := {2 f Sin[t]^2, Sinh[f t] + f Log[t]};ParametricPlot[Evaluate[xy[1, t]], {t, 0, 2}];andf = {.5, 1, 1.5};trj = Map[xy[#, t] &, f]will work. Jens How to perturb the constant f in parametric plots? f= 1 ;' for single f value'> xy= { 2 f Sin[t]^2 ,Sinh[f t]+f Log[t] };> ParametricPlot[ xy , {t,0,2}]; An attemt to Map did not work.> Ô f={ .5,1,1.5};'> Ôtrj = Map [ xy &, f ];'> --Reply-To: kuska@informatik.uni-leipzig.de ==== a) as long as Times[] has the Listable attribute it will not work to get a expression like a*{x,y,z} because Times will scatter a across the vector elementsb) what is withm = {(a - 2*wone*Sin[a*t])/4, (a - 2*wone*Sin[a*t])/4, (a +2*wone*Sin[a*t])/ 4, (a + 2*wone*Sin[a*t])/4, (-a - 2*Sqrt[a^2 +wone^2*Sin[a*t]^2])/ 4, (-a - 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/ 4, (-a + 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/ 4, (-a + 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4};a*Hold[Evaluate[Apart[#/a] & /@ m]] /. a_*Hold[b_] :> Hold[a*b] Jens > How can I tell Mathematica to pull a particular factor out of an expression. For example in this expression:> {(a - 2*wone*Sin[a*t])/4, (a - 2*wone*Sin[a*t])/4, (a + 2*wone*Sin[a*t])/4,> (a + 2*wone*Sin[a*t])/4,> (-a - 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a - 2*Sqrt[a^2 +> wone^2*Sin[a*t]^2])/4,> (-a + 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a + 2*Sqrt[a^2 +> wone^2*Sin[a*t]^2])/4} I would like to bring the a out to the front of the expression, even> outside the matrix. How can I ask Mathematica to do this, and how can I stop the a just> ßoating back into the main expression? Yours Chris Rodgers> St John's College> http://rodgers.org.uk/ ==== One way to factor a from expr isexpr2 = a HoldForm@@{Simplify[expr/a]}The HoldForm is hidden in OutputForm, StandardForm, and TraditionalForm. Adrawback is that the HoldForm may complicate manipulation of expr2.Tom Burton ==== >-----Original Message----->Sent: Tuesday, January 21, 2003 1:38 PM>To: mathgroup@smc.vnet.net>How to perturb the constant f in parametric plots? f= 1 ;' for single f value'>xy= { 2 f Sin[t]^2 ,Sinh[f t]+f Log[t] };>ParametricPlot[ xy , {t,0,2}];An attemt to Map did not work.>' f={ .5,1,1.5};'>'trj = Map [ xy &, f ];'>--Preferably, I don't press everthing into one line:In[1]:= f = 1;Now, as f has a certain value, we must block it off, when defining xy:In[2]:= Block[{f}, xy = {2 f Sin[t]^2, Sinh[f t] + f Log[t]}]Out[2]= {2 Sin[t]^2, Log[t] + Sinh[t]}f seemingly disappeared, butIn[3]:= ?xy Global`xy xy = {2 f Sin[t]^2, f Log[t] + Sinh[f t]}Rest is easy:In[4]:=ParametricPlot[ Evaluate[Block[{f = #}, xy] & /@ {.5, 1, 1.5}], {t, 0, 3}, PlotStyle -> {Hue[0], Hue[.3], Hue[.6]}]--Hartmut ==== MatchQ[x^1, x^_Integer] I got False result. I think I should get True for this. Could anyone explain this ? ==== There seems to be some confusion on the terms undefined andindeterminate. First of all, karthik's statement that 0/0 cannot beindeterminate because it has to take the form (0x1)/0 is in error. That's just another name for 0/0. We could easily rewrite 0/0 in manydifferent forms.Should we say that it is all numbers? Let's consider a differentexample:What is 6/2?Well, by reducing, we get 6/2=3. How do we know that is true? We canmultiply 3 by 2 to get 6: 3*2=6. Now, let's apply that back to theoriginal question.If we look at 0/0, what times zero gives us zero?0*0=0, therefore 0/0=00*1=0, therefore 0/0=10*2=0, therefore 0/0=2 ... and on and on to the point any number can satisfy the question:What is 0/0?Now, is it undefined? Let's take a look at that.6/0=undefined. Why? The answer is in the question we answeredbefore. What multiplied by zero gives 6? The answer is, we don'tknow. There is noting defined to give us the number zero.0/0 cannot be undefined because there are plenty of definitions forwhat it gives. It must therefore be indeterminate. ==== It's actually pretty easy to modify the menu to include whatever sizes you want. (Although technically it might violate the license agreement... ??) Just find the file called MenuSetup.tr. On my Mac it's in SystemFiles : FrontEnd : TextResources : Macintosh.Once you open it and scroll down a bit, it will be obvious what to do. (But, just in case, you should make a back-up first.)-----Selwyn Hollishttp://www.math.armstrong.edu/faculty/hollis> Dear All,> Probably a stupid question, but:> Can I set the size of the font used in text cells at 13 ?> The options on the menu go: ...9, 10, 12, 14, 16, ...> But 12 seems too small to read easily, and 14 seems too big.> I want my external examiner to have as comfortable a time reading my > thesis> as possible ! ==== Danke schoen Jens! That's just what I needed. After some refinement, here's the result as a QuickTime movie (140k): http://www.appliedsymbols.com/mma/icosaspin.mov(If WRI had the same mediocre standards as their competition, they'd feature this on their website.. :-)----Selwyn Hollis a) computing the true shadows of the 3 light sources> would requite the construction of the shadow volumes> and take an half hour per frame b) fake a single shadow is easy with Needs[Graphics`Polyhedra`]> Needs[Graphics`Shapes`] toShadow[gray_?MatrixQ, {x1_, x2_}, {y1_, y2_}, z_] := Module[{n, m, dx, dy, points, cgraph},> {m, n} = Dimensions[gray];> dx = (x2 - x1)/(n);> dy = (y2 - y1)/(m);> points = Table[{x1 + dx*i, y1 + dy*j, z}, {j, 0, m}, {i, 0, n}]; poly => Drop [#, -1] & /@> Drop[Transpose[{points, RotateRight[points],> RotateLeft /@ RotateRight[points], RotateLeft /@ points},> {3, 1,> 2}], -1];> {EdgeForm[], Transpose[{Map[SurfaceColor[GrayLevel[#]] &, gray,> {2}],> Map[Polygon, poly, {2}]}, {3, 1, 2}]}> ] makeShadow[t_, opts___?OptionQ] :=> Module[{sh},> sh = DensityPlot[> 1 - Exp[-(3 + Sin[t/2])*(x^2 + y^2)], {x, -2, 2}, {y, -2, 2},> DisplayFunction -> Identity, opts];> toShadow[sh[[1]], {-2, 2}, {-2, 2}, -2]> ]> obj = Table[RotateShape[Icosahedron[], t, t/2, t/3], {t, 0, 8, 1/10}];>> MapIndexed[> Show[Graphics3D[{makeShadow[First[#2], PlotPoints -> 30], #1},> Boxed -> False, PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}]] &,> obj]; but that is *not* the shadow that the three colored light sources would> produce -- that would be much more expensive. If some one else would like to have (hard) shadows I can include it > into Jens> I'm interestied in using Mathematica to do something similar to this:> http://www.mapleapps.com/powertools/logos/appess3.gif> Does anyone have a guess at what kind of rotation is being used?> And how one might get a similar shadow effect? (Without resorting to a> different rendering engine.)> Selwyn To: mathgroup@smc.vnet.net> -----Original Message-----> To: mathgroup@smc.vnet.net> Sent: Saturday, January 18, 2003 6:39 AM> To: mathgroup@smc.vnet.net> Does anyone why f@a_=2 a gives a proper answer for f[1]> and not in the case of Prefix[s[a_]]= 2 a eventhough that> Prefix[s[a_]]=> f@a_???> In[1]:=> f@a_=2 a> f[1]> Out[1]=> 2 a> Out[2]=> 2> In[3]:=> Prefix[s[a_]]> Prefix[s[a_]]=2 a> s[1]> Out[3]=> s@a_> Set::write: Tag Prefix in s@a_ is Protected.> Out[4]=> 2 a> Out[5]=> s[1]>> Ashraf, the question is: what behaviour did you expect? An answer to that might> solve your problem. First, Prefix[s[a_]] is *not* the same as f@a_ In[1]:= f@a_ := 2 a> In[2]:= ?f> Global`f> f[a_] := 2 a In[3]:= f[1]> Out[3]= 2 Compare this to In[4]:= Prefix[s[a_]]> Out[4]= s@a_ In[5]:= % // FullForm> Out[5]//FullForm=> Prefix[s[Pattern[a, Blank[]]]] So Prefix is a wrapper for printing purposes (only). Such you cannot > make> definitions for it (as it is protected), but also, it is a special > form not> submitted to the standard evaluation sequence, see: In[7]:= Prefix[s[aaa___]] ^= s[aaa]> Out[7]= s[aaa] In[8]:= s[a_] := 2 a> In[9]:= ?s> Global`s> Prefix[s[aaa___]] ^= s[aaa]> s[a_] := 2 a> In[10]:= Prefix[s[2]]> Out[10]= Prefix[4] So even Upvalues won't work. You may however do In[12]:= Prefix[Unevaluated[s[2]]]> Out[12]= 4 The very question, however, is whether this is what you intended, or > say,> what did you want to achieve at all? -- ==== Since Exp[-x] goes to zero as x goes to +infinity, the dominant termis not Exp[-3x]==Exp[-x]^3 but Exp[-x], so 3 is the real value of thelimit.Using Simplify on the original expression yields:-1 + 3 Exp[2x]---------------1+ 2 Exp[2x]It is clear (use L'Hospital rule for formal proof) that the limit isindeed 3.Finally, by applying FullSimplify we get 1 + 2Tanh[x] and sinceLimit[Tanh[x],x->inf]==1 we also get 3.Orestis> Hey all - I'm taking a basic calculus course that uses Mathematica. > We have been studying limits and I have been using the Limit function> to check if my answers are correct.> We were given the following function and asked to determine a limit:> (3E^(-x) - E^(-3x)) / (E^(-3x) + E^(-x)) Usually the approach is to select the dominant terms, factor and then> determine the limit. My initial reason had me select -E^(-3x) in the> numerator and E^(-3x) in the denominator. Factoring the terms would> yield -1, thus the limit for x->infinity. But I plotted the function> and the real answer is somewhere near 3.> I then tried to use the Limit function which is not producing an> answer (perhaps I'm not sure of the usage). Any help is greatly appreciated, David SeruyangeReply-To: kuska@informatik.uni-leipzig.de ==== if you useexpr = (3E^(-x) - E^(-3x))/(E^(-3x) + E^(-x));Cancel[expr /. {Exp[-x] -> z, Exp[-3x] -> z^3}]z->0 when x->Infinity and from the limit of(3 - z^2)/(1 + z^2)is obvious 3 for z->0 Jens Hey all - I'm taking a basic calculus course that uses Mathematica.> We have been studying limits and I have been using the Limit function> to check if my answers are correct.> We were given the following function and asked to determine a limit:> (3E^(-x) - E^(-3x)) / (E^(-3x) + E^(-x)) Usually the approach is to select the dominant terms, factor and then> determine the limit. My initial reason had me select -E^(-3x) in the> numerator and E^(-3x) in the denominator. Factoring the terms would> yield -1, thus the limit for x->infinity. But I plotted the function> and the real answer is somewhere near 3.> I then tried to use the Limit function which is not producing an> answer (perhaps I'm not sure of the usage). Any help is greatly appreciated, David Seruyange ==== > Hey all - I'm taking a basic calculus course that uses Mathematica.> We have been studying limits and I have been using the Limit function> to check if my answers are correct.> We were given the following function and asked to determine a limit:> (3E^(-x) - E^(-3x)) / (E^(-3x) + E^(-x)) Usually the approach is to select the dominant terms, factor and then> determine the limit. My initial reason had me select -E^(-3x) in the> numerator and E^(-3x) in the denominator. Factoring the terms would> yield -1, thus the limit for x->infinity. But I plotted the function> and the real answer is somewhere near 3.> I then tried to use the Limit function which is not producing an> answer (perhaps I'm not sure of the usage).Your idea of considering the dominant terms is good, but you thought thatthe wrong ones were dominant. Since you are working with x -> Infinity,the dominant terms in numerator and denominator are 3E^(-x) and E^(-x),resp. Thus, their ratio approaches 3, just as your graph indicated.I hate to report, however, that your usage of Mathematica was correct.That its Limit function could not give an answer for such a simpleproblem is ludicrous. I had thought that perhaps you just needed to usethe Standard Add-on Package Calculus`Limit`. But I hate to report thatusing it is even worse! Rather than merely giving no answer, it then givesthe incorrect answer 0. Even more ludicrous.There is a simple workaround, however. Just Simplify your functionfirst, before asking for its limit. Mathematica gives(-1+3E^(2x))/(1+E^(2x)) as the simplification. Then, using either thebuilt-in Limit function or the one in the add-on package, the correctanswer, 3, is obtained.David Cantrell ==== On 1/21/03 at 7:38 AM, google.news.invalid@web2news.net (Narasimham>How to perturb the constant f in parametric plots?f= 1 ;' for single f value' >xy= { 2 f Sin[t]^2 ,Sinh[f t]+f Log[t] };>ParametricPlot[ xy , {t,0,2}];>An attemt to Map did not work. >' f={ .5,1,1.5};' >'trj = Map [ xy &, f];' Try trj = { 2 # Sin[t]^2 ,Sinh[f t]+# Log[t] }&/@{ .5,1,1.5}; ==== If an object is made in ParametricPlot3D, is there a way of includingcode lines to click/drag the mouse so as to rotate it ( say about avertcal axis) and to be able to see it from the other side ? -- ==== we are searching all solutions where the function f results null. f[x_] := -7500 * Ceiling[(0.5 * x) / 880] + (5 * x)Solve[{f[x] == 0}, x]As f contains jump discontinuities, we recieved the following error:InverseFunction::ifun: Inverse functions are being used. Values may be lost for multivalued inverses.Solve::tdep: The equations appear to involve the variables to be solved for in an essentially non-algebraic way.We would be pleased if anybody could help us.Philipp BurkertCarsten Siegmund ==== All:I'm striving to stay away from the mouse, using keyboard shortcutsinstead, so that I can move more quickly.Here's one that's irritating me (on windows):You are in the midst of editing in a cell. You decide you want tochange the style of the cell (e.g. from text to small text). There arethe Alt- shortcuts, but those only seem to work when the cell itself isselected. And so, the question: What keystrokes will select a cellitself, from someplace within the cell? ==== >We were given the following function and asked to determine a limit:>(3E^(-x) - E^(-3x)) / (E^(-3x) + E^(-x))>Usually the approach is to select the dominant terms, factor and then>determine the limit. My initial reason had me select -E^(-3x) in the>numerator and E^(-3x) in the denominator.E^(-x) > E^(-3x) for x > 0. So, try multiplying the numerator and denominator by E^x ==== I was wondering if someone here would be nice enough to convert this C toMathematica code. A module would be best I suppose, so users can just callit just like Random[].I'd like to experiment with this RNG in Mathematica. In fact, IIRC Mathematica uses some variant of SWC also.By the way, the following words are from another thread in another NGregarding a RNG.*** Words below from Dr. Marsaglia ***Here is a MWC example with period 3056868392^33216-1, a mere10^4005 times as long as that of the Mersenne twister, yet faster,far simpler, and seemingly at least as well-performing in testsof randomness:static unsigned long Q[1038],c=362436;unsigned long MWC1038(void){static unsigned long i=1037;unsigned long long t, a=611373678LL;t=a*Q[i]+c; c=(t>32);if(--i) return(Q[i]=t);i=1037; return(Q[0]=t); }You need to assign random 32-bits seeds to the static array Q[1038]and to the initial carry c, with 0<=c<61137367.George Marsaglia ==== Turtle-Interpretation - has been used for describing structures in 3D spaceand you probably need to get the .m file from the original location whereyou acquired the notebook using turtleinterpretation.When procuring notebooks from external sources you might want to check for*.m files as well, as some notebooks will create it if it is missing andsome will not.Steven shippee@jcs.mil> To whom may concern, I have a problem with Mathematica. I have installed Mathematica 4.2 onWindows XP. I need to run a program in Mathematica, Get[turtleinterpretation.m], this instruction could not be compiledfind this package in Mathematica and also in the Internet. Could you help me?> best regard. Hung Viet.Reply-To: kuska@informatik.uni-leipzig.de ==== no, because MathSourcehttp://library.wolfram.com/databasedon't know it and every user of mathematica can choose anyname for packages we can not know *who* has written the package. Jens To whom may concern, I have a problem with Mathematica. I have installed Mathematica 4.2 on Windows XP. I need to run a program in Mathematica, best regard. Hung Viet. ==== >-----Original Message----->Sent: Tuesday, January 21, 2003 1:40 PM>To: mathgroup@smc.vnet.netHow can I tell Mathematica to pull a particular factor out of >an expression.For example in this expression:>{(a - 2*wone*Sin[a*t])/4, (a - 2*wone*Sin[a*t])/4, (a + >2*wone*Sin[a*t])/4,>(a + 2*wone*Sin[a*t])/4,> (-a - 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a - 2*Sqrt[a^2 +>wone^2*Sin[a*t]^2])/4,> (-a + 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a + 2*Sqrt[a^2 +>wone^2*Sin[a*t]^2])/4}I would like to bring the a out to the front of the expression, even>outside the matrix.How can I ask Mathematica to do this, and how can I stop the a just>ßoating back into the main expression?YoursChris Rodgers>St John's College>http://rodgers.org.uk/>Chris,The problem comes from the Listable attribute of Plus. If you want to seeyour expression (which I call alist for a while) as you want, you can clearthat Attribute for a while: ClearAttributes[Plus, Listable] Thread[Apart[alist], Plus]Now, I think, you see what you want. The procedure is dangerous however,since the attributes of Plus should be restored, before you make any otherevaluation. SetAttributes[Plus, Listable]Assuming you need that form only for printing purposes, it might be moreconvenient just to wrap it into HoldForm: Block[{Plus}, HoldForm[#] &[Thread[Sort /@ Apart[alist], Plus]]]The Block temporarily inactivates Plus (and its attributes), HoldFormprevents threading back to the original form, after the expression havingleft Block.--Hartmut ==== > Has anybody encountered problems with Windows 2000 Service Pack 3 ? It> appears to change the way Mathlink works in Mathematica 4.0.> <...snipped... > Additionally, Mathematica 4.2 installation will not complete (after> asking whether or not I want to enter password, Mathematica fails to> launch). After starting Mathematica manually, and having entered pwd> information, JLink fails Needs[JLink`] InstallJava[] causes a file browser to pop-up and asks to select some non otherwise> specified file. I have reported the problems toram support which seemed surprised> by this ... Fulvio I am surprised too, because I have been using Mathematica 4.0.x,> Mathematica 4.1.2, and Mathematica 4.2.x on my Windows 2000 sp3> computer with no problems. Has anyone else here experienced this kind of problem?Bhuvanesh,Did you take the steps of installing Mathematica 4.2 on a machinewhich had Whidnows 2000 + SP3 ? I would like to reiterate that theprevious problems was observed on three completely different machines,all running Microsoft Windows 2000, so I am hard pressed to believethat this is a ßuke. Two of the machines, the ones that had all ofthe latest Windows Update, failed installation (it never completed)while the third, which had not been updated after SP2, worked fine. Itmay very well be that if you update windows to SP3 AFTER Mathematica4.2 is installed you may not have (or notice) a problem {a problem, itseems worth repeating, which is noticeable ONLY with Mathlink andJLink, everything else seems OK ). You should try installingMathematica 4.2 on a computer running Windows 2000 with all of the SPand updates, and then you may give us an update/comment on whether ornot you have a problem. As it stands, I must conclude that thesoftware does not run under Windows 2000.Fulvio ==== something likehttp://phong.informatik.uni-leipzig.de/~kuska/mathgl3dv3/ id15.htmhttp://phong.informatik.uni-leipzig.de/~kuska/ mathgl3dv3/id16.htmBut I have hundreds more of it ... Jens > I'm working one some webMathematica applications for finance and finance that I> will soon be putting online. In the course of designing my web site, I> came to realize that I need an interesting mathematically-oriented logo.> Can anyone point me to an interesting/cool Mathematica graphic (that is not> copyrighted), or better yet, the code for such a graphic? Ideally> 3-D... Many thanks! > Mark ==== x^1 evaluates to just x which is no longer of the form (=FullForm) Power[x,1]. Since the matching is syntactic and not semantic you do not get a match. However you do get one if instead you evaluate:In[1]:=MatchQ[Unevaluated[x^1],x^_Integer]Out[1]= Trueor:In[2]:=MatchQ[x^1,x^_Integer:1]Out[2]=TrueAndrzej Kozlowski> MatchQ[x^1, x^_Integer]> I got False result. I think I should get True for this.> Could anyone explain this ?Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/Reply-To: kuska@informatik.uni-leipzig.de ==== Aber bitte -- ist mir immer eine Freude.The true/ not faked animation with all shadows can be found athttp://phong.informatik.uni-leipzig.de/~kuska/icosshad.mov Jens Danke schoen Jens! That's just what I needed. After some refinement,> here's the result as a QuickTime movie (140k): http://www.appliedsymbols.com/mma/icosaspin.mov (If WRI had the same mediocre standards as their competition, they'd> feature this on their website.. :-) ----> Selwyn Hollis > a) computing the true shadows of the 3 light sources> would requite the construction of the shadow volumes> and take an half hour per frame> b) fake a single shadow is easy with> Needs[Graphics`Polyhedra`]> Needs[Graphics`Shapes`]> toShadow[gray_?MatrixQ, {x1_, x2_}, {y1_, y2_}, z_] :=> Module[{n, m, dx, dy, points, cgraph},> {m, n} = Dimensions[gray];> dx = (x2 - x1)/(n);> dy = (y2 - y1)/(m);> points = Table[{x1 + dx*i, y1 + dy*j, z}, {j, 0, m}, {i, 0, n}];> poly => Drop [#, -1] & /@> Drop[Transpose[{points, RotateRight[points],> RotateLeft /@ RotateRight[points], RotateLeft /@ points},> {3, 1,> 2}], -1];> {EdgeForm[], Transpose[{Map[SurfaceColor[GrayLevel[#]] &, gray,> {2}],> Map[Polygon, poly, {2}]}, {3, 1, 2}]}> ]> makeShadow[t_, opts___?OptionQ] :=> Module[{sh},> sh = DensityPlot[> 1 - Exp[-(3 + Sin[t/2])*(x^2 + y^2)], {x, -2, 2}, {y, -2, 2},> DisplayFunction -> Identity, opts];> toShadow[sh[[1]], {-2, 2}, {-2, 2}, -2]> ]> obj = Table[RotateShape[Icosahedron[], t, t/2, t/3], {t, 0, 8, 1/10}];> MapIndexed[> Show[Graphics3D[{makeShadow[First[#2], PlotPoints -> 30], #1},> Boxed -> False, PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}]] &,> obj];> but that is *not* the shadow that the three colored light sources would> produce -- that would be much more expensive.> If some one else would like to have (hard) shadows I can include it> into> Jens> I'm interestied in using Mathematica to do something similar to this:> http://www.mapleapps.com/powertools/logos/appess3.gif> Does anyone have a guess at what kind of rotation is being used?> And how one might get a similar shadow effect? (Without resorting to a> different rendering engine.)> Selwyn> To: mathgroup@smc.vnet.net> -----Original Message-----> To: mathgroup@smc.vnet.net> Sent: Saturday, January 18, 2003 6:39 AM> To: mathgroup@smc.vnet.net> Does anyone why f@a_=2 a gives a proper answer for f[1]> and not in the case of Prefix[s[a_]]= 2 a eventhough that> Prefix[s[a_]]=> f@a_???> In[1]:=> f@a_=2 a> f[1]> Out[1]=> 2 a> Out[2]=> 2> In[3]:=> Prefix[s[a_]]> Prefix[s[a_]]=2 a> s[1]> Out[3]=> s@a_> Set::write: Tag Prefix in s@a_ is Protected.> Out[4]=> 2 a> Out[5]=> s[1]> Ashraf,> the question is: what behaviour did you expect? An answer to that might> solve your problem.> First, Prefix[s[a_]] is *not* the same as f@a_> In[1]:= f@a_ := 2 a> In[2]:= ?f> Global`f> f[a_] := 2 a> In[3]:= f[1]> Out[3]= 2> Compare this to> In[4]:= Prefix[s[a_]]> Out[4]= s@a_> In[5]:= % // FullForm> Out[5]//FullForm=> Prefix[s[Pattern[a, Blank[]]]]> So Prefix is a wrapper for printing purposes (only). Such you cannot> make> definitions for it (as it is protected), but also, it is a special> form not> submitted to the standard evaluation sequence, see:> In[7]:= Prefix[s[aaa___]] ^= s[aaa]> Out[7]= s[aaa]> In[8]:= s[a_] := 2 a> In[9]:= ?s> Global`s> Prefix[s[aaa___]] ^= s[aaa]> s[a_] := 2 a> In[10]:= Prefix[s[2]]> Out[10]= Prefix[4]> So even Upvalues won't work. You may however do> In[12]:= Prefix[Unevaluated[s[2]]]> Out[12]= 4> The very question, however, is whether this is what you intended, or> say,> what did you want to achieve at all?> --> ==== >How to perturb the constant f in parametric plots?> Preferably, I don't press everthing into one line:> f = 1;> Now, as f has a certain value, we must block it off, when defining xy: Block[{f}, xy = {2 f Sin[t]^2, Sinh[f t] + f Log[t]}] ParametricPlot[ Evaluate[Block[{f = #}, xy] & /@ {.5, 1, 1.5}], {t, 0, 3}]Actually got earlier some plot by ParamaeterPlot3D where [ x,y,z=0] =F(f,t) where f,t, are parameters and chose a vertically up View point,but this one gives a better ßat plot by perturbation rather than takingspecial 3D case that I really wanted and thank you for this. -- ==== G.L.,There are a number of ways. Your could install Jens-Peer Kuska's MathGLpackage available from his web site.http://phong.informatik.uni-leipzig.de/~kuska/You could use the RealTime3D` package that comes with Mathematica. (It workson Windows, I'm not certain about other platforms.)plot1 = ParametricPlot3D[......]< 0.1, AnimationDirection -> Forward]}]You only need the SpinShow statement. The other statements select the cells,close them and start the animation. The above will run the animation for 200seconds, with each frame being displayed for 0.1 second. TheAnimationDirection can also be set to Backward or ForwardBackward.In running animations like SpinShow, you can use the cursor keys (up ordown) to stop the animation and advance one frame at a time. This is often avery convenient method for viewing animations. You can use the numeric keysto control the speed.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== >-----Original Message----->Sent: Wednesday, January 22, 2003 12:14 PM>To: mathgroup@smc.vnet.net>discontinuitieswe are searching all solutions where the function f results null. f[x_] := -7500 * Ceiling[(0.5 * x) / 880] + (5 * x)>Solve[{f[x] == 0}, x]As f contains jump discontinuities, we recieved the following error:InverseFunction::ifun: Inverse functions are being used. >Values may be >lost for multivalued inverses.Solve::tdep: The equations appear to involve the variables >to be solved >for in an essentially non-algebraic way.We would be pleased if anybody could help us.Philipp Burkert>Carsten Siegmund>Philipp, Carsten,there seems to be no method to solve problems of this kind in general. But Ican tackle your case: Instead of looking at the zeros for your risingsawtooth, we solve for a corresponding family of functions, and the sort outthose solutions which are not on any tooth.We replace the Ceiling part of the definition by constants:As Ceiling[(0.5*x)/880] are Integers we define xx = Range[-10, 20] * 880 / 0.5for a certain range and make f depended on a second parameter: f[x_, xx_] := -7500*(0.5*xx)/880 + (5*x)We now solve f[x, xx] for every xx, but keep only those solutions whichqualify. res = With[{x0 = First[x /. Solve[f[x, #] == 0, x]]}, If[f[x0] == 0, {x -> x0}, Unevaluated[Sequence[]]]] & /@ xxIn[33]:= xxres = x /. resOut[33]= {0, 1500., 3000., 4500., 6000., 7500., 9000.}We check: Plot[f[x], {x, -2000, 12000}, PlotPoints -> 500, Epilog -> {PointSize[0.01], Hue[0], Point[{#, f[#]}] & /@ xxres}]Perhaps you can adapt the method to your real Problem.--Hartmut ==== > I was wondering if someone here would be nice enough to convert this C to> Mathematica code. A module would be best I suppose, so users can just call> it just like Random[]. I'd like to experiment with this RNG in Mathematica. In fact, IIRC Mathematica uses some variant of SWC also. By the way, the following words are from another thread in another NG> regarding a RNG. *** Words below from Dr. Marsaglia *** Here is a MWC example with period 3056868392^33216-1, a mere> 10^4005 times as long as that of the Mersenne twister, yet faster,> far simpler, and seemingly at least as well-performing in tests> of randomness: static unsigned long Q[1038],c=362436; unsigned long MWC1038(void){> static unsigned long i=1037;> unsigned long long t, a=611373678LL;> t=a*Q[i]+c; c=(t>32);> if(--i) return(Q[i]=t);> i=1037; return(Q[0]=t);> } You need to assign random 32-bits seeds to the static array Q[1038]> and to the initial carry c, with 0<=c<61137367. George MarsagliaI think the code below does what is intended. This assumes a long longis 64 bits and a long is 32 bits. These are both quite platformdependent for C; maybe Marsaglia specified a particular platform? (a URLto his note would be helpful). For seeding the q and c variables I usebuilt-in Random. I also changed the variable names to avoid singlecharacters and capitalized names.SeedRandom[1111];qarray = Table[Random[Integer,{0,2^32-1}], {1038}];cc = Random[Integer, {0,61137367}];index = 1037;aconst = 611373678;mwc1038[] := Module[ {}, tt = aconst*qarray[[index]] + cc; cc = Developer`BitShiftRight[tt,32]; (*Could instead use Quotient *) tt = Mod[tt,2^32]; index--; If [index!=0, qarray[[index]] = tt; Return[tt]]; index = 1037; qarray[[0]] = tt ]Example:Table[mwc1038[], {10}]Out[48]= {1392539486, 2580953375, 977837705, 1393978643, 2243451427, 374027900, 2689334407, 2953422566, 41924440, 2262165557}Daniel LichtblauWolfram Research ==== Dear newsgroupIt is possible to calculate an Laplace-Operator with Mathematica???For each coordinate systems in each dimensions??If yes, how?AxelPs.: I mean as Laplace-Operator Nabla^2 not theLaplace-Beltrami-operator (it is a extention of the Laplace-Operator) ==== Hendrik van Hees ( http://theory.gsi.de/~vanhees/ ) gave me the solution forthis problem:For example: 2Dim - Polar coordinates------------x = r Sin[a]y = r Cos[b]xvec = {x,y}q = {r,a}jacobian = Table[D[xvec[[mu]],q[[nu]]],{mu,1,2},{nu,1,2}]gcov = FullSimplify[Transpose[jacobian].jacobian]gcontra = Inverse[gcov]g = Det[gcov]grad = Table[D[phi[q[[1]],q[[2]]],q[[k]]],{k,1,2}];Lapl = FullSimplify[1/Sqrt[g] Sum[D [Sqrt[g](gcontra.grad)[[j]],q[[j]]],{j,1,2}]]-----------It is going on for each coordinate systems in each dimensions.many thanks to HendrikAxelAxel Ligon schrieb im Newsbeitrag> Dear newsgroup It is possible to calculate an Laplace-Operator with Mathematica???> For each coordinate systems in each dimensions??> If yes, how? Axel Ps.: I mean as Laplace-Operator Nabla^2 not the> Laplace-Beltrami-operator (it is a extention of the Laplace-Operator)> ==== UËytkownik Axel Ligon napisañ w wiadomo.a6ci> Dear newsgroup It is possible to calculate an Laplace-Operator with Mathematica???> For each coordinate systems in each dimensions??> If yes, how? Axel Ps.: I mean as Laplace-Operator Nabla^2 not the> Laplace-Beltrami-operator (it is a extention of the Laplace-Operator)> Calculus`VectorAnalysis`GartekReply-To: kuska@informatik.uni-leipzig.de ==== what maythe Lapacian[] function from< For each coordinate systems in each dimensions??> If yes, how? Axel Ps.: I mean as Laplace-Operator Nabla^2 not the> Laplace-Beltrami-operator (it is a extention of the Laplace-Operator) ==== Dear MathGroup,Steven Shippee asked me about methods of solving the following problem.Find the numbers n such that n^2 is a five digit number with 0 in the seconddigit and 1 in the last digit. (i.e., x0xx1 where x is a digit 0..9).We know how to solve the problem by testing a list of all possible candidatenumbers. But is there a method that uses Solve and modular arithimetic orsome other clever method? If one looks at the answers one would think theremust be.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ ==== > Dear group, > I have m balls shared in n box. What is the probability that one box has r o > more balls? If m = 4, n=3 and r = 2 the solution will be (?): In[1] := Needs[DiscreteMath`Combinatorica`] In[2] := list = Compositions[4,3]; In[3] := (Count[list,2,2]+Count[list,2,3]+Count[list,2,4])/(3 Length[list]) The question is that this way works only when m and n are small , but for > values sush as m=20, n=11 and r=5 the computer is out of memory. Any idea?Two brute force-type methods that use functions in combinatoria:1) Given m and n, initialize a Composition c={m,0,...,0} so it is aset of Length[c]=n. Now repeatedly call c=NextComposition[c], testingeach iteration to see if it meets your criteria. Stop when you getc={0,...,0,m}.2) Repeatedly call RandomComposition[m,n] and test, using a samplesize such that you have confidence that the probability calculated viaMonte Carlo is close enough. ==== > Dear group,> I have m balls shared in n box. What is the probability that one box has r o> more balls? If m = 4, n=3 and r = 2 the solution will be (?): In[1] := Needs[DiscreteMath`Combinatorica`] In[2] := list = Compositions[4,3]; In[3] := (Count[list,2,2]+Count[list,2,3]+Count[list,2,4])/(3 Length[list]) The question is that this way works only when m and n are small , but for> values sush as m=20, n=11 and r=5 the computer is out of memory. Any idea?Two ideas, both of which are brute force, and use some similar functions...1) Use the NextComposition[ ] function, starting with list {m,0,0,...,0}] anditerating through to {0,...,0,m}, counting the ones that meet your constraint.Divide this by NumberOfComposition[m,n]. This gives exact answer.2) Run RandomComposition[m,n] a fixed number of times, counting the ones thatmeet your constraint, divided by number of times run. This gives approximateanswer. You could monitor the run, and stop on some convergence property. ==== Why doesn't this multiplication equal zero ?In[1]:= DiracDelta[2 + t] DiracDelta[t]Out[1]= DiracDelta[t] DiracDelta[2 + t]A delta multiplied by a delayed delta = 0 ... right ?Also like this :In[2]:= DiracDelta[2 + t] DiracDelta[t] // SimplifyDiracDeltaOut[2]= SimplifyDiracDelta[DiracDelta[t] DiracDelta[2 + t]]thanksMattReply-To: kuska@informatik.uni-leipzig.de ==== because Mathematica has no build-in rule to handleproduct of delta-Functionsbut now it hasUnprotect[DiracDelta]DiracDelta /: DiracDelta[a_]^n_Integer := DiracDelta[a]DiracDelta /: DiracDelta[a_]* DiracDelta[b_] /; a =!= b := 0Protect[DiracDelta]But you should keep in mind that only expressionIntegrate[a_*DiracDelta[t],{t,-Infinity,In[CapitalTh orn]nity}]/; FreeQ[a,_DiracDelta]are covered by the theory of distributions. Jens Why doesn't this multiplication equal zero ? In[1]:= DiracDelta[2 + t] DiracDelta[t]> Out[1]= DiracDelta[t] DiracDelta[2 + t] A delta multiplied by a delayed delta = 0 ... right ? Also like this : In[2]:= DiracDelta[2 + t] DiracDelta[t] // SimplifyDiracDelta> Out[2]= SimplifyDiracDelta[DiracDelta[t] DiracDelta[2 + t]] thanks> Matt ==== I don't really see the point in all this, but here is my opinion:0/0 is indeterminate and not undefined because it can NOT be defined!It is in a sense Ôundefinable', hence indeterminate.If you don't know anything about complex numbers, it appears to youthat Sqrt[-1] has no meaning, just as 0/0. It is not the same though:Sqrt[-1] can be defined to have a single (non-real) value I, so thatthe whole construct that results has an internal consistency. Since itcan actually be defined, it is undefined(if you stick to real numbers)and not indeterminate.0/0 is indeterminate for exactly the opposite reason: if someone triesto give it a reasonable value, it can be proven that ANY number wouldbe equal to it and the resulting construct would collapse immediately.Therefore 0/0 is indeterminate, eg. undefinable.Orestis Vantzos> There seems to be some confusion on the terms undefined and> indeterminate. First of all, karthik's statement that 0/0 cannot be> indeterminate because it has to take the form (0x1)/0 is in error. > That's just another name for 0/0. We could easily rewrite 0/0 in many> different forms. Should we say that it is all numbers? Let's consider a different> example: What is 6/2? Well, by reducing, we get 6/2=3. How do we know that is true? We can> multiply 3 by 2 to get 6: 3*2=6. Now, let's apply that back to the> original question. If we look at 0/0, what times zero gives us zero? 0*0=0, therefore 0/0=0> 0*1=0, therefore 0/0=1> 0*2=0, therefore 0/0=2 ... and on and on to the point any number can satisfy the question:> What is 0/0? Now, is it undefined? Let's take a look at that. 6/0=undefined. Why? The answer is in the question we answered> before. What multiplied by zero gives 6? The answer is, we don't> know. There is noting defined to give us the number zero. 0/0 cannot be undefined because there are plenty of definitions for> what it gives. It must therefore be indeterminate. ==== How do I wrap and call a C subroutine that should return nothing back toMathematica. I want to somehow specify a :ReturnType: of None or Void,but mprep doesn't recognize those tokens. If I specify Manual then myMathematica session just hangs waiting for an answer from my MathLinkprogram. Does MathLink have a function like MLPutEmptyPacket() that justtells Mathematica Expect nothing from this MathLink function. It's OK tostop waiting and return to your command loop.This is (part of) the template file I am using::Begin::Function: SetValue:Pattern: SetValue[ value_?NumericQ ]:Arguments: {value}:ArgumentTypes: {Real}:ReturnType: Manual:End:void SetValue ( double value ){ /* * Do something useful with value. * It doesn't make sense to return anything. */ /* What goes here to keep Mathematica from hanging? */}How do I specify a true MathLink subroutine that doesn't return a value toReply-To: kuska@informatik.uni-leipzig.de ==== end you function withMLPutSymbol(stdlink,Null);and not with nothing. Mathematica expect alwaysa result form a function call, because it isa functional language. Jens How do I wrap and call a C subroutine that should return nothing back to> Mathematica. I want to somehow specify a :ReturnType: of None or Void,> but mprep doesn't recognize those tokens. If I specify Manual then my> Mathematica session just hangs waiting for an answer from my MathLink> program. Does MathLink have a function like MLPutEmptyPacket() that just> tells Mathematica Expect nothing from this MathLink function. It's OK to> stop waiting and return to your command loop. This is (part of) the template file I am using: :Begin:> :Function: SetValue> :Pattern: SetValue[ value_?NumericQ ]> :Arguments: {value}> :ArgumentTypes: {Real}> :ReturnType: Manual> :End: void SetValue ( double value )> {> /*> * Do something useful with value.> * It doesn't make sense to return anything.> */ /* What goes here to keep Mathematica from hanging? */> } How do I specify a true MathLink subroutine that doesn't return a value to> ==== While playing variations on Hartmut's elegant solution I came across thefollowing illustration of the perils of blocking basic operations like Plusexpr = {(a - 2*wone*Sin[a*t])/4, (a - 2*wone*Sin[a*t])/ 4, (a + 2*wone*Sin[a*t])/4, (a + 2*wone*Sin[a*t])/ 4, (-a - 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/ 4, (-a - 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/ 4, (-a + 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/ 4, (-a + 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4}Block[{Plus},HoldForm[#] &[FullSimplify[expr]]]//InputForm HoldForm[{(4 + a)/4, (4 + a)/4, (4 + a)/4, (4 + a)/4, (-a - 2*Sqrt[1 +a^2])/4, (-a - 2*Sqrt[1 + a^2])/4, (-a + 2*Sqrt[1 + a^2])/4, (-a + 2*Sqrt[1+ a^2])/4}]Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 >-----Original Message----->Sent: Tuesday, January 21, 2003 1:40 PM>To: mathgroup@smc.vnet.net>How can I tell Mathematica to pull a particular factor out of>an expression.>For example in this expression:>{(a - 2*wone*Sin[a*t])/4, (a - 2*wone*Sin[a*t])/4, (a +>2*wone*Sin[a*t])/4,>(a + 2*wone*Sin[a*t])/4,> (-a - 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a - 2*Sqrt[a^2 +>wone^2*Sin[a*t]^2])/4,> (-a + 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a + 2*Sqrt[a^2 +>wone^2*Sin[a*t]^2])/4}>I would like to bring the a out to the front of the expression, even>outside the matrix.>How can I ask Mathematica to do this, and how can I stop the a just>ßoating back into the main expression? The problem comes from the Listable attribute of Plus. If you want to see> your expression (which I call alist for a while) as you want, you canclear> that Attribute for a while: ClearAttributes[Plus, Listable] Thread[Apart[alist], Plus]> Now, I think, you see what you want. The procedure is dangerous however,> since the attributes of Plus should be restored, before you make any other> evaluation. SetAttributes[Plus, Listable]> Assuming you need that form only for printing purposes, it might be more> convenient just to wrap it into HoldForm: Block[{Plus},> HoldForm[#] &[Thread[Sort /@ Apart[alist], Plus]]] The Block temporarily inactivates Plus (and its attributes), HoldForm> prevents threading back to the original form, after the expression having> left Block. -- ==== > MatchQ[x^1, x^_Integer]> I got False result. I think I should get True for this.> Could anyone explain this ?Kimberly,x^1 evaluates to x before the match is tested.But we have: MatchQ[Unevaluated[x^1], x^_Integer] True--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== MatchQ[x^1, x^_Integer] gives FalsebutMatchQ[Unevaluated[x^1], x^_Integer] gives TrueThe first result is because x^1 evaluates to x which doesn't match thepattern x^_Integer. The second result is because Unevaluated prevents thisevaluation from occurring before the pattern matching.--Steve LuttrellWest Malvern, UK> MatchQ[x^1, x^_Integer]> I got False result. I think I should get True for this.> Could anyone explain this ? ==== MatchQ evaluates x^1 to get x ... then x is compared with the patternand does not match, since syntactically it is not of the formx^_Integer (it doesn't even have a Power head.)In[2]:= 1 _IntegerTrace[MatchQ[x , x ]]Out[2]= 1xx _IntegerMatchQ[x, x ]FalseOn the other hand MatchQ[x, x^_.] will match... see Default in theHelp Browser.Orestis Vantzos> MatchQ[x^1, x^_Integer] > I got False result. I think I should get True for this. > Could anyone explain this ?> Reply-To: kuska@informatik.uni-leipzig.de ==== tryMatchQ[x^1, x^_.]orMatchQ[x^1, x^n_./; IntegerQ[n]] Jens MatchQ[x^1, x^_Integer]> I got False result. I think I should get True for this.> Could anyone explain this ?> Reply-To: k.chourdakis@qmul.ac.uk ==== Dear all,I am trying to simulate a multivariate t-distribution,and encounter the following problem:(* First load the packages *)<we are searching all solutions where the function f results null.>f[x_] := -7500 * Ceiling[(0.5 * x) / 880] + (5 * x) By inspection f[0]=0Eliminating Ceiling to get f=-7500 * (0.5 * x) / 880 + (5 * x) gives a result that is linear in x. Since it is linear in x, there can only be one root. So, clearly the only root to the original equation is x = 0. ==== hiI want to solove u_{t}=u_{x} * u ^ 2 + u_{xx} * (1-u) and u_{t} =u_{xx} + exp (-u )+ exp (-2u) by using Method Of Lineplease help me.Note: Please give your explain by using computer code or computer algorithm(numerical)Reply-To: kuska@informatik.uni-leipzig.de ==== it looks pretty much like a student home work.Ask your instructor/tutor. Jens hi I want to solove u_{t}=u_{x} * u ^ 2 + u_{xx} * (1-u) and u_{t} =u_{xx} + exp (-u )+ exp (-2u) by using Method Of Line please help me. Note: Please give your explain by using computer code or computer algorithm(numerical)Reply-To: kuska@informatik.uni-leipzig.de ==== a) you can use MathGL3d form http://phong.informatik.uni-leipzig.de/~kuska/mathgl3dv3/id3. htmb) you can load < code lines to click/drag the mouse so as to rotate it ( say about a> vertcal axis) and to be able to see it from the other side ?> -- ==== >If an object is made in ParametricPlot3D, is there a way of including>code lines to click/drag the mouse so as to rotate it ( say about a>vertcal axis) and to be able to see it from the other side ?>--This can be done using JLink and the LiveGraphics3D applet. For an example, seehttp://omegaconsultinggroup.com/Services/ezine19.nborhttp ://omegaconsultinggroup.com/Services/ezine19.htmlunder the section QuickTip.-------------------------------------------------- ------------Omega ConsultingThe final answer to your Mathematica needshttp://omegaconsultinggroup.com ==== Kirk,This question has come up before, and you could search the archives atgoogle orram to find an answer.At any rate, the simplest way to select a cell while the cursor is in thecell is to repeatedly hit Ctrl-. until the vertical bar is highlighted. Themain problem with this approach is that if you hit Ctrl-. one too manytimes, you will select a whole bunch of cells. A smaller problem is that ifyou are deeply buried within a cell, it may take many Ctrl-.s to select thecell.A more complicated method to do what you want which avoids the aboveproblems is to create a new hot key by editing the KeyEventTranslations.trsystem file. If you are interested in doing this, you can search thearchives for discussions about this file, or you can fiddle with the file(after you save a copy of it). One thing to watch out for is to avoid usinghot keys that have already been defined for the menu system. The menu hotkeys are defined in the file MenuSetup.tr.If you want to pursue the second option above, feel free to ask for moreadvice.Carl WollPhysics DeptU of Washington> All: I'm striving to stay away from the mouse, using keyboard shortcuts> instead, so that I can move more quickly. Here's one that's irritating me (on windows): You are in the midst of editing in a cell. You decide you want to> change the style of the cell (e.g. from text to small text). There are> the Alt- shortcuts, but those only seem to work when the cell itself is> selected. And so, the question: What keystrokes will select a cell> itself, from someplace within the cell? ==== > All: I'm striving to stay away from the mouse, using keyboard shortcuts> instead, so that I can move more quickly. Here's one that's irritating me (on windows): You are in the midst of editing in a cell. You decide you want to> change the style of the cell (e.g. from text to small text). There are> the Alt- shortcuts, but those only seem to work when the cell itself is> selected. And so, the question: What keystrokes will select a cell> itself, from someplace within the cell?> Control-period expands the current selection. If you have the entirecontents of a cell selected, the selection is expanded to be the cellbracket. So, typically, you would have to press Control-period twoto four times (but if your selection is in a deeply nested expression,perhaps more) to select the cell bracket.A related mouse trick (I know you didn't ask, but since I'm on thesoapbox, I thought I'd mention it) can duplicate this keystroke withthe mouse. If you double-click on some text, that's the same ashaving the selection there and pressing Control-period once. Triple-clicking is like pressing control-period twice. And so on (except thatyou cannot select the cell bracket using the mouse via this means).This is particularly useful in input/output cells where the selectioncan be expanded by knowledge of the expression structure. This meansthat you can, for example, easily select a whole string, or the entirecontents of a set of square brackets by either triple-clicking insidethe string/square brackets or by using Control-period twice when insidethe string/square brackets.Sincerely,John Fultzjfultz@wolfram.comUser Interface GroupWolfram Research, Inc. ==== Suppose you have an initial value (value of assets Vo) and you know (like in a binomial option pricing model) that this asset value can either go up (Vo u) or down (Vo d), where u is 1.1 (let's assume this) and d==1/u. This process continues defining a binomial tree for the evolution of this asset value. Now suppose that, in step 3 (M1), you have to subtract P1 from the asset value at that moment. You have to subtract this amount P1 to each node (in step 3 you will have 4 nodes). Then continue with the binomial tree using u and d as defined above. I really have a problem here. My implementation is an algorith that produces a n-step binomial tree starting with value Vo and with given u & d parameters. However my problem is that this algorithm subtracts P1 for all the values of the tree after step 3. What the algorithm its expected to do is to subtract P1 only for the nodes of step 3 and then go on with the calculation. Ignacio ==== the package< hi I want to solove u_{t}=u_{x} * u ^ 2 + u_{xx} * (1-u) and u_{t} =u_{xx} + exp (-u )+ exp (-2u) by using Method Of Line please help me. Note: Please give your explain by using computer code or computer algorithm(numerical) ==== > Mathematica is NOT giving wrong answers in this case. It is assuming (non-zero) real parameters and giving the right> answer in that case.Whether Mathematica is or is not giving a wrong answer in the caseresult = Integrate[ Abs[Sin[k x]]^2, {x,0,1}]; N[ result /. k->I+1 ]depends upon whether it is or is not appropriate for Mathematica tomake a default assumption that k is a nonzero real. IMO, that could bedebated.But surely, as I noted previously in this thread, Mathematica -- atleast version 4.2 for Windows -- does give a wrong answer forresult = Integrate[ Abs[Sin[k x]]^2, {x,0,1}, Assumptions->Element[k, Complexes]; N[ result /. k->I+1 ]. I do not see how theincorrectness of this can be debated (other than to say thatMathematica should be allowed to ignore an _explicitly stated_assumption!)David> On Wed, 22 Jan 2003 06:09:24 -0500 (EST), David W. Cantrell > Jos R Bergervoet result = Integrate[ Abs[Sin[k x]]^2, {x,0,1}]> N[ result /. k->I+1 ]> (* Analytical approach gives 0.261044 + 0.616283 I, WRONG!!! *)> k=I+1; NIntegrate[ Abs[Sin[k x]^2], {x,0,1}]> (* Numerical check gives 0.679391 *)> ...> What should I do to circumvent such errors?> One thing that works in Mathematica (as well as in the other> CAS) is to> Integrate[ Abs[Sin[(a+b*I) x]]^2, {x,0,1}].> This gives (a*Sinh[2*b] - b*Sin[2*a]) / (4*a*b),> which agrees with your result below.> But again it is wrong! It only is correct if a and b happen> to be real quantities, which is nowhere stated!> Well, let me state it now here:> I was merely trying to provide a workaround which would give> you a correct result in the event that your coefficient k wascomplex.> (I was not trying in any way to exonerate Mathematica!) In that> event, k may be written, _without loss of generality_, as a+b*I,> where a and b are both REAL.> So the main question still is: Why is Mathematica making> these very silly errors? One could expect it from an early> version of a product, but that is not what Mathematica 4.x> is!> Yes, the main question remains. ==== Mathematica is NOT giving wrong answers in this case.It is assuming (non-zero) real parameters and giving the right answer in that case.BobbyOn Wed, 22 Jan 2003 06:09:24 -0500 (EST), David W. Cantrell > Jos R Bergervoet result = Integrate[ Abs[Sin[k x]]^2, {x,0,1}]> N[ result /. k->I+1 ]> (* Analytical approach gives 0.261044 + 0.616283 I, WRONG !!! *)> k=I+1; NIntegrate[ Abs[Sin[k x]^2], {x,0,1}]> (* Numerical check gives 0.679391 *)> ...> What should I do to circumvent such errors?> One thing that works in Mathematica (as well as in the other CAS) is > to> Integrate[ Abs[Sin[(a+b*I) x]]^2, {x,0,1}].> This gives (a*Sinh[2*b] - b*Sin[2*a]) / (4*a*b),> which agrees with your result below.> But again it is wrong! It only is correct if a and b happen> to be real quantities, which is nowhere stated! Well, let me state it now here: I was merely trying to provide a workaround which would give you a> correct result in the event that your coefficient k was complex. (I was> not trying in any way to exonerate Mathematica!) In that event, k may be> written, _without loss of generality_, as a+b*I, where a and b are both> REAL.> So the main question still is: Why is Mathematica making> these very silly errors? One could expect it from an early> version of a product, but that is not what Mathematica 4.x> is! Yes, the main question remains. David-- majort@cox-internet.comBobby R. Treat ==== Kimberly,Because Mathematica evaluates and simplifies x^1 to x, which does not matchyour form.x^1 // FullFormxBut this works...MatchQ[Unevaluated[x^1], x^_Integer]TrueUnderstanding and controlling order of evaluation in Mathematica is probablyone of its toughest aspects. Fortunately, most of the time things work theway you want.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== Does anyone have experience of using Mathematica or any other math application to teach a blind student?I am interested of any knowlegde no matter level, ie grade 7 to university. My student will next semester be in grade 7.SincerelyTruls Cronberg ==== Is this what you did (essentially)? Flatten[ Outer[List, Range[9], {0}, Range[0, 9], Range[0, 9], {1}], 4], _Integer]%*%{101, 201, 301}{10201, 40401, 90601}I haven't thought of a much smarter method, as yet, but here's a far less exhaustive search:nSquare /. List /@ Thread[c -> {1, 9}]Flatten[% /. List /@ Thread[a -> {1, 2, 3}]]At this point, it's clear that b=0, c=1, a=1, 2, or 3 gives three valid answers and that b can't be anything but 0 when a = 3, which narrows the field considerably.nSquare /. List /@ Thread[c -> {1, 9}]Flatten[% /. List /@ Thread[a -> {1, 2}]]Flatten[% /. List /@ Thread[b -> Range[9]]]Visual inspection shows no solutions among these, which can be verified as follows.Cases[%, q_ /; 10^4 < q < 10^5]Cases[%, q_ /; Mod[Floor[q/10^3], 10] == 0]Alternatively, the following isn't too exhaustive, either:nSquare /. List /@ Thread[c -> {1, 9}]Flatten[% /. List /@ Thread[a -> {1, 2, 3}]]Flatten[% /. List /@ Thread[b -> Range[0, 9]]]Cases[%, q_ /; 10^4 < q < 10^5]Cases[%, q_ /; Mod[Floor[q/10^3], 10] == 0]BobbyOn Thu, 23 Jan 2003 08:04:38 -0500 (EST), David Park second> digit and 1 in the last digit. (i.e., x0xx1 where x is a digit 0..9). We know how to solve the problem by testing a list of all possible > candidate> numbers. But is there a method that uses Solve and modular arithimetic or> some other clever method? If one looks at the answers one would think > there> must be. David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ -- majort@cox-internet.comBobby R. Treat ==== David: If n squared yields a five-digit answer, n must be 100 orgreater but not more than 316. Only n's ending in 1 or 9 will produce asquare ending in 1. Join[Range[101,316,10], Range[109,316,10]]generates all (43) such n's. It is simple to select from those the few(3) that yield 0 as the second digit in their squares: Select[,IntegerDigits[#^2][[2]]== 0 &] They are: 101, 201, and 301. Givenhowfew candidates there are to test (43), I wonder why this approach, eventhough it involves testing a list of all possible candidate numbers,isn't the fastest and easiest route. Best, Harvey-----Original Message-----orsome other clever method? If one looks at the answers one would thinktheremust be.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Reply-To: no spam please ==== i'm looking for a function to plot a cone with a interpolated gouraudshading in Mathematica.I tried with another system, but theresult is awful, because the circle of the cone is squared.thanks. ==== With Mathematica 4.1 on Windows98:N[Log[8]/Log[2]]3.Floor[N[Log[8]/Log[2]]]2Beware!== ==How does one determine whether an instance of the Mathematica Kernal isrunning via Mathlink , or even Visual Basic. I only want to keep oneconnect to this instance not start up a new instance. All I can think of iskeep the MLINK variable as a global and check that it does not equal zero.that will connect to this.--Daniel Heneghan ==== Here's a useful plot:f[x_] := 5(x - 1500 Ceiling[x/1760])plot1 = Block[{$DisplayFunction = Identity}, Plot[f@x, {x, -2000, 15000}]];Show[plot1, Graphics@{ AbsolutePointSize@5, Point[{#, f@#}] & /@ Range[0, 9000, 1500]} ];Bobby> You missed two roots (0 and 1500). Here's the case Mod[x, 1760] > 0: f[x_] := 5(x - 1500 Ceiling[x/1760])> xRule = x -> 1760 k + y;> Simplify[f@x /. xRule, {0 < y < 1760, k .89ÌÌ Integers}]> % /. Ceiling[a_] -> 1> yRule = First@Solve[% == 0, y]> Flatten[k /. Solve[y == # /. yRule, k] & /@ {1, 1759}]> kValues = Range[Ceiling@Min@%, Floor@Max@%]> yValues = y /. (yRule /. List /@ Thread[k -> kValues])> 1760kValues + yValues> f /@ % and here's the case Mod[x, 1760] == 0:>> xRule = x -> 1760 k + y;> Simplify[5(x - 1500 Ceiling[x/1760]) //. {xRule, y -> 0}, {k .89ÌÌ Integers}]> yRule = First@Solve[% == 0, k]> 1760k /. %> f@% Bobby On Thu, 23 Jan 2003 08:05:15 -0500 (EST), Orestis Vantzos > Your function simplifies to:> f[x_]:=5(x - 1500 Ceiling[x/1760])> Now assume that [First Case] x==1760 k + y , 0 Then Ceiling[x/1760]== Ceiling[k + y/1760]== k+1> so that f[x]==5 (-1500 + 260 k + y)> If f[x]==0 then 5 (-1500 + 260 k + y)==0 and we solve for y:> y== 1500-260 k> 0 0< 1500-260k <=1760> -1500<-260 k <= 260> 5.77 > k >= 1> So k ranges from 1 to 5 and since x==1500(k+1) the roots are:> Table[1500(k + 1),{k,1,5}]> {3000, 4500, 6000, 7500, 9000}> Orestis Vantzos> we are searching all solutions where the function f results null.> f[x_] := -7500 * Ceiling[(0.5 * x) / 880] + (5 * x)> Solve[{f[x] == 0}, x]> As f contains jump discontinuities, we recieved the following error:> InverseFunction::ifun: Inverse functions are being used. Values may > be > lost for multivalued inverses.> Solve::tdep: The equations appear to involve the variables to be > solved > for in an essentially non-algebraic way.> We would be pleased if anybody could help us. -- majort@cox-internet.comBobby R. Treat ==== You missed two roots (0 and 1500). Here's the case Mod[x, 1760] > 0:f[x_] := 5(x - 1500 Ceiling[x/1760])xRule = x -> 1760 k + y;Simplify[f@x /. xRule, {0 < y < 1760, k .89ÌÌ Integers}]% /. Ceiling[a_] -> 1yRule = First@Solve[% == 0, y]Flatten[k /. Solve[y == # /. yRule, k] & /@ {1, 1759}]kValues = Range[Ceiling@Min@%, Floor@Max@%]yValues = y /. (yRule /. List /@ Thread[k -> kValues])1760kValues + yValuesf /@ %and here's the case Mod[x, 1760] == 0:xRule = x -> 1760 k + y;Simplify[5(x - 1500 Ceiling[x/1760]) //. {xRule, y -> 0}, {k .89ÌÌ Integers}]yRule = First@Solve[% == 0, k]1760k /. %f@%BobbyOn Thu, 23 Jan 2003 08:05:15 -0500 (EST), Orestis Vantzos > Your function simplifies to:> f[x_]:=5(x - 1500 Ceiling[x/1760]) Now assume that [First Case] x==1760 k + y , 0 Then Ceiling[x/1760]== Ceiling[k + y/1760]== k+1> so that f[x]==5 (-1500 + 260 k + y) If f[x]==0 then 5 (-1500 + 260 k + y)==0 and we solve for y:> y== 1500-260 k 0 -1500<-260 k <= 260> 5.77 > k >= 1 So k ranges from 1 to 5 and since x==1500(k+1) the roots are:> Table[1500(k + 1),{k,1,5}]> {3000, 4500, 6000, 7500, 9000} Orestis Vantzos> we are searching all solutions where the function f results null.> f[x_] := -7500 * Ceiling[(0.5 * x) / 880] + (5 * x)> Solve[{f[x] == 0}, x]> As f contains jump discontinuities, we recieved the following error:> InverseFunction::ifun: Inverse functions are being used. Values may > be > lost for multivalued inverses.> Solve::tdep: The equations appear to involve the variables to be > solved > for in an essentially non-algebraic way.> We would be pleased if anybody could help us.> Philipp Burkert> Carsten Siegmund-- majort@cox-internet.comBobby R. Treat ==== we are searching all solutions where the function f results null. f[x_] := -7500 * Ceiling[(0.5 * x) / 880] + (5 * x)> Solve[{f[x] == 0}, x]Sometimes, it is helpful to try plotting the function on a macro scale andthen to find regions of interest.Once regions of interest are found, one can then use other methods to locatethe roots.In your problem, do:Plot[f[x], {x, -4000, 15000}]and see where the area of interest is.Can you now define the region?What other commands are available to you when you can define regions?Note: I haven't looked at other root finding methods to know if this can besolved, but there probably is something in Mathematica, just some recommendationswhen all seems lost to canned methods.HTH, Flip ==== Your function simplifies to:f[x_]:=5(x - 1500 Ceiling[x/1760])Now assume that [First Case] x==1760 k + y , 00< 1500-260k <=1760-1500<-260 k <= 2605.77 > k >= 1So k ranges from 1 to 5 and since x==1500(k+1) the roots are:Table[1500(k + 1),{k,1,5}]{3000, 4500, 6000, 7500, 9000}Orestis Vantzos we are searching all solutions where the function f results null. f[x_] := -7500 * Ceiling[(0.5 * x) / 880] + (5 * x)> Solve[{f[x] == 0}, x] As f contains jump discontinuities, we recieved the following error: InverseFunction::ifun: Inverse functions are being used. Values may be > lost for multivalued inverses. Solve::tdep: The equations appear to involve the variables to be solved > for in an essentially non-algebraic way. We would be pleased if anybody could help us. Philipp Burkert> Carsten Siegmund ==== > we are searching all solutions where the function f results null. f[x_] := -7500 * Ceiling[(0.5 * x) / 880] + (5 * x)> Solve[{f[x] == 0}, x] As f contains jump discontinuities, we recieved the following error: InverseFunction::ifun: Inverse functions are being used. Values may be> lost for multivalued inverses. Solve::tdep: The equations appear to involve the variables to be> solved for in an essentially non-algebraic way. We would be pleased if anybody could help us.Your equation has 7 roots. To see them, let me suggest that you firstPlot[f[x], {-2000, 15000}]. (BTW, please ignore the spurious verticalsegments!) As you can then guess from the graph, the solutions are 0,1500, 3000, 4500, 6000, 7500, and 9000.You discovered that Solve will not help you. However, FindRoot can be used.For example, try FindRoot[f[x]==0, {x, 7000, 8000}]. It does find a root,but not the one expected! (It gives the root 9000, rather than 7500.) Soeven with FindRoot, you must be savvy, not depending on Mathematica tooheavily.David ==== It's a SAMPLE variance, so almost anything can happen ONCE.I'm not getting sample variances anything like that, though, so there could be a bug in your version of Mathematica. I'm using version 4.2 with WinXP.Also, you may as well look at the simulated covariance matrix, CovarianceMatrix@Transpose@ET, rather than just the variance.BobbyOn Thu, 23 Jan 2003 08:05:54 -0500 (EST), KyriakosChourdakis > Dear all, I am trying to simulate a multivariate t-distribution,> and encounter the following problem: (* First load the packages *)> < < df = 20; (* the degrees of freedom - Since the number> is large, it should make the t similar to a normal *) (* Create a random variance-covariance matrix *)> rS0 = RandomArray[UniformDistribution[-0.30,> 0.80],{NS, NS}];> rS0 = rS0.Transpose[rS0];> rS0 = (rS0/Max[rS0]) (1 - IdentityMatrix[NS]) + IdentityMatrix[NS]; (* the var-covar matrix is *)> rS0> {{1, -0.290755},> {-0.290755, 1 }} (* create 10000 draws of 2 dimensional vectors *)> ET => Transpose[RandomArray[MultivariateTDistribution[rS0,> df], 10000]]; (* the theoretical cov matrix is ok, with> var=df/[df-2]... *)> ST = N[CovarianceMatrix[MultivariateTDistribution[rS0,> df]]]> {{1.11111, -0.323061}, {-0.323061, 1.11111}} (* ... But the simulated variance is not*)> Mean /@ ET> Variance /@ ET> {-0.00426186, 0.00824351}> {0.067534, 0.0670659} (* On the other hand, if I draw from the corresponding> multinormal *)> EN = Transpose[RandomArray[MultinormalDistribution[{0,> 0}, ST], 10000]]; (* Everything is OK *)> Mean /@ EN> Variance /@ EN> {0.0196956, -0.00675908} (* Should be 0 *)> {1.1362, 1.1099} (* Should be 1.111 *) I cannot understand why the simulated variance is> 0.067 instead of 1.111/[20-2]. Alternatively, why> should I multiply all values with sqrt(1.111/0.067)=4. Best, Kyriakos> __________________________________________________> Do You Yahoo!?> Everything you'll ever need on one web page> http://uk.my.yahoo.com-- majort@cox-internet.comBobby R. Treat ==== Even when the ReturnType is Manual, your C function needs to send something. It can really be anything, as long as it's a complete expression. For example, you could do/* send Print[Done] to kernel */MLPutFunction(stdlink, Print, 1);MLPutString(stdlink, Done);Now SetValue will print Done. But since you probably don't want anything from SetValue, you should send the symbol Null.MLPutSymbol(stdlink, Null);Null is an output that's automatically suppressed, so you won't see an output cell.>How do I wrap and call a C subroutine that should return nothing back to>Mathematica. I want to somehow specify a :ReturnType: of None or Void,>but mprep doesn't recognize those tokens. If I specify Manual then my>Mathematica session just hangs waiting for an answer from my MathLink>program. Does MathLink have a function like MLPutEmptyPacket() that just>tells Mathematica Expect nothing from this MathLink function. It's OK to>stop waiting and return to your command loop.This is (part of) the template file I am using:>:Begin:>:Function: SetValue>:Pattern: SetValue[ value_?NumericQ ]>:Arguments: {value}>:ArgumentTypes: {Real}>:ReturnType: Manual>:End:void SetValue ( double value )>{> /*> * Do something useful with value.> * It doesn't make sense to return anything.> */ /* What goes here to keep Mathematica from hanging? */>}>How do I specify a true MathLink subroutine that doesn't return a value to>---------------------------------------------------------- ----Omega ConsultingThe final answer to your Mathematica needshttp://omegaconsultinggroup.com ==== What's the best/simplest way to encode or format a Mathematica notebook to make it available on a web site? (as a downloadable source file only, sufficiently brief that file compression is not needed, nothing live or intended for online execution, no need for Output cells or graphics outputs in the online file, but intended to be dowbnloaded and executed by users on multiple platforms, with header and text cells kept distinct from Input cells)-- Power tends to corrupt. Absolute power corrupts absolutely. Lord Acton (1834-1902)Dependence on advertising tends to corrupt. Total dependence on advertising corrupts totally. (today's equivalent) ==== How do you enter the partial derivative shown at:www.previze.com/ partialderivative.gif ==== You might want to use VarianceTest to give a measure of how far off the sample variance is. Without something like this, the sample variance is wrong doesn't mean anything.NS = 2;df = 20; rS0 = RandomArray[UniformDistribution[-0.30, 0.80], {NS, NS}];rS0 = rS0.Transpose[rS0];rS0 = (rS0/Max[rS0]) (1 - IdentityMatrix[NS]) + IdentityMatrix[NS];rS0ET = Transpose[RandomArray[MultivariateTDistribution[rS0, df], 10000]];ST = N[CovarianceMatrix[MultivariateTDistribution[rS0, df]]]VarianceTest[Transpose@ET, 20/(20 - 2), TwoSided -> True, FullReport -> True]{{1, 0.0799201}, {0.0799201, 1}}{{1.11111, 0.0888001}, {0.0888001, 1.11111}}{FullReport -> TableForm[ {{{1.0781668250596432, 1.083761196394562}, {9702.531075394236, 9752.875382474302}, ChiSquareDistribution[ 9999]}}, TableHeadings -> {None, {Variance, TestStat, Distribution}}], TwoSidedPValue -> {0.0346164820576073098234084515`10.8823, 0.0800810808224253545167676788`10.8566}}Bobby> Dr. Bob, It is true that anything can happen once, but this is> not the case since it is happening consistently. In any way, when a sample of 10000 is drawn and the> degrees of freedom is so high [making all first> moments to exist and implying near normality], one> should not be so unlucky and get both variances wrong. I am starting to think about the bug scenario...> I am using version 4.0 on WinME. If anyone with> similar specs could try it I would be grateful. To find a path around the problem, I could try to use> univariate t-random numbers [which work fine] to> create the multivariate series, but I am not sure how.> Is the standard X = rho Y + sqrt(1-rho^2) W trick working when Y and W are [standardized]> t-distributed with df degrees of freedom ? My guess is> not since t=sqrt(Z1^2+...+Zdf^2). What would be the> correct way? Best, Kyriakos It's a SAMPLE variance, so almost anything can happen> ONCE. I'm not getting sample variances anything like that,> though, so there could> be a bug in your version of Mathematica. I'm using> version 4.2 with WinXP. Also, you may as well look at the simulated covariance> matrix,> CovarianceMatrix@Transpose@ET, rather than just the> variance. Bobby On Thu, 23 Jan 2003 08:05:54 -0500 (EST),> KyriakosChourdakis> Dear all,> I am trying to simulate a multivariate> t-distribution,> and encounter the following problem:> (* First load the packages *)> < < NS = 2; (* the number of series *)> df = 20; (* the degrees of freedom - Since the> number> is large, it should make the t similar to a normal> *)> (* Create a random variance-covariance matrix *)> rS0 = RandomArray[UniformDistribution[-0.30,> 0.80],{NS, NS}];> rS0 = rS0.Transpose[rS0];> rS0 = (rS0/Max[rS0]) (1 - IdentityMatrix[NS]) +> IdentityMatrix[NS];> (* the var-covar matrix is *)> rS0> {{1, -0.290755},> {-0.290755, 1 }}> (* create 10000 draws of 2 dimensional vectors *)> ET => Transpose[RandomArray[MultivariateTDistribution[rS0,> df], 10000]];> (* the theoretical cov matrix is ok, with> var=df/[df-2]... *)> ST => N[CovarianceMatrix[MultivariateTDistribution[rS0,> df]]]> {{1.11111, -0.323061}, {-0.323061, 1.11111}}> (* ... But the simulated variance is not*)> Mean /@ ET> Variance /@ ET> {-0.00426186, 0.00824351}> {0.067534, 0.0670659}> (* On the other hand, if I draw from the> corresponding> multinormal *)> EN => Transpose[RandomArray[MultinormalDistribution[{0,> 0}, ST], 10000]];> (* Everything is OK *)> Mean /@ EN> Variance /@ EN> {0.0196956, -0.00675908} (* Should be 0 *)> {1.1362, 1.1099} (* Should be 1.111 *)> I cannot understand why the simulated variance is> 0.067 instead of 1.111/[20-2]. Alternatively, why> should I multiply all values with> sqrt(1.111/0.067)=4.> Best,> Kyriakos> __________________________________________________> Do You Yahoo!?> Everything you'll ever need on one web page> http://uk.my.yahoo.com>> --> majort@cox-internet.com> Bobby R. Treat __________________________________________________> Do You Yahoo!?> Everything you'll ever need on one web page> http://uk.my.yahoo.com>-- majort@cox-internet.comBobby R. TreatReply-To: k.chourdakis@qmul.ac.uk ==== Dr. Bob,It is true that anything can happen once, but this isnot the case since it is happening consistently.In any way, when a sample of 10000 is drawn and thedegrees of freedom is so high [making all firstmoments to exist and implying near normality], oneshould not be so unlucky and get both variances wrong.I am starting to think about the bug scenario...I am using version 4.0 on WinME. If anyone withsimilar specs could try it I would be grateful.To find a path around the problem, I could try to useunivariate t-random numbers [which work fine] tocreate the multivariate series, but I am not sure how.Is the standardX = rho Y + sqrt(1-rho^2) Wtrick working when Y and W are [standardized]t-distributed with df degrees of freedom ? My guess isnot since t=sqrt(Z1^2+...+Zdf^2). What would be thecorrect way?Best,KyriakosIt's a SAMPLE variance, so almost anything can happenONCE.I'm not getting sample variances anything like that,though, so there couldbe a bug in your version of Mathematica. I'm usingversion 4.2 with WinXP.Also, you may as well look at the simulated covariancematrix,CovarianceMatrix@Transpose@ET, rather than just thevariance.BobbyOn Thu, 23 Jan 2003 08:05:54 -0500 (EST),KyriakosChourdakis> Dear all, I am trying to simulate a multivariatet-distribution,> and encounter the following problem: (* First load the packages *)> < < df = 20; (* the degrees of freedom - Since thenumber> is large, it should make the t similar to a normal*) (* Create a random variance-covariance matrix *)> rS0 = RandomArray[UniformDistribution[-0.30,> 0.80],{NS, NS}];> rS0 = rS0.Transpose[rS0];> rS0 = (rS0/Max[rS0]) (1 - IdentityMatrix[NS]) +IdentityMatrix[NS]; (* the var-covar matrix is *)> rS0> {{1, -0.290755},> {-0.290755, 1 }} (* create 10000 draws of 2 dimensional vectors *)> ET => Transpose[RandomArray[MultivariateTDistribution[rS0,> df], 10000]]; (* the theoretical cov matrix is ok, with> var=df/[df-2]... *)> ST =N[CovarianceMatrix[MultivariateTDistribution[rS0,> df]]]> {{1.11111, -0.323061}, {-0.323061, 1.11111}} (* ... But the simulated variance is not*)> Mean /@ ET> Variance /@ ET> {-0.00426186, 0.00824351}> {0.067534, 0.0670659} (* On the other hand, if I draw from thecorresponding> multinormal *)> EN =Transpose[RandomArray[MultinormalDistribution[{0,> 0}, ST], 10000]]; (* Everything is OK *)> Mean /@ EN> Variance /@ EN> {0.0196956, -0.00675908} (* Should be 0 *)> {1.1362, 1.1099} (* Should be 1.111 *) I cannot understand why the simulated variance is> 0.067 instead of 1.111/[20-2]. Alternatively, why> should I multiply all values withsqrt(1.111/0.067)=4. Best, Kyriakos> __________________________________________________> Do You Yahoo!?> Everything you'll ever need on one web page> http://uk.my.yahoo.com--majort@cox-internet.comBobby R. Treat__________________________________________________Do You Yahoo!?Everything you'll ever need on one web pagehttp://uk.my.yahoo.com ==== I am trying to minimize a nonlinear function of 15 variables using FindMinimum. The function is basically a CHIsquare regression for a problem I am studying that looks something like this:CHIsquare=Abs[Sum(Sum(A_m * x_m * E^(-i * B_n * y_m)))]^2 m nwhere: Sums go over all m's (# of independent variables,15 of them) and n's (# of my data points) respectively x's and y's are the variables w.r.t which I want to minimize the function <-- I must assign them COMPLEX starting values A's and B's are COMPLEX valued constantsBecasue of Abs and ^2, my CHIsquare will always be REAL but when I try using all this, it does not work - I get a message: Starting value is not a real numberfor the first variable to which I gave complex starting value.Is there some way to minimize my function that allows for complex values of variables?VesnaReply-To: k.chourdakis@qmul.ac.uk ==== A variance test gives p-values of order 10^(-4000)which apparently reject the null at all confidencelevels. I am pretty certain it is bug too.K.<< ==== ========>You might want to use VarianceTest to give a measureof how far off the sample variance is. Withoutsomething like this, the sample variance is wrongdoesn't mean anything.__________________________________________________Do You Yahoo!?Everything you'll ever need on one web pagehttp://uk.my.yahoo.com ==== I have the following problem in a do loop. I want to repeat a procedure that involves many functions many times, but I need to store the values of the functions in a matrix after each iteration.Dimitirs Psychoyios ==== I have a function f[a_,b_] defined some way. i want to fix one argument,and then generate an array of values where the other argument varies. Howcan I do this?For example, I want:{f[1, 4], f[2, 4], f[3, 4], f[4, 4]}Is there an easy way to do this?Cancel-Lock: sha1:clUpO7TgOxEfmU//aL/sajnEP6s ==== => I have a function f[a_,b_] defined some way. i want to fix one argument,> and then generate an array of values where the other argument varies. > For example, I want: {f[1, 4], f[2, 4], f[3, 4], f[4, 4]}Table[ f[i,4], {i,4} ]-Nevin ==== may be there is a simpler waythe following workesFor[(i = 0; l = {}), i < 5, (i++; l = {Flatten[l], f[i, 4]})]; l = Flatten[l]Zachary Turner schrieb:> I have a function f[a_,b_] defined some way. i want to fix one argument,> and then generate an array of values where the other argument varies. How> can I do this? For example, I want: {f[1, 4], f[2, 4], f[3, 4], f[4, 4]} Is there an easy way to do this? > ==== The following will do it:f[#, b]&/@a,where a is an array of values and b is a fixed value.Kezhao> I have a function f[a_,b_] defined some way. i want to fix one argument,> and then generate an array of values where the other argument varies. How> can I do this? For example, I want: {f[1, 4], f[2, 4], f[3, 4], f[4, 4]}> ==== > I have a function f[a_,b_] defined some way. i want to fix one argument,> and then generate an array of values where the other argument varies. How> can I do this? For example, I want: {f[1, 4], f[2, 4], f[3, 4], f[4, 4]} Is there an easy way to do this?>Zachary, Table[f[x,4],{x,1,4}] {f[1, 4], f[2, 4], f[3, 4], f[4, 4]}Or, for irregular values or a known list of values: f[x,#]&/@{ 1, 2.3, 8,-3+I, Pi,a} {f[x, 1], f[x, 2.3], f[x, 8], f[x, -3 + I], f[x, Pi], f[x, a]}--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== > I have a function f[a_,b_] defined some way. i want to fix oneargument,> and then generate an array of values where the other argument varies.How> can I do this?> For example, I want:> {f[1, 4], f[2, 4], f[3, 4], f[4, 4]}> Is there an easy way to do this?> Zachary, Table[f[x,4],{x,1,4}] {f[1, 4], f[2, 4], f[3, 4], f[4, 4]} Or, for irregular values or a known list of values: f[x,#]&/@{ 1, 2.3, 8,-3+I, Pi,a} {f[x, 1], f[x, 2.3], f[x, 8], f[x, -3 + I], f[x, Pi],> f[x, a]}Good lord. I didn't expect this many responses :) Anyway, the Table methodseems the simplest. Now I extend on this a little bit. Is there any way Ican apply FullSimplify to the result before it gets inserted into the array? ==== Perhaps Fold, FoldList, Nest, NestList and NestWhileList may help.Yas I have the following problem in a do loop. I want to repeat a procedure> that involves many functions many times, but I need to store the values> of the functions in a matrix after each iteration.> Dimitirs Psychoyios ==== Zachary: Table[f[i,4],{i,4}] Best, HarveyHarvey P. DaleUniversity Professor of Philanthropy and the LawDirector, National Center on Philanthropy and the LawNew York University School of LawRoom 206A110 West 3rd StreetNew York, N.Y. 10012-1074-----Original Message----- ==== Zachary,First, don't overlook the humble Table statement.Table[f[x, 4], {x, 1, 4}]{f[1, 4], f[2, 4], f[3, 4], f[4, 4]}Other methods to generate evenly spaced arguments...Array[f[#, 4] &, 4]{f[1, 4], f[2, 4], f[3, 4], f[4, 4]}f[#, 4] & /@ Range[4]{f[1, 4], f[2, 4], f[3, 4], f[4, 4]}For an oddball list of first arguments.f[#, 4] & /@ {1, 3, 4, 7, x}{f[1, 4], f[3, 4], f[4, 4], f[7, 4], f[x, 4]}MapThread[f[#, 4] &, {{1, 3, 4, 7, x}}]{f[1, 4], f[3, 4], f[4, 4], f[7, 4], f[x, 4]}Or to generate an oddball values for both arguments.MapThread[f[#1, #2] &, {{1, 3, 4, 7, x}, {2, 3, 4, 9, x}}]{f[1, 2], f[3, 3], f[4, 4], f[7, 9], f[x, x]}David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ ==== It's not rejected at ALL confidence levels --- just the ones with alpha > 10^(-4000).Nevertheless, that's good evidence of a bug.BobbyOn Fri, 24 Jan 2003 05:08:06 -0500 (EST), Kyriakos Chourdakis > A variance test gives p-values of order 10^(-4000)> which apparently reject the null at all confidence> levels. I am pretty certain it is bug too. K. << ==== ======== You might want to use VarianceTest to give a measure> of how far off the sample variance is. Without> something like this, the sample variance is wrong> doesn't mean anything. __________________________________________________> Do You Yahoo!?> Everything you'll ever need on one web page> http://uk.my.yahoo.com-- majort@cox-internet.comBobby R. Treat ==== I have substituted r for rho. The greek letter rho may be entered as esc-r-esc or [rho] .The expression below will compute (giving zero unless you define z in terms of r elsewhere).Abs[D[z,{r,2}]/(1+D[z,r]^2)^(3/2)]If it is a question of typesetting the formula, you can enter the above expression in a text cell, select the cell bracket and follow the menu path Cell > Convert To > TraditionalForm.The result below is the Expression version.!(*FormBox[ RowBox[{[LeftBracketingBar], FractionBox[ FractionBox[(=A1=D3^2 z), (=A1=D3r^2), MultilineFunction->None], SuperscriptBox[ RowBox[{(, RowBox[{ SuperscriptBox[ RowBox[{(, FractionBox[(=A1=D3z), (=A1=D3r), MultilineFunction->None], )}], 2], +, 1}], )}], (3/2)]], [RightBracketingBar] }], TraditionalForm])> How do you enter the partial derivative shown at: HREF=www.previze.com/partialdervative.gif>www.previze.com/> partialderivative.gifGarry HelzerDepartment of MathematicsUniversity of Maryland1303 Math BldgCollege Park, MD 20742-4015 ==== Andr.8e:Realize thatIn[1]:=FullForm[N[Log[8]/Log[2]]]Out[1]//FullForm= 2.9999999999999996`Under these conditions, and keeping in mind thatIn[2]:=?FloorIn[2]:=Floor[x] gives the greatest integer less than or equal to x.It is obvious thatIn[3]:=Floor[N[Log[8]/Log[2]]]Out[3]=2In[4]:=Ceiling[N[ Log[8]/Log[2]]]Out[4]=3Greetings,Germ.87n Buitrago----- Original Message -----> ==== > With Mathematica 4.1 on Windows98:> N[Log[8]/Log[2]]> 3.> Floor[N[Log[8]/Log[2]]]> 2> Beware!I don't find that surprising. After all, you asked for a numericalapproximation first!Several comments (based on using version 4.2 for Windows):(1) N[Log[8]/Log[2]] has FullForm 2.9999999999999996`, which, being lessthan 3, must have its Floor equal to 2 of course.(2) Floor[Log[8]/Log[2]] returns unevaluated, accompanied by a complaintabout uncertainty, while Floor[Log[2, 8]] yields 3, just as desire.(3) N[Floor[Log[8]/Log[2]]] evaluates to 2., but again accompanied by acomplaint about uncertainty. (Such complaints are valuable.)(4) FullSimplify[Floor[Log[8]/Log[2]]] evaluates to 3, just as we desire.(5) It's simply a bad idea to ask for numerical approximations when youare dealing with something in the vicinity of a jump discontinuity.(Indeed, I think it could be argued that things like Floor[3.] shouldactually be Indeterminate in Mathematica.)David Cantrell ==== >-----Original Message----->Sent: Friday, January 24, 2003 11:06 AM>To: mathgroup@smc.vnet.net>With Mathematica 4.1 on Windows98:>N[Log[8]/Log[2]]>3.>Floor[N[Log[8]/Log[2]]]>2> Beware! ,that's not a problem of Mathematica, but we have to pose the right question:In[75]:= FullSimplify[Log[8]/Log[2]]Out[75]= 3The exact answer!You might be interested to observe (e.g. set n = 1000):Length /@ Split@Table[Floor@(Divide @@ Log@SetPrecision[{8, 2}, p]), {p, n}]Or else, look at:In[92]:= Divide @@ Log@SetPrecision[{8, 2}, 60] // InputFormOut[92]//InputForm= 2.99999999999999999999999999999999999999999999999999999 9999999999999740815`59.7159In[93]:= Divide @@ Log@SetPrecision[{8, 2}, 61] // InputFormOut[93]//InputForm= 3.00000000000000000000000000000000000000000000000000000 000000000000000000609051`60.7159We shouldn't expect something much different from this.--Hartmut ==== There are a lot of ways !Here one way for your example :In[18]:=MapThread[f, Transpose[({#1, 4} & )/@Range[4]]]Out[18]={f[1, 4], f[2, 4], f[3, 4], f[4, 4]}Or, more generally :In[21]:=MapThread[f, Transpose[({#1, fix} & ) /@ {a, b, c, d, e}]]Out[21]={f[a, fix], f[b, fix], f[c, fix], f[d, fix], f[e, fix]}Meilleures salutationsFlorian Jaccard-----Message d'origine-----Envoy.8e : ven., 24. janvier 2003 11:07è : mathgroup@smc.vnet.netObjet : Functional programmingI have a function f[a_,b_] defined some way. i want to fix one argument,and then generate an array of values where the other argument varies. Howcan I do this?For example, I want:{f[1, 4], f[2, 4], f[3, 4], f[4, 4]}Is there an easy way to do this?Reply-To: Diana ==== All,I know that I can generate the divisors of any integer with the Divisorscommand. I would like to start with x = 10, for example, and generate thedivisors of x, and then determine the sum of the divisors. I would thenlike to increment x, up to 100, for example.Diana-- ==== ========================================== ==== ===God made the integers, all else is the work of man.L. Kronecker, Jahresber. DMV 2, S. 19. ==== > All, I know that I can generate the divisors of any integer with the Divisors> command. I would like to start with x = 10, for example, and generatethe> divisors of x, and then determine the sum of the divisors. I would then> like to increment x, up to 100, for example.> Diana --> ==== =================================================> God made the integers, all else is the work of man.> L. Kronecker, Jahresber. DMV 2, S. 19.Some tools that may be useful:Diana,Plus@@Divisors[#]&/@Range[10,100]{ 18,12,28,14,24,24,31,18,39,20,42,32,36,24,60,31,42,40,56,30,72 ,32,63,48,54, 48,91,38,60,56,90,42,96,44,84,78,72,48,124,57,93,72,98,54,120, 72,120,80,90,60, 168,62,96,104,127,84,144,68,126,96,144,72,195,74,114,124,140,9 6,168,80,186, 121,126,84,224,108,132,120,180,90,234,112,168,128,144,120,252, 98,171,156,217}Rest[NestWhileList[Plus@@Divisors[1+#]&,9,#<= 100&,1, Infinity,-1]]{18,20,32,48,57,90}Allan--------------------- Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== {#1, #1^2, #1^3} &@Range[1,manytimes] might be an example of how toapproach this. Or NestList often is useful for this sort of operation. I have the following problem in a do loop. I want to repeat a procedure> that involves many functions many times, but I need to store the values> of the functions in a matrix after each iteration. > Dimitirs Psychoyios ==== I have the following problem in a do loop. I want to repeat a procedure> that involves many functions many times, but I need to store the values> of the functions in a matrix after each iteration.> Dimitirs PsychoyiosDimitris,Someway you need to include the instruction to modify the matrix and assignit to a a symbol- here is a simple illustration: lst={}; Do[lst= Append[lst,n^2],{n,5}];lst {1,4,9,16,25}--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== I do not understand your problem fully, but I think you may use theiteration construct For instead of Do. For[iter=start,.......and use a matrix e.g. with name: mtr[iter], where iter is the value, whichchanges in the loop.Hermann Schmitt----- Original Message -----> ==== Wow. But apparently it has nothing to do with Log. Look:Floor[3.0000000000000000] 3Floor[3.00000000000000000] 2---Selwyn Hollis> With Mathematica 4.1 on Windows98:> N[Log[8]/Log[2]]> 3.> Floor[N[Log[8]/Log[2]]]> 2> Beware! ==== >I have a function f[a_,b_] defined some way. i want to fix one>argument, and then generate an array of values where the other>argument varies. How can I do this?>For example, I want:>{f[1, 4], f[2, 4], f[3, 4], f[4, 4]}>Is there an easy way to do this?Try f[#,4]&/@Range[1,4] ==== >With Mathematica 4.1 on Windows98:>N[Log[8]/Log[2]] >3.>Floor[N[Log[8]/Log[2]]] >2This occurs since the N[Log[8]/Log[2]] gives you a machine precision number that is slightly less than 3With Mathematica 4.2 on a TiBook running MacOS 10.2.3Sign[N[Log[8]/Log[2]] - 3]-1A better way to express Log[8]/Log[2] would be Log[2,8] which gives an exact result of 3 ==== If I want to create a matrix A mod 2, which is a matrix of 0's and 1's, howdo I do that?So, if I want all 2x2 matrices, A mod 2, there would be 2^4 = 16 suchmatrices consisting only of 0's and 1's.These will be:{{{0, 0}, {0, 0}}, {{1, 0}, {0, 0}}, ..., {{1, 1}, {1, 1}}}I looked at permutations, discrete and combinatoria, but didn't see anythingobvoius (but I just missed it probably).Laslty, I'd like to be to do any size matrix (that is, 2x2, 3x3, where it isuser selectable) and any mod n.Flip ==== If I want to create a matrix A mod 2, which is a matrix of 0's and 1's, how> do I do that? Flip> For a matrix of order n first create a list of 0s and 1s with IntegerDigits[k,2,n^2].This operation represent the integer k as an n^2 bit number and then separates the bits into a length n^2 list.Next divide the list into n sublists, voila, an nxn matrix. By letting krange from 0 to 2^(n^2) - 1 you can generate all binary matrices ofthat order.WeshReply-To: Matthew Senn ==== i'm relatively new using mathematica 4.2. the other day, i came across whatseemed to be a simple problem, but i couldn't figure out how to do it.say i was plotting y=x^2, and i wanted to shade the region under the graphonly between x=2 to x=4 over a range of {x, 0, 5}, is there a way to dothis? i tried FilledPlot, but it filled the entire area under the graph.thank you! ==== like this:FilledRange[fun_,{x_,x1_,x2_},{f1_,f2_}]:= Module[{p1,p2}, Block[{$DisplayFunction=Identity}, p1=Plot[fun,{x,x1,x2}]; p2=FilledPlot[fun,{x,f1,f2}]; ]; Show[p1,p2] ] Your example isFilledRange[x^2,{x,0,5},{2,4}] And my example isFilledRange[Cos[x] Exp[-.1 x],{x,0,20},{4,14}] That helps? Borut> i'm relatively new using mathematica 4.2. the other day, i came acrosswhat> seemed to be a simple problem, but i couldn't figure out how to do it. say i was plotting y=x^2, and i wanted to shade the region under the graph> only between x=2 to x=4 over a range of {x, 0, 5}, is there a way to do> this? i tried FilledPlot, but it filled the entire area under the graph. thank you!> ==== Sorry for the earlier post, something went wrong in the cut and pastedepartment.For Matthew Senn's filled plot, here is an example one might cut and pastedirectly into mathematica as a starting point?< i'm relatively new using mathematica 4.2. the other day, i came acrosswhat> seemed to be a simple problem, but i couldn't figure out how to do it. say i was plotting y=x^2, and i wanted to shade the region under the graph> only between x=2 to x=4 over a range of {x, 0, 5}, is there a way to do> this? i tried FilledPlot, but it filled the entire area under the graph.Steven ShippeeHome: (360) 493-8353Work: (360) 902-5817Reply-To: Matthew Senn ==== solution:DisplayTogether[ FilledPlot[eq1[x], {x, 2, 4}, Fills -> GrayLevel[.9]], Plot[eq1[x], {x, 0, 4.5}]]and by the way, i'm very impressed with the speed at which i received theresponses. you are all very helpful, and thank you again!-- matt> i'm relatively new using mathematica 4.2. the other day, i came acrosswhat> seemed to be a simple problem, but i couldn't figure out how to do it. say i was plotting y=x^2, and i wanted to shade the region under the graph> only between x=2 to x=4 over a range of {x, 0, 5}, is there a way to do> this? i tried FilledPlot, but it filled the entire area under the graph. thank you!> ==== > i'm relatively new using mathematica 4.2. the other day, i came acrosswhat> seemed to be a simple problem, but i couldn't figure out how to do it. say i was plotting y=x^2, and i wanted to shade the region under the graph> only between x=2 to x=4 over a range of {x, 0, 5}, is there a way to do> this? i tried FilledPlot, but it filled the entire area under the graph. thank you!>Matthew,A third way: << Graphics`Graphics` DisplayTogether[ FilledPlot[{0, x^2}, {x, 2, 4}], Plot[x^2, {x, 0, 5}]]If we use x^2 instead of {0,x^2} the fill is gray.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== > i'm relatively new using mathematica 4.2. the other day, i came acrosswhat> seemed to be a simple problem, but i couldn't figure out how to do it. say i was plotting y=x^2, and i wanted to shade the region under the graph> only between x=2 to x=4 over a range of {x, 0, 5}, is there a way to do> this? i tried FilledPlot, but it filled the entire area under the graph. thank you!>Matthew,Two suggestions: << Graphics`FilledPlot` FilledPlot[{x^2, If[2 <= x <= 4, 0, x^2]}, {x, 0, 5}];Below, I use Off[Plot::plnr] to suppress messages complaining ofnon-real values. Off[Plot::plnr] FilledPlot[{x^2, If[2 <= x <= 4, 0]}, {x, 0, 5}] On[Plot::plnr]Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== f[a_, b_] := a + bWith[{b = 4}, HoldForm[f[#, b]] & /@ {1, 2, 3, 4}]{f[1, 4], f[2, 4], f[3, 4], f[4, 4]}Yas> I have a function f[a_,b_] defined some way. i want to fix one argument,> and then generate an array of values where the other argument varies. How> can I do this? For example, I want: {f[1, 4], f[2, 4], f[3, 4], f[4, 4]} Is there an easy way to do this? ==== MapThread[f,{{1,2,3,4},{4,4,4,4}}]Will produce{f[1,4],f[2,4],f[3,4],f[4,4]}You can check the link:http://mathematica.co.kr/mathcomm/20_definitionviz/ index.htmlVery good tutorial on functional programming.Ignacio> I have a function f