I can no longer find help info on the <Add-ons>Extra Utilities>Functions I used to be able to access the help info. Where in the world is it? ---------------------------------------------------------------------- In article <6tbscr$mm0@smc.vnet.net>, Lawrence Walker writes: |> I can no longer find help info on the < tried the following: |> |> Help>Add-ons>Extra Utilities>Functions |> |> I used to be able to access the help info. Where in the world is it? The actual scroll-pane sequence is: With the Add-ons radio button clicked... Extra Utilities -> Notation -> Functions If this is not what you're observing, you may want to do a sanity check by evaluating the following expression in a notebook: FrontEndExecute[FrontEnd`HelpBrowserLookup[AddOns, Functions]] If that produces a beep, the next thing that I would do would be to have the front end to rebuild the Help Index. This is done with the front end menu command seqence: Help -> Rebuild Help Index Repeat the FrontEndExecute[] command thereafter. If this produces the same beep error, then browse the hard drive where Mathematica is installed. You can do this by evaluating the following commands: SetDirectory[ ToFileName[{$TopDirectory,AddOns, ExtraPackages,Utilities, Documentation, English}]] FileNames[] This should return {BrowserCategories.m,NotationDocumentation.nb,NotationSource.nb} Either of the first two files is missing, you've found the source of your problem. Copy the files off of the Mathematica CD-ROM into this directory and then rebuild the Help Index. 7 I have Mathematica 3.0 version for Windows and, using the Insert Object from the File menu, I have inserted figures in Micrografx Designer 6.0. Everything seems correct, the figures are displayed on video, but when I print the notebook sheet, with Print from the File menu, the figures are not printed! Why can't Mathematica integrate thrice a piecewise defined function? Here is what I mean: This is a step function: h[x_]:=If[x>0,1,0] It can (of course) be plotted and integrated. Then let: f[x_]:=Integrate[h[t],{t,0,x}] f, as well as h, can be plotted and if I put g[x_]:=Integrate[f[t],{t,0,x}] then g can be plotted, but any integral (definite or not) that I attempt to compute about g leads to an error message (though g can be NIntegrated). Am I doing something wrong somewhere? Thanks for any help. I have a similar problem with W95, but it occurs only maybe 1% of the time. A related (?) problem is that when I use the help window. If I click on the help window at all and then go back to Mathematica the window focus does not stay in the NB, even though when I click on the NB window, the cursor is where I put it. In order to continue, I have to click on the window again - very irritating. Kevin >I have problems with the Linux version; but no one else who's running it >in Linux has been able to verify my problem. When I want to edit a >line, I usually click at the point in the line where I want to insert a >character; occasionally, maybe 20% of the time, when I start typing >there, the characters are appended to the END of the line, Mathematica >beeps, and I get an error message (which I've forgotten). I suspect >the #!%* PNP mouse. Has anybody else seen this problem? (It's easy to >get around; hit the right-arrow key, then the left-arrow key, and all >goes well. But I use Mathematica on several platforms, and this is >distinctly annoying.) --Ron Bruck > > I have Mathematica 3.0 version for Windows and, using the Insert > Object from the File menu, I have inserted figures in Micrografx > Designer 6.0. > Everythings seems correct, the figures are displayed on video, but when > I print the notebook sheet, with Print from the File menu, the > figures are not printed! For an answer to your question, see the following posting to this newsgroup/mailing list. http://www.dejanews.com/getdoc.xp?AN=343197787 - Is it possible to get NDSOLVE to exit before the independent variable reaches its range? I would like to exit the numerical integration routine based on monitored conditions in the simulation. I would also like to know the value of some of my variables at exit. For example, I am modeling the vertical motion of a water rocket and would like to stop the simulation when the water is dispelled from the rocket, not necessarily at some particular value of the independent variable (time). Does anybody has a program for Mathematica with the BS-formula and formulas for exotic options? Thanx. >Does anybody has a program for Mathematica with the BS-formula and >formulas for exotic options? >Thanx. Michael Christen >michael.christen@balcab.ch For closed form solutions based on the BS-model, its simply a matter of coding down a bunch of formulas. I don't see the need to a published Mathematica package for that. However, I happend to see an annoucement in the big 10:th aniversary conference a few moths ago about doing Stochastic calculus with Mathematica (symbolic). Is there anything useful out there? http://www.mathsource.com/cgi-bin/MathSource/Applications/EconomicsFinance/0209-270 Try this.............. Michael Christen wrote: Does anybody has a program for Mathematica with the BS-formula and > formulas for exotic options? > Thanx. > How can I create an 2D-graph with 2 curves having different x-ranges ? It is possible to plot the one x-axis at the bottom and the other x-axis at the top of the frame ? Thank you for your help. === > resoudre l inequatin > (3-2x/x-1) <= (6-5x/x+2) > merci pour vos solution > nicolas d aout In[1]:= < Fourier[] implements a numerical fast fourier transform. That means that > the data passed to Fourier[] are the function values f(t) on the > interval t in [0,2Pi) with constant increment. The data are assumed to > be periodic in t with period 2Pi. My understanding was that Fourier implemented a Discrete Fourier Transform as a general case, and a Fast Fourier Transform if your data length an integer power of 2. -- ================================================================== David Annetts _____________ http://www.ocs.mq.edu.au/~dannetts/ |C R C A M E T| |-------------| oss what seems like it should be a simple little function, but could not come up with a clever way to implement it. Generally, what I am trying to do is take a list of lists of length 2 ie a list of x,y coordinates, and Select x values based on some criterion for y. For example I want to select the first x value for which the corresponding y is greater than 5. I can write a function using Position and Take etc. , but there must be a clever,and more efficient way to do this. Any thoughts... Jason - Is there any reson that you can't use directly a build-in function Select as in the following example? In[1]:= lst = Table[{Random[], Random[]}, {10}] Out[1]= {{0.87642,0.859277},{0.990313,0.434662},{0.631448,0.153609},{0.515145, 0.424282},{0.00339491,0.575325},{0.562473,0.690501},{0.817277,0.713543},{ 0.709017,0.351955},{0.937637,0.0728005},{0.553451,0.791334}} In[1]:= Select[lst, #[[2]] < .5 &] Out[1]= {{0.990313,0.434662},{0.631448,0.153609},{0.515145,0.424282},{0.709017, 0.351955},{0.937637,0.0728005}} > I came across what seems like it should be a simple little function, but > could not come up with a clever way to implement it. Generally, what I > am trying to do is take a list of lists of length 2 ie a list of x,y > coordinates, and Select x values based on some criterion for y. For > example I want to select the first x value for which the corresponding > y is greater than 5. > I can write a function using Position and Take etc. , but there must be > a clever,and more efficient way to do this. Any thoughts... Jason -- Wolfram Research has expanded its popular educational grant program, which encourages universities to explore the use of Mathematica as a teaching tool in their research, in their classrooms, and through the web. Each year, Wolfram Research awards a limited number of grants to select academic institutions and educators. The Wolfram Research Grant Programs now includes the following programs. -The Acedemic Institution Grant Program is awarded to aid institutions committed to innovative Mathematica-based programs -The Engineering Educator's Grant Program specifically designed for undergraduate engineering educators in four-year colleges and universities -Special Project Grants available to support individuals or small groups performing specific Mathematica-based projects in research and education Does anyone have code for numerical solutions of delay differential equations? How can I create an 2D-graph with 2 curves having different x-ranges ? It is possible to plot the one x-axis at the bottom and the other x-axis at the top of the frame ? Thank you for your help. As you indicated, the problem occurs because numerical values are used in attempting to evaluate the ratio. However, Log[2]/Log[4] // Simplify Log[2]/Log[4] %//FullSimplify 1/2 Consequently, Round[Log[2]/Log[4]//FullSimplify] 0 : >>** this is not a bug report *** >> Windows 3.0.0.0. >[That Mathematica didn't have enough precision to compute Round[Log[2]/Log[4]] Hmmm. Interesting. Since Log[2]/Log[4] = 1/2, Mathematica can't decide >whether to round up or down--it SHOULD apply round-to-even, to give >zero, but it's trying to do this with just numerical values. As I recall, deciding when A == B is a profoundly difficult problem. >I'm not sure how else one could go about this. (Oh, sure, the >immediate problem could be fixed by applying a special rule for >logarithms, but what about special functions for which the relations >are still undiscovered?) I have two versions of Mathematica running for Linux; version 3.0.1 handles the integral as it should while 3.0.2 fails to simplify the expression. Is there a way to make new datatypes in Mathematica? I have some routines for reading various sorts of data from files, along with some information about the data, like label to use for plot, axis labels, etc. And I would like to be able to treat all this like a single object. I supose I could just use a list, and have the first element be the data itself, the second element as the label, etc. and then have functions like setLabel/getLabel but this dosn't seem very elegant. Any ideas? I use the list method you describe. For example: newDataType = { {labelString, dateString}, {xlist, ylist, zlist} } Since Mathematica allows list structures to appear on the left side, I process items from a such a structure passed to a function by using { {label, date}, {xlist, ylist, zlist}} = argument Where label, date, xlist, ylist, zlist are variables private to the module defining the function. Dave Morten N. Aasnes wrote in message <6tbum2$mru@smc.vnet.net>... >Is there a way to make new datatypes in Mathematica? I have some >routines for reading various sorts of data from files, along with some >information about the data, like label to use for plot, axis labels, >etc. And I would like to be able to treat all this like a single >object. I supose I could just use a list, and have the first element be >the data itself, the second element as the label, etc. and then have >functions like setLabel/getLabel but this dosn't seem very elegant. Any >ideas? > In article <6t2l44$47o@smc.vnet.net>, Ronald Bruck wrote: >In article <6ssvo6$m9r@smc.vnet.net>, >Wouter Meeussen wrote: >>** this is not a bug report *** >> Windows 3.0.0.0. >[That Mathematica didn't have enough precision to compute Round[Log[2]/Log[4]] Hmmm. Interesting. Since Log[2]/Log[4] = 1/2, Mathematica can't decide >whether to round up or down--it SHOULD apply round-to-even, to give >zero, but it's trying to do this with just numerical values. As I recall, deciding when A == B is a profoundly difficult problem. >I'm not sure how else one could go about this. (Oh, sure, the >immediate problem could be fixed by applying a special rule for >logarithms, but what about special functions for which the relations >are still undiscovered?) I've had an interesting e-mail discussion with... Hmmm, I suppose the ethics of the internet prohibit me from saying whom :-( To summarize: The error message is generated by Round[Log[2]/Log[4]], not the //N part. This is because Mathematica attempts to apply purely-numeric comparisons, which can't work of course; after it's tried 66 decimal digits of precision, it punts (returning the correct answer, but how much confidence can you put in that?). This is because Mathematica doesn't attempt to simplify the Log[2]/Log[4] term. In general, it's NOT safe to replace Log[z^2] by 2 Log[z], because this is NOT TRUE (branch problems) in the complex plane. But surely Mathematica knows that Log[a b] = Log[a] + Log[b] for POSITIVE reals a, b. And it does; FullSimplify does the job: Round[Log[2]/Log[4]//FullSimplify] returns 0. You have to put the FullSimplify INSIDE the Round, of course, otherwise you get the error message. It's interesting that FullSimplify of Log[z^2] returns Log[z^2], of Log[z^2]/Log[z] returns Log[z^2]/Log[z], and of Log[4]/Log[2] returns 2. This seems to me a reasonable compromise between generality and specificity. Simplify computations which involve Numbers; don't simplify those which involve general variables. But why couldn't this be incorporated into Simplify? Does anyone know of a good reference (book, tutorial, code package) for the best way to handle the conversion of graphics options to an equivalent set of primitives. Eg. I want to write a function which makes Line[] primitives and does Show[Graphics[{...}],...] but can handle options in the way that ParametricPlot(3D) does (so PlotStyle, PlotRange do what you would expect them to, etc.). I am running Optica(Version for Mathematica 2.3) with Mathematica 3.0 on NT 4.0. I have programmed the following optical system, and the ray stops at the last surface without any reason. System={Resonate[{IntrinsicSurface[{70,70},Air,BK7],Table[{ Move3D[ IntrinsicSurface[{10,70},BK7,Water],{7,Sqrt[2]*(-2.5+t*1 0),0},{ 1,1,0},0], Move3D[ IntrinsicSurface[{10,70},BK7,Water],{7,Sqrt[2]*(2.5+t*10 ),0},{ 1,-1,0},0]},{t,-2,2}], Move3D[IntrinsicSurface[{70,70},Water,BK7],{14,0,0},{1,0,0},0], Move3D[IntrinsicSurface[{70,70},BK7,Air],{15,0,0},{1,0,0},0]}, Mtrip], Boundary[{-10,-70,-70},{50,70,70}]}; Test=DrawSystem[{Move3D[Ray[],{-1,-5,0},{Cos[71 Degree],Sin[71 Degree],0},0], System},PlotType->TopView,QuickTrace->False] The ray is traced at the end, if the last medium is not Air but Water again. Any suggestions what are the reason for this? Thanks Steffen we are installing LiveWire Pro and kept getting the following error during the Oracle7 installation. error during action 'creating ntcontab.o' I'm a chemist working on my PhD thesis about kinetics and NMR spectroscopy. A typical problem (i don't know how to deal with) is to fit experimental data to the (numerical) solutions of a system of coupled differential equations. I want to use mathematica (the function NDSolve), but i don't know if it is possible to optimize the parameters with the help of a least-squares fit: start with typical parameters --> NDSolve --> determination of the errors ---> varying the parameters --> NDSolve ---> least-squares optimization ---> ... I am trying to fit gaussians to data using the FindMinimum function. The problem is that in some case, the error function that I try to minimize as a function of the mean and standart deviation of the normal distribution keeps going down with m and s increasing. The error only becomes marginally smaller, but FindMinimum keeps trying larger and larger values. How can I tell it that if the error only changes in steps smaller than 0.001, it shouldn't bother going on? I know there are two paramaters AccuracyGoal and PrecisionGoal, but they are not explained in the book. Does anybody know more? According to the book section 1.8.4, t[[1]][[2]] is equivalent to t[[1,2]], but is clumsier to write and that is all that I can find concerning the difference between the two ways of refering to a list element. But... In[37]:= alist = {{1,2},{3,4}}; alist[[2,1]] = 7 ; alist Out[37]= {{1,2},{7,4}} So far so good, and yet... In[39]:= anotherlist = {{1,2},{3,4}}; anotherlist[[2]][[1]] = 7 Set::setps: !(anotherlist [LeftDoubleBracket] 2 [RightDoubleBracket]) in assignment of part is not a symbol. Out[39]= 7 What's the problem here? Is there a difference between the two ways of referencing list elements that the book neglects to mention? - http://www.ews.uiuc.edu/~tdelling I encountered a problem: After I solved a set of equations and got a list of solutions for the variables, I want to make use of only two or three of the solutions. But I tried and failed to get the number out of the whole expression which include an arrow. Say it's like this: out={{x->12, y->23, z->13}} I want to manipulate the operations like x+y or something else, but how can I succeed in realizing that? Thanks in advance > I am using the following function to read binary files. I would not >consider the data files very large, and yet the process is extremely >slow. I am running Mathematica 3.0 for win95. I have installed the >MathLink program FastReadBinary Files, which help a ton, but it is >still to slow. The net is I use this function on multiple files to >create a three dimensional data matrix with Dimensions on the order of >[6,1000,300]. Mathematica handles the data O.K., once loaded but the >loading takes to long. For the aforementioned matrix, loading the >files can take upwards of 15 minutes. Which seems excessie to me. > Using the timming function, the largest consumer of time is the actual >binary read. Does anyone have any suggestions? I also have access to >Mathematica (3.0) running on an RS/6000 is there a Mathlink equivalent >to Fast Read Binary available for this platform? Any suggestions would >be greatly appreciated. Options[ReadandConvertLMX]={SetDirPath->d:lmxdatajanussq}; > ReadandConvertLMX[filename_,opts___]:= >Module[{inline,setpath,convert6,waste, > }, >directory=SetDirPath /. {opts} /. Options[ReadandConvertLMX]; >SetDirectory[directory]; > inline = OpenReadBinary[filename]; > {modules,parameters,timestep,powerHour}= > ReadListBinary[inline,Int16,4, >ByteOrder->MostSignificantByteFirst]; >waste=ReadListBinary[inline,Byte,120]; >data=ReadListBinary[inline,Byte]; >data=Take[Partition[data,4],(modules*parameters)]; Close[inline]; >ResetDirectory[]; >convert6 = Compile[{b1, b2, b3, b4}, If[b1 < 128, > (b2*256^2+b3*256+b4)/256^3 16^(b1-64), > -(b2*256^2+b3*256+b4)/256^3 16^(b1-192)]]; ResetDirectory[]; >data=Transpose[Partition[Apply[convert6,data,2],parameters]]; >Dimensions[data]]; > Your timing seems a little excessive, but it's not clear to me exactly how many bytes you are reading. On my 180 MHz Pentium Pro, it takes FastBinaryFiles about 40 sec. to read 10^6 byte-sized numbers. This is almost entirely the MathLink transfer time--reading the file is very fast. You will be happy to know that there is a much, much faster way to read your data than using the FastBinaryFiles MathLink program. Just use the built-in ReadList function with the Byte type. I've rewritten your program using ReadList to get the main data. You still need to get a few numbers as Int16, so I just use the standard Utilities`BinaryFiles` package for this. That package has a flaw that causes it to be very slow, but that isn't an issue for the small header data that you need to read. Needs[Utilities`BinaryFiles`] ReadandConvertLMX[filename_, opts___] := Module[{inline, setpath, convert6, waste}, (* I took out the directory manipulation. I assume that was a workaround for a Windows-specific bug in FastBinaryFiles. OpenRead searches $Path, which is probably all you need. *) (* Using the (new in 3.0) DOSTextFormat->False option is critical. *) inline = OpenRead[filename, DOSTextFormat->False]; {modules,parameters,timestep,powerHour} = ReadListBinary[inline, Int16, 4, ByteOrder->MostSignificantByteFirst]; waste=ReadListBinary[inline, Byte, 120]; (* Use the built-in ReadList function to get the main data. Very fast. *) data=ReadList[inline,Byte]; Close[inline]; data=Take[Partition[data,4],(modules*parameters)]; convert6 = Compile[{b1, b2, b3, b4}, If[b1 < 128, (b2*256^2+b3*256+b4)/256^3 16^(b1-64), -(b2*256^2+b3*256+b4)/256^3 16^(b1-192)]]; data = Transpose[Partition[Apply[convert6, data, 2], parameters]]; Dimensions[data] ] If this can be done so easily and quickly without using FastBinaryFiles, then you might ask why FastBinaryFiles was written in the first place. Two reasons: 1) On Windows, Mathematica simply could not read binary files. It always opened files in text mode, and thus it always interpreted the bytes in a special way. In particular, it would read a CR-LF combination as a single byte, and it stopped at the first 0x1A byte it read, as this is the EOF indicator in a text file. 2) As mentioned above, the Utilities`BinaryFiles` package has a flaw that causes it to take astronomically long to read large files. Motivation 1 was made irrelevant in Mathematica 3.0, which provides the DOSTextFormat->False option in OpenRead. Motivation 2 is still valid. FastBinaryFiles is much faster than the Utilities`BinaryFiles` package. It should be used whenever you need the convenience of a high-level interface for reading multi-byte types (Int16, Double, etc.) For reading straight bytes from a file, though, just open the file with DOSTextFormat->False and use ReadList[Byte]. I have developed some packages for my classes, together with palettes and helpfiles explaining the functions. I would like the palette file to be listed under the Files -> Palettes menu and the helpfile permanently show in the Files -> Notebooks menu. I also want to load the packages , say DDS1.m, with just the command <Length[stack], Message[ ReplaceByStack::stack,Length[tmp],Length[stack] ] ]; (*Error message if replacements are incomplete*) (inrep[[ #[[1]] ]]= Replace[ (*make list of replacements and*) inrep[[ #[[1]] ]], (*do replace element by element*) #[[2]] ])&/@Table[ {tmp[[i]], crit->stack[[i]]}, {i,1,Min[Length[stack],Length[tmp]]} ]; inrep (*return the modified list*) ]; In[9]:= ReplaceByStack::stack= Stack given has Length `2`, replacements needed: `1`.n Only the first `2` hits were replaced.; In[1]:= L1 = {1,2,3,4,5,3,7,2,3,9} Out[1]= {1,2,3,4,5,3,7,2,3,9} In[2]:= L2 = {a, b, c} Out[2]= {a,b,c} In[7]:= ReplaceByStack[L1,3,L2] Out[7]= {1,2,a,4,5,b,7,2,c,9} In[8]:= ReplaceByStack[L1,3,{a,b}] ReplaceByStack::stack: Stack given has Length 2, replacements needed: 3. Only the first 2 hits were replaced. Out[8]= {1,2,a,4,5,b,7,2,3,9} Well – not really without a loop since I still need the Table[] command. However, the lists of elements to be replaced and the replacement stack somehow have to be aligned, coping with unequal length of the lists. So, I think, in this problem we won't find an efficient way doing without a loop. Cheers, Peter In article <6tbvmg$mv1@smc.vnet.net>, k.duellmann@uni-mannheim.deXXX says... > I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 > successively, > that is the first 3 by a, the second 3 by b and the third 3 by c. That > is I want to get the following modified L1-list: {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. Is > there a chance to avoid hideous Do-Loops? > --simple boundary Content-Type: text/plain; charset=US-ASCII Lets consider a function 'newfunction' which takes an expression as an argument. If I wish to work with the expression as a function inside newfunction, I have some options as to what syntax to use as illustrated below in the private functions g,g2,g3,g4. Note that I wish to shield the user of the function from pure function constructs like most built-in mathematica functions do. newfunction[f_,x_,x1_]:=Module[{g,g2,g3,g4}, g=(f/.x->#)&; g2[xx_]=Hold[f]/.x->xx; g3=Function[x,f]; g4[xx_]:=f/.x->xx; {g[x1],ReleaseHold[g2[x1]],g3[x1],g4[x1]}] Here is the expected behavior: All of the above forms are equivalent to each other and to the original function when evaluated numerically as illustrated below. It turns out that the syntaxes evaluate with different speeds, but they all arrive at the same place. In[2]:= newfunction[Sin[x]^3-x,x,2.5] Out[2]= {-2.28565,-2.28565,-2.28565,-2.28565} In[9]:= Sin[2.5]^3-2.5 Out[9]= -2.28565 I am currently working with a function which itself calls functions which use Solve and other things. For some reason, this complicated function does not behave as expected when given to newfunction as an argument. In[7]:= newfunction[DkKTPsfgII[63 Degree,0. Degree,1.064,x],x,1.32] Out[7]= {-0.0466874,-0.0466874,-0.0466874,-0.0466874} In[8]:= DkKTPsfgII[63 Degree,0. Degree,1.064,1.32] Out[8]= -0.00034538 Notice that here, the four syntaxes agree with each other, but they are all wrong in the sense that they don't evaluate to the same number the original function did. The really weird thing is that the syntaxes for g2 and g3 work correctly when not placed inside a Module construct. The syntaxes for g1 and g4 don't work correctly at all. I am attaching a notebook which contains the definition of the DkKTPsfgII function. I would appreciate any suggestions to: --alternate syntaxes for passing functions as arguments. --any insights as to why this particular function(DkKTPsfgII) is pathological to mathematica and how I might change it. --any workarounds. Please respond directly to me: rosss@plk.af.mil or ross@worldnet.att.net as I don't subscribe to the mathgroup any more. Also, please bear in mind that simple examples are irrelevant to this issue. All four syntaxes work for simple functions. They don't work for really complicated ones. I have a dozen more similarly pathological functions, but am not including them so as not to clutter up the issue. Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 7945, 172]*) (*NotebookOutlinePosition[ 8594, 195]*) (* CellTagsIndexPosition[ 8550, 191]*) (*WindowFrame->Normal*) Notebook[{ Cell[TextData[{ KTP is a biaxial crystal, so I first must work out the general form for the percieved index of refraction in a biaxial crystal. I start with Yariv, chapter 4. First, we solve the vector equation , Cell[BoxData[ (TraditionalForm `(k&[RightVector]) x (k&[RightVector]) x E&[RightVector] = (-[Omega]^2) ([Mu]_0) D&[RightVector])]], (1). It can be written as a sort of eigenvector problem and a quadratic solution for the effective index of refraction obtained. This is contained in the nextKTP function, which calls on the next function for the algebraic form of the determinant of (1) and on nxKTP etc for the indices along the principle axes. The solution of the determinant of (1) is quadratic in , Cell[BoxData[ (TraditionalForm`n^2)]], , so there are always two answers returned. These correspond to preferred orthogonal axes for the polarization direction. }], Text], Cell[CellGroupData[{ Cell[< index of refraction as a function of propagation direction in a biaxial crystal (KTP) >, Section], Cell[BoxData[ RowBox[{ RowBox[{ (Clear[kmatrix, nmatrix, nextKTP, nxKTP, nyKTP, nzKTP, abs, unitv]), ;, n, (abs[v : {__}] := Sqrt[v . v]), ;, n, (unitv[v : {__}] := v/abs[v]), ;, n, RowBox[{(kmatrix[[Theta]_, [Phi]_, [Lambda]_]), :=, RowBox[{(, TagBox[ RowBox[{ RowBox[{(, GridBox[{ { ((-n^2) ((Cos[[Theta]]^2 + Sin[[Theta]]^2 Sin[[Phi]]^2)) + n_x%2), (n^2 Cos[[Phi]] Sin[[Theta]]^2 Sin[[Phi]]), (n^2 Cos[[Theta]] Cos[[Phi]] Sin[[Theta]])}, {(n^2 Cos[[Phi]] Sin[[Theta]]^2 Sin[[Phi]]), ((-n^2) ((Cos[[Theta]]^2 + Cos[[Phi]]^2 Sin[[Theta]]^2)) + n_y%2), (n^2 Cos[[Theta]] Sin[[Theta]] Sin[[Phi]])}, {(n^2 Cos[[Theta]] Cos[[Phi]] Sin[[Theta]]), (n^2 Cos[[Theta]] Sin[[Theta]] Sin[[Phi]]), ((-n^2) Sin[[Theta]]^2 + n_z%2)} }], )}], /., ({n^2 -> nn, n^4 -> nn^2, n_x -> nxKTP[[Lambda]], n_y -> nyKTP[[Lambda]], n_z -> nzKTP[[Lambda]]})}], (MatrixForm[ #]&)], )}]}], ;, n, ( (*a symbolic determinant is needed here . If you take a numerical one, small cubic terms creep in for values of [Theta] and [Phi] near, but on on the principle axes and give bad (answers . )*) ), n, n, (kdeterminant[[Theta]_, [Phi]_, [Lambda]_] := ((n_x%2 n_y%2 n_z%2 + n^4 (( Cos[[Theta]]^2 Cos[[Phi]]^2 Sin[[Theta]]^2 n_x%2 + Cos[[Phi]]^4 Sin[[Theta]]^4 n_x%2 + Cos[[Phi]]^2 Sin[[Theta]]^4 Sin[[Phi]]^2 n_x%2 + Cos[[Theta]]^2 Sin[[Theta]]^2 Sin[[Phi]]^2 n_y%2 + Cos[[Phi]]^2 Sin[[Theta]]^4 Sin[[Phi]]^2 n_y%2 + Sin[[Theta]]^4 Sin[[Phi]]^4 n_y%2 + Cos[[Theta]]^4 n_z%2 + Cos[[Theta]]^2 Cos[[Phi]]^2 Sin[[Theta]]^2 n_z%2 + Cos[[Theta]]^2 Sin[[Theta]]^2 Sin[[Phi]]^2 n_z%2)) + n^2 (( (-Cos[[Phi]]^2) Sin[[Theta]]^2 n_x%2 n_y%2 - Sin[[Theta]]^2 Sin[[Phi]]^2 n_x%2 n_y%2 - Cos[[Theta]]^2 n_x%2 n_z%2 - Cos[[Phi]]^2 Sin[[Theta]]^2 n_x%2 n_z%2 - Cos[[Theta]]^2 n_y%2 n_z%2 - Sin[[Theta]]^2 Sin[[Phi]]^2 n_y%2 n_z%2))) ) /. {n^2 -> nn, n^4 -> nn^2, n_x -> nxKTP[[Lambda]], n_y -> nyKTP[[Lambda]], n_z -> nzKTP[[Lambda]]}), ;, n, n, (nmatrix[[Theta]_, [Phi]_, [Lambda]_, j_: 1] := Module[{mat}, mat = kmatrix[[Theta], [Phi], [Lambda]] /. nn -> (nextKTP[[Theta], [Phi], [Lambda]])[([j])]^2; n tChop[mat/Max[Chop[mat]]]]), ;, n, n, n, (nextKTP[[Theta]_, [Phi]_, [Lambda]_] := ttntt Sqrt[Flatten[ nn /. Solve[ kdeterminant[[Theta], [Phi], [Lambda]] == 0, {nn}]]]), ;, n, n, (nxKTP[[Lambda]_] := Module[{aa = 2.11460, bb = 0.89188, cc = 0.20861, dd = 0.01320}, Sqrt[aa + bb/(1 - ((cc/[Lambda]))^2) - dd [Lambda]^2]] ), ;, n, (nyKTP[[Lambda]_] := Module[{aa = 2.15180, bb = 0.87862, cc = 0.21801, dd = 0.01327}, Sqrt[aa + bb/(1 - ((cc/[Lambda]))^2) - dd [Lambda]^2]] ), ;, n, (nzKTP[[Lambda]_] := Module[{aa = 2.31360, bb = 1.00012, cc = 0.23831, dd = 0.01679}, Sqrt[aa + bb/(1 - ((cc/[Lambda]))^2) - dd [Lambda]^2]] ), ;}], n}]], Input] }, Open ]], Cell[BoxData[ (([CapitalDelta]kKTPsfgII[[Theta]_, [Phi]_, [Lambda]1_, [Lambda]2_] := Module[{[Lambda]sum}, [Lambda]sum = ((1/[Lambda]1 + 1/[Lambda]2))^(-1); (nextKTP[[Theta], [Phi], [Lambda]sum])[([1])]/[Lambda]sum - (nextKTP[[Theta], [Phi], [Lambda]1])[([2])]/[Lambda]1 - (nextKTP[[Theta], [Phi], [Lambda]2])[([1])]/[Lambda]2]; ))], Input] }, FrontEndVersion->Microsoft Windows 3.0, ScreenRectangle->{{0, 800}, {0, 572}}, WindowSize->{651, 434}, WindowMargins->{{Automatic, 46}, {Automatic, 5}} ] Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1709, 49, 980, 17, 128, Text], Cell[CellGroupData[{ Cell[2714, 70, 114, 3, 74, Section], Cell[2831, 75, 4641, 84, 890, Input] }, Open ]], Cell[7487, 162, 454, 8, 77, Input] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************) --simple boundary-- I want to create notebooks with a two column format just like the format used in the Mathematica book (comments on the left, input/output lines on the right). Does anyone know of a style sheet that supports this? None of the style sheets that come with 3.0 allow me to do this. Given a symbolic matrix of rank N, is there a way to avoid the excessive symbol growth which occurs while finding its symbolic inverse? The maximum rank would be N=100, M f = N d where M and N are symbolic matrices and f and d are vectors. The elements of M and N are nonlinear symbolic functions of nx, ny, and x. Would like f=LinearSolve[M,N d] solution or the symbolic inverse of M. data = Table[{Random[], 10 Random[]}, {1000}]; To select the first x for which the corresponding y is greater than five: Select[data, #[[2]]>5&][[1, 1]]//Timing {0.0666667 Second,0.190228} Cases[data, {x_, y_/;y>5}][[1, 1]]//Timing {0.0666667 Second,0.190228} Cases[data, {x_, y_/;y>5}->x][[1]]//Timing {0.0666667 Second,0.190228} Cases[data, {x_, y_}?(#[[2]]>5&)][[1, 1]]//Timing {0.0833333 Second,0.190228} Cases[data, {x_, y_}?(#[[2]]>5&)->x][[1]]//Timing {0.116667 Second,0.190228} firstCase[theList_List, gtr_?NumericQ] := Module[{selected}, selected = Cases[theList, {x_, y_/;y>gtr}]; If[Length[selected] > 0, selected[[1, 1]], {}]] firstCase[data, 5] 0.190228 In a message dated 9/11/98 6:47:45 PM, jgill@vbimail.champlain.edu wrote: >I came across what seems like it should be a simple little function, but >could not come up with a clever way to implement it. Generally, what I >am trying to do is take a list of lists of length 2 ie a list of x,y >coordinates, and Select x values based on some criterion for y. For >example I want to select the first x value for which the corresponding >y is greater than 5. >I can write a function using Position and Take etc. , but there must be >a clever,and more efficient way to do this. Any thoughts... Jason L1 = {1, 2, 3, 4, 5, 3, 7, 2, 3, 9}; L2 = {a, b, c}; n=0; L1 /. (x_/;x==3) :> (n++; L2[[n]]) {1,2,a,4,5,b,7,2,c,9} Bob Hanlon In a message dated 9/11/98 7:54:56 PM, k.duellmann@uni-mannheim.deXXX wrote: >I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 >successively, >that is the first 3 by a, the second 3 by b and the third 3 by c. That >is I want to get the following modified L1-list: {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. Is >there a chance to avoid hideous Do-Loops? Any hints are appreciated! Use the standard package Calculus`DiracDelta` Needs[Calculus`DiracDelta`]; h[x_]:=UnitStep[x] Plot[h[x], {x, -1, 3}]; f[x_]:=Integrate[h[t],{t,0,x}]; Plot[f[x], {x, -1, 3}]; g[x_]:=Integrate[f[t],{t,0,x}]; Plot[g[x], {x, -1, 3}]; m[x_]:=Integrate[g[t],{t,0,x}]; Plot[m[x], {x, -1, 3}]; p[x_]:=Integrate[m[t],{t,0,x}]; Plot[p[x], {x, -1, 3}]; Bob Hanlon In a message dated 9/11/98 6:35:40 PM, dclement@mail.cpod.fr wrote: >Why can't Mathematica integrate thrice a piecewise defined function? >Here is what I mean: This is a step function: >h[x_]:=If[x>0,1,0] >It can (of course) be plotted and integrated. Then let: >f[x_]:=Integrate[h[t],{t,0,x}] >f, as well as h, can be plotted and if I put >g[x_]:=Integrate[f[t],{t,0,x}] >then g can be plotted, but any integral (definite or not) that I attempt >to compute about g leads to an error message (though g can be >NIntegrated). I think you are being unfair to Mathematica here. You're running into the always bewildering notational inconsistencies of > Mathematica. Consider A = ={{a,b,c}} > B = {{d},{e},{f}} (note bracketing). Are these vectors? Well, they can be dotted, as in A . B and B . A > Actually, A and B here are matrices, not vectors, and the dot product corresponds to matrix multiplication. That is, A.B produces the 1 x 1 matrix (a d + b e + c f) and B.A produces the 3 x 3 matrix a d b d c d a e b e c e a f b f c f > and you'll get the right answer in each case. So, if they can be > dotted, they ought to be cross-able as well, right? So try Cross[A,B] > Cross[B,A] > Cross[A,A] > Cross[B,B] and find that _none_ of these work. Since A and B are matrices and not vectors, Cross doesn't work. > Now, page 115 of the Bible says > that Cross[a,b] can also be input as a * b, so try instead A * B > B * A > A * A > B * B and get three or four different answers; some of these work, some don't. Just don't expect consistency! > The Book says you can input Cross[a,b] as a [Cross] b, where [Cross] comes out looking like a small, bold x. You can't input Cross[a,b] with a*b, since * is simply ordinary multiplication. So, I don't think Mathematica is being obscure or inconsistent here. In[1]:= li=Table[{n^2,n},{n,10}]; In[2]:= Cases[li,x_?(#[[2]]>5&):>(x[[1]]),1,1] Out[2]= {36} Jurgen Jason Gill wrote: > I came across what seems like it should be a simple little function, but > could not come up with a clever way to implement it. Generally, what I > am trying to do is take a list of lists of length 2 ie a list of x,y > coordinates, and Select x values based on some criterion for y. For > example I want to select the first x value for which the corresponding > y is greater than 5. > I can write a function using Position and Take etc. , but there must be > a clever,and more efficient way to do this. Any thoughts... Jason there is a not too well documented option StoppingTest for NDSolve (try ?StoppingTest) which could be helpful. The only way I found to use it is like in the following example: NDSolve[{y'[t]==-y[t],y[0]==1},y,{t,0,5},StoppingTest->(y[t]<0.5)] This will stop integration at t==0.71712 and of course the InterpolatingFunction shows this as the upper limit of it's interval. > Is it possible to get NDSOLVE to exit before the independent variable > reaches its range? I would like to exit the numerical integration routine > based on monitored conditions in the simulation. I would also like to > know > the value of some of my variables at exit. For example, I am modeling the vertical motion of a water rocket and would > like to stop the simulation when the water is dispelled from the rocket, > not > necessarily at some particular value of the independent variable (time). how do you like this one? In[1]:= l1 = {1,2,3,4,5,3,7,2,3,9}; In[2]:= l2 = {a, b, c}; In[3]:= n=1; In[4]:= l1/.{3:>l2[[n++]]} Out[4]= {1,2,a,4,5,b,7,2,c,9} Jurgen Klaus Duellmann wrote: > I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 > successively, > that is the first 3 by a, the second 3 by b and the third 3 by c. That > is I want to get the following modified L1-list: {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. Is > there a chance to avoid hideous Do-Loops? > > I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 > successively, that is the first 3 by a, the second 3 by b and the > third 3 by c. That is I want to get the following modified L1-list: > {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. > Is there a chance to avoid hideous Do-Loops? How about: In[1]:= CyclicReplace[L_List, x_, R_List]:= Block[{n = Length[R], pointer = Length[R]}, L /. (x :> Q[[(pointer = 1 + Mod[pointer, n])]])] In[2]:= stuff = {1, 3, 2, 4, 5, 3, 6, 3, 7, 8, 9, 3} Out[2]= {1, 3, 2, 4, 5, 3, 6, 3, 7, 8, 9, 3} In[3]:= Q = {a, b, c} Out[3]= {a, b, c} In[4]:= CyclicReplace[stuff, 3 ,Q] Out[4]= {1, a, 2, 4, 5, b, 6, c, 7, 8, 9, a} >am trying to do is take a list of lists of length 2 ie a list of x,y >coordinates, and Select x values based on some criterion for y. For >example I want to select the first x value for which the corresponding >y is greater than 5. >... Use Select or Cases. In general, there are two ways to extract elements from the list. One is based on their position, the other on properties of elements. The former is done with Take or Part, which is useful when you know the positions of elements you want. For the latter, there's Select and Cases. In Select, the selection is based on a user defined True/False function (a predicate). Cases is more general. It uses pattern matching as criterion, and user can also specify the level to extract at, and applying a transformation on elements of matched result. Note that a pattern matching and predicate are interchangable as follows: Suppose predicateQ is your predicate function, and suppose patternQ is your pattern. To turn a predicate into a pattern, use (_?predicateQ) To turn a pattern into a predicate, use Function[MatchQ[#,patternQ]] -- In your example, perhaps one of the following is useful: (Last@#>5&) or {x_, _?(#>5&)}->x. Xah, xah@best.com http://www.best.com/~xah/Wallpaper_dir/c0_WallPaper.html Perl: all unix's stupidity in one. : >According to the book section 1.8.4, t[[1]][[2]] is equivalent to t[[1,2]], but is clumsier to write >... But... The answer can be found by looking at FullForm, In[17]:= FullForm[Hold[li[[1]][[2]]]] Out[17]//FullForm= Hold[Part[Part[li,1],2]] In[18]:= FullForm[Hold[li[[1,2]]]] Out[18]//FullForm= Hold[Part[li,1,2]] Both forms acts equivalently when you use them to extract an element, but for assignment, Part[Part[li,1],2]=x is not the same as Part[li,1,2]=x. patterns with conditions are nice constructs : it={{a,1},{b,3},{c,4},{d,9},{e,7}} Cases[it,{_,x_?PrimeQ}] First/@Cases[it,{_,x_?PrimeQ}] {{b,3},{e,7}} {b,e} if your criteria for selection do not involve a standard yes-or-no returning test, then make your own: Cases[it, {_,_?myowntestQ}] or explicitely with a /;condition structure : Cases[it,{_,x_}/;(IntegerQ[Sqrt[x]])] First/@Cases[it,{_,x_}/;(IntegerQ[Sqrt[x]])] {{a,1},{c,4},{d,9}} {a,c,d} >I came across what seems like it should be a simple little function, but >could not come up with a clever way to implement it. Generally, what I >am trying to do is take a list of lists of length 2 ie a list of x,y >coordinates, and Select x values based on some criterion for y. For >example I want to select the first x value for which the corresponding >y is greater than 5. >I can write a function using Position and Take etc. , but there must be >a clever,and more efficient way to do this. Any thoughts... Jason According to the book section 1.8.4, t[[1]][[2]] is equivalent to t[[1,2]], but is clumsier to write and that is all that I can find concerning the difference between the > two ways of refering to a list element. But... In[37]:= > alist = {{1,2},{3,4}}; alist[[2,1]] = 7 ; alist Out[37]= > {{1,2},{7,4}} So far so good, and yet... In[39]:= > anotherlist = {{1,2},{3,4}}; anotherlist[[2]][[1]] = 7 > Set::setps: > !(anotherlist [LeftDoubleBracket] 2 [RightDoubleBracket]) in assignment of part is not a symbol. > Out[39]= > 7 What's the problem here? Is there a difference between the two ways of > referencing list elements that the book neglects to mention? t[[1]][[2]] is equivalent to t[[1,2]] for extraction of parts, as indicated by your example. But for part resetting, as in your second example, it in not equivalent. The catch is that part resetting like a[[3]] = 7 works only when 1) a is a symbol that has been assigned an expression expr with a = expr (a:= expr will not do) 2) expr has a part 3 During evaluation, anotherlist[[2]][[1]] = 7 (that is (anotherlist[[2]])[[1]] = 7 ) becomes {3,4} [[1]] = 7 which does not meet requirment 1). I came across what seems like it should be a simple little function, but > could not come up with a clever way to implement it. Generally, what I > am trying to do is take a list of lists of length 2 ie a list of x,y > coordinates, and Select x values based on some criterion for y. For > example I want to select the first x value for which the corresponding > y is greater than 5. > I can write a function using Position and Take etc. , but there must be > a clever,and more efficient way to do this. Any thoughts... Jason Jason: data= {{1,2},{2,6},{3,6}}; Cases[data,{x_,y_}/;y>5->x, {1},1] >Does anyone know of a good reference (book, tutorial, code package) for >the best way to handle the conversion of graphics options to an >equivalent set of primitives. Not sure what you mean. Perhaps FullGraphics is what you need? In[43]:= ?FullGraphics FullGraphics[g] takes a graphics object, and generates a new one in which objects specified by graphics options are given as explicit lists of graphics primitives. >Eg. I want to write a function which makes Line[] primitives and does >Show[Graphics[{...}],...] but can handle options in the way that >ParametricPlot(3D) does (so PlotStyle, PlotRange do what you would >expect them to, etc.). PlotStyle you'll have to program yourself, by pairing the styles with each Line. PlotRange is an option to Graphics too. There are few options in ParametricPlot but not in Graphics... but I'm not sure what you want to do. Xah, xah@best.com http://www.best.com/~xah/MathGraphicsGallery_dir/mathGraphicsGallery.html I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 > successively, > that is the first 3 by a, the second 3 by b and the third 3 by c. That > is I want to get the following modified L1-list: {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. Is > there a chance to avoid hideous Do-Loops? L1 = {1,2,3,4,5,3,7,2,3,9} ; L2 = {a, b, c}; L1[[Flatten[Position[L1,3]]]]= L2; L1 {1,2,a,4,5,b,7,2,c,9} -- http://www.haystack.demon.co.uk Unfortunately, IntrinsicSurface does not work very well and is not going to be useful for your problem. Instead, you can use LensSurface as shown below: System={ Resonate[{ LensSurface[{70,70},ComponentMedium->{Air,BK7}], Table[{ Move3D[ LensSurface[{10,70},ComponentMedium->{BK7,Water}], {7,Sqrt[2]*(-2.5+t*10),0},{1,1,0},0], Move3D[ LensSurface[{10,70},ComponentMedium->{BK7,Water}], {7,Sqrt[2]*(2.5+t*10),0},{1,-1,0},0]}, {t,-2,2}], Move3D[LensSurface[{70,70},ComponentMedium->{Water,BK7}], {14,0,0},{1,0,0},0], Move3D[LensSurface[{70,70},ComponentMedium->{BK7,Air}], {15,0,0},{1,0,0},0]},Mtrip], Boundary[{-10,-70,-70},{50,70,70}]}; For future questions about Optica, you can write to optica-support@wolfram.com I am running Optica(Version for Mathematica 2.3) with Mathematica 3.0 >on NT 4.0. I have programmed the following optical system, and the ray stops at >the last surface without any reason. System={Resonate[{IntrinsicSurface[{70,70},Air,BK7],Table[{ > Move3D[ > IntrinsicSurface[{10,70},BK7,Water],{7,Sqrt[2]*(-2.5+t*1 > 0),0},{ > 1,1,0},0], > Move3D[ > IntrinsicSurface[{10,70},BK7,Water],{7,Sqrt[2]*(2.5+t*10 > ),0},{ > 1,-1,0},0]},{t,-2,2}], > Move3D[IntrinsicSurface[{70,70},Water,BK7],{14,0,0},{1,0,0},0], > Move3D[IntrinsicSurface[{70,70},BK7,Air],{15,0,0},{1,0,0},0]}, > Mtrip], > Boundary[{-10,-70,-70},{50,70,70}]}; Test=DrawSystem[{Move3D[Ray[],{-1,-5,0},{Cos[71 Degree],Sin[71 >Degree],0},0], > System},PlotType->TopView,QuickTrace->False] The ray is traced at the end, if the last medium is not Air but Water >again. Any suggestions what are the reason for this? > try L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} Fold[ReplacePart[#1,#2,First@Position[#1,3]] & ,L1, L2] >I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 >successively, >that is the first 3 by a, the second 3 by b and the third 3 by c. That >is I want to get the following modified L1-list: {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. Is >there a chance to avoid hideous Do-Loops? > any idea of how to align frame labels in Mathematica 3.0.1? By default, labels are centered below/next to the axes/frames. I'd like to have them aligned left/right hand, e.g. starting in the lower left corner rather than being centered. Any ideas? TIA, In article <6ssvep$m98@smc.vnet.net>, gehinjc@gnvpc.cped.ornl.gov (Jess C. Gehin) wrote: > Does mathematica have anything similar to a diary command? This > command, used from text mode, will log all of your input to a file so > that you can re-execute the commands later. Take a look at the package SessionLog.m.n Contained in the AddOns/ExtraPackages/ProgrammingInMathematica directory of the standard Mathematica 3 distribution. This might do what you want. Here are the usage messages from that package: OpenLog::usage = OpenLog[filename, opts..] starts logging all input and output to filename. CloseLog::usage = CloseLog[] closes the logfile opened by OpenLog[]. The package is described in detail in Maeder's Book, Programming in Mathematica My original response was unnecessarily complex. This simpler form also works: n=0; L1 /. 3 :> (n++; L2[[n]]) _______________ L1 = {1, 2, 3, 4, 5, 3, 7, 2, 3, 9}; L2 = {a, b, c}; n=0; L1 /. (x_/;x==3) :> (n++; L2[[n]]) {1,2,a,4,5,b,7,2,c,9} In a message dated 9/11/98 7:54:56 PM, k.duellmann@uni-mannheim.deXXX wrote: >I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 >successively, >that is the first 3 by a, the second 3 by b and the third 3 by c. That >is I want to get the following modified L1-list: {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. Is >there a chance to avoid hideous Do-Loops? > The following function handles the case when there are more instances in the target list of the target value to be replaced than there are elements in the replacement list (withList). It will cycle through the replacement list as often as necessary to replace all instances of the target value. substitute[targetList_List, withList_List, targetValue_] := Module[{n, replacements}, replacements = Nest[Prepend[#, withList]&, withList, Ceiling[Count[targetList, targetValue]/ Length[withList]]-1]//Flatten; n=0; targetList /. targetValue :> (n++; replacements[[n]])] L1 = {1, 2, 3, 4, 5, 3, 7, 2, 3, 9}; L2 = {a, b, c}; substitute[L1, L2, 3] {1,2,a,4,5,b,7,2,c,9} L1 = {1, 2, 3, 4, 5, 3, 7, 2, 3, 9, 3, 10, 3}; substitute[L1, L2, 3] {1,2,a,4,5,b,7,2,c,9,a,10,b} L1 = Table[5, {15}]; L2 = {a, b, c, d}; L3 = substitute[L1, L2, 5] substitute[L3, {1, 5, 9, 13}, a] {a,b,c,d,a,b,c,d,a,b,c,d,a,b,c} {1,b,c,d,5,b,c,d,9,b,c,d,13,b,c} ______________ My original response was unnecessarily complex. This simpler form also works: n=0; L1 /. 3 :> (n++; L2[[n]]) _______________ L1 = {1, 2, 3, 4, 5, 3, 7, 2, 3, 9}; L2 = {a, b, c}; n=0; L1 /. (x_/;x==3) :> (n++; L2[[n]]) {1,2,a,4,5,b,7,2,c,9} >I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 >successively, >that is the first 3 by a, the second 3 by b and the third 3 by c. That >is I want to get the following modified L1-list: {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. Is >there a chance to avoid hideous Do-Loops? try L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} Fold[ReplacePart[#1,#2,First@Position[#1,3]] & ,L1, L2] >I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 >successively, >that is the first 3 by a, the second 3 by b and the third 3 by c. That >is I want to get the following modified L1-list: {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. Is >there a chance to avoid hideous Do-Loops? >> I'm a chemist working on my PhD thesis about kinetics and NMR > spectroscopy. > A typical problem (i don't know how to deal with) is to fit experimental > data to the > (numerical) solutions of a system of coupled differential equations. I > want to use > mathematica (the function NDSolve), but i don't know if it is possible > to > optimize the parameters with the help of a least-squares fit: start with > typical parameters --> NDSolve --> determination of the errors > ---> varying the parameters --> NDSolve ---> least-squares optimization > ---> ... > Maybe a book or a typical example would help me ... Thank you very much! > Patrick Huebler, Bonn, Germany > patrick@rs1.thch.uni-bonn.de See How can I fit data to a model that is defined using NDSolve? in the Wolfram Research web site: http://www.wolfram.com/support/Math/Statistics/NDSolveFit.html You are also 'lucky' : I checked if N[Log[n]/Log[n^2]] ever produces a floating point number 'sufficiently far from 1/2' to cause the round to even rule to fail: In[ ]:=Table[Round[N [n+Log[2,n ]/Log[2,n^2]]],{n,2,4000}]~Cases~(_?OddQ) Out[ ]={} so it holds for the first 4000 integers. The bets are open for the lowest n where this fails. At 15:06 11-09-98 -0400, George E. Hrabovsky wrote: >When I do Log[2]/Log[4]//N I get 0.5, when I do Log[2]/Log[4]//N//Round >I get 0. > [That Mathematica didn't have enough precision to compute Round[Log[2]/Log[4]] >> >> Hmmm. Interesting. Since Log[2]/Log[4] = 1/2, Mathematica can't decide >> whether to round up or down--it SHOULD apply round-to-even, to give >> zero, but it's trying to do this with just numerical values. >> >> As I recall, deciding when A == B is a profoundly difficult problem. >> I'm not sure how else one could go about this. (Oh, sure, the >> immediate problem could be fixed by applying a special rule for >> logarithms, but what about special functions for which the relations >> are still undiscovered?) >> * > * I want to do symbolic calculation with vectors, in particular, I want > to * do a vector product. But if I declare: * > * A = (a b c) > * > * and do > * > * A x A > * > * (which should give zero), but instead I get: * > * Cross::nonn1: Not all of the arguments are vectors * of > required length You're running into the always bewildering notational inconsistencies of > Mathematica. Consider A = ={{a,b,c}} > B = {{d},{e},{f}} (note bracketing). Are these vectors? Well, they can be dotted, as in A . B and B . A and you'll get the right answer in each case. So, if they can be > dotted, they ought to be cross-able as well, right? So try Cross[A,B] > Cross[B,A] > Cross[A,A] > Cross[B,B] and find that _none_ of these work. Now, page 115 of the Bible says > that Cross[a,b] can also be input as a * b, so try instead A * B > B * A > A * A > B * B and get three or four different answers; some of these work, some don't. Just don't expect consistency! Huh? I don't get it. Where is the inconsistency? A={{a,b,c}} and B={{d},{e},{f}} are matrices. They are not vectors. A.B and B.A compute matrix dot products. Cross product is a vector operation. Cross is not intended for use with matrices, so Cross[A,B], etc., will not work. And no, the book does not say you can use a * b for Cross[a, b]. It says you can use the typeset [Cross] character (similar to a x b). This all looks fine to me. How else could it be designed? * Actually, A and B here are matrices, not vectors, and the dot product * corresponds to matrix multiplication. That is, A.B produces the 1 x 1 * matrix * * (a d + b e + c f) * * and B.A produces the 3 x 3 matrix * * a d b d c d * a e b e c e * a f b f c f I take your point. But I also believe that many people would say that A and B here are row and column VECTORS, and that the row/column vector is widely used and useful in many fields of analysis. FindRoot[Exp[x] == x^2, {x, -0.5}] {x --> -0.703467} How do I assign the result [-0.7033467] to a variable? > I am looking for an efficient solution of the following problem: Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} I want to replace all numbers 3 in L1 by the elements of L2 > successively, that is the first 3 by a, the second 3 by b and the > third 3 by c. That is I want to get the following modified L1-list: > {1,2,a,4,5,b,7,2,c,9}. Replace[] unfortunately replaces elements with a single element only. > Is there a chance to avoid hideous Do-Loops? My original reply contained a typo. Here is a corrected version. (The 'Q on the third line of In[1] should have been an 'R'. In[1]:= CyclicReplace[L_List, x_, R_List]:= Block[{n = Length[R], pointer = Length[R]}, L /. (x :> R[[(pointer = 1 + Mod[pointer, n])]])] In[2]:= stuff = {1, 3, 2, 4, 5, 3, 6, 3, 7, 8, 9, 3} Out[2]= {1, 3, 2, 4, 5, 3, 6, 3, 7, 8, 9, 3} In[3]:= Q = {a, b, c} Out[3]= {a, b, c} In[4]:= CyclicReplace[stuff, 3 , Q] Out[4]= {1, a, 2, 4, 5, b, 6, c, 7, 8, 9, a} Dear Group, any idea how to access tick labels (FrameTicks and Ticks) in graphics to be able to manipulate the respective text object to be rotated? TIA, Peter Recall the recent discussion on Round[Log[2]/Log[4]]. The line below produces a message, and no progress on the problem. In[1]:= Round[Log[2]/Log[4]] $MaxEtraPrecision::meprec: In increasing internal precision while attempting to evaluate Round[Log[2]/Log[4]], the limit $MaxExtraPrecision=49.99 was reached. Increasing the value of $MaxExtraPrecision may help resolve the uncertainty. Out[1]= Round[Log[2]/Log[4]] As others pointed out, we need to use FullSimplify inside of Round to get the desired result. It would be nice if the kernel could figure out when FullSimplify might help and use it, but only in cases where the normal algorithm fails. My definition below for Round does the trick. In[2]:= $UseFullSimplify=True; Unprotect[Round]; Round[expr_]/;$UseFullSimplify:= Block[{$UseFullSimplify,$Messages={}}, Check[ Round[expr], Round[FullSimplify[expr]], $MaxExtraPrecision::meprec ] ]; Protect[Round]; In[3]:= Round[Log[2]/Log[4]] Out[3]= 0 We get the right answer, and FullSimplify is only used when it's needed! The same improvement can be made for Floor, Ceiling and possibly others. Hi, I just got emails discussing how to assign a solution to a variable. However, the same approach doesn't work for the following similar question, in which the solution is a vector. FindRoot[{x+y==10,x==y},{x,3},{y,3}] {{x->5,y->5}} {x,y}={x,y}/.% > Hi, I just got emails discussing how to assign a solution to a variable. > However, the same approach doesn't work for the following similar > question, in which the solution is a vector. FindRoot[{x+y==10,x==y},{x,3},{y,3}] {{x->5,y->5}} > {x,y}={x,y}/.% Thanks. Shih-ying Wu but if you write, FindRoot[{x+y == 10, x == y}, {x, 3}, {y, 3}] u = {x, y} /. % you'll get u = {5, 5}. The following problem arises with Mathematica 2.2 for X-Windows, with Mathematica 2.2.3 for MS-Windows 3.x and for Mathematica 3.0.1 on Windows-NT. Perhaps, it is present in all versions on all platforms. ListContourPlot has an option Contours to select which contours shall be drawn. Using Contours->{z1,z2,...} I experienced cases, where one or more contour lines were not drawn, although they should show up. (In the examples which I have investigated, they were missing around a local maximum totally within the rectangle to be displayed and totally surrounded by a lower contour line.) The funny thing is, that by leaving out one row of data points, sometimes the missing contour line is drawn! - See the example below. A similar question (in essence) was rised on June 26, 1997 in this group, but there was only a single Re telling, that one has observed similar things without being able to always reproduce it. The problem itself was not solved, I think it was not really brought to the point. 1.) Can anybody enlighten us with the internals of ListContourPlot? 2.) Does anybody know, how ListContourPlot searches starting points for the contours to be displayed? 3.) Does the used searching algorithm guarantee, if there are neighbouring data points on the grid zLow, zHigh such that zLow..., that a contour line for zContour is found and displayed between the neighbouring points? The basic problem seems to be, to find *all* places f(z)=zContour for a sufficiently continuous function f interpolating the data points. This problem is non-trivial for the one dimensional case (but not, if f is piecewise linear or quadratic). As the contour lines belong to some interpolating function (maybe defined through the smoothed contour lines), at least all contour lines for the conditions mentioned above should be found! 4.) If the search starts with an initial set of starting points less than the given data points: how can I increase the size of this set? There is no option PlotPoints in ListContourPlot (it would not be necessary. I also find no option to influence the kind of interpolation used for display other than smoothing). 5.) Would it be possible to Unprotect[...] and redefine the relavant subfunction of ListContourPlot to exchange the current search algorithm used in ListContourPlot by a better one? 6.) has anybody out there a better ListContourPlot than the built-in one? The problem probably also explains, why LabelContourLines in TWJ-Packs sometimes puts the wrong numbers at some lines. I have not yet gone into this in full depth. Here is a practical example which arose in my work: list1=Get[list1,StandardForm]; list2=Table[list1[[i]],{i,1,14}]; (* watch at line 6: all requested contour lines are shown....*) ListContourPlot[list2,Contours->{7.0,7.50,7.75}]; ListPlot[list2[[6]]]; (* But now: just add one line of data points far away at the top... *) list3=Table[list1[[i]],{i,1,15}]; (* the 7.75-contour line is not shown, although it should be there between the 12/13 and between the 16/17-th data point!... *) ListContourPlot[list3,Contours->{7.0,7.50,7.75}]; ListPlot[list3[[6]]]; The example data list1 are given at the very end. =-=-=-=-=-=-=-=-=-=-=- list1 following: -=-=-=-=-=-=-=-=-=-=-=-=-= {{6.869325565627659, 6.857446808180289, 6.84698416452472, 6.839044013465366, 6.835444160898676, 6.838852388710257, 6.852798575241432, 6.881354743109187, 6.928181744098699, 6.994654797396585, 7.077146868619937, 7.164544473802138, 7.238444442863809, 7.278535528488228, 7.272100230498775, 7.221257763984616, 7.141698944189755, 7.054062482428515, 6.975094170415043, 6.91376501445003, 6.872082501928315, 6.847822555552206, 6.837072928864801, 6.835845134205293, 6.84082633954687, 6.849584653564301, 6.860507483131376}, {6.848606869351836, 6.836551106963296, 6.825441561115646, 6.81655680454321, 6.812107405905901, 6.815557261599827, 6.831867741924336, 6.867380720881377, 6.928812585981121, 7.020628967212311, 7.140350166026214, 7.272971668894657, 7.389106082182595, 7.453451034240708, 7.44306440734425, 7.361798660875765, 7.237781854259043, 7.106273940942552, 6.99313245770147, 6.909565462216552, 6.855642082697267, 6.825922021553251, 6.813612440639452, 6.812690027396614, 6.81860345055071, 6.828253510252547, 6.839709016532673}, {6.831166586023586, 6.818804796218802, 6.806822202431263, 6.796557051130921, 6.79049499812875, 6.792824072057539, 6.810035433817112, 6.851240397180393, 6.927419588773187, 7.048185363285409, 7.214412318770605, 7.407213724886268, 7.581210478835789, 7.678514008785894, 7.662812830312304, 7.540012380127651, 7.355318811453724, 7.166242659558683, 7.011314741460387, 6.903063629338904, 6.837300521430444, 6.803521587045906, 6.791062231303412, 6.791500519714738, 6.799011573731299, 6.809921489878079, 6.822099589628805}, {6.817043971397372, 6.804487442871054, 6.791656471365898, 6.779804490475294, 6.7714859644461, 6.77135947230377, 6.787231204398493, 6.831032047612374, 6.918729720680725, 7.066877849955929, 7.282072641473021, 7.541296451056316, 7.775368510226098, 7.898166562884262, 7.87927791353267, 7.720756302741492, 7.470947261065594, 7.218671913458327, 7.020747685678399, 6.890058179238629, 6.815776282969779, 6.780840526080832, 6.770218487128766, 6.77314277418751, 6.782755059704049, 6.795052100053613, 6.807893242126157}, {6.806362108360374, 6.793987523625182, 6.780666428312756, 6.767415763746458, 6.756589666568626, 6.752882797639427, 6.764800264255748, 6.806387417746168, 6.898114727333193, 7.063710760226269, 7.316392321645329, 7.627699947925949, 7.894292920704887, 7.995723600082916, 7.985634212586519, 7.835896262540917, 7.543359718208297, 7.24094904129291, 7.011159300698578, 6.867390752489567, 6.791348917578932, 6.759415938013053, 6.752779895150521, 6.759028872274202, 6.770841445375238, 6.784271539779322, 6.797401423985501}, {6.799196257902635, 6.787645460723926, 6.774578428872485, 6.760661202603423, 6.747786840127027, 6.740166931960198, 6.746079082566222, 6.780213339826242, 6.865551878113858, 7.03093212557181, 7.295236283699719, 7.627259313017956, 7.902970343400872, 7.996110302248572, 7.987659414957541, 7.844665806473557, 7.53738885908768, 7.215402531548791, 6.97746932837246, 6.836183774752383, 6.767206272917278, 6.742488583431381, 6.741311745479563, 6.750935980260122, 6.764379123653909, 6.778189127512978, 6.790883748974068}, {6.795441504213237, 6.785564635167139, 6.773849610046728, 6.760580633535126, 6.747031321333164, 6.736500292596074, 6.736093506835191, 6.759351101707673, 6.828854299165366, 6.974949956599778, 7.220814190462863, 7.542447317973985, 7.829541091530026, 7.9620692975927, 7.943383448626827, 7.764894721637197, 7.453982997867057, 7.145466823376087, 6.926775774655749, 6.804154802278788, 6.749736584700658, 6.734591732377261, 6.738703044256149, 6.75053592584682, 6.764224546869137, 6.777149162291618, 6.788376700768024}, {6.794697276462893, 6.787421832246713, 6.778352152376936, 6.767463017733423, 6.755416719630179, 6.744416090268848, 6.739771057016515, 6.75239388809188, 6.801686192537496, 6.915657585282088, 7.119735865018216, 7.404004124166268, 7.686687594398495, 7.847385605376641, 7.821630590859125, 7.618588813192664, 7.323588872601439, 7.055980279390967, 6.877227343884191, 6.783484520310445, 6.746418064934555, 6.739901761960156, 6.747023873329745, 6.758657388086038, 6.770525822975606, 6.780955291636678, 6.789528015252598}, {6.796200946991733, 6.792336312625754, 6.787117104294887, 6.780355952250216, 6.772260746815418, 6.764029939369476, 6.759015644178421, 6.76471000548955, 6.795343672818852, 6.872998368186963, 7.020922115367739, 7.240108063466045, 7.476116583471624, 7.623179936322296, 7.598701614300163, 7.417115553871529, 7.176544123145663, 6.973803850224111, 6.84624627369554, 6.783611374063736, 6.761485490560134, 6.759713929069829, 6.766103293356892, 6.774508616286978, 6.782309244935895, 6.788655921699076, 6.793487473481822}, {6.798843532548795, 6.798864003980891, 6.798267211398282, 6.796852455855644, 6.794573298246401, 6.791851752528667, 6.790236127569599, 6.793601855062521, 6.809880299306096, 6.852243305580604, 6.936040842143472, 7.06534822862427, 7.210537802571185, 7.304261613575677, 7.28847574195284, 7.173658599499304, 7.027289897920135, 6.908998106789416, 6.837486100954453, 6.803623736569726, 6.791859773455964, 6.790397167296545, 6.79256282306449, 6.795254892839097, 6.797317227735535, 6.798499273676815, 6.798909527673434}, {6.801283697965363, 6.805157261023293, 6.809231497554554, 6.813359171108611, 6.817346106748447, 6.820991545034754, 6.824220121769551, 6.827389937259499, 6.831841819884529, 6.840505282901545, 6.857607689946297, 6.885558414681534, 6.918664057449437, 6.940765997827593, 6.937008471045154, 6.910113263656908, 6.87715762472071, 6.851997861276829, 6.83755183645306, 6.83039593991549, 6.826498926538191, 6.823391927355683, 6.820061489768098, 6.816308716274791, 6.812263537647862, 6.808132796434858, 6.804099817453189}, {6.802145170545397, 6.809273864209884, 6.8172306967026, 6.825860613291387, 6.834754230299275, 6.843035521148423, 6.849024467605643, 6.849777219066632, 6.840678136343654, 6.815720503385994, 6.769878212185215, 6.705025136149717, 6.637228682091514, 6.595361826521358, 6.602327920078329, 6.654070533694507, 6.723571008896335, 6.784241782976494, 6.824271607969944, 6.844394104095141, 6.850317425307452, 6.847790357210231, 6.840963416486971, 6.832395178795731, 6.823510395265032, 6.815033376006613, 6.807289270333292}, {6.800249703627458, 6.809554680648106, 6.819896349125625, 6.830943984417198, 6.841862457018158, 6.85088354824925, 6.854629245430264, 6.847223206399466, 6.819626528804421, 6.76060359302745, 6.662028890465112, 6.530415356594877, 6.398583488581318, 6.319447386577963, 6.332505286765577, 6.430881705091884, 6.567406804090728, 6.69221862701556, 6.780021698844278, 6.829584709840593, 6.850741618912278, 6.854424473690285, 6.848817233421117, 6.839041081406548, 6.827963705723939, 6.817049411744977, 6.806965748088736}, {6.794819297112645, 6.804951639529726, 6.81580871286505, 6.826689466265042, 6.836105036765136, 6.841196817181458, 6.836905189493197, 6.815081868796712, 6.764370446168952, 6.672870182360744, 6.536373004050822, 6.371413048149445, 6.221075895377967, 6.137296291279374, 6.15079364689932, 6.256641872481329, 6.416153396417787, 6.57673264107763, 6.701755630981128, 6.781435975108895, 6.82320993167174, 6.839365368887625, 6.84049889683353, 6.833867180181343, 6.823850894493469, 6.812871760718681, 6.802162017984143}, {6.785588568741793, 6.795200209663352, 6.804761214427468, 6.813073155293877, 6.817890207403784, 6.815277669232163, 6.798826396915947, 6.759123045400022, 6.68465510547851, 6.566452446333961, 6.408494217242655, 6.239297094839491, 6.106266779905343, 6.04265678451334, 6.052316040121886, 6.135709223622327, 6.282917230445919, 6.453390250570421, 6.602389924830453, 6.708544539585568, 6.772622872460932, 6.805044485541785, 6.817011015609027, 6.817131938311185, 6.8110814187891, 6.802269782470764, 6.792609602902421}} Have you tried using ContourPlot on an interpolated function and setting the plot points? here is the help text of the StoppingTest option In[15]:= ?StoppingTest StoppingTest is an option for NDSolve that can be used to stop the integration of the ode when a certain condition is found to be True. The condition can evaluate to True/False only and should contain the dependent and independent variables explicitly. This option cannot be used for linear boundary value problems. The result of NDSolve can still be used to obtain the results. Subject: [mg13948] Options to exit NDSOLVE? >> Is it possible to get NDSOLVE to exit before the independent variable >> reaches its range? I would like to exit the numerical integration routine >> based on monitored conditions in the simulation. I would also like to >know >> the value of some of my variables at exit. >> For example, I am modeling the vertical motion of a water rocket and would >> like to stop the simulation when the water is dispelled from the rocket, >not >> necessarily at some particular value of the independent variable (time). say Your data are named data than You can just write what you want First[Select[data,Last[#]>5 &]] If You don't like to waste time computing all elements larger than 5 You can write Catch[Scan[If[Last[#]>5,Throw[#],Null] &,data]] If You don't like Catch and Throw You can still use pattern matching with First[data /. {x_,y_?NumericQ} /; y<=5 :> Sequence[]] >I came across what seems like it should be a simple little function, but >could not come up with a clever way to implement it. Generally, what I >am trying to do is take a list of lists of length 2 ie a list of x,y >coordinates, and Select x values based on some criterion for y. For >example I want to select the first x value for which the corresponding >y is greater than 5. >I can write a function using Position and Take etc. , but there must be >a clever,and more efficient way to do this. Any thoughts... Jason --Improving on my earlier solution we can give Round an option! With the lines below I give it the option UseFullSimplify->True. In[1]:= $DoThis=True; Unprotect[Round]; Round[expr_,opts___]/;$DoThis:=Block[{$DoThis}, If[ (UseFullSimplify/.{opts}/.Options[Round])=!=True, Round[expr], Block[{$Messages}, Check[ Round[expr], Round[FullSimplify[expr]], $MaxExtraPrecision::meprec ] ] ] ]; Options[Round]={UseFullSimplify->True}; Protect[Round]; UseFullSimplify::usage=UseFullSimplify is an option for select functions that determines whether FullSimplify should be used on the arguments when numerical evaluation has trouble determining the result.; Now we get the desired answer for Round[Log[2]/Log[4]] As with my previous solution, FullSimplify is only used when needed. In[3]:= Round[Log[2]/Log[4]] Out[3]= 0 If you don't want Round to use FullSimplify you can specify that with the option (see In[4]). You can also change the default setting of the option using; SetOptions[Round, UseFullSimplify->False] In[4]:= Round[Log[2]/Log[4], UseFullSimplify->False] $MaxEtraPrecision::meprec: In increasing internal precision while attempting to evaluate Round[Log[2]/Log[4]], the limit $MaxExtraPrecision=49.99 was reached. Increasing the value of $MaxExtraPrecision may help resolve the uncertainty. Out[4]= Round[Log[2]/Log[4]] As far as I can tell this will work as if this new option was a built-in feature. Well I suspect Wolfram Research could make it work more efficiently if they made it a built-in feature. I don't include the code here, but similar enhancements can be made for Floor, Ceiling, Equal, and Unequal. I don't know the code but the restriction of the usual fast Fourier transfrom to data sets of length 2^n comes from the radix 2 based integer representation in the most computers. I think Mathematica is so clever that it will use the fast version of the fft when ever possible. You can try it out that In[1]:= data=Table[Random[],{i,8,1024},{n,1,i}]; In[3]:= tm= First /@ (Timing[Fourier[#]] & /@ data); In[5]:= ListPlot[tm /. Second->1] gives not propto N^2 plot with some drastic smaller timing results at Length[data[k]]==2 ^M_Integer. > Fourier[] implements a numerical fast fourier transform. That means that >> the data passed to Fourier[] are the function values f(t) on the >> interval t in [0,2Pi) with constant increment. The data are assumed to >> be periodic in t with period 2Pi. My understanding was that Fourier implemented a Discrete Fourier >Transform as a general case, and a Fast Fourier Transform if your data >length an integer power of 2. have the following problem: I generate a 2-dimensional grid of points that represent x,y-cartesian coordinates. Separately I have a list of numbers (z-coordinates that I would later like to use in a contour plot) which will be mapped to the grid of x,y-coordinates. I create a function that rotates the grid matrix by a certain angle. Now I need to display a contour plot of the z-values in terms of the new rotated x,y coordinates. Obviously, after the rotation the new matrix of x,y- coordinates is not sorted anymore. To be able to display the contour plot I need to resort the matrix of the coordinates in a conventional way. WHat would be the best way to do that? Below there is an example of what I wrote so far: _________ Grid11[horiz_, vert_]:=Table[Table[{k,l},{l,1, horiz}], {k,1,vert}]; GridRot[Grid1_,angle_]:= Floor[Table[ Table[Rotate2D[Grid1[[m,n]],N[angle], {1.,1.}], {n,1, Length[Grid1[[1]]]}],{m,1,Length[Grid1]}]]; grida=Grid11[5,5]; In[9]:= gridb=GridRot[grida,3 Pi/4] Out[9]= {{{1,1},{1,0},{2,-1},{3,-2},{3,-2}},{{0,0},{1,-1},{1,-2},{2,-2},{ 3,-3}},{{-1,-1},{0,-2},{1,-2},{1,-3},{2,-4}},{{-2,-2},{-1,-2},{0,-3},{ 1,-4},{1,-4}},{{-2,-2},{-2,-3},{-1,-4},{0,-4},{1,-5}}} Shift[gridd_]:=Block[{}, horizmin= Min[Table[ Table[#[[m,n,2]]&@gridd,{n,Length[gridd[[1]]]}],{m, Length[gridd]}]]; vertmin= Min[Table[ Table[#[[m,n,1]]&@gridd,{n,Length[gridd[[1]]]}],{m, Length[gridd]}]]; Table[Table[{gridd[[m,n,1]]+Abs[vertmin]+1,gridd[[m,n,2]]+Abs[horizmin]+1},{ n,Length[gridd[[1]]]}],{m,Length[gridd]}]] (this will shift the grid in such a way that there won't be negative coordinates) In[12]:= gridc=Shift[gridb] Out[12]= {{{4,7},{4,6},{5,5},{6,4},{6,4}},{{3,6},{4,5},{4,4},{5,4},{6,3}},{{2,5},{3, 4},{4,4},{4,3},{5,2}},{{1,4},{2,4},{3,3},{4,2},{4,2}},{{1,4},{1,3},{2, 2},{3,2},{4,1}}} After this step I will map the z-values into the rotated grid: FTGridCombo= Table[Table[{gridc[[m,n,1]],gridc[[m,n,2]],zvalues[[m,n]]},{n, Length[gridc[[1]]]}],{m,Length[gridc]}]; Now I will have to resort the x,y coordinates in a conventional way, so that it will be a table of the form: {{{1,3},{1,4}},{{2,2},{2,4},{2,5}},{{3,3},{3,4},{3,6}},{{4,1},{4,2},{4, 2},...etc. What would be the best way to do this? There is also a problem that contour plot accepts only rectangular matrices mXn, but obviously after rotation the matrix won't look like this anymore. To bring it back to the conventional form I simply filled the missing parts with zeros: cnt1a:=Block[{}, temp=Table[ Join[Table[ 0,{n,Ceiling[Length[cnt1[[31]]]/2]-Ceiling[Length[cnt1[[j]]]]/2}], cnt1[[j]], Table[0,{n, Ceiling[Length[cnt1[[31]]]/2]-Ceiling[Length[cnt1[[j]]]]/2}]], { j,Length[cnt1]}]; temp1=Table[Length[temp[[n]]], {n, Length[temp]}]; temp2=Max[temp1]; Table[Join[temp[[n]], Table[0,{temp2-Length[temp[[n]]]}]], {n, Length[temp]}]] But it seems to me that this approach is very cumbersome... Would there be a better approach? Is it possible to display non-rectangular matrices using ListContourPlot? sorry for such a long message and thank you very much for your time. Tatyana Plots to xterms appear as Black on Black under the SGI IRIX 6.2 24-bit color driver. Under the 8-bit color driver for xdm, plots are Black on White. Is there a fix for this? In the lines below SetPrecision[Round,False] makes it so Precision and accuracy return the actual floating point numbers that are used internally. $NumberMarks=True, makes it so (among other things) InputForm[num] returns all digits used internally, and the precision marks at the end of inexact numbers. In[1]:= SetPrecision[Round,False]; $NumberMarks=True; x=12345.67; Out[2] shows exactly how Precision[x] is represented internally. Out[3] shows that Precision[x] is the number closest to Log[10, 2^53]. In[2]:= Precision[x]//InputForm Out[2]= 15.9545897701910028` In[3]:= N[N[Log[10,2^53],17]]//InputForm Out[3]= 15.9545897701910028` The next line shows exactly how Accuracy[x] is represented internally. Where does this number come from? Since accuracy is the number of digits to the right of the decimal I expect to get roughly 11.9. But why ( 11.8630751061039617` )? In[4]:= Accuracy[x]//InputForm Out[4]= 11.8630751061039617` Does anybody know about a Mathematica package which can implements conditional expectation, i.e. implementing rules as E[x[t]+y[t],t]=E[x[t],t] + E[y[t],t] E[E[x,t],t-1]= E[x,t-1] E[a[t-1] x[t],t]= a[t-1] E[x[t],t] and d E[x[y[t]]]/d y[t] = E[d x[y[t]]/dy[t]] and so on?? I'm trying to write a program in Visual Basic 4.0 that uses the MathLink comunication protocol with mathematica. First thing I've tried is to run the samples in the Mathlink's package, but that's not possible because the program cannot open the library (mlink32.dll). could you tell me how to open that library? I've checked the declarations and it seems to be all right It looks to me that you may be using a Visual Basic example that is quite old. The reason it looks this way is that the file mlink32.dll is the name of the MathLink libraries from Mathematica V2.2. The name of the MathLink libraries for Mathematica V3.0 is ml32i1.dll. If you look in the Mathematica 3.0 distribution, under AddOnsMathLinkDevelopersKitsWindowsUnsupportedGoodiesvb, you will find a more recent example of using MathLink through Visual Basic. > I'm trying to write a program in Visual Basic 4.0 that uses the >MathLink comunication protocol with mathematica. First thing I've tried >is to run the samples in the Mathlink's package, but that's not >possible because the program cannot open the library (mlink32.dll). >could you tell me how to open that library? I've checked the >declarations and it seems to be all right Does anybody know how to properly convert a graphic to EPS format? I can do it, but the EPS file does not seem much the original graphic when seen from a EPS graphics visualizer, specially in the labels were I use greek letters and so. Also, is there the possibility of just the PS format in Mathematica 3.0? Does anybody know how to properly convert a graphic to EPS format? I can > do it, but the EPS file does not seem much the original graphic when > seen from a EPS graphics visualizer, specially in the labels were I use > greek letters and so. > Also, is there the possibility of just the PS format in Mathematica 3.0? The greek letters included in EPS files require the Mathematica fonts to be available to the visualizer (and the printer for printing). Solutions are : a) include the Mathematica fonts in the Postscript file. I do not remember if this is valid for EPS files and the fonts are copyrighted, which may be a problem if you are going to export the Postscript file containing the fonts. See : http://www.wolfram.com/support/FrontEnds/Printing/FontsInGraph.html If the EPS is to be included in a LaTeX document, make the fonts available to LaTeX and reference them in the reamble. b) Make the Mathematica Postscript fonts available to the visualizer. I did it once for XDVI. c) For printing only, you can download manually the Mathematica fonts in the printer. d) Forget greek letters and set FormatType to OutputForm in Mathematica : http://www.wolfram.com/support/Graphics/NoMathFonts.html > Does anybody know how to properly convert a graphic to EPS format? I can > do it, but the EPS file does not seem much the original graphic when > seen from a EPS graphics visualizer, specially in the labels were I use > greek letters and so. The problem you may be encountering is that the EPS graphics visualizer does not know what to do with requests for the Math fonts that appear in the PostScript code. This would be a problem if you used grouping symbols or Greek characters. You may want to review the documentation for your PostScript rendering program to see how fonts are added. If the program uses Ghostscript as the rendering engine, you can take advantage of the HOWTO at the Wolfram Research FAQ site: http://www.wolfram.com/support/Graphics/Formats/EPS/Ghostscript.html > Also, is there the possibility of just the PS format in Mathematica 3.0? Only if you are using Unix. There is a legacy shell script in the Mathematica installation called psfix that can do the job. > Does anybody know how to properly convert a graphic to EPS format? I can > do it, but the EPS file does not seem much the original graphic when > seen from a EPS graphics visualizer, specially in the labels were I use > greek letters and so. > To make show up greek letters in an .eps file under Linux using ghostscript, I have the following in my /etc/profile: GS_FONTPATH=/opt/mathematica/SystemFiles/Fonts/Type1 export GS_FONTPATH Now a graphic saved with Mathematica 3.0 (edit/Save SElection As/EPS) is displayed correctly by Ghostscript. We would like to buy mathematica 3.0 for our digital alpha server but I read some strange postings in this newsgroup about some bug for this mathematica version. Would you be so kind to give me some ulterior informations ? Is the WinNT edition preferable ? What misery has befallen me, whoa is me. I accidently deleted a directory with quite a few notebooks in it. No problem I thought, just get out the trusty Norton undelete program. It did work like a charm and recovered all of my notebooks. My problem now is that over half of the notebooks that I open have syntax errors in them. The exact message that I get is There was a syntax error in the file being read. This indicates that the file has become corrupted, or was generated incorrectly....... The next message that I get tells me that there was a syntax error on line so and so and tells me that the error was a syntax error on line % Id in the file %s. The error was %s. Is Mathematica telling me a specific error or referring to a previous output? Sometimes the file opens with the affected part highlighted. But I don't know the syntax well enough to spot an error. I suspect that the recovery program probably inserted the same character in all the files. I think that if I poke around in them a bit I can find something common to all, but what to look for and more importantly with what text editor? I have about 60 files that I would like to recover. Any suggestions where I should start or what I ought to be looking for? I'd like to simulate a rectangular voltage source. How can I define such a function in Mathematica? Example: It must be possible then to multiply a Sinus-function with the rectangular function. Hello, I am looking for on-line Mathematica archives - specifically those dealing with Linear Algebra, Matrix Manipulation, and related subjects. http://www.gatecom.com/~wcrane/index.html -- In[1]:=FindRoot[{x+y==10,x==y},{x,3},{y,3}] Out[1]:= {x->5.,y->5.} In[2]:={x,y}/.% Out[2]:={5.,5.} Subject: [mg14017] how to replace a list of variables >Hi, I just got emails discussing how to assign a solution to a variable. >However, the same approach doesn't work for the following similar >question, in which the solution is a vector. FindRoot[{x+y==10,x==y},{x,3},{y,3}] {{x->5,y->5}} >{x,y}={x,y}/.% > I have been told there used to be a Signal Processing package available (SigProc2.9.5, I believe) from MathSource - however I cannot seem to find it. Is this package still available from any ftp site? In article <6tt3al$k0e@smc.vnet.net>, edx@cc.usu.edu@cc.usu.edu wrote: > Relay-Version: ANU News - V6.2.0 06/23/97 OpenVMS AXP; site cc.usu.edu > Subject: Signal Processing package > From: edx@cc.usu.edu > MIME-Version: 1.0 > Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: > 7bit I have been told there used to be a Signal Processing package available > (SigProc2.9.5, I believe) from MathSource - however I cannot seem to > find it. Is this package still available from any ftp site? > The author of this package, Brian Evans, has a pointer to this on one of his web pages: http://www.ece.utexas.edu/~bevans/projects/spp.html However, the URL reference to mathsource is outdated since this item is not contained in MathSource 3.0. However, it is still in the (frozen) Mathsource 2.2 at the address: http://mathsource.com/cgi-bin/MathSource22/Applications/Engineering/Electrical/Signals/0202-240 Note that this package has significant incompatibilities with Mathenatica 3 or above, but there also should be significant portions that still work. Brian is also the author of quite a few software tools that might be of interest to you (or not). His main web page is: http://www.ece.utexas.edu/~bevans if I work in UNIX, I save the graphics using Edit/SaveSelectionAs/AdobeIllustrator for some reason on a PC (Windows95 platform) I have to use: Edit/SaveSelectionAs/EPS In Macintosh I believe either should work fine. All the files generated in this way preserve the characters, and are also editable using any standard graphics software (Adobe Illustrator, Canvas 5, etc.) You can also print your graphics into a postscript file, and then use a standard ps-eps converter to generate an EPS format. > Does anybody know how to properly convert a graphic to EPS format? I can > do it, but the EPS file does not seem much the original graphic when > seen from a EPS graphics visualizer, specially in the labels were I use > greek letters and so. > Also, is there the possibility of just the PS format in Mathematica 3.0? > I am in the very early stages of putting together a business plan (and starting the associated funding discussions) for a Mathematica related business and am interested in getting a feel for the pool of talent that I might draw on should funding get secured. Very generally, this venture would aim to produce a steady sequence of Mathematica aftermarket products that leverage the full spectrum of Mathematica's strengths: those that are present in the current version and those planned for future releases. I am interested in hearing from experienced Mathematica programmers who have broad scientific and engineering interests. Works on my machine. Clear[x, y]; FindRoot[{x+y == 10, x == y}, {x, 3}, {y, 3}] {x,y}={x,y}/.% {5., 5.} Clear[x, y]; FindRoot[{E^(x+y) == 10, x == y+2}, {x, 3}, {y, 3}] {x,y}={x,y}/.% {2.15129254649721, 0.1512925464972104} If you had previously made an assignment to x or y and didn't clear the assignment, you might get a bad result. For example, FindRoot[{x+y == 10, x == y}, {x, 3}, {y, 3}] {x,y}={x,y}/.% {5., 5.} FindRoot[{E^(x+y) == 10, x == y+2}, {x, 3}, {y, 3}] {x,y}={x,y}/.% {2.15129254649721, 2.15129254649721} >Hi, I just got emails discussing how to assign a solution to a variable. >However, the same approach doesn't work for the following similar >question, in which the solution is a vector. FindRoot[{x+y==10,x==y},{x,3},{y,3}] {{x->5,y->5}} >{x,y}={x,y}/.% One approach: Needs[Calculus`DiracDelta`]; rect[x_, intvl_:1] := Sum[(-1)^Floor[t/intvl] * UnitStep[t/intvl], {t, 0, x, intvl}]; Plot[rect[x], {x, 0, 6}]; Plot[{rect[x, Pi/2], Sin[x]}, {x, 0, 4Pi}]; Plot[rect[x, Pi/2] * Sin[x], {x, 0, 4Pi}]; Plot[{2rect[x, Pi/2]-1, Sin[x]}, {x, 0, 4Pi}]; Plot[(2rect[x, Pi/2]-1) * Sin[x], {x, 0, 4Pi}]; Plot[{2rect[x, Pi]-1, Sin[x]}, {x, 0, 4Pi}]; Plot[(2rect[x, Pi]-1) * Sin[x], {x, 0, 4Pi}]; Plot[{2rect[x, 2Pi]-1, Sin[x]}, {x, 0, 4Pi}]; Plot[(2rect[x, 2Pi]-1) * Sin[x], {x, 0, 4Pi}]; >I'd like to simulate a rectangular voltage source. How can I define such >a function in Mathematica? >Example: It must be possible then to multiply a Sinus-function with the >rectangular function. I've been informed there is a signal processing package available, SigProc2.9.5, for Mathematica; however I've been unable to locate it. Could someone point me to an ftp site with SigProc2.9.5. > I've been informed there is a signal processing package available, > SigProc2.9.5, for Mathematica; however I've been unable to locate it. > Could someone point me to an ftp site with SigProc2.9.5. You can get if from the version 2.2 branch of MathSource: http://www.mathsource.com/cgi-bin/MathSource22/Applications/Engineering/Electrical/Signals/0202-240 I believe that this is an old precursor to the Signals and Systems package that is now part of the Mathematica Applications library. http://www.wolfram.com/~paulh/ Make a little notebook. You might have to experiment with different types of cells and so on. You can then open the notebook with a text editor, and see what a healthy notebooks contains. Then you can open the problem notebooks with a text editor, and compare it with the healthy notebook. If all the notebooks that give you trouble are large you might have a big problem. Also If you have regular or premier service you might email one of the smaller problem notebooks to tech support. What misery has befallen me, whoa is me. I accidently deleted a directory with quite a few notebooks in it. No problem I thought, just get out the trusty Norton undelete program. It did work like a charm and recovered all of my notebooks. My problem now is that over half of the notebooks that I open have syntax errors in them. The exact message that I get is There was a syntax error in the file being read. This indicates that the file has become corrupted, or was generated incorrectly....... The next message that I get tells me that there was a syntax error on line so and so and tells me that the error was a syntax error on line % Id in the file %s. The error was %s. Is Mathematica telling me a specific error or referring to a previous output? Sometimes the file opens with the affected part highlighted. But I don't know the syntax well enough to spot an error. I suspect that the recovery program probably inserted the same character in all the files. I think that if I poke around in them a bit I can find something common to all, but what to look for and more importantly with what text editor? I have about 60 files that I would like to recover. Any suggestions where I should start or what I ought to be looking for? A simpler approach rather than my initial use of UnitStep is to just use the Sign function. rect[x_, intvl_:1] := Sign[Sin[x Pi/intvl]] Plot[rect[x], {x, 0, 6}]; Plot[(rect[x]+1)/2, {x, 0, 6}]; Plot[rect[x, Pi] Sin[x], {x, 0, 4Pi}]; >I'd like to simulate a rectangular voltage source. How can I define such >a function in Mathematica? >Example: It must be possible then to multiply a Sinus-function with the >rectangular function. http://www.wolfram.com/support/FrontEnds/Notebooks/Files/Fixing Corrupted.html can You explain what Your input mean ? The input FindRoot[{x+y==10,x==y},{x,3},{y,3}] {{x->5,y->5}} is due to the Mathematica manual interpreted as Times[FindRoot[{x+y==10,x==y},{x,3},{y,3}], {{x->5,y->5}}] and You get {{x->5,y->5}}*{x->5.,y->5.} that can not be used as an replacement rule and gives various errors. In the case that You mean FindRoot[{x+y==10,x==y},{x,3},{y,3}];{{x->5,y->5}} that is (CompoundExpression[FindRoot[{x+y==10,x==y},{x,3},{y,3}], {{x->5,y->5}}]) You must simply type it to get the correct result. >Hi, I just got emails discussing how to assign a solution to a variable. >However, the same approach doesn't work for the following similar >question, in which the solution is a vector. FindRoot[{x+y==10,x==y},{x,3},{y,3}] {{x->5,y->5}} >{x,y}={x,y}/.% I am running Mathematica 3.0 remotely on an IBM UNIX terminal from an SGI workstation using X-Windows. I invoke the command on my terminal, and then telnet to the host and run the command so that the windows are displayed on my terminal. Then I run Mathematica 3.0 It runs fine, except that the fonts are weird. While starting, it gives me an error that reads: The Mathematica fonts are not properly installed in your system. Without these fonts, typeset mathematical expressions cannot be displayed properly Has anyone encountered this before? Some characters look fine, while others (Math operators and greek letters, for example) are garbled. Do I need to install a Mathematica font set locally on the IBM station serving as an X-Windows terminal, and where do I get it? Any insight into my problem would be much appreciated. e: > I am running Mathematica 3.0 remotely on an IBM UNIX terminal from an > SGI workstation using X-Windows. I invoke the command on my > terminal, and then telnet to the host and run the Mathematica 3.0 It runs fine, except that the fonts are weird. While > starting, it gives me an error that reads: The Mathematica fonts are > not properly installed in your system. Without these fonts, typeset > mathematical expressions cannot be displayed properly Has anyone encountered this before? Some characters look fine, > while others (Math operators and greek letters, for example) are > garbled. Do I need to install a Mathematica font set locally on the > IBM station serving as an X-Windows terminal, and where do I get it? > Any insight into my problem would be much appreciated. > I don't know about IBM UNIX, but with Linux and XFree, you have to make know X about the fonts by adding them to the Font-Path (in Linux it's /etc/XF86config): FontPath /opt/mathematica/SystemFiles/Fonts/X FontPath /opt/mathematica/SystemFiles/Fonts/Type1 > I am running Mathematica 3.0 remotely on an IBM UNIX terminal from an > SGI workstation using X-Windows. I invoke the command on my > terminal, and then telnet to the host and run the Mathematica 3.0 It runs fine, except that the fonts are weird. While > starting, it gives me an error that reads: The Mathematica fonts are > not properly installed in your system. Without these fonts, typeset > mathematical expressions cannot be displayed properly Has anyone encountered this before? Some characters look fine, > while others (Math operators and greek letters, for example) are > garbled. Do I need to install a Mathematica font set locally on the > IBM station serving as an X-Windows terminal, and where do I get it? > Any insight into my problem would be much appreciated. When you are displaying the X front end running on a remote host to a local X server (your IBM machine), it is necessary for you to manually add the Mathematica-specific fonts to the X server's path. Under various flavors of Unix, this is done with the shell command xset fp+ Note that this command must be executed on a shell on the local machine, not the remote machine. This is documented in the booklet _Getting Started with Mathematica 3.0 under Unix and X_. You can retrieve this information with the Help Browser by evaluating the notebook command: FrontEndExecute[ FrontEnd`HelpBrowserLookup[GettingStarted, Interfacing Capabilities (X)]] Scroll to the section titled, Running the front end remotely. You can determine the path to the fonts on your system by evaluating the following command in a notebook: LinkWrite[$ParentLink, FrontEnd`ToFileName[ FrontEnd`FileName[{$TopDirectory, SystemFiles, Fonts}]]]; LinkRead[$ParentLink] In order for the xset command to work as described above, the directories with the Mathematica fonts must be mounted by your local machine. If not, then you will need to make a copies of these directories on the filesystem of your local machine, as described in: FrontEndExecute[ FrontEnd`HelpBrowserLookup[GettingStarted, File Layout (X)]] under the section Fonts. Making local copies of the fonts for this purpose is well within the Mathematica license agreement. This is noted in the booklet _The System Administrator's Guide to Mathematica 3.0_. You should be aware the the fonts consume a sizeable amount of disk space (approximately 11 MB for the BDF and PostScript Type 1 fonts combined). If disk quotas for your account do not allow for this degree of disk space, you may need to get assistance from your system administrator in copying the fonts. >garbled. Do I need to install a Mathematica font set locally on the >IBM station serving as an X-Windows terminal, and where do I get it? exactly. the fonts are in . alternatively, you can use an x11 font server, see man fs or man xfs for this. >solution=FindRoot[{x+y==10,x==y},{x,3},{y,3}] >{x->5.,y->5.} >solution[[1]] >x->5. >xx=solution[[1,2]] >yy=solution[[2,2]] >5. >5. : >>Hi, I just got emails discussing how to assign a solution to a variable. >>However, the same approach doesn't work for the following similar >>question, in which the solution is a vector. >>FindRoot[{x+y==10,x==y},{x,3},{y,3}] {{x->5,y->5}} >>{x,y}={x,y}/.% Take a look at the package Corruption.m located at, ftp://ftp.wolfram.com/pub/outgoing/Support/Corruption.m It is a work in progress by WRI, and may help you in your darkest hour. {x,y} is not a valid name for a variable. You can assign: v={x,y} /. % then access v[[1]] and v[[2]], or individually x=x /. % y=y /. %% Hi, I just got emails discussing how to assign a solution to a variable. > However, the same approach doesn't work for the following similar > question, in which the solution is a vector. FindRoot[{x+y==10,x==y},{x,3},{y,3}] {{x->5,y->5}} > {x,y}={x,y}/.% > read the manual !!! Did You ever hear about the PlotRange-option? Your bug dissapears when You use the command cplt=ListContourPlot[list3,Contours->{7.0,7.50,7.75},PlotRange->All]; Without this option Mathematica choose a z-Range that ends at z=7.5 and so the contour line not drawn because it is outside the z-range. It may be inconsistent to use the PlotRange->Automatic when explicit z-values are given but it is not a bug -- it is a feature. >The following problem arises with Mathematica 2.2 for X-Windows, with >Mathematica 2.2.3 for MS-Windows 3.x and for Mathematica 3.0.1 on >Windows-NT. Perhaps, it is present in all versions on all platforms. ListContourPlot has an option Contours to select which contours shall be >drawn. Using Contours->{z1,z2,...} I experienced cases, where one or more contour lines were not drawn, >although they should show up. (In the examples which I have >investigated, they were missing around a local maximum totally within >the rectangle to be displayed and totally surrounded by a lower contour >line.) The funny thing is, that by leaving out one row of data points, >sometimes the missing contour line is drawn! - See the example below. A similar question (in essence) was rised on June 26, 1997 in this >group, but there was only a single Re telling, that one has observed >similar things without being able to always reproduce it. The problem >itself was not solved, I think it was not really brought to the point. 1.) Can anybody enlighten us with the internals of ListContourPlot? 2.) Does anybody know, how ListContourPlot searches starting points for >the contours to be displayed? 3.) Does the used searching algorithm guarantee, if there are >neighbouring data points on the grid zLow, zHigh such that >zLowthe requested contour line from Contours->..., that a contour line for >zContour is found and displayed between the neighbouring points? The basic problem seems to be, to find *all* places f(z)=zContour for a >sufficiently continuous function f interpolating the data points. This >problem is non-trivial for the one dimensional case (but not, if f is >piecewise linear or quadratic). As the contour lines belong to some >interpolating function (maybe defined through the smoothed contour >lines), at least all contour lines for the conditions mentioned above >should be found! 4.) If the search starts with an initial set of starting points less >than the given data points: how can I increase the size of this set? >There is no option PlotPoints in ListContourPlot (it would not be >necessary. I also find no option to influence the kind of interpolation >used for display other than smoothing). 5.) Would it be possible to Unprotect[...] and redefine the relavant >subfunction of ListContourPlot to exchange the current search algorithm >used in ListContourPlot by a better one? 6.) has anybody out there a better ListContourPlot than the built-in >one? The problem probably also explains, why LabelContourLines in TWJ-Packs >sometimes puts the wrong numbers at some lines. I have not yet gone >into this in full depth. Here is a practical example which arose in my work: list1=Get[list1,StandardForm]; list2=Table[list1[[i]],{i,1,14}]; >(* watch at line 6: all requested contour lines are shown....*) >ListContourPlot[list2,Contours->{7.0,7.50,7.75}]; ListPlot[list2[[6]]]; (* But now: just add one line of data points far away at the top... *) >list3=Table[list1[[i]],{i,1,15}]; >(* the 7.75-contour line is not shown, although > it should be there between the 12/13 and > between the 16/17-th data point!... *) >ListContourPlot[list3,Contours->{7.0,7.50,7.75}]; ListPlot[list3[[6]]]; >The example data list1 are given at the very end. > I am running a dual boot NT/Win 95 with Mathematica 3.0 in each. However many, but not all, notebooks that I created in Win95 are unreadable under NT... Mathematica just hangs with some brief disk access followed by silence. f[x_] := -2 + 2 * Cos[x] + x * Sin[x] How can I solve the equation f[x] == 0 in a symbolic way? Solve[f[x] == 0, x] says, that it isn't possible to solve this equation! Furthermore I can't simplify this equation. But I think, that x = z * 2 * Pi (z = .. -2, -1, 0, 1, 2 ...) are some of the possible solutions. Is there a trick or a possibility to find out this solutions and the rest of all solutions with Mathematica?? P. S. Is f[x] == Sin[x](Sin[x](x^2 + 4) - 4x)??? How can I find this out with Mathematica?? I would need to be able to see some figures which are in EPS format (and include Greek characters) with CorelDraw 8. I work with Mathematica 3.0 for Windows. Everything appears correctly but the greek characters do not. Do you know if that is feasible and in that case how to do it? I would appreciate any answer to be sent to my email address too. carles@molphys.leidenuniv.nl P.D. I want to thanks here the kind answers that I got for my previous question about EPS problems format, to P.J. Hinton, Andreas, Jean-Michel and . MathCode C++ Generate C++ Code That Links Seamlessly into Mathematica Mathematica is an ideal environment in which to develop, debug, and analyze programs, and with MathCode C++ you can translate entire Mathematica programs into optimized C++ code. The resulting C++ code can run in stand-alone mode useful for embedded applications. Alternatively, the C++ code can use Mathematica callbacks for accessing higher level functions not available in C++ -- automatically. MathCode C++ Key Features: - Optimizes Mathematica matrix expressions into C++, for faster numeric computation - Offers a C++ library for extended matrix manipulation - Generates stand-alone C++ code from Mathematica programs - Generates C++ code connected to Mathematica via MathLink - Offers connectivity with existing C, C++, and FORTRAN77 programs The product is compatible with Mathematica 3.0.1 and later. For additional information, visit http://store.wolfram.com/view/mathcode/. MathCode C++ is developed and supported by MathCore AB. email: info@mathcore.com http://www.mathcore.com I have a partial differential equation solved by NDsolve, and I have plotted it in 3 dimensions with Plot3d. Now I want to look at only one slice of it, that is, I want to look at x=1 for a function of x, y and z. Could somebody help me? I have a power series of the form f[x_] = Sum[c[m] x^m, {m, 0, Infinity}] which I would like to evaluate over a fairly large range of x. The coefficients are defined by a four-term recurrence relation, with c[0] = 1 c[1] = alpha1 / gam c[2] = ((2 * gam + a2 * (1 + alpha1)) * c[1] - 2 * (alpha1 + alpha2 + alpha3)) / (2 * a2 * (1 + gam)) c[3] = (a2 * (4 * (1 + gam) + a2 * (2 + alpha1)) * c[2] - (2 * a2 * (1 + alpha1 + alpha2 + alpha3) + gam) * c[1] + (alpha1 + 2 * alpha2)) / (3 * a2^2 * (2 + gam)) c[m_ /; m > 3] := (a2 * (2 * (m - 1) * (m - 2 + gam) + (m - 1 + alpha1) * a2) * c[m-1] - ((m - 2) * (m - 3 + gam + 2 * a2) + 2 * a2 * (alpha1 + alpha2 + alpha3)) * c[m-2] + (m - 3 + alpha1 + 2 * alpha2) * c[m-3]) / (m * a2^2 * (gam + m - 1)) This series is a solution of the differential equation f''[x] + (gam / x - 1) * f'[x] - (alpha1 / x + 2 * alpha2 / (x - a2) - 2 * alpha2 * alpha3 / (x - a2)^2) * f[x] which is very similar to the confluent hypergeometric equation, except for the additional regular singular point at x = a2. The series converges uniformly for x < a2. I am interested in calculating f(2*z), 0 < z <~ 100. f() is also an implicit function of an integer n, 1 < n <~ z + 4 * z^(1/3), with alpha = Sqrt[n * (n + 1)] gam = 2 * (alpha + 1 / 2) alpha1 = 1 / 2 * (gam + 1 / (4 * z) - 2 * z) alpha2 = -1 / (16 * z) alpha3 = -3 / (32 * z) a2 = 4 * z Note that for large z, the terms 2 * alpha2 / (x - a2) and 2 * alpha2 * alpha3 / (x - a2)^2 are small relative to alpha1 / x, so I should be able to use the confluent hypergeometric function 1F1 here. However, I'm having trouble implementing this summation even for small z. I run into Recursion depth exceeded errors, or if I limit the summation range to {m, 0, 10}, problems such as Summand (or its derivative) is not numerical at point m = 10. I don't usually use Mathematica, but am using it in this case because some of these calculations require extended precision arithmetic. I would appreciate any additional pointers that anyone might be able to provide. my experience with Corel 8 & Mathematicas fonts is extrem bad. At the first look is seems more easy to export Windows meta files from Mathematica and read the meta files into Corel Draw. Unfortunately Corel Draw show nothing when it reads Mathematica's meta files or crashes when the meta file information is copied via clipboard. The only graphic program that read and show the fonts in Mathematica's meta files correctly is the Designer 7 from Micrografx. I assume it is a bug in Corel Draw. The problem with the import via PostScript interpreted is the font translation form PostScript -> Windows True Type. It may be resolved when the Adobe Type Manager is installed and uses the Type 1 PostScript fonts of Mathematica. If You don't have the Adobe Type Manager the clever Panose Font comparsion takes place. That works fine for text fonts. For the symbol fonts from Mathematica it produces nonsense. In principal You have in the options-tree (the german menu labels are Extras | Optionen | Text | Schriften. Sorry we have only an German Corel Draw from the CP-program of the Max-Planck Institut and I have no idea how the dutch or englisch version is labeled) a button Panose-Schrift abgleich. If You press the button You get a dialog where You can declare exceptions. There You must add Math1 to the missing fonts and replace it by Math1-Normal, Math1Mono by Math1Mono-Normal ... for all the fonts You need. Than, hopefully You get the fonts imported. I have seen installations where this works and I have also seen Corel Draw 8 versions where it fails. Corel is working on a bugfix-patch of several MBytes for the international versions and in some weeks, years or in Corel Draw 9 it will correct read - windows metafiles (WMF,EMF) - Adobe Illustrator - symbol fonts form Mathematica PS: I recomment Designer 7 & Export/Import of metafiles when You plan to edit the graphic and You can't wait for Corel Draw 2000 >I would need to be able to see some figures which are in EPS format (and >include Greek characters) with CorelDraw 8. I work with Mathematica 3.0 >for Windows. >Everything appears correctly but the greek characters do not. Do you >know if that is feasible and in that case how to do it? >P.D. I want to thanks here the kind answers that I got for my previous >question about EPS problems format, to P.J. Hinton, Andreas, >Jean-Michel and . say You have s solution ndsol=InterpolatingFunction[x,y,z] You can make 2d slices in z-direction by ContourPlot[nsol /. z->someZValue,{x,0,1},{y,0,1}] and You can create scans along a coordinate value in a similar way Plot[nsol /. {x->someXValue, z->someZValue},{y,0,1}] Or You may use an curve curve[t_]:={x0+t*ax,y0+t*by,z0+t*az} Plot[nsol /. Thread[{x,y,z}->curve[t]], {t,someStart, someEnd}] >I have a partial differential equation solved by NDsolve, and I have >plotted it in 3 dimensions with Plot3d. Now I want to look at only one >slice of it, that is, I want to look at x=1 for a function of x, y >and z. Could somebody help me? > >