mm-629 === Subject: Re: notebook font encoding Mathematica notebooks (which is to say the modern .nb format...I'm assuming you're not dealing with the very old .ma file format) are written in a neutral character encoding that fully represents plane 0 Unicode. I can think of a couple of cases where exceptions slip through, but in general, you shouldn't see these kinds of problems and the setting of $SystemCharacterEncoding should be irrelevant for purposes of exchanging notebook files. The exceptions I can think of are... * PostScript graphics do not contain Unicode representations, and could render differently between Windows and Mac for some European-only characters. Graphics will not suffer from this problem in the next release, incidentally. * If the notebook contains a style that specifically indicates a character encoding contrary to the normal one being used. This is rare, and you'd probably know if you'd done this. * If there's a bug in Mathematica's encoding mapping tables. For example, earlier versions of Mathematica for Windows were missing the mapping tables for Cyrillic, and so would write improper Cyrillic notebook files even though everything looked correct as you typed it. If the problem is in graphics, you'll just have to suffer the limitation for now (or just re-evaluate the affected graphics on the system you're on now, which ought to fix the problem), but if it's elsewhere, feel free to send me a sample notebook you're having problems with and I'll be happy to take a look at it to see how it came to be. And please be clear as to what the problem is...since I don't read Italian, I won't be able to spot the error without some help. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > Hello! > I have received a notebook written with Mathematica presumably on > an Italian Windows machine. Displaying it on my Macintosh I get many > accented letters wrong (some look right, though). > I tried opening it with OpenSpecial with Latin1 and other encoding, > but I couldn't get the display right. > Does anybody know what the $SystemCharacterEncoding is for Italian > Windows machines? > Is it possible that a notebook edited on two different machines at > different times gets a mixture of encodings? > Gianluca Gorni === Subject: MathGL3d and Mathematica 5.3 attention wolfram ... please include MathGL3d in Mathematica 5.3. i'm very disapointed that mathematica still does not have an integrated interactive 3d viewer after so many years. Mitch === Subject: Using Get in a Module I am returning to Mathematica 5.2 after a hiatus, and have a few questions. I have text files that contain valid Mathematica assignments, such as x = {1,2,3}; There are several assignments in a single file, as the files are data dumps from a larger system. If a top-level notebook contains <filename<>.txt; <Automatic] But, compared to the firste Show[...] expression, this is a rather cumbersome way of doing this. Is there a shorter way to display a graylevel images properly scaled (0-255). I did not find anything in the Digital Image Processing documentation. Maarten === Subject: Re: Re: 2D FT of f(r): Fast Hankel Transforms Hi Hyper > You can implement them as a convolution with a digital > filter. Google > for various papers so you can derive coefficients, but one I'd > recommend is JOHANSEN, HK, AND SORENSEN, K. Fast Hankel > transforms in > Geophysical Prospecting from a fair while ago. > I'll certainly look into it, thank you. The choice of > journal is intriguing...what are the applications of FHTs to > Geophysics? They enter in electromagnetic prospecting in fields of electric dipoles. I believe they are also used in magnetic & gravimetric prospecting. Dave. === Subject: MeijerG evaluates an imaginary part, which does not exist please have a look at http://people.freenet.de/Peter_Berlin/Mathe/schon_wieder_MeijerG.nb There is an integral evaluating to 0.9.. or 0.07... depending on the method used. And the first attempt leads to an imaginary part Abs[Im[value]]~=4.8. I would really like to know wether development-versions of Mathematica handle MeijerG in a more satisfactory way (Daniel Lichtblau!?) Peter === Subject: Re: Problem plotting high-order Laguerre polynomials > I'm doing some work which involves plotting fairly high-order Laguerre > polynomials, up to 200 or so. I've been getting some very strange and > obviously incorrect results which seem to have to do with the order of > evaluation. (I'm using Mathematica 5.0, but I've checked it in 5.2 and I > get the same problems.) Here are some examples with a simple form of the > type of function I'm working with: > func = 1/Pi Exp[- q^2] LaguerreL[n, 2 q^2] Another approach to plotting/computing high-order polynomials is to use an appropriate asymptotic form. Note that (from Szego or Abramowitz and Stegun) the leading term in the asymptotic expansion for large n is Exp[- x/2] LaguerreL[n, x] ~ BesselJ[0, 2 Sqrt[n x]] See also http://locus.siam.org/SIMA/volume-19/art_0519087.html. Paul _______________________________________________________________________ Paul Abbott Phone: 61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul === Subject: Re: determinant of sparse matrix > Are there methods for computing the determinant of (large) sparse > matrices? Mathematica shuts down the kernel when I ask for > Det[iden] > where > iden = SparseArray[{i_, i_} -> 1. {10^4, 10^4}, 0.] > Of course I know the answer in this case, but more generally I'm > interested in the determinant of tridiagonal positive definite matrices. A general n x n tridiagonal matrix with diagonal entries a[i], super-diagonal entries b[i], and sub-diagonal entries c[i], is tri[n_] := SparseArray[{ {i_, i_} -> a[i], {i_, j_} /; j - i == 1 -> b[i], {i_, j_} /; i - j == 1 -> c[j] }, {n, n}] The determinant of such a matrix can be computed recursively using standard properties of the determinant: Clear[det] det[0] = 1; det[1] = a[1]; det[n_] := det[n] = a[n] det[n-1]-b[n-1]c[n-1]det[n-2] with no need to explicitly construct the matrix. As a check Simplify[ det[7] == Det[tri[7]] ] For a large matrix you will have to increase the $RecursionLimit, say $RecursionLimit = 10^4 and, if the expressions for a[i], b[i], c[i], are exact, then the resulting expression can be huge. On the other hand, for numeric entries, the result is likely to be quite reasonable. Paul _______________________________________________________________________ Paul Abbott Phone: 61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul === Subject: notebook applications Hi guys, I heard that certain notebook-based applications of MATHEMATICA are distributed free-of-charge. If so, I want the links for applications like Control Systems , Signal Processing and Time-Series package. A longtime back , a William Haager's website contained notebooks for control systems. If you know his URL , will you forward it to me ? === Subject: Re: NIntegrate[Abs] bug in v5.1, not v5.0 > First, I establish that everything works in v5.0. > In[1]:= > f[x_]:=E^-(Sin[.1+x]^2)-E^-(Sin[.1-x]^2) > In[2]:= > {$Version,$ReleaseNumber} > Out[2]= > In[3]:= > Timing[NIntegrate[-f[x],{x,0,Pi/2},AccuracyGoal->1]] > Out[3]= > {0.001438 Second,0.125515} > In[4]:= > Timing[NIntegrate[Abs[f[x]],{x,0,Pi/2},AccuracyGoal->1]] > Out[4]= > {0.0015 Second,0.125515} > Now I try again in v5.1. > In[1]:= > f[x_]:=E^-(Sin[.1+x]^2)-E^-(Sin[.1-x]^2) > In[2]:= > {$Version,$ReleaseNumber} > Out[2]= > In[3]:= > Timing[NIntegrate[-f[x],{x,0,Pi/2},AccuracyGoal->1]] > Out[3]= > {0.001286 Second,0.125515} > In[4]:= > Timing[NIntegrate[Abs[f[x]],{x,0,Pi/2},AccuracyGoal->1]] > This produces no output for several minutes. Then the Kernel crashes. Any > ideas? Mathematica 5.1 has new methods for numerical integration of piecewise functions. If you want to emulate the behaviour of Mathematica 5.0, specify the method explicitly: In[2]:= NIntegrate[Abs[f[x]], {x, 0, Pi/2}, Method -> GaussKronrod] Out[2]= 0.12551527 This shows that by default NIntegrate calls Reduce: Trace[ TimeConstrained[NIntegrate[Abs[f[x]], {x, 0, Pi/2}], 1], Reduce, TraceInternal -> True] trying to evaluate something similar to Reduce[Rationalize[f[x]] >= 0 && 0 < x < Pi/2, x, Reals] but it doesn't finish in 10 minutes. A seemingly harder example works without a problem: In[3]:= Reduce[Rationalize[f[x]] >= 0 && 0 < x < Pi/2, x] Out[3]= False Apparently a different algorithm is being used in this case. Maxim Rytin m.r@inbox.ru === Subject: nonspurious bug report (probably PackedArray related) Try the following with n < 100 and then with n >= 100. You'll see something goes drastically awry! Map[ReplacePart[{{1, 1}}, {#}, 1] &, Range[n]] The problem exists in (at least) version 5.2, both Windows and Linux. -- http://ai.eecs.umich.edu/people/dreeves - - search://Daniel Reeves === Subject: creating packages of my own. Hi buddies I have written a small code , say, SquaresAll in the form of a Module[...] . Say this is saved in notebook X . I want to call the Module SquaresAll again in another notebook Y in another new Mathematica session. How can I do this ? I even tried to write it in the form of a Package , but the Mathematica Help was too complicated for me to understand. Can any of you put it in simple words ? === Subject: Re: FindFit and NormFunction -----Original Message----- === Subject: Re: FindFit and NormFunction > I am having difficulty using the NormFunction option to FindFit. Let me > give a concrete example. Abramowitz and Stegun Section 17.3.35 gives a > nonlinear approximant to the complete elliptic integral. See > > > This approximant to EllipticE[1-m] can be implemented as > > f[a_, b_, c_, d_][m_] = a m + b m^2 - (c m + d m^2) Log[m] + 1; > > After sampling EllipticE[1-m], > > data = N[Table[{m, EllipticE[1-m]}, {m, 10^-8, 1 - 10^-8, 10^-3}]]; > > using FindFit gives quite a decent approximant: > > FindFit[data, f[a, b, c, d][m], {a,b,c,d}, m] > > best[m_] =f[a, b, c, d][m] /. % > > The maximal absolute fractional error is ~6 x 10^-5 as seen from > > Plot[10^5 (1 - best[m]/EllipticE[1 - m]), {m, 0, 1}, PlotRange -> All] > > However, the Abramowitz and Stegun approximant has error ~4 x 10^-5. > > AS[m_] =f[0.4630151, 0.1077812, 0.2452727, 0.0412496][m]; > One option is to try a global optimizer instead of FindFit: > In[4]:= (sol = NMinimize[ > Norm[data[[All, 2]] - f[a, b, c, d][data[[All, 1]]], Infinity], > {a, b, c, d}, > Method -> {DifferentialEvolution, CrossProbability -> .05}]) // Timing > Out[4]= {22.953*Second, {0.000035864209, {a -> 0.46224543, b -> > 0.10851758, c -> 0.24549621, d -> 0.041990523}}} > I've been unable to reproduce your result on my computer using version 5.1: > In[11]:= (sol = NMinimize[ > Norm[data[[All,2]] - f[a, b, c, d][data[[All,1]]], Infinity], > {a, b, c, d}, > Method -> {DifferentialEvolution, CrossProbability -> 0.05}]) // Timing > Out[11]= {14.422*Second, {0.000170617785, {a -> 0.47491173, b -> > 0.09573489, c -> 0.24082805, d -> 0.034393029}}} > I also tried using several different values of RandomSeed, but was never > able to get an error as low as your 0.000035864209. Why was I unable to > reproduce your result? Could it be because I'm using version 5.1? > A triviality: Looking at the documentation for NMinimize, I had thought > that double quotation marks would be _required_ around the Method option > names, that is, Method -> {DifferentialEvolution, CrossProbability -> > 0.05}. But I see now that the quotation marks are not needed (although they > still can be used). Is the documentation out of date? > Plot[ > {EllipticE[1 - m] - AS[m], > EllipticE[1 - m] - f[a, b, c, d][m] /. sol[[2]]}, > {m, 0, 1}, PlotRange -> All, PlotStyle -> {Red, Blue}] > Actually this approximation has a smaller relative error as well as > smaller absolute error than AS[m]. > Indeed it does. Explanation: > Formula 17.3.35 in A&S is from a book of computer approximations by > Hastings. I haven't looked at that book, and so I don't know whether or not > Hastings makes it clear that 1 + a + b must be Pi/2. But whether stated or > not, that was apparently a restriction used by Hastings to insure that the > approximation would give the exact value of EllipticE[1 - m] at the end > point m = 1. And of course, the fact that the constant term in the > approximation was 1 insured that it would also give the exact value at the > other end point, m = 0. I assume that Hastings _wanted_ the approximation > to be exact at both extremes of m. If my assumption is correct, then the > values of the coefficients and the error given by Hastings are OK. > OTOH, if the only objective were to minimize worst |error|, then your > result (which does not give the exact value at m = 1) is, as you indicated, > better than Hastings. Furthermore, there is no reason that the constant > term should be 1 if we do not require an exact value at m = 0. Dropping > that restriction, we can then get a still better approximation, > having |error| < 3*10^-5: > f[a_, b_, c_, d_, e_][m_] = a m + b m^2 - (c m + d m^2) Log[m] + e > with {a -> 0.464167, b -> 0.106570, c -> 0.244708, d -> 0.040691, > e -> 1.00002943} > One could similarly improve formula 17.3.36 in A&S. But to my taste at > least, it's nicer to have approximations which give EllipticE[1 - m] > exactly at the extremes of m. > David Cantrell You're correct, the NMinimize algorithms, in particular the local search methods (e.g., submethod InteriorPoint for RandomSearch), underwent some changes in version 5.2. My guess is that if you were to try In[4]:= NMinimize[ Norm[data[[All, 2]] - f[a, b, c, d][data[[All, 1]]], Infinity], {a, b, c, d}, Method -> {DifferentialEvolution, CrossProbability -> .05, PostProcess -> False}, MaxIterations -> 1000] Out[4]= {0.000035461782, {a -> 0.46215121, b -> 0.10860872, c -> 0.24552379, d -> 0.042078762}} (turning the local search off), the results would be the same in versions 5.1 and 5.2. Or we can optimize the function f[a, Pi/2 - 1 - a, c, d][m] if the value at m = 1 is fixed. It is probably safer to use strings, as shown in the documentation (DifferentialEvolution, etc.). For instance, I think in earlier versions of Mathematica Developer`SetSystemOptions accepted only strings, not symbols; now it accepts both. I just prefer to use symbols for uniformity and also because then I can use Ctrl-K (command completion) to speed up the typing. Maxim Rytin m.r@inbox.ru