A32 == I'm woking on a kind of a Mathematica cheat-sheet. So I don't have to repeatthe same learning process if I get pulled away for another 6 months.I've attempted to get my domain name to resolve to my IP address, but it seems Verisign and I have different ideas about what 24 hours is.The site is supposed to be www.globalsymmetry.com, but that will not currently resolve. Here's the IP and path:http://66.92.149.152/proprietary/com/wri/index.htmlThis is not a literary masterpiece. It's probably proof that giving just anybody the power to publish is, perhaps, not a guaranty that more quality publication will take place.If anybody has answers to the questions I've come up with, or comments about the answeres, etc. I'd be happy to know. ==== =>>I believe the complexity is O(n log n), so this should be good enough.Umm ...good enough? I understand the words individually, but thephrase makes no sense to me.Bobby Treat-----Original Message-----> crash the Front End. I was thinking about the fact that I calculated> all those digits and then threw them away. I could save them withSave> or DumpSave, and read them in with Get the next time I wanted any of> them, although the file would be close to 70 MB (if not more). I maydo> that, in fact -- I have plenty of disk space. The next step would be to somehow reuse the stored digits if I wanted> MORE digits. But how? The Bailey-Borwein-Plouffe Pi algorithm is an avenue of attack, sinceit> can calculate digits far from the decimal point, without calculating> those in between. Unfortunately, it calculates hexadecimal digits in> that way, not decimal digits. (That's true for the version I've seen,> anyway.) Still, I could take the stored digits, convert tohexadecimal,> add more hexadecimal digits with the B-B-P algorithm, and then convert> back to decimal. In both conversions, I'd have to be very cognizantof> how much precision I end up with, but that shouldn't be too difficult.> It might go faster if I store hexadecimal digits, as well as decimal> digits, to eliminate one of those conversions at each increase in the> number of digits. The next step would be to set up an application that allowed anyone to> ping for digits across the Internet, and would return them if they're> stored. Hasn't someone already done that? It seems as if someone would have. Bobby TreatIf you're interested in decimal digits, I don't think the BBP algorithmis theway to go. In order to get the nth decimal digit of Pi you need tocompute theprevious n-1 digits, since base conversion is global, not local. ThealgorithmMathematica uses for computing Pi is quite fast - I believe thecomplexity is O(nlog n), so this should be good enough.David> -----Original Message-----calculation in So would it take about the same amont of time for the completeprintout> of digits? Of course it would take a few additional seconds to format> the output... Or does Mathematica take alot less time when it truncates the output?> > Could you tell me the CPU you used and its speed etc...i amcurious,performance> to> other programs out there.> > I used one processor of a dual 1GH Mac and got the same answer with> the> following speed:> > 4.2 for Mac OS X (June 4, 2002)> oldmax = $MaxPrecision> 6> 1. 10> $MaxPrecision = Infinity> Infinity> With[{n = 2^26}, Timing[> pd = RealDigits[N[Pi, n + 1], 10, 20,> 19 - n]; ]]> {28794.1 Second, Null}> MaxMemoryUsed[]> 512055204> pd> {{3, 3, 8, 6, 3, 2, 2, 0, 8, 9, 6, 2, 2, 3,> > 4, 0, 9, 8, 0, 3}, -67108844}> > Tom Burton ==== =Edit ->Preferences -> Font OptionsIn Preferences you will find everything you need to configure yourMathematica environment. Also you may want to look up Style Sheets in thebook or the on line help.Yas> I've been trying to get my Mathematica 4.1 properly configured. I set:> ############################################################# ######> /usr/local/mathematica/SystemFiles/FrontEnd/TextResources/X/ Specific.tr:> @@resource maxForXListFonts> 10000 # xlsfonts | wc -l> 5572 /etc/X11/XF86Config:> FontPath /usr/X11R6/lib/X11/fonts/100dpi:unscaled> FontPath /usr/X11R6/lib/X11/fonts/75dpi:unscaled> FontPath /usr/X11R6/lib/X11/fonts/CID> FontPath /usr/X11R6/lib/X11/fonts/Speedo> FontPath /usr/X11R6/lib/X11/fonts/Type1> FontPath /usr/X11R6/lib/X11/fonts/URW> FontPath /usr/X11R6/lib/X11/fonts/kwintv:unscaled> FontPath /usr/X11R6/lib/X11/fonts/latin2/Type1> FontPath /usr/X11R6/lib/X11/fonts/local/mma/Type1> FontPath /usr/X11R6/lib/X11/fonts/local/mma/X:unscaled> FontPath /usr/X11R6/lib/X11/fonts/misc:unscaled> FontPath /usr/X11R6/lib/X11/fonts/misc/sgi:unscaled> FontPath /usr/X11R6/lib/X11/fonts/truetype> FontPath /usr/X11R6/lib/X11/fonts/uni:unscaled # ls -R /usr/X11R6/lib/X11/fonts/ | grep /> /usr/X11R6/lib/X11/fonts/:> /usr/X11R6/lib/X11/fonts/100dpi:> /usr/X11R6/lib/X11/fonts/75dpi:> /usr/X11R6/lib/X11/fonts/CID:> /usr/X11R6/lib/X11/fonts/Speedo:> /usr/X11R6/lib/X11/fonts/Type1:> /usr/X11R6/lib/X11/fonts/URW:> /usr/X11R6/lib/X11/fonts/encodings:> /usr/X11R6/lib/X11/fonts/encodings/large:> /usr/X11R6/lib/X11/fonts/kwintv:> /usr/X11R6/lib/X11/fonts/latin2:> /usr/X11R6/lib/X11/fonts/latin2/Type1:> /usr/X11R6/lib/X11/fonts/local:> /usr/X11R6/lib/X11/fonts/local/mma:> /usr/X11R6/lib/X11/fonts/local/mma/Type1:> /usr/X11R6/lib/X11/fonts/local/mma/X:> /usr/X11R6/lib/X11/fonts/misc:> /usr/X11R6/lib/X11/fonts/misc/sgi:> /usr/X11R6/lib/X11/fonts/truetype:> /usr/X11R6/lib/X11/fonts/uni:> /usr/X11R6/lib/X11/fonts/util: ######################################################## When I open the Mathematica Book Reference Guide in the Help Browser, I get> a beep and the message says: Unable to find font with family Helvetica, weight Bold, slant Plain, and> size 26. Substituting Courier. Compared to the things which *were* broken, this is a minor problem. I can> live with the beep. What I would now like to know is how to tell Mathematica what> fonts to use by default. This seemingly simple question seems to have no> simple answer. Could someone please help me. TIA, ^L ==== => Edit ->Preferences -> Font Options> In Preferences you will find everything you need to configure your> Mathematica environment. Also you may want to look up Style Sheets in the> book or the on line help.> Yas> I went into the preferences browser, and it was not clear to me what I was modifying. At one point I clicked on a field filled with text. I had inteded to edit it, and all the text vanished. It didn't bother me as much as such things use to, because I believe I know a backout strategy. It's been a while since I looked at this stuff, and I have to admit it seems far more tractible than it did a year ago. I'll look at the discussion again, and see if it makes more sence to me now.STH ==== => As an example, I spent several hours trying to figure out how to tell> Mathematica to understand the delete key in the way most contemporary> systems understand it. I wanted to avoid modifying system> configuration files such as:> /usr/local/mathematica/SystemFiles/FrontEnd/TextResources/ KeyEventTranslations.tr I expected to be able to change something in my own ~/.Mathematic> directory, but I could not figure out an obvious way to affect this> modification.If you could post a precise description of what you expect the Delete keyto do when depressed, we could probably provide you with a clear cutanswer of what needs to be done.> I want to adjust the font size used in the widgets, but again, I see> no ovbious means of modifying these attributes. I suspect it can be> accomplished by modifying the ~/.Mathematica/4.1/FrontEnd/init.m.> Perhaps to an experienced Mathematica user, the syntax and semantics> of this file are obvious. They aren't to me.The size of fonts in user interface elements is not specified through theMathemtica init.m file. It is set through an X resource. If you are notfamiliar with resources, you may want to track down an introductory texton the X Window System. Information on application-specific resourcesettings can be found in the Mathematica Getting Started Guide:http://documents.wolfram.com/v4/GettingStarted/ TroubleshootingUnixX.htmlThe setting that you would need to adjust is XMathematica*fontList. Thevalue of the resource is an X Logical Font Description field.> I also find the overall look & feel of the interface to be archaic.That's because Mathematica relies on the Motif library for user interfaceelements.http://www.opengroup.org/desktop/ motif.htmlThe appearance of these elements, such as the menu and scroll bars, wouldbe the same for any other Motif application, such as the DDD debugger orreleases of Netscape prior to verison 4.-- User Interface Programmer paulh@wolfram.comWolfram Research, Inc. ==== =hi,> I sholdn't have to. If I start messing with X resource settings for my> user environment, I am sure to break something else which is configured> based on the current settings. There should either be a GUI interface, or a> clearly documented, and easily accessible configuration file to modify such> properties as the size of the fonts in the GUI widgets. This is> functionality which is rightfully expected of a modern desktop UI.[snip]> And I'm sure there is some configuration file in which I could place that,> and hope that what you think will be read by my system *will* in fact be> read, and not subsequently overridden during xsession startup. Things> aren't the way they used to be back in the 1980s. The modern Unix desktop> has moved beyond the paradigm of openlook and motif. See for example> http://www.trolltech.com, http://www.gnome.org, and http://www.kde.org>moving the frontend over to QT would have some neat side effects: consistent look & feel with the modern linux gui, themeability, source code truetype fonts as QT supports Xrender and Xft (looks great - see KDE3). i think all of those points are of value, but the most important might be source compatibility. ONE frontend for MOST (or ALL) platforms - sounds like a dream :-))gerald -- *************************************Gerald RothM@th Desktop Development************************************* ==== => If you could post a precise description of what you expect the Delete key> to do when depressed, we could probably provide you with a clear cut> answer of what needs to be done.Item[KeyEvent[Delete], DeleteNext]'Most' means Ômore than half.' > I want to adjust the font size used in the widgets, but again, I see> no ovbious means of modifying these attributes. I suspect it can be> accomplished by modifying the ~/.Mathematica/4.1/FrontEnd/init.m.> Perhaps to an experienced Mathematica user, the syntax and semantics> of this file are obvious. They aren't to me.> The size of fonts in user interface elements is not specified through the> Mathemtica init.m file. It is set through an X resource. If you are not> familiar with resources, you may want to track down an introductory text> on the X Window System. I sholdn't have to. If I start messing with X resource settings for my user environment, I am sure to break something else which is configured based on the current settings. There should either be a GUI interface, or a clearly documented, and easily accessible configuration file to modify such properties as the size of the fonts in the GUI widgets. This is functionality which is rightfully expected of a modern desktop UI.> Information on application-specific resource> settings can be found in the Mathematica Getting Started Guide:> http://documents.wolfram.com/v4/GettingStarted/ TroubleshootingUnixX.htmlIt should be in a clear and easy to access configuraton interface, or at least be redily available through the help system in such a way that reasonable queries will locate it. Changing fonts does not belong in a section on trouble shooting, unless this is an acknowledgement that the UI is broken.> The setting that you would need to adjust is XMathematica*fontList. The> value of the resource is an X Logical Font Description field.And I'm sure there is some configuration file in which I could place that, and hope that what you think will be read by my system *will* in fact be read, and not subsequently overridden during xsession startup. Things aren't the way they used to be back in the 1980s. The modern Unix desktop has moved beyond the paradigm of openlook and motif. See for example http://www.trolltech.com, http://www.gnome.org, and http://www.kde.org > I also find the overall look & feel of the interface to be archaic.> That's because Mathematica relies on the Motif library for user interface> elements.> http://www.opengroup.org/desktop/motif.html> The appearance of these elements, such as the menu and scroll bars, would> be the same for any other Motif application, such as the DDD debugger or> releases of Netscape prior to verison 4.My point exactly. ==== =Awk! Legends!Basically, the answer to your question is that the PlotLegend option worksONLY for the Plot command and does not work for other types of plots. Forother types of plots you have to use ShowLegend. And ShowLegend is not allthat easy to use, especially since WRI does not give an example for multiplecurves in the Help.Needs[Graphics`Graphics`]Needs[Graphics`Legend`]{q1[t_], q2[t_], q3[t_]} = {0.1 Exp[-0.02 t], 0.2 Exp[-0.025 t], 0.4 Exp[-0.028 t]};Let's look at your first plot.Plot[{q1[t], q2[t], q3[t]}, {t, 0, 100}, PlotStyle -> {{AbsoluteThickness[0.5], AbsoluteDashing[{4, 4}]}, AbsoluteThickness[1.5], {AbsoluteThickness[2], AbsoluteDashing[{1, 8}]}}, AxesLabel -> {Y, X}, PlotLabel -> Title, PlotLegend -> {1, 3, 5}, LegendPosition -> {0.5, 0}, ImageSize -> 500];The legend is almost as big as the plot. It distracts from the realinformation you are trying to convey. Furthermore, the order of the curvesin the legend is the reverse of their order in the plot.The following shows how to put the legend in a LogLogPlot, or other types ofplots. I defined the plot styles independently because they are used inseveral places. I made the legend much smaller and put it in an empty areaof the plot. I also reversed the order of the keys so they would match theorder of the curves in the plot.styles={{AbsoluteThickness[0.5], AbsoluteDashing[{4,4}]},{AbsoluteThickness[1.5]},{ AbsoluteThickness[ 2],AbsoluteDashing[{1,8}]}};ShowLegend[ LogLogPlot[{q1[t], q2[t], q3[t]}, {t, 0, 100}, PlotStyle -> styles, AxesLabel -> {Y, X}, PlotLabel -> Title, ImageSize -> 500, DisplayFunction -> Identity], {MapThread[{Graphics[{Sequence @@ #1, Line[{{0, 0}, {1, 0}}]}], #2} &, {styles, {1, 3, 5}}] // Reverse, LegendPosition -> {-0.7, -0.4}, LegendSize -> {0.2, 0.3}, LegendShadow -> {0.02, -0.02}, LegendSpacing -> 0.5} ];But why use a legend at all? After all, a legend is nothing but another plotin which you have put labels on the curves. Why not put the labels directlyon the curves in the real plot in the first place?LogLogPlot[{q1[t], q2[t], q3[t]}, {t, 0, 100}, PlotStyle -> styles, AxesLabel -> {Y, X}, PlotLabel -> Title, ImageSize -> 500, Epilog -> MapThread[ Text[SequenceForm[Case , #1], {Log[10, 0.01], Log[10, #2[0.01]]}, {0, -1}] &, {{1, 2, 3}, {q1, q2, q3}}]];In the legend you have keyed the curves to numbers 1, 3 and 5. (Perhaps youjust used these as examples and meant to use something different in the realplots?) But these don't seem to have any obvious relation to your functions.I suppose the reader will have to look at another table or look into thetext of your paper or notebook to find out what 1, 3 and 5 mean. So thereader has to go from the graph to the legend then to the text and thenmentally transfer the meaning of the curve back to the main plot. It is somuch nicer to put the meaning right on the curve if you can.For the most part, legends are just computer junk and not even easy tonicely construct. When the legend urge comes over you - try to resist.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ AbsoluteThickness[1.5], {AbsoluteThickness[2], AbsoluteDashing[{1,8}]}}, AxesLabel[Rule]{Y, X}, PlotLabel[Rule]Title, PlotLegend[Rule]{1,3,5}, LegendPosition[Rule] {0.5,0}](*However with LogPlot or LogLogPlot the legend desappear*)LogLogPlot[{q1[t],q2[t],q3[t]}, {t, 0, 100},PlotStyle[Rule]{ {AbsoluteThickness[0.5], AbsoluteDashing[{4,4}]}, AbsoluteThickness[1.5], {AbsoluteThickness[2], AbsoluteDashing[{1,8}]}}, AxesLabel[Rule]{Y, X}, PlotLabel[Rule]Title, PlotLegend[Rule]{1,3,5}, LegendPosition[Rule] {0.5,0}]I have shown a particular case, but I has this problem always with LegendandLogPlot and LogPlotPlot. I will appreciate any help.GuillermoSanchez---------------------------------------- -----This message was sent using Endymion MailMan. ==== =Using the Front End as a interface with the kernel I was running some calulations when suddenly pressing Shift+Enter causes the contents of the cell being evaluated to transform to the next text underlined with a red line: NotebookObject[FrontEndObject[LinkObject[dd8,1,1]],8] foollowed by the next messages:An unknown box name (NotebookObject) was sent as the BoxForm for the expression. Check the format rules for the expression.An unknown box name (FrontEndObject) was sent as the BoxForm for the expression. Check the format rules for the expression.An unknown box name (LinkObject) was sent as the BoxForm for the expression. Check the format rules for the expression.An invalid typeset structure was generated: Missing BoxFormData.Any suggestions will be very aprreciated.Cesar ==== =I have an odd problem. I need to use and simplify functions that havebeen provided by a piece of software that insists on outputing thefunctional results of a data mining proceedure, using e whenoutputing numbers in scientific notation.I'm having difficultly using Replace, Hold, etc. to correctly evaluatethese types of function formats. For example, y = 5e+5x1+2e-1x2,should be transcribed into 5 10^5 x1 + 0.2 x2.ChuckReply-To: kuska@informatik.uni-leipzig.de ==== =str = 5e+5x1+2e-1x2;StringJoin[Characters[str] /. e -> *10^] // ToExpression??Work fine for me.But this type of output is typical generated by a C/FORTRANProgram and you should rewrite the formating rules inthe code that produce this output. Jens> I have an odd problem. I need to use and simplify functions that have> been provided by a piece of software that insists on outputing the> functional results of a data mining proceedure, using e when> outputing numbers in scientific notation.> I'm having difficultly using Replace, Hold, etc. to correctly evaluate> these types of function formats. For example, y = 5e+5x1+2e-1x2,> should be transcribed into 5 10^5 x1 + 0.2 x2.> Chuck ==== =RB> I am considering the following integralRB> W[m_,n_]:=Integrate[BesselJ[m, x]*BesselJ[n, x], {x, 0, Infinity}]RB> where m,n are reals >=0. With Mathematica 4.1 I obtain:RB> If[Re[m+n]>-1, -Cos[(m-n)Pi/2]/(2 Pi)*RB> (2 EulerGamma + Log[4] +RB> PolyGamma[0, 1/2(1 + m - n)] +RB> PolyGamma[0, 1/2(1 - m + n)] +RB> 2PolyGamma[0, 1/2(1 + m + n)])RB> Any explanation about the analytical expression will beRB> gratefully accepteed.The expression for W[m_,n_] returned by Mathematica is wrong.To prove, just substitute m = n = 0 which is exactly what you had doneand observe that the output you had hadW[0,0]=-(2 EulerGamma + Log[4] + 4 PolyGamma[0, 1/2])/(2 Pi)= 0.84564was incorrect. The correct answer is 1/2.Mathematica can handle the numeric integration successfullyIn[1] := NIntegrate[BesselJ[1, x]*BesselJ[0, x], {x, 0, Infinity}, Method -> Oscillatory] (* The warnings are skipped *)Out[1] = 0.5Using NIntegrate[BesselJ[0, x]*BesselJ[0, x], {x, 0, Infinity}]without Method -> Oscillatory is not the optimal choice asthe integrand oscillates fairly rapidly over the integrationregion.RB> I suspect that these integrals are divergent (*).In fact, not exactly.Integrate[BesselJ[1, x]*BesselJ[0, x], {x, 0, Infinity}]is equal to 1/2, and Mathematica 4.1 for Microsoft Windows(November 2, 2000) does it correctly, while Mathematica 4.2for Microsoft Windows (February 28, 2002) concocts a strangemixture of a wrong divergence message and the warning thatit cannot check the convergence [should I trust to the secondwarning? or the first?]As a matter of fact,Integrate[BesselJ[1, x]*BesselJ[0, x], {x, 0, Infinity}]converges because the integrand is regular at x=0, bounded overthe whole right semi-axis, and decays as2*Cos[Pi/4 - x]*Cos[(3*Pi)/4 - x]/(Pi*x) + o(1/x)at x -> Infinity .Say, calculateNormal[Series[BesselJ[1, x], {x, Infinity, 1}]] Normal[Series[BesselJ[0, x], {x, Infinity, 1}]] // InputForm->(2*(Cos[Pi/4 - x] - Sin[Pi/4 - x]/(8*x))*(Cos[(3*Pi)/4 - x] +(3*Sin[(3*Pi)/4 - x])/(8*x)))/(Pi*x)then Plot[%,{x,1,10}]and Plot[BesselJ[1,x]*BesselJ[0,x],{x,1,10}]and you could hardly see the difference.Generally, to get to the convergence domain for W in terms ofm and n is easy via the asymtotics of the Bessel functions(use something likeExpand[Normal[Series[BesselJ[m, x], {x, Infinity, 1}]]Normal[Series[BesselJ[n, x], {x, Infinity, 1}]]]then analyze the main term).Best wishes,Vladimir BondarenkoMathematical DirectorSymbolic Testing GroupWeb : http://www.CAS-testing.org/ http://maple.bug-list.org/VER2/ (under tuning) http://maple.bug-list.org/VER3/ (under tuning) http://maple.bug-list.org/VER1/ (under tuning) http://www.beautyriot.com/ (teamwork) http://www.ohaha.com/ (teamwork) Voice: (380)-652-447325 Mon-Fri 9 a.m. - 6 p.m.Mail : 76 Zalesskaya Str, Simferopol, Crimea, Ukraine ==== => inside a program I need to solve this linear equation in terms of p1.> However something odds happens. Sometimes the solution is computed and> sometimes the result is empty [I mean no output...]. Is this a bug of the> solve command or am I doing something wrong? The problem is robust to:> changing name to the variables and other makeups..> DavidThat's the weirdest bug I've seen in weeks. As it happens, it's mine. Atleast the inconsistent behavior, that is. I'll fix it, and maybe alsotry to address the issue of how to handle approximate numbers in testingsubexpressions for zero.I've excised your code and put in place a substantially smaller examplethat I believe is responsible. The table will tend to give erraticresults.zz = (-1.*x^7*(-1. + p - 7.*x^6 + p*x^6 + 6.*x^7)* (7.000000000000002 - 7.000000000000002*x + 14.000000000000004*x^6 - 14.000000000000004*x^7 + 7.000000000000002*x^12 -6.999999999999998*x^13))/ (p^2*(1. + 0.9*x^6)^2*(1. + x^6)^5);One workaround would be to use exact input, say by preprocessing withRationalize.Daniel LichtblauWolfram Research ==== =>inside a program I need to solve this linear equation in terms of p1.>However something odds happens. Sometimes the solution is computed and>sometimes the result is empty [I mean no output...]. Is this a bug of the>solve command or am I doing something wrong? The problem is robust to:>changing name to the variables and other makeups..>David>>ps: Sorry for the stupid way in which I copied the command...>>Solve[(x^2*((-0.9*x^7*(p^2*(-1 - 5.8*x^6 - 14.010000000000002*x^12 -> 18.04*x^18 - 13.06*x^24 -> 5.040000000000001*x^30 - 0.81*x^36) +> x*(7.777777777777779 - 9.074074074074076*x +> 30.333333333333336*x^6 -> 21.51851851851852*x^7 -> 16.333333333333336*x^8 +> 44.33333333333334*x^12 +> 3.188888888888883*x^13 -> 65.68333333333332*x^14 +> 28.777777777777786*x^18 +> 47.937037037037044*x^19 -> 100.10000000000002*x^20 + 7.*x^24 +> 45.6037037037037*x^25 -> 69.53333333333333*x^26 +> 13.299999999999999*x^31 -> 19.833333333333332*x^32 -> 1.0499999999999996*x^38) +> p*(-6 + 8.296296296296296*x -> 28.799999999999997*x^6 +> 32.785185185185185*x^7 +> 9.333333333333336*x^8 -> 55.260000000000005*x^12 +> 49.04777777777776*x^13 +> 38.38333333333334*x^14 -> 52.980000000000004*x^18 +> 34.20518518518518*x^19 +> 60.20000000000001*x^20 -> 25.380000000000003*x^24 +> 11.736296296296294*x^25 +> 43.63333333333334*x^26 - 4.86*x^30 +> 2.8999999999999986*x^31 +> 13.533333333333333*x^32 + 0.81*x^37 +> 1.0499999999999996*x^38)))/(x + 1.9*x^7 +> 0.9*x^13)^2 - ((-1 + p - 7*x^6 + p*x^6 +> 6*x^7)*(1.2962962962962965 - 3.111111111111112*x^6>+> 9.333333333333336*x^7 - 10.111111111111114*x^12>+> 22.05*x^13 - 5.703703703703705*x^18 + 17.15*x^19>+> 5.483333333333331*x^25 + 1.0499999999999996*x^31>+> p1*x^5*(7.000000000000002 - 7.000000000000002*x>+> 14.000000000000004*x^6 -> 14.000000000000004*x^7 +> 7.000000000000002*x^12 -> 6.999999999999998*x^13) -> 1.166666666666667*p*x^4*x1 -> 3.500000000000001*p*x^10*x1 -> 1.0500000000000003*p*x^11*x1 -> 3.500000000000001*p*x^16*x1 -> 3.150000000000001*p*x^17*x1 -> 1.166666666666667*p*x^22*x1 -> 3.150000000000001*p*x^23*x1 -> 1.0500000000000003*p*x^29*x1))/((1 + 0.9*x^6)^2*(1>+> x^6)^2)))/(p^2*(1 + x^6)^3) == 0, p1]>You might find it more robust (and the results cleaner) if you Simplify the equation prior to using Solve. Such asSolve[eqn // Rationalize // Simplify, p1]However, if you are assigning values to p or x prior to using Solve, there may not be a solution. That is, for whenever the numerator of the expression for p1 would be zero, e.g., p = (-6 x^7 + 7 x^6 +1)/(x^6 + 1).Bob Hanlon ==== =I prefer to delete all output and then Copy As>Notebook expression. ItBobby-----Original Message-----andoutput --- I try to use one tab indent for input and two tabs indent foroutput, plus some blank line adjustment.I wonder if anyone has a way of automatically achieving thisreformating.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> Often posters to MathGroup copy and paste in the complete cellexpression,> including the In and Out numbers, when posting to MathGroup. I wonder if this is the best method because one can't then just copyoutall> the statements and paste them into a Mathematica notebook. All thestatement> numbers have to be edited out and if there are many statementdefinitions> this is an extended task for any responder. This, of course, decreasesthe> chances for a response. A better method is for the poster to just copyand> paste the CONTENTS of each cell. This is more work for the poster, butit> may pay off in better responses. David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ ==== =Could someone explain what is going on here, please?In[1]:= a = 77617.; b = 33096.; In[2]:=SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity]; SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b)In[5]:=SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=fOut[6]=-1.1805916207174113*^21In[7]:=a = 77617; b = 33096; In[8]:=g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + (55/10)*b^8 + a/(2*b)In[9]:=gOut[9]=-(54767/66192)In[10]:=N[%]Out[10]=- 0.8273960599468214PK ==== =Peter,I hope that the following example will help - it is a matter or when thingsevaluate.The a in SetAccuracy[a, Infinity], below, evaluates before SetAccuracy acts,so we getSetAccuracy[2.3, Infinity]. The value of a is not changed. a = 2.3; aa = SetAccuracy[a, Infinity] 2589569785738035/1125899906842624But, a 2.3Whereas aa 2589569785738035/1125899906842624--Allan--------------------- Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> Could someone explain what is going on here, please? In[1]:=> a = 77617.; b = 33096.; In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b) In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=> f Out[6]=> -1.1805916207174113*^21 In[7]:=> a = 77617; b = 33096; In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + (55/10)*b^8+ a/(2*b) In[9]:=> g Out[9]=> -(54767/66192) In[10]:=> N[%] Out[10]=> -0.8273960599468214> PK> ==== =In receiving notebooks from many different people I have noticed thatbeginners often do not know how to use Text cells and write all of theircomments as Input cells. I have even run across some extremely advancedusers who did not know the easy method for entering Text cells. A goodnotebook is usually a blend of Text cells, Input/Output cells and graphicscells. Text cells are very useful for documenting what you are doing andpassing information to other people. Since many people do not know how touse Text cells, I thought I would write a little explanation for beginnerswho are followers of MathGroup.The very easiest method for entering a Text cell is to put the insertionpoint where you want the new cell to be (at the end of the notebook orbetween two existing cells) and then type Alt-7. Then just start typing andyou will have a Text cell.Alternatively you can use MenuFormatStyleText to start a new Text cell.Often, it is useful to put the ToolBar at the top of the notebook. UseMenuFormatShow ToolBar. The drop-down menu on the ToolBar has the variouskinds of cells available for the current style of the notebook. You canselect Text (or any other style) from there.Some users may hesitate to use Text cells because they want to include amathematical expression in the comments. However, that is also very easy.Just use an Inline cell within the text cell. At the point within the textcell where you want to include a mathematical expression, start an Inlinecell by typing Ctrl-(. A selection placeholder will appear on a pinkbackground. You can type a Mathematica expression there just as in an Inputcell. Use Ctrl-) to complete the Inline cell, or Shift-Space. You can evenselect an Inline cell and evaluate it with Shift-Ctrl-Enter.Putting comments in Text cells is far better than using Input cells (or cellgroup header cells). Mathematica won't try to evaluate Text cells, the textwill wrap properly and adjust better to the notebook width if you change it.You can also check the spelling of words by putting the cursor after a wordand using Ctrl-K. (In an Input cell Mathematica doesn't use the dictionary,but uses the table of symbols instead and hence it won't check spelling.)David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Reply-To: murray@math.umass.edu ==== =David Park's posting reminded me of a frequent annoyance when I am trying to include some Mathematica expressions within text cells -- a Mathematica input expression in Standard Form that involves use of a Control-key combination to form a superscript, square-root, or built-up fraction:For example, suppose I want to include within a text cell a Standard Form expression for the square of x, with the exponent 2 raised. If I type the x first, even if I immediately highlight it and change it to Courier (to match the default font for Input cells in Standard Form), as soon as I press the Control-^ key combination, an Inline cell is created beginning with the x, and then when I type the exponent 2 everything in that Inline cell is now in Times, and the x is Italic. To change both characters to Courier is not so easy: it seems to require separately the entire Inline cell and selecting Courier does not change the exponent!)So to avoid this annoyance I normally must first type the desired expression in a separate Input cell, then copy the contents of that cell to the desired point in the Text cell.Any suggestions on a more efficient method for handling this?> In receiving notebooks from many different people I have noticed that> beginners often do not know how to use Text cells ....> Some users may hesitate to use Text cells because they want to include a> mathematical expression in the comments....> Just use an Inline cell within the text cell....-- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375Reply-To: kuska@informatik.uni-leipzig.de ==== =just one comment: the meaning of the Alt-7 key depend on the style sheet that is in use.The TMJ style use Alt-8 for text and one hasto learn new key short-cuts for every style sheet ! Jens> In receiving notebooks from many different people I have noticed that> beginners often do not know how to use Text cells and write all of their> comments as Input cells. I have even run across some extremely advanced> users who did not know the easy method for entering Text cells. A good> notebook is usually a blend of Text cells, Input/Output cells and graphics> cells. Text cells are very useful for documenting what you are doing and> passing information to other people. Since many people do not know how to> use Text cells, I thought I would write a little explanation for beginners> who are followers of MathGroup.> The very easiest method for entering a Text cell is to put the insertion> point where you want the new cell to be (at the end of the notebook or> between two existing cells) and then type Alt-7. Then just start typing and> you will have a Text cell.> Alternatively you can use MenuFormatStyleText to start a new Text cell.> Often, it is useful to put the ToolBar at the top of the notebook. Use> MenuFormatShow ToolBar. The drop-down menu on the ToolBar has the various> kinds of cells available for the current style of the notebook. You can> select Text (or any other style) from there.> Some users may hesitate to use Text cells because they want to include a> mathematical expression in the comments. However, that is also very easy.> Just use an Inline cell within the text cell. At the point within the text> cell where you want to include a mathematical expression, start an Inline> cell by typing Ctrl-(. A selection placeholder will appear on a pink> background. You can type a Mathematica expression there just as in an Input> cell. Use Ctrl-) to complete the Inline cell, or Shift-Space. You can even> select an Inline cell and evaluate it with Shift-Ctrl-Enter.> Putting comments in Text cells is far better than using Input cells (or cell> group header cells). Mathematica won't try to evaluate Text cells, the text> will wrap properly and adjust better to the notebook width if you change it.> You can also check the spelling of words by putting the cursor after a word> and using Ctrl-K. (In an Input cell Mathematica doesn't use the dictionary,> but uses the table of symbols instead and hence it won't check spelling.)> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ ==== =Solve[youre equation, p1, VerifySolutions->True] will return a solution. So willSolve[Rationalize[your equation],p1].Andrzej KozlowskiToyama International UniversityJAPAN inside a program I need to solve this linear equation in terms of p1.> However something odds happens. Sometimes the solution is computed and> sometimes the result is empty [I mean no output...]. Is this a bug of > the> solve command or am I doing something wrong? The problem is robust to:> changing name to the variables and other makeups..> David ps: Sorry for the stupid way in which I copied the command... Solve[(x^2*((-0.9*x^7*(p^2*(-1 - 5.8*x^6 - 14.010000000000002*x^12 -> 18.04*x^18 - 13.06*x^24 -> 5.040000000000001*x^30 - 0.81*x^36) +> x*(7.777777777777779 - 9.074074074074076*x +> 30.333333333333336*x^6 -> 21.51851851851852*x^7 -> 16.333333333333336*x^8 +> 44.33333333333334*x^12 +> 3.188888888888883*x^13 -> 65.68333333333332*x^14 +> 28.777777777777786*x^18 +> 47.937037037037044*x^19 -> 100.10000000000002*x^20 + 7.*x^24 +> 45.6037037037037*x^25 -> 69.53333333333333*x^26 +> 13.299999999999999*x^31 -> 19.833333333333332*x^32 -> 1.0499999999999996*x^38) +> p*(-6 + 8.296296296296296*x -> 28.799999999999997*x^6 +> 32.785185185185185*x^7 +> 9.333333333333336*x^8 -> 55.260000000000005*x^12 +> 49.04777777777776*x^13 +> 38.38333333333334*x^14 -> 52.980000000000004*x^18 +> 34.20518518518518*x^19 +> 60.20000000000001*x^20 -> 25.380000000000003*x^24 +> 11.736296296296294*x^25 +> 43.63333333333334*x^26 - 4.86*x^30 +> 2.8999999999999986*x^31 +> 13.533333333333333*x^32 + 0.81*x^37 +> 1.0499999999999996*x^38)))/(x + 1.9*x^7 +> 0.9*x^13)^2 - ((-1 + p - 7*x^6 + p*x^6 +> 6*x^7)*(1.2962962962962965 - > 3.111111111111112*x^6 +> 9.333333333333336*x^7 - > 10.111111111111114*x^12 +> 22.05*x^13 - 5.703703703703705*x^18 + > 17.15*x^19 +> 5.483333333333331*x^25 + > 1.0499999999999996*x^31 +> p1*x^5*(7.000000000000002 - > 7.000000000000002*x +> 14.000000000000004*x^6 -> 14.000000000000004*x^7 +> 7.000000000000002*x^12 -> 6.999999999999998*x^13) -> 1.166666666666667*p*x^4*x1 -> 3.500000000000001*p*x^10*x1 -> 1.0500000000000003*p*x^11*x1 -> 3.500000000000001*p*x^16*x1 -> 3.150000000000001*p*x^17*x1 -> 1.166666666666667*p*x^22*x1 -> 3.150000000000001*p*x^23*x1 -> 1.0500000000000003*p*x^29*x1))/((1 + > 0.9*x^6)^2*(1 +> x^6)^2)))/(p^2*(1 + x^6)^3) == 0, p1]>Reply-To: murray@math.umass.edu ==== =For all names, perhaps: Names[*`*]For names you defined at a normal session (without changing to some other context than the default Global`): Names[Global`*]> IIRC, there is a way to get a list of all the symbols defined in the > currently running session. I can't seem to find the reference to that > command. Could somone point me in the direction of documentation which > will tell me how to get information about the current session?> TIA,> -- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375 ==== => For all names, perhaps:> Names[*`*]> For names you defined at a normal session (without changing to some> other context than the default Global`):> Names[Global`*]> IIRC, there is a way to get a list of all the symbols defined in the> currently running session. I can't seem to find the reference to that> command. Could somone point me in the direction of documentation which> will tell me how to get information about the current session?> TIA,> I think I asked the wrong question. I'll have to look at things some more. What you gave me resulted in far more than I was looking for.http://public.globalsymmetry.com/proprietary/com/wri/ system-symbols.htmlhttp://66.92.149.152/proprietary/com/wri/ system-symbols.htmlI think I really hosed the code for generating that table. I used 5 lines. I probably didn't need more than two, but I'm too tired right now to think about it. Mathematica is totaly awesome when it comes to what it was intended for. They really need to rent a Troll for a few months and fix this interface. Qt will run on just about anything. Heck, my Win-XP partition runs XFree86, with the KDE, or it did when I booted into XP a month ago.STH ==== =?*does the trick. You can limit it to Global variables with?Global`*Bobby-----Original Message-----Sender: steve@smc.vnet.netApproved: Steven M. Christensen , Moderator ==== =Well, first of of all, your using SetAccuracy and SetPrecision does nothing at all here, since they do not change the value of a or b. You should use a = SetAccuracy[a, Infinity] etc. But even then you won't get the same answer as when you use exact numbers because of the way you evaluate f. Here is the order of evaluation that will give you the same answer, and should explain what is going on:f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121* b^4 - 2) + 5.5*b^8 + a/(2*b), Infinity];a = 77617.; b = 33096.;a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity];f 54767-(-----) 66192Andrzej KozlowskiToyama International UniversityJAPAN> Could someone explain what is going on here, please? In[1]:=> a = 77617.; b = 33096.; In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + > a/(2*b) In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=> f Out[6]=> -1.1805916207174113*^21 In[7]:=> a = 77617; b = 33096; In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + > (55/10)*b^8 + a/(2*b) In[9]:=> g Out[9]=> -(54767/66192) In[10]:=> N[%] Out[10]=> -0.8273960599468214> PK> ==== =Andrzej, Bobby, PeterIt looks as if using SetAccuracy succeeds here because the inexact numbersthat occur have finite binary representations. If we change them slightly toavoid this then we have to use Rationalize:1) Using SetAccuracy Clear[a,b,f] f=SetAccuracy[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/(2*b), Infinity]; a=77617.1; b=33096.1; a=SetAccuracy[a,Infinity];b=SetAccuracy[b,Infinity ]; f - 15640321149084868351974949239896188679725401538739519428131155 14949389123623452500771916869370459119776018798804630436149786 9199129319625743010292363124675/ 10867106143970760551000357827554793888198143135975649579607989 867743572824016 06539536129829321813712324363677397376040962) Rewriting as fractions a=776171/10; b=330961/10; f=33374/100*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+54/10*b^8+a/(2 *b) -(5954133808997234115690303589909929091649391296257/ 41370125000000)3) Using Rationalize Clear[a,b,f]f=Rationalize[333.74*b^6+a^2*(11*a^2*b^2-b^6-121* b^4-2)+5.4*b^8+a/(2*b),0]; a=77617.1; b=33096.1; a=Rationalize[a,0];b=Rationalize[b,0]; f -(5954133808997234115690303589909929091649391296257/ 41370125000000)I use Rationalize[. , 0] besause of results like Rationalize[3.1415959] 3.1416 Rationalize[3.1415959,0] 31415959/10000000--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> Well, first of of all, your using SetAccuracy and SetPrecision does> nothing at all here, since they do not change the value of a or b. You> should use a = SetAccuracy[a, Infinity] etc. But even then you won't> get the same answer as when you use exact numbers because of the way> you evaluate f. Here is the order of evaluation that will give you the> same answer, and should explain what is going on: f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*> b^4 - 2) + 5.5*b^8 + a/(2*b), Infinity]; a = 77617.;> b = 33096.; a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity]; f 54767> -(-----)> 66192 Andrzej Kozlowski> Toyama International University> JAPAN> Could someone explain what is going on here, please?> > In[1]:=> a = 77617.; b = 33096.;> > In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity];> > In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 +> a/(2*b)> > In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity];> > In[6]:=> f> > Out[6]=> -1.1805916207174113*^21> > In[7]:=> a = 77617; b = 33096;> > In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> (55/10)*b^8 + a/(2*b)> > In[9]:=> g> > Out[9]=> -(54767/66192)> > In[10]:=> N[%]>> Out[10]=> -0.8273960599468214> > PK> > ==== => Integrate[BesselJ[1, x]*BesselJ[0, x], {x, 0, Infinity}] is equal to 1/2, and Mathematica 4.1 for Microsoft Windows> (November 2, 2000) does it correctly, while Mathematica 4.2> for Microsoft Windows (February 28, 2002) concocts a strange> mixture of a wrong divergence message and the warning that> it cannot check the convergence [should I trust to the second> warning? or the first?]In[6]:=Integrate[BesselJ[1, x]*BesselJ[0, x], {x, 0, Infinity}]Out[6]=1/2In[7]:=Out[7]=4.2 for Mac OS X (June 4, 2002)Andrzej KozlowskiToyama International UniversityJAPAN ==== =That should read ...denominator of the expression for p1... Bob>You might find it more robust (and the results cleaner) if you Simplify>the >equation prior to using Solve. Such as>>Solve[eqn // Rationalize // Simplify, p1]>>However, if you are assigning values to p or x prior to using Solve, there>>may not be a solution. That is, for whenever the numerator of the expression>>for p1 would be zero, e.g., >>p = (-6 x^7 + 7 x^6 +1)/(x^6 + 1).>Bob Hanlon ==== => The expression for W[m_,n_] returned by Mathematica is wrong. To prove, just substitute m = n = 0 which is exactly what you had done> and observe that the output you had had> W[0,0]=-(2 EulerGamma + Log[4] + 4 PolyGamma[0, 1/2])/(2 Pi)> = 0.84564> was incorrect. The correct answer is 1/2.> Mathematica can handle the numeric integration successfully> In[1] := NIntegrate[BesselJ[1, x]*BesselJ[0, x], {x, 0, Infinity},> Method -> Oscillatory]> (* The warnings are skipped *)> Out[1] = 0.5You'll find that W[m=1,n=0]=1/2, so Mathematica gets that right. W[0,0]diverges. Mathematica gets that wrong.I note that Mathematica yields a result forIntegrate[BesselJ[m, a*x]*BesselJ[n, b*x], {x, 0, Infinity}]that appears to agree with formula 6.512(1) of Gradshteyn and Ryshik (4thed., 1965), including the condition b True]If the zi's need to be scaled, then you can do something like this:colorfn = Hue[.67#]&;With[{ m = {Min[#],Max[#]}&@vals }, Show[Graphics[ {colorfn[#[[3]]], PointSize[.01], Point[{#[[1]],#[[2]]}]}]& /@ (data /. {x_,y_,z_} -> {x, y, (z-m[[1]])/(m[[2]]-m[[1]])}), Axes -> True]]---Selwyn Hollis> I have a list of points l1={xi,yi,zi} how can I make a 2D list plot of > ==== =John,It is easier to do without ListPlot:Make some data,dat= Table[Random[],{10},{3}];Show[Graphics[{PointSize[.05],{Hue[2 /3#3],Point[{#1,#2}]}&@@@dat} ], Frame->True ];If the points need to be joined then something likeShow[Graphics[{ Line /@Partition[dat[[All,{1,2}]],2,1], PointSize[.05],{Hue[2/3#3],Point[{#1,#2}]}&@@@dat } ], Frame->True ];--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> I have a list of points l1={xi,yi,zi} how can I make a 2D list plot of ==== =A few years ago we made a package that do just this. Seehttp://cern.ch/jowett/Mathematica/Graphics/ ColorListPlot.htmlThe type of plot you want is covered in the section Examples thenThree-dimensional data. The Introduction gives links for downloading thepackage.JMJ> I have a list of points l1={xi,yi,zi} how can I make a 2D list plot of ==== =Your problem can be solved in numerous ways of course, try something like .:Module[ { data=Flatten[Table[{x,y,Random[]},{x,10},{y,10}],1] }, Show[ Graphics[ { AbsolutePointSize[10], data/.{x_,y_,z_}[Rule]{Hue[z],Point[{x,y}]} } ] ,AspectRatio[Rule]Automatic ] ]Note that you can replace the main part, ie the transforming rule from pointlists to colored point directives with a function for example .:{Hue[#3],Point[{#1,#2}]}&@@@databye,Borut| I have a list of points l1={xi,yi,zi} how can I make a 2D list plot ofReply-To: kuska@informatik.uni-leipzig.de ==== =data = Table[{Random[], Random[], Random[]}, {20}];Show[Graphics[ {Hue[Last[#]], Point[Take[#, 2]]} & /@ data, Axes -> True ] ] Jens> I have a list of points l1={xi,yi,zi} how can I make a 2D list plot of ==== =input = 5e+5x1+2e-1x2;StringJoin[Characters[input] //. e -> *10^]5*10^+5x1+2*10^-1x2ToExpression[%]500000*x1 + x2/5Bobby Treat-----Original Message-----should be transcribed into 5 10^5 x1 + 0.2 x2.Chuck ==== =Neither SetAccuracy[expr,n] nor SetPrecisions[expr,n] modify expr. These functions modify the prinout not the internal representation. So, the first computation of f is done with approximate numbers and doesn't result in a correct answer due to approximate arithmetic.By assigning a rational expression to each of the variables, you have made them exact numbers and Mathematica responds with an exact solution.>Could someone explain what is going on here, please?>>In[1]:= a = 77617.; b = 33096.;>>In[2]:= SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];>SetPrecision[a, Infinity]; SetPrecision[b, Infinity];>>In[4]:= f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +>5.5*b^8 + a/(2*b)>>In[5]:= SetAccuracy[f, Infinity]; SetPrecision[f, Infinity];>>In[6]:= f>>Out[6]= -1.1805916207174113*^21>>In[7]:= a = 77617; b = 33096;>>In[8]:= g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +>(55/10)*b^8 + a/(2*b)>>In[9]:= g>>Out[9]= -(54767/66192)>>In[10]:= N[%]>>Out[10]= -0.8273960599468214>PK> ==== =SetAccuracy. However, I still don't understand why the order in which we set the accuracies for f, a, and b matters.In[1]:=f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b), Infinity]; a = SetAccuracy[77617., Infinity]; b = SetAccuracy[33096., Infinity]; In[4]:=fOut[4]=-(54767/66192)In[5]:=f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b), Infinity] Out[5]=1180591620717411303424Similarily:In[1]:=f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 50]; a = SetAccuracy[77617., 100]; b = SetAccuracy[33096., 100]; In[4]:=fOut[4]=-0.8273960599468212641107299556`11.4133In[5]:= f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b), 100]; Out[5]=1.180591620717411303424`121.0721*^21-PK ==== =Hallo,I have the problem, that I want to determine the numerical solution of a double integral, like e.g. the following:<< Statistics`ContinuousDistributions`ndist = NormalDistribution[0, 1];N[Sigma^2/(Abs[Mu_1^2 - Mu_2^2]) Integrate[(Integrate[1/y_1 1/(y - y_1) PDF[ndist, d*Log[y_1] + c*Log[y - y_1] + f]*PDF[ndist, Sigma*(c*Log[y_1] + d*Log[y - y_1] + g)], {y_1,0,y}]), {y,0,Lambda}]]wherebyLambda := 3;Mu_1 := 4;Mu_2 := 5;Sigma := 0.25;a = 1/2 (Mu_1^2 + Mu_2^2/Sigma^2)b = 1/2 (Mu_2^2 + Mu_1^2/Sigma^2)c = -Mu_2/(Mu_1^2 - Mu_2^2)d = -Mu_1/(Mu_2^2 - Mu_1^2)f = d*a + c*bg = c*a + d*bSorry for the poor code... The problem is, that Mathematica doesn't give me a result (after waiting 2 hours I turned my machine off).Thus, the question is, if there is still a possibility of solving such complicated expressions...TIA,Sven. ==== =I am trying to solve a system of simultaneous equations with 26 variablesand 14 equations (the 12 free variables can be any of the 26 from the eqns..preferably ones that will minimize the computation time for the other 14).These equation are not linearly related.. the highest degree in any one eqnis degree 4 i believe.. and there are some cross terms in the equations butnot every equation depends on every variable.. (some are actually rathersimple eqns). Any ideas on how to get started with this using mathematica (any ideas for algorithms)..Anything will be helpful..I can be reached at ngupta2@seas.upenn.eduMany thanks,Nachi ==== =I should add that the solution is over natural numbers.. this willprobably make a big difference..Nachi> I am trying to solve a system of simultaneous equations with 26 variables> and 14 equations (the 12 free variables can be any of the 26 from the eqns..> preferably ones that will minimize the computation time for the other 14).> These equation are not linearly related.. the highest degree in any one eqn> is degree 4 i believe.. and there are some cross terms in the equations but> not every equation depends on every variable.. (some are actually rather> simple eqns). Any ideas on how to get started with this using> mathematica (any ideas for algorithms)..>> Anything will be helpful.. I can be reached at ngupta2@seas.upenn.edu Many thanks, Nachi ==== =This may seem like a trivial issue, but I find it very frustrating. I use variety of intellectual domains. In every package (JBuilder, KMail, Emacs, XEmacs, Mozilla, xterm, Konsole, etc.) the keyboar mapping is a bit differnt from the other. There are certain idioms which I find to be fairly invaraint between these different packages. I tend to use this common subset more than the package specific idioms.Switching from one package to the next can be a very disorienting experience. It can be even trickier to try and copy and paste from one to the next. I also use Ôspecial' characters in certain domains, .8d,?,.81,?,[CapitalYAcute],fi, §, ø, etc. Add to all of this, that I run beta code for just about everything. The function of my keyboard changed like the weather. I have spent hours trying to figure out why I can no longer type Ô.9a'. This doesn't even address the problems of switching between character encodings, or keyboard compose modes. The last thing I want to start doing is messing with the key mappings in my user environment. I want to control the way my keyboard works with Mathematica from within the Mathematica runtime environment. That is, the configuration should be loaded when Mathematica loads, and should not impact the rest of my X environment.If I have come across as a bit jaded regarding this issue, there are reasons. There is a history. I don't find keyboard configuration issues interesting. I want my fine keyboard to just work, the way I want it to Shift+point movement = select text.Ctrl+Insert = copyShift+Insert = pasteCtrl+c = copyCtrl+x = cutCtrl+v = pasteShift+End = select to end of line.etc.Yes, I said I use XEmacs, and Emacs. Yes (X)Emacs is different, but adding yet another alteration with Mathematica is just too much. Is there a way around this?STH ==== =>FrontEndExecute[{> FrontEnd`NotebookWrite[FrontEnd`SelectedNotebook[],> [LeftDoubleBracket][RightDoubleBracket],After]}] FrontEndExecute[{ FrontEnd`NotebookWrite[FrontEnd`SelectedNotebook[], [LeftDoubleBracket][RightDoubleBracket],After], FrontEnd`SelectionMove[FrontEnd`SelectedNotebook[], Previous, Character]}]orFrontEndExecute[{ FrontEnd`NotebookWrite[FrontEnd`SelectedNotebook[], [LeftDoubleBracket][SelectionPlaceholder][RightDoubleBracket] , Placeholder]}]----------------------------------------------- ---------------Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== =I'm trying to address the special issues related to using Mathematica on the would not if I used a Windows system. These are typically not all that big if a problem _once I figure out what's going on_. What I hope to do is collect all such matters and document them effectively in something like a haven't discussed here http://66.92.149.152/proprietary/com/wri/index.html I'm interested in hearing what you have to say. Of particular interest are the issues faced by a person who is not familiar with the technical aspects would help make this less painful?STHReply-To: jmt@dxdydz.net ==== =See the MathLink API for C, or the JLink API for java.JLink is easier to use, MathLink is a lower level but native interface. JLink is built on MathLink.As far as I know, the perl API Math::ematica has not been upgraded to Mathematica 4.> Is it possible to get a document of the description of how to> interface with the kernel? Kind of what should an interface say to the> kernel and how to connect to it.> Paulo> ==== =Is it possible to get a document of the description of how tointerface with the kernel? Kind of what should an interface say to thekernel and how to connect to it.Paulo ==== =for your extensive answer but I still have some doubts about convergence of the following integral (m,nintegrers>=0)W[m_,n_]:=Integrate[BesselJ[m, x]*BesselJ[n, x], {x, 0, Infinity}]for wich Mathematica gives the close form W[m_,n_]:= -Cos[(m-n)Pi/2]/(2 Pi)* ( 2 EulerGamma + Log[4] + PolyGamma[0, 1/2(1 + m - n)] + PolyGamma[0, 1/2(1 - m + n)] + 2PolyGamma[0, 1/2(1 + m + n)] )You say this integral is convergent to 1/2 for m=0 and n=1.Also Mathematica agrees to you since for m>=0W[m,m+1]=1/2W[m,m+3]=-1/2Numerically we haveNIntegrate[BesselJ[0, x]*BesselJ[1, x], {x, 0, Infinity}]NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy....0.597973NIntegrate[BesselJ[0, x]*BesselJ[1, x], {x, 0, Infinity}, Method ->Oscillatory]NIntegrate::ploss : ....0.5So I define also the corresponding numeric definitionNW[m_, n_] := NIntegrate[BesselJ[m, x]*BesselJ[n, x], {x, 0, Infinity},Method -> Oscillatory]THEORYThe integral is the critical case of Weber-Schafheitlin integral(see Watson book on Bessel function p.402, or Ryzhik-Gradshteyn 6.574(2)).According to this theoryWS[m_,n_,p_]:=Integrate[BesselJ[m, x]*BesselJ[n, x] x^-p, {x, 0, Infinity}]= A/BwhereA=Gamma[p]*Gamma[(n+m-p+1)/2]B=2^p Gamma[(n-m+p+1)/2]Gamma[(n+m+p+1)/2]Gamma[(m-n+p+1)/2]By the presence of Gamma[p] in numerator A, in the case p=0 as in W[m,n]all these integrals are divergent since Gamma[0]=Infinity.The integral exist if m+n+1 > p > 0.ASYMPTOTICSThe Watson theory is in conßict with Mathematica and your notes accordingwhichthe asyntotic trend 1/x of the integrand in W[m,n] is enough forconvergernce. I divide the integral in two partsWasy[m_,n_,a_]=NIntegrate[BesselJ[0, x]*BesselJ[1, x], {x, 0, a]+ NIntegrate[BesselJ[0, x]*BesselJ[1, x], {x, a, Infinity}]and if a>>1 I use asyntotic expansion of Bessel function in the secondintegralso that I can writeWasy[m_,n_,a_]= int1[m,n,a]+int2[m,n,a]whereint1[m_,n_,a_]:=NIntegrate[ BesselJ[0, x]*BesselJ[1, x], {x, 0, a]+int2[m_,n_,a_]:=(2/Pi)Integrate[Cos[x-(2m+1)Pi/4]*Cos[x-( 2n+1)Pi/4], {x, a,Infinity}]The first integral is a quite normal finite integral. The second (int2) issingularand according to Mathematica 4.1 int2[m_, n_, a_] := -(1/Pi)*Log[a]*Cos[1/2(m - n)Pi]*]Log[a] + (1/Pi)*CosIntegral[2 a]*Sin[1/2(m+n)Pi] + 1/(2*Pi)*Cos[1/2(m+n)Pi]*(Pi-SinIntegral[2*a]) RESULTSm=1;n=0;a=20.;WS[m,n,0]=divergentW[m,n]=1/2NW[m,n]= 0.5Wasy[m,n,a]=.49816m=2;n=0;a=20.;WS[m,n,0]=divergentW[m,n]= 0.427599NW[m,n]=-2.43818Wasy[m,n,a]=-1.48052m=3;n=1;a=20.;WS[ m,n,0]=divergentW[m,n]=0.639806NW[m,n]=-2.31957Wasy[m,n,a]=- 1.26822m=4;n=0;a=20.;WS[m,n,0]=divergentW[m,n]=-.852012NW[m,n ]=1.45786Wasy[m,n,a]=1.06835The cases W[m,m+1],W[m,m+3] well agrre with the numerical counterpart.Other case are doubtfully.I think the main problem is the convergence of this kind of integrals.Any suggestion will be well considerd.RobertRoberto BrambillaCESIVia Rubattino 5420134 Milanotel +39.02.2125.5875fax +39.02.2125.5492rlbrambilla@cesi.it ==== =On Sun, 29 Sep 2002 09:35:41, in the message Re: A Bessel integral,VB>> The expression for W[m_,n_] returned by Mathematica is wrong.VB>>VB>> To prove, just substitute m = n = 0 which is exactly what you had doneVB>>VB>> and observe that the output you had hadVB>>VB>> W[0,0]=-(2 EulerGamma + Log[4] + 4 PolyGamma[0, 1/2])/(2 Pi)VB>>VB>> = 0.84564VB>>VB>> was incorrect. The correct answer is 1/2. ^^^^^^^^^^^^^^^^^^^^^^^^^^TB> W[0,0]diverges. Mathematica gets that wrong.(That my terrible bug shows how it is dangerous to do severalposting to the MathGroup before sending them ;-)Why sure, you are right, the integral Integrate[BesselJ[0, z]^2, {z, 0, Infinity}]diverges because the integrand is bounded everywhereover the integration region and decays at z -> Infinityas Cos[Pi/4 - z]^2/z + o(z), that is as In[1] := Expand[TrigExpand[Cos[Pi/4 - z]^2/z]] // InputForm Out[1] = 1/(2*z) + (Cos[z]*Sin[z])/zwhich means that the integral Integrate[BesselJ[0, z]^2, {z, 0, x}]diverges logarithmically in x.By the way, the main term of Expand[Normal[Series[BesselJ[0, z], {z, Infinity, 1}]]^2]is (2*Cos[Pi/4 - z]^2)/(Pi*z) which conveys the suggestion thatwe should try it, too.This reveals us another integral which Mathematica 4.1 fails to calculate In[1] := Integrate[Cos[Pi/4 - z]^2/z, {z, 1, Infinity}] // N Out[1]= -0.0173083 Out[2]= 4.1 for Microsoft Windows (November 2, 2000)but Mathematica 4.2 handles correctly In[1] := Integrate[Cos[Pi/4 - z]^2/z, {z, 1, Infinity}] Out[1] = Integrate::idiv: Integral of... does not converge on {1, Infinity). Out[2]= 4.2 for Microsoft Windows (February 28, 2002)Even simpler, In[1] := Integrate[Cos[z]^2/z, {z, 1, Infinity}] Out[1] = -EulerGamma/2 - Log[2]/2 + (EulerGamma - CosIntegral[2] + Log[2])/2 Out[2]= 4.1 for Microsoft Windows (November 2, 2000)which is wrong while Mathematica 4.2 works excellent In[1] := Integrate[Cos[z]^2/z, {z, 1, Infinity}] Out[1] = Integrate::idiv: Integral of...does not converge on {1, Infinity). Out[2]= 4.2 for Microsoft Windows (February 28, 2002)Best wishes,Vladimir BondarenkoMathematical DirectorSymbolic Testing GroupWeb : http://www.CAS-testing.org/ http://maple.bug-list.org/VER2/ (under tuning) http://maple.bug-list.org/VER3/ (under tuning) http://maple.bug-list.org/VER1/ (under tuning) http://www.beautyriot.com/ (teamwork) http://www.ohaha.com/ (teamwork) Voice: (380)-652-447325 Mon-Fri 9 a.m. - 6 p.m.Mail : 76 Zalesskaya Str, Simferopol, Crimea, Ukraine ==== =John,You could do something like this.points = With[{del = 2Pi/24}, Table[{Cos[t], Sin[t], t/(2Pi)}, {t, 0, 2Pi - del, del}]];Show[Graphics[ {AbsolutePointSize[7], {Hue[Last[#]], Point[#[[{1, 2}]]]} & /@ points, Line[Drop[#, -1] & /@ points]}], AspectRatio -> Automatic, Background -> GrayLevel[0.4], ImageSize -> 400];When I made the point list I made certain the z values were between 0 and 1.Otherwise you will have to define a color function that will associate aproper color with each value of z.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Approved: Steven M. Christensen , Moderator ==== =Many thanks to all who replied.The original problem was as follows:In a presentation I wish to use Plot to generate a sequence of frames andthen animate them. The problem is that the audience sees the animationtwice. Once when the frames are being generated and then again after I haveclosed the group and double clicked on the top graphic. However, the firstshowing during generation is enough (but uncontrolled). Is it possible to tidy up the generation of the graphic so that it becomesthe animation?There were two main solutions which I now apply to my real problem and notthe simple, generic, problem in the original post. The real problem was how to build up a probably density function (PDF) inreal time. In the examples below I redraw the PDF every time I add 10points.Initialise<500] ], {500}]; NotebookWrite[EvaluationNotebook[],Cell[CellGroupData[graphs, Closed]]]; SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndExecute[{FrontEndToken[EvaluationNotebook[], SelectionAnimate]}] ]This solution works but it generates 500 frames and sometimes exceeds thememory. The paradigm here is generate all frames, then animate all frames. Wereally need a loop that does: generate next frame, delete last frame, show next frameIs it possible to do this?Bobby Treat also offered a solution involving SelectionMove.The second solution was from Jerry Blimbaum and uses JAVAInstallJava[];UseFrontEndForRendering = False;createWindow[] := Module[{frame}, frame = JavaNew[com.wolfram.jlink.MathFrame, Probability DensityFunction]; drawArea = JavaNew[com.wolfram.jlink.MathCanvas]; drawArea@setUsesFE[UseFrontEndForRendering]; drawArea@setSize[800, 600];JavaBlock[frame@setLayout[JavaNew[java.awt.BorderLayout] ]; frame@add[drawArea, ReturnAsJavaObject[BorderLayout`CENTER]]; frame@pack[]; frame@setSize[800, 600]; frame@setLocation[100, 100]; JavaShow[frame]];frame]ClearAll[drawString]; drawString[] :=( data=Flatten[Join[data,RandomArray[wb,10]]]; freq=BinCounts[data,{0,50,1}]; BarChart[Transpose[{freq,midpts}],ImageSize ->500, DisplayFunction -> Identity]) LoadJavaClass[java.lang.Thread]; AnimationPlot[n_] := JavaBlock[ Block[{frm}, frm = createWindow[]; Do[(obj = drawString[]; drawArea@setMathCommand[obj]; drawArea@repaintNow[]; Thread@sleep[];) ,{n} ]]]data={}; AnimationPlot[500];This solution works and does not use significant memory. However, we havenot managed to control the speed of this animation. The JAVA code sleep doesnot work nor does the use of a Mathematica Pause which always rounds up toan integer (is this a bug?).Hugh Goyder ==== =>>I need a loop that goes generate next frame, delete old frame, shownew frame so that the number of frames does not become excessive.I'm pinging the group for that. I'm just following along in this, otherthan the trick of taking advantage of the half-period.I'll be very interested in a solution myself, as I frequently run out ofmemory in animations of fairly modest size -- despite having 1024MB ofRAM.Bobby-----Original Message-----need a loop that goes generate next frame, delete old frame, show new frameso that the number of frames does not become excessive.Any ideas?Hugh Goyder-----Original Message----- graphs = Rest@Join[half, Rest@Reverse@half]; NotebookWrite[EvaluationNotebook[], Cell[CellGroupData[graphs,Closed]]]; SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndExecute[{FrontEndToken[EvaluationNotebook[], SelectionAnimate]}]]Bobby-----Original Message----->showing during generation is enough (but uncontrolled).>>Hugh GoyderThis creates a graphics cell from a graphics expression.GraphicCell[graphics_] := Cell[GraphicsData[PostScript, DisplayString[graphics]],Graphics]cellgroup.Block[{$ DisplayFunction=Identity, graphs}, graphs = Table[GraphicCell[ Plot[Sin[t]*Sin[x], {x, 0, Pi}, PlotRange -> {{0, Pi}, {-1,1}}, ImageSize -> 400]], {t,0,15,.1}]; NotebookWrite[EvaluationNotebook[],Cell[CellGroupData[graphs, Closed]]]; SelectionMove[EvaluationNotebook[], All, GeneratedCell]; FrontEndExecute[{FrontEndToken[EvaluationNotebook[], SelectionAnimate]}] ]------------------------------------------------------------ --Omega ConsultingThe final answer to your Mathematica needsSpend less time searching and more time finding.http://www.wz.com/internet/Mathematica.html ==== = Actually, we don't know whether SetAccuracy succeeds, because we don'tknow how inexact those numbers really are. If they are known to moredigits than shown in the original post, they should be entered with asmuch precision as they deserve. If not, there's no trick or algorithmthat will give the result precision, because the value of f really isin the noise. That is, we have no idea what the value of f should be.Mathematica's failing is in returning a value without pointing out thatit has no precision.Bobby-----Original Message----- f=SetAccuracy[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/(2*b), Infinity]; a=77617.1; b=33096.1; a=SetAccuracy[a,Infinity];b=SetAccuracy[b,Infinity ]; f - 15640321149084868351974949239896188679725401538739519428131155 14949389123623452500771916869370459119776018798804630436149786 9199129319625743010292363124675/ 10867106143970760551000357827554793888198143135975649579607989 867743572824016 06539536129829321813712324363677397376040962) Rewriting as fractions a=776171/10; b=330961/10; f=33374/100*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+54/10*b^8+a/(2 *b) -(5954133808997234115690303589909929091649391296257/ 41370125000000)3) Using Rationalize Clear[a,b,f]f=Rationalize[333.74*b^6+a^2*(11*a^2*b^2-b^6-121* b^4-2)+5.4*b^8+a/(2*b),0]; a=77617.1; b=33096.1; a=Rationalize[a,0];b=Rationalize[b,0]; f -(5954133808997234115690303589909929091649391296257/ 41370125000000)I use Rationalize[. , 0] besause of results like Rationalize[3.1415959] 3.1416 Rationalize[3.1415959,0] 31415959/10000000--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> Well, first of of all, your using SetAccuracy and SetPrecision does> nothing at all here, since they do not change the value of a or b. You> should use a = SetAccuracy[a, Infinity] etc. But even then you won't> get the same answer as when you use exact numbers because of the way> you evaluate f. Here is the order of evaluation that will give you the> same answer, and should explain what is going on: f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*> b^4 - 2) + 5.5*b^8 + a/(2*b), Infinity]; a = 77617.;> b = 33096.; a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity]; f 54767> -(-----)> 66192 Andrzej Kozlowski> Toyama International University> JAPAN> Could someone explain what is going on here, please?> > In[1]:=> a = 77617.; b = 33096.;> > In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity];> > In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 +> a/(2*b)> > In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity];> > In[6]:=> f> > Out[6]=> -1.1805916207174113*^21> > In[7]:=> a = 77617; b = 33096;> > In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> (55/10)*b^8 + a/(2*b)> > In[9]:=> g> > Out[9]=> -(54767/66192)> > In[10]:=> N[%]>> Out[10]=> -0.8273960599468214> > PK> > ==== =It seems clear to me that what Allan and what you mean by succeeds here refer to quite different things and your objection is therefore beside the point. There are obviously two ways in which one can interpret the original posting. The first interpretation, which Allan and myself adopted, was that the question concerned purely the computational mechanism of Mathematica. Or, to put it in other words, it was why are the results of these two computations not the same?. In this sense success means no more than making Mathematica return the same answer using the two different routes the original poster used.You on the other hand choose to assume that the posting shows that its author does not understand not just the mechanism of significance arithmetic used by Mathematica but also computations with inexact numbers in general. I do not think this is necessarily the correct assumption. I also don't see that Mathematica is doing anything wrong. After all, one can always check the accuracy of your answer:In[1]:=a = 77617.; b = 33096.;In[2]:=f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 + a/(2*b)In[3]:=fOut[3]=-1.1805916207174113*^21In[4]:=Accuracy[ %]Out[4]=-5which tells you that it can't be very reliable. What more do you demand?AndrzejAndrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> Actually, we don't know whether SetAccuracy succeeds, because we > don't> know how inexact those numbers really are. If they are known to more> digits than shown in the original post, they should be entered with as> much precision as they deserve. If not, there's no trick or algorithm> that will give the result precision, because the value of f really is> in the noise. That is, we have no idea what the value of f should > be. Mathematica's failing is in returning a value without pointing out that> it has no precision. Bobby -----Original Message-----> Sent: Monday, September 30, 2002 11:59 AM Andrzej, Bobby, Peter It looks as if using SetAccuracy succeeds here because the inexact> numbers> that occur have finite binary representations. If we change them> slightly to> avoid this then we have to use Rationalize: 1) Using SetAccuracy Clear[a,b,f]> f=SetAccuracy[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/ > (2*b),> Infinity]; a=77617.1;> b=33096.1; a=SetAccuracy[a,Infinity];b=SetAccuracy[b,Infinity ]; f> - 15640321149084868351974949239896188679725401538739519428131155 14949> 3891236234 52500771916869370459119776018798804630436149786919912931962574 301029236 > 3> 1246> 75 / > 10867106143970760551000357827554793888198143135975649579607989 867743572> 8240> 16> 0653953612982932181371232436367739737604096 2) Rewriting as fractions a=776171/10;> b=330961/10; f=33374/100*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+54/10*b^8+a/(2 *b) -(5954133808997234115690303589909929091649391296257/> 41370125000000) 3) Using Rationalize Clear[a,b,f]> f=Rationalize[333.74*b^6+a^2*(11*a^2*b^2-b^6-121*b^4-2)+5.4*b ^8+a/ > (2*b),> 0]; a=77617.1;> b=33096.1; a=Rationalize[a,0];b=Rationalize[b,0]; f -(5954133808997234115690303589909929091649391296257/> 41370125000000)> I use Rationalize[. , 0] besause of results like Rationalize[3.1415959] 3.1416 Rationalize[3.1415959,0] 31415959/10000000> --> Allan ---------------------> Allan Hayes> Mathematica Training and Consulting> Leicester UK> www.haystack.demon.co.uk> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198> Well, first of of all, your using SetAccuracy and SetPrecision does> nothing at all here, since they do not change the value of a or b. You> should use a = SetAccuracy[a, Infinity] etc. But even then you won't> get the same answer as when you use exact numbers because of the way> you evaluate f. Here is the order of evaluation that will give you the> same answer, and should explain what is going on: f = SetAccuracy[333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*> b^4 - 2) + 5.5*b^8 + a/(2*b), Infinity]; a = 77617.;> b = 33096.; a = SetAccuracy[a, Infinity]; b = SetAccuracy[b, Infinity]; f 54767> -(-----)> 66192 Andrzej Kozlowski> Toyama International University> JAPAN> Could someone explain what is going on here, please? In[1]:=> a = 77617.; b = 33096.; In[2]:=> SetAccuracy[a, Infinity]; SetAccuracy[b, Infinity];> SetPrecision[a, Infinity]; SetPrecision[b, Infinity]; In[4]:=> f := 333.75*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) + 5.5*b^8 +> a/(2*b) In[5]:=> SetAccuracy[f, Infinity]; SetPrecision[f, Infinity]; In[6]:=> f Out[6]=> -1.1805916207174113*^21 In[7]:=> a = 77617; b = 33096; In[8]:=> g := (33375/100)*b^6 + a^2*(11*a^2*b^2 - b^6 - 121*b^4 - 2) +> (55/10)*b^8 + a/(2*b) In[9]:=> g Out[9]=> -(54767/66192) In[10]:=> N[%] Out[10]=> -0.8273960599468214> PK> ==== =Here's a refinement of my previous post. Everything is wrapped up in a function named DotPlot, which takes the following options:ColorFunction (default: Hue)ColorFunctionScaling (default: True)DotSize (default: 0.01)You can also provide other options such as Axes, Frame, Background, etc. Needs[Utilities`FilterOptions`]; DotPlot[data_?MatrixQ, opts___Rule] := Module[{colorfn, scale, dotsize}, colorfn = ColorFunction/.{opts}/.{ColorFunction->Hue}; scale = ColorFunctionScaling/.{opts}/.{ColorFunctionScaling->True}; dotsize = DotSize/.{opts}/.{DotSize->.01}; With[{m = If[scale,{Min[#],Max[#]}&@Transpose[data][[3]], {0,1}]}, Show[(Graphics[ {colorfn[#[[3]]],PointSize[dotsize],Point[{#[[1]],#[[2]]}]}]& )/@ (data /. {x_,y_,z_}-> {x,y,(z-m[[1]])/(m[[2]]-m[[1]])}), FilterOptions[Graphics, opts] ] ] ]Example: vals = Table[{Random[], Random[], .5 Random[]}, {100}]; DotPlot[vals, ColorFunction -> (Hue[#, 1, 1-#] & ), ColorFunctionScaling -> False, DotSize -> 0.02, Frame -> True]---Selwyn Hollis ==== =These expressions are condensation of larger ones(about 700 lines or so each) but they illustrate randomsubstitution failures in 4.2. Question: how can thesubstitution Sqrt[...]->Q always be made to work? The help file under ReplaceAll, ReplaceRepeated, etc, does not address this problem.f=B*(A+Sqrt[X+Y+Z])+C/(Sqrt[X+Y+Z]/4*F^2);Print[(f/. Sqrt[X+Y+Z]->Q)//InputForm]; B*(A + Q) + (4*C)/(F^2*Sqrt[X + Y + Z]) (* fails *)g=B*(A+Sqrt[X+Y+Z])+C/(Sqrt[X+Y+Z]*4*F^2);Print[(g/.Sqrt[X+ Y+Z]->Q)//InputForm];B*(A + Q) + C/(4*F^2*Sqrt[X + Y + Z]) (* fails *)h=B*(A+Sqrt[X+Y+Z])+C/(Sqrt[X+Y+Z]+4*F^2); ==== =====> BRIEF> Mathematica seems to support 3 levels of nesting:> section, subsection, and subsubsection.> Q: how can I obtain more levels of nesting?> I typically go 6-7 levels deep.Well, I started by editting the notebook in a text editor(having used Edit Style Sheet to unshare),and I created stylesSub3section ... Sub9section,with Dewey decimal numbering 1.2.3.4.5.6.7.8.9.10I got collapsable group working, by mucking with CellGroupingRules->{SectionGrouping, 100},changing the number.I am not sure what the number is, but I'm guessingit may be a pixel count for the nesting boxesat the left of the screen.I'm a bit worried about whether this is fragile. ==== Was there any way to accomplish this from the GUI?Or was using a text editor mandatory? ==== Related: this exercise makes it obvious that acommon operation is to push down or pull upa whole subtree - e.g. a Subsection becomes aSubsubsection, a Subsubsection becomes aSub3section, etc. The sort of thing that MicrosoftWord does with Outline mode.Q: has anyone got something like Outline modefor Mathematica?I'm tempted to go the other way, and ask if anyonehas a front end that allows Mathematica to be embeddedin Word documents. But that might be a hassle,since Word runs on Windows, and the Mathematicalicence I have access to runs on Suns. ==== => inFile = OpenRead[197-tst.txt]> y = ReadList[inFile, String, 1, RecordLists -> True]> Close[inFile];> This appears to pull in a line. Now I want to take characters > 25 to 110 to get just the stuff I want:> y1=StringTake[y ,{25,110}];> Here's the output. StringTake doesn't seem to work.> -1281.9 -229. 321. 317. 367. -115. 126. > 146. -410. -426.000000EF 75.}, {25, 110}]> It doesn't take loading another package as far> as I can tell from the help. I'm thinking that it doesn't > work because it's trying to work on a list> rather than a string. I've tried Flatten, and other stuff to > try to get to just a string and not a list but> nothing has worked so far. I'm a long way from getting to > those numbers in there but heck, I> can't even get to the string. Can anyone point me in the > right direction?You might try lst = Read[StringToStream[y1], {Word, Table[Number, {16}], Word,Number}]//Flatten;You can then pick the numbers (or words) from the list lst.A quicker alternative might be as follows:-ifile = ReadList[197-tst.txt, {Word, Table[Number, {16}], Word, Number}];Dave. ==== ======================================= Dr. David Annetts EM Modelling Analyst Australia David.Annetts@csiro.au ==== ==================================== ==== =====I was and do have problems reading files Exported files in AdobeIllustrator format (.ai) from Adobe Illustrator 10.0.3.With an upgrade to Adobe Illustrator 10.0.3, I can read EPS filescreated by Mathematica 4.0.1.A message from tech support at Wolfram implies that Adobe Illustratorformat files can be read ONLY if you are using the correct Adobe andWolfram programs. Additionally, Mathematica is going to favor the exportof EPS files (is that clear enough?).My approach to using Mathematica as a source of images for AdobeIllustrator 10.0.3 is:Create the image in MathematicaExport[ImageFileName.eps, theMathematicaImageCreated, EPS]Open the file ImageFileName.eps within Adobe Illustrator 10.0.3Save the file as a .ai fileBe sure to check the ImageSize as it is not often what you toldMathematica. ==== =Have you tried deleting ... Mathematica4.2DocumentationEnglishMainBookBrowserIndex.nbThere are two BrowserIndex files. Only delete the .nb one (or just move itsomewhere else).> What about this problem? I have tried the previous suggestions but none of> them worked. Will Wolfram help us in this problem? ==== =I ran it 10 times on 4.2 with no crashes.> Jens-Peer Kuska tells me that he gets no crash with Mathematica 4.2,however after working> with this program for more than a month, trying every possible permutationand> manipulation, and having it still crash, I am still worried that upgradingto 4.2> won't solve my problem. Can anyone else with 4.2 try running this programfor me a> good number of times, say 3 or 4, and see if they get similar goodresults?> Bernard Gress> Dear Group,> I have a program to take the local polynomial non parametric regression> of two variables. It uses Compile, unfortunately, and regularly, but> inconsistently, causes Mathematica to crash (in Win2K, with I forget> what error, and in Win98/Mathematica4.0 with an invalid memory access from> MathDLL.dll). I am running Mathematica 4.1, and have this problemconsistently> on 4 different machines.> Here is the code, if it doesn't crash the first time, it will the second> or third:> (*> w = Compile[{{xj, _Real, 0}, {XX, _Real, 1}, {YY, _Real, 1}, {h, _Real,> 0},> {nn, _Integer, 0}, {ord, _Integer, 0}},> First[Inverse[Sum[Outer[Times, Table[If[Positive[q], (XX[[i]] - xj)^q,> 1], {q, 0, ord}],> Table[If[Positive[q], (XX[[i]] - xj)^q, 1.], {q, 0,> ord}]*E^(-0.5*((XX[[i]] - xj)/h)^2)], {i, nn}]] .> Sum[(Table[If[Positive[q], (XX[[i]] - xj)^q, 1.], {q, 0, ord}]*YY[[i]])*> E^(-0.5*((XX[[i]] - xj)/h)^2), {i, nn}]]];> *)> (*> !(tt = MemoryInUse[];> ListPlot[Table[{((i + 1))^2, (Timing[> nn = ((i + 1))^2; [Epsilon] = Table[Random[]*3, {i,> nn}];> testX = Table[i* .3 - Random[]*2, {i, nn}];> testY = Table[Sin[i/3] - 2, {i, nn}] + [Epsilon];> Map[w[#, testX, testY, .1 + Random[], nn, 0] &,> testX];])[([1])]/Second}, {i, 15}], PlotJoined ->> True,> PlotLabel -> ];> MemoryInUse[] - tt)> *) ==== =In his not-so-subtle way, Jens-Peer is trying to tell you that since yousee z in the error message, that's what NIntegrate saw too. z is asymbol, and NIntegrate needs numbers. Now I'll have to search onlinefor your original problem, since I deleted my copy long ago... (Excuseme a few minutes...) Hmm... OK, I'm back.Well... there's still a missing (or extra) parenthesis in the definitionof f and a missing bracket in the definition of F, but I also can't seethat you've given z a numerical value. The error shouldn't occur untilyou use F though, since you used SetDelayed. So, the error message goeswith a line you didn't include in your post. However, in your latestpost, the linesNumericQ[z]Falsetell me z is NOT a real number. For instance,NumericQ[1.2]TrueSo, proceeding with the theory that z needs to be numeric, let's tryF[1.2]NIntegrate::itraw:Raw object 1.2` cannot be used as an iterator.NIntegrate[f[y, 1.2], {1.2, 0, Infinity}]NIntegrate::itraw:Raw object !(1.2`) cannot be used as aniterator.As you see, in the definition of F, you've used z as an iterator. Nomatter what the argument z to F is -- number, symbol, whatever -- youcan't use it as an iterator, because it already has an identity, anditerators are stand-ins -- temporary variables that don't exist outside(in this case) NIntegrate. So, as Jens-Peer pointed out, y should havebeen your iterator. (Probably. We don't actually know what you weretrying to do. We only know for sure that z couldn't be the iterator.)So, if I've made the right guesses, the definition for F should beF[z_] := NIntegrate[f[y, z], {y, 0, Infinity}]But... F[z] will still give you an error if z doesn't have a numericalvalue, so it's even better to define F this way:ClearAll[F]F[z_?NumericQ] := NIntegrate[f[y, z], {y, 0, Infinity}]That way, F[z] is left unevaluated if z isn't numeric.I can't go any further, since I don't know the value of f -- because Idon't know where to add or subtract that pesky parenthesis. (I askedstill isn't.)Bobby Treat-----Original Message-----> F[z_?NumericQ]: = NIntegrate[f[y,z], {y, 0, Infinity}]I'm a newbie, bat I mean:*************************In[1]= NumericQ[z]Out[1]=False*************************BTW, z is a real number.--Rob_jack ==== =I'm learning the fine art of patterns and Hold one tricky example at atime.Bobby-----Original Message-----> I want to make a list of all symbols in the Global context, as in> Names[Global`*]> and compute a ByteCount for each symbol's OwnValues -- without> evaluating the symbols.> It seems possible in principle, but I haven't found a way.> Bobby Treat ==== =Here's the fairly useful bit of code I came up with, using Jens-Peer'sbrilliant solution:names = Names[Global`*];counts = ToExpression[#, StandardForm, Hold] & /@ names /. Hold[a_] :> ByteCount[OwnValues[a]];Select[Transpose[{names, counts}], Last@# > 16 &] // TableFormIt tells me how some of my memory is being spent.Bobby Treat-----Original Message-----> I want to make a list of all symbols in the Global context, as in> Names[Global`*]> and compute a ByteCount for each symbol's OwnValues -- without> evaluating the symbols.> It seems possible in principle, but I haven't found a way.> Bobby Treat ==== =>Try deleting ...>Mathematica4.2DocumentationEnglishMainBookBrowserIndex.nb ==== =Jack,Often, what I do when developing a slightly complicated module is to firsttest it after I add each statement L1, L2, etc. But then often I want tomake changes after I have all the statements in. Then to debug I just addtemporary Print statements. For example...myFunction[f_] := Module[ {L1,L2,L3},L1 = ... ;L2 = ... ;Print[{L1, L2}];l3 = ... ;]Sometimes I use multiple Print statements. The only problem with thisapproach is that sometimes the difficulty might be in a subexpression of alonger expression.This forces me to temporarily break out the longer expression into multiplestatements, or perhaps duplicate the subexpression in the Print statement.But I find that the easiest method to track down errors.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/l3 = ... ; final step ]To see what went wrong, I use (* *) selectively as follows:Stage 1myFunction[f_] := Module[ {L1,L2,L3},L1 = ... (*;L2 = ... ;L3 = ... ; final step *) ]Thus I see if L1 worked as expected. The next step is to put (* after L2and see if this works. I continue this til the bitter end and I usuallyfind my errors.My question; The process of moving (* *) step by step through theprogram is quite tedious when the code has lots more lines. What I wouldlike is a meta-program which (like FoldList) does this job for me. Theoutput of this meta-program is the list of outputs of each line in themodule, probably best printed as a column.This sounds like Trace but my problem with Trace is it is terriblydifficult to read. For the not-so-subtle programming I do, the only thingI need is what expression is returned line by line.Any advice? All remarks are appreciated!JackReply-To: kuska@informatik.uni-leipzig.de ==== =does help you ? Jens> I often run into this difficulty: when designing a program, say as a> module, and testing it for various inputs, I get wrong answers. What to> do? I use a method that works for me but may not be the best available.> I want to show my method and then ask a question about how it can be> imporved. (Oh yes, I abandoned Trace a long time ago!)> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... ;> L2 = ... ;> l3 = ... ;> final step> ]> To see what went wrong, I use (* *) selectively as follows:> Stage 1> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... (*;> L2 = ... ;> L3 = ... ;> final step *)> ]> Thus I see if L1 worked as expected. The next step is to put (* after L2> and see if this works. I continue this til the bitter end and I usually> find my errors.> My question; The process of moving (* *) step by step through the> program is quite tedious when the code has lots more lines. What I would> like is a meta-program which (like FoldList) does this job for me. The> output of this meta-program is the list of outputs of each line in the> module, probably best printed as a column.> This sounds like Trace but my problem with Trace is it is terribly> difficult to read. For the not-so-subtle programming I do, the only thing> I need is what expression is returned line by line.> Any advice? All remarks are appreciated!> Jack ==== =I've enhanced the code for PartialEvaluation (see my post, which Iincorrectly attaced to someone else's reply). It is somewhat moreßexible now and does more error checking. It finds the rule inDownValues that matches f[args] (allowing for more than one rule inDownValues); it allows the user to specify the position of the mainCompoundExpression; and it allows the user to specify an expressionthat gets appended to the truncated CompoundExpression (and henceevaluated and returned). The package is just a bit too large to posthere. It can be downloaded from my web site athttp://www.markfisher.net/~mefisher/mma/ mathematica.htmlNevertheless, I can give an outline of the code here (absent the errorchecking stuff).PartialEvaluation[f[args], n, expr]:(* get the DownValues and turn them off *)dv = DownValues[f];DownValues[f] = {};(* find the rule that matches *)matches = Position[MatchQ[f[args], #]& /@ dv[[All, 1]], True];match = dv[[ matches[[1, 1]] ]];(* find the main CompoundExpression *)ppos = Position[match, HoldPattern[CompoundExpression[__]]];pos = First[Sort[ppos]];(* extract, truncate, append to, and reinsert it *)held = Extract[match, pos, Hold];held = ReplacePart[held, Sequence, {1, 0}];held = Take[held, n];held = Join[held, Hold[expr]];held = ReplacePart[Hold[Evaluate[held]], CompoundExpression, {1, 0}];match = ReplacePart[match, held, pos, 1];(* apply the modified rule and restore DownValues *)result = f[args] /. match;DownValues[f] = dv;result--Mark> I often run into this difficulty: when designing a program, say as a> module, and testing it for various inputs, I get wrong answers. What to> do? I use a method that works for me but may not be the best available.> I want to show my method and then ask a question about how it can be> imporved. (Oh yes, I abandoned Trace a long time ago!)> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... ;> L2 = ... ;> l3 = ... ;> final step> ]> To see what went wrong, I use (* *) selectively as follows:> Stage 1> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... (*;> L2 = ... ;> L3 = ... ;> final step *)> ]> Thus I see if L1 worked as expected. The next step is to put (* after L2> and see if this works. I continue this til the bitter end and I usually> find my errors.> My question; The process of moving (* *) step by step through the> program is quite tedious when the code has lots more lines. What I would> like is a meta-program which (like FoldList) does this job for me. The> output of this meta-program is the list of outputs of each line in the> module, probably best printed as a column.> This sounds like Trace but my problem with Trace is it is terribly> difficult to read. For the not-so-subtle programming I do, the only thing> I need is what expression is returned line by line.> Any advice? All remarks are appreciated!> Jack ==== =The following code is my attempt to provide the functionality yourequested. It does some rudimentary error checking, but I haven'ttried very hard to fool it. The code manipulates the DownValues,locating the highest CompoundExpression (see the lines in whichpos is defined), keeping only those expressions specified.DownValues are restored after the expression is evaluated. The trickypart is keeping the CompoundExpression from evaluating while it isbeing manipulated. (See the lines in which held and new aredefined.) I'm not sure I'm doing this part the most elegant way, butit seems to work.(* code starts here *)PartialEvaluation::usage = PartialEvaluation[f[args], n] returnsf[args] where only the first n expressions are evaluated in themainCompoundExpression in DownValues[f]. For example:ntClear[f]ntf[x_] := Module[{a,b}, a=3; b=4; a b x]ntPartialEvaluation[f, 2]n returns 4.PartialEvaluation::dvprob = DownValues[``] is either empty or hasmorethan one element.PartialEvaluation::toobig = There are only `1` expressions inthe CompoundExpression in `2`.PartialEvaluation::noce = There are no CompoundExpressions inDownValues[``].SetAttributes[PartialEvaluation, HoldFirst]PartialEvaluation[f_[args__], n_Integer] := Module[{dv, pos, held, new, eval}, Catch[ dv = DownValues[f]; If[Length[dv] != 1, Message[PartialEvaluation::dvprob, f]; Throw[HoldForm[f[args]]]]; pos = Sort[Position[dv, CompoundExpression]]; If[pos == {}, Message[PartialEvaluation::noce, f]; Throw[HoldForm[f[args]]]]; pos = Drop[First @ pos, -1]; held = Extract[dv, pos, Hold] /. CompoundExpression -> Sequence; If[Abs[n] > Length[held], Message[PartialEvaluation::toobig, Length[held], HoldForm[f[args]]]; Throw[HoldForm[f[args]]]]; new = ReplacePart[dv, Take[held, n] /. Hold[x__] :> Hold[CompoundExpression[x]], pos, 1]; DownValues[f] = new; eval = f[args]; DownValues[f] = dv; eval ]](* code ends here *)--Mark.P.S. The version of this message I posted directly from my newsreaderdidn't show up, so I'm reposting (a slightly improved version) fromGoogle.> Jack,> Often, what I do when developing a slightly complicated module is to first> test it after I add each statement L1, L2, etc. But then often I want to> make changes after I have all the statements in. Then to debug I just add> temporary Print statements. For example...> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... ;> L2 = ... ;> Print[{L1, L2}];> l3 = ... ;> ]> Sometimes I use multiple Print statements. The only problem with this> approach is that sometimes the difficulty might be in a subexpression of a> longer expression.> This forces me to temporarily break out the longer expression into multiple> statements, or perhaps duplicate the subexpression in the Print statement.> But I find that the easiest method to track down errors.> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/> I often run into this difficulty: when designing a program, say as a> module, and testing it for various inputs, I get wrong answers. What to> do? I use a method that works for me but may not be the best available.> I want to show my method and then ask a question about how it can be> imporved. (Oh yes, I abandoned Trace a long time ago!)> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... ;> L2 = ... ;> l3 = ... ;> final step> ]> To see what went wrong, I use (* *) selectively as follows:> Stage 1> myFunction[f_] := Module[ {L1,L2,L3},> L1 = ... (*;> L2 = ... ;> L3 = ... ;> final step *)> ]> Thus I see if L1 worked as expected. The next step is to put (* after L2> and see if this works. I continue this til the bitter end and I usually> find my errors.> My question; The process of moving (* *) step by step through the> program is quite tedious when the code has lots more lines. What I would> like is a meta-program which (like FoldList) does this job for me. The> output of this meta-program is the list of outputs of each line in the> module, probably best printed as a column.> This sounds like Trace but my problem with Trace is it is terribly> difficult to read. For the not-so-subtle programming I do, the only thing> I need is what expression is returned line by line.> Any advice? All remarks are appreciated!> Jack ==== =Mathematica often produces complex resluts. But the problem is not complex:TrySolve[FR == Pi r1^2 - Pi r2^2, r1]It is simple to eliminate it in this case. Just square it.Does someone give me a hint, how to write ra rule for simplify, lik Ted Ersek did inhttp://www.verbeia.com/mathematica/tips/Links/Tricks_lnk_41 .htmlI thin, one has to to replace the patterni Sqrt[-a_]bySqrt[(i Sqrt[-a_])^2]and then one has to simplify it?Peter Klamser ==== =There has been an interesting discussion about using InterpolatingFunctionfor an empirical CDF.If one is willing to sacrifice some theoretical soundness, an empirical CDFmay be computed in a simplified form:simpleEmpiricalCDF[distr_/;VectorQ[distr,NumberQ]] :=With[{nonu=Sort[distr], u=Union[distr]},Transpose[{u,FoldList[Plus,0,(Count[nonu,#]&/ @u)/Length[nonu]]//Rest}]]This code does not return a function, and the result needs someinterpretation. Nevertheless, it may be of some use.data = {0.59, 0.72, 0.47, 0.43, 0.31, 0.56, 0.22, 0.9, 0.96, 0.78, 0.66,0.18, 0.73, 0.43, 0.58, 0.11}(the tie [0.43] will be accounted for in a way that is consistent with sometextbooks)simpleEmpiricalCDF[data]//N returns{{0.11,0.0625},{0.18,0.125},{0.22,0.1875},{0.31,0.25}, {0.43,0.375},{0.47,0.4375},{0.56,0.5},{0.58,0.5625},{ 0.59,0.625},{0.66,0.6875},{0.72,0.75},{0.73,0..8125},{ 0.78,0.875},{0.9,0.9375},{0.96,1.}}A plot may be given with:simpleEmpiricalCDFPlot[distr_/;VectorQ[distr,NumberQ]] :=Module[{res,x,p},res=simpleEmpiricalCDF[distr];x=({#,#}& /@ Transpose[res][[1]])//Flatten;p=({#,#}& /@ Transpose[res][[2]])//Flatten;p= Join[{0},Drop[p,-2],{1}];ListPlot[Transpose[{x,p}],c]]Again, this plot does not reßect theoretical considerations at the lowerand upper end.With regardHermann Meier ==== =Caution: where right- and left-continuity are concerned, Daniel'srelying on undocumented behavior that may change in the next version.Bobby-----Original Message-----that evaluates the empirical CDF given the observations in the list.The function is defined on the entire real line.MakeEmpiricalCDF[list_?(VectorQ[#, NumericQ]&)] := Module[{n, s, a, r, idata}, n = Length[list]; s = Sort[list]; a = Append[s, s[[-1]] + 1]; (* phantom obs. *) r = Range[1/n, 1 + 1/n, 1/n]; (* phantom value 1 + 1/n *) idata = Last /@ Split[Transpose[{-a, r}], #1[[1]] == #2[[1]]&]; (* -a is the first sign change *) Block[{x}, Function @@ {x, Which @@ { x < s[[ 1]], 0., x > s[[-1]], 1., True, Interpolation[idata, InterpolationOrder -> 0][-x] (* -x is the second sign change *) }}] ]The construction Last /@ Split[ ... ] accounts for duplicate values.Here are two examples. Needs[Statistics`ContinuousDistributions`]list1 = RandomArray[NormalDistribution[0, 1], 100];f1 = MakeEmpiricalCDF[list1];Plot[f1[x], {x, -4, 4}]list2 = Table[Random[Integer, {1, 10}], {10}];f2 = MakeEmpiricalCDF[list2];Plot[f2[x], {x, 0, 11}]--Mark> I'm trying to write a fast empirical cummulative distribution function> (CDF). Empirical CDFs are step functions that can be expressed in> terms of a Which statement. For example, given the list of> observations {1, 2, 3},> f = Which[# < 1, 0, # < 2, 1/3, # < 3, 2/3, True, 1]&> is the empirical CDF. Note that f /@ {1, 2, 3} returns {1/3, 2/3, 1}> and f is continuous from the right.> When the number of observations is large, the Which statement> evaluates fairly slowly (even if it has been Compiled). Since> InterpolationFunction evaluates so much faster in general, I've tried> to use Interpolation with InterpolationOrder -> 0. The problem is that> the resulting InterpolatingFunction doesn't behave the way (I think)> it ought to. For example, let> g = Interpolation[{{1, 1/3}, {2, 2/3}, {3, 1}}, InterpolationOrder - 0]> Then, g /@ {1, 2, 3} returns {2/3, 2/3, 1} instead of {1/3, 2/3, 1}.> In addition, g is continuous from the left rather than from the right.> Obviously I am not aware of the considerations that went into> determining the behavior of InterpolationFunction when> InterpolationOrder -> 0.> So I have two questions: > (1) Does anyone have any opinions about how InterpolatingFunction> ought to behave with InterpolationOrder -> 0?> (2) Does anyone have a faster way to evaluate an empirical CDF than a> compiled Which function?> By the way, here's my current version:> CompileEmpiricalCDF[list_?(VectorQ[#, NumericQ] &)] :=> Block[{x}, Compile[{{x, _Real}}, Evaluate[> Which @@ Flatten[> Append[> Transpose[{> Thread[x < Sort[list]],> Range[0, 1 - 1/#, 1/#] & @ Length[list]> }],> {True, 1}]]> ]]]> --Mark ==== =Hey,How can I duplicate those nifty ÔMore' hyperlinks in my usagestatements? That is the hyperlinks that appears at the end of text thatis generated after invoking a Ô?' to get more information about a function.Lawrence ==== =>I've got to extract some numbers from a file that are in lines of>text. Since the line contents are not numbers, I presume I must pull>the line out as a string. Here I start by pulling out just one line:>inFile = OpenRead[197-tst.txt] >y = ReadList[inFile, String, 1, RecordLists -> True] >Close[inFile];>This appears to pull in a line. Now I want to take characters 25 to>110 to get just the stuff I want: y1=StringTake[y ,{25,110}];>Here's the output. StringTake doesn't seem to work.ReadList returns a List not a String. So, y is a List and StringTake fails since it expects a String.Also, you do not need the options RecordLists->True when reading Strings. Nor do you need the OpenRead/Close statements with ReadListTryy = First[readList[197-tst.txt,String,1];y1 = StringTake[y, {25,110}]; ==== =>Does anybody know how to calculate in Mathematica: >a)empirical CDF,>b)empirical PDF, >c)normal QQ-plot; >d)QQ-plot two different random samples?!Yes, but there are a number of issues particularly with an empirical PDF. A very nice package that does all of the above and more is mathStatica. See http://www.mathstatica.com for details.Obviously, it is less expensive to write your own functions.Just recently in message Mark Fisher posted code that addresses the empirical CDF. However, in this code you may want to replace 1/n with 1/(n+1) or (j-0.5)/n depending on your application. Note, these will have no significant effect for large data sets. ==== => I am trying to implement a very simple sorted tree to quickly store some> real numbers I need. I have written an add, delete, minimum, and pop> (delete the lowest value) function and they seem to work ok but are very> slow. Let's just look @ my implementation of the add part:> nums=Null;(*my initial blank Tree)> In[326]:=> Clear[add]> In[327]:=> add[Null,x_Real]:=node[x,Null,Null]> add[Null,node[x_Real,lower_,higher_]]=node[x,lower,higher]> In[328]:=> add[node[x_Real,lower_,higher_],y_Real]:=> If[x>y,node[x,add[lower,y],higher],node[x,lower,add[higher,y] ]]> In[288]:=> add[node[x_Real,lowerx_,higherx_],node[y_Real,lowery_,highery _]]:=If[x>y,> node[x,add[lowerx,node[y,lowery,highery]],higherx],> node[x,lowerx,add[higherx,node[y,lowery,highery]]]> ]> Now this is my attempt to test how fast my add works:> SeedRandom[5];> Do[nums=add[nums,Random[]],{5000}];//Timing> Out[333]=> {13.279 Second,Null}> running on an 1.4GHz Athlon with 1GB of ram).> Questions:> 1. Is this as fast as I can get my code to run?> 2. Am I doing something obviously stupid?> 3. would Compiling things help?> HusainI'll respond to your third question first. No, use of Compile will nothelp. You do not have a tensor structure and moreover it will copy itsarguments. Hence invoking it within a loop would be quite slow for aproblem where the argument grows in size.One thing you did not check is the actual run-time complexity of yourcode. On my 15.GHz machine I get:In[6]:= SeedRandom[5];In[7]:= ee = Table[Random[], {10000}];In[8]:= nums = Null; Timing[Do[nums = add[nums,ee[[j]]],{j,1000}];]Out[8]= {0.34 Second, Null}In[9]:= nums = Null; Timing[Do[nums = add[nums,ee[[j]]],{j,2000}];]Out[9]= {1.28 Second, Null}In[10]:= nums = Null; Timing[Do[nums = add[nums,ee[[j]]],{j,4000}];]Out[10]= {4.94 Second, Null}In[11]:= nums = Null; Timing[Do[nums = add[nums,ee[[j]]],{j,8000}];]Out[11]= {25.08 Second, Null}We see this is clearly of no better than quadratic complexity, whereas Iwould guess you were expecting O(n*Log[n]). So this indicates a problem.Offhand I do not know what aspect of your code is responsible, but I'llgive some different code that has the desired complexity.Note that some of this, and code very similar to that below, isdiscussed at:http://library.wolfram.com/conferences/devconf99/lichtblau /in the section entitled Trees.There is a corresponding Mathematica notebook available at:http://library.wolfram.com/conferences/devconf99/near the bottom of the web page.The code I used to implement a tree structure similar to yours is below.One difference is that, as I place node values in the center, when theyare ßattened the tree is automatically sorted. You might (or might not)regard this as an added benefit.leftsubtree[node[left_, _, _]] := leftrightsubtree[node[_, _, right_]] := rightnodevalue[node[_, val_, _]] := valemptyTree = node[];Clear[treeInsert]treeInsert[emptyTree, elem_] := node[emptyTree, elem, emptyTree]treeInsert[tree_, elem_] /; OrderedQ[{nodevalue[tree], elem}] := node[leftsubtree[tree], nodevalue[tree], treeInsert[rightsubtree[tree], elem]]treeInsert[tree_, elem_] := node[treeInsert[leftsubtree[tree],elem], nodevalue[tree], rightsubtree[tree]]Now for some tests.In[40]:= tt1k = First[Timing[ff1k = node[]; Do[ff1k = treeInsert[ff1k, ee[[j]]], {j,1000}];]] Out[40]= 0.15 SecondWe will check that the ßattened version is actually sorted.In[41]:= gg1k = Apply[List,Flatten[ff1k]];In[42]:= gg1k ==== Sort[Take[ee,1000]]Out[42]= TrueAlso we will observe that the maximum depth is reasonable.In[43]:= Depth[ff1k]Out[43]= 23In the perfectly balanced case it would be 10 so this is not too bad.For larger examples I'll just show timings.In[44]:= tt2k = First[Timing[ff2k = node[]; Do[ff2k = treeInsert[ff2k, ee[[j]]], {j,2000}];]]Out[44]= 0.32 SecondIn[45]:= tt4k = First[Timing[ff4k = node[]; Do[ff4k = treeInsert[ff4k, ee[[j]]], {j,4000}];]]Out[45]= 0.73 SecondIn[47]:= tt8k = First[Timing[ff8k = node[]; Do[ff8k = treeInsert[ff8k, ee[[j]]], {j,8000}];]]Out[47]= 1.58 SecondIn[53]:= SeedRandom[5]; ee = Table[Random[], {32000}];In[54]:= tt32k = First[Timing[ff32k = node[]; Do[ff32k = treeInsert[ff32k, ee[[j]]], {j,32000}];]]Out[54]= 7.58 SecondThis is not of blinding speed but it has the advantage of exhibiting theappropriate run-time complexity. One can, with careful coding, cut downon tree size but if you check with LeafCount you will find that theversion above is already not too wasteful (3x larger than #valuesstored). Moreover the code needed would run a bit slower as it wouldhave more cases to check.As for removing nodes, I think you will need to use some form of heldattribute so as to avoid copying the entire tree when you alterelements.Daniel LichtblauWolfram Research ==== =>>So far, so good. It seems that you want these 11 numbers, OK? Theproblemnow, I think, is that this is just a string and I can think of no easywayto convert it precisely into a list of 11 real numbers.You could try StringToStream followed by a Read from that stream.Bobby Treat-----Original Message-----None];This allowed me to examine your records and I found out that in this wayeach record comes out as a list of length 1: In[2]:=Head[a[[1]]]Out[2]=ListIn[3]:=Length[a[[1]]]Out[3]= 1That is,In[3]:=a[[1]]Out[3]=317. 367. -115. 126. 146. -410. -426.000000EF 75.}In[4]:=StringLength[a[[1,1]]]Out[4]=140and the characters you want areIn[5]:=StringTake[a[[1,1]], {25, 110}]Out[5]=5935.80 5946.66 27.06 -1281.9 -229. 321. 317. 367. -115.126. 146.So far, so good. It seems that you want these 11 numbers, OK? Theproblemnow, I think, is that this is just a string and I can think of no easywayto convert it precisely into a list of 11 real numbers. Then, I suggestyouread the file in a different way, without the WordSeparators option:In[6]:=b=ReadList[197-tst.txt,Word,RecordLists -> True];In[7]:=b[[1]]Out[7]=.,-115.,126.,146.,-410.,- 426.000000EF,75.}In[8]:=Head[b[[1]]]Out[8]=ListIn[9]:=Length[ b[[1]]]Out[9]=19so that each record is now a list of 19 strings. What you want isstrings 6to 16, but converted to reals (unless I'm being presumptuous). This willachieve that:In[10]:=ToExpression[Take[b[[1]],{6,16}]]Out[10]={ 5935.8,5946.66,27.06,-1281.9,-229.,321.,317.,367.,-115.,126., 146.} Now you have a nice list of real numbers to work with. You can do thisforthe whole file like this:In[11]:=ToExpression[Take[#,{6,16}]&/@b]; I hope this will solve your problem.Tomas GarzaMexico City> ----- Original Message -----> Sent: Friday, September 13, 2002 12:14 AMfrom a file...> I've got to extract some numbers from a file that are in lines oftext.> Since the line contents are not numbers, I presume I must pull thelineout> as a string. Here I start by pulling out just one line:> > inFile = OpenRead[197-tst.txt]> y = ReadList[inFile, String, 1, RecordLists -> True]> Close[inFile];> > This appears to pull in a line. Now I want to take characters 25 to110to> get just the stuff I want:> y1=StringTake[y ,{25,110}];> > Here's the output. StringTake doesn't seem to work.>-229.> 321. 317. 367. -115. 126. 146. -410. -426.000000EF 75.},> {25, 110}]> > It doesn't take loading another package as far> as I can tell from the help. I'm thinking that it doesn't workbecause> it's trying to work on a list> rather than a string. I've tried Flatten, and other stuff to try togetto> just a string and not a list but> nothing has worked so far. I'm a long way from getting to thosenumbers> in there but heck, I> can't even get to the string. Can anyone point me in the rightdirection?> >------------------------------------------------------------ -------- ==== =Evaluate ?Floor and then, with your cursor in the output cell from that,push Ctrl-Shift-E, and you should see something like:Information[Floor, LongForm -> False]Floor[x] gives the greatest integer less than or equal tox.*Button[More[Ellipsis], ButtonData :> Floor, Active -> True, ButtonStyle -> RefGuideLink]OK. Change ButtonData :> Floor to ButtonData :> Ceiling, and pushCtrl-Shift-E again. Push the More... button, and you should go toCeiling in the Help Browser, not Floor.Another method is to click Input>Create Button>RefLink and type inCeiling. You should get a button that takes you to Help for Ceiling.Push Ctrl-Shift-E in both cells and compare, and you'll see some cluesto your options. Clues are all you get in Mathematica, so get used toit!Bobby Treat-----Original Message----- ==== =Since r1 and r2 only appear squared, you can do it this way:Simplify[Solve[FR == Pi*r1Sq - Pi*r2Sq, r1Sq]]{{r1Sq -> FR/Pi + r2Sq}}orSimplify[Solve[FR == Pi*r1Sq - Pi*r2^2, r1Sq]]{{r1Sq -> FR/Pi + r2^2}}Then r1 is the square root of r1Sq. In the complex plane, real numbershave two square roots, but we usually ignore that.Bobby Treat-----Original Message-----http://www.verbeia.com/mathematica/tips/Links/ Tricks_lnk_41.htmlI thin, one has to to replace the patterni Sqrt[-a_]bySqrt[(i Sqrt[-a_])^2]and then one has to simplify it?Peter Klamser ==== => My question; The process of moving (* *) step by step through the> program is quite tedious when the code has lots more lines. What I would> like is a meta-program which (like FoldList) does this job for me. The> output of this meta-program is the list of outputs of each line in the> module, probably best printed as a column.Beside the Print statements, sometimes I do the following. Put the functionto be tested in its own context and then empty the list of local symbols,e.g.,myfunction[stuff__] := Module [{}, expr1; expr2; ... ]so that all temporary variables defined within the function are now globalwithin the new context. Then I can examine the values of all these variablesafter execution of the function and can often find the error. If the erroris caused by a complex expression of nested functions, then I unwind thecomplex expression, adding more temporary variables, until I see theproblem. Then I think twice before recomplexifying.The two advandages of a special context are (1) I don't get the previouslylocal symbols mixed up with other symbols and (2) I can examine all of themand only them with TableForm[{#,ToExpression[#]}&/@Names[mynewcontext`*]]Once I do this, I often leave the new context in place. Mathematica seems tobe able to handle a large number of contexts efficiently.Tom Burton ==== =I have quite an easy and annoying problem with mathematica:I need to define a function f(x,y) which takes some values forx=0,2pi,4pi (indepently of y) and has a different expression for allthe other values of y. This is easily done for one-dimensionalfunctions but I am in serious troubles for my two-dimensional problem:any suggestion?FabioReply-To: kuska@informatik.uni-leipzig.de ==== =Clear[f]f[0, _] := qf[Pi, _] := pf[2Pi, _] := rf[x_, y_] := x^2*y^2??? Jens> I have quite an easy and annoying problem with mathematica:> I need to define a function f(x,y) which takes some values for> x=0,2pi,4pi (indepently of y) and has a different expression for all> the other values of y. This is easily done for one-dimensional> functions but I am in serious troubles for my two-dimensional problem:> any suggestion?> Fabio ==== => I have quite an easy and annoying problem with mathematica:> I need to define a function f(x,y) which takes some values for> x=0,2pi,4pi (indepently of y) and has a different expression for all> the other values of y. This is easily done for one-dimensional> functions but I am in serious troubles for my two-dimensional problem:> any suggestion?> FabioThere were some typos in my last message. It should have read:Let the known values of the function at x={0,2Pi,4Pi} be {f0,f2,f4}.Your conditions can be met byf(x,y)=x(x-2Pi)(x-4Pi)g(y)+h(x),where {h(0),h(2Pi),h(4Pi)}={f0,f2,f4}. An h(x) can be found by quadratic interpolation: h[x]= a + bx + cx^2;Solve[{a==f0,a+2Pi b +(2Pi)^2 c==f2, a+4Pi b+(4Pi)^2 c==f4},{a,b,c}]{{b -> -(3*f0 - 4*f2 + f4)/(4*Pi), c -> -(-f0 + 2*f2 - f4)/(8*Pi^2), a -> f0}} ==== => I have quite an easy and annoying problem with mathematica:> I need to define a function f(x,y) which takes some values for> x=0,2pi,4pi (indepently of y) and has a different expression for all> the other values of y. This is easily done for one-dimensional> functions but I am in serious troubles for my two-dimensional problem:> any suggestion?> FabioLet the known values of the function at x={0,2Pi,4Pi} be {f0,f2,f4}.Your conditions can be met byf(x,y)=x(x-2Pi)(x-4Pi)g(y)+h(x),where {h(0),h(2Pi),h(4Pi)}={f0,f2,f4}. An h(x) can be found by quadratic interpolation: h[x]= a + bx + cx^2;Solve[{a==f0,a+2Pi b +(2Pi)^2+(2Pi)^2 c==f2, a+4Pi b+(4Pi)^2 c==f4]{{b -> -(3*f0 - 4*f2 + f4)/(4*Pi), c -> -(-f0 + 2*f2 - f4)/(8*Pi^2), a -> f0}}Maurice ==== => I have quite an easy and annoying problem with mathematica:> I need to define a function f(x,y) which takes some values for> x=0,2pi,4pi (indepently of y) and has a different expression for all> the other values of y. This is easily done for one-dimensional> functions but I am in serious troubles for my two-dimensional problem:> any suggestion?> FabioSomething like this?In[1]:= f[x_,y_] := If[Mod[x,2*Pi] ==== 0, Exp[x], Sin[y]+x]In[2]:= f[4*Pi, y] 4 PiOut[2]= EIn[3]:= f[1, y]Out[3]= 1 + Sin[y]--Bhuvanesh,Wolfram Research. ==== => I have quite an easy and annoying problem with mathematica:> I need to define a function f(x,y) which takes some values for> x=0,2pi,4pi (indepently of y) and has a different expression for all> the other values of y. This is easily done for one-dimensional> functions but I am in serious troubles for my two-dimensional problem:> any suggestion?> Fabiof[0, y_] := 5f[2 Pi, y_] := 7f[4 Pi, y_] := -3f[x_ /; x < 0, y_] := x yf[x_ /; 0 < x < 2 Pi, y_] := x + yf[x_ /; 2Pi < x < 4 Pi, y_] := x - yf[x_ /; 4Pi < x, y_] := 2x y ==== =>-----Original Message----->Sent: Monday, September 16, 2002 6:34 AM >I have quite an easy and annoying problem with mathematica:>I need to define a function f(x,y) which takes some values for>x=0,2pi,4pi (indepently of y) and has a different expression for all>the other values of y. This is easily done for one-dimensional>functions but I am in serious troubles for my two-dimensional problem:>any suggestion?>FabioIt's difficult to guess what you wanted to attain and what your problemswere. Perhaps this example might help you:In[11]:= f[x_, _] /; Mod[x, 2Pi] == 0 := x/(2Pi)In[12]:= f[x_, y_] := x + yIn[13]:= epsilon = $MachineEpsilonOut[13]= 2.220446049250313*^-16In[14]:=f[6Pi(1 + epsilon Sin[#]), #] & /@ Range[0, 4Pi, Pi 10^-1]Out[14]={3, 3., 19.4779, 19.792, 20.1062, 20.4204, 20.7345, 21.0487, 21.3628, 3., 3,22.3053, 22.6195, 22.9336, 23.2478, 23.5619, 23.8761, 24.1903, 24.5044, 24.8186, 3, 3., 25.7611, 26.0752, 26.3894, 26.7035, 27.0177, 27.3319,27.646, 3., 3, 28.5885, 28.9027, 29.2168, 29.531, 29.8451, 30.1593, 30.4734,30.7876, 31.1018, 3}Look close at the values returned (compare with epsilon Sin[Range[0, 4Pi, Pi 10^-1]]), also to recognize the dangers of such a definition.--Hartmut ==== =I am new with Mathematica, I have one question,I know that the sollution might be very easy, but I wasn't able tofind it by now.I would like to draw an ellipse, the formula let's say is as follows:0.09 x^2 +0.04 x y + 0.06 y^2 = 4Maciej ==== =Although it is not outstanding, I prefer to write your equation in the form:9*x^2+4*x*y+6*y^2==400In order to plot the ellipse you can use the package Graphics`ImplicitPlot`in this way:In[1]:=<< Graphics`ImplicitPlot`In[2]:=ImplicitPlot[ 9*x^2 + 4*x*y + 6*y^2 == 400, {x, -7, 7}, PlotStyle -> RGBColor[1, 0, 0]];Germ.87n Buitrago A.----- Original Message -----> 0.09 x^2 +0.04 x y + 0.06 y^2 = 4> Maciej ==== =first this in not an ellipse.the ellipse generic formula is : (x^2)/(a^2)+(y^2)/(b^2) = 0.I guest that you want report a graph of the solution y of the equation: 0.09x^2 +0.04 x y + 0.06 y^2 = 4 for x varying into a given range.As you can veryfing using:Solve[0.09 x^2 + 0.04 x y + 0.06 y^2 == 4, y]the solutins are two:{{y -> 8.333333333333334*(-0.04*x -0.1414213562373095*Sqrt[48.00000000000001 + 0.*x - 1.*x^2])}, {y -> 8.333333333333334*(-0.04*x +0.1414213562373095*Sqrt[48.00000000000001 + 0.*x - 1.*x^2])}}than you can construct a function:function1[x_] = 8.333333333333334*(-0.04*x -0.1414213562373095*Sqrt[48.00000000000001 - *x^2])},that is a real value only if (48.00000000000001 - *x^2)>0, i.e. ifapproximatively -6 True]the same for the other soluztion.good luck-upimak ha scritto nel messaggio> I am new with Mathematica, I have one question,> I know that the sollution might be very easy, but I wasn't able to> find it by now.> I would like to draw an ellipse, the formula let's say is as follows:> 0.09 x^2 +0.04 x y + 0.06 y^2 = 4> MaciejReply-To: murray@math.umass.edu ==== =One way is:ContourPlot[0.09 x^2 + 0.04 x y + 0.06 y^2, {x, -10, 10}, {y, -10, 10}, Contours -> {4}, PlotPoints -> 50, ContourShading -> False];> I am new with Mathematica, I have one question,> I know that the sollution might be very easy, but I wasn't able to> find it by now.> I would like to draw an ellipse, the formula let's say is as follows:> 0.09 x^2 +0.04 x y + 0.06 y^2 = 4> Maciej> -- Murray Eisenberg murray@math.umass.eduMathematics & Statistics Dept.Lederle Graduate Research Tower phone 413 549-1020 (H)University of Massachusetts 413 545-2859 (W)710 North Pleasant StreetAmherst, MA 01375Reply-To: kuska@informatik.uni-leipzig.de ==== =Needs[Graphics` ImplicitPlot`]ImplicitPlot[0.09 x^2 + 0.04 x y + 0.06 y^2 == 4, {x, -10, 10}, {y, -10, 10}]may help. Jens> I am new with Mathematica, I have one question,> I know that the sollution might be very easy, but I wasn't able to> find it by now.> I would like to draw an ellipse, the formula let's say is as follows:> 0.09 x^2 +0.04 x y + 0.06 y^2 = 4> Maciej ==== =I pretend to know how many times the function f has to be evaluated when using NDSolve to solve a differential equation.I've tried :cont=0;f[x_]:=(cont++;x^2);NDSolve[ {y''[x]+y[x]==f[x],y[0]==1,y'[0 ]==0},y,{x,0,6}]I obtain the solution of the ODE but cont returns 1 instead the number of funtion evaluations.How can I obtain it? ==== => I pretend to know how many times the function f has to be evaluated when > using NDSolve to solve a differential equation.> I've tried :> cont=0;> f[x_]:=(cont++;x^2);> NDSolve[ {y''[x]+y[x]==f[x],y[0]==1,y'[0 ]==0},y,{x,0,6}]> I obtain the solution of the ODE but cont returns 1 instead the number > of funtion evaluations.> How can I obtain it?> you need to make sure that the function f[x] is evaluated only when itgets a numeric argument. Otherwise, Mathematica expands f[x]symbolically to the expression x^2 before NDSolve is called.Writing your code as follows will solve your problem:cont=0;f[x_?NumericQ]:=(cont++;x^2);NDSolve[ {y''[x]+y[x]==f[x],y[0]==1,y'[0 ]==0},y,{x,0,6}] Eckhard Hennig ==== => I pretend to know how many times the function f has to be evaluated when > using NDSolve to solve a differential equation.> I've tried :> cont=0;> f[x_]:=(cont++;x^2);> NDSolve[ {y''[x]+y[x]==f[x],y[0]==1,y'[0 ]==0},y,{x,0,6}]> I obtain the solution of the ODE but cont returns 1 instead the number > of funtion evaluations.> How can I obtain it?cont=0;f[x_?NumericQ]:=(cont++;x^2)NDSolve[ {y''[x]+y[x]==f[x],y[0]==1,y'[0 ]==0},y,{x,0,6}]-> cont = 94-Jim ==== =Try the following:Clear[f]cont=0;f[x_?NumericQ]:=(cont++;x^2);NDSolve [ {y''[x]+y[x]==f[x],y[0]==1,y'[0] ==0},y,{x,0,6}]The problem you are encountering occurs because NDSolve evaluates it'sinputs first, and so NDSolve is trying to solve the differential equationy''[x]+y[x]==x^2 instead of y''[x]+y[x]==f[x]. By restricting the definitionof f to evaluate only when it's input is numeric, NDSolve will keep the f[x]in the differential equation. I've included a Clear[f] statement just incase the old definition of f was still there.Carl WollPhysics DeptU of Washington> I pretend to know how many times the function f has to be evaluated when> using NDSolve to solve a differential equation.> I've tried :> cont=0;> f[x_]:=(cont++;x^2);> NDSolve[ {y''[x]+y[x]==f[x],y[0]==1,y'[0 ]==0},y,{x,0,6}]> I obtain the solution of the ODE but cont returns 1 instead the number> of funtion evaluations.> How can I obtain it?Reply-To: kuska@informatik.uni-leipzig.de ==== =and aftercont = 0;f[x_?NumericQ] := (cont++; x^2);NDSolve[{y''[x] + y[x] == f[x], y[0] == 1, y'[0] == 0}, y, {x, 0, 6}]cont is 93.Thats because *you* gave only a blank pattern for f[x_] and NDSolve[]evaluate it to compile the right hand sides or translate itto an internal function. So *your* function is only oncewhen Mathematica can include it into it's internal functionfor the right hand sides. Jens> I pretend to know how many times the function f has to be evaluated when> using NDSolve to solve a differential equation.> I've tried :> cont=0;> f[x_]:=(cont++;x^2);> NDSolve[ {y''[x]+y[x]==f[x],y[0]==1,y'[0 ]==0},y,{x,0,6}]> I obtain the solution of the ODE but cont returns 1 instead the number> of funtion evaluations.> How can I obtain it?> ==== =Fabio,f[x_ /; IntegerQ[Rationalize[x/(2Pi)]], y] := g[x]f[x_, y_] := h[x, y]f[# Pi, y] & /@ Range[10]{h[Pi, y], g[2*Pi], h[3*Pi, y], g[4*Pi], h[5*Pi, y], g[6*Pi], h[7*Pi, y], g[8*Pi], h[9*Pi, y], g[10*Pi]}f[2.0Pi, y]g[6.28319]f[3.5, y]h[3.5, y]f[4.01Pi, 5]h[12.5978, 5]You can use a second argument in Rationalize to control how small arationalization error is allowed and there is always the question about whatdomain around 2nPi you want to include in the first definition.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ ==== =yes , this is a comon problem.You can either do:y=If[x>1000, ToExpression[BigVariable][[x]],x] ]or, maybe more readable, declare at the begging of ThisPackage:bigvar := bigvar = ToExpression[OtherPackage`BigVariable];and then y=If[x>1000, bigvar, x](* ************************** *)Alternatively you can create .mx files which load much quicker than .m files.It would be really nice if WRI could investigate why loading larger .m files is so slow ( I suspect it has to do something with the speed of side effectslike DownValues declarations etc., but I don't know ).Rolf MertigMertig Consultinghttp://www.mertig.com ==== =========================== ==== =DeclareePackage[OtherPackage`, {BigVariable} ]. The idea was to preventthe loading of a large file in routine cases. However, when ThisPackage`defines its functions, inside the Private` area, it includes a conditionalcall to BigVariable. It turns out that OtherPackage is loaded when thatfunction is defined. I was wondering if there is a way to avoid this.Roughly speaking, here is the setting:BeginPackage[ OtherPackage` ]BigVariable::usage=exampleBegin[Private`]BigVariable=Table[x y,{x,1000},{y,1000}]End[ ]EndPackage[ ]BeginPackage[ ThisPackage` ]function::usage=exampleBegin[Private`]function[x_]:=Module[{ y},y=If[x>1000,BigVariable[[x]],x] ]End[ ]EndPackage[ ]I don't want OtherPakage to be loaded unless function[x] is called withx>1000 but it loads when function is defined. Any ideas?Nicholas ==== =I was looking for a function that can convert numbers between bases.For example, going from Base 3 to Base 9, or from Base 16 to Base 8.It seems like I have to a few steps and then use BaseForm to convert to thedesired end base.Is there a single command or simple function to do such conversions? Forexample,ConvertBase[from_, to_, num_]would convert from base to base 9 using the number num as the number toconvert (it would best be allowed to let users input in that specific basesince they'd be going from base 3 to base 9, for example so maybe num isneeded at all). ==== =Dear NGMabye this is too simple, but I cant just figure it outI want to get an inverse function for y[t] where y[t_]:=NIntegrate[R[x]^4,{x,0,t}] /. ndsolution[[1]]andR[t] is an interpolatingfunction(R>0 from NDSolve) on the interval 0= Dear NG> Mabye this is too simple, but I cant just figure it out> I want to get an inverse function for y[t] where> y[t_]:=NIntegrate[R[x]^4,{x,0,t}] /. ndsolution[[1]]> and> R[t] is an interpolatingfunction(R>0 from NDSolve) on the interval 0= after that I hope to be able to calculate the integral :> a = (1/y[T])*> NIntegrate[R[InvFunction[y[t]]*Cos[y[t]], {y[t], 0, y[T]}]> it works with a constant instead of R[t].> Hope you can help, and that the above is understandable.> Martin Skogstad ==== =You may have noticed that there have been no posts to the Mathematicaice storm in North Carolina and my power was out for several days andT-1 circuits all over the area were out until today. Everything is backto normal now. Posts will start going out tonight.Sorry for the delays,Steve ChristensenModeratorReply-To: ==== =Dear Luiz,The theory of Levemberg-Marquardt algorithm is described in many books; Isuggest, for example, Numerical Recipes, W.H Press, B.P. Flannery, S.A. Teukolsky, Cambridgeuniversity press, in whichthere is also the source code in Fortran Language.However, the Mathematica calculated errors differ from the originaltheoretical errors.***********************************************Stefano FricanoDip. di Scienze Fisiche ed AstronomicheUniversit.88 degli StudiVia Archirafi, 36Palermo 90123********************************************* ==== =There seems to be a bug here due to the fact that ContinuousDistributions.m(4.0.0) does not check that q is numeric.Quantile[NoncentralChiSquareDistribution[2, 10], q]Produces a load of errors and some incorrect results when used in LogPlot.LogPlot[Quantile[NoncentralChiSquareDistribution[2, 10], q], {q, .1, .9}]This is of course a pain. What is the best way to correct this? Is it tocopy the particular function from ContinuousDistribution.m and re-include itin a little add on or is there an updated version.TIA-- Nigel ==== =I am confused by this result:In: Module[{a}, a = x; g[x_] = a]; g[y]Out: xSomehow I would expect the same output asIn: Module[{}, a = x; g[x_] = a]; g[y]Out: yIn the first case ?g gives g[x$_] = x,while in the second it gives g[x_] = x.The difference is a dollar sign.Can anyone explain why the dollar is inserted in one casebut not in the other? The x was not a local variablein either case.My version is 4.1 for PowerMac. Gianluca Gorni-- +---------------------------------+ | Gianluca Gorni | | Universita` di Udine | | Dipartimento di Matematica | | e Informatica | | via delle Scienze 208 | | I-33100 Udine UD | | Italy | +---------------------------------+ | Ph.: (39) 0432-558422 | | http://www.dimi.uniud.it/~gorni | +---------------------------------+ ==== => I tried to do but I can't. mathematica says sigma^2 is not a valid> variable.> is there any way to do that ? I can do that if I replace sigma^2 with> some variable and then differentiate it with respect to the some> variable not having power term.You can do this with the change rule. If the following example, f is afunction of s, and g[s s] ==== f[x].f[s_] = (Sin[t]*Cos[2*t])/s + 3*t^3 /. t -> s*sg[t_] = (Sin[t]*Cos[2*t])/Sqrt[t] + 3*t^3Although we cannot find the derivative of f wrt s^2 directly, we can use thechain rule:d1 = f'[s]/D[s*s, s]To check the answer, for the equivalent derivative on g:d2 = g'[t] /. t -> s*sSimplify[PowerExpand[d1 - d2]]Hope this helps,Tom Burton ==== =I guess I never learn anything the easy way. I've been told this before, but until I actually started poking around in the data from Mathematica 3D animations, I didn't understand what all this meant. I had been creating my straight line segments with ParametricPlot3D and not setting PlotPoints->2. When I looked at how they were represented, I realised how much useless data was being generated. Anyhow, just about the time I was ready to put this on the web, I had the first hard drive failure in my life (on my own system). What luck! It was the drive holind my web-site. Fortunately, I have backups of everything. Nonetheless, It took a while to get everything back up. It was already well past the end of the day. I'm too tired to add much explanation to the I made extensive use of Dr. Míóder.81[YAcute] CSM`Classes` package. It's not quite Java level OO, but It certainly is usable. http://public.globalsymmetry.com/projects/lorenz3d/ lorenz3D-scene1.nbThe notebook is just a front-end. I'm not ready to publish the code yet.-- STHHatton's Law: There is only One inviolable Law. ==== =Try:In[1]:=TableForm[Table[i + 10 j, {i, 3}, {j, 2}], TableSpacing -> {0, 5}] // OutputFormOut[2]//OutputForm=11 2112 2213 23The output can be copied and pasted in the form you wanted. TheTableSpacing option is necessary to make sure there is no blank linebetween adjacent rows.One drawback of this approach is that you have to mannually delete theline containing Out[2]//OutputForm=.Kezhao> Given some output in a notebook, say from> Table[i+10 j, {i, 3}, {j, 2}] // TableForm> grabs the cell expression and formatting info along with the text, which> isn't what I want. I just want the table, more or less as it appears in> 11 21> 12 22> 13 23> I hacked it by doing Export[t.txt,%] but that's a bit clumsy.> ==== =Can anyone explain the following results?In[8]:=r[t_]:=4-3Sin[t]In[9]:=!(NIntegrate[Sqrt[r[t]^ 2 + (r')[t]^2], {t, 0, 2 [Pi]}])Out[9]=28.8142In[10]:=!(Integrate[Sqrt[r[t]^2 + (r')[t]^2], {t, 0, 2 [Pi]}] // N)Out[10]=-18.9606The result with Integrate //N is -18.9606 but with NIntegrate it is Ray Gittings ==== =Try this:Apply[Plus,Partition[{a, b, c, d, e}, 2, 1],1]/2Ariel Sep.9clveda-CuevasQuality Department, HP-PRMOPO Box 4048Aguadilla, PR 00605-----Original Message-----f[list1]but I am sure that some member of the group can find a more elegantfunction. I will appreciate to know it.Guillermo Sanchez---------------------------------------------This message was sent using Endymion MailMan. ==== =Interesting optimization problem: Given a list of n-dimensional points, find a point that minimizes the average distance to all the given points.For example, here are 4 points in 3-space:points = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};Here's the formula for euclidean distance:d[p1_, p2_] := Sqrt[Tr[(p1 - p2)^2]]Now we want to find the point where all the partial derivatives are 0:eq[i_] := D[Tr[d[Array[z, 3], #] & /@ points], z[i]]eqs = (eq[#] == 0 & /@ Range[3])Solve[eqs, {z[1], z[2], z[3]}]But Mathematica chokes on that...Any ideas for a better algorithm to find the total-distance minimizing point (this should work for any dimensions; 16 in my case)?Daniel-- Daniel Reeves -- http://ai.eecs.umich.edu/people/dreeves/ Humans are genes' way of making more genes. -- Richard Dawkins ==== =Guillermo: Perhaps this -- #/2 & /@ Plus @@@ Partition[{a, b, c, d, e}, 2, 1] Best, HarveyHarvey P. DaleUniversity Professor of Philanthropy and the LawDirector, National Center on Philanthropy and the LawNew York University School of LawRoom 206A110 West 3rd StreetNew York, N.Y. 10012-1074tel: 212-998-6161fax: 212-995-3149-----Original Message-----f[list1]but I am sure that some member of the group can find a more elegantfunction. Iwill appreciate to know it.Guillermo Sanchez---------------------------------------------This message was sent using Endymion MailMan. ==== =Please tell me if there's a way to make mathematica 4 show me the wholeprocedure before spitting out the solution?thanks,Anto ==== =Math friends,I am trying to create a multiplication table for the factor groups,(Z_4 (+) Z_12)/<(2,2)>I understand how to list the elements of (Z_4 (+) Z_12). This is done with:Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]I would like to be able to figure out how to list the eight factor groupswith a calculation with (2,2). This would be in modulo 4,12 arithmetic.As a workaround, I defined (Z_4 (+) Z_12)/<(2,2)> as the eight cosetsdefined below:multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4], Mod[b + d, 12]}Multiplication[Z4Z12, multZ4Z12] // TableForm;Coset1 = {Z4Z12[[1]], Z4Z12[[27]], Z4Z12[[5]], Z4Z12[[31]], Z4Z12[[9]], Z4Z12[[35]]}Coset2 = {Z4Z12[[2]], Z4Z12[[28]], Z4Z12[[6]], Z4Z12[[32]], Z4Z12[[10]], Z4Z12[[36]]}Coset3 = {Z4Z12[[3]], Z4Z12[[29]], Z4Z12[[7]], Z4Z12[[33]], Z4Z12[[11]], Z4Z12[[25]]}Coset4 = {Z4Z12[[4]], Z4Z12[[30]], Z4Z12[[8]], Z4Z12[[34]], Z4Z12[[12]], Z4Z12[[26]]}Coset5 = {Z4Z12[[37]], Z4Z12[[15]], Z4Z12[[41]], Z4Z12[[19]], Z4Z12[[45]], Z4Z12[[23]]}Coset6 = {Z4Z12[[38]], Z4Z12[[16]], Z4Z12[[42]], Z4Z12[[20]], Z4Z12[[46]], Z4Z12[[24]]}Coset7 = {Z4Z12[[39]], Z4Z12[[17]], Z4Z12[[43]], Z4Z12[[21]], Z4Z12[[47]], Z4Z12[[13]]}Coset8 = {Z4Z12[[40]], Z4Z12[[18]], Z4Z12[[44]], Z4Z12[[22]], Z4Z12[[48]], Z4Z12[[14]]}I was not able to figure a way to create a multiplication table with theseeight elements, because of the multiple part modulo addition.There must be a way to multiply <(2,2)> by different elements of theexternal direct product, and a way to compute the multiplication table ofthe factor groups. Can someone help?Diana ==== ================================================ ==God made the integers, all else is the work of man.L. Kronecker, Jahresber. DMV 2, S. 19. ==== =Respected Sir/Madam,I want to super impose(add) two curves of different ranges-one is -5ms to 15 ms and other one is 0ms to 20ms of different amplitude.So kindly suggest me-- With best wishes.............. SISIR KUMAR NAYAK ELECTRICAL SCIENCE U-79,STUDENT HOSTEL IISC, BANGALORE. PH:3942624(080) ==== =I am trying to solve 3 equations on 3 variables --- which is solveable.After that I want to use only the positive solutions of the threevariables for further calculations. I tried to use the Select command inconnection with the Solve command, but I get only an empty list.Could you help by recommend commands?Angela Birk--Angela BirkUniversity of HamburgHWWAEconomics20347 Hamburg, Germany+49 40 42834 - 478 ==== =I use Plot3D to plot a function which is exponential in one region and almost a constant in the other. If I specify PlotPoints ->50 (say), costant region is well presented but there are too few points when the surface is very sharp.Is there any possibility to get a smooth surface everywhere? As far as I know MaxBend, which defines a maximum possible angle between succesive line segments, can help for ContourPlot3D but in the case of a Plot3D?Veniamin ==== =hi[NonBreakingSpace] try to solve a set of equitons that involves 10 nonlinear equations and 10 variables. I tried to solve byusing Solve and FindRoot order , but both couldn'tsucceed to solve.When i used FindRoot order thecomputer said that( findRoot::frnum:Function(.........)is not length 10 list of numbers ofat (....... ).And unfortunately some equations aremade by integral equation and 2 variables are on theboundary of integral... sorry my bad english:)...could you give me an idea to solve this equation.bye...______________________________________________ ____Do you Yahoo!?Yahoo! Mail Plus - Powerful. Affordable. Sign up now. ==== =Folks,I realize that there is an added complication that multiplying (adding withmodulo arithmetic) the cosets together actually does not give exact cosetproducts. In other words, if I add Coset1 + Coset2, I get:{{0, 1}, {0, 5}, {0, 9}, {0, 1}, {0, 5}, {0, 9}}, which are components ofCoset2, but not all of Coset2. So, the multiplication for adding Coset1 +Coset2 would somehow need to understand that the product represented Coset2.Diana> Math friends,>> I am trying to create a multiplication table for the factor groups,>> (Z_4 (+) Z_12)/<(2,2)> I understand how to list the elements of (Z_4 (+) Z_12). This is donewith:>> Z4Z12 = Flatten[Outer[List, Range[0, 3], Range[0, 11]], 1]>> I would like to be able to figure out how to list the eight factor groups> with a calculation with (2,2). This would be in modulo 4,12 arithmetic.>> As a workaround, I defined (Z_4 (+) Z_12)/<(2,2)> as the eight cosets> defined below:>> multZ4Z12[{a_, b_}, {c_, d_}] := {Mod[a + c, 4], Mod[b + d, 12]}>> Multiplication[Z4Z12, multZ4Z12] // TableForm;>> Coset1 = {Z4Z12[[1]], Z4Z12[[27]], Z4Z12[[5]], Z4Z12[[31]], Z4Z12[[9]],> Z4Z12[[35]]}>> Coset2 = {Z4Z12[[2]], Z4Z12[[28]], Z4Z12[[6]], Z4Z12[[32]], Z4Z12[[10]],> Z4Z12[[36]]}>> Coset3 = {Z4Z12[[3]], Z4Z12[[29]], Z4Z12[[7]], Z4Z12[[33]], Z4Z12[[11]],> Z4Z12[[25]]}>> Coset4 = {Z4Z12[[4]], Z4Z12[[30]], Z4Z12[[8]], Z4Z12[[34]], Z4Z12[[12]],> Z4Z12[[26]]}>> Coset5 = {Z4Z12[[37]], Z4Z12[[15]], Z4Z12[[41]], Z4Z12[[19]], Z4Z12[[45]],> Z4Z12[[23]]}>> Coset6 = {Z4Z12[[38]], Z4Z12[[16]], Z4Z12[[42]], Z4Z12[[20]], Z4Z12[[46]],> Z4Z12[[24]]}>> Coset7 = {Z4Z12[[39]], Z4Z12[[17]], Z4Z12[[43]], Z4Z12[[21]], Z4Z12[[47]],> Z4Z12[[13]]}>> Coset8 = {Z4Z12[[40]], Z4Z12[[18]], Z4Z12[[44]], Z4Z12[[22]], Z4Z12[[48]],> Z4Z12[[14]]}>> I was not able to figure a way to create a multiplication table with these> eight elements, because of the multiple part modulo addition.>> There must be a way to multiply <(2,2)> by different elements of the> external direct product, and a way to compute the multiplication table of> the factor groups. Can someone help?> Diana>> ==== ==================================================> God made the integers, all else is the work of man.> L. Kronecker, Jahresber. DMV 2, S. 19.>> ==== =Can you help me with this small problem.i need to problem that K-GG' equals a positive definite matrix.where K is a symmetric positive definite matrix and GG' are itsincomplete cholesky decomposition of it.going by x'Ax= x'(K-GG')x= x'Kx - x'GG'xnow I know I need to use induction here, but I am unsure how...in the overall proof I want to show that ||K-GG'|| <= sum(diag(K-GG'))thank in advance,David. ==== =Can you help me with this small problem.i need to problem that K-GG' equals a positive definite matrix.where K is a symmetric positive definite matrix and GG' are itsincomplete cholesky decomposition of it.going by x'Ax= x'(K-GG')x= x'Kx - x'GG'xnow I know I need to use induction here, but I am unsure how...thank in advance,David. The hunger for knowledge only grows as one knows more.....David R. Hardoon David.R.Hardoon@cs.rhul.ac.ukDept of Computer Science, Royal Holloway, University of LondonMobile: +44 7967 634954 http://g4.cs.rhul.ac.uk/ ==== =I give below some further speed-ups.The improvement, at least on the data I used, is due to usingSplit[Sort[_]] right at the start to parcel the data - it probably dependson there being a lot of repetition of the first term of the entries in thedata.The code for Matchings6 below is faster than Daniel Lichblau's recentlyposted code - though he suggests that this might be speeded up bysubstituting numbers for strings and compiling.Data Random[Integer, {1, 2000}]}, {6000}]; Random[Integer, {1, 2000}]}, {12000}];Get the members of s1 with the same first entry as some member of s2.Previous code (preserves order) Matched1[s1_,s2_]:= Cases[ s1,{Alternatives@@Union[s2[[All,1]]],_}] Matched1[s1,s2];//Timing {3.4 Second,Null}New code (does not preserve order) - note the use of s1[[Ordering[s1[[All,1]]]]] to save on ordering with respect to the second entries Matched4[s1_,s2_]:= Cases[Split[s1[[Ordering[s1[[All,1]]]]], #1[[1]] ==== #2[[1]]&], {{Alternatives@@Union[s2[[All,1]]],_},___}] Matched4[s1,s2];//Timing {1.6 Second,Null}Get the full matchings (this code will work on {s1,s2 ,....,sn}, as well asjust {s1, s2}) Matchings7[s_]:= Module[{st,pt,sp}, st = #[[Ordering[#[[All,1]]]]]&/@s; sp=Split[#,#1[[1]] ==== #2[[1]]&]&/@st; pt= (Alternatives@@(Intersection@@ st[[All,All,1]])); Transpose[Cases[#,{{pt,_},___}]&/@sp] ]; (ms7=Matchings7[{s1,s2}]);//Timing {3.46 Second,Null}Daniel Lichtblau (gives essentially the same information as Matchings7) myTest[l1_, l2_] := Module[{s1, s2, m = Length[l1], n = Length[l2], j, k, res = {}, ord }, s1 = Sort[l1]; s2 = Sort[l2]; For[j = 1; k = 1, j <= m && k <= n, Null, ord = Order[s1[[j,1]], s2[[k,1]]]; If[ord == 1, j++; Continue[]]; If[ord == -1, k++; Continue[]]; res = {res, {s1[[j]], s2[[k]]}}; j++; k++; ]; Partition[Partition[Flatten[res], 2], 2] ] myTest[s1,s2];//Timing {7.47 Second,Null}--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 ==== =[I am re-posting since the subject line did not appear with the original]Dear Hartmut,> But introducing a test in Intersection appears to kill> its performance).It may be that introducing a test prevents internal compiling.One more simplification - and this points up the value of using Alternativesto reduce the problem to simple pattern matching without conditions ortests: Random[Integer,{1,2000}]},{6000}]; Random[Integer,{1,2000}]},{12000}];In my second posting I ended with s1[[Flatten[Position[ s1[[All,1]], Alternatives@@Union[s2[[All,1]]]]]]];//Timing {3.24 Second,Null}Using Cases gives a simpler and slightly faster version: Cases[ s1, {Alternatives@@Union[s2[[All,1]]],_}];//Timing {3.13 Second,Null}How useful Union or, as below, Intersection are will be, depends of courseon the particular inputs, but for the current ones I get Cases[ s1, {Alternatives@@s2[[All,1]],_}];//Timing {5.32 Second,Null} Cases[ s1, {Alternatives@@Intersection[s1[[All,1]],s2[[All,1]]],_}];// Timing {3.41 Second,Null}In the last one, Cases may be repeating some of the work that Intersectionhas done.Perhaps you can build spme of this in your developments.Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198----- Original Message -----kill> its performance). Nonetheless we might combine ideas to get somethingstill> faster.>> (To keep all this legible I will snip out in the following part of your> deduction and examples)>-----Original Message----->Sent: Wednesday, December 04, 2002 9:25 AM>>>Brian,>>> I have two lists (in general of different length) that have the>> following structure>> Random[Integer, {1, 2000}]}, {100}];{4}]],> Random[Integer, {1, 2000}]}, {200}];>>> I am then interested in obtaining all the strings in s1 that match>> with those in s2. At the present time I use the following agorithm to>> find the matches>[I evaluate and time]>>> (myList = Flatten[Outer[List, s1, s2, 1], 1];> r1 = Select[myList, (First[First[#]] == First[Last[#]]) &]) // Timing>>>>>I may be misunderstanding what you are after, but if it is>the menbers of>s1 that have the same first element (string) as a member of>s2 then the>following seems quite quick>>(r2=s1[[Flatten[Position[> Transpose[s1][[1]],> Alternatives@@(Transpose[s2][[1]])]]]])//Timing>>>There is a difference:>>>This is caused by the occurence of> {{BEAB, 716}, {BEAB, 1071}},> {{BEAB, 716}, {BEAB, 1098}},> {{BEAB, 716}, {BEAB, 1966}}>>in r1 compared to>> {BEAB, 716}>>in r2>>>However, we can get the same matching information as from the Outer>technique with the following quick steps>> Here I just sewed together your steps to a procedure (for short, with an> obvious renaming):>> myMatch2[s1_, s2_] := Module[{r1, rr1, r2, rr2},> r1 = s1[[Flatten[> Position[Transpose[s1][[1]],> Alternatives @@ (Transpose[s2][[1]])]]]];> rr1 = Split[Sort[r1], #1[[1]] ==== #2[[1]] &];> r2 = s2[[Flatten[> Position[Transpose[s2][[1]],> Alternatives @@ (Transpose[s1][[1]])]]]];> rr2 = Split[Sort[r2], #1[[1]] ==== #2[[1]] &];> Flatten[MapThread[Outer[List, #1, #2, 1] &, {rr1, rr2}], 2]]> In fact I replaced the last step, which was Transpose[{rr1, rr2}] to whatI> had used in myMatch (I'm so sorry for the name!) as to reproduce Brians's> results.>>>>>-->Allan>>--------------------->Allan Hayes>Mathematica Training and Consulting>Leicester UK>www.haystack.demon.co.uk>hay@haystack.demon.co.uk>Voice: +44 (0)116 271 4198>>>> I have two lists (in general of different length) that have the>> following structure>> Random[Integer, {1, 2000}]}, {100}];>> Random[Integer, {1, 2000}]}, {200}];>> I am then interested in obtaining all the strings in s1 that match>> with those in s2. At the present time I use the following agorithm to>> find the matches>> myList = Flatten[Outer[List, s1, s2, 1], 1];Select[myList,>> (First[First[#]] == First[Last[#]]) &]>> This works fine, but when s1 and s2 are large ( e.g. 3000 or more>> elements) then Outer seems inefficient. My question: does>anyone have>> a suggestion that would be more efficient than my kludge approach.>> Note I have tried Intersection, which finds all the matches, i.e.>> myList2 = Intersection[s1,s2, SameTest -> (#1[[1]] == #2[[1]] &)];>> But I have not been successful in selecting all the matched pairs>> using myList2>> Brian>>> That procedure can be forther improved by cutting down the alternativesand> avoiding recalculation:>> myMatch3[s1_, s2_] :=> Module[{ss1 = Sort[s1], k1, r1, rr1, ss2 = Sort[s2], k2, r2, rr2, alt},> k1 = Transpose[ss1][[1]]; k2 = Transpose[ss2][[1]];> alt = Alternatives @@ Intersection[k1, k2];> r1 = ss1[[Flatten[Position[k1, alt]]]];> rr1 = Split[r1, #1[[1]] ==== #2[[1]] &];> r2 = ss2[[Flatten[Position[k2, alt]]]];> rr2 = Split[r2, #1[[1]] ==== #2[[1]] &];> Flatten[MapThread[Outer[List, #1, #2, 1] &, {rr1, rr2}], 2]]> Now the Timings:>> In[149]:=> Random[Integer, {1, 2000}]}, {250}];> Random[Integer, {1, 2000}]}, {500}];>> (I increased the size of the problem a bit)>> In[151]:= (myList = Flatten[Outer[List, s1, s2, 1], 1];> res00 => Select[myList, (First[First[#]] == First[Last[#]]) &]); // Timing> Out[151]=> {13.42 Second, Null}> In[152]:= res0 = myMatch0[s1, s2]; // Timing> Out[152]= {11.716 Second, Null}>> (BTW, why this comes out faster, is something I don't understand)>> In[153]:= res0 == Sort[res00]> Out[153]= True> In[154]:= res1 = myMatch[s1, s2]; // Timing> Out[154]= {15.703 Second, Null}>> (my miserable one)>> In[155]:= res1 == res0> Out[155]= True>> In[157]:= res2 = myMatch2[s1, s2]; // Timing> Out[157]= {0.24 Second, Null}>> (That's yours, quite fine!)>> In[158]:= res2 == res0> Out[158]= True>> In[160]:= res3 = myMatch3[s1, s2]; // Timing> Out[160]= {0.131 Second, Null}>> (your algorithm, improved)>> In[161]:= res3 == res0> Out[161]= True> Astonishingly, pretty old procedural programming is competitive:>> getLabelled[s_, labels_] :=> Module[{i = 1, len = Length[s], r},> (r = {};> While[i <= len && Order[s[[i, 1]], #] > 0, ++i];> While[i <= len && Order[s[[i, 1]], #] == 0, AppendTo[r, s[[i++]]] ];> r) & /@ labels]>> myMatch4[s1_, s2_] :=> Module[{ss1 = Sort[s1], ss2 = Sort[s2], k1, k2, keys, rr1, rr2},> k1 = Transpose[ss1][[1]]; k2 = Transpose[ss2][[1]];> keys = Intersection[k1, k2];> rr1 = getLabelled[ss1, keys];> rr2 = getLabelled[ss2, keys];> Flatten[MapThread[Outer[List, #1, #2, 1] &, {rr1, rr2}], 2]]> In[235]:= res4 = myMatch4[s1, s2]; // Timing> Out[235]= {0.25 Second, Null}>> In[236]:= res4 == res0> Out[236]= True>> (I know, this can be made a bit faster still!)>> Finally we also might compare to Sseziwa's solution>> In[172]:=> res5 = Join[Cases[s1, {#, _}], Cases[s2, {#, _}]] & /@> Intersection[Union[Transpose[s1][[1]]],> Union[Transpose[s2][[1]]]]; // Timing> Out[172]=> {0.621 Second, Null}>> Although Union is unnecessary here, it gives a slight performance> improvement (another riddle of Intersection -- to me; I might guess WRI> could do something there).>> res4 does not correlate the pairs, so we just look for occurances:>> In[180]:= Union[Flatten[res0, 1]] == Union[Flatten[res5, 1]]> Out[180]= True> --> Hartmut>> ==== =I need to save a mathematica output in a file with a given number of digitand in scientific format.(-fortranlike output)I tried ScientificForm but it only alter the format as displayed bymathemetica.I then tried SetPrecision and I found that I could only control the totalnumber of digit and so does notsolve my problemAny ideas out there?Jeff ==== =Can i make mathematica 4 show me the whole procedure it does before spittingout the result? ==== =I can't get this function to do anything. I read it in with Needs[Graphics`MultipleListPlot`];and no error messages appear, and the file IS present inthis directory:C:Program FilesWolfram ResearchMathematica4.1 (2)AddOnsStandardPackagesGraphics'MultipleListPlot.mbut when I do an example right out of Help such as<< Graphics`MultipleListPlot`(list1 = Table[{x, Sin[2 Pi x]}, {x, 0, 1, 0.1}]; list2 = Table[{x, Cos[2 Pi x]}, {x, 0, 1, 0.1}]);MultipleListPlot[list1, list2], nothing appears (no plot shows) except this text!(MultipleListPlot[{{0, 0}, {0.1`, 0.5877852522924731`}, {0.2`, 0.9510565162951535`}, {0.30000000000000004`, 0.9510565162951535`}, {0.4`, 0.5877852522924732`}, {0.5`, 1.2246063538223773`*^-16}, {0.6000000000000001`, (-0.5877852522924734`)}, {0.7000000000000001`,(-0.9510565162951535`)}, {0.8`, (-0.9510565162951536`)}, {0.9`, (-0.5877852522924734`)},{1.`, (-2.4492127076447545`*^-16)}}, {{0, 1}, {0.1`, 0.8090169943749475`},{0.2`, 0.30901699437494745`}, {0.30000000000000004`,(-0.30901699437494756`)}, {0.4`, (-0.8090169943749473`)}, {0.5`, (-1.`)}, {0.6000000000000001`, (-0.8090169943749472`)}, {0.7000000000000001`,(-0.30901699437494756`)}, {0.8`, 0.30901699437494723`}, {0.9`, 0.8090169943749473`}, {1.`, 1.`}}]) ==== => Can anybody trace the source of this old joke? I heard it back in > 1959-1960 when I was taking calculus.> Me too -- along with integral, zero to ice, of x squared.Suggest transfering further discussion, rapidly, to alt.folklore.urban or maybe alt.folklore.science. [agreed - please do this - moderator]-- Power tends to corrupt. Absolute power corrupts absolutely. Lord Acton (1834-1902)Dependence on advertising tends to corrupt. Total dependence on advertising corrupts totally. (today's equivalent) ==== =I have found that if there is a lot of detail in the graphic, you sometimesget better results if you expand the graphic size in Mathematica before youcopy.Stan Linauskas.>> I have found that the Windows Metafile format leaves graphics fairly> unperturbed. Fairly, not perfectly; there are often discrepancies in> spacing. You can export or copy into this format.>> Vince Virgilio>> -----Original Message-----> Sent: Tuesday, December 03, 2002 4:34 AM> To: mathgroup@smc.vnet.net>>> [I fear this is a FAQ but I've dutifully searched the current> 4.2 docs and this formus archive and could find only> recommendations for Mathematica 3.0]>> I'm trying to copy/export graphics from Mathematica to other> apps such as MS Word or PowerPoint. Graphs print great> directly from Mathematica (correctly rotates the y-axis text> even though it doesn't appear correctly on the screen). But> attempts to copy/paste into other applications (using PICT,> PICT with embedded postscript, and all other options) or> Export[file.GIF,%] etc. and then importing that file to> other apps usually produces something ugly and the y-axis> text never prints rotated from these other apps.>> I'm addicted to producing publication-quality graphics with> Mathematica, but I need to be able to include them in those> documents produced by other apps. I know the workaround is> simply to use Mathematica as my word processor for technical> documents, but I can't convert all my colleagues with whom I> exchange working drafts.>> Any suggestions appreciated, including RTFM if you will give> me a hint where to look.>> gary> ************************************> delivery of this message to the addressee, please note that this messagemay> contain ITT Privileged/Proprietary Information. In such a case, you maynot> copy or deliver this message to anyone. You should destroy this messageand> message that does not relate to the business of ITT is neither endorsed by> nor attributable to ITT.> ************************************>> ==== =Using version 4.1,Integral[Sin[x+d]/(x+d),{x,-Infinity,Infinity} ] yields 0 .This is, of course, incorrect. (Does version 4.2 make this error also?)Mathematica does Integral[Sin[x]/x,{x,-Infinity,Infinity}] correctlyhowever, yielding Pi, which should also be the answer for the originalintegral (regardless of the value of d).Does anyone have an idea why Mathematica gets the original integral wrong?David Cantrell-- -------------------- http://NewsReader.Com/ --------------------Usenet Newsgroup Service New Rate! $9.95/Month 50GB ==== =I was wondering if there was a simple expression (as a function of m and k )to computethe total number of solutions to the integer programming problem:n_1 + n_2 + n_3 + ... + n_k = mwhere m > k, each ni >= 1.Basically, I am trying to figure out the number of ways of partitioninga set with m unique elements into k non-empty disjoint subsets.For example, if k = 2, then the number of solutions ton_1 + n_2 = m is (m-1) = M_2(m) (say)if k = 3, then the number of solutions ton_1 + n_2 + n_3 = m is M_3(m) = sum_{i=1}^{m-2} (m-i-1) =sum_{i=1}^{m-2} M_2(m-i)I can think of a recursive solutions whereinM_2(m) = (m-1) andM_k(m) = sum_{i=1}^{m-k+1} M_(k-1)(m-i), k > 2Kumar ==== =disvovered that the portion of the plot between,9.5Pi and 11Pi is displayed as a line segment joining the points {9.5 , 9.5 Sin[9.5]} and {11 , 11 Sin[11]}. I've also found that the plot from x=-100 to x=99.99 is incorrect. The plot over the range [-100,99] is correct. What is happening here? Does this happen on other systems?-- STHHatton's Law: There is only One inviolable Law. ==== =It occured to me that there are probably enough users running Mathematica with the KDE to justify the creation of a KDE-specific mode wherein the keyboard mapping is harmonious with the default KDE settings. What do otheres think about this suggestions?-- STHHatton's Law: There is only One inviolable Law.Reply-To: kuska@informatik.uni-leipzig.de ==== =http:// www.library.cornell.edu/nr/bookcpdf/c15-5.pdfpage 683 Jens> Does anybody know where I can find the Levemberg-Marquardt algorithm> (theory, source code, whatever) that is implemented in the nonlinear fit? I> have some problems involving errors using the fit and need to calculate> them.> Luiz ==== =im sure if you try a search engine like google or yahoo you'll find it. justtype in the keywords in what your looking for.RAyRAy>Does anybody know where I can find the Levemberg-Marquardt algorithm>(theory, source code, whatever) that is implemented in the nonlinear fit? I>have some problems involving errors using the fit and need to calculate>them.>Luiz>> ==== =Luiz,You could try Iterative Methods for Nonlinear Equations and Unconstrained Optimization by J. Dennis and R. Schnabel. I think it's published by SIAM now.---Selwyn Hollis> Does anybody know where I can find the Levemberg-Marquardt algorithm> (theory, source code, whatever) that is implemented in the nonlinear fit? I> have some problems involving errors using the fit and need to calculate> them.> Luiz> ==== => Does anybody know where I can find the Levemberg-Marquardt algorithm> (theory, source code, whatever) that is implemented in the nonlinear > fit? I> have some problems involving errors using the fit and need to calculate> them.>There's a reasonable explanation in Numerical Recipes Chapter 15 section 15.5, there is a free version available at http://www.library.cornell.edu/nr/nr_index.cgi.Ssezi ==== =If you're not desperate to pull apart the algorithm, then leveraging the Java implementation might be the way to go, considering Mathematica seems to get along with Java reasonably well. Rijndael is supposed to be integrated into Java 1.4.1, though I found it to be missing from 1.4.0. Check out the javax.crypto package.If you look at the algorithm spec, it's all fast operations on bytes. It's tricky to make some of the operations (like the key-schedule) work in a functional manner, and the result is pretty unreadable compared to the original spec IMHO. Some of the algebraic operations can be made to look more elegent in Mathematica though.Tim.> I'm a french student in Computer Science, and crypto, and i want to know> if somebody have the mathematica implementation of Rijndael, or some> good url where i could find ressources about it.> > Sincerely> ==== =Good day, I have a question about the utilization of FITS format. I haveMathematica 4.2 for Students and I'm trying to display and analyze thoseimages. Since 4.2 is suppose to have added the FITS format to the list ofrecognized formats how come I cannot use the standard functions to view andmanipulate them? I use image=Import[m22.fits]; Then Show[image]It does not display anything!I bought the add-on Digital Image Processing (1.1) and again I cannot useany of the functions in that package.In a nut shell: I thought that FITS format could be used the same way a JPEGformat or any image (pic) format is used (displayed,manipulated,analyzed).Am I doing something wrong or maybe I did not understand something aboutthis new feature in Mathematica 4.2?Robert Pigeon ==== =Regard this function:f[x_] := Sin[x]^3 * Cos[x]And then try this:Solve[f'[x] == 0, x]and you'll get a list of all roots but one. I wonder why.By regarding f'[x] one can directly see that x = pi is a root,yet, Mathematica fails to see it...V.8anligenKonrad------------------- ==== =Dearest groupHas anyone noticed this before? I would like to use KSubsets andRandomKSubsets a few million times in a proggy, but after executing it a fewthousand times Mathematica crashes, running out of memory. Watching my Taskman (Win2K, Mathematica 4.1) we see a constant increase in memory used, until its all soakedup. I have this problem with both the Combinatorica.m that shipped withMathematica, and the new one that has been written, which I believe is now the onein Mathematica 4.2. I am not really sure what it means to Ôleak memory', but thisseems to fit the bill.Here is a crashing-demo. Executing memorySwallower[3,100], for example,repeatedly just soaks up more and more memory. Pourquoi? I believe thesame thing happens if I use KSubsets also.In[1]:=MemoryInUse[]Get[DiscreteMath`Combinatorica`] MemoryInUse[]Out[1]=1398624Out[3]=1956536memorySwallower[S_,n _]:= Module[{data,subsamples},Print[ToString[MemoryInUse[]]]; Table[data=Table[{i,j},{i,1000},{j,1+m}]; subsamples=Table[RandomKSubset[data,S],{100}],{m,n}]; Print[ToString[MemoryInUse[]]]]memorySwallower[3,100] 1549793629833672B_____________________________ Bernard Gress Department of Economics University of California, Riverside 1150 University Ave. Riverside, CA 92521-0247 BGRESSatMAILdotUCRdotEDU http://www.economics.ucr.edu/people/candidates.html ==== =at school the command plot makes mathematica opena new page witch contains the graphics but it dont seems tobe a preset of mathematica so my question is how can Iconfigure mathematica to make im plot my grapchics in new pagethanks. ==== =Elegance often lies in the eye of the beholder. But this is shorter than theone you propose, I guess:In[1]:=Rest[list1 + RotateRight[list1]]/2Out[1]={(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}Tomas GarzaMexico City----- Original Message -----> It can be done for this function>> f[data_List] := Drop[Plus @@ NestList[RotateRight, data,> 1], 1]/2>> f[list1]>> but I am sure that some member of the group can find a more elegantfunction. I> will appreciate to know it.> Guillermo Sanchez> ---------------------------------------------> This message was sent using Endymion MailMan.> ==== => I have a list:>> list1 = {a, b, c, d, e};>> I want manipulate the list to obtain:>> (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*)>> It can be done for this function>> f[data_List] := Drop[Plus @@ NestList[RotateRight, data,> 1], 1]/2>> f[list1]>> but I am sure that some member of the group can find a more elegant> function. I will appreciate to know it.> Guillermo Sanchezf[data_List] := Apply[Plus, Partition[data, 2, 1], 1] / 2Rob PrattDepartment of Operations Researchhttp://www.unc.edu/~rpratt/ ==== => I'm trying to find roots of the characteristic equation of a> dielectric-loaded waveguide. There are multiple roots of the equation and I> use FindRoot to find them. The sequence of roots is very important in my> further calculations.> Is there a routine or a clever way to (numerically) find all the roots of an> equation in a predefined values?> As it is now I have to look for each individual root manually and it gets a> bit tedious as the number of required modes increases.> --> Novak Petrovic> novak@itee.uq.edu.auThis probably depends on the specifics of your equations (polynomial?exponential? analytic? other?) and region of interest (a segment?rectangle in complex plane? something else?). A similar question wasraised at the URL below. Several replies showed various approaches onemight take.http://forums.wolfram.com/mathgroup/archive/2001/Jun/ msg00226.htmlFor certain special cases one might be able to get exact solutions e.g.by using Solve and taking advantage of periodicity e.g. for atrigonometric polynomial. This can only be done if the equation is suchthat Solve can form a polynomial in some reasonable set of variables.Daniel LichtblauWolfram Research ==== =Novak: Ted Ersek's package, RootSearch, may help. You can find it at: Best, HarveyHarvey P. DaleUniversity Professor of Philanthropy and the LawDirector, National Center on Philanthropy and the LawNew York University School of LawRoom 206A110 West 3rd StreetNew York, N.Y. 10012-1074tel: 212-998-6161fax: 212-995-3149-----Original Message-----equation in a predefined values?As it is now I have to look for each individual root manually and itgets abit tedious as the number of required modes increases.--Novak Petrovicnovak@itee.uq.edu.au ==== =Guillermo,list1 = {a, b, c, d, e};ListConvolve[{1, 1}/2, list1]//Simplify{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ function. Iwill appreciate to know it.Guillermo Sanchez---------------------------------------------This message was sent using Endymion MailMan. ==== =Veniamin,Yes, you can make the mesh better fit the surface by doing a coordinatetransformation for the plotting and then reverse transform all of thepoints. It may not always be easy to find suitable transformations. Here isan easy case.f[x_, y_] := Exp[-x]Plot3D[Evaluate[f[x, y]], {x, 0, 10}, {y, 0, 10}, PlotPoints -> {20, 10}, BoxRatios -> {1, 1, 1}, PlotRange -> All];The above plot is not great because it has wide spacings in the steepestpart of the surface and narrow spacings in the ßat portion. What we do ismake a plot versus Log[x].plot1 = Plot3D[Evaluate[f[E^u, y]], {u, -3, Log[10]}, {y, 0, 10}, PlotPoints -> {20, 10}];Of course, that isn't what you really want but it has better spacing. Now weconvert the plot from SurfaceGraphics to Graphics3D and take the first partto obtain the primitive graphics.logplot = First[Graphics3D[plot1]];Then we display the plot using a rule to transform all of the points in theplot to get back to the x scale.Show[Graphics3D[ logplot /. {u_?NumberQ, y_?NumberQ, z_?NumberQ} -> {Exp[u], y, z}], Axes -> True, AxesLabel -> {x, y, f}, BoxRatios -> {1, 1, 1}, ImageSize -> 450];Now you have close spacing in the steep part of the surface and wide spacingin the ßat portion.This can be done a little easier with the DrawGraphics package at my website below. The plot routines automatically extract the primitive graphics,which can then be manipulated - here with the DrawingTransform3D routine.Needs[DrawGraphics`DrawingMaster`]Draw3DItems[ {Draw3D[Evaluate[f[Exp[u], y]], {u, -3, Log[10]}, {y, 0, 10}, PlotPoints -> {20, 10}] /. DrawingTransform3D[Exp[#1] &, #2 &, #3 &]}, Axes -> True, AxesLabel -> {x, y, f}, BoxRatios -> {1, 1, 1}, ImageSize -> 450];Mathematica automatically uses even spacing in a rectangular domain for allthe plotting so this type of procedure is needed to change that.DrawGraphics also has routines for transforming plotting functions so thatthe plotting domain does not have to be rectangular or the second plottingdomain can depend upon the first.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ Veniamin ==== =Novak,You might want to try the RootSearch package by Ted Ersek available onMathSource. It is quite robust, and will find all the roots in a giveninterval. I'm not certain at the moment if it gives them in order, but itprobably does. In any case you could always sort them.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/--Novak Petrovicnovak@itee.uq.edu.au ==== =ListConvolve[{1, +1}, list1]/2James ==== =I have the following problem. Given two random points on a sphere, I wouldlike to connect them with a curve that goes Ôapproximately' on the sufraceline segments.Connecting the points with a straigh line is achived by Line[{pt1,pt2}].I am failing to get good ideas on how to approach the problem, wouldappreciate any hint / trick / tip.Borut LevartSlovenia ==== =I too found the documentation experience a bit disorienting at first. Isuspect it's because it isn't based on the full text search model we'veall come to be familiar with. You sometimes have to work to phrase yourdesires properly, just as you do with full text search, but it's adifferent kind of tailoring: one that may cause one some discomfortuntil one gets used to it.> Dave,> I disagree. I think that Mathematica has very good documentation and that is> one of its strong points. All of the principal commands have individual Help> pages and also their individual usage messages. It is easy to get to them.> The book index and master index are very long.> One of the best features is that the user can write his own documentation> for his own packages and completely integrate it with the standard> documentation.> Yes, the documentation is not completely perfect - but this is a massive> piece of software. As with any program it does take new users a little while> to find their way around.> My experience is that Mathematica has the best documentation of any program> I have used (mainly things like Word and Excel).> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/> To: mathgroup@smc.vnet.net>>> Have an entry under Graphics Primitives>> Have an entry under Primitives>> Have an entry under Graphics Directives>> Have an entry under Directives>>............>>Dave,>>I almost always use the on line Help Browser>>Set the category to Master Index and these are found.>>The first three are in the printed book's index,>>-->Allan>> I type primitives in the Master Index and get section 2.9.1, which does> not> have a list of all the primitives. Yes, of course I found it sooner or> later.> But that's not a good index.> All I can say is that, when someone asks me about Mathematica, I'll say it> is> hard to use for many reasons, and one of them is the poor documentation.> Dave Golber ==== =I wish all software had the same level and quality of documentation that Mathematica does. The stuff that Microsoft includes for the Office apps is a joke -- especially considering what the documentation for the older versions used to be. Mathematica is the only major program I know where the amount of documentation increases with each new version.More than many technical programs, Mathematica has a different Ômindset', which can take some getting used to, especially if your mind works differently.Whenever I get a new version of Mathematica, I always read the entire book -- even the parts that I do not understand. I find that this makes tasks like guessing the correct thing to type in the help system much easier.George> Dave,>> I disagree. I think that Mathematica has very good documentation and > that is> one of its strong points. All of the principal commands have > individual Help> pages and also their individual usage messages. It is easy to get to > them.> The book index and master index are very long.>> One of the best features is that the user can write his own > documentation> for his own packages and completely integrate it with the standard> documentation.>> Yes, the documentation is not completely perfect - but this is a > massive> piece of software. As with any program it does take new users a little > while> to find their way around.>> My experience is that Mathematica has the best documentation of any > program> I have used (mainly things like Word and Excel).>> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/>> To: mathgroup@smc.vnet.net>> Have an entry under Graphics Primitives> Have an entry under Primitives> Have an entry under Graphics Directives> Have an entry under Directives>> ............>> Dave,>> I almost always use the on line Help Browser>> Set the category to Master Index and these are found.>> The first three are in the printed book's index,>> -->> Allan> I type primitives in the Master Index and get section 2.9.1, which > does> not> have a list of all the primitives. Yes, of course I found it sooner or> later.> But that's not a good index.>> All I can say is that, when someone asks me about Mathematica, I'll > say it> is> hard to use for many reasons, and one of them is the poor > documentation.>> Dave Golber>> ==== =It is astonishing that debates like this keep coming up. To anyone who disagrees with the notion that 1^Infinity is indeterminate, I suggest that you write something called a new kind of calculus. But you might want to learn the old kind first.---Selwyn Hollis ==== =I need some help, here. I'm using Mathematica 4.2 on OS X and I'd like to save a notebook so that I can include it in a LaTeX file. According to the Wolfram site, Mathematica has a convenient save as option just for this sort of task. Unfortunately, I can't get it to work for the life of me. The notebook saves, but it won't compile.I use TeXShop, a very standard LaTeX environment for OS X that's built (I believe) on top of teTeX. Per the Ôrequest' of my LaTeX compiler, I've located copies of notebook2e.sty and wrisym.sty, but this doesn't help; the fatal error is something like Ô! LaTeX Error: This NFSS system isn't set up properly.'Does anybody out there have a slick solution to my problem? It seems to me that Wolfram should have made this process work out-of-the-box with standard installations of Mathematica 4.2 and standard installation of LaTeX utilities. Perhaps I'm missing something.I hope somebody out there can give me a hand with this. (FWIW, I have access to latex and Mathematics 4.2 on linux and NT platforms, too.)-- Jason Miller, Ph.D.Division of Mathematics and Computer ScienceTruman State University100 East Normal St.Kirksville, MO 63501http://vh216801.truman.edu660.785.7430 ==== =ListConvolve[{ 1/2, 1/2}, {a, b, c, d, e}]orPlus[##]/2 & @@@ Partition[{a, b, c, d, e}, 2, 1]> I have a list:>> list1 = {a, b, c, d, e};>> I want manipulate the list to obtain:>> (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*)>> It can be done for this function>> f[data_List] := Drop[Plus @@ NestList[RotateRight, data,> 1], 1]/2>> f[list1]>> but I am sure that some member of the group can find a more elegant function. I> will appreciate to know it.> Guillermo Sanchez> ---------------------------------------------> This message was sent using Endymion MailMan.>>Reply-To: kuska@informatik.uni-leipzig.de ==== =Plus @@@ Partition[list1, 2, 1]/2 Jens> I have a list:> list1 = {a, b, c, d, e};> I want manipulate the list to obtain:> (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*)> It can be done for this function> f[data_List] := Drop[Plus @@ NestList[RotateRight, data,> 1], 1]/2> f[list1]> but I am sure that some member of the group can find a more elegant function. I> will appreciate to know it.> Guillermo Sanchez> ---------------------------------------------> This message was sent using Endymion MailMan. ==== => I have a list:>> list1 = {a, b, c, d, e};>> I want manipulate the list to obtain:>> (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*) list1={a,b,c,d,e}; ListCorrelate[{1,1},list1]/2 {(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKwww.haystack.demon.co.ukhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198> I have a list:>> list1 = {a, b, c, d, e};>> I want manipulate the list to obtain:>> (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*)>> It can be done for this function>> f[data_List] := Drop[Plus @@ NestList[RotateRight, data,> 1], 1]/2>> f[list1]>> but I am sure that some member of the group can find a more elegantfunction. I> will appreciate to know it.> Guillermo Sanchez> ---------------------------------------------> This message was sent using Endymion MailMan.> ==== =This does what you want:list1 = {a, b, c, d, e}Apply[Plus, Partition[list1, 2, 1], 1]/2Steve Luttrell> I have a list:>> list1 = {a, b, c, d, e};>> I want manipulate the list to obtain:>> (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*)>> It can be done for this function>> f[data_List] := Drop[Plus @@ NestList[RotateRight, data,> 1], 1]/2>> f[list1]>> but I am sure that some member of the group can find a more elegantfunction. I> will appreciate to know it.> Guillermo Sanchez> ---------------------------------------------> This message was sent using Endymion MailMan.> ==== =Listability of basic numerical operators is a major feature of Mathematica__use it!Your target is equal to ({a,b,c,d}+{b,c,d,e})/2So:(Drop[list1,-1]+Drop[list1,1])/ 2Also:Drop[list1+RotateLeft[list1],-1]/2Orestis> I have a list:> list1 = {a, b, c, d, e}; > I want manipulate the list to obtain: > (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*)> It can be done for this function> f[data_List] := Drop[Plus @@ NestList[RotateRight, data, > 1], 1]/2> f[list1]> but I am sure that some member of the group can find a more elegant function. I > will appreciate to know it.> Guillermo Sanchez> ---------------------------------------------> This message was sent using Endymion MailMan. ==== =Use ListCorrelate:In[1]:=ListCorrelate[{1, 1}, {a, b, c, d, e}]/2 a + b b + c c + d d + eOut[1]= {-----, -----, -----, -----} 2 2 2 2Kezhao> I have a list:> list1 = {a, b, c, d, e}; > I want manipulate the list to obtain: > (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*)> It can be done for this function> f[data_List] := Drop[Plus @@ NestList[RotateRight, data, > 1], 1]/2> f[list1]> but I am sure that some member of the group can find a more elegant function. I > will appreciate to know it.> Guillermo Sanchez> ---------------------------------------------> This message was sent using Endymion MailMan. ==== =Mathematica generally uses indeterminate for expressions which are by nature ambiguous, which means they can be represented as limits leading to different answers. This is the case with 1^Infinity. For example, consider(2^(1/n))^n and let n tend to Infinity. This can be thought of as 1^Infinity yet it remains all the time equal to 2.I assume the same is true with other expressions where Indeterminate is returned. Of course this is not mathematically the only valid approach, one adapt various conventions, for after all these are but conventions. But personally I find it rather convenient and have got programming examples which only work because Indeterminate rather than a number are returned in similar cases. I personally think this answer is on the whole more ßexible than any alternative, and I would vote for keeping it.Andrzej Kozlowski> Isn't this a bit like trying to divide by zero?>> Infinity + Infinity = Infinity; however, one can not subtract infinity > from> infinity or or divide by it.>> Steven Shippee> shippee@jcs.mil> Consider this:>> In[1]:=>> 1^Infinity>> Out[1]=>> Indeterminate>> --------->> I agree 1.0^Infinity is Indeterminate because 1.0 might be a bit >> less>> than 1 or a bit greater than 1.>> but isn't (1*1*1* ..... *1) simply the integer 1.>> --------->> Ted Ersek>>>> ==== =It seems to me that at least for shortness this will be hard to beat:(list1 + RotateLeft[list1])/2{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2, (a + e)/2}Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> I have a list:>> list1 = {a, b, c, d, e};>> I want manipulate the list to obtain:>> (*Out[]:{(a + b)/2, (b + c)/2, (c + d)/2, (d + e)/2}*)>> It can be done for this function>> f[data_List] := Drop[Plus @@ NestList[RotateRight, data,> 1], 1]/2>> f[list1]>> but I am sure that some member of the group can find a more elegant > function. I> will appreciate to know it.> Guillermo Sanchez> ---------------------------------------------> This message was sent using Endymion MailMan.>>>