A123 === Subject: Re: imagesize to full width of current screen > greetings, > i'm trying to determine the current width of the notebook screen to > size graphics and manipulate's to fit the whole width of the window. = > > i've looked at PageWidth, ImageSize->All, ImageSize->Full, ImageSize- > >Large, ImageSize->Scaled[s] (ImageSize->Scaled@1 is equivalent to = > > ImageSize->Full), $* variables, ... > this is a common feature in other programming languages (javascript in = > > web browsers for example). i've also searched this mailing list > without success. any ideas? > Mitch >> the information is in the WindowSize option of the corresponding >> notebook object. This will give you the size of the notebook that >> evaluates it: >> >> WindowSize /. Options[EvaluationNotebook[]] >> >> when working with manipulates and palettes you also might want to use >> ButtonNotebook[] , SelectedNotebook[] and Notebooks[] to get a handle at >> the notebook you are after. >> >> Just in case: You can also get the size of the screen with: >> >> ScreenRectangle /. Options[$FrontEnd] >> >> which then lets you choose a reasonable size for a new notebook/window. > ScreenRectangle does not appear in the $FrontEnd options in Mathematica 6.0, > but it is mentioned in the Help file as a function not yet fully > integrated (in 6.0). > Is there any other way to call it? in another post there was mentioned: FullScreenArea /. SystemInformation[Devices, ScreenInformation] SystemInformation is new in version 6 and it is not clear to me how fully integrated this is and whether it could be changed in newer versions, but it might be a better choice. Note that ScreenRectangle is an option for $FrontEnd since at least version 4.2, so it has quite a history in being not yet fully integrated :-) hth, albert === Subject: Re: imagesize to full width of current screen magma, Try Options[$FrontEnd, ScreenRectangle] or (from Mathematica 6 on) CurrentValue[$FrontEnd, ScreenRectangle] === Subject: Re: Real and Complex Roots presented in a single plot We can also recognize and see the real parts of all = the complex roots of z where the curve is nearest to x -axis at {1.4, 4.2, 6.6, 9.6, 12.3, 15.3, 17.7}. They are near to x-values where the local maxima/minima occur.But we cannot 'see' their complex parts, as they need to be computed. > > Please note that your claim that the real part of the complex roots is > found at the local minima of the given function as the indipendent > variable moves on the real axis, is not valid in general and wrong in > this particular instance. > > For example in the interval {1,2} there are 2 local extrema found > using the derivative: > > f[z_] := 1.3 Sin[1.7 z] + 0.6 Sin[4 z] > > The derivative: > > In[43]:= fp[z_] := D[f[z], z] > > In[44]:= fp[z] > > Out[44]= 2.21 Cos[1.7 z] + 2.4 Cos[4 z] > > In[73]:= extrema = z /. FindRoot[fp[z], {z, #}] & /@ {1.4, 1.6} > > Out[73]= {1.33751, 1.69029} > > The first is the local minimum (see the plot). > But the complex roots in interval {1,2} are > > 1.27946 + 0.374308 I and 1.27946 - 0.374308 I > > The real part is 1.27946, while the minimum was at 1.33751 (I do not have Presentations). My point is that 1.33751 is sufficiently near to and corresponding to the root place holder 1.27946 so that succesive tangents drawn in complex Newton-Raphson procedure the roots would not settle anywhere else. Narasimham > This can be visualized on the complex plane using Presentations: > > f[z_] := 1.3 Sin[1.7 z] + 0.6 Sin[4 z] > > Needs[Presentations`Master`] > > fp[z_] := D[f[z], z] > > extrema = z /. FindRoot[fp[z], {z, #}] & /@ {1.4, 1.6} > > roots = z /. > FindRoot[ > f[z], {z, ToComplex@#}] & /@ {{-0.005546, -0.02102}, {1.28= 5, > 0.3771}, {1.279, -0.3678}, {2.081, > 0.01109}, {3.462, -0.008173}, {4.194, -0.3485}, {4.213, > 0.345}} // Chop; > > In the following plot we see the roots (blu) and the extrema (red) in > the interval {1,2} > > With[{zmin = -.5 - I, zmax = 5 + I, > contourlist = {0, 0.1, 0.2, .5, .505, .5095, .51, .53, 0.55, 0.57, > 0.6, .61, .62, .6205, 1}}, > Draw2D[{ComplexCartesianContour[f[z], {z, zmin, zmax}, Abs, > Contours -> contourlist, ColorFunctionScaling -> False, > ColorFunction -> (ContourColors[contourlist, > ColorData[SolarColors]][#] &), PlotPoints -> {30, 15= }, > MaxRecursion -> 3, PlotRange -> {0, 11}], > ComplexCirclePoint[#, 3, Black, Blue] & /@ roots, > ComplexCirclePoint[#, 3, Black, Red] & /@ extrema, > ComplexLine[{-5, 5}]}, AspectRatio -> Automatic, > PlotRange -> {{1, 2}, {-.7, .7}}, Frame -> True, > FrameLabel -> {Re, Im}, RotateLabel -> False, > PlotLabel -> Row[{Modulus of , f[z]}], ImageSize -> 900, > Background -> Legacy@Linen]] === Subject: Re: weird NMaximize behaviour Hi Andrzej, We do not know what method is chosen by the default Method->Automatic, but it seems to me that some up hill method is invoked. Starting at some point x0>1, the algorithm will then go towards larger x until reaching the border of the region. To fix this, we need to choose a method that does not simply go uphill but tries to find a global maximum, e.g. SimulatedAnnealing or DifferentialEvolution. E.g. SimulatedAnnealing gives: {9.,{x->-2.,y->0.999067}} Daniel > I have just encountered strange behaviour by NMaximize (which has been > ruining a demonstration I have been working on): > > This is fine: > > NMaximize[{(x - 1)^2, -2 <= x <= 2}, {x}] > {9., {x -> -2.}} > > but this definitely is not: > > NMaximize[{(x - 1)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}] > {1., {x -> 2., y -> 0.87904}} > > The objective function s independent of y, yet NMaximize seems to go > off on some wild goose chase and ends up with a very poor maximum. > > This does not happen here: > > NMaximize[{(x - 2)^2, -2 <= x <= 2}, {x}] > {16., {x -> -2.}} > > NMaximize[{(x - 2)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}] > {16., {x -> -2., y -> -0.980305}} > > Kind of weird. > > Andrzej Kozlowski > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: weird NMaximize behaviour Try to pick a method such as DifferentialEvolution NMaximize[{(x - 1)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}, Method -> DifferentialEvolution] {9., {x -> -2., y -> 1.}} I believe the default condition uses NelderMead and that apparently provides the wrong result. The RandomSearch takes a while. SimulatedAnnealing converges to the right answer as well. === Subject: Re: Variable names in Mathematica NO, they are NOT reserved. Example (converted to InputForm, which I'd never use when actually entering Greek letters [Alpha]=2; [Alpha]+10 12 Perhaps you're confusing some Greek letters with similarly-shaped symbols, such as the Element symbol or the Sum symbol. > > I can't seem to get an answer to this simple question: are greek letters > allowed as variable names in Mathematica? I have tried this with limited > success (v 5.2). It seems that some greek letters are reserved, for example === Subject: Re: Variable names in Mathematica > > I can't seem to get an answer to this simple question: are greek letter= s allowed as variable names in Mathematica? I have tried this with limite= d success (v 5.2). It seems that some greek letters are reserved, for example > for variable names you can use all latin, greek, script and gothic > letters. Exceptions are the one letter functions or constants: > C, D, E, I, K, N, O and $, which are protected. > > K isn't protected, but lives in the System` context and is used > internally e.g. as summation variable. It will not be cleared with > Clear[Global`*]. > > Gruss Peter > -- > ==-==-==-==-==-==-==-==-==-==-== =-==-==-==-==-==-==-==-==-==-==-= == > Peter Breitfeld, Bad Saulgau, Germany --http://www.pBreitfeld.de .....and of course greek Pi is protected too. === Subject: Re: blurry ellipse > NB: This is a mathematical problem, not necessarily a Mathematica problem= . > > I need a rasterized, blurry ellipse, i.e. an ellipse convolved with a > Gaussian. I already know how to make a blurry circle. You take the Fourie= r > transform of a circle (i.e. a Bessel function), the Fourier transform of = a > Guassian, multiply them, and transform them back. No problem. Since an > ellipse is just a circle that has been squashed in one dimension, I figur= ed > I could make a blurry one the same way as I make blurry circles. I just > needed to squash the Bessel function first. And I was right. The code bel= ow > works just fine, *except* the intensity varies as you go around the elips= e. > If anyone could tell me how to fix that problem, I'd be very grateful! > > BlurryEllipse[sizePix_, radiusPix_, sigmaPix_,stretchFactors_: {1, 1}] := = > > Module[{half = sizePix/2, x, y, f, r, a, pr2}, > > f = 2*Pi*radiusPix/sizePix; > pr2 = -2 (Pi*sigmaPix/sizePix)^2; > > RotateRight[ > > Abs[ > Chop[ > > InverseFourier[ > > RotateRight[ > > Table[r1= > A= bs[stretchFactors[[1]]*x+ > = stretchFactors[[2]]*I*y]; > r2 == Abs[x + I*y]; > Bessel= J[0, f*r1] Exp[pr2 (r2^2)], > {y, -half= , half-1} , {x, -half, half-1}], > {half, half}]]]],= {half,half}]] > > size = 64; rad = 24; scale = 3; > tmp = BlurryEllipse[size, rad, scale, {1, .5}]; > Show[Graphics[Raster[tmp/Max[Max[tmp]]]], ImageSize -> 400] > > Intensity varies around the elipse. We can compare amplitude (or power) > ratios between major and minor axes: > > In[]:=Max[tmp[[33]]]/Max[Transpose[tmp][[33]]] > > Out[]=1.93009 > > In[]:= Sqrt[Total[tmp[[33]]^2]/Total[Transpose[tmp][[33]]^2]] > > Out[]= 1.98887 > > I was surprised these numbers weren't closer to 2. How can we make intens= ity > invariant around the ellipse? Good day, Using Exp[pr2 (r1^2)] as kernel instead of Exp[pr2 (r2^2)] seems to work better. V.Astanoff === Subject: Re: blurry ellipse Hi Joshua, you can blurry any picture by a convolution with a suitable kernel. Here is an example. We first create a picture of an ellips. Then we increasingly blurry it three times. Note that we must keep the numbers between 0..1 because of Raster: n=100; pict=Table[0,{n},{n}]; Scan[(pict[[Round[n/2+n/5 Sin[#]],Round[n/2+2 n/5Cos[#]]]]=1)&,Range[0,2Pi,0.01]]; Graphics[Raster[pict]] kernel={{1,1},{1,1}}; pict=ListConvolve[kernel,pict];pict=pict/Max[pict]; Graphics[Raster[pict]] kernel={{1,1,1},{1,1,1},{1,1,1}}; pict=ListConvolve[kernel,pict];pict=pict/Max[pict]; Graphics[Raster[pict]] kernel={{1,1,1,1},{1,1,1,1},{1,1,1,1},{1,1,1,1}}; pict=ListConvolve[kernel,pict];pict=pict/Max[pict]; Graphics[Raster[pict]] Note that you may instead of using a larger kernel, repeat the operation. hope this helps, Daniel > NB: This is a mathematical problem, not necessarily a Mathematica problem. > > I need a rasterized, blurry ellipse, i.e. an ellipse convolved with a > Gaussian. I already know how to make a blurry circle. You take the Fourier > transform of a circle (i.e. a Bessel function), the Fourier transform of a > Guassian, multiply them, and transform them back. No problem. Since an > ellipse is just a circle that has been squashed in one dimension, I figured > I could make a blurry one the same way as I make blurry circles. I just > needed to squash the Bessel function first. And I was right. The code below > works just fine, *except* the intensity varies as you go around the elipse. > If anyone could tell me how to fix that problem, I'd be very grateful! > > BlurryEllipse[sizePix_, radiusPix_, sigmaPix_,stretchFactors_: {1, 1}] := > > Module[{half = sizePix/2, x, y, f, r, a, pr2}, > > f = 2*Pi*radiusPix/sizePix; > pr2 = -2 (Pi*sigmaPix/sizePix)^2; > > RotateRight[ > > Abs[ > Chop[ > > InverseFourier[ > > RotateRight[ > > Table[r1= > Abs[stretchFactors[[1]]*x+ > stretchFactors[[2]]*I*y]; > r2 = Abs[x + I*y]; > BesselJ[0, f*r1] Exp[pr2 (r2^2)], > {y, -half, half-1} , {x, -half, half-1}], > {half, half}]]]], {half,half}]] > > size = 64; rad = 24; scale = 3; > tmp = BlurryEllipse[size, rad, scale, {1, .5}]; > Show[Graphics[Raster[tmp/Max[Max[tmp]]]], ImageSize -> 400] > > Intensity varies around the elipse. We can compare amplitude (or power) > ratios between major and minor axes: > > In[]:=Max[tmp[[33]]]/Max[Transpose[tmp][[33]]] > > > Out[]=1.93009 > > > In[]:= Sqrt[Total[tmp[[33]]^2]/Total[Transpose[tmp][[33]]^2]] > > Out[]= 1.98887 > > > > I was surprised these numbers weren't closer to 2. How can we make intensity > invariant around the ellipse? > > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: WorldPlot and crosshatching countries This shouldn't be difficult but after having spent some time on it, I haven't made any headway. I am trying to illustrate two variables on a world map. The first is illustrated using color. The second, a binary variable, by a thick, black border. Instead of using the thick, black border, I'd like to use vertical, diagonal, or horizontal cross hatching. Below is some simple code which illustrates the process using the thick, black border. How do I use cross hatching? I am using version 6. Best, Daniel << WorldPlot` border = {Black, Thickness[.01]}; country1 = {USA, China, Nigeria}; country2 = {China}; color1 = {Blue, Red, Yellow}; color2 = {Hue[3, 1, 1, .01]}; map1 = WorldPlot[{country1, color1}, WorldToGraphics -> True, WorldGridBehind -> True, WorldBackground -> White, WorldGrid -> None, ImageSize -> {500}] map2 = WorldPlot[{country2, color2}, WorldToGraphics -> True, WorldBorders -> border, WorldGrid -> None, ImageSize -> {500}] finalmap = Show[{map1, map2}] -- boydkramer@gmail.com === Subject: Debracketing array symbols For a class project I generate 1D and 2D arrays of arbitrary size with entries [i] and [i,j] that I need then to convert to i and ij for export to other languages that do not allow brackets in symbol names. E.g. 1D: {A[1],A[2],A[3],A[4]} -> {A1,A2,A3,A4} 2D: {{W[1,1],W[1,2]},{W[2,1],W[2,2]}} -> {{W11,W12},{W21,W22}} Question: would this be the simplest way to do it? DebracketArrayEntries[Wm_]:=Module[{dim,rep,i,j,n,m,s,Wr}, rep={[->,]->,,->, ->}; Wr=Wm; dim=Length[Dimensions[Wm]]; If [dim==1,n=Length[Wm]; Print[n=,n]; For [i=1,i<=n,i++, s=ToString[Wm[[i]]]; Wr=Wr/.Wm[[i]]->Symbol[StringReplace[s,rep]] ]]; If [dim==2,{n,m}=Dimensions[Wm]; For [i=1,i<=n,i++, For[j=1,j<=m,j++, s=ToString[Wm[[i,j]]]; Wr=Wr/.Wm[[i,j]]->Symbol[StringReplace[s,rep]] ]]]; Return[Wr]]; The procedural style is to simplify conversion to C++. === Subject: Re: Debracketing array symbols Hi carlos, you could e.g. try: {A[1],A[2],A[3],A[4]}/.x_[y_]:>Symbol[ToString[x]<>ToString[y]] hope this helps, Daniel > > For a class project I generate 1D and 2D arrays of arbitrary size with > entries [i] and [i,j] that I need then to convert > to i and ij for export to other languages that do not > allow brackets in symbol names. E.g. > > 1D: {A[1],A[2],A[3],A[4]} -> {A1,A2,A3,A4} > > 2D: {{W[1,1],W[1,2]},{W[2,1],W[2,2]}} -> {{W11,W12},{W21,W22}} > > Question: would this be the simplest way to do it? > > DebracketArrayEntries[Wm_]:=Module[{dim,rep,i,j,n,m,s,Wr}, > rep={[->,]->,,->, ->}; Wr=Wm; > dim=Length[Dimensions[Wm]]; > If [dim==1,n=Length[Wm]; Print[n=,n]; > For [i=1,i<=n,i++, s=ToString[Wm[[i]]]; > Wr=Wr/.Wm[[i]]->Symbol[StringReplace[s,rep]] ]]; > If [dim==2,{n,m}=Dimensions[Wm]; > For [i=1,i<=n,i++, For[j=1,j<=m,j++, s=ToString[Wm[[i,j]]]; > Wr=Wr/.Wm[[i,j]]->Symbol[StringReplace[s,rep]] ]]]; > Return[Wr]]; > > The procedural style is to simplify conversion to C++. > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: Apparent error integrating product of DiracDelta's Hmmm. I appreciate (mostly) the niceties of this argument, but what about the practical matter that as an intermediate step in some problem I may want to have some DiracDelta's floating around prior to a final integration? Michael > > How do I get: Integrate[DiracDelta[z- x] DiracDelta[z- y], {z-Infinity, Infinit= y}= ] to give DiracDelta[x-y] as the result? Currently it gives 0. I = ha= ve all three variable assumed to be Reals. I am using 6.0.0. Michael Mandelberg > I think you have synatx error in the limit part. I assume you mean to = wri= te > {z, -Infinity,Infinity} > > Given that, I think zero is the correct answer. When you multiply 2= de= ltas > at different positions, you get zero. Integral of zero is zero. > > Nasser > No Nasser, the correct value of the integral should be DiracDelta[x- y], as Michael said. This value is indeed 0 if x != y but it is not 0 if x==y. > > It is not 0 at x==y, but neither is it DiracDelta[x-y]. The value the= re > is undefined. > Mathematica correctly calculates: > Integrate[f[z - x] DiracDelta[z - y], {z, -Infinity, Infinity}, Assumptions -> y [Element] Reals] > as > f[-x + y] > > This is making a tacit assumption that f is a nice function. Nice, in > this context, means it is an element of Schwartz space S: C^infinity and > vanishing faster than any polynomial at +-infinity. DiracDelta, suffice > it to say, is not an element of S (it's not even a function). > However it fails to recognize that if f[z-x] is replaced by DiracDelta[z-x], the result should be > DiracDelta[-x + y] > or the equivalent > DiracDelta[x - y] > > This is not a failure but rather an active intervention. > In the help file, under possible issues it is mentioned that Products of distributions with coinciding singular support cannot be defined: > > This is a statement of mathematics and not specific to Mathematica. > So perhaps at the moment the only way to do the integral is: > Integrate[f[z - x] DiracDelta[z - y], {z, -Infinity, Infinity}, Assumptions -> y [Element] Reals] /. f -> DiracDelta > hth > > Here is a general rule of thumb. If you are working with DiracDelta > function(al)s, instead approximate them as ordinary functions. If > different methods of approximation will lead to different results, then > what you have cannot be defined. One can use this notion to see that, > for example, DiracDelta[x]^2 is not defined. > > Daniel Lichtblau > Wolfram Research- Hide quoted text - > > - Show quoted text - === Subject: Re: Apparent error integrating product of DiracDelta's > > How do I get: Integrate[DiracDelta[z- x] DiracDelta[z- y], {z-Infinity, Infinit= y}= ] to give DiracDelta[x-y] as the result? Currently it gives 0. I = ha= ve all three variable assumed to be Reals. I am using 6.0.0. Michael Mandelberg > I think you have synatx error in the limit part. I assume you mean to = wri= te > {z, -Infinity,Infinity} > > Given that, I think zero is the correct answer. When you multiply 2= de= ltas > at different positions, you get zero. Integral of zero is zero. > > Nasser > No Nasser, the correct value of the integral should be DiracDelta[x- y], as Michael said. This value is indeed 0 if x != y but it is not 0 if x==y. > > It is not 0 at x==y, but neither is it DiracDelta[x-y]. The value the= re > is undefined. > Mathematica correctly calculates: > Integrate[f[z - x] DiracDelta[z - y], {z, -Infinity, Infinity}, Assumptions -> y [Element] Reals] > as > f[-x + y] > > This is making a tacit assumption that f is a nice function. Nice, in > this context, means it is an element of Schwartz space S: C^infinity and > vanishing faster than any polynomial at +-infinity. DiracDelta, suffice > it to say, is not an element of S (it's not even a function). > However it fails to recognize that if f[z-x] is replaced by DiracDelta[z-x], the result should be > DiracDelta[-x + y] > or the equivalent > DiracDelta[x - y] > > This is not a failure but rather an active intervention. > In the help file, under possible issues it is mentioned that Products of distributions with coinciding singular support cannot be defined: > > This is a statement of mathematics and not specific to Mathematica. > So perhaps at the moment the only way to do the integral is: > Integrate[f[z - x] DiracDelta[z - y], {z, -Infinity, Infinity}, Assumptions -> y [Element] Reals] /. f -> DiracDelta > hth > > Here is a general rule of thumb. If you are working with DiracDelta > function(al)s, instead approximate them as ordinary functions. If > different methods of approximation will lead to different results, then > what you have cannot be defined. One can use this notion to see that, > for example, DiracDelta[x]^2 is not defined. > > Daniel Lichtblau > Wolfram Research Very interesting answer! Yet, taking a naive (physicist's ?) point of view, the result seems intuitively correct. Mr. Delta himself (P.A.M. Dirac) in his The principles of quantum mechanics published in 1930 confirms the result (eq. 15.9 in the Italian 4th edition). He even proves it, a little bit later. The proof is a bit heuristics because he assumes the integral is defined in the first place. Yet the whole Delta function story was at the time just heuristics. Apparently the delta was described for the first time in this book (Wikipedia). I am also pretty sure he uses the result somewhere else later in the book (probably where double integrals appear). So, could he have been so wrong after having been so right before? More to the point: I found very intriguing your claim that If different methods of approximation will lead to different results, then what you have cannot be defined. I agree with you of course, but could you show with Mathematica - maybe with a Manipulate program - that this is the case with this integral? Could you find 2 different approximation methods which give 2 different results? I look forward to seeing it. Concerning DiracDelta[x]^2, I would agree it is undefined at least because its integral, if it existed, would be DeltaDirac[0], which is undefined. === Subject: Working modulo 2 Howdy, How does one reduce a polynomial's coefficients modulo 2? For example, I have a function that sums several polynomials, and currently produces a result like this: 7 + x + 4 y + 4 x y + 3 z + 2 x z + 4 y z + 4 x y z I want to reduce this to 1 + x + z I thought I might be able to do this by somehow coercing the terms into a list and then doing Sum[L[[i]],{i,1,Length[L]},Modulus->2], but no such luck. Any ideas? Bob H === Subject: the graphic of a function i think i've asked this before. anyway, i am new in mathematica and i want how can I create the graphic of an exact function the same as I do for Sin[]. for example f(x)=x^2/(x+1)^2 can anyone help? === Subject: Re: Functional programming? > To a novice in these matters like myself it looks to me as if:1. Debugging > FP code could be very challenging > 2. Although FP looks very concise and fast, there a lot going on that's not > immediately apparent and its not clear [ to me ] how to get full hand-on on > that code. > I know these comments will seem naive to the many experts out there, but its > just my observation. > > Peter > > I don't think this comment is naive at all - code in a style that seems clear to you, but bear in mind that if you expect performance to be an issue, the innermost loops should use FP if at all possible. Often the only way to unpick really complex expressions, is to select successively larger pieces (using Ctrl-. ) copy them somewhere, and see how they evaluate. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Functional programming? > > To me, using Mathematica without learning functional programing > is somewhat analogous to driving a sports car without learning > to use the higher gears. You can get from point A to point B in > a sports car using only first gear but clearly that isn't > efficient use of the sports car. Similarly, you can solve > problems with Mathematica using procedural programing but that > isn't efficient use of Mathematica. > This is true, but Stephen Wolfram did include all the procedural constructs as well, and I think he did this for a reason. There are certain messy real-world bits of data processing that are easier to code in procedural style. My point is simply that we should not condemn procedural programming to the point where users give up on problems that they could otherwise have solved using (say) While[...]. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Functional programming? (RPN -v- Algebraic) > > Debating which is better (functional programing or procedural > programing) is analogous to debates of early calculators > comparing HP's RPN style to TI's algebraic style. Either could > get the task done. And it was possible to find example problems > that were more efficiently done by one than by the other. Actually, this question was answered many years ago, and RPN required significantly less work to solve non-toy programs. How was this determined? By comparing the number of keystrokes needed to solve various standard programs, like interest-rate calculations in the financial world. People just counted the keystrokes in the programs provided in the respective users manuals, on the assumption that each such program was written by experts working for the respective manufacturers, and so would be as close to optimal as humanly possible, making the comparison both fair and informative. The bottom line was that it took RPN about two thirds the keystrokes that algebraic took for the same problem. This certainly is my personal experience as well. Joe Gwinn === Subject: Re: Functional programming? >David Bailey says: >>I think you have chosen a rather favourable example here. Suppose >>instead that you need to remove every zero together with the >>preceding element (sweeping from left to right). >A quick and dirty fp answer is (safer code would check that leading >elements were not already zero) >In[1]:= v = {1, 2, 0, 3, 4, 0}; >v1 = MapAt[0 &, v, Position[v, 0] - 1]; >v2 = Select[v1, # != 0 &] > >Out[1]= {1, 3} Even more concise In[15]:= v //. {{a___, _, 0, b___} -> {a, b},{0, b___} -> {b}} Out[15]= {1,3} But perhaps pattern matching isn't considered part of functional programing === Subject: NDSolve and Piecewise Folks, I am having some trouble with getting Piecewise and NDSolve to play nicely together. My problem is to find a solution to the heat flow equation with an arbitrary time-varying upper boundary condition and a Neumann-type lower boundary (steady head flow condition). My code looks like this: NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[t, 0] == Piecewise[{{t/10, 0 <= t < 5}, {(10 - t)/10, 5 <= t < 10}}], u[0, x] == x/5, (D[u[t, x], x] /. x -> 5) == 1/5}, u, {t, 0, 10}, {x, 0, 5}] This returns and NDSolve::ndum error on my system, which past experience tells me is usually me leaving some symbolic value hanging around somewhere it ought not to be. I can't see any such problem this time. I'm pretty sure that I have written similar code in the past (using Piecewise and NDSolve, though it was some time ago and I can't locate the file now) and had it work, and it works if you replace Piecewise with another functional form (like Sin[t]). Am I missing something? Marshall === Subject: Column/Row/Grid bars FrontEnd String formatting in new cells? The last example (#3) in the following sequence puzzles me: EX. 1: CellPrint@hellonworld (* new cell *) hello world EX. 2: CellPrint@List@hellonworld (* new cell *) hello world EX. 3: CellPrint@Column@List@hellonworld (* new cell *) hellonworld In this last case, it appears that 'Column' prevents formatting of the string by the FrontEnd. Could someone offer a better explanation? Is there a way around this, that would produce formatted output identical to the first two examples? Vince Virgilio === Subject: Re: ListContourPlot3D, no output > Indeed,I should explain better what is happening. The table I have is a r= elative large data collection and I am not sure about how to post this here= . > Concerning your examples of code, I would guess all of it should work, si= nce I could run all the examples that are given on the help page of ListCon= toutPlot3D. > In the end, I tried this: I took my table of the form Basbsselect={{x,y= ,z,f}, ...} (again, a regular array with equally spaced x, y, and z values,= and which contains nx x ny x nz values) and made an array using: Babsarray = > Array[Babsselect[[1 + (#1 - 1)*naz*nay + (#2 - 1)*naz + ( #3 - 1), > 4]] &, {nax, nay, naz}]; Then I can plot this using ListContourPlot3D. So this sort of solves my p= roblem. > But I would still be interested to post the original code, it is unfortun= ately a rather big table and I do not know if that is possible. Adi Why don't you just post a little bit of your table? not the whole bunch. Just a subset. Does ListContoutPlot3D work with a subset of your table? === Subject: Re: How to find the best fit for a list {x,y} of data Hi Mathematica gives you the best result given the fitting expression: (1 - k x) (1 - (k x)/q) (1 - (k p x)/q) === Subject: Problem in PL spectrum analysis I now have troubles in the PL(photoluminescence) spectrum analysis. Integration of the PL spectrum is the aim, however these data are dispersed ones. I don't know how to make it by Mathematica. yours gyzhou Below are the useful data. 10099.38062 -0.00000 10097.45215 0.00002 10095.52368 0.00005 10093.59521 0.00009 10091.66675 0.00012 10089.73828 0.00013 10087.80981 0.00014 10085.88135 0.00013 10083.95288 0.00012 10082.02441 0.00011 10080.09595 0.00009 10078.16748 0.00009 10076.23901 0.00009 10074.31055 0.00009 10072.38208 0.00010 10070.45361 0.00011 10068.52515 0.00011 10066.59668 0.00012 10064.66821 0.00013 10062.73975 0.00013 10060.81128 0.00012 10058.88281 0.00011 10056.95435 0.00011 10055.02588 0.00011 10053.09741 0.00011 10051.16895 0.00012 10049.24048 0.00013 10047.31201 0.00013 10045.38354 0.00013 10043.45508 0.00014 10041.52661 0.00015 10039.59814 0.00017 10037.66968 0.00018 10035.74121 0.00020 10033.81274 0.00020 10031.88428 0.00021 10029.95581 0.00021 10028.02734 0.00020 10026.09888 0.00020 10024.17041 0.00019 10022.24194 0.00018 10020.31348 0.00018 10018.38501 0.00018 10016.45654 0.00018 10014.52808 0.00019 10012.59961 0.00019 10010.67114 0.00020 10008.74268 0.00020 10006.81421 0.00022 10004.88574 0.00024 10002.95728 0.00025 10001.02881 0.00027 9999.10034 0.00027 9997.17188 0.00028 9995.24341 0.00028 9993.31494 0.00029 9991.38647 0.00029 9989.45801 0.00029 9987.52954 0.00029 9985.60107 0.00029 9983.67261 0.00029 9981.74414 0.00029 9979.81567 0.00030 9977.88721 0.00031 9975.95874 0.00031 9974.03027 0.00030 9972.10181 0.00029 9970.17334 0.00028 9968.24487 0.00028 9966.31641 0.00029 9964.38794 0.00031 9962.45947 0.00033 9960.53101 0.00034 9958.60254 0.00035 9956.67407 0.00035 9954.74561 0.00035 9952.81714 0.00036 9950.88867 0.00036 9948.96021 0.00037 9947.03174 0.00037 9945.10327 0.00038 9943.17480 0.00039 9941.24634 0.00040 9939.31787 0.00041 9937.38940 0.00041 9935.46094 0.00040 9933.53247 0.00040 9931.60400 0.00040 9929.67554 0.00040 9927.74707 0.00042 9925.81860 0.00043 9923.89014 0.00044 9921.96167 0.00044 9920.03320 0.00046 9918.10474 0.00047 9916.17627 0.00049 9914.24780 0.00050 9912.31934 0.00050 9910.39087 0.00050 9908.46240 0.00050 9906.53394 0.00050 9904.60547 0.00050 9902.67700 0.00051 9900.74854 0.00053 9898.82007 0.00055 9896.89160 0.00058 9894.96313 0.00059 9893.03467 0.00060 9891.10620 0.00061 9889.17773 0.00062 9887.24927 0.00063 9885.32080 0.00064 9883.39233 0.00066 9881.46387 0.00067 9879.53540 0.00069 9877.60693 0.00070 9875.67847 0.00071 9873.75000 0.00072 9871.82153 0.00072 9869.89307 0.00072 9867.96460 0.00072 9866.03613 0.00073 9864.10767 0.00074 9862.17920 0.00075 9860.25073 0.00076 9858.32227 0.00076 9856.39380 0.00077 9854.46533 0.00078 9852.53687 0.00080 9850.60840 0.00081 9848.67993 0.00082 9846.75146 0.00083 9844.82300 0.00084 9842.89453 0.00086 9840.96606 0.00089 9839.03760 0.00092 9837.10913 0.00094 9835.18066 0.00096 9833.25220 0.00098 9831.32373 0.00099 9829.39526 0.00101 9827.46680 0.00104 9825.53833 0.00106 9823.60986 0.00108 9821.68140 0.00109 9819.75293 0.00109 9817.82446 0.00108 9815.89600 0.00107 9813.96753 0.00107 9812.03906 0.00108 9810.11060 0.00110 9808.18213 0.00112 9806.25366 0.00115 9804.32520 0.00118 9802.39673 0.00121 9800.46826 0.00124 9798.53979 0.00126 9796.61133 0.00127 9794.68286 0.00127 9792.75439 0.00127 9790.82593 0.00127 9788.89746 0.00128 9786.96899 0.00130 9785.04053 0.00134 9783.11206 0.00138 9781.18359 0.00142 9779.25513 0.00145 9777.32666 0.00147 9775.39819 0.00147 9773.46973 0.00147 9771.54126 0.00147 9769.61279 0.00149 9767.68433 0.00151 9765.75586 0.00153 9763.82739 0.00155 9761.89893 0.00157 9759.97046 0.00159 9758.04199 0.00160 9756.11353 0.00161 9754.18506 0.00163 9752.25659 0.00166 9750.32813 0.00169 9748.39966 0.00173 9746.47119 0.00177 9744.54272 0.00180 9742.61426 0.00183 9740.68579 0.00185 9738.75732 0.00187 9736.82886 0.00188 9734.90039 0.00189 9732.97192 0.00190 9731.04346 0.00192 9729.11499 0.00195 9727.18652 0.00198 9725.25806 0.00203 9723.32959 0.00207 9721.40112 0.00210 9719.47266 0.00212 9717.54419 0.00214 9715.61572 0.00215 9713.68726 0.00216 9711.75879 0.00217 9709.83032 0.00220 9707.90186 0.00223 9705.97339 0.00227 9704.04492 0.00230 9702.11646 0.00233 9700.18799 0.00235 9698.25952 0.00237 9696.33105 0.00240 9694.40259 0.00243 9692.47412 0.00247 9690.54565 0.00250 9688.61719 0.00252 9686.68872 0.00255 9684.76025 0.00257 9682.83179 0.00259 9680.90332 0.00260 9678.97485 0.00262 9677.04639 0.00263 9675.11792 0.00266 9673.18945 0.00268 9671.26099 0.00272 9669.33252 0.00276 9667.40405 0.00280 9665.47559 0.00283 9663.54712 0.00287 9661.61865 0.00290 9659.69019 0.00294 9657.76172 0.00297 9655.83325 0.00301 9653.90479 0.00304 9651.97632 0.00307 9650.04785 0.00310 9648.11938 0.00313 9646.19092 0.00316 9644.26245 0.00318 9642.33398 0.00321 9640.40552 0.00324 9638.47705 0.00327 9636.54858 0.00330 9634.62012 0.00334 9632.69165 0.00337 9630.76318 0.00340 9628.83472 0.00343 9626.90625 0.00345 9624.97778 0.00348 9623.04932 0.00351 9621.12085 0.00355 9619.19238 0.00360 9617.26392 0.00366 9615.33545 0.00372 9613.40698 0.00377 9611.47852 0.00382 9609.55005 0.00387 9607.62158 0.00391 9605.69312 0.00395 9603.76465 0.00398 9601.83618 0.00400 9599.90771 0.00401 9597.97925 0.00402 9596.05078 0.00405 9594.12231 0.00409 9592.19385 0.00415 9590.26538 0.00420 9588.33691 0.00425 9586.40845 0.00429 9584.47998 0.00433 9582.55151 0.00436 9580.62305 0.00439 9578.69458 0.00442 9576.76611 0.00445 9574.83765 0.00449 9572.90918 0.00453 9570.98071 0.00458 9569.05225 0.00462 9567.12378 0.00467 9565.19531 0.00470 9563.26685 0.00474 9561.33838 0.00478 9559.40991 0.00483 9557.48145 0.00488 9555.55298 0.00493 9553.62451 0.00498 9551.69604 0.00501 9549.76758 0.00504 9547.83911 0.00507 9545.91064 0.00510 9543.98218 0.00515 9542.05371 0.00520 9540.12524 0.00525 9538.19678 0.00531 9536.26831 0.00536 9534.33984 0.00540 9532.41138 0.00545 9530.48291 0.00550 9528.55444 0.00555 9526.62598 0.00561 9524.69751 0.00567 9522.76904 0.00572 9520.84058 0.00577 9518.91211 0.00582 9516.98364 0.00585 9515.05518 0.00589 9513.12671 0.00593 9511.19824 0.00597 9509.26978 0.00602 9507.34131 0.00607 9505.41284 0.00612 9503.48438 0.00617 9501.55591 0.00622 9499.62744 0.00626 9497.69897 0.00630 9495.77051 0.00634 9493.84204 0.00639 9491.91357 0.00645 9489.98511 0.00651 9488.05664 0.00657 9486.12817 0.00664 9484.19971 0.00669 9482.27124 0.00674 9480.34277 0.00679 9478.41431 0.00684 9476.48584 0.00690 9474.55737 0.00696 9472.62891 0.00701 9470.70044 0.00707 9468.77197 0.00712 9466.84351 0.00717 9464.91504 0.00721 9462.98657 0.00725 9461.05811 0.00730 9459.12964 0.00736 9457.20117 0.00743 9455.27271 0.00750 9453.34424 0.00756 9451.41577 0.00761 9449.48730 0.00766 9447.55884 0.00772 9445.63037 0.00778 9443.70190 0.00784 9441.77344 0.00791 9439.84497 0.00797 9437.91650 0.00802 9435.98804 0.00807 9434.05957 0.00813 9432.13110 0.00819 9430.20264 0.00825 9428.27417 0.00832 9426.34570 0.00839 9424.41724 0.00846 9422.48877 0.00852 9420.56030 0.00859 9418.63184 0.00865 9416.70337 0.00872 9414.77490 0.00879 9412.84644 0.00885 9410.91797 0.00892 9408.98950 0.00898 9407.06104 0.00904 9405.13257 0.00910 9403.20410 0.00918 9401.27563 0.00926 9399.34717 0.00935 9397.41870 0.00943 9395.49023 0.00950 9393.56177 0.00956 9391.63330 0.00960 9389.70483 0.00965 9387.77637 0.00970 9385.84790 0.00976 9383.91943 0.00983 9381.99097 0.00990 9380.06250 0.00996 9378.13403 0.01002 9376.20557 0.01007 9374.27710 0.01013 9372.34863 0.01020 9370.42017 0.01029 9368.49170 0.01037 9366.56323 0.01046 9364.63477 0.01054 9362.70630 0.01061 9360.77783 0.01068 9358.84937 0.01076 9356.92090 0.01084 9354.99243 0.01092 9353.06396 0.01100 9351.13550 0.01107 9349.20703 0.01113 9347.27856 0.01120 9345.35010 0.01127 9343.42163 0.01135 9341.49316 0.01142 9339.56470 0.01150 9337.63623 0.01157 9335.70776 0.01164 9333.77930 0.01171 9331.85083 0.01178 9329.92236 0.01186 9327.99390 0.01195 9326.06543 0.01205 9324.13696 0.01215 9322.20850 0.01224 9320.28003 0.01232 9318.35156 0.01239 9316.42310 0.01246 9314.49463 0.01253 9312.56616 0.01261 9310.63770 0.01269 9308.70923 0.01278 9306.78076 0.01287 9304.85229 0.01297 9302.92383 0.01305 9300.99536 0.01313 9299.06689 0.01321 9297.13843 0.01328 9295.20996 0.01334 9293.28149 0.01341 9291.35303 0.01347 9289.42456 0.01354 9287.49609 0.01361 9285.56763 0.01370 9283.63916 0.01379 9281.71069 0.01389 9279.78223 0.01399 9277.85376 0.01409 9275.92529 0.01418 9273.99683 0.01427 9272.06836 0.01436 9270.13989 0.01444 9268.21143 0.01451 9266.28296 0.01459 9264.35449 0.01466 9262.42603 0.01474 9260.49756 0.01483 9258.56909 0.01492 9256.64063 0.01502 9254.71216 0.01511 9252.78369 0.01520 9250.85522 0.01529 9248.92676 0.01538 9246.99829 0.01546 9245.06982 0.01554 9243.14136 0.01560 9241.21289 0.01566 9239.28442 0.01572 9237.35596 0.01579 9235.42749 0.01586 9233.49902 0.01595 9231.57056 0.01606 9229.64209 0.01617 9227.71362 0.01627 9225.78516 0.01636 9223.85669 0.01643 9221.92822 0.01650 9219.99976 0.01656 9218.07129 0.01664 9216.14282 0.01672 9214.21436 0.01680 9212.28589 0.01688 9210.35742 0.01696 9208.42896 0.01704 9206.50049 0.01712 9204.57202 0.01720 9202.64355 0.01728 9200.71509 0.01736 9198.78662 0.01743 9196.85815 0.01750 9194.92969 0.01759 9193.00122 0.01768 9191.07275 0.01777 9189.14429 0.01786 9187.21582 0.01794 9185.28735 0.01800 9183.35889 0.01805 9181.43042 0.01811 9179.50195 0.01817 9177.57349 0.01824 9175.64502 0.01831 9173.71655 0.01838 9171.78809 0.01846 9169.85962 0.01854 9167.93115 0.01863 9166.00269 0.01872 9164.07422 0.01881 9162.14575 0.01890 9160.21729 0.01898 9158.28882 0.01907 9156.36035 0.01914 9154.43188 0.01921 9152.50342 0.01928 9150.57495 0.01935 9148.64648 0.01942 9146.71802 0.01949 9144.78955 0.01957 9142.86108 0.01964 9140.93262 0.01971 9139.00415 0.01979 9137.07568 0.01987 9135.14722 0.01994 9133.21875 0.02001 9131.29028 0.02008 9129.36182 0.02014 9127.43335 0.02021 9125.50488 0.02029 9123.57642 0.02037 9121.64795 0.02044 9119.71948 0.02051 9117.79102 0.02059 9115.86255 0.02066 9113.93408 0.02073 9112.00562 0.02081 9110.07715 0.02090 9108.14868 0.02098 9106.22021 0.02107 9104.29175 0.02115 9102.36328 0.02121 9100.43481 0.02127 9098.50635 0.02132 9096.57788 0.02136 9094.64941 0.02142 9092.72095 0.02147 9090.79248 0.02153 9088.86401 0.02160 9086.93555 0.02168 9085.00708 0.02175 9083.07861 0.02183 9081.15015 0.02191 9079.22168 0.02198 9077.29321 0.02205 9075.36475 0.02212 9073.43628 0.02219 9071.50781 0.02226 9069.57935 0.02233 9067.65088 0.02240 9065.72241 0.02247 9063.79395 0.02253 9061.86548 0.02260 9059.93701 0.02267 9058.00854 0.02275 9056.08008 0.02282 9054.15161 0.02289 9052.22314 0.02295 9050.29468 0.02301 9048.36621 0.02307 9046.43774 0.02313 9044.50928 0.02320 9042.58081 0.02327 9040.65234 0.02335 9038.72388 0.02342 9036.79541 0.02350 9034.86694 0.02357 9032.93848 0.02363 9031.01001 0.02368 9029.08154 0.02374 9027.15308 0.02381 9025.22461 0.02387 9023.29614 0.02394 9021.36768 0.02401 9019.43921 0.02407 9017.51074 0.02413 9015.58228 0.02419 9013.65381 0.02425 9011.72534 0.02431 9009.79688 0.02438 9007.86841 0.02443 9005.93994 0.02449 9004.01147 0.02454 9002.08301 0.02460 9000.15454 0.02466 8998.22607 0.02473 8996.29761 0.02479 8994.36914 0.02485 8992.44067 0.02491 8990.51221 0.02496 8988.58374 0.02502 8986.65527 0.02507 8984.72681 0.02513 8982.79834 0.02518 8980.86987 0.02523 8978.94141 0.02528 8977.01294 0.02533 8975.08447 0.02538 8973.15601 0.02543 8971.22754 0.02548 8969.29907 0.02554 8967.37061 0.02560 8965.44214 0.02565 8963.51367 0.02571 8961.58521 0.02576 8959.65674 0.02580 8957.72827 0.02583 8955.79980 0.02587 8953.87134 0.02592 8951.94287 0.02597 8950.01440 0.02603 8948.08594 0.02608 8946.15747 0.02612 8944.22900 0.02615 8942.30054 0.02618 8940.37207 0.02622 8938.44360 0.02627 8936.51514 0.02632 8934.58667 0.02636 8932.65820 0.02640 8930.72974 0.02644 8928.80127 0.02647 8926.87280 0.02651 8924.94434 0.02655 8923.01587 0.02660 8921.08740 0.02663 8919.15894 0.02665 8917.23047 0.02667 8915.30200 0.02667 8913.37354 0.02668 8911.44507 0.02669 8909.51660 0.02673 8907.58813 0.02678 8905.65967 0.02684 8903.73120 0.02690 8901.80273 0.02694 8899.87427 0.02698 8897.94580 0.02704 8896.01733 0.02710 8894.08887 0.02716 8892.16040 0.02718 8890.23193 0.02717 8888.30347 0.02713 8886.37500 0.02709 8884.44653 0.02710 8882.51807 0.02714 8880.58960 0.02720 8878.66113 0.02727 8876.73267 0.02731 8874.80420 0.02733 8872.87573 0.02732 8870.94727 0.02728 8869.01880 0.02725 8867.09033 0.02723 8865.16187 0.02724 8863.23340 0.02727 8861.30493 0.02731 8859.37646 0.02734 8857.44800 0.02734 8855.51953 0.02732 8853.59106 0.02729 8851.66260 0.02728 8849.73413 0.02728 8847.80566 0.02730 8845.87720 0.02732 8843.94873 0.02733 8842.02026 0.02732 8840.09180 0.02729 8838.16333 0.02726 8836.23486 0.02723 8834.30640 0.02719 8832.37793 0.02716 8830.44946 0.02711 8828.52100 0.02705 8826.59253 0.02698 8824.66406 0.02690 8822.73560 0.02681 8820.80713 0.02670 8818.87866 0.02657 8816.95020 0.02641 8815.02173 0.02626 8813.09326 0.02616 8811.16479 0.02611 8809.23633 0.02612 8807.30786 0.02614 8805.37939 0.02615 8803.45093 0.02613 8801.52246 0.02609 8799.59399 0.02605 8797.66553 0.02601 8795.73706 0.02596 8793.80859 0.02589 8791.88013 0.02581 8789.95166 0.02571 8788.02319 0.02561 8786.09473 0.02550 8784.16626 0.02540 8782.23779 0.02530 8780.30933 0.02520 8778.38086 0.02510 8776.45239 0.02500 8774.52393 0.02490 8772.59546 0.02478 8770.66699 0.02466 8768.73853 0.02454 8766.81006 0.02441 8764.88159 0.02427 8762.95313 0.02415 8761.02466 0.02403 8759.09619 0.02392 8757.16772 0.02381 8755.23926 0.02369 8753.31079 0.02357 8751.38232 0.02345 8749.45386 0.02331 8747.52539 0.02317 8745.59692 0.02302 8743.66846 0.02286 8741.73999 0.02268 8739.81152 0.02251 8737.88306 0.02235 8735.95459 0.02220 8734.02612 0.02205 8732.09766 0.02189 8730.16919 0.02173 8728.24072 0.02156 8726.31226 0.02138 8724.38379 0.02119 8722.45532 0.02100 8720.52686 0.02082 8718.59839 0.02066 8716.66992 0.02051 8714.74146 0.02036 8712.81299 0.02022 8710.88452 0.02007 8708.95605 0.01990 8707.02759 0.01973 8705.09912 0.01956 8703.17065 0.01939 8701.24219 0.01922 8699.31372 0.01905 8697.38525 0.01888 8695.45679 0.01872 8693.52832 0.01855 8691.59985 0.01838 8689.67139 0.01819 8687.74292 0.01799 8685.81445 0.01777 8683.88599 0.01756 8681.95752 0.01734 8680.02905 0.01713 8678.10059 0.01693 8676.17212 0.01674 8674.24365 0.01657 8672.31519 0.01641 8670.38672 0.01626 8668.45825 0.01610 8666.52979 0.01593 8664.60132 0.01576 8662.67285 0.01557 8660.74438 0.01537 8658.81592 0.01515 8656.88745 0.01494 8654.95898 0.01474 8653.03052 0.01454 8651.10205 0.01435 8649.17358 0.01417 8647.24512 0.01398 8645.31665 0.01379 8643.38818 0.01361 8641.45972 0.01343 8639.53125 0.01326 8637.60278 0.01309 8635.67432 0.01292 8633.74585 0.01274 8631.81738 0.01256 8629.88892 0.01238 8627.96045 0.01219 8626.03198 0.01200 8624.10352 0.01182 8622.17505 0.01163 8620.24658 0.01143 8618.31812 0.01124 8616.38965 0.01105 8614.46118 0.01088 8612.53271 0.01071 8610.60425 0.01055 8608.67578 0.01037 8606.74731 0.01020 8604.81885 0.01002 8602.89038 0.00985 8600.96191 0.00969 8599.03345 0.00954 8597.10498 0.00939 8595.17651 0.00924 8593.24805 0.00908 8591.31958 0.00891 8589.39111 0.00874 8587.46265 0.00856 8585.53418 0.00839 8583.60571 0.00823 8581.67725 0.00806 8579.74878 0.00791 8577.82031 0.00775 8575.89185 0.00761 8573.96338 0.00747 8572.03491 0.00734 8570.10645 0.00721 8568.17798 0.00708 8566.24951 0.00695 8564.32104 0.00680 8562.39258 0.00665 8560.46411 0.00650 8558.53564 0.00635 8556.60718 0.00621 8554.67871 0.00608 8552.75024 0.00595 8550.82178 0.00582 8548.89331 0.00569 8546.96484 0.00555 8545.03638 0.00542 8543.10791 0.00528 8541.17944 0.00516 8539.25098 0.00504 8537.32251 0.00494 8535.39404 0.00483 8533.46558 0.00474 8531.53711 0.00464 8529.60864 0.00453 8527.68018 0.00443 8525.75171 0.00432 8523.82324 0.00421 8521.89478 0.00410 8519.96631 0.00399 8518.03784 0.00389 8516.10938 0.00378 8514.18091 0.00368 8512.25244 0.00359 8510.32397 0.00350 8508.39551 0.00342 8506.46704 0.00334 8504.53857 0.00327 8502.61011 0.00319 8500.68164 0.00311 8498.75317 0.00302 8496.82471 0.00293 8494.89624 0.00285 8492.96777 0.00278 8491.03931 0.00271 8489.11084 0.00264 8487.18237 0.00257 8485.25391 0.00251 8483.32544 0.00245 8481.39697 0.00239 8479.46851 0.00234 8477.54004 0.00228 8475.61157 0.00220 8473.68311 0.00212 8471.75464 0.00203 8469.82617 0.00195 8467.89771 0.00189 8465.96924 0.00184 8464.04077 0.00179 8462.11230 0.00175 8460.18384 0.00171 8458.25537 0.00168 8456.32690 0.00165 8454.39844 0.00161 8452.46997 0.00157 8450.54150 0.00151 8448.61304 0.00144 8446.68457 0.00137 8444.75610 0.00131 8442.82764 0.00126 8440.89917 0.00122 8438.97070 0.00118 8437.04224 0.00115 8435.11377 0.00112 8433.18530 0.00110 8431.25684 0.00107 8429.32837 0.00105 8427.39990 0.00102 8425.47144 0.00099 8423.54297 0.00095 8421.61450 0.00091 8419.68604 0.00088 8417.75757 0.00084 8415.82910 0.00082 8413.90063 0.00080 8411.97217 0.00078 8410.04370 0.00076 8408.11523 0.00073 8406.18677 0.00070 8404.25830 0.00067 8402.32983 0.00064 8400.40137 0.00061 8398.47290 0.00058 8396.54443 0.00056 8394.61597 0.00054 8392.68750 0.00051 8390.75903 0.00048 8388.83057 0.00046 8386.90210 0.00045 8384.97363 0.00046 8383.04517 0.00047 8381.11670 0.00047 8379.18823 0.00045 8377.25977 0.00041 8375.33130 0.00038 8373.40283 0.00034 8371.47437 0.00033 8369.54590 0.00032 8367.61743 0.00032 8365.68896 0.00032 8363.76050 0.00032 8361.83203 0.00032 8359.90356 0.00032 8357.97510 0.00031 8356.04663 0.00029 8354.11816 0.00026 8352.18970 0.00025 8350.26123 0.00024 8348.33276 0.00024 8346.40430 0.00024 8344.47583 0.00024 8342.54736 0.00024 8340.61890 0.00023 8338.69043 0.00022 8336.76196 0.00021 8334.83350 0.00019 8332.90503 0.00017 8330.97656 0.00016 8329.04810 0.00016 8327.11963 0.00016 8325.19116 0.00016 8323.26270 0.00016 8321.33423 0.00015 8319.40576 0.00014 8317.47729 0.00013 8315.54883 0.00013 8313.62036 0.00013 8311.69189 0.00012 8309.76343 0.00011 8307.83496 0.00010 8305.90649 0.00008 8303.97803 0.00007 8302.04956 0.00007 8300.12109 0.00007 8298.19263 0.00006 8296.26416 0.00006 8294.33569 0.00007 8292.40723 0.00008 8290.47876 0.00010 8288.55029 0.00011 8286.62183 0.00010 8284.69336 0.00007 8282.76489 0.00005 8280.83643 0.00003 8278.90796 0.00003 8276.97949 0.00004 8275.05103 0.00006 8273.12256 0.00008 8271.19409 0.00010 8269.26563 0.00010 8267.33716 0.00009 8265.40869 0.00009 8263.48022 0.00008 8261.55176 0.00006 8259.62329 0.00004 8257.69482 0.00003 8255.76636 0.00002 8253.83789 0.00001 8251.90942 0.00002 8249.98096 0.00003 8248.05249 0.00004 8246.12402 0.00004 8244.19556 0.00004 8242.26709 0.00003 8240.33862 0.00002 8238.41016 0.00002 8236.48169 0.00003 8234.55322 0.00005 8232.62476 0.00007 8230.69629 0.00007 8228.76782 0.00006 8226.83936 0.00005 8224.91089 0.00003 8222.98242 0.00002 8221.05396 0.00001 === Subject: Re: Problem in PL spectrum analysis assuming your data is in d: Integrate[Interpolation[d][x],{x,8224.91089`,10099.38062`}] hope this helps, Daniel > I now have troubles in the PL(photoluminescence) spectrum analysis. > Integration of the PL spectrum is the aim, however these data are > dispersed ones. > I don't know how to make it by Mathematica. yours gyzhou Below are the useful data. 10099.38062 -0.00000 > 10097.45215 0.00002 > 10095.52368 0.00005 > 10093.59521 0.00009 > 10091.66675 0.00012 > 10089.73828 0.00013 > 10087.80981 0.00014 > 10085.88135 0.00013 > 10083.95288 0.00012 > 10082.02441 0.00011 > 10080.09595 0.00009 > 10078.16748 0.00009 > 10076.23901 0.00009 > 10074.31055 0.00009 > 10072.38208 0.00010 > 10070.45361 0.00011 > 10068.52515 0.00011 > 10066.59668 0.00012 > 10064.66821 0.00013 > 10062.73975 0.00013 > 10060.81128 0.00012 > 10058.88281 0.00011 > 10056.95435 0.00011 > 10055.02588 0.00011 > 10053.09741 0.00011 > 10051.16895 0.00012 > 10049.24048 0.00013 > 10047.31201 0.00013 > 10045.38354 0.00013 > 10043.45508 0.00014 > 10041.52661 0.00015 > 10039.59814 0.00017 > 10037.66968 0.00018 > 10035.74121 0.00020 > 10033.81274 0.00020 > 10031.88428 0.00021 > 10029.95581 0.00021 > 10028.02734 0.00020 > 10026.09888 0.00020 > 10024.17041 0.00019 > 10022.24194 0.00018 > 10020.31348 0.00018 > 10018.38501 0.00018 > 10016.45654 0.00018 > 10014.52808 0.00019 > 10012.59961 0.00019 > 10010.67114 0.00020 > 10008.74268 0.00020 > 10006.81421 0.00022 > 10004.88574 0.00024 > 10002.95728 0.00025 > 10001.02881 0.00027 > 9999.10034 0.00027 > 9997.17188 0.00028 > 9995.24341 0.00028 > 9993.31494 0.00029 > 9991.38647 0.00029 > 9989.45801 0.00029 > 9987.52954 0.00029 > 9985.60107 0.00029 > 9983.67261 0.00029 > 9981.74414 0.00029 > 9979.81567 0.00030 > 9977.88721 0.00031 > 9975.95874 0.00031 > 9974.03027 0.00030 > 9972.10181 0.00029 > 9970.17334 0.00028 > 9968.24487 0.00028 > 9966.31641 0.00029 > 9964.38794 0.00031 > 9962.45947 0.00033 > 9960.53101 0.00034 > 9958.60254 0.00035 > 9956.67407 0.00035 > 9954.74561 0.00035 > 9952.81714 0.00036 > 9950.88867 0.00036 > 9948.96021 0.00037 > 9947.03174 0.00037 > 9945.10327 0.00038 > 9943.17480 0.00039 > 9941.24634 0.00040 > 9939.31787 0.00041 > 9937.38940 0.00041 > 9935.46094 0.00040 > 9933.53247 0.00040 > 9931.60400 0.00040 > 9929.67554 0.00040 > 9927.74707 0.00042 > 9925.81860 0.00043 > 9923.89014 0.00044 > 9921.96167 0.00044 > 9920.03320 0.00046 > 9918.10474 0.00047 > 9916.17627 0.00049 > 9914.24780 0.00050 > 9912.31934 0.00050 > 9910.39087 0.00050 > 9908.46240 0.00050 > 9906.53394 0.00050 > 9904.60547 0.00050 > 9902.67700 0.00051 > 9900.74854 0.00053 > 9898.82007 0.00055 > 9896.89160 0.00058 > 9894.96313 0.00059 > 9893.03467 0.00060 > 9891.10620 0.00061 > 9889.17773 0.00062 > 9887.24927 0.00063 > 9885.32080 0.00064 > 9883.39233 0.00066 > 9881.46387 0.00067 > 9879.53540 0.00069 > 9877.60693 0.00070 > 9875.67847 0.00071 > 9873.75000 0.00072 > 9871.82153 0.00072 > 9869.89307 0.00072 > 9867.96460 0.00072 > 9866.03613 0.00073 > 9864.10767 0.00074 > 9862.17920 0.00075 > 9860.25073 0.00076 > 9858.32227 0.00076 > 9856.39380 0.00077 > 9854.46533 0.00078 > 9852.53687 0.00080 > 9850.60840 0.00081 > 9848.67993 0.00082 > 9846.75146 0.00083 > 9844.82300 0.00084 > 9842.89453 0.00086 > 9840.96606 0.00089 > 9839.03760 0.00092 > 9837.10913 0.00094 > 9835.18066 0.00096 > 9833.25220 0.00098 > 9831.32373 0.00099 > 9829.39526 0.00101 > 9827.46680 0.00104 > 9825.53833 0.00106 > 9823.60986 0.00108 > 9821.68140 0.00109 > 9819.75293 0.00109 > 9817.82446 0.00108 > 9815.89600 0.00107 > 9813.96753 0.00107 > 9812.03906 0.00108 > 9810.11060 0.00110 > 9808.18213 0.00112 > 9806.25366 0.00115 > 9804.32520 0.00118 > 9802.39673 0.00121 > 9800.46826 0.00124 > 9798.53979 0.00126 > 9796.61133 0.00127 > 9794.68286 0.00127 > 9792.75439 0.00127 > 9790.82593 0.00127 > 9788.89746 0.00128 > 9786.96899 0.00130 > 9785.04053 0.00134 > 9783.11206 0.00138 > 9781.18359 0.00142 > 9779.25513 0.00145 > 9777.32666 0.00147 > 9775.39819 0.00147 > 9773.46973 0.00147 > 9771.54126 0.00147 > 9769.61279 0.00149 > 9767.68433 0.00151 > 9765.75586 0.00153 > 9763.82739 0.00155 > 9761.89893 0.00157 > 9759.97046 0.00159 > 9758.04199 0.00160 > 9756.11353 0.00161 > 9754.18506 0.00163 > 9752.25659 0.00166 > 9750.32813 0.00169 > 9748.39966 0.00173 > 9746.47119 0.00177 > 9744.54272 0.00180 > 9742.61426 0.00183 > 9740.68579 0.00185 > 9738.75732 0.00187 > 9736.82886 0.00188 > 9734.90039 0.00189 > 9732.97192 0.00190 > 9731.04346 0.00192 > 9729.11499 0.00195 > 9727.18652 0.00198 > 9725.25806 0.00203 > 9723.32959 0.00207 > 9721.40112 0.00210 > 9719.47266 0.00212 > 9717.54419 0.00214 > 9715.61572 0.00215 > 9713.68726 0.00216 > 9711.75879 0.00217 > 9709.83032 0.00220 > 9707.90186 0.00223 > 9705.97339 0.00227 > 9704.04492 0.00230 > 9702.11646 0.00233 > 9700.18799 0.00235 > 9698.25952 0.00237 > 9696.33105 0.00240 > 9694.40259 0.00243 > 9692.47412 0.00247 > 9690.54565 0.00250 > 9688.61719 0.00252 > 9686.68872 0.00255 > 9684.76025 0.00257 > 9682.83179 0.00259 > 9680.90332 0.00260 > 9678.97485 0.00262 > 9677.04639 0.00263 > 9675.11792 0.00266 > 9673.18945 0.00268 > 9671.26099 0.00272 > 9669.33252 0.00276 > 9667.40405 0.00280 > 9665.47559 0.00283 > 9663.54712 0.00287 > 9661.61865 0.00290 > 9659.69019 0.00294 > 9657.76172 0.00297 > 9655.83325 0.00301 > 9653.90479 0.00304 > 9651.97632 0.00307 > 9650.04785 0.00310 > 9648.11938 0.00313 > 9646.19092 0.00316 > 9644.26245 0.00318 > 9642.33398 0.00321 > 9640.40552 0.00324 > 9638.47705 0.00327 > 9636.54858 0.00330 > 9634.62012 0.00334 > 9632.69165 0.00337 > 9630.76318 0.00340 > 9628.83472 0.00343 > 9626.90625 0.00345 > 9624.97778 0.00348 > 9623.04932 0.00351 > 9621.12085 0.00355 > 9619.19238 0.00360 > 9617.26392 0.00366 > 9615.33545 0.00372 > 9613.40698 0.00377 > 9611.47852 0.00382 > 9609.55005 0.00387 > 9607.62158 0.00391 > 9605.69312 0.00395 > 9603.76465 0.00398 > 9601.83618 0.00400 > 9599.90771 0.00401 > 9597.97925 0.00402 > 9596.05078 0.00405 > 9594.12231 0.00409 > 9592.19385 0.00415 > 9590.26538 0.00420 > 9588.33691 0.00425 > 9586.40845 0.00429 > 9584.47998 0.00433 > 9582.55151 0.00436 > 9580.62305 0.00439 > 9578.69458 0.00442 > 9576.76611 0.00445 > 9574.83765 0.00449 > 9572.90918 0.00453 > 9570.98071 0.00458 > 9569.05225 0.00462 > 9567.12378 0.00467 > 9565.19531 0.00470 > 9563.26685 0.00474 > 9561.33838 0.00478 > 9559.40991 0.00483 > 9557.48145 0.00488 > 9555.55298 0.00493 > 9553.62451 0.00498 > 9551.69604 0.00501 > 9549.76758 0.00504 > 9547.83911 0.00507 > 9545.91064 0.00510 > 9543.98218 0.00515 > 9542.05371 0.00520 > 9540.12524 0.00525 > 9538.19678 0.00531 > 9536.26831 0.00536 > 9534.33984 0.00540 > 9532.41138 0.00545 > 9530.48291 0.00550 > 9528.55444 0.00555 > 9526.62598 0.00561 > 9524.69751 0.00567 > 9522.76904 0.00572 > 9520.84058 0.00577 > 9518.91211 0.00582 > 9516.98364 0.00585 > 9515.05518 0.00589 > 9513.12671 0.00593 > 9511.19824 0.00597 > 9509.26978 0.00602 > 9507.34131 0.00607 > 9505.41284 0.00612 > 9503.48438 0.00617 > 9501.55591 0.00622 > 9499.62744 0.00626 > 9497.69897 0.00630 > 9495.77051 0.00634 > 9493.84204 0.00639 > 9491.91357 0.00645 > 9489.98511 0.00651 > 9488.05664 0.00657 > 9486.12817 0.00664 > 9484.19971 0.00669 > 9482.27124 0.00674 > 9480.34277 0.00679 > 9478.41431 0.00684 > 9476.48584 0.00690 > 9474.55737 0.00696 > 9472.62891 0.00701 > 9470.70044 0.00707 > 9468.77197 0.00712 > 9466.84351 0.00717 > 9464.91504 0.00721 > 9462.98657 0.00725 > 9461.05811 0.00730 > 9459.12964 0.00736 > 9457.20117 0.00743 > 9455.27271 0.00750 > 9453.34424 0.00756 > 9451.41577 0.00761 > 9449.48730 0.00766 > 9447.55884 0.00772 > 9445.63037 0.00778 > 9443.70190 0.00784 > 9441.77344 0.00791 > 9439.84497 0.00797 > 9437.91650 0.00802 > 9435.98804 0.00807 > 9434.05957 0.00813 > 9432.13110 0.00819 > 9430.20264 0.00825 > 9428.27417 0.00832 > 9426.34570 0.00839 > 9424.41724 0.00846 > 9422.48877 0.00852 > 9420.56030 0.00859 > 9418.63184 0.00865 > 9416.70337 0.00872 > 9414.77490 0.00879 > 9412.84644 0.00885 > 9410.91797 0.00892 > 9408.98950 0.00898 > 9407.06104 0.00904 > 9405.13257 0.00910 > 9403.20410 0.00918 > 9401.27563 0.00926 > 9399.34717 0.00935 > 9397.41870 0.00943 > 9395.49023 0.00950 > 9393.56177 0.00956 > 9391.63330 0.00960 > 9389.70483 0.00965 > 9387.77637 0.00970 > 9385.84790 0.00976 > 9383.91943 0.00983 > 9381.99097 0.00990 > 9380.06250 0.00996 > 9378.13403 0.01002 > 9376.20557 0.01007 > 9374.27710 0.01013 > 9372.34863 0.01020 > 9370.42017 0.01029 > 9368.49170 0.01037 > 9366.56323 0.01046 > 9364.63477 0.01054 > 9362.70630 0.01061 > 9360.77783 0.01068 > 9358.84937 0.01076 > 9356.92090 0.01084 > 9354.99243 0.01092 > 9353.06396 0.01100 > 9351.13550 0.01107 > 9349.20703 0.01113 > 9347.27856 0.01120 > 9345.35010 0.01127 > 9343.42163 0.01135 > 9341.49316 0.01142 > 9339.56470 0.01150 > 9337.63623 0.01157 > 9335.70776 0.01164 > 9333.77930 0.01171 > 9331.85083 0.01178 > 9329.92236 0.01186 > 9327.99390 0.01195 > 9326.06543 0.01205 > 9324.13696 0.01215 > 9322.20850 0.01224 > 9320.28003 0.01232 > 9318.35156 0.01239 > 9316.42310 0.01246 > 9314.49463 0.01253 > 9312.56616 0.01261 > 9310.63770 0.01269 > 9308.70923 0.01278 > 9306.78076 0.01287 > 9304.85229 0.01297 > 9302.92383 0.01305 > 9300.99536 0.01313 > 9299.06689 0.01321 > 9297.13843 0.01328 > 9295.20996 0.01334 > 9293.28149 0.01341 > 9291.35303 0.01347 > 9289.42456 0.01354 > 9287.49609 0.01361 > 9285.56763 0.01370 > 9283.63916 0.01379 > 9281.71069 0.01389 > 9279.78223 0.01399 > 9277.85376 0.01409 > 9275.92529 0.01418 > 9273.99683 0.01427 > 9272.06836 0.01436 > 9270.13989 0.01444 > 9268.21143 0.01451 > 9266.28296 0.01459 > 9264.35449 0.01466 > 9262.42603 0.01474 > 9260.49756 0.01483 > 9258.56909 0.01492 > 9256.64063 0.01502 > 9254.71216 0.01511 > 9252.78369 0.01520 > 9250.85522 0.01529 > 9248.92676 0.01538 > 9246.99829 0.01546 > 9245.06982 0.01554 > 9243.14136 0.01560 > 9241.21289 0.01566 > 9239.28442 0.01572 > 9237.35596 0.01579 > 9235.42749 0.01586 > 9233.49902 0.01595 > 9231.57056 0.01606 > 9229.64209 0.01617 > 9227.71362 0.01627 > 9225.78516 0.01636 > 9223.85669 0.01643 > 9221.92822 0.01650 > 9219.99976 0.01656 > 9218.07129 0.01664 > 9216.14282 0.01672 > 9214.21436 0.01680 > 9212.28589 0.01688 > 9210.35742 0.01696 > 9208.42896 0.01704 > 9206.50049 0.01712 > 9204.57202 0.01720 > 9202.64355 0.01728 > 9200.71509 0.01736 > 9198.78662 0.01743 > 9196.85815 0.01750 > 9194.92969 0.01759 > 9193.00122 0.01768 > 9191.07275 0.01777 > 9189.14429 0.01786 > 9187.21582 0.01794 > 9185.28735 0.01800 > 9183.35889 0.01805 > 9181.43042 0.01811 > 9179.50195 0.01817 > 9177.57349 0.01824 > 9175.64502 0.01831 > 9173.71655 0.01838 > 9171.78809 0.01846 > 9169.85962 0.01854 > 9167.93115 0.01863 > 9166.00269 0.01872 > 9164.07422 0.01881 > 9162.14575 0.01890 > 9160.21729 0.01898 > 9158.28882 0.01907 > 9156.36035 0.01914 > 9154.43188 0.01921 > 9152.50342 0.01928 > 9150.57495 0.01935 > 9148.64648 0.01942 > 9146.71802 0.01949 > 9144.78955 0.01957 > 9142.86108 0.01964 > 9140.93262 0.01971 > 9139.00415 0.01979 > 9137.07568 0.01987 > 9135.14722 0.01994 > 9133.21875 0.02001 > 9131.29028 0.02008 > 9129.36182 0.02014 > 9127.43335 0.02021 > 9125.50488 0.02029 > 9123.57642 0.02037 > 9121.64795 0.02044 > 9119.71948 0.02051 > 9117.79102 0.02059 > 9115.86255 0.02066 > 9113.93408 0.02073 > 9112.00562 0.02081 > 9110.07715 0.02090 > 9108.14868 0.02098 > 9106.22021 0.02107 > 9104.29175 0.02115 > 9102.36328 0.02121 > 9100.43481 0.02127 > 9098.50635 0.02132 > 9096.57788 0.02136 > 9094.64941 0.02142 > 9092.72095 0.02147 > 9090.79248 0.02153 > 9088.86401 0.02160 > 9086.93555 0.02168 > 9085.00708 0.02175 > 9083.07861 0.02183 > 9081.15015 0.02191 > 9079.22168 0.02198 > 9077.29321 0.02205 > 9075.36475 0.02212 > 9073.43628 0.02219 > 9071.50781 0.02226 > 9069.57935 0.02233 > 9067.65088 0.02240 > 9065.72241 0.02247 > 9063.79395 0.02253 > 9061.86548 0.02260 > 9059.93701 0.02267 > 9058.00854 0.02275 > 9056.08008 0.02282 > 9054.15161 0.02289 > 9052.22314 0.02295 > 9050.29468 0.02301 > 9048.36621 0.02307 > 9046.43774 0.02313 > 9044.50928 0.02320 > 9042.58081 0.02327 > 9040.65234 0.02335 > 9038.72388 0.02342 > 9036.79541 0.02350 > 9034.86694 0.02357 > 9032.93848 0.02363 > 9031.01001 0.02368 > 9029.08154 0.02374 > 9027.15308 0.02381 > 9025.22461 0.02387 > 9023.29614 0.02394 > 9021.36768 0.02401 > 9019.43921 0.02407 > 9017.51074 0.02413 > 9015.58228 0.02419 > 9013.65381 0.02425 > 9011.72534 0.02431 > 9009.79688 0.02438 > 9007.86841 0.02443 > 9005.93994 0.02449 > 9004.01147 0.02454 > 9002.08301 0.02460 > 9000.15454 0.02466 > 8998.22607 0.02473 > 8996.29761 0.02479 > 8994.36914 0.02485 > 8992.44067 0.02491 > 8990.51221 0.02496 > 8988.58374 0.02502 > 8986.65527 0.02507 > 8984.72681 0.02513 > 8982.79834 0.02518 > 8980.86987 0.02523 > 8978.94141 0.02528 > 8977.01294 0.02533 > 8975.08447 0.02538 > 8973.15601 0.02543 > 8971.22754 0.02548 > 8969.29907 0.02554 > 8967.37061 0.02560 > 8965.44214 0.02565 > 8963.51367 0.02571 > 8961.58521 0.02576 > 8959.65674 0.02580 > 8957.72827 0.02583 > 8955.79980 0.02587 > 8953.87134 0.02592 > 8951.94287 0.02597 > 8950.01440 0.02603 > 8948.08594 0.02608 > 8946.15747 0.02612 > 8944.22900 0.02615 > 8942.30054 0.02618 > 8940.37207 0.02622 > 8938.44360 0.02627 > 8936.51514 0.02632 > 8934.58667 0.02636 > 8932.65820 0.02640 > 8930.72974 0.02644 > 8928.80127 0.02647 > 8926.87280 0.02651 > 8924.94434 0.02655 > 8923.01587 0.02660 > 8921.08740 0.02663 > 8919.15894 0.02665 > 8917.23047 0.02667 > 8915.30200 0.02667 > 8913.37354 0.02668 > 8911.44507 0.02669 > 8909.51660 0.02673 > 8907.58813 0.02678 > 8905.65967 0.02684 > 8903.73120 0.02690 > 8901.80273 0.02694 > 8899.87427 0.02698 > 8897.94580 0.02704 > 8896.01733 0.02710 > 8894.08887 0.02716 > 8892.16040 0.02718 > 8890.23193 0.02717 > 8888.30347 0.02713 > 8886.37500 0.02709 > 8884.44653 0.02710 > 8882.51807 0.02714 > 8880.58960 0.02720 > 8878.66113 0.02727 > 8876.73267 0.02731 > 8874.80420 0.02733 > 8872.87573 0.02732 > 8870.94727 0.02728 > 8869.01880 0.02725 > 8867.09033 0.02723 > 8865.16187 0.02724 > 8863.23340 0.02727 > 8861.30493 0.02731 > 8859.37646 0.02734 > 8857.44800 0.02734 > 8855.51953 0.02732 > 8853.59106 0.02729 > 8851.66260 0.02728 > 8849.73413 0.02728 > 8847.80566 0.02730 > 8845.87720 0.02732 > 8843.94873 0.02733 > 8842.02026 0.02732 > 8840.09180 0.02729 > 8838.16333 0.02726 > 8836.23486 0.02723 > 8834.30640 0.02719 > 8832.37793 0.02716 > 8830.44946 0.02711 > 8828.52100 0.02705 > 8826.59253 0.02698 > 8824.66406 0.02690 > 8822.73560 0.02681 > 8820.80713 0.02670 > 8818.87866 0.02657 > 8816.95020 0.02641 > 8815.02173 0.02626 > 8813.09326 0.02616 > 8811.16479 0.02611 > 8809.23633 0.02612 > 8807.30786 0.02614 > 8805.37939 0.02615 > 8803.45093 0.02613 > 8801.52246 0.02609 > 8799.59399 0.02605 > 8797.66553 0.02601 > 8795.73706 0.02596 > 8793.80859 0.02589 > 8791.88013 0.02581 > 8789.95166 0.02571 > 8788.02319 0.02561 > 8786.09473 0.02550 > 8784.16626 0.02540 > 8782.23779 0.02530 > 8780.30933 0.02520 > 8778.38086 0.02510 > 8776.45239 0.02500 > 8774.52393 0.02490 > 8772.59546 0.02478 > 8770.66699 0.02466 > 8768.73853 0.02454 > 8766.81006 0.02441 > 8764.88159 0.02427 > 8762.95313 0.02415 > 8761.02466 0.02403 > 8759.09619 0.02392 > 8757.16772 0.02381 > 8755.23926 0.02369 > 8753.31079 0.02357 > 8751.38232 0.02345 > 8749.45386 0.02331 > 8747.52539 0.02317 > 8745.59692 0.02302 > 8743.66846 0.02286 > 8741.73999 0.02268 > 8739.81152 0.02251 > 8737.88306 0.02235 > 8735.95459 0.02220 > 8734.02612 0.02205 > 8732.09766 0.02189 > 8730.16919 0.02173 > 8728.24072 0.02156 > 8726.31226 0.02138 > 8724.38379 0.02119 > 8722.45532 0.02100 > 8720.52686 0.02082 > 8718.59839 0.02066 > 8716.66992 0.02051 > 8714.74146 0.02036 > 8712.81299 0.02022 > 8710.88452 0.02007 > 8708.95605 0.01990 > 8707.02759 0.01973 > 8705.09912 0.01956 > 8703.17065 0.01939 > 8701.24219 0.01922 > 8699.31372 0.01905 > 8697.38525 0.01888 > 8695.45679 0.01872 > 8693.52832 0.01855 > 8691.59985 0.01838 > 8689.67139 0.01819 > 8687.74292 0.01799 > 8685.81445 0.01777 > 8683.88599 0.01756 > 8681.95752 0.01734 > 8680.02905 0.01713 > 8678.10059 0.01693 > 8676.17212 0.01674 > 8674.24365 0.01657 > 8672.31519 0.01641 > 8670.38672 0.01626 > 8668.45825 0.01610 > 8666.52979 0.01593 > 8664.60132 0.01576 > 8662.67285 0.01557 > 8660.74438 0.01537 > 8658.81592 0.01515 > 8656.88745 0.01494 > 8654.95898 0.01474 > 8653.03052 0.01454 > 8651.10205 0.01435 > 8649.17358 0.01417 > 8647.24512 0.01398 > 8645.31665 0.01379 > 8643.38818 0.01361 > 8641.45972 0.01343 > 8639.53125 0.01326 > 8637.60278 0.01309 > 8635.67432 0.01292 > 8633.74585 0.01274 > 8631.81738 0.01256 > 8629.88892 0.01238 > 8627.96045 0.01219 > 8626.03198 0.01200 > 8624.10352 0.01182 > 8622.17505 0.01163 > 8620.24658 0.01143 > 8618.31812 0.01124 > 8616.38965 0.01105 > 8614.46118 0.01088 > 8612.53271 0.01071 > 8610.60425 0.01055 > 8608.67578 0.01037 > 8606.74731 0.01020 > 8604.81885 0.01002 > 8602.89038 0.00985 > 8600.96191 0.00969 > 8599.03345 0.00954 > 8597.10498 0.00939 > 8595.17651 0.00924 > 8593.24805 0.00908 > 8591.31958 0.00891 > 8589.39111 0.00874 > 8587.46265 0.00856 > 8585.53418 0.00839 > 8583.60571 0.00823 > 8581.67725 0.00806 > 8579.74878 0.00791 > 8577.82031 0.00775 > 8575.89185 0.00761 > 8573.96338 0.00747 > 8572.03491 0.00734 > 8570.10645 0.00721 > 8568.17798 0.00708 > 8566.24951 0.00695 > 8564.32104 0.00680 > 8562.39258 0.00665 > 8560.46411 0.00650 > 8558.53564 0.00635 > 8556.60718 0.00621 > 8554.67871 0.00608 > 8552.75024 0.00595 > 8550.82178 0.00582 > 8548.89331 0.00569 > 8546.96484 0.00555 > 8545.03638 0.00542 > 8543.10791 0.00528 > 8541.17944 0.00516 > 8539.25098 0.00504 > 8537.32251 0.00494 > 8535.39404 0.00483 > 8533.46558 0.00474 > 8531.53711 0.00464 > 8529.60864 0.00453 > 8527.68018 0.00443 > 8525.75171 0.00432 > 8523.82324 0.00421 > 8521.89478 0.00410 > 8519.96631 0.00399 > 8518.03784 0.00389 > 8516.10938 0.00378 > 8514.18091 0.00368 > 8512.25244 0.00359 > 8510.32397 0.00350 > 8508.39551 0.00342 > 8506.46704 0.00334 > 8504.53857 0.00327 > 8502.61011 0.00319 > 8500.68164 0.00311 > 8498.75317 0.00302 > 8496.82471 0.00293 > 8494.89624 0.00285 > 8492.96777 0.00278 > 8491.03931 0.00271 > 8489.11084 0.00264 > 8487.18237 0.00257 > 8485.25391 0.00251 > 8483.32544 0.00245 > 8481.39697 0.00239 > 8479.46851 0.00234 > 8477.54004 0.00228 > 8475.61157 0.00220 > 8473.68311 0.00212 > 8471.75464 0.00203 > 8469.82617 0.00195 > 8467.89771 0.00189 > 8465.96924 0.00184 > 8464.04077 0.00179 > 8462.11230 0.00175 > 8460.18384 0.00171 > 8458.25537 0.00168 > 8456.32690 0.00165 > 8454.39844 0.00161 > 8452.46997 0.00157 > 8450.54150 0.00151 > 8448.61304 0.00144 > 8446.68457 0.00137 > 8444.75610 0.00131 > 8442.82764 0.00126 > 8440.89917 0.00122 > 8438.97070 0.00118 > 8437.04224 0.00115 > 8435.11377 0.00112 > 8433.18530 0.00110 > 8431.25684 0.00107 > 8429.32837 0.00105 > 8427.39990 0.00102 > 8425.47144 0.00099 > 8423.54297 0.00095 > 8421.61450 0.00091 > 8419.68604 0.00088 > 8417.75757 0.00084 > 8415.82910 0.00082 > 8413.90063 0.00080 > 8411.97217 0.00078 > 8410.04370 0.00076 > 8408.11523 0.00073 > 8406.18677 0.00070 > 8404.25830 0.00067 > 8402.32983 0.00064 > 8400.40137 0.00061 > 8398.47290 0.00058 > 8396.54443 0.00056 > 8394.61597 0.00054 > 8392.68750 0.00051 > 8390.75903 0.00048 > 8388.83057 0.00046 > 8386.90210 0.00045 > 8384.97363 0.00046 > 8383.04517 0.00047 > 8381.11670 0.00047 > 8379.18823 0.00045 > 8377.25977 0.00041 > 8375.33130 0.00038 > 8373.40283 0.00034 > 8371.47437 0.00033 > 8369.54590 0.00032 > 8367.61743 0.00032 > 8365.68896 0.00032 > 8363.76050 0.00032 > 8361.83203 0.00032 > 8359.90356 0.00032 > 8357.97510 0.00031 > 8356.04663 0.00029 > 8354.11816 0.00026 > 8352.18970 0.00025 > 8350.26123 0.00024 > 8348.33276 0.00024 > 8346.40430 0.00024 > 8344.47583 0.00024 > 8342.54736 0.00024 > 8340.61890 0.00023 > 8338.69043 0.00022 > 8336.76196 0.00021 > 8334.83350 0.00019 > 8332.90503 0.00017 > 8330.97656 0.00016 > 8329.04810 0.00016 > 8327.11963 0.00016 > 8325.19116 0.00016 > 8323.26270 0.00016 > 8321.33423 0.00015 > 8319.40576 0.00014 > 8317.47729 0.00013 > 8315.54883 0.00013 > 8313.62036 0.00013 > 8311.69189 0.00012 > 8309.76343 0.00011 > 8307.83496 0.00010 > 8305.90649 0.00008 > 8303.97803 0.00007 > 8302.04956 0.00007 > 8300.12109 0.00007 > 8298.19263 0.00006 > 8296.26416 0.00006 > 8294.33569 0.00007 > 8292.40723 0.00008 > 8290.47876 0.00010 > 8288.55029 0.00011 > 8286.62183 0.00010 > 8284.69336 0.00007 > 8282.76489 0.00005 > 8280.83643 0.00003 > 8278.90796 0.00003 > 8276.97949 0.00004 > 8275.05103 0.00006 > 8273.12256 0.00008 > 8271.19409 0.00010 > 8269.26563 0.00010 > 8267.33716 0.00009 > 8265.40869 0.00009 > 8263.48022 0.00008 > 8261.55176 0.00006 > 8259.62329 0.00004 > 8257.69482 0.00003 > 8255.76636 0.00002 > 8253.83789 0.00001 > 8251.90942 0.00002 > 8249.98096 0.00003 > 8248.05249 0.00004 > 8246.12402 0.00004 > 8244.19556 0.00004 > 8242.26709 0.00003 > 8240.33862 0.00002 > 8238.41016 0.00002 > 8236.48169 0.00003 > 8234.55322 0.00005 > 8232.62476 0.00007 > 8230.69629 0.00007 > 8228.76782 0.00006 > 8226.83936 0.00005 > 8224.91089 0.00003 > 8222.98242 0.00002 > 8221.05396 0.00001 > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Spline`Spline and GraphicsComplex Is there an easy way to have Spline`Spline work inside GraphicsComplex? -- m === Subject: Re: Label style in PieChart? Needs[PieCharts`] pct = 21.7; pieLab = StringJoin[ToString[pct], %]; Format the label directly pc = PieChart[{pct, 100 - pct}, PieLabels -> { Style[pieLab, 14, FontFamily -> Helvetica], }, PieStyle -> { Directive[Darker[Blue], Opacity[0.4]], Directive[Gray, Opacity[0.1]]}, ImageSize -> 200] Or change the BaseStyle pc = PieChart[{pct, 100 - pct}, BaseStyle -> Directive[14, FontFamily -> Helvetica], PieLabels -> {pieLab, }, PieStyle -> { Directive[Darker[Blue], Opacity[0.4]], Directive[Gray, Opacity[0.1]]}, ImageSize -> 200] Bob Hanlon I'm using Mathematica 6.0.3 on OSX 10.5. In a PieChart, is it possible to control the label font size and family? I routinely control this for 'FrameLabel' with ListPLot. But in the following, adding 'LabelStyle -> Directive[12, FontFamily -> Helvetica]', does not change the '21.7%' label, PieLabelStyle is not valid, PieStyle does not accept font information, and I have found nothing information in the Help system or on the web for this. pct = 21.7 pieLab = StringJoin[ToString[pct], %] PieChart[{pct, 100 - pct}, PieLabels -> {pieLab, }, PieStyle -> {Directive[Darker[Blue], Opacity[0.4]], Directive[Gray, Opacity[0.1]]}, ImageSize -> 200] G -- Gordon Robertson B.C. Cancer Agency Genome Sciences Centre Vancouver BC Canada V5Z 4S6 604.707.5900 x5416 www.bcgsc.ca -- Bob Hanlon === Subject: Re: how to test where a list contains constant(s) or not IsConstantsIn[list_] := Or @@ (NumericQ /@ list) IsConstantsIn /@ {{a, b, c, Pi}, {a, b, c, 0.0001}, {a, b, c, 2 + Pi I}, {a, b, c}} {True,True,True,False} Bob Hanlon case1: { a, b, c, Pi } gives true because of Pi case2: { a, b, c, 0.0001} gives true because of 0.0001 case3: { a, b, c, 2 + Pi I } gives ture becase of 2 + Pi I case4: { a, b, c} gives false is this function right ? ComplexQ[z_] := NumericQ[ z ] || ( NumericQ[ z ] && SameQ[ Head[ z ], Complex] ) IsConstantsIn[ lstList_ ] := Module[ { intLength }, intLength = Length@Select[ lstList, ComplexQ[ # ]& ]; If[ intLength > 0, Return[ True ], Return[ False ] ]; Return[ False ]; ] -- Bob Hanlon === Subject: Re: Label style in PieChart? Gordon, Use Style on individual items, or BaseStyle for an entire plot. Needs[PieCharts`] pct = 21.7; pieLab = StringJoin[ToString[pct], %]; PieChart[{pct, 100 - pct}, PieLabels -> {Style[pieLab, 14], }, PieStyle -> {Directive[Darker[Blue], Opacity[0.4]], Directive[Gray, Opacity[0.1]]}, ImageSize -> 200] PieChart[{pct, 100 - pct}, PieLabels -> {pieLab, }, PieStyle -> {Directive[Darker[Blue], Opacity[0.4]], Directive[Gray, Opacity[0.1]]}, BaseStyle -> {FontSize -> 14}, ImageSize -> 200] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm using Mathematica 6.0.3 on OSX 10.5. In a PieChart, is it possible > to control the label font size and family? I routinely control this for > 'FrameLabel' with ListPLot. But in the following, adding > 'LabelStyle -> Directive[12, FontFamily -> Helvetica]', does not > change the '21.7%' label, PieLabelStyle is not valid, PieStyle does > not accept font information, and I have found nothing information in > the Help system or on the web for this. pct = 21.7 pieLab = StringJoin[ToString[pct], %] PieChart[{pct, 100 - pct}, PieLabels -> {pieLab, }, > PieStyle -> {Directive[Darker[Blue], Opacity[0.4]], Directive[Gray, > Opacity[0.1]]}, ImageSize -> 200] > G > -- > Gordon Robertson > B.C. Cancer Agency Genome Sciences Centre > Vancouver BC Canada V5Z 4S6 > 604.707.5900 x5416 > www.bcgsc.ca === Subject: Re: Label style in PieChart? Needs[PieCharts`] pct = 21.7 pieLab = StringJoin[ToString[pct], %]; PieChart[{pct, 100 - pct}, PieLabels -> {pieLab, }, PieStyle -> {Directive[Darker[Blue], Opacity[0.4]], Directive[Gray, Opacity[0.1]]}, ImageSize -> 200, BaseStyle -> {FontSize -> 24, FontFamily -> Brush Script Std}] works on my Windows box. Jens I'm using Mathematica 6.0.3 on OSX 10.5. In a PieChart, is it possible > to control the label font size and family? I routinely control this for > 'FrameLabel' with ListPLot. But in the following, adding > 'LabelStyle -> Directive[12, FontFamily -> Helvetica]', does not > change the '21.7%' label, PieLabelStyle is not valid, PieStyle does > not accept font information, and I have found nothing information in > the Help system or on the web for this. pct = 21.7 pieLab = StringJoin[ToString[pct], %] PieChart[{pct, 100 - pct}, PieLabels -> {pieLab, }, > PieStyle -> {Directive[Darker[Blue], Opacity[0.4]], Directive[Gray, > Opacity[0.1]]}, ImageSize -> 200] > G === Subject: Re: asumming and Exp orthogonality condition On Sep 15, 2:38 am, Jean-Marc Gulliet Element[ 0 , Integers ] evaluates to true, however; > Assuming[ Element[ n , Integers] , Integrate[ Exp [ 2 I Pi n x ] , {x , 0 , 1 } ] ] evaluates to zero. Shouldn't evaluate to KroneckerDelta[ 0 , n ] instead? The following might explain what is going on. Mathematica does not have > any transformation rule for this specific case of this definite integral. So, I guess, what Mathematica computes first is the general formula for > the definite integral (I shall call it int[n]) and then applies the > assumption about n being an integer. (This is conceptually equivalent to > In[1] and In[2].) As it stands, int[n] is defined and equal to 0 for all n in N, n !=0. > (For n == 0 we have a division by zero.) So what Mathematica sees is > that the function is defined for every non-zero integer and its value is > therefore zero. Now, if we extend the domain of definition of int[n] to the whole set of > integers and defined int[0] == 1, (having checked that the limit = of > int[n] as n approaches zero on the left and on the right is equal to > one), only then this extended definition matches KroneckerDelta[0, n]. Thus, Mathematica's behavior seems reasonable since Mathematica is not > going to attempt by itself to check the limits and/or extend the domain > of definition. In[1]:= int[n_] = Integrate[Exp[2 I Pi n x], {x, 0, 1}] Out[1]= -((I (-1 + E^(2 I n [Pi])))/(2 n [Pi])) In[2]:= Assuming[Element[n, Integers], Simplify[int[n]]] Out[2]= 0 In[3]:= Table[int[n], {n, -2, 2}] During evaluation of In[3]:= Power::infy: Infinite expression 1/0 > encountered. > > During evaluation of In[3]:= [Infinity]::indet: Indeterminate > expression (0 ComplexInfinity)/[Pi] encountered. > > Out[3]= {0, 0, Indeterminate, 0, 0} In[4]:= Limit[int[n], n -> 0, Direction -> 1] Out[4]= 1 In[5]:= Limit[int[n], n -> 0, Direction -> -1] Out[5]= 1 -- Jean-Marc I've read that it is possible to unprotect the Integrate function and add/override values with custom functions. Is it possible to override this in this particular case? Charles J. Quarra === Subject: Re: Problem with replacement rules On Sep 11, 12:16 pm, Jens-Peer Kuska makeFunction[expr_, x_] := Module[{var}, > var = Complement[Variables[expr], {x}]; > Function @@ {var, x /. Solve[expr == 0, x][[1]]} > ] and f = makeFunction[2 + x - y^2, x]; Plot[f[z], {z, -2, 2}] ?? Jens This code proposed by Jens-Peer Kuska only works with polynomial equations, because Variables only works correctly with polynomials. For example, makeFunction[Sin[x]-y,x] gives as output: Function[{y, Sin[x]}, ArcSin[y]] which is incorrect and cannot be plotted. A more general code is the following: invFunction[expr_, x_, vars_List] := Function @@ {vars, x /. Solve[expr == 0, x][[1]]} where the argument x is the dependent variable and vars_List is the list of independent variables. Now you have as before: f = invFunction[2 + x - y^2, x, {y}] Plot[f[z], {z, -2, 2}] for your polynomial functions, but also f = invFunction[Sin[x] - y, x, {y}] Plot[f[z], {z, -2, 2}] without a problem. An example with multiple indep. variables: f = invFunction[Sin[x] - y - z, x, {y, z}] Plot3D[f[y, z], {y, -1, 1}, {z, -1, 1}] hth === Subject: Re: One fundamental Gudermannian identity not verified > Since I couldn't find a definition of the Gudermannian fonction among > Mathematica packages I defined it myself : > >> In[9]:= Gd= (2 tan^-1(e^#)-[Pi]/2) & The above expression *cannot* yield the result below for neither lowercase e has any built-in meaning nor tan^-1. However, capital E and ArcTan have the desired meaning. >> Out[9]= 2 ArcTan[[ExponentialE]^#1] - [Pi]/2 & I could verify all the identies with that fonction I thought of , > including one involving half-angles ie > >> In[14]:= FullSimplify[Subtract @@ {#[[1]][Gd[x]/2], #[[2]][x/2]}, >> x[Epsilon] Reals] & /@ {{Tan, Tanh}} Surely you meant Element[x, Reals] and not x times epsilon times Reals? >> Out[14]= {0} but not this last one : > >> In[16]:= FullSimplify[Subtract @@ {#[[1]][x], #[[2]][Tanh x/2]}, What you have written means (Tanh times x) divided by two. >> x[Epsilon] Reals] & /@ {{Gd , 2 ArcTan}} >> Out[16]= {-[Pi]/2 + >> 2 ArcTan[[ExponentialE]^x] - (2 ArcTan)[(Tanh x)/2]} Notice the spurious set of parentheses around two times ArcTan... > Is there another way with Mahematica 6.0 to make this verification? You should post actual code, i.e. the output must be produce by the input, and not a mix of fantasied notation. -- Jean-Marc === Subject: Re: Advanced plotting > I am wondering is there a possibility in Mathematica 6 to use two > different scales on vertical axis- one scale on the left one and the > other on the right one (with a horizontal axis being common for both The Technical Support FAQ titled, Can I create a two-axis graph in Mathematica? should answer your question. See, http://support.wolfram.com/mathematica/graphics/2d/twoaxisgraph.html Note that you must *not* load the packageGraphics`MultipleListPlot` when working with version 6.x. For instance, In[1]:= $Version TwoAxisPlot[{f_, g_}, {x_, min_, max_}, frange_, grange_, (opts___)?OptionQ] := Module[{old, new, scale, pts, gstuff, fstuff}, {fm, fM} = frange; {gm, gM} = grange; scale[var_] = ((var - gm)*(fM - fm))/(gM - gm) + fm; old = AbsoluteOptions[ Plot[g, {x, min, max}, Frame -> True, PlotRange -> grange, DisplayFunction -> Identity], FrameTicks][[1, 2, 2]]; new = (Prepend[Rest[#1], scale[First[#1]]] &) /@ old; Plot[{f, scale[g]}, {x, min, max}, Frame -> True, PlotRange -> frange + {0, .05 (fM - fm)}, FrameTicks -> {Automatic, Automatic, None, new}, PlotStyle -> {{RGBColor[1, 0, 0]}, {RGBColor[0, 0, 1]}}, FrameStyle -> {{}, {RGBColor[1, 0, 0]}, {}, {RGBColor[0, 0, 1]}}, opts]] TwoAxisPlot[{x^3, Sqrt[x]}, {x, 0, 4}, {0, 64}, {0, 2}] TwoAxisPlot[{Sqrt[x], x^3}, {x, 0, 4}, {0, 2}, {0, 70}] Out[1]= 6.0 for Mac OS X x86 (64-bit) (May 21, 2008) [... graphics deleted ...] -- Jean-Marc === Subject: Re: Advanced plotting I have to admit that this was a bit of work because I never tried to make a plot with an x-axis break before, but this can be done with the Presentations package. I plot BesselJ[5,x] and x^2 on the same plot with the y scale on the left going from -0.4 to 0.4 and on the right going from 0 to 2500. The scale on the right was produced with CustomTicks. The x^2 function and scale are shown in Red. The functions are shown in the domain [0,10] and [40,50] with a break, using a dashed line and // in the middle. Since we can't have several partial scales on an axis with Mathematica, I used two XTickLines from Presentations to produce the x scales from 0 to 10 and 40 to 50. This whole process might be automated if we were going to do a lot of it. We have to do a y scaling transformation on the x^2 function in both its plotting and in the CustomTicks. We have to do x domain shifting for both functions in the separated domain [40,50]. The x-axis and its labeling are essentially hand crafter. Needs[Presentations`Master`] yrightticks = CustomTicks[-.4 + .00032 # &, {0, 5200, 500, 5}, CTNumberFunction -> (Style[#, Red] &)]; Draw2D[ {Draw[BesselJ[5, x], {x, 0, 10}], Draw[BesselJ[5, x + 25], {x, 15, 25}], Red, Draw[-0.4` + 0.00032` x^2, {x, 0, 10}], Draw[-0.4` + 0.00032` (x + 25)^2, {x, 15, 25}], (* Draw the x axis in two pieces *) Black, {AbsoluteDashing[{4}], Line[{{10, -.4}, {25, -.4}}]}, Text[Style[//, 12, Bold], {12.5, -.4}], XTickLine[{0, 10, -.4}, {0, 10}, {0, 10, 5}, 5, XLabTickSpecs -> {0.02, 0}, XUnLabTickSpecs -> {.01, 0}], XTickLine[{15, 25, -.4}, {40, 50}, {40, 50, 5}, 5, XLabTickSpecs -> {0.02, 0}, XUnLabTickSpecs -> {.01, 0}], Text[x // TraditionalForm, {12.5, -.45}]}, AspectRatio -> .6, Frame -> {False, True, False, True}, FrameTicks -> {None, Automatic, None, yrightticks}, FrameLabel -> {None, BesselJ[5, x], None, x^2}, RotateLabel -> False, PlotRange -> {{0, 25}, {-.40, .40}}, PlotRangePadding -> 0, PlotRangeClipping -> False, ImagePadding -> {{60, 50}, {30, 10}}, PlotLabel -> Two Scale Plot with x Axis Break, BaseStyle -> {FontSize -> 12}, ImageSize -> 500] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > I am wondering is there a possibility in Mathematica 6 to use two > different scales on vertical axis- one scale on the left one and the > other on the right one (with a horizontal axis being common for both > the vertical ones). The thing is I would like to plot two functions > that have the same x-domain but completely different y-domain. If > I used the standard plotting procedure then if a first function (with > values about 100) can be easily seen on the plot, the values of the > other are to small (close to zero) to be seen. The solution would be > to set two independent Y axes, however I don't know if there is the > possibility in Mathematica 6 (I have seen such a plots in scientific > papers but maybe done with some other application). > The second question is is there a possibility to make breaks in axes. > What I mean is that I have a plot with let say X domain [0,50], but I > am only interested in two parts of it, say [0,10] and [40,50], so is > it possible to set a kind of an option in Plot command? Such a trick > is also quite common in scientific papers with characteristic on > axis in a place where the break is made (I know for example how to > do it in Origin and there is quite an easy task). > I have been searching for the staff quite long and haven't found any > solution yet so I would be really grateful if someone would help me > with the issue. > Kazik > === Subject: Re: Apparent error integrating product of DiracDelta's How do I get: > Integrate[DiracDelta[z- x] DiracDelta[z- y], {z-Infinity, Infinity}= ] > to give DiracDelta[x-y] as the result? Currently it gives 0. I ha= ve all three variable assumed to be Reals. I am using 6.0.0. > Michael Mandelberg I think you have synatx error in the limit part. I assume you mean to wri= te > {z, -Infinity,Infinity} Given that, I think zero is the correct answer. When you multiply 2 de= ltas > at different positions, you get zero. Integral of zero is zero. Nasser However, I disagree with your conclusion. Who says 'x' and 'y' are different? === Subject: Re: Apparent error integrating product of DiracDelta's How do I get: > Integrate[DiracDelta[z- x] DiracDelta[z- y], {z-Infinity, Infinity}= ] > to give DiracDelta[x-y] as the result? Currently it gives 0. I ha= ve all three variable assumed to be Reals. I am using 6.0.0. > Michael Mandelberg I think you have synatx error in the limit part. I assume you mean to wri= te > {z, -Infinity,Infinity} Given that, I think zero is the correct answer. When you multiply 2 de= ltas > at different positions, you get zero. Integral of zero is zero. Nasser No Nasser, the correct value of the integral should be DiracDelta[x- y], as Michael said. This value is indeed 0 if x != y but it is not 0 if x==y. Mathematica correctly calculates: Integrate[f[z - x] DiracDelta[z - y], {z, -Infinity, Infinity}, Assumptions -> y [Element] Reals] as f[-x + y] However it fails to recognize that if f[z-x] is replaced by DiracDelta[z-x], the result should be DiracDelta[-x + y] or the equivalent DiracDelta[x - y] In the help file, under possible issues it is mentioned that Products of distributions with coinciding singular support cannot be defined: So perhaps at the moment the only way to do the integral is: Integrate[f[z - x] DiracDelta[z - y], {z, -Infinity, Infinity}, Assumptions -> y [Element] Reals] /. f -> DiracDelta hth === Subject: imagesize to full width of current screen greetings, i'm trying to determine the current width of the notebook screen to size graphics and manipulate's to fit the whole width of the window. i've looked at PageWidth, ImageSize->All, ImageSize->Full, ImageSize- >Large, ImageSize->Scaled[s] (ImageSize->Scaled@1 is equivalent to ImageSize->Full), $* variables, ... this is a common feature in other programming languages (javascript in web browsers for example). i've also searched this mailing list without success. any ideas? Mitch === Subject: Re: imagesize to full width of current screen Hi Mitch, the magic word is: FullScreenArea/.SystemInformation[Devices,ScreenInformation] hope this helps, Daniel > greetings, i'm trying to determine the current width of the notebook screen to > size graphics and manipulate's to fit the whole width of the window. > i've looked at PageWidth, ImageSize->All, ImageSize->Full, ImageSize- > >Large, ImageSize->Scaled[s] (ImageSize->Scaled@1 is equivalent to > ImageSize->Full), $* variables, ... this is a common feature in other programming languages (javascript in > web browsers for example). i've also searched this mailing list > without success. any ideas? Mitch > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: imagesize to full width of current screen > greetings, i'm trying to determine the current width of the notebook screen to > size graphics and manipulate's to fit the whole width of the window. > i've looked at PageWidth, ImageSize->All, ImageSize->Full, ImageSize- > >Large, ImageSize->Scaled[s] (ImageSize->Scaled@1 is equivalent to > ImageSize->Full), $* variables, ... this is a common feature in other programming languages (javascript in > web browsers for example). i've also searched this mailing list > without success. any ideas? Mitch the information is in the WindowSize option of the corresponding notebook object. This will give you the size of the notebook that evaluates it: WindowSize /. Options[EvaluationNotebook[]] when working with manipulates and palettes you also might want to use ButtonNotebook[] , SelectedNotebook[] and Notebooks[] to get a handle at the notebook you are after. Just in case: You can also get the size of the screen with: ScreenRectangle /. Options[$FrontEnd] which then lets you choose a reasonable size for a new notebook/window. hth, albert === Subject: Re: Advanced plotting >two different scales on vertical axis- one scale on the left one and >the other on the right one (with a horizontal axis being common for >both the vertical ones). Yes, this is possible and has been answered several times before here. >The second question is is there a possibility to make >breaks in axes. What I mean is that I have a plot with let say X >domain [0,50], but I am only interested in two parts of it, say >[0,10] and [40,50], so is it possible to set a kind of an option in >Plot command? Yes, here is one way to do what you've outlined above. Plot[-1, {x, 0, 5}, PlotRange -> {0, 50}, Axes -> None, Epilog -> {Inset[ Plot[45 - 20 ( x - 2)^2 + x, {x, 0, 5}, PlotRange -> {40, 50}, Frame -> {False, True, True, True}, AspectRatio -> 1/5], Scaled@{.06, .5}, {0, 40}, 5], Inset[Plot[45 - 20 ( x - 2)^2 + x, {x, 0, 5}, PlotRange -> {0, 10}, Frame -> {True, True, False, True}, AspectRatio -> 1/5], Scaled@{.06, .1}, {0, 0}, 5]}] Note the same usage of Inset can create a second y-axis. That is modifying this somewhat your first question could be answered by replacing the Plot[-1 ... part with one function using Frame->{True,True,True,False} then using Inset to plot the other function with Frame->{False,False,False,True}. But this approach is more complex than previous suggestions for creating a second y-axis. The simplest way I can think of to create a second y-axis would be to use FrameTicks to specify a custom axis on the right side, i.e., FrameTicks->{Automatic,Automatic,None, customList} === Subject: Re: how to test where a list contains constant(s) or not >case1: { a, b, c, Pi } gives true because of Pi >case2: { a, b, c, 0.0001} gives true because of 0.0001 >case3: { a, b, c, 2 + Pi I } gives ture becase of 2 + Pi I >case4: { a, b, c} gives false >is this function right ? >ComplexQ[z_] := NumericQ[ z ] || ( NumericQ[ z ] && SameQ[ Head[ z ], >Complex] ) >IsConstantsIn[ lstList_ ] := >Module[ { intLength }, >intLength = Length@Select[ lstList, ComplexQ[ # ]& ]; >If[ intLength > 0, Return[ True ], Return[ False ] ]; >Return[ False ]; >] > Your function looks overly complex. If I understand correctly what you want to do then constantQ[x_List] := Or @@ (NumericQ /@ x) should work. Using this on your test cases gives In[58]:= constantQ@{a, b, c, Pi} constantQ@{a, b, c, 0.0001} constantQ@{a, b, c, 2 + Pi I} constantQ@{a, b, c} Out[58]= True Out[59]= True Out[60]= True Out[61]= False === Subject: Re: how to test where a list contains constant(s) or not Hi Aya, a complex number is numeric, therefore you only need to test for NumericQ. E.g.: MemberQ[yourList, _?NumericQ] However, there seems to be a problem with what you consider a constant. As Mathematica evaluates the arguments of functions, the following gives True: a=1; MemberQ[{a}, _?NumericQ] Is this what you want??? hope this helps, Daniel > case1: { a, b, c, Pi } gives true because of Pi > case2: { a, b, c, 0.0001} gives true because of 0.0001 > case3: { a, b, c, 2 + Pi I } gives ture becase of 2 + Pi I > case4: { a, b, c} gives false is this function right ? ComplexQ[z_] := NumericQ[ z ] || ( NumericQ[ z ] && SameQ[ Head[ z ], > Complex] ) > IsConstantsIn[ lstList_ ] := > Module[ { intLength }, > intLength = Length@Select[ lstList, ComplexQ[ # ]& ]; > If[ intLength > 0, Return[ True ], Return[ False ] ]; > Return[ False ]; > ] > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: how to test where a list contains constant(s) or not > case1: { a, b, c, Pi } gives true because of Pi > case2: { a, b, c, 0.0001} gives true because of 0.0001 > case3: { a, b, c, 2 + Pi I } gives ture becase of 2 + Pi I > case4: { a, b, c} gives false is this function right ? ComplexQ[z_] := NumericQ[ z ] || ( NumericQ[ z ] && SameQ[ Head[ z ], > Complex] ) > IsConstantsIn[ lstList_ ] := > Module[ { intLength }, > intLength = Length@Select[ lstList, ComplexQ[ # ]& ]; > If[ intLength > 0, Return[ True ], Return[ False ] ]; > Return[ False ]; > ] > As written above, the predicate ComplexQ is equivalent to NumericQ. So you could write your function directly as follows: In[1]:= IsConstantsIn[lstList_] := If[Length@Select[lstList, NumericQ[#] &] > 0, True, False] (* Now, is this what you are looking for? I do no know. You should describe precisely what you intent to do. *) case = {{a, b, c, Pi}, {a, b, c, 0.0001}, {a, b, c, 2 + Pi I}, {a, b, c}}; IsConstantsIn /@ case Out[3]= {True, True, True, False} In[4]:= NumericQ /@ case[[4]] Out[4]= {False, False, False} In[5]:= Head /@ case[[4]] Out[5]= {Symbol, Symbol, Symbol} -- Jean-Marc === Subject: Re: how to test where a list contains constant(s) or not > case1: { a, b, c, Pi } gives true because of Pi > case2: { a, b, c, 0.0001} gives true because of 0.0001 > case3: { a, b, c, 2 + Pi I } gives ture becase of 2 + Pi I > case4: { a, b, c} gives false is this function right ? ComplexQ[z_] := NumericQ[ z ] || ( NumericQ[ z ] && SameQ[ Head[ z ], > Complex] ) > IsConstantsIn[ lstList_ ] := > Module[ { intLength }, > intLength = Length@Select[ lstList, ComplexQ[ # ]& ]; > If[ intLength > 0, Return[ True ], Return[ False ] ]; > Return[ False ]; > ] It probably does what you want, but I think it is way too complicated. Note that Complex numbers are Numeric by default, so there is no need for your ComplexQ-definition. If you think about seriously using Mathematica you should get familiar with its pattern matcher, otherwise you are missing its strongest part :-). If I correctly understood what you are after, the following leaves all the work for mathematica: IsConstantsIn[{___, _?NumericQ, ___}] := True IsConstantsIn[___] := False the first definition gives True, if the argument to IsConstantsIn is a list containing at least one numeric element at any position. The second definition ensures that IsConstantsIn will return False in any other case. To handle other cases, e.g. expressions that are not lists you can easily extend by adding additional definitions. Finally I think the name of your function could probably changed to reflect more clearly what exactly it is doing, e.g. IsNumericIn or HasNumericElement. Mathematica has the posibility to define attributes to symbols, among these attributes is Constant, so IsCOnstantsIn would mislead me in thinking it has something to do with that... hth, albert === Subject: Re: how to test where a list contains constant(s) or not > case1: { a, b, c, Pi } gives true because of Pi > case2: { a, b, c, 0.0001} gives true because of 0.0001 > case3: { a, b, c, 2 + Pi I } gives ture becase of 2 + Pi I > case4: { a, b, c} gives false is this function right ? > Most of what you've written is completely redundant. > ComplexQ[z_] := NumericQ[ z ] || ( NumericQ[ z ] && SameQ[ Head[ z ], > Complex] ) This ComplexQ function is completely equivalent to NumericQ. p || (p && q) is just p, right? > IsConstantsIn[ lstList_ ] := > Module[ { intLength }, > intLength = Length@Select[ lstList, ComplexQ[ # ]& ]; One could just use ComplexQ instead of ComplexQ[#]&. > If[ intLength > 0, Return[ True ], Return[ False ] ]; > Return[ False ]; > ] > You almost never need to use Return in Mathematica. The above two lines are equivalent to the simple expression intLength > 0 in this context. With all these simplifications your function becomes f[lst_List] := Length@Select[lst, NumericQ] > 0 But the following approach is simpler and more efficient: g[lst_List] := MemberQ[lst, _?NumericQ] === Subject: Re: how to test where a list contains constant(s) or not ?? Jens > case1: { a, b, c, Pi } gives true because of Pi > case2: { a, b, c, 0.0001} gives true because of 0.0001 > case3: { a, b, c, 2 + Pi I } gives ture becase of 2 + Pi I > case4: { a, b, c} gives false is this function right ? ComplexQ[z_] := NumericQ[ z ] || ( NumericQ[ z ] && SameQ[ Head[ z ], > Complex] ) > IsConstantsIn[ lstList_ ] := > Module[ { intLength }, > intLength = Length@Select[ lstList, ComplexQ[ # ]& ]; > If[ intLength > 0, Return[ True ], Return[ False ] ]; > Return[ False ]; > ] > === Subject: Re: A interesting case Hi Miguel, I think Mathematica chooses what it considers the simplest form for an expression. By default the complexity of an expression is judged according to LeafCount, thta is how many leaves there are if the expression is written as tree (by e.g. TreeForm). Now try: LeafCount/@{a^(-2),2/a^2,3/a^2} TreeForm/@{a^(-2),2/a^2,3/a^2} and you will see that a^(-2) has less leaves than 1/a^2 hope this helps, Daniel > I have spent work hours with this case. ToString[#,InputForm]&/@{1/a^2,2/a^2,3/a^2} > {a^(-2),2/a^2,3/a^2} When the numerator of a rational element is 1, the structure string is > diferent. Why? > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: A interesting case because 1/a^n is Power[a,-n] and k/a^n is Times[k,Power[a,-n]] it would be nonsense to store Times[1,Power[a,-n]] in the first case and Times[1,q__] simplify to Times[q] Jens > I have spent work hours with this case. ToString[#,InputForm]&/@{1/a^2,2/a^2,3/a^2} > {a^(-2),2/a^2,3/a^2} When the numerator of a rational element is 1, the structure string is > diferent. Why? > === Subject: Functional Programming? John Gray's book Mastering Mathematica has a a chapter on functional programming in Mathematica. For more on fp techniques in the context of longer programs see http://book.realworldhaskell.org/ where there is a preliminary copy of a book, Real World Haskell to be published soon by O'Reilly. Many tutorials and books are to be found at www.haskell.org which can be ordered from http://www.ffconsultancy.com/products/index.html Also at your local bookstore is Harrop's book, F# for Scientists. (I saw a copy at Borders yesterday) F# is Microsoft's adaptation of the ML family of functional programming languages. And I would be remiss if I didn't mention the bible of computer science, Abelson and Sussman, Structure and Interpretation of Computer Programs from the MIT press. This book is to computers what the Feynman Lectures are to physics, and anybody who programs should read it three or four times in their lives. This book is written in the context of the functional programming language Scheme, a dialect of Lisp. Free downloadable videos of the corresponding course are available from the MIT web site. I just watched them this year. BTW, I have been programming for 45 years, so being an old guy shouldn't stop you. It just means that the world offers so many new and intreresting things to learn about as we go along. For example I am learning that the structure of haskell has a number of tie-ins with abstract mathematics such as category theory, and this is rather what I naively imagined computer programming would be like before I took my first computer course in 1963. --Bert Mayo === Subject: Solving algebraic equations with some conditions I am trying to solve a system of 3 PDEs using a Fourier ansatz: nL[x_, t_] = Sum[cn[p, l] Exp[I (p k x + l [Omega] t)], {p, -1, 1}, {l, -1, 1}]; EscL[x_, t_] = Sum[cE[p, l] Exp[I (p k x + l [Omega] t)], {p, -1, 1}, {l, -1, 1}]; iL[t_] = Sum[ci[l] Exp[I l [Omega] t], {l, -1, 1}]; So I have a system of up to 55 algebraic equations (Not every Exp[I (p k x + l [Omega] t)] occures after inserting the ansatz, thus some will be trivial) for the 55 Fourier coefficient. The equations are not linear, but linear in every coefficient. I was told that this would take some time but should be possible. Additionally, I know that the functions are all real, thus I get more equations: K[p,l]=Conjugate[K[p,l]] Unfortunately, I have the impression that Mathematica cannot handle these in Solve[], as simple examples produce things like Conjugate^-1[I]. A possibility I considered is constructing the coefficients with real and imaginary part: iL[t_] = Sum[(ci[l, re] + ci[l, im] I) Exp[I l [Omega] t], {l, -1, 1}]; Then I had to give Mathematica assumtions that these are all real so that an expression like -H Wges+(I cn[0,0,im]+cn[0,0,re])/[Tau]==0 will be correktly solved to {cn[0,0,im] -> 0, cn[0,0,re]->[Tau] H Wges} (also assuming that [Tau], H, Wges are real) I am not sure how to achieve that. Indeed I have another condition for the coefficients: K[p,l][[omega]]=K[p,-l]][-[omega]] In this case, I have completely no idea how to model this in Mathematica. Can anybody give me a hint (on the problem or on literature) how to solve this problem? Kay-Michael Voit === Subject: Re: Solving algebraic equations with some conditions > So I have a system of up to 55 algebraic equations (Not every Exp[I (p k > x + l [Omega] t)] occures after inserting the ansatz, thus some will be > trivial) for the 55 Fourier coefficient. The equations are not linear, Sorry, there are obviously only 21 Fourier coefficients to calculate according to the ansatz. I messed it up. === Subject: Re: eliminate values while caculating Mean[data] data = {1, 2, 3, 4, 5, 0, 0, 0}; {Mean[data] , Mean[data /. 0 :> Sequence[]]} ?? Jens An easy question: > I would like to make an average of a data file.I know that we can use > Mean function for this. However, I want to eliminate some values from my data.For example if I have data={1,2,3,4,5,0,0,0} > Mean[data] would be 15/8 I do not want the zero values in my Mean function (i.e.I want the mean > value to be 3 in the above example) How can I do this? Best, > Pasha === Subject: Re: eliminate values while caculating Mean[data] > Hello Pasha, > I would generally recommend you to write your own functions, it's more > customizable:) The name of your set of data is Data and looks like in your post, > say: Data={1,2,3,4,5}; Value of Summ gives you a sum of all non-zero > elements in Data and NonZeroValuesCounter gives you a number of > non-zero entries in Data. Average is what you want. Just paste the > script below into Mathematica and run: Summ = 0; NonZeroValuesCounter = 0; > For[index = 1, index <= Length[Data], index += 1, > If[Data[[index]] != 0, Summ += Data[[index]]; > NonZeroValuesCounter += 1]; > ]; > Average = Summ/NonZeroValuesCounter; > Print[Summ: , Summ, > NonZeroValuesCounter: , NonZeroValuesCounter, > Average: , Average] Even if you insist in doing things that way, you can do them more Mathematica-ly: For example, myMean[ll_] := Module[{n = 0, s = 0}, Scan[If[# > 0, s += #; n += 1] &, ll]; s/n ]; -- m === Subject: Re: eliminate values while caculating Mean[data] try Mean[Select[data, ! PossibleZeroQ[#] &]] Best, Markus === Subject: Re: eliminate values while caculating Mean[data] Hi Do some list opetations: Mean[DeleteCases[data, 0]] By this 0 is taken away when you make the average. gyzhou === Subject: Re: eliminate values while caculating Mean[data] An easy question: > I would like to make an average of a data file.I know that we can use > Mean function for this. However, I want to eliminate some values from my data.For example if I have data={1,2,3,4,5,0,0,0} > Mean[data] would be 15/8 I do not want the zero values in my Mean function (i.e.I want the mean > value to be 3 in the above example) How can I do this? Best, > Pasha > Mean[DeleteCases[data,0]] Gruss Peter -- ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: Regressions in Mathematica Needs[LinearRegression`] tdata = Append[#, Times @@ #] & /@ Table[RandomReal[], {10}, {2}]; Regress[tdata, {1, x, y, x*y}, {x, y}] ?? Jens > Hello everyone, I'm having trouble understanding the syntax of the Regress command. > If data is an nx2 matrix where the first column is the explanatory > variable and the second is the dependent variable, then either Regress[data, {1, x}, x] or Regress[data, x, x] performs a standard regression of the second column on the first with > a constant thrown in. But how do I write the command for the case of > more than one explanatory variable? Say that my data matrix is now > nx3, so that the first two columns are the explanatory variables and > the last is the dependent variable. Regress[data, {x,x}, x] or Regress[data, {1, x,x}, x] gives the error > message Number of coordinates (2) is not equal to the number of > variables (1). I'm not sure how I'm supposed to identify each > explanatory variable. > Gregory > === Subject: Graphics Issue MacBook Pro & Mathematica 6.0.1.0 I'm running Mathematica 6.0.1.0 on a MacBook Pro (Intel processor) and OS 10.4.11. I am unable to get it to display graphics, e.g., Plot[]. When I load it on a G5 Mac same OS, everything works fine. Has anyone experienced this issue? === Subject: shooting method Using a shooting method, I would like to find the smallest eigenvalue of -y''[x] + 400((1/x)^12 - (1/x)^6) y[x] == E0*y[x] (the quantum-mechanical steady state energy of an anharmonic oscillator with Lennard-Jones potential) with the boundary conditions : y[A]==0 y[B]==0 with A<<1 and B >> 1 Can anyone help about how to implement it ? Luca === Subject: Re: shooting method Hi Luca, there lurk some numerical problems. First note that the equation is homogeneous, the function is only determined up to a constant factor. We may therefore choose the starting slope as we please. As the Potential goes to infinity near zero the function becomes very small there. It is therefore numerical difficult to start the integration there. It is much less problematic to start the integration at the node and integrate towards zero. We therefore set fun[B]==0 and arbitrarily fun'[B]==1. And we take care not to set A too far inside the classical forbidden region, because this is calling for troubles. Here is an example: A=3/4;B=3/2; slope=-1; fun0[E0_]:=Module[{y,x,eq}, eq={-y''[x]+400((1/x)^12-(1/x)^6) y[x]-E0*y[x] ==0, y[B]==0,y' [B]==slope}; y/.NDSolve[eq,y,{x,A,B}][[1]]] fun[E0_?NumericQ]:=fun0[E0][A]; res=FindRoot[fun[E0],{E0,-50}] fun[E0]/.res Plot[fun0[E0/.res][x],{x,A,B}] hope this helps, Daniel Using a shooting method, I would like to find the smallest eigenvalue of -y''[x] + 400((1/x)^12 - (1/x)^6) y[x] == E0*y[x] (the quantum-mechanical steady state energy of an anharmonic oscillator with Lennard-Jones potential) > with the boundary conditions : > y[A]==0 > y[B]==0 > with A<<1 and B >> 1 > Can anyone help about how to implement it ? > Luca > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: Debugger Hi David, I used your M-Debug for a while with Mathematica 5.x and it was a real pleasure. Easy and well documented. Unfortunately it does not seem to work any longer in Mathematica 6.0 (I tried a couple of times). Would it be possible for you to update it and make it usable with the 6th generation ? I think many Mathematica users would appreciate it. === Subject: integration - Interpolating Function I have two different problems concerning Mathematica: First: to calculate a characteristic function [CurlyPhi][u_] for each u I have to evaluate a solution of a system of ordinary differential equations depending on u: solution[u_] := NDSolve[ {z1'[t] == -[Kappa] [Theta]y y1[ t] - (ly [Mu] (y1[ t] - [Mu] y1[t]^2 - [Mu] y2[t]^2))/((1 - [Mu] y1[ t])^2 + [Mu]^2 y2[t]^2), z2'[t] == -[Kappa] [Theta]y y2[ t] - (ly [Mu] y2[ t])/((1 - [Mu] y1[t])^2 + [Mu]^2 y2[t]^2), y1'[t] == [Kappa] y1[t] - ([Sigma]^2)/2 (y1[t]^2 - y2[t]^2), y2'[t] == [Kappa] y2[t] - [Sigma]^2 y1[t] y2[t] - u, z1[T] == 0, z2[T] == 0, y1[T] == 0, y2[T] == 0}, {z1, z2, y1, y2}, {t, 0, T}] a1[u_] := z1[0] /. solution[u][[1, 1]] a2[u_] := z2[0] /. solution[u][[1, 2]] b1[u_] := y1[0] /. solution[u][[1, 3]] b2[u_] := y2[0] /. solution[u][[1, 4]] [CurlyPhi][u_] := E^(a1[u] + I a2[u] + b1[u] + I b2[u] x0) as a result I get a set of Interpolating Functions, so I can evaluate the characteristic functions in specific points u. Next I have to integrate over this characteristic function: Needs[FourierSeries`]; f[z_]:=NInverseFourierTransform[[CurlyPhi][u_] , u,z,FourierParameters=84_{1,1}] but Mathematica cannot solve this problem. Does anybody know an answer or a way to fix this problem? Second: Can anybody give me advice, how to implement efficiently a recursion, that depends on two variables? (Does Mathematica have another function besides RSolve which solves this kind of problems?) I would be really grateful if someone could help me. Marion === Subject: Using Mathematica with GSL Any there any glue libraries available that implements Glue code, to evaluate C expressions exported by the Mathematica Splice command, in terms of functions provided by the GNU Scientific library (GSL). === Subject: How to separate a sum into terms Hi! I want to separate a Mathematica expression written as a sum into separate terms E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? -- Vyacheslav Rychkov https://mail.sns.it/~rychkov Scuola Normale Superiore Tel: +39-050-509068 (office) Classe di Scienze +39-050-3820086 (home) Piazza dei Cavalieri, 7 +39-3403925168 (mobile) 56100 Pisa Fax: +39-050-509045 Italy E-mail: Rychkov@sns.it === Subject: Out[xx] included when saving figures? I recently upgraded to Mathematica v.6, and am encountering a problem. In the session, if I click on the sidebar of a figure generated by GraphicsGrid, and choose save selection as from the menu, then the Out[xx]= in front of the figure is also saved. If instead I click on the figure directly, the save selection as option is grayed out. Is there anyway I could save the figure without being bothered by this Out[xx]=? If I quite the session and restart Mathematica, without doing any cell calculations, then there is not any Out[xx]= (and In[xx]=) so I could save the figure without the need of any post-processing. JT === Subject: Re: Functional programming? > I feel there is another thing to say regarding FP. The fact that FP > performs so well in Mathematica is, in my opinion, something of a > fluke. > The real reason is that because Mathematica is such a high level > language, absolutely every step incurs considerable overhead, that is > not present in languages such as Fortran or Java. Because FP > provides a > way to do a lot in one step, it reduces this overhead. I don't think it is a fluke, but simply a consequence of the fact that Mathematica is or originated as a Computer Algebra System, and there is no doubt that functional programming is the most efficient and natural way to program in a CAS. I don't think there is any point even arguing about this so I just note that the first (at least I think it is the first) genuine CAS system did not even have its own programing language but used LISP (the paradigm of all functional languages), and one of Mathematica's main rivals, which uses a procedural programming language (in my opinion a pretty awful one), had functional constructs belatedly added to it. Andrzej Kozlowski === Subject: Re: Functional programming? I found this excellent resource by Jose Gomez-Munoz below: Peter ---------- Forwarded message ---------- === A small tutorial for going from procedural to functional programming in Mathematica: http://homepage.cem.itesm.mx/lgomez/matecmatica/funcionalprog.nb Here is an html version http://homepage.cem.itesm.mx/lgomez/matecmatica/fp/fp.html I hope is useful Jose Mexico 2008/9/13 AES : > I suggest it might be instructive if some of the functional programming > proponents on this group could provide us DO-looping old timers with a > brief summary or tutorial as to what is really meant by, or involved in, > functional programming? --- especially as this concept might relate to building programs to do > calculations involving multi-stage real-world engineering or technical > problems --- and especially as it might relate to programs that are going to be > developed in an evolutionary process and that in the end, rather than > being built into some long-term library, are maybe only going to be run > or executed a few times before the person involved (e.g., an engineer, > or scientist, or other real-world individual, not a programmer) moves > on to some other totally different task or assignment. -- === Subject: Re: Functional programming? > as an old-timer myself - I'd be very interested in this too, > particularly - as you say - with reference to engineering problems. > I'm afraid my favorite construct was the REPEAT - UNTIL loop, which > should finally ruin any shreds of credibility that I may once have > had... I think it is possible to frighten people off with functional programming. It is true that simple examples of FP can be much shorter than their procedural equivalent, and will almost certainly run much faster, but FP can become very messy for some real world problems, and procedural programming offers a way to 'hack' almost anything. I am tempted to give an example of something that is hard to do by FP, but someone will, of course, provide an answer - but that is not the point, the point is whether users with limited experience of Mathematica would be able to come up with such a solution. There are quite a few While loops in my Super Widget Package! I feel there is another thing to say regarding FP. The fact that FP performs so well in Mathematica is, in my opinion, something of a fluke. The real reason is that because Mathematica is such a high level language, absolutely every step incurs considerable overhead, that is not present in languages such as Fortran or Java. Because FP provides a way to do a lot in one step, it reduces this overhead. Thus, for example, whole array operations (which are somewhat analogous to FP) in Fortran perform little if any better than explicit DO-loops, and re-coding a Fortran application to use whole array operations may reduce its performance because the cache utilisation can suffer. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Functional programming? > as an old-timer myself - I'd be very interested in this too, > particularly - as you say - with reference to engineering problems. > I'm afraid my favorite construct was the REPEAT - UNTIL loop, which > should finally ruin any shreds of credibility that I may once have > had... > Peter 2008/9/13 AES : >> I suggest it might be instructive if some of the functional programming >> proponents on this group could provide us DO-looping old timers with a >> brief summary or tutorial as to what is really meant by, or involved in, >> functional programming? >> --- especially as this concept might relate to building programs to do >> calculations involving multi-stage real-world engineering or technical >> problems >> --- and especially as it might relate to programs that are going to be >> developed in an evolutionary process and that in the end, rather than >> being built into some long-term library, are maybe only going to be run >> or executed a few times before the person involved (e.g., an engineer, >> or scientist, or other real-world individual, not a programmer) moves >> on to some other totally different task or assignment. Say we want to compute the mean (average) of all non-zero values for each row of a two dimensional array. The code must not crash when fed with data of incorrect format as well as it must handle nicely such things like divisions by zero. (* Functional / Pattern matching code *) myMean2[array_?VectorQ] := Mean[Select[array, # != 0 &]] myMean2[array_?MatrixQ] := Map[myMean2, array] (* Procedural code *) myMean1[array_] := Module[{iter, len, cnt, sum, mean}, sum = 0; mean = 0; cnt = 0; len = Length[array]; If[len != 0, For[iter = 1, iter <= len, iter = iter + 1, If[array[[iter]] != 0, sum = sum + array[[iter]]; cnt = cnt + 1]; ]; If[cnt != 0, mean = sum/cnt; , mean = NA; ]; , mean = NA; ]; Return[mean] ] meanArray[array_] := Module[{res, len, dim}, res = {}; len = Length[array]; dim = Depth[array] - 1; If[dim != 2, Return[NA]]; For[iter = 1, iter <= len, iter = iter + 1, AppendTo[res, myMean1[array[[iter]]] ]; ]; Return[res] ] (* Some data and some tests *) data = {{}, {1, 2, 3, 4, 5, 0, 0, 0}, {0, 0, 0}, {1, 2, -10, 3, 4}, {a, b, c}}; meanArray[{1, 2, 3, 4, 5, 0, 0, 0}] meanArray[{{1, 2, 3, 4, 5, 0, 0, 0}}] meanArray[data] meanArray[{{{1, 2, 3, 4}, {5, 0, 0, 0}}}] (* Out[6]= NA Out[7]= {3} Out[8]= {NA, 3, NA, 0, NA} Out[9]= NA *) myMean2[{1, 2, 3, 4, 5, 0, 0, 0}] myMean2[{{1, 2, 3, 4, 5, 0, 0, 0}}] Map[myMean2, data] Map[myMean2, {{{1, 2, 3, 4}, {5, 0, 0, 0}}}] (* Out[10]= 3 Out[11]= {3} Out[12]= {Mean[{}], 3, Mean[{}], 0, Mean[{}]} Out[13]= {{5/2, 5}} *) -- Jean-Marc === Subject: Re: Functional programming? > >> as an old-timer myself - I'd be very interested in this too, >> particularly - as you say - with reference to engineering problems. >> I'm afraid my favorite construct was the REPEAT - UNTIL loop, which >> should finally ruin any shreds of credibility that I may once have >> had... >> Peter >> 2008/9/13 AES : > I suggest it might be instructive if some of the functional programming > proponents on this group could provide us DO-looping old timers with a > brief summary or tutorial as to what is really meant by, or involved in, > functional programming? >> --- especially as this concept might relate to building programs to do > calculations involving multi-stage real-world engineering or technical > problems >> --- and especially as it might relate to programs that are going to be > developed in an evolutionary process and that in the end, rather than > being built into some long-term library, are maybe only going to be run > or executed a few times before the person involved (e.g., an engineer, > or scientist, or other real-world individual, not a programmer) moves > on to some other totally different task or assignment. > Say we want to compute the mean (average) of all non-zero values for > each row of a two dimensional array. The code must not crash when fed > with data of incorrect format as well as it must handle nicely such > things like divisions by zero. (* Functional / Pattern matching code *) myMean2[array_?VectorQ] := Mean[Select[array, # != 0 &]] > myMean2[array_?MatrixQ] := Map[myMean2, array] > (* Procedural code *) myMean1[array_] := > Module[{iter, len, cnt, sum, mean}, > sum = 0; > mean = 0; > cnt = 0; > len = Length[array]; > If[len != 0, > For[iter = 1, iter <= len, iter = iter + 1, > If[array[[iter]] != 0, sum = sum + array[[iter]]; cnt = cnt + 1]; > ]; > If[cnt != 0, > mean = sum/cnt; > , mean = NA; > ]; > , mean = NA; > ]; > Return[mean] > ] meanArray[array_] := > Module[{res, len, dim}, > res = {}; > len = Length[array]; > dim = Depth[array] - 1; > If[dim != 2, > Return[NA]]; > For[iter = 1, iter <= len, iter = iter + 1, > AppendTo[res, myMean1[array[[iter]]] > ]; > ]; > Return[res] > ] > (* Some data and some tests *) data = {{}, {1, 2, 3, 4, 5, 0, 0, 0}, {0, 0, 0}, {1, 2, -10, > 3, 4}, {a, b, c}}; meanArray[{1, 2, 3, 4, 5, 0, 0, 0}] > meanArray[{{1, 2, 3, 4, 5, 0, 0, 0}}] > meanArray[data] > meanArray[{{{1, 2, 3, 4}, {5, 0, 0, 0}}}] (* > Out[6]= NA Out[7]= {3} Out[8]= {NA, 3, NA, 0, NA} Out[9]= NA > *) myMean2[{1, 2, 3, 4, 5, 0, 0, 0}] > myMean2[{{1, 2, 3, 4, 5, 0, 0, 0}}] > Map[myMean2, data] > Map[myMean2, {{{1, 2, 3, 4}, {5, 0, 0, 0}}}] (* > Out[10]= 3 Out[11]= {3} Out[12]= {Mean[{}], 3, Mean[{}], 0, Mean[{}]} Out[13]= {{5/2, 5}} > *) I think you have chosen a rather favourable example here. Suppose instead that you need to remove every zero together with the preceding element (sweeping from left to right). Realistically, you also probably want to do something, rather than output Mean[{}] for myMean2[{0,0,0}]. I would say that users should not be scared away from using procedural code when faced with ad hoc problems of this sort. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: bug... GraphicsGrid ItemAspectRatio Spacings FYI for poor souls that might encounter that same problem i just did. if you use ItemAspectRatio option for GraphicsGrid, you also need to specify the Spacings option. GraphicsGrid[{{foo}, {Graphics@Rectangle[]}}, Frame -> All, ItemAspectRatio -> {.1, 1}] gives errors ... Coordinate {189., {-19.2, -19.2}} should be a pair of numbers, or a Scaled or Offset form. Coordinate {360., {35.99999999999999, 14.399999999999999`}} should be a pair of numbers, or a Scaled or Offset form. Coordinate {189., {-230.4, -230.39999999999998`}} should be a pair of numbers, or a Scaled or Offset form. Coordinate {360., {381.59999999999997`, 360.}} should be a pair of numbers, or a Scaled or Offset form. GraphicsGrid[{{foo}, {Graphics@Rectangle[]}}, Frame -> All, ItemAspectRatio -> {.1, 1}, Spacings -> 2] ... works OK. cheers, Mitch === Subject: Re: data source for demonstration Sir, I went to this site and downloaded a .nbp file. Mathematica loads this file but there's nothing in it. I searched documentation for .nbp files and found nothing. Can > See this Demonstration for a way to use Compress[] http://demonstrations.wolfram.com/PrecessionOfTheEquinoxes/ -Jeff Bryant > Wolfram Research, Inc. > >> I would like to create a demonstration that does analysis on a dataset >> that is too large to fit into a notebook. What is the best way (or any >> way) to bundle data with a demonstration? Import[url, ...]? >> The examples on the Demonstrations site that I could find either had >> the data in the notebook or used something like CountryData or other >> data paclet that I guess also comes with Mathematica Player. > === Subject: Re: Apparent error integrating product of DiracDelta's > How do I get: > Integrate[DiracDelta[z- x] DiracDelta[z- y], {z-Infinity, Infinity}= > ] > to give DiracDelta[x-y] as the result? Currently it gives 0. I ha= > ve > all three variable assumed to be Reals. I am using 6.0.0. > Michael Mandelberg >> I think you have synatx error in the limit part. I assume you mean to wri= > te >> {z, -Infinity,Infinity} >> Given that, I think zero is the correct answer. When you multiply 2 de= > ltas >> at different positions, you get zero. Integral of zero is zero. >> Nasser No Nasser, the correct value of the integral should be DiracDelta[x- > y], as Michael said. > This value is indeed 0 if x != y but it is not 0 if x==y. It is not 0 at x==y, but neither is it DiracDelta[x-y]. The value there is undefined. > Mathematica correctly calculates: Integrate[f[z - x] DiracDelta[z - y], {z, -Infinity, Infinity}, > Assumptions -> y [Element] Reals] as f[-x + y] This is making a tacit assumption that f is a nice function. Nice, in this context, means it is an element of Schwartz space S: C^infinity and vanishing faster than any polynomial at +-infinity. DiracDelta, suffice it to say, is not an element of S (it's not even a function). > However it fails to recognize that if f[z-x] is replaced by > DiracDelta[z-x], the result should be DiracDelta[-x + y] or the equivalent DiracDelta[x - y] This is not a failure but rather an active intervention. > In the help file, under possible issues it is mentioned that > Products of distributions with coinciding singular support cannot be > defined: This is a statement of mathematics and not specific to Mathematica. > So perhaps at the moment the only way to do the integral is: Integrate[f[z - x] DiracDelta[z - y], {z, -Infinity, Infinity}, > Assumptions -> y [Element] Reals] /. f -> DiracDelta hth Here is a general rule of thumb. If you are working with DiracDelta function(al)s, instead approximate them as ordinary functions. If different methods of approximation will lead to different results, then what you have cannot be defined. One can use this notion to see that, for example, DiracDelta[x]^2 is not defined. Daniel Lichtblau Wolfram Research === Subject: blurry ellipse NB: This is a mathematical problem, not necessarily a Mathematica problem. I need a rasterized, blurry ellipse, i.e. an ellipse convolved with a Gaussian. I already know how to make a blurry circle. You take the Fourier transform of a circle (i.e. a Bessel function), the Fourier transform of a Guassian, multiply them, and transform them back. No problem. Since an ellipse is just a circle that has been squashed in one dimension, I figured I could make a blurry one the same way as I make blurry circles. I just needed to squash the Bessel function first. And I was right. The code below works just fine, *except* the intensity varies as you go around the elipse. If anyone could tell me how to fix that problem, I'd be very grateful! BlurryEllipse[sizePix_, radiusPix_, sigmaPix_,stretchFactors_: {1, 1}] := Module[{half = sizePix/2, x, y, f, r, a, pr2}, f = 2*Pi*radiusPix/sizePix; pr2 = -2 (Pi*sigmaPix/sizePix)^2; RotateRight[ Abs[ Chop[ InverseFourier[ RotateRight[ Table[r1= Abs[stretchFactors[[1]]*x+ stretchFactors[[2]]*I*y]; r2 = Abs[x + I*y]; BesselJ[0, f*r1] Exp[pr2 (r2^2)], {y, -half, half-1} , {x, -half, half-1}], {half, half}]]]], {half,half}]] size = 64; rad = 24; scale = 3; tmp = BlurryEllipse[size, rad, scale, {1, .5}]; Show[Graphics[Raster[tmp/Max[Max[tmp]]]], ImageSize -> 400] Intensity varies around the elipse. We can compare amplitude (or power) ratios between major and minor axes: In[]:=Max[tmp[[33]]]/Max[Transpose[tmp][[33]]] Out[]=1.93009 In[]:= Sqrt[Total[tmp[[33]]^2]/Total[Transpose[tmp][[33]]^2]] Out[]= 1.98887 I was surprised these numbers weren't closer to 2. How can we make intensity invariant around the ellipse? === Subject: Re: blurry ellipse you function are exceptional long winded. Try: makeImage[todraw_] := Rasterize[ Graphics[{White, todraw}, Background -> Black, AspectRatio -> Automatic, PlotRangePadding -> 1], ColorSpace -> GrayLevel] gauss[s_] := Table[N[Exp[-(x^2 + y^2)/(2*s)]/(2 Pi*s)], {x, -10, 10}, {y, -10, 10}] and makeImage[Circle[{0, 0}, 1]] /. Raster[bm_, args___] :> Raster[ ListConvolve[gauss[2], bm, {6, 6}], args] makeImage[Circle[{0, 0}, {1, 0.5}]] /. Raster[bm_, args___] :> Raster[ ListConvolve[gauss[2], bm, {6, 6}], args] Clearly you have to adjust the parameters of the functions above to fit your needs. Jens > NB: This is a mathematical problem, not necessarily a Mathematica problem. I need a rasterized, blurry ellipse, i.e. an ellipse convolved with a > Gaussian. I already know how to make a blurry circle. You take the Fourier > transform of a circle (i.e. a Bessel function), the Fourier transform of a > Guassian, multiply them, and transform them back. No problem. Since an > ellipse is just a circle that has been squashed in one dimension, I figured > I could make a blurry one the same way as I make blurry circles. I just > needed to squash the Bessel function first. And I was right. The code below > works just fine, *except* the intensity varies as you go around the elipse. > If anyone could tell me how to fix that problem, I'd be very grateful! BlurryEllipse[sizePix_, radiusPix_, sigmaPix_,stretchFactors_: {1, 1}] := Module[{half = sizePix/2, x, y, f, r, a, pr2}, f = 2*Pi*radiusPix/sizePix; > pr2 = -2 (Pi*sigmaPix/sizePix)^2; RotateRight[ Abs[ > Chop[ InverseFourier[ RotateRight[ Table[r1= > Abs[stretchFactors[[1]]*x+ > stretchFactors[[2]]*I*y]; > r2 = Abs[x + I*y]; > BesselJ[0, f*r1] Exp[pr2 (r2^2)], > {y, -half, half-1} , {x, -half, half-1}], > {half, half}]]]], {half,half}]] size = 64; rad = 24; scale = 3; > tmp = BlurryEllipse[size, rad, scale, {1, .5}]; > Show[Graphics[Raster[tmp/Max[Max[tmp]]]], ImageSize -> 400] Intensity varies around the elipse. We can compare amplitude (or power) > ratios between major and minor axes: In[]:=Max[tmp[[33]]]/Max[Transpose[tmp][[33]]] > Out[]=1.93009 > In[]:= Sqrt[Total[tmp[[33]]^2]/Total[Transpose[tmp][[33]]^2]] Out[]= 1.98887 I was surprised these numbers weren't closer to 2. How can we make intensity > invariant around the ellipse? === Subject: Re: Debugger > Hi David, > I used your M-Debug for a while with Mathematica 5.x and it was a real > pleasure. > Easy and well documented. > Unfortunately it does not seem to work any longer in Mathematica 6.0 (I tried > a couple of times). > Would it be possible for you to update it and make it usable with the > 6th generation ? > I think many Mathematica users would appreciate it. Unfortunately, the debugger will not work with 6.0 - I know. I am toying with the idea of making a debugger that would work exclusively with .m (package) files - which need not, of course, contain a package. Such a file could be read in by the debugger and pre-processed to insert line number information - thus avoiding the use of TraceScan and the heavy overhead per step. This approach would preserve the line number information and would probably run acceptably fast. I guess I am waiting for the next release of Mathematica to see if they make the debugger more usable - if they don't, I will probably release something. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Variable names in Mathematica I can't seem to get an answer to this simple question: are greek letters allowed as variable names in Mathematica? I have tried this with limited success (v 5.2). It seems that some greek letters are reserved, for example -Tony === Subject: Re: Variable names in Mathematica I can't seem to get an answer to this simple question: are greek letters > allowed as variable names in Mathematica? I have tried this with limited > success (v 5.2). It seems that some greek letters are reserved, for example -Tony > for variable names you can use all latin, greek, script and gothic letters. Exceptions are the one letter functions or constants: C, D, E, I, K, N, O and $, which are protected. K isn't protected, but lives in the System` context and is used internally e.g. as summation variable. It will not be cleared with Clear[Global`*]. Gruss Peter -- ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: Variable names in Mathematica foo[[Alpha]_, [ScriptA]_] := [Alpha]*[ScriptA] and foo[2, 3] gives 6 and foo[2, [Beta]] gives 2 [Beta] Jens I can't seem to get an answer to this simple question: are greek letters > allowed as variable names in Mathematica? I have tried this with limited > success (v 5.2). It seems that some greek letters are reserved, for example -Tony > === Subject: Re: imagesize to full width of current screen greetings, > i'm trying to determine the current width of the notebook screen to size graphics and manipulate's to fit the whole width of the window. = i've looked at PageWidth, ImageSize->All, ImageSize->Full, ImageSize- >Large, ImageSize->Scaled[s] (ImageSize->Scaled@1 is equivalent to = ImageSize->Full), $* variables, ... > this is a common feature in other programming languages (javascript in = web browsers for example). i've also searched this mailing list without success. any ideas? > Mitch the information is in the WindowSize option of the corresponding > notebook object. This will give you the size of the notebook that > evaluates it: WindowSize /. Options[EvaluationNotebook[]] when working with manipulates and palettes you also might want to use > ButtonNotebook[] , SelectedNotebook[] and Notebooks[] to get a handle at > the notebook you are after. Just in case: You can also get the size of the screen with: ScreenRectangle /. Options[$FrontEnd] which then lets you choose a reasonable size for a new notebook/window. hth, albert ScreenRectangle does not appear in the $FrontEnd options in Mathematica 6.0, but it is mentioned in the Help file as a function not yet fully integrated (in 6.0). Is there any other way to call it? === Subject: Re: Problem with replacement rules and what does Solve[] ? work with polynomial equations??? So there is no problem, because nobody would use Solve[] for an equation like Sin[x]-y Jens > On Sep 11, 12:16 pm, Jens-Peer Kuska makeFunction[expr_, x_] := Module[{var}, >> var = Complement[Variables[expr], {x}]; >> Function @@ {var, x /. Solve[expr == 0, x][[1]]} >> ] >> and >> f = makeFunction[2 + x - y^2, x]; >> Plot[f[z], {z, -2, 2}] >> ?? >> Jens This code proposed by Jens-Peer Kuska only works with polynomial > equations, because Variables only works correctly with polynomials. > For example, makeFunction[Sin[x]-y,x] gives as output: Function[{y, Sin[x]}, ArcSin[y]] which is incorrect and cannot be plotted. A more general code is the following: invFunction[expr_, x_, vars_List] := > Function @@ {vars, x /. Solve[expr == 0, x][[1]]} where the argument x is the dependent variable and vars_List is the > list of independent variables. Now you have as before: > f = invFunction[2 + x - y^2, x, {y}] Plot[f[z], {z, -2, 2}] for your polynomial functions, but also f = invFunction[Sin[x] - y, x, {y}] > Plot[f[z], {z, -2, 2}] without a problem. An example with multiple indep. variables: f = invFunction[Sin[x] - y - z, x, {y, z}] > Plot3D[f[y, z], {y, -1, 1}, {z, -1, 1}] hth > === Subject: Re: Functional programming? On 9/16/08 at 7:26 PM, dave@Remove_Thisdbailey.co.uk (David Bailey) >It is true that simple examples of FP can be much shorter than their >procedural equivalent, and will almost certainly run much faster, >but FP can become very messy for some real world problems, I think it is also true procedural programing can become messy for some real world problems. Consider something that requires deeply nested For loops. Keeping track of loop indices for such a problem certainly seems messy to me. >and procedural programming offers a way to 'hack' almost anything. and I believe the same can be said of functional programing >I am tempted to give an example of something that is hard to do by FP, >but someone will, of course, provide an answer - but that is not the >point, the point is whether users with limited experience of >Mathematica would be able to come up with such a solution. Why is this the point? For any capable system similar to Mathematica, whether functional based or procedural based, it should always be possible to find examples of problems that users with limited experience with that system will not be able to come up with a simple solution much less an optimal solution. This follows essentially by definition. Systems where it would not be possible to find such problems surely lack rich toolset offered by Mathematica. Debating which is better (functional programing or procedural programing) is analogous to debates of early calculators comparing HP's RPN style to TI's algebraic style. Either could get the task done. And it was possible to find example problems that were more efficiently done by one than by the other. I don't think the point should be finding example problems or whether users with limited experience can solve a particular problem with functional programing. The bottom line is, Mathematica performs better with functional programing than procedural programing. And I believe once a user becomes familiar with Mathematica's functional programing, he/she will find the functional approach more efficient and easier to debug/maintain. To me, using Mathematica without learning functional programing is somewhat analogous to driving a sports car without learning to use the higher gears. You can get from point A to point B in a sports car using only first gear but clearly that isn't efficient use of the sports car. Similarly, you can solve problems with Mathematica using procedural programing but that isn't efficient use of Mathematica. === Subject: Re: Out[xx] included when saving figures? >I recently upgraded to Mathematica v.6, and am encountering a >problem. In the session, if I click on the sidebar of a figure >generated by GraphicsGrid, and choose save selection as from the >menu, then the Out[xx]= in front of the figure is also saved. >Is there anyway I could save the figure without being bothered by >this Out[xx]=? Go to Mathematica's preferences and click on the evaluation tab. Once there uncheck the box next to Show In/Out names. With this box unchecked, you will be able to click on the sidebar, use save selection as and not get the Out[xx]=. === Subject: Re: How to separate a sum into terms >I want to separate a Mathematica expression written as a sum into >separate terms E.g. for >a+b-c+f[1]-g[a]/g[b] >I want to get a list >{a,b,-c,f[1],-g[a]/g[b]} >Is there a simple way to do this? Yes, simply change the head of the sum to List using Apply. That is In[1]:= expr = a + b - c + f[1] - g[a]/g[b]; In[2]:= List @@ expr Out[2]= {a,b,-c,f(1),-(g(a)/g(b))} In[3]:= Apply[List, expr] Out[3]= {a,b,-c,f(1),-(g(a)/g(b))} === Subject: weird NMaximize behaviour I have just encountered strange behaviour by NMaximize (which has been ruining a demonstration I have been working on): This is fine: NMaximize[{(x - 1)^2, -2 <= x <= 2}, {x}] {9., {x -> -2.}} but this definitely is not: NMaximize[{(x - 1)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}] {1., {x -> 2., y -> 0.87904}} The objective function s independent of y, yet NMaximize seems to go off on some wild goose chase and ends up with a very poor maximum. This does not happen here: NMaximize[{(x - 2)^2, -2 <= x <= 2}, {x}] {16., {x -> -2.}} NMaximize[{(x - 2)^2, -2 <= x <= 2 && -1 <= y <= 1}, {x, y}] {16., {x -> -2., y -> -0.980305}} Kind of weird. Andrzej Kozlowski === Subject: Re: How to separate a sum into terms Slava, try the following: expression = a + b - c + f[1] - g[a]/g[b]; Table[expression[[i]], {i, 1, Length[expression]}] Alexei -- Alexei Boulbitch, Dr., Habil. Senior Scientist IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern Luxembourg Phone: +352 2454 2566 Fax: +352 2454 3566 Website: www.iee.lu === Subject: Re: included when saving figures? Hi Jung-Tsung > I recently upgraded to Mathematica v.6, and am encountering a problem. > In the session, if I click on the sidebar of a figure > generated by GraphicsGrid, and choose save selection as > from the menu, then the Out[xx]= in front of the figure is > also saved. If instead I click on the figure directly, the > save selection as option is grayed out. Is there anyway I could save the figure without being > bothered by this Out[xx]=? Because of the problems selecting composite graphics that you've described, I have been doing this using plt = GraphicsGrid[...] Export[plt.png, plt] but your mileage may vary. Dave. === Subject: Re: Using Mathematica with GSL Hi Tommy, > Any there any glue libraries available that implements Glue > code, to evaluate C expressions exported by the Mathematica > Splice command, in terms of functions provided by the GNU > Scientific library (GSL). years ago on this very topic. Try searching for Industrial C Code Generation by Y Papegay from the 2006 Technical Conference. Dave. === Subject: Re: How to separate a sum into terms expr = a + b - c + f[1] - g[a]/g[b]; soln = List @@ expr {a, b, -c, f[1], -(g[a]/g[b])} Plus @@ soln == expr True Total[soln] == expr True Bob Hanlon Hi! I want to separate a Mathematica expression written as a sum into separate terms E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? -- Vyacheslav Rychkov https://mail.sns.it/~rychkov Scuola Normale Superiore Tel: +39-050-509068 (office) Classe di Scienze +39-050-3820086 (home) Piazza dei Cavalieri, 7 +39-3403925168 (mobile) 56100 Pisa Fax: +39-050-509045 Italy E-mail: Rychkov@sns.it -- Bob Hanlon === Subject: Re: Functional programming? David Bailey says: >I think you have chosen a rather favourable example here. Suppose >instead that you need to remove every zero together with the preceding >element (sweeping from left to right). A quick and dirty fp answer is (safer code would check that leading elements were not already zero) In[1]:= v = {1, 2, 0, 3, 4, 0}; v1 = MapAt[0 &, v, Position[v, 0] - 1]; v2 = Select[v1, # != 0 &] Out[1]= {1, 3} It looks like even index manipulation can be written more concisely with functional methodology. It is also easier to read, to me at least. The v1 line reads Find the positions of all zeros, subtract 1, and replace those elements by zero. --Bert Mayo === Subject: Re: Functional programming? > >> I feel there is another thing to say regarding FP. The fact that FP >> performs so well in Mathematica is, in my opinion, something of a >> fluke. >> The real reason is that because Mathematica is such a high level >> language, absolutely every step incurs considerable overhead, that is >> not present in languages such as Fortran or Java. Because FP >> provides a >> way to do a lot in one step, it reduces this overhead. I don't think it is a fluke, but simply a consequence of the fact that > Mathematica is or originated as a Computer Algebra System, and there > is no doubt that functional programming is the most efficient and > natural way to program in a CAS. I don't think there is any point even > arguing about this so I just note that the first (at least I think it > is the first) genuine CAS system did not even have its own programing > language but used LISP (the paradigm of all functional languages), > and one of Mathematica's main rivals, which uses a procedural > programming language (in my opinion a pretty awful one), had > functional constructs belatedly added to it. Andrzej Kozlowski I agree, what I meant was that FP's advantage over PP only exists in environments such as Mathematica. An FP extension to Java (say) would be no faster than an equivalent regular Java program - because both would be ultimately translated into the same machine instructions. BTW, modern Java is fully compiled just prior to execution. I think the mixture of FP and PP constructs in Mathematica is ideal. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Functional programming? > as an old-timer myself - I'd be very interested in this too, > particularly - as you say - with reference to engineering problems. > I'm afraid my favorite construct was the REPEAT - UNTIL loop, which > should finally ruin any shreds of credibility that I may once have > had... > Peter >> 2008/9/13 AES : >> I suggest it might be instructive if some of the functional programming >> proponents on this group could provide us DO-looping old timers with a >> brief summary or tutorial as to what is really meant by, or involved in, >> functional programming? >> --- especially as this concept might relate to building programs to do >> calculations involving multi-stage real-world engineering or technical >> problems >> --- and especially as it might relate to programs that are going to be >> developed in an evolutionary process and that in the end, rather than >> being built into some long-term library, are maybe only going to be run >> or executed a few times before the person involved (e.g., an engineer, >> or scientist, or other real-world individual, not a programmer) moves >> on to some other totally different task or assignment. >> Say we want to compute the mean (average) of all non-zero values for >> each row of a two dimensional array. The code must not crash when fed >> with data of incorrect format as well as it must handle nicely such >> things like divisions by zero. >> (* Functional / Pattern matching code *) >> myMean2[array_?VectorQ] := Mean[Select[array, # != 0 &]] >> myMean2[array_?MatrixQ] := Map[myMean2, array] >> (* Procedural code *) >> myMean1[array_] := >> Module[{iter, len, cnt, sum, mean}, >> sum = 0; >> mean = 0; >> cnt = 0; >> len = Length[array]; >> If[len != 0, >> For[iter = 1, iter <= len, iter = iter + 1, >> If[array[[iter]] != 0, sum = sum + array[[iter]]; cnt = cnt + 1]; >> ]; >> If[cnt != 0, >> mean = sum/cnt; >> , mean = NA; >> ]; >> , mean = NA; >> ]; >> Return[mean] >> ] >> meanArray[array_] := >> Module[{res, len, dim}, >> res = {}; >> len = Length[array]; >> dim = Depth[array] - 1; >> If[dim != 2, >> Return[NA]]; >> For[iter = 1, iter <= len, iter = iter + 1, >> AppendTo[res, myMean1[array[[iter]]] >> ]; >> ]; >> Return[res] >> ] >> (* Some data and some tests *) >> data = {{}, {1, 2, 3, 4, 5, 0, 0, 0}, {0, 0, 0}, {1, 2, -10, >> 3, 4}, {a, b, c}}; >> meanArray[{1, 2, 3, 4, 5, 0, 0, 0}] >> meanArray[{{1, 2, 3, 4, 5, 0, 0, 0}}] >> meanArray[data] >> meanArray[{{{1, 2, 3, 4}, {5, 0, 0, 0}}}] >> (* >> Out[6]= NA >> Out[7]= {3} >> Out[8]= {NA, 3, NA, 0, NA} >> Out[9]= NA >> *) >> myMean2[{1, 2, 3, 4, 5, 0, 0, 0}] >> myMean2[{{1, 2, 3, 4, 5, 0, 0, 0}}] >> Map[myMean2, data] >> Map[myMean2, {{{1, 2, 3, 4}, {5, 0, 0, 0}}}] >> (* >> Out[10]= 3 >> Out[11]= {3} >> Out[12]= {Mean[{}], 3, Mean[{}], 0, Mean[{}]} >> Out[13]= {{5/2, 5}} >> *) >> -- Jean-Marc > I think you have chosen a rather favourable example here. Suppose > instead that you need to remove every zero together with the preceding > element (sweeping from left to right). Realistically, you also probably > want to do something, rather than output Mean[{}] for myMean2[{0,0,0}]. Fair enough! Below, I have added a function called avg that computes the mean, since I did not use the built-in function Mean[] in the procedural code. Also, myMean2 now returns NA rather than Mean[{}] to be consistent w/ the procedural version. In[1]:= avg[ lst_ /; VectorQ[lst, NumericQ] && Positive[Length[lst]]] := (Plus @@ lst)/Length[lst] avg[___] = NA; myMean2[array_?VectorQ] := avg[Select[array, # != 0 &]] myMean2[array_?MatrixQ] := Map[myMean2, array] data = {{}, {1, 2, 3, 4, 5, 0, 0, 0}, {0, 0, 0}, {1, 2, -10, 3, 4}, {a, b, c}}; myMean2[{1, 2, 3, 4, 5, 0, 0, 0}] myMean2[{{1, 2, 3, 4, 5, 0, 0, 0}}] Map[myMean2, data] Map[myMean2, {{{1, 2, 3, 4}, {5, 0, 0, 0}}}] Out[6]= 3 Out[7]= {3} Out[8]= {NA, 3, NA, 0, NA} Out[9]= {{5/2, 5}} > I would say that users should not be scared away from using procedural > code when faced with ad hoc problems of this sort. I second that. -- Jean-Marc === Subject: Re: Functional programming? > I suggest it might be instructive if some of the functional programming > proponents on this group could provide us DO-looping old timers with a > brief summary or tutorial as to what is really meant by, or involved in, > functional programming? --- especially as this concept might relate to building programs to do > calculations involving multi-stage real-world engineering or technical > problems --- and especially as it might relate to programs that are going to be > developed in an evolutionary process and that in the end, rather than > being built into some long-term library, are maybe only going to be run > or executed a few times before the person involved (e.g., an engineer, > or scientist, or other real-world individual, not a programmer) moves > on to some other totally different task or assignment. I know this book is a little dated, but it has a chapter on the matter and also was a very good book for Mathematica in general. http://library.wolfram.com/infocenter/Books/3788/ HTH ~A === Subject: Re: Functional programming? To a novice in these matters like myself it looks to me as if:1. Debugging FP code could be very challenging 2. Although FP looks very concise and fast, there a lot going on that's not immediately apparent and its not clear [ to me ] how to get full hand-on on that code. I know these comments will seem naive to the many experts out there, but its just my observation. Peter === Subject: Re: How to separate a sum into terms Hi Slaa, you need simply to change the Head Plus of the expression to List, using e.g. Apply: List@@ expression hope this helps, Daniel > Hi! I want to separate a Mathematica expression written as a sum into > separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: How to separate a sum into terms > I want to separate a Mathematica expression written as a sum into > separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? Yes, by changing the head of the original expression from Plus to List everything is an expression of the form head[e1, e2, ...] where the head can be itself composed and possibly followed by zero, one, or more elements.) For instance, In[12]:= a + b - c + f[1] - g[a]/g[b] Out[12]= g[a] a + b - c + f[1] - ---- g[b] In[13]:= % // FullForm Out[13]//FullForm= Plus[a, b, Times[-1, c], f[1], Times[-1, g[a], Power[g[b], -1]]] In[14]:= Apply[List, %] Out[14]= g[a] {a, b, -c, f[1], -(----)} g[b] In[15]:= % // FullForm Out[15]//FullForm= List[a, b, Times[-1, c], f[1], Times[-1, g[a], Power[g[b], -1]]] -- Jean-Marc === Subject: Re: How to separate a sum into terms Here is your expression: expr = (a + b - c + f[1] - g[a]/g[b]); The Head of the expression is: Head[expr] Plus But you would like to have a List instead of a sum (Plus) of the items. Do this by applying List to the expression. This replaces the Head, Plus, by a new Head, List. Apply[List, expr] {a, b, -c, f[1], -(g[a]/g[b])} Or use the Mathematica shortcut, @@, for Apply: List @@ expr {a, b, -c, f[1], -(g[a]/g[b])} Or Apply directly to the expression: List @@ (a + b - c + f[1] - g[a]/g[b]) {a, b, -c, f[1], -(g[a]/g[b])} In this particular case you could also do a simple substitution: a + b - c + f[1] - g[a]/g[b] /. Plus -> List {a, b, -c, f[1], -(g[a]/g[b])} But that would not work if, for example, g had a sum for an argument. So Apply is the best method. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ > Hi! I want to separate a Mathematica expression written as a sum into > separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? -- > Vyacheslav Rychkov https://mail.sns.it/~rychkov > Scuola Normale Superiore Tel: +39-050-509068 (office) > Classe di Scienze +39-050-3820086 (home) > Piazza dei Cavalieri, 7 +39-3403925168 (mobile) > 56100 Pisa Fax: +39-050-509045 > Italy E-mail: Rychkov@sns.it > === Subject: Re: How to separate a sum into terms Change the head by @@: List @@ (a + b - c + f[1] - g[a]/g[b]) yours gyzhou === Subject: Re: How to separate a sum into terms Another simplier way is to replace the Head of your sum with a List: List @@ (a + b - c + f[1] - g[a]/g[b]) It gives the same result. Shiu-sing Hong Kong ----- Original Message ----- === Subject: How to separate a sum into terms > Hi! I want to separate a Mathematica expression written as a sum into > separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? -- > Vyacheslav Rychkov https://mail.sns.it/~rychkov > Scuola Normale Superiore Tel: +39-050-509068 (office) > Classe di Scienze +39-050-3820086 (home) > Piazza dei Cavalieri, 7 +39-3403925168 (mobile) > 56100 Pisa Fax: +39-050-509045 > Italy E-mail: Rychkov@sns.it > > === Subject: Re: How to separate a sum into terms Since the Head of your sum is Plus, the following statement works: a + b - c + f[1] - g[a]/g[b] /. Plus[p_, q__] -> {p, q} Shiu-sing Hong Kong ----- Original Message ----- === Subject: How to separate a sum into terms > Hi! I want to separate a Mathematica expression written as a sum into > separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? -- > Vyacheslav Rychkov https://mail.sns.it/~rychkov > Scuola Normale Superiore Tel: +39-050-509068 (office) > Classe di Scienze +39-050-3820086 (home) > Piazza dei Cavalieri, 7 +39-3403925168 (mobile) > 56100 Pisa Fax: +39-050-509045 > Italy E-mail: Rychkov@sns.it > > === Subject: Re: How to separate a sum into terms > Hi! I want to separate a Mathematica expression written as a sum into > separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? Is List@@(a+b-c+f[1]-g[a]/g[b]) simple enough? hth, albert === Subject: Re: How to separate a sum into terms expr = a + b - c + f[1] - g[a]/g[b] List @@ expr ?? Jens > Hi! I want to separate a Mathematica expression written as a sum into > separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? > === Subject: Re: How to separate a sum into terms In[1]:= List @@ (a + b - c + f[1] - g[a]/g[b]) Out[1]= {a, b, -c, f[1], -(g[a]/g[b])} Adriano Pascoletti 2008/9/17 Slava Rychkov separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? -- > Vyacheslav Rychkov https://mail.sns.it/~rychkov > Scuola Normale Superiore Tel: +39-050-509068 (office) > Classe di Scienze +39-050-3820086 (home) > Piazza dei Cavalieri, 7 +39-3403925168 (mobile) > 56100 Pisa Fax: +39-050-509045 > Italy E-mail: Rychkov@sns.it === Subject: Re: How to separate a sum into terms > Hi! I want to separate a Mathematica expression written as a sum into > separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? -- expr = a+b-c+f[1]-g[a]/g[b] List@@expr Gruss Peter -- ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: How to separate a sum into terms In[5]= Apply[List, a + b - c + f[1] - g[a]/g[b]] Out[5]= {a, b, -c, f[1], -g[a]/g[b]} As was brought to our attention in a recent post: In[6]= Variables[a + b - c + f[1] - g[a]/g[b]] Out[6]= {a, b, c, f[1], g[a], g[b]} May also be of use? Tom Dowling > Hi! I want to separate a Mathematica expression written as a sum into > separate terms > E.g. for a+b-c+f[1]-g[a]/g[b] I want to get a list {a,b,-c,f[1],-g[a]/g[b]} Is there a simple way to do this? -- > Vyacheslav Rychkov https://mail.sns.it/~rychkov Classe di Scienze +39-050-3820086 (home) > Piazza dei Cavalieri, 7 +39-3403925168 (mobile) > 56100 Pisa Fax: +39-050-509045 > Italy E-mail: Rychkov@sns.it === Subject: Re: Out[xx] included when saving figures? select the cell bracket of your cell. Open the OptionInspector (Menu: Format/OptionInspector). Type: ShowCellLabel into the LookUp fiel nad hit enter. Then disselect ShowCellLabel. Now when you click apply, the Out[..] will disappear. Hope This helps, Daniel > I recently upgraded to Mathematica v.6, and am encountering a problem. > In the session, if I click on the sidebar of a figure generated by > GraphicsGrid, and choose save selection as from the menu, then the > Out[xx]= in front of the figure is also saved. If instead I click on > the figure directly, the save selection as option is grayed out. Is there anyway I could save the figure without being bothered by this > Out[xx]=? If I quite the session and restart Mathematica, without doing any cell > calculations, then there is not any Out[xx]= (and In[xx]=) so I > could save the figure without the need of any post-processing. > JT > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: Out[xx] included when saving figures? > I recently upgraded to Mathematica v.6, and am encountering a problem. > In the session, if I click on the sidebar of a figure generated by > GraphicsGrid, and choose save selection as from the menu, then the > Out[xx]= in front of the figure is also saved. If instead I click on > the figure directly, the save selection as option is grayed out. Is there anyway I could save the figure without being bothered by this > Out[xx]=? If I quite the session and restart Mathematica, without doing any cell > calculations, then there is not any Out[xx]= (and In[xx]=) so I > could save the figure without the need of any post-processing. I believe that what you are looking for is located within the Preferences dialog box -> Evaluation -> uncheck the box Show In/Out names. HTH, -- Jean-Marc === Subject: Re: Out[xx] included when saving figures? > I believe that what you are looking for is located within the Preferences > dialog box -> Evaluation -> uncheck the box Show In/Out names. HTH, > -- Jean-Marc figure is generated by, for example, a simple plot function, I could click on the figure directly and save it in pdf or eps format, without the Out[xx] being included. For graphics array generated by GraphicsGrid, however, it is not possible to do so for the entire array, although for each individual figure in the array it could still be done. I knew one could use Export to save the entire figure, but that's slightly more work than a simple click and save ( if one only wants the figures in pdf or eps formats). Moreover, at least to me, this shows inconsistency of saving figures. JT === Subject: How to find the best fit for a list {x,y} of data Hello everybody, I have the list and the y=f(x) equation data = {{1, 1}, {28, 0.719188377}, {54, 0.35746493}, {81, 0.182114228}, {117, 0.166082164}, {260, 0.132765531}}; express = (1 - k*x)*(1 - k*x/q)*(1 - p*k*x/q) (1 - k x) (1 - (k x)/q) (1 - (k p x)/q) k,q and p are parameters; then I do the fitting: f1 = FindFit[data, (1 - k*x)*(1 - k*x/q)*(1 - p*k*x/q), {{k, 0.01}, {p, 1.5}, {q,1}}, x, MaxIterations -> 200] and I obtain: {k -> 0.00586032, p -> 2.86841, q -> 2.86841} My question is: how I can find the best fit to my data for values of (k,q,p) >0 ?? Dino === Subject: Re: How to find the best fit for a list {x,y} of data and how can we know what do you understand as best fit to my data ? Jens > Hello everybody, > I have the list and the y=f(x) equation data = {{1, 1}, {28, 0.719188377}, {54, 0.35746493}, {81, > 0.182114228}, {117, 0.166082164}, {260, 0.132765531}}; > express = (1 - k*x)*(1 - k*x/q)*(1 - p*k*x/q) (1 - k x) (1 - (k x)/q) (1 - (k p x)/q) > k,q and p are parameters; then I do the fitting: f1 = FindFit[data, (1 - k*x)*(1 - k*x/q)*(1 - p*k*x/q), {{k, 0.01}, > {p, 1.5}, {q,1}}, x, MaxIterations -> 200] and I obtain: {k -> 0.00586032, p -> 2.86841, q -> 2.86841} My question is: how I can find the best fit to my data for values of > (k,q,p) >0 ?? Dino > === Subject: Re: How to find the best fit for a list {x,y} of data > I have the list and the y=f(x) equation data = {{1, 1}, {28, 0.719188377}, {54, 0.35746493}, {81, > 0.182114228}, {117, 0.166082164}, {260, 0.132765531}}; > express = (1 - k*x)*(1 - k*x/q)*(1 - p*k*x/q) (1 - k x) (1 - (k x)/q) (1 - (k p x)/q) > k,q and p are parameters; then I do the fitting: f1 = FindFit[data, (1 - k*x)*(1 - k*x/q)*(1 - p*k*x/q), {{k, 0.01}, > {p, 1.5}, {q,1}}, x, MaxIterations -> 200] and I obtain: {k -> 0.00586032, p -> 2.86841, q -> 2.86841} My question is: how I can find the best fit to my data for values of > (k,q,p) >0 ?? Some tweaking and experimentation gives you a variety of options to get excellent approximations. In[1]:= data = {{1, 1}, {28, 0.719188377}, {54, 0.35746493}, {81, 0.182114228}, {117, 0.166082164}, {260, 0.132765531}}; expr = (1 - k*x)*(1 - k*x/q)*(1 - p*k*x/q); (* You could add the constrains k > 0 && p > 0 && q > 0 and set the option Method to NMinimize *) f1 = FindFit[data, {expr, k > 0 && p > 0 && q > 0}, {k, p, q}, x, Method -> NMinimize] Plot[expr /. f1, {x, 1, 260}, Epilog -> Point /@ data] (* Or set the precision of the data to, say, 20 and test several methods but Gradient *) f1 = FindFit[SetPrecision[data, 20], expr, {k, p, q}, x, Method -> #] & /@ {ConjugateGradient, LevenbergMarquardt, Newton, QuasiNewton} Plot[expr /. #, {x, 1, 260}, Epilog -> Point /@ data] & /@ f1 Out[3]= {k -> 0.00586017, p -> 0.348616, q -> 0.999951} Out[5]= {{k -> 0.0058603184189148254461, p -> 0.34862536795753106130, q -> 1.0000000000759083932}, {k -> 0.0058603184186521820593, p -> 0.34862536786743369247, q -> 0.99999999999757125104}, {k -> 0.0020430556645278991563, p -> 0.99999999999994081062, q -> 0.34862536786785086450}, {k -> 0.0058603184186556336479, p -> 0.34862536786744803858, q -> 0.99999999999859996068}}59996068}} -- Jean-Marc === Subject: Re: Zoomable ListPlot On 11 Sep, 04:12, peter.stene...@gmail.com > Hi I made a small function to produce a zoomable listplot, hold alt down > and draw a rect to zoom, shift click to return. I'm not very familiar > with the eventhandlers, maybe someone else can do this much better, > without redrawing the plot as many times? I would also like to be able > to turn data series on and off by clicking the legend, but I have no > idea on how to do that... /Peter I found a way to turn data series on and off... PListPlot[fun_, opts : OptionsPattern[{Options[ListPlot], Legend -> {}, Frame -> True, ColorScheme -> 1, PPlotStyle -> {}}]] := DynamicModule[{p1, p2, pr = Automatic, pt = {{0, 0}, {0, 0}}, pl = {}, mylegend, is, style, show, ps}, show = Table[True, {i, 1, Length[fun]}]; ps = Table[ Directive[{ColorData[OptionValue[ColorScheme], i]}~Join~ OptionValue[PPlotStyle]], {i, 1, Length[fun]}]; mylegend[data_] := Framed[Grid[ MapIndexed[{Item[ Graphics[{ColorData[OptionValue[ColorScheme], First@#2], Thick, Line[{{0, 0}, {1, 0}}]}, AspectRatio -> .1, ImageSize -> 30], Alignment -> {Center, Bottom}], Button[Item[ Style[#1, FontSize -> 16, FontColor -> If[show[[First@#2]], Black, Gray], FontFamily -> Helvetica], Alignment -> {Left, Top}], show[[First@#2]] = ! show[[First@#2]], Appearance -> Frameless, Alignment -> {Left, Top}]} &, data]], Background -> RGBColor[1, 1, 0.99999]]; is[x_] := {x, x/GoldenRatio}; EventHandler[ Dynamic[ ListPlot[ fun[[ Select[MapIndexed[If[#1, First@#2] &, show], NumberQ]]], PlotRange -> pr, Epilog -> {pl, Inset[mylegend[OptionValue[Legend]], ImageScaled[{1 - 0.02, 1 - 0.02}], {Right, Top}]}, Evaluate@ FilterRules[{opts}, Options[ListPlot]], PlotStyle -> ps[[ Select[MapIndexed[If[#1, First@#2] &, show], NumberQ]]], MaxPlotPoints -> ControlActive[1000, Infinity]], SynchronousUpdating -> Automatic], MouseDown :> (If[CurrentValue[AltKey], p1 = MousePosition[Graphics]]; If[CurrentValue[ShiftKey], pr = Automatic]; ), MouseUp :> (If[CurrentValue[AltKey], p2 = MousePosition[Graphics]; pt[[1, 1]] = p1[[1]]; pt[[1, 2]] = p2[[1]]; pt[[2, 1]] = p1[[2]]; pt[[2, 2]] = p2[[2]]; pr = pt; pl = {}; ] ), MouseDragged :> (If[CurrentValue[AltKey], p2 = MousePosition[Graphics]; pt[[1, 1]] = p1[[1]]; pt[[1, 2]] = p2[[1]]; pt[[2, 1]] = p1[[2]]; pt[[2, 2]] = p2[[2]]; pl = {Line[{p1, {p2[[1]], p1[[2]]}, p2, {p1[[1]], p2[[2]]}, p1}]}; ]; ) , PassEventsDown -> True ] ] === Subject: Re: Real and Complex Roots presented in a single plot We can also recognize and see the real parts of all the > complex roots of z where the curve is nearest to x -axis at {1.4, > 4.2, 6.6, 9.6, 12.3, 15.3, 17.7}. They are near to x-values where the > local maxima/minima occur.But we cannot 'see' their complex parts, as > they need to be computed. Please note that your claim that the real part of the complex roots is found at the local minima of the given function as the indipendent variable moves on the real axis, is not valid in general and wrong in this particular instance. For example in the interval {1,2} there are 2 local extrema found using the derivative: f[z_] := 1.3 Sin[1.7 z] + 0.6 Sin[4 z] The derivative: In[43]:= fp[z_] := D[f[z], z] In[44]:= fp[z] Out[44]= 2.21 Cos[1.7 z] + 2.4 Cos[4 z] In[73]:= extrema = z /. FindRoot[fp[z], {z, #}] & /@ {1.4, 1.6} Out[73]= {1.33751, 1.69029} The first is the local minimum (see the plot). But the complex roots in interval {1,2} are 1.27946 + 0.374308 I and 1.27946 - 0.374308 I The real part is 1.27946, while the minimum was at 1.33751 This can be visualized on the complex plane using Presentations: f[z_] := 1.3 Sin[1.7 z] + 0.6 Sin[4 z] Needs[Presentations`Master`] fp[z_] := D[f[z], z] extrema = z /. FindRoot[fp[z], {z, #}] & /@ {1.4, 1.6} roots = z /. FindRoot[ f[z], {z, ToComplex@#}] & /@ {{-0.005546, -0.02102}, {1.285, 0.3771}, {1.279, -0.3678}, {2.081, 0.01109}, {3.462, -0.008173}, {4.194, -0.3485}, {4.213, 0.345}} // Chop; In the following plot we see the roots (blu) and the extrema (red) in the interval {1,2} With[{zmin = -.5 - I, zmax = 5 + I, contourlist = {0, 0.1, 0.2, .5, .505, .5095, .51, .53, 0.55, 0.57, 0.6, .61, .62, .6205, 1}}, Draw2D[{ComplexCartesianContour[f[z], {z, zmin, zmax}, Abs, Contours -> contourlist, ColorFunctionScaling -> False, ColorFunction -> (ContourColors[contourlist, ColorData[SolarColors]][#] &), PlotPoints -> {30, 15}, MaxRecursion -> 3, PlotRange -> {0, 11}], ComplexCirclePoint[#, 3, Black, Blue] & /@ roots, ComplexCirclePoint[#, 3, Black, Red] & /@ extrema, ComplexLine[{-5, 5}]}, AspectRatio -> Automatic, PlotRange -> {{1, 2}, {-.7, .7}}, Frame -> True, FrameLabel -> {Re, Im}, RotateLabel -> False, PlotLabel -> Row[{Modulus of , f[z]}], ImageSize -> 900, Background -> Legacy@Linen]] === Subject: Plotting ListDensityPlot with Custom Color Scheme I'm trying to plot out a color map of a matrix with a custom color scheme, and add a legend to it. The maximum value in the matrix is approximately 1.7, and the lowest value is -2.7. Most of the values lie in the range -0.5 to +0.5. When Mathematica 6.0 produces a ListDensityPlot of this matrix, it color codes most of the plot, but it leaves large areas with overflow colors - some of the plot is displayed as white, not on the color map. I'd like to be able to rescale the color function so that it spans the range -2.7 to 1.7, and produce a legend for the plot that accurately reflects this. --Buz === Subject: Re: Plotting ListDensityPlot with Custom Color Scheme I'm trying to plot out a color map of a matrix with a custom color > scheme, and add a legend to it. The maximum value in the matrix is approximately 1.7, and the lowest > value is -2.7. Most of the values lie in the range -0.5 to +0.5. When Mathematica 6.0 produces a ListDensityPlot of this matrix, it > color codes most of the plot, but it leaves large areas with > overflow colors - some of the plot is displayed as white, not on the > color map. I'd like to be able to rescale the color function so that it spans the > range -2.7 to 1.7, and produce a legend for the plot that accurately > reflects this. > MatrixPlot or ArrayPlot may be more suitable for this than ListDensityPlot (try them). With ListDensityPlot, use the option PlotRange -> All, or PlotRange -> {-2.7, 1.7} to set the range of values to be included in the plot. The ColorFunction and ColorFunctionScaling options may also be useful. The legend can be added with the Plot Legends package, http://reference.wolfram.com/mathematica/PlotLegends/tutorial/PlotLegends.ht ml Unfortunately that package can be a little problematic to use sometimes, so you may want to try this alternative: http://www.walkingrandomly.com/?p=24 === Subject: Adding Legend to a ListDensityPlot As a follow up to my previous question, I'd like to add a legend to a ListDensityPlot in Mathematica 6.0. I've able to do this with ShowLegend, using this command Show[ ShowLegend[ ListDensityPlot[ distanceDifferenceData, PerformanceGoal -> Normal, Mesh -> Automatic, LabelStyle -> {FontFamily -> Helvetica, FontSize -> 10}, ColorFunction -> ThermometerColors, DataRange -> {{-2, 230}, {-2, 230}}, ColorFunctionScaling -> True, FrameLabel -> {Style[Residue Number, FontWeight -> Bold], Style[Residue Number, FontWeight -> Bold]} ], {ColorData[ThermometerColors][1 - #1] &, 25, >0.4, <-0.6, LegendBorder -> {Black}, LegendPosition -> {1.1, -0.4}, LegendTextSpace -> 5, LegendBorderSpace -> 3, LegendShadow -> {0., 0.}} ], ImageSize -> {400, Automatic}] However, I'd really like to display the text in the legend in Helvetica, as in the rest of the plot. I've tried: {ColorData[ThermometerColors][1 - #1] &, 25, Style[>0.4,FontFamily- >Helvetica], Style[<-0.6,FontFamily->Helvetica], LegendBorder -> {Black}, LegendPosition -> {1.1, -0.4}, LegendTextSpace -> 5, LegendBorderSpace -> 3, LegendShadow -> {0., 0.}} but each time I try this, Mathematica gives an error. Is there a way around this, or should I edit the text in an external program like Illustrator? --Buz === Subject: Importing svg files I ask just for reference: s = Import[Ampersand_Evolution.svg] and got: Import::fmtnosup: SVG is not a supported Import format. >> $Failed Is this normal? I mean: that Export works and Import not? (I started a new kernel and there it was again...) P_ter === Subject: Re: Importing svg files yes, try the POVRay export/import .. or TeX Complement[$ExportFormats, $ImportFormats] Jens I would expec > I ask just for reference: > s = Import[Ampersand_Evolution.svg] > and got: > Import::fmtnosup: SVG is not a supported Import format. > $Failed Is this normal? I mean: that Export works and Import not? > (I started a new kernel and there it was again...) > P_ter > === Subject: Re: Importing svg files > I ask just for reference: > s = Import[Ampersand_Evolution.svg] > and got: > Import::fmtnosup: SVG is not a supported Import format. > $Failed Is this normal? I mean: that Export works and Import not? > (I started a new kernel and there it was again...) According to the documentation for SVG, yes it is normal you get an error message since it is stipulated that Mathematica (at least up to 6.0.3) can *only* export /static/ SVG files (1.0 and 1.1). -- Jean-Marc === Subject: Re: Importing svg files > I ask just for reference: > s = Import[Ampersand_Evolution.svg] > and got: > Import::fmtnosup: SVG is not a supported Import format. > $Failed Is this normal? I mean: that Export works and Import not? > (I started a new kernel and there it was again...) Yes, there are several formats that can be exported but not imported with Mathematica. This is understandable: exporting is usually much easier to implement than importing. === Subject: Re: Text-based interface: Editing line input It is interesting that math.exe does provide in-line text editing. Well the linux versions do not. I guess I should have mentioned that I was using linux. However I did find a good solution to my problem on a linux forum. I can wrap the math command with rlwrap, which will intercept input from the command line and allow editing, history etc before passing it onto Mathematica. rlwrap math > If you're on Linux, try the JMath front end: http://robotics.caltech.edu/~radford/jmath/ I have never used it myself, but it uses gnu readline, so it should provide line editing and command history. Szabolcs === Subject: Re: Text-based interface: Editing line input I didn't mean to make this a flame war, just ask for suggestions on solving a specific scenario that I encounter. That is why I tried the technical mailing list, rather than resorting to some random forum. While I definitely agree that the GUI version is much better, there are real reasons to use the text based interface (TBI). For instance originally my school only offered Mathematica on campus computers only. Rather than go to campus, I could log into a school Unix server. It is much easier to run the TBI for many basic things rather than using a vnc session to get the GUI up. Then at one point I could get my hands on Mathematica 5.2 for Linux, but the fonts wouldn 't show up on the GUI, and therefore the normal front end was unusable. Rather than properly fixing the problem, I just resort to the TBI (I know that I am lazy, but I didn't care to troubleshoot when I have a viable solution for my needs). It is interesting that math.exe does provide in-line text editing. Well the linux versions do not. I guess I should have mentioned that I was using linux. However I did find a good solution to my problem on a linux forum. I can wrap the math command with rlwrap, which will intercept input from the command line and allow editing, history etc before passing it onto Mathematica. rlwrap math === > Subject: Re: Text-based interface: Editing line input > > I have been enjoying mathematica, for a bit. While > some might consider > > me a minimalist, I enjoy the text-based interface > over the notebook > > style usage. However I severely miss the ability to > move the cursor > > left and right for editing a single line. The > documentation itself > > suggests pasting lines, but most of my pasting > requires a little > > editing too. So instead of pasting whole lines of > input, I resort to > > partial line paste, adding different text, then > pasting the remaining > > relevant portion of a line. > > I would not call it being minimalistic ... it is more like > senseless > self torture ... But it seems that doing everything from a > command line > has become the new fad these days. Yes, you can use Mathematica from a very primitive command > line, lose a > lot of the functionality, but gain nothing ... Or you can > use it with > a very advanced command line where you *can* (but are not > *forced to*) > go back and edit any of the previous inputs (not just the > current line), > use automatic expression formatting and colouring, see > graphics as the > output of some functions, or even use graphics as input! > This advanced > command line interface to Mathematica is called the Front > End. > Is there any way to be able to freely move the cursor > on a line? I > > have obviously tried the arrow keys, and also have > tried emacs style > > movements as well with no luck (ctrl-b ctrl-f for > backwards and > > forewards). Any suggestions? > > Your question is OS specific and you didn't say which > OS you use. On > Windows try starting math.exe, which is a real console mode > program (not > MathKernel.exe). All the usual input features of cmd.exe > such as line > editing and command history will be present. === Subject: Re: Alternating sums of large numbers >I'm using a Mathematica 6, and I've faced with the following >problem. Here is a copy of my Mathematica notebook: >-------------------------------------------------------- >NN = 69.5; >n = 7; >coeff = (Gamma[2*NN - n + 1]*(2*NN - 2*n))/n!; f[z_] := Sum[((-1)^([Mu] + [Nu])*Binomial[n, [Mu]]*Binomial[n, >[Nu]]*Gamma[2*NN - 2*n + [Mu] + [Nu], z])/(Gamma[2*NN - 2*n + >[Mu] + 1]*Gamma[2*NN - 2*n + [Nu] + 1]), {[Mu],0, n}, {[Nu], 0, >n}]; >Plot[coeff*f[z], {z, 0, 100}] >-------------------------------------------------------- >As you can see, I want to calculate a double alternating sum, >consisting of large terms (products of Gamma-functions and binomial >coefficients). Then I want to plot the result, in dependence on >parameter z, which takes part in the summation as an argument of the >incomplete Gamma-function, Gamma[2*NN - 2*n + [Mu] + [Nu], z]. alternating signs, contributing to the summation - probably there >are some mistakes introduced by numerical evaluation. This is exactly the issue when machine precision numbers are used. Change NN to an exact number, i.e., NN = 69+1/2 then try. === Subject: Re: How I can fit data with a parametric equation? >parameters have to be positive, so i was searching for the optimal >values of the parameter that fit the data. How I can modify my code >in order to find the best parameters fitting the data?I tried to do >the Norm between the value of the data and the value of the equation >Remove[Global`*] data = {{1, 1}, {28, 0.719188377}, {54, >0.35746493}, {81, 0.182114228}, {117, >0.166082164}, {260, 0.132765531}}; >express = (1 - k*x)*(1 - k*x/q)*(1 - p*k*x/q) this is the >equation with which i want to fit the data When you want to place constraints on the parameters, using NMinimize is probably going to work for you better than FindFit. First create a function that computes the summed square error In[18]:= ss[x_, y_, k_, p_, q_] := Total[((1 - k*x)*(1 - k*x/q)*(1 - p*k*x/q) - y)^2] Here I've separated the x,y components to simplify the code In[19]:= {xx, yy} = Transpose[data]; Now, NMinimize can be used to find the desired parameters In[20]:= NMinimize[{ss[xx, yy, k, p, q], k > 0 && p > 0 && q > 0}, {k, p, q}] Out[20]= {0.0178264,{k->0.00204306,p->1.,q->0.348625}} In[21]:= Show[ ListPlot[data, PlotRange -> All, Frame -> True, Axes -> None, PlotMarkers -> Automatic], Plot[express /. Last[%20], {x, 0, 300}]] Shows the estimates give a reasonable fit to the data. === Subject: Re: ListContourPlot3D, no output >I am trying to use ListContourPlot3D on a table of the form >{{x,y,z,f},...}. Execution does not give any error number and I get >only a system of axis, with all the ranges {0,1}. I made sure that >the table is properly formatted. I am really puzzled. Until you show some details (sample code etc) of what you are doing, it is almost certain no one here will be able to provide you any meaningful help. That is ListContourPlot3D[RandomReal[1, {20, 4}]] generates a plot. === Subject: Re: Simulate a finite-state markov process I've seen a message in comp.soft-sys.math.mathematica : > I found it very interesting and tried to develop a similar program > using the same idea. The problem is that I'm not that good with programming... Suppose I have the following Emission matrix: {{0.470949,0.260239,0.268812},{0.529412,0.470588,0},{0.625,0,0.375}, > {0.722222,0,0.277778},{0.446667,0.24,0.313333},{0.5,0.5,0}, > {0.481301,0.252846,0.265854},{0.471374,0.257634,0.270992}, > {0.47293,0.269108,0.257962},{0.52027,0.239865,0.239865}, > {0.595238,0.214286,0.190476},{0.444444,0.296296,0.259259}, > {0.478528,0.263804,0.257669},{0.507874,0.233071,0.259055}, > {0.434251,0.308869,0.256881},{0.504274,0.262108,0.233618}, > {0.419753,0.320988,0.259259},{0.473684,0.315789,0.210526}, > {0.512012,0.231231,0.256757},{0.5,0.19469,0.30531}, > {0.390244,0.195122,0.414634},{0.510949,0.19708,0.291971}, > {0.464286,0.25,0.285714},{0.285714,0,0.714286}} The alphabet is {A,B,C} And the following Transition Matrix: {{0.470949,0,0,0,0,0,0.260239,0,0,0,0,0,0,0.268812,0,0,0,0,0,0,0,0,0,0}, > {0.529412,0,0,0,0,0,0,0.470588,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.625,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.375,0,0,0,0,0,0,0,0}, > {0.722222,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.277778,0,0,0,0,0,0}, > {0.446667,0,0,0.24,0,0,0,0,0,0,0,0,0,0,0,0.313333,0,0,0,0,0,0,0,0}, > {0.5,0,0,0,0.5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.481301,0,0,0,0,0,0,0,0.252846,0,0,0,0,0,0.265854,0,0,0,0,0,0,0,0,0}, > {0.471374,0,0,0,0,0,0,0,0,0.257634,0,0,0,0,0,0.270992,0,0,0,0,0,0,0,0}, > {0.47293,0,0,0,0,0,0,0,0,0,0,0,0.269108,0,0,0,0.257962,0,0,0,0,0,0,0}, > {0.52027,0,0,0,0,0,0,0,0,0,0,0,0.239865,0,0,0,0,0.239865,0,0,0,0,0,0}, > {0.595238,0,0,0,0.214286,0.190476,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.444444,0.259259,0,0,0,0,0,0,0.296296,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.478528,0,0,0,0,0,0,0,0,0,0.257669,0,0.263804,0,0,0,0,0,0,0,0,0,0,0}, > {0.507874,0,0,0,0,0,0,0.233071,0,0,0,0,0,0,0,0,0,0,0.259055,0,0,0,0,0}, > {0.434251,0,0,0,0,0,0,0.308869,0,0,0,0,0,0,0,0,0,0,0,0.256881,0,0,0,0}, > {0.504274,0,0,0,0,0,0,0.262108,0,0,0,0,0,0,0,0,0,0,0,0,0.233618,0,0,0}, > {0.419753,0,0,0,0.320988,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.259259,0,0,0,0}, > {0.473684,0,0,0,0.315789,0,0,0,0,0,0,0,0,0,0,0,0,0,0.210526,0,0,0,0,0}, > {0.512012,0,0,0,0,0,0,0.231231,0,0,0,0,0,0,0,0,0,0,0,0,0,0.256757,0,0}, > {0.5,0,0,0,0.19469,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.30531,0,0}, > {0.390244,0,0.195122,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.414634,0,0}, > {0.510949,0,0,0,0,0,0,0,0,0,0,0.19708,0,0,0,0,0,0,0,0,0,0,0.291971,0}, > {0.464286,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.285714,0.25}, > {0.285714,0.714286,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} How can I develop a program to generate x sequences of a specified > length? By the way, does anyone know how to calculate the probability of a > specific sequence to occur within n generated sequences?? > Edson Ferreira My answer might be irrelevant to your true problem (that I have not grasp), but if you want to apply repeatedly a computation to its previous result, you can use functions of the *Nest* family [1, 2]. For instance, In[1]:= P = {{.9, .1}, {.5, .5}}; x = {1, 0}; Nest[#.P &, x, 5] NestList[#.P &, x, 5] Out[3]= {0.83504, 0.16496} Out[4]= {{1, 0}, {0.9, 0.1}, {0.86, 0.14}, {0.844, 0.156}, {0.8376, 0.1624}, {0.83504, 0.16496}} HTH, - Jean-Marc [1] Nest http://reference.wolfram.com/mathematica/ref/Nest.html [2] Applying Functions Repeatedly, http://reference.wolfram.com/mathematica/tutorial/ApplyingFunctionsRepeatedl y.html === Subject: Re: Simulate a finite-state markov process I've seen a message in comp.soft-sys.math.mathematica : > I found it very interesting and tried to develop a similar program > using the same idea. The problem is that I'm not that good with programming... Suppose I have the following Emission matrix: {{0.470949,0.260239,0.268812},{0.529412,0.470588,0},{0.625,0,0.375}, > {0.722222,0,0.277778},{0.446667,0.24,0.313333},{0.5,0.5,0}, > {0.481301,0.252846,0.265854},{0.471374,0.257634,0.270992}, > {0.47293,0.269108,0.257962},{0.52027,0.239865,0.239865}, > {0.595238,0.214286,0.190476},{0.444444,0.296296,0.259259}, > {0.478528,0.263804,0.257669},{0.507874,0.233071,0.259055}, > {0.434251,0.308869,0.256881},{0.504274,0.262108,0.233618}, > {0.419753,0.320988,0.259259},{0.473684,0.315789,0.210526}, > {0.512012,0.231231,0.256757},{0.5,0.19469,0.30531}, > {0.390244,0.195122,0.414634},{0.510949,0.19708,0.291971}, > {0.464286,0.25,0.285714},{0.285714,0,0.714286}} The alphabet is {A,B,C} And the following Transition Matrix: {{0.470949,0,0,0,0,0,0.260239,0,0,0,0,0,0,0.268812,0,0,0,0,0,0,0,0,0,0}, > {0.529412,0,0,0,0,0,0,0.470588,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.625,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.375,0,0,0,0,0,0,0,0}, > {0.722222,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.277778,0,0,0,0,0,0}, > {0.446667,0,0,0.24,0,0,0,0,0,0,0,0,0,0,0,0.313333,0,0,0,0,0,0,0,0}, > {0.5,0,0,0,0.5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.481301,0,0,0,0,0,0,0,0.252846,0,0,0,0,0,0.265854,0,0,0,0,0,0,0,0,0}, > {0.471374,0,0,0,0,0,0,0,0,0.257634,0,0,0,0,0,0.270992,0,0,0,0,0,0,0,0}, > {0.47293,0,0,0,0,0,0,0,0,0,0,0,0.269108,0,0,0,0.257962,0,0,0,0,0,0,0}, > {0.52027,0,0,0,0,0,0,0,0,0,0,0,0.239865,0,0,0,0,0.239865,0,0,0,0,0,0}, > {0.595238,0,0,0,0.214286,0.190476,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.444444,0.259259,0,0,0,0,0,0,0.296296,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.478528,0,0,0,0,0,0,0,0,0,0.257669,0,0.263804,0,0,0,0,0,0,0,0,0,0,0}, > {0.507874,0,0,0,0,0,0,0.233071,0,0,0,0,0,0,0,0,0,0,0.259055,0,0,0,0,0}, > {0.434251,0,0,0,0,0,0,0.308869,0,0,0,0,0,0,0,0,0,0,0,0.256881,0,0,0,0}, > {0.504274,0,0,0,0,0,0,0.262108,0,0,0,0,0,0,0,0,0,0,0,0,0.233618,0,0,0}, > {0.419753,0,0,0,0.320988,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.259259,0,0,0,0}, > {0.473684,0,0,0,0.315789,0,0,0,0,0,0,0,0,0,0,0,0,0,0.210526,0,0,0,0,0}, > {0.512012,0,0,0,0,0,0,0.231231,0,0,0,0,0,0,0,0,0,0,0,0,0,0.256757,0,0}, > {0.5,0,0,0,0.19469,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.30531,0,0}, > {0.390244,0,0.195122,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.414634,0,0}, > {0.510949,0,0,0,0,0,0,0,0,0,0,0.19708,0,0,0,0,0,0,0,0,0,0,0.291971,0}, > {0.464286,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.285714,0.25}, > {0.285714,0.714286,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} How can I develop a program to generate x sequences of a specified > length? By the way, does anyone know how to calculate the probability of a > specific sequence to occur within n generated sequences?? > Edson Ferreira In definining your emission and transition matrixes, you need to make sure that the rows sum to one. (Your's don't quite.) So use the following: EmisionMatrix = #/Total[#]& /@ {{0.470949,0.260239,0.268812},...}; TransmissionMatrix = #/Total[#]& /@ {{0.470949,0,0,0,0,0,0.260239,0,0,0,0,0,0,0.268812,0,0,0,0,0,0,0,0,0,0},...= }; --Mark === Subject: Re: Simulate a finite-state markov process I've seen a message in comp.soft-sys.math.mathematica : > I found it very interesting and tried to develop a similar program > using the same idea. The problem is that I'm not that good with programming... Suppose I have the following Emission matrix: {{0.470949,0.260239,0.268812},{0.529412,0.470588,0},{0.625,0,0.375}, > {0.722222,0,0.277778},{0.446667,0.24,0.313333},{0.5,0.5,0}, > {0.481301,0.252846,0.265854},{0.471374,0.257634,0.270992}, > {0.47293,0.269108,0.257962},{0.52027,0.239865,0.239865}, > {0.595238,0.214286,0.190476},{0.444444,0.296296,0.259259}, > {0.478528,0.263804,0.257669},{0.507874,0.233071,0.259055}, > {0.434251,0.308869,0.256881},{0.504274,0.262108,0.233618}, > {0.419753,0.320988,0.259259},{0.473684,0.315789,0.210526}, > {0.512012,0.231231,0.256757},{0.5,0.19469,0.30531}, > {0.390244,0.195122,0.414634},{0.510949,0.19708,0.291971}, > {0.464286,0.25,0.285714},{0.285714,0,0.714286}} The alphabet is {A,B,C} And the following Transition Matrix: {{0.470949,0,0,0,0,0,0.260239,0,0,0,0,0,0,0.268812,0,0,0,0,0,0,0,0,0,0}, > {0.529412,0,0,0,0,0,0,0.470588,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.625,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.375,0,0,0,0,0,0,0,0}, > {0.722222,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.277778,0,0,0,0,0,0}, > {0.446667,0,0,0.24,0,0,0,0,0,0,0,0,0,0,0,0.313333,0,0,0,0,0,0,0,0}, > {0.5,0,0,0,0.5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.481301,0,0,0,0,0,0,0,0.252846,0,0,0,0,0,0.265854,0,0,0,0,0,0,0,0,0}, > {0.471374,0,0,0,0,0,0,0,0,0.257634,0,0,0,0,0,0.270992,0,0,0,0,0,0,0,0}, > {0.47293,0,0,0,0,0,0,0,0,0,0,0,0.269108,0,0,0,0.257962,0,0,0,0,0,0,0}, > {0.52027,0,0,0,0,0,0,0,0,0,0,0,0.239865,0,0,0,0,0.239865,0,0,0,0,0,0}, > {0.595238,0,0,0,0.214286,0.190476,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.444444,0.259259,0,0,0,0,0,0,0.296296,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, > {0.478528,0,0,0,0,0,0,0,0,0,0.257669,0,0.263804,0,0,0,0,0,0,0,0,0,0,0}, > {0.507874,0,0,0,0,0,0,0.233071,0,0,0,0,0,0,0,0,0,0,0.259055,0,0,0,0,0}, > {0.434251,0,0,0,0,0,0,0.308869,0,0,0,0,0,0,0,0,0,0,0,0.256881,0,0,0,0}, > {0.504274,0,0,0,0,0,0,0.262108,0,0,0,0,0,0,0,0,0,0,0,0,0.233618,0,0,0}, > {0.419753,0,0,0,0.320988,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.259259,0,0,0,0}, > {0.473684,0,0,0,0.315789,0,0,0,0,0,0,0,0,0,0,0,0,0,0.210526,0,0,0,0,0}, > {0.512012,0,0,0,0,0,0,0.231231,0,0,0,0,0,0,0,0,0,0,0,0,0,0.256757,0,0}, > {0.5,0,0,0,0.19469,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.30531,0,0}, > {0.390244,0,0.195122,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.414634,0,0}, > {0.510949,0,0,0,0,0,0,0,0,0,0,0.19708,0,0,0,0,0,0,0,0,0,0,0.291971,0}, > {0.464286,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.285714,0.25}, > {0.285714,0.714286,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} How can I develop a program to generate x sequences of a specified > length? By the way, does anyone know how to calculate the probability of a > specific sequence to occur within n generated sequences?? > Edson Ferreira I'm not familiar with emission matrixes and alphabets. But a quick Google search suggests that the following might be what you're looking for. First, make sure you have defined the functions randomChoice and InvariantDistribution (from the message you reference). Next assign your matrices to the symbols EmissionMatrix and TransitionMatrix. (* get the starting value for the simulation *) lambda = InvariantDistribution[TransitionMatrix]; start = randomChoice[lambda -> Range[24]]; (* simulate sequence of hidden states of length 100 *) hiddenstatesim = NestList[randomChoice[TransitionMatrix[[#]] -> Range[24]] &, start, 100]; (* simulate observable alphabet *) alphasim = randomChoice[EmissionMatrix[[#]] -> {A, B, C}] & /@ hiddenstatesim One way to compute probabilities is to run simulations and count outcomes. --Mark === Subject: How can you get the list of all used variables and functions in How can you get the list of all used variables and functions in Mathematica? Is that possible? === Subject: Re: How can you get the list of all used variables and functions > How can you get the list of all used variables and functions in > Mathematica? Is that possible? > Try ?Global`* or Names[Global`*] === Subject: Re: How can you get the list of all used variables and functions Names[Global`*] ?? Jens > How can you get the list of all used variables and functions in > Mathematica? Is that possible? > === Subject: How can you get the list of Jean I find ?Global`* is useful. And I work out like this: Begin[a`] Y=H[Ky,Ly] End[] Names[a`*]//MatrixForm Weber -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- =E5=8F=91=E4=BB=B6=E4=BA=BA: Jean-Marc Gulliet = [mailto:jeanmarc.gulliet@gmail.com] =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2008=E5=B9=B49=E6=9C=8812=E6=97=A5 = 21:49 =E6=94=B6=E4=BB=B6=E4=BA=BA: Weber; mathgroup@smc.vnet.net =E4=B8=BB=E9=A2=98: Re: How can you get the list of all used variables = and functions in > How can you get the list of all used variables and functions in > Mathematica? Is that possible? Depending on what you intend to do with the result, you could use ? or Names. For instance, the following will give you all the user defined functions and variables (located in the context Global by default) In[1]:= f[x_] := x^2 In[2]:= g[x_, y_] := x^2 + y^2 In[3]:= ?Global`* Global` f g x y In[4]:= lst = Names[Global`*] Out[4]= {f, g, lst, x, y} In[5]:= Definition /@ lst // TableForm Out[5]//TableForm= 2 f[x_] := x 2 2 g[x_, y_] := x + y lst = {f, g, lst, x, y} Null Null -- Jean-Marc === Subject: Re: How can you get the list of all used variables and functions > How can you get the list of all used variables and functions in > Mathematica? Is that possible? Depending on what you intend to do with the result, you could use ? or Names. For instance, the following will give you all the user defined functions and variables (located in the context Global by default) In[1]:= f[x_] := x^2 In[2]:= g[x_, y_] := x^2 + y^2 In[3]:= ?Global`* Global` f g x y In[4]:= lst = Names[Global`*] Out[4]= {f, g, lst, x, y} In[5]:= Definition /@ lst // TableForm Out[5]//TableForm= 2 f[x_] := x 2 2 g[x_, y_] := x + y lst = {f, g, lst, x, y} Null Null -- Jean-Marc === Subject: Re: Transformations in expressions Use ReplaceAll ( /. ) Log[x^2 + y^3]/Sin[x^2 + y^3] /. x^2 + y^3 -> z Csc[z]*Log[z] or Simplify[Log[x^2 + y^3]/Sin[x^2 + y^3], z == x^2 + y^3] csc(z) log(z) In both cases, 1/Sin[z] is automatically converted to Csc[z] as a simpler form. I do not understand your second question. Bob Hanlon Hi all, How can I to transform a specific expression to other by substitution of a part of it. For example, I want to transform the expression Log[x^2+y^3]/ Sin[x^2+y^3] in Log[z]/Sin[z] by substitution x^2+y^3 --> z. And other question: Is the new expression dependent of z. I see it is, but how can I to programar it. -- Bob Hanlon === Subject: Re: Transformations in expressions Log[x^2 + y^3]/Sin[x^2 + y^3] /. x^2 + y^3 -> z ?? Jens > Hi all, > How can I to transform a specific expression to other by substitution > of a part of it. For example, I want to transform the expression Log[x^2+y^3]/ > Sin[x^2+y^3] in Log[z]/Sin[z] by substitution x^2+y^3 --> z. And other question: Is the new expression dependent of z. I see it is, > but how can I to programar it. === Subject: Re: Transformations in expressions > Hi all, > How can I to transform a specific expression to other by substitution > of a part of it. For example, I want to transform the expression Log[x^2+y^3]/ > Sin[x^2+y^3] in Log[z]/Sin[z] by substitution x^2+y^3 --> z. > In[1]:= Log[x^2 + y^3]/Sin[x^2 + y^3] /. x^2 + y^3 -> z Out[1]= Csc[z] Log[z] > And other question: Is the new expression dependent of z. I see it is, > but how can I to programar it. > I don't really understand this second question ... === Subject: Re: Transformations in expressions > How can I to transform a specific expression to other by substitution > of a part of it. For example, I want to transform the expression Log[x^2+y^3]/ > Sin[x^2+y^3] in Log[z]/Sin[z] by substitution x^2+y^3 --> z. replacement operator (/.) In[1]:= expr = Log[x^2 + y^3]/Sin[x^2 + y^3] ; expr /. x^2 + y^3 -> z Out[2]= Csc[z] Log[z] > And other question: Is the new expression dependent of z. I see it is, > but how can I to programar it. In[3]:= f[z_] = Log[x^2 + y^3]/Sin[x^2 + y^3] /. x^2 + y^3 -> z f[2] % // N Out[3]= Csc[z] Log[z] Out[4]= Csc[2] Log[2] Out[5]= 0.762289 You should have a look at tutorial/DefiningFunctions http://reference.wolfram.com/mathematica/tutorial/DefiningFunctions.html -- Jean-Marc === Subject: Re: Transformations in expressions Log[x^2 + y^3]/Sin[x^2 + y^3] /. x^2 + y^3 -> z 2008/9/11 Miguel : > Hi all, > How can I to transform a specific expression to other by substitution > of a part of it. For example, I want to transform the expression Log[x^2+y^3]/ > Sin[x^2+y^3] in Log[z]/Sin[z] by substitution x^2+y^3 --> z. And other question: Is the new expression dependent of z. I see it is, > but how can I to programar it. > -- === Subject: Re: ListContourPlot3D, no output Basically it sounds like it did not recognize your data as something that evaluates to numbers. But why don't you give a specific example? -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I am trying to use ListContourPlot3D on a table of the form > {{x,y,z,f},...}. Execution does not give any error number and I get only a > system of axis, with all the ranges {0,1}. I made sure that the table is > properly formatted. > I am really puzzled. Adi > === Subject: Re: ListContourPlot3D, no output and you had not the idea, that this may be caused by your data ? that you don't give us ? Does data = Table[RandomReal[], {2000}, {4}]; ListContourPlot3D[data] work for you ? Jens I am trying to use ListContourPlot3D on a table of the form {{x,y,z,f},...}. Execution does not give any error number and I get only a system of axis, with all the ranges {0,1}. I made sure that the table is properly formatted. > I am really puzzled. Adi > === Subject: Re: ListContourPlot3D, no output I am trying to use ListContourPlot3D on a table of the form {{x,y,z,f},..= .}. Execution does not give any error number and I get only a system of axi= s, with all the ranges {0,1}. I made sure that the table is properly format= ted. > I am really puzzled. Adi Could you post your code, please? === Subject: Re: ListContourPlot3D, no output > I am trying to use ListContourPlot3D on a table of the form {{x,y,z,f},...}. Execution does not give any error number and I get only a system of axis, with all the ranges {0,1}. I made sure that the table is properly formatted. > I am really puzzled. You should post an actual example of a command that does not work on your system. The following works fine on mine: In[1]:= $Version Short[data = Flatten[Table[{x, y, z, RandomReal[{-1, 1}]}, {x, -2, 8}, {y, 1, 10}, {z, 10}], 2], 3] Dimensions[data] ListContourPlot3D[data, Contours -> {0}] Out[1]= 6.0 for Mac OS X x86 (64-bit) (May 21, 2008) Out[2]= {{-2,1,1,0.43068}, {-2,1,2,-0.317796}, {-2,1,3,-0.397626}, <<1095>>, {8,10,9,0.872865}, {8,10,10,-0.914065}} Out[3]= {1100, 4} Out[4] = [... Awesome 3D color graphic deleted :-) ...] -- Jean-Marc === Subject: Re: Alternating sums of large numbers Use the WorkingPrecision option of Plot, and set NN to a high precision using the backquote character, or set NN = 139/2. NN = 69.5`30; n = 7; coeff = (Gamma[2*NN - n + 1]*(2*NN - 2*n))/n!; f[z_] := Sum[((-1)^([Mu] + [Nu])*Binomial[n, [Mu]]* Binomial[n, [Nu]]* Gamma[2*NN - 2*n + [Mu] + [Nu], z])/(Gamma[ 2*NN - 2*n + [Mu] + 1]*Gamma[2*NN - 2*n + [Nu] + 1]), {[Mu], 0, n}, {[Nu], 0, n}]; Plot[coeff*f[z], {z, 0, 100}, WorkingPrecision -> 25] -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm using a Mathematica 6, and I've faced with the following problem. > Here is a copy of my Mathematica notebook: -------------------------------------------------------- NN = 69.5; n = 7; coeff = (Gamma[2*NN - n + 1]*(2*NN - 2*n))/n!; f[z_] := Sum[((-1)^([Mu] + [Nu])*Binomial[n, [Mu]]*Binomial[n, > [Nu]]*Gamma[2*NN - 2*n + [Mu] + [Nu], z])/(Gamma[2*NN - 2*n + [Mu] > + 1]*Gamma[2*NN - 2*n + [Nu] + 1]), {[Mu],0, n}, {[Nu], 0, n}]; Plot[coeff*f[z], {z, 0, 100}] -------------------------------------------------------- As you can see, I want to calculate a double alternating sum, > consisting of large terms (products of Gamma-functions and binomial > coefficients). Then I want to plot the result, in dependence on > parameter z, which takes part in the summation as an argument of the > incomplete Gamma-function, Gamma[2*NN - 2*n + [Mu] + [Nu], z]. Apart from this, I have another parameter, n, which is an upper limit > for both of sums, and also takes part in Gamma functions. When this > parameter grows, the expression next to summation also increases. At > some point, Mathematica begins to show very strange results - and my > question is actually about this. For instance, if the parameter n=5, everything is O.K., the plot shows > a smooth curve. When we set n=6, there appears a little noise at > 60 for n=8. A suppose that this error is caused by the huge numbers with > alternating signs, contributing to the summation - probably there are > some mistakes introduced by numerical evaluation. I tried to play with > Accuracy etc., but it does not help. I also investigated the > possibility that the error is introduced not by the summation, but by > the product of big numbers. According to this, I tried to compute the > sum of Exp[Log[Gamma]+Log[Gamma]...] (the logarithm smoothly > depends on z). But it does not help as well... I would very much appreciate your advice on such problem. Mikhail. > === Subject: Re: Alternating sums of large numbers > Use the WorkingPrecision option of Plot, and set NN to a high precision > using the backquote character, or set NN = 139/2. NN = 69.5`30; n = 7; coeff = (Gamma[2*NN - n + 1]*(2*NN - 2*n))/n!; f[z_] := Sum[((-1)^([Mu] + [Nu])*Binomial[n, [Mu]]* > Binomial[n, [Nu]]* > Gamma[2*NN - 2*n + [Mu] + [Nu], z])/(Gamma[ > 2*NN - 2*n + [Mu] + 1]*Gamma[2*NN - 2*n + [Nu] + 1]), {= [Mu], > 0, n}, {[Nu], 0, n}]; Plot[coeff*f[z], {z, 0, 100}, > WorkingPrecision -> 25] -- > David Park > djmp...@comcast.nethttp://home.comcast.net/~djmpark/ I'm using a Mathematica 6, and I've faced with the following problem. Here is a copy of my Mathematica notebook: > -------------------------------------------------------- > NN = 69.5; > n = 7; > coeff = (Gamma[2*NN - n + 1]*(2*NN - 2*n))/n!; > f[z_] := Sum[((-1)^([Mu] + [Nu])*Binomial[n, [Mu]]*Binomial[n, [Nu]]*Gamma[2*NN - 2*n + [Mu] + [Nu], z])/(Gamma[2*NN - 2*n + [Mu] + 1]*Gamma[2*NN - 2*n + [Nu] + 1]), {[Mu],0, n}, {[Nu], 0, n}]; > Plot[coeff*f[z], {z, 0, 100}] > -------------------------------------------------------- > As you can see, I want to calculate a double alternating sum, consisting of large terms (products of Gamma-functions and binomial coefficients). Then I want to plot the result, in dependence on parameter z, which takes part in the summation as an argument of the incomplete Gamma-function, Gamma[2*NN - 2*n + [Mu] + [Nu], z]. > Apart from this, I have another parameter, n, which is an upper limit for both of sums, and also takes part in Gamma functions. When this parameter grows, the expression next to summation also increases. At some point, Mathematica begins to show very strange results - and my question is actually about this. > For instance, if the parameter n=5, everything is O.K., the plot show= s a smooth curve. When we set n=6, there appears a little noise at 60 I would very much appreciate your advice on such problem. > Mikhail. === Subject: Re: Alternating sums of large numbers I'm using a Mathematica 6, and I've faced with the following problem. > Here is a copy of my Mathematica notebook: -------------------------------------------------------- NN = 69.5; n = 7; coeff = (Gamma[2*NN - n + 1]*(2*NN - 2*n))/n!; f[z_] := Sum[((-1)^([Mu] + [Nu])*Binomial[n, [Mu]]*Binomial[n, > [Nu]]*Gamma[2*NN - 2*n + [Mu] + [Nu], z])/(Gamma[2*NN - 2*n + [Mu] > + 1]*Gamma[2*NN - 2*n + [Nu] + 1]), {[Mu],0, n}, {[Nu], 0, n}]; Plot[coeff*f[z], {z, 0, 100}] -------------------------------------------------------- As you can see, I want to calculate a double alternating sum, > consisting of large terms (products of Gamma-functions and binomial > coefficients). Then I want to plot the result, in dependence on > parameter z, which takes part in the summation as an argument of the > incomplete Gamma-function, Gamma[2*NN - 2*n + [Mu] + [Nu], z]. Apart from this, I have another parameter, n, which is an upper limit > for both of sums, and also takes part in Gamma functions. When this > parameter grows, the expression next to summation also increases. At > some point, Mathematica begins to show very strange results - and my > question is actually about this. For instance, if the parameter n=5, everything is O.K., the plot shows > a smooth curve. When we set n=6, there appears a little noise at > 60 for n=8. A suppose that this error is caused by the huge numbers with > alternating signs, contributing to the summation - probably there are > some mistakes introduced by numerical evaluation. I tried to play with > Accuracy etc., but it does not help. I also investigated the > possibility that the error is introduced not by the summation, but by > the product of big numbers. According to this, I tried to compute the > sum of Exp[Log[Gamma]+Log[Gamma]...] (the logarithm smoothly > depends on z). But it does not help as well... I would very much appreciate your advice on such problem. Mikhail. > As you already realise, the alternating sums are generating rounding error (noise) because your calculations are being done at machine precision. Once Mathematica starts a calculation in machine precision, it basically stays at that precision, so you need to ensure that the real numbers entering your calculation are high precision. Thus you need to set NN=65.9000000000000000000000000000000000000000000000; and also, Plot will by default inject real number values, which you can override by using the WorkingPrecision option - setting it to some large value - say 50. With both of these changes, you get a smooth graph. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Import[] remote files via scp? Does Mathematica support opening files via scp or sftp? Or is there a separate package around to do that? Or is it possible to write one, using only the Mathematica API without foreign functions? (Otherwise, seems like I'll have to J/Link with the jsch library and post my results here) -- Eugene Kirpichov Web IR developer, Yandex === Subject: Re: Import[] remote files via scp? > Does Mathematica support opening files via scp or sftp? > Or is there a separate package around to do that? > Or is it possible to write one, using only the Mathematica API without > foreign functions? (Otherwise, seems like I'll have to J/Link with the jsch library and > post my results here) > Import can read from pipes. Assuming that you use public key authentication (and thus do not need to type a password), the following *should* work on a Unix system, but I have not tested it: Import[!ssh remote-machine cat path/to/your/file, Table] (It is important to explicitly specify the data type, e.g. Table, when Import is reading from a pipe.) === Subject: Re: integration frustration I have a question about a particular integral: > i[r]= Integrate[(L-z)(f[Sqrt[z^2+r^2]] -f[z]),{z,0,L}] Assumptions->f[0]==0, f[r]>0 if r>0. Is i[r]>=0 for all r? Any Ideas? Help! TIA, Chris Notice that your i[] is also a function of L. No, it is not always positive. Best way to show this is to construct a counterexample. Look for one that rises and then falls, so that your f[Sqrt[z^2+r^2]] will tend to be less than your f[z] (requires picking suitable f-dependent r to enforce this). If this is certifiably not homework, feel free to explain the application if you require an explicit counterexample. Daniel Lichtblau Wolfram Research === Subject: integration frustration I have a question about a particular integral: i[r]= Integrate[(L-z)(f[Sqrt[z^2+r^2]] -f[z]),{z,0,L}] Assumptions->f[0]==0, f[r]>0 if r>0. Is i[r]>=0 for all r? Any Ideas? Help! TIA, Chris === Subject: Re: integration frustration I have a question about a particular integral: > i[r]= Integrate[(L-z)(f[Sqrt[z^2+r^2]] -f[z]),{z,0,L}] > Assumptions->f[0]==0, f[r]>0 if r>0. Is i[r]>=0 for all r? > No > Any Ideas? > Yes > Help! TIA, Chris > Hi Chris, here is a simple counter-example: In[1]:= i[r_] = Integrate[(L - z)*(f[Sqrt[z^2 + r^2]] - f[z]), {z, 0, L}]; In[2]:= f[x_] := Piecewise[{{1, 0 < x < L/10}, {1/10, L/10 <= x <= L}}] Assuming[L > 0, ((Print[#1]; #1) & )[Factor[i[L/2]]] >= 0 // Simplify] During evaluation of In[2]:= ((-173 + 50*Sqrt[3])*L^2)/1000 Out[3]= False f being a strictly increasing function is obviously sufficient for i[r]>=0 for all real r. Peter === Subject: Re: integration frustration Mathematica won't perform the integration unless f is defined. However, I think your statement is true provided f is a monotonically increasing function. -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I have a question about a particular integral: > i[r]= Integrate[(L-z)(f[Sqrt[z^2+r^2]] -f[z]),{z,0,L}] > Assumptions->f[0]==0, f[r]>0 if r>0. Is i[r]>=0 for all r? Any Ideas? Help! TIA, Chris > === Subject: Re: Text-based interface: Editing line input === > Subject: Re: Text-based interface: Editing line input > Cc: mathgroup@smc.vnet.net > > It is interesting that math.exe does provide in-line > text editing. Well the linux versions do not. I guess I > should have mentioned that I was using linux. However I did > find a good solution to my problem on a linux forum. I can > wrap the math command with rlwrap, which will intercept > input from the command line and allow editing, history etc > before passing it onto Mathematica. > > rlwrap math > > If you're on Linux, try the JMath front end: http://robotics.caltech.edu/~radford/jmath/ I have never used it myself, but it uses gnu readline, so > it should > provide line editing and command history. Szabolcs=0A=0A=0A === Subject: Apparent error integrating product of DiracDelta's How do I get: Integrate[DiracDelta[z- x] DiracDelta[z- y], {z-Infinity, Infinity}] to give DiracDelta[x-y] as the result? Currently it gives 0. I have all three variable assumed to be Reals. I am using 6.0.0. Michael Mandelberg === Subject: Re: Apparent error integrating product of DiracDelta's > How do I get: Integrate[DiracDelta[z- x] DiracDelta[z- y], {z-Infinity, Infinity}] to give DiracDelta[x-y] as the result? Currently it gives 0. I have > all three variable assumed to be Reals. I am using 6.0.0. Michael Mandelberg > I think you have synatx error in the limit part. I assume you mean to write {z, -Infinity,Infinity} Given that, I think zero is the correct answer. When you multiply 2 deltas at different positions, you get zero. Integral of zero is zero. Nasser === Subject: Re: Text-based interface: Editing line input > I have been enjoying mathematica, for a bit. While some might consider me a minimalist, I enjoy the text-based interface over the notebook style usage. However I severely miss the ability to move the cursor left and right for editing a single line. The documentation itself suggests pasting lines, but most of my pasting requires a little editing too. So instead of pasting whole lines of input, I resort to partial line paste, adding different text, then pasting the remaining relevant portion of a line. Is there any way to be able to freely move the cursor on a line? I have obviously tried the arrow keys, and also have tried emacs style movements as well with no luck (ctrl-b ctrl-f for backwards and forewards). Any suggestions? > > Rather than use the command line interface, I like to store code in a package file (.m) and edit and execute code from that. The FE will edit a .m file, but it does not auto-indent, and there is a very simple relationship between the visible package file and what is stored on disk. I would strongly suggest you try this interface. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Text-based interface: Editing line input For general use of Mathematica I believe users should stay with front end notebooks. Otherwise, they will spend most their time on computer science rather than mathematics. Notebooks are the way Mathematica is basically designed to work. Notebooks allow the writing of classical looking documents and the accumulation of embedded knowledge. These are powerful features that should not be lightly given up. A few people may have special requirements to connect Mathematica to other software, but most people should use notebooks. It's difficult enough to learn Mathematica as it is! -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >I have been enjoying mathematica, for a bit. While some might consider me a >minimalist, I enjoy the text-based interface over the notebook style usage. >However I severely miss the ability to move the cursor left and right for >editing a single line. The documentation itself suggests pasting lines, but >most of my pasting requires a little editing too. So instead of pasting >whole lines of input, I resort to partial line paste, adding different >text, then pasting the remaining relevant portion of a line. Is there any way to be able to freely move the cursor on a line? I have > obviously tried the arrow keys, and also have tried emacs style movements > as well with no luck (ctrl-b ctrl-f for backwards and forewards). Any > suggestions? === Subject: Re: Text-based interface: Editing line input > I have been enjoying mathematica, for a bit. While some might consider > me a minimalist, I enjoy the text-based interface over the notebook > style usage. However I severely miss the ability to move the cursor > left and right for editing a single line. The documentation itself > suggests pasting lines, but most of my pasting requires a little > editing too. So instead of pasting whole lines of input, I resort to > partial line paste, adding different text, then pasting the remaining > relevant portion of a line. > I would not call it being minimalistic ... it is more like senseless self torture ... But it seems that doing everything from a command line has become the new fad these days. Yes, you can use Mathematica from a very primitive command line, lose a lot of the functionality, but gain nothing ... Or you can use it with a very advanced command line where you *can* (but are not *forced to*) go back and edit any of the previous inputs (not just the current line), use automatic expression formatting and colouring, see graphics as the output of some functions, or even use graphics as input! This advanced command line interface to Mathematica is called the Front End. > Is there any way to be able to freely move the cursor on a line? I > have obviously tried the arrow keys, and also have tried emacs style > movements as well with no luck (ctrl-b ctrl-f for backwards and > forewards). Any suggestions? > Your question is OS specific and you didn't say which OS you use. On Windows try starting math.exe, which is a real console mode program (not MathKernel.exe). All the usual input features of cmd.exe such as line editing and command history will be present. === Subject: Regressions in Mathematica Hello everyone, I'm having trouble understanding the syntax of the Regress command. If data is an nx2 matrix where the first column is the explanatory variable and the second is the dependent variable, then either Regress[data, {1, x}, x] or Regress[data, x, x] performs a standard regression of the second column on the first with a constant thrown in. But how do I write the command for the case of more than one explanatory variable? Say that my data matrix is now nx3, so that the first two columns are the explanatory variables and the last is the dependent variable. Regress[data, {x,x}, x] or Regress[data, {1, x,x}, x] gives the error message Number of coordinates (2) is not equal to the number of variables (1). I'm not sure how I'm supposed to identify each explanatory variable. Gregory === Subject: Re: Regressions in Mathematica > I'm having trouble understanding the syntax of the Regress command. > If data is an nx2 matrix where the first column is the explanatory > variable and the second is the dependent variable, then either Regress[data, {1, x}, x] or Regress[data, x, x] performs a standard regression of the second column on the first with > a constant thrown in. But how do I write the command for the case of > more than one explanatory variable? Say that my data matrix is now > nx3, so that the first two columns are the explanatory variables and > the last is the dependent variable. Regress[data, {x,x}, x] or Regress[data, {1, x,x}, x] gives the error > message Number of coordinates (2) is not equal to the number of > variables (1). I'm not sure how I'm supposed to identify each > explanatory variable. I hope the following will help: In[1]:= Needs[LinearRegression`] In[2]:= data = Flatten[Table[{x, y, x^2 + y^2}, {x, -1, 2}, {y, 3}], 1] Out[2]= {{-1, 1, 2}, {-1, 2, 5}, {-1, 3, 10}, {0, 1, 1}, {0, 2, 4}, {0, 3, 9}, {1, 1, 2}, {1, 2, 5}, {1, 3, 10}, {2, 1, 5}, {2, 2, 8}, {2, 3, 13}} In[3]:= Regress[data, {1, x, y}, {x, y}] Out[3]= {ParameterTable -> Estimate SE TStat PValue , 1 -2.33333 0.988826 -2.3597 0.0426223 x 1. 0.329609 3.0339 0.014157 -6 y 4. 0.451335 8.86259 9.68155 10 RSquared -> 0.906977, AdjustedRSquared -> 0.886305, EstimatedVariance -> 1.62963, ANOVATable -> DF SumOfSq MeanSq FRatio PValue } Model 2 143. 71.5 43.875 0.0000228382 Error 9 14.6667 1.62963 Total 11 157.667 In[4]:= Regress[data, {1, x, y, x^2, y^2}, {x, y}] Out[4]= {ParameterTable -> Estimate SE TStat PValue , -15 -15 1 -5.3843 10 6.47747 10 -0.831234 0.433276 -16 -15 x -5.93487 10 1.13915 10 -0.520992 0.618443 -15 -15 y 4.74751 10 7.27927 10 0.652197 0.535096 2 -16 15 x 1. 8.49071 10 1.17776 10 0. 2 -15 14 y 1. 1.80115 10 5.552 10 0. RSquared -> 1., AdjustedRSquared -> 1., -30 EstimatedVariance -> 8.65106 10 , ANOVATable -> DF SumOfSq MeanSq FRatio PValue} 30 Model 4 157.667 39.4167 4.55628 10 0. -29 -30 Error 7 6.05574 10 8.65106 10 Total 11 157.667 -- Jean-Marc === Subject: Re: Regressions in Mathematica I get it now. The dependent variable, always taken to be in the last column, is not mentioned in the command. All of the dependent variables must be listed. Gregory === Subject: Re: How can you get the list of all used variables and Names[] Bob Hanlon How can you get the list of all used variables and functions in Mathematica? Is that possible? -- Bob Hanlon === Subject: Re: How can you get the list of all used variables and functions in >How can you get the list of all used variables and functions in >Mathematica? Is that possible? Yes, this can be done. ?System`* will provide a list of all built-in symbols (constants, variables and functions). But before you use this be aware version 6 has ~3000 built-in symbols. So, this really isn't a good way to just browse through the built in stuff. But perhaps you were interested in a list of stuff you have defined. If so, ?Global`* will generate that list. === Subject: Re: Importing svg files >I ask just for reference: s = Import[Ampersand_Evolution.svg] and >got: Import::fmtnosup: SVG is not a supported Import format. >$Failed Is this normal? I mean: that Export works and Import not? (I started >a new kernel and there it was again...) Yes, this should be expected as can easily be verified by doing: In[3]:= Complement[$ExportFormats, $ImportFormats] Out[3]= {EPS,FLV,Maya,MIDI,PICT,POV,SVG,SWF,TeX,VRML,X3D,ZPR} Similarly, you can find formats that can be imported but not exported with: In[4]:= Complement[$ImportFormats, $ExportFormats] Out[4]= {ApacheLog,CDED,CUR,DBF,Directory,EDF,GTOPO30,ICO,LaTeX,MBOX, MDB,MPS,MTP,NetCDF,ODS,PDB,QuickTime,RSS,SDTS,SXC,USGSDEM,VCF,XPORT} Note, this was done on In[5]:= $Version Out[5]= 6.0 for Mac OS X PowerPC (32-bit) (May 21, 2008) The results for other versions or other platforms will almost certainly be different. === Subject: Re: Plotting ListDensityPlot with Custom Color Scheme >I'm trying to plot out a color map of a matrix with a custom color >scheme, and add a legend to it. >The maximum value in the matrix is approximately 1.7, and the lowest >value is -2.7. Most of the values lie in the range -0.5 to +0.5. >When Mathematica 6.0 produces a ListDensityPlot of this matrix, it >color codes most of the plot, but it leaves large areas with >overflow colors - some of the plot is displayed as white, not on >the color map. >I'd like to be able to rescale the color function so that it spans >the range -2.7 to 1.7, and produce a legend for the plot that >accurately reflects this. So, use the built-in function Rescale. For example, ColorFunction->(Hue@Rescale[#,{-2.7,1.7}]&) will eliminate the white areas. But note, this choice maps both minimum and maximum values to the same color. So, it is probably not one you want. Better might be ColorFunction->(ColorData[TemperatureMap][Rescale[#,{-2.7,1.7}]]&) === Subject: asumming and Exp orthogonality condition Element[ 0 , Integers ] evaluates to true, however; Assuming[ Element[ n , Integers] , Integrate[ Exp [ 2 I Pi n x ] , {x , 0 , 1 } ] ] evaluates to zero. Shouldn't evaluate to KroneckerDelta[ 0 , n ] instead? Charles J. Quarra === Subject: Re: asumming and Exp orthogonality condition > Element[ 0 , Integers ] evaluates to true, however; Assuming[ Element[ n , Integers] , Integrate[ Exp [ 2 I Pi n x ] , > {x , 0 , 1 } ] ] evaluates to zero. Shouldn't evaluate to > KroneckerDelta[ 0 , n ] instead? The following might explain what is going on. Mathematica does not have any transformation rule for this specific case of this definite integral. So, I guess, what Mathematica computes first is the general formula for the definite integral (I shall call it int[n]) and then applies the assumption about n being an integer. (This is conceptually equivalent to In[1] and In[2].) As it stands, int[n] is defined and equal to 0 for all n in N, n !=0. (For n == 0 we have a division by zero.) So what Mathematica sees is that the function is defined for every non-zero integer and its value is therefore zero. Now, if we extend the domain of definition of int[n] to the whole set of integers and defined int[0] == 1, (having checked that the limit of int[n] as n approaches zero on the left and on the right is equal to one), only then this extended definition matches KroneckerDelta[0, n]. Thus, Mathematica's behavior seems reasonable since Mathematica is not going to attempt by itself to check the limits and/or extend the domain of definition. In[1]:= int[n_] = Integrate[Exp[2 I Pi n x], {x, 0, 1}] Out[1]= -((I (-1 + E^(2 I n [Pi])))/(2 n [Pi])) In[2]:= Assuming[Element[n, Integers], Simplify[int[n]]] Out[2]= 0 In[3]:= Table[int[n], {n, -2, 2}] During evaluation of In[3]:= Power::infy: Infinite expression 1/0 encountered. >> During evaluation of In[3]:= [Infinity]::indet: Indeterminate expression (0 ComplexInfinity)/[Pi] encountered. >> Out[3]= {0, 0, Indeterminate, 0, 0} In[4]:= Limit[int[n], n -> 0, Direction -> 1] Out[4]= 1 In[5]:= Limit[int[n], n -> 0, Direction -> -1] Out[5]= 1 -- Jean-Marc === Subject: Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]? In the earlier discussion of this problem I forgot that there is much better approach. Simply use the two argument version of ArcTan to get: Assuming[Element[x | y, Reals], FullSimplify[ArcCos[x/Sqrt[x^2 + y^2]] - (Pi/2 - ArcTan[Abs[y], x])]] 0 Andrzej Kozlowski > I don't think there is a way to simplify one of these expressions > into the other, but one can use Mathematica as an aid in proving > that they are equal (for real x and y). One way to do this is: expres = {ArcCos[x/Sqrt[x^2 + y^2]], Pi/2 - ArcTan[x/Abs[y]]}; Subtract @@ Assuming[Element[x | y, Reals], Simplify[Sin /@ expres]] > 0 Subtract @@ Assuming[Element[x | y, Reals], Simplify[Cos /@ expres]] > 0 So for real x and y, the two expressions have equal sines and > cosines. That means that they must differ by an integer multiple of > 2Pi. However, since the difference is a continuous function of x and > y, it has to be constant. Now, putting (for example) x=0, y=1, we > see that the constant must be zero, hence they are equal. Andrzej Kozlowski > ArcCos[x/Sqrt[x^2+y^2]] >> and >> Pi/2-ArcTan[x/Abs[y]] >> are the same. >> But I can not get the first expression be simplified to the second >> one. And the following command can not be simplified to zero in >> mathematica as well. >> FullSimplify[ArcCos[x/Sqrt[x^2 + y^2]] - ( Pi/2 - ArcTan[x/Abs[y]]), >> Element[x, Reals] && Element[y, Reals]] >> I'm wondering if there is any walkaround to do this simplification. >> Peng > === Subject: Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]? >> My question was raised because I had a very complex expression, which >> is too long to understand. The case in the title is just one little >> sub expression in that I could pinpoint in that long expression. I >> don't know the simplest form of the long expression. But it is of >> course not the simplest, because I pinpoint the sub expression that >> can be made simpler. >> I could do this by hand, but then why I need Mathematica? You can never hope to get the simplest form, firstly because there is no > unique defintion of simplest (that is why the functions Simplify and > FullSimplify have the ComplexityFunction option, which allows you to decide > which of two equivalent forms of an expression is simpler.). Secondly, > there are only a certain finite number of transformations that Simplify and > FullSimplify will use (FullSimplify uses more). Some very natural functions > ar enot included because they have too high complexity and applying them all > the time would essentially stall Mathematica. You can add your own functions > using the option TransformationFucntions in Simplify and FullSimplify. In > general, only you can know what kind of simplifications will be useful in > your particular case. Computers cannot think and make choices, so if one > adds too many transformation functions as default they will be applied all > the time even in situations when they have no hope of being useful. Human > beings are (hopefully) intelligent and often can see easily that a certain > transformation will be of no use in a certain situation. Computer programs > usually can't. > In any case, all you can expect from Simplify is to obtain an expression > that will have the lowest value of ComplexityFunction under transformations > that are built up of the ones Simplify uses automatically plus any that you > have added yourself. FullSimplify uses more transformation functions than > Simplify and also uses them recursively, so it will often take a very long > time to return an answer. That's all there really is to it, and short of > developing software than can reason like human mathematicians there is > little, I think, that can in principle be changed, although of course more > efficient algorithms are being developed all the time (and implemented in > Mathematica). There are only a few examples in the help of ComplexityFunction. I'm wondering what kind of complexity functions I should use for the two cases that I raised. Peng === Subject: Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]? Forget to forward to math group. >> I agree you point. But I don't know the exact algorithm how > Mathematica manipulate expressions, and I don't know how to improve it > algorithmically in a general way. >> Like suggesting the improvement to all other softwares, users can only > tell the software developers what the users want. Although the users > provide somewhat ambiguous or not exact information, it is up to the > developers to figure out what the users mean. The users' suggestion > might only be some point cases, it is up to the developer to see if > these cases can be generalized. Therefore, the communication between > the developers and the users become important. >> Of course, but... Do you have any reason to think Mathematica developers do >> not know it would be a good thing if Mathematica could transform inverse >> trigonotmetric functions (or other mathematical expressions) into equivelent >> forms? Do you really think that the reason it can't is because the >> developer's have not been paying attention to this matter? >> Similarly, do you think that mathematicians do not know that it would be a >> good idea to prove the Riemann hypothesis and that the reason it has not yet >> been done so is their lack of trying? I don't know the reason. That is why I ask. I think that it would be a > little offensive if you ask some other people in this way. Anyway, I > don't really care. There are multiple equivalent forms for any inverse trigonometric > functions. If there is a way to specific which form to choose for any > inverse trigonometric function under any condition (just like what > human can do), then the problem is solve. Therefore, I thought it is > just an software issue. >> For right now, I think Mathematica shall at least be able to do all > the elementary manipulations in the following webpage ragarding > inverse trigonometry functions, which I don't see can be done by > Mathematica now (correct me if I'm wrong). >> http://en.wikipedia.org/wiki/Inverse_trigonometric_function >> It is completely trivial to implement all these rules in Mathematica using >> pattern matching and you should be able to do it yourself with just a >> minimal knowledge of Mathematica. So this is not the problem. The problem is >> to implement them in such a way that not only expressions that match exactly >> the ones on this page are transformed but also an infinite class of >> essentially equivalent expressions which are mathematically equal but do not >> match the same pattern. For this one needs general mathematical algorithms >> and finding such algorithms is a problem in mathematics and not a problem in >> software development. Now, I understand it is an algorithmic issue, which might not be easy > to solve absolutely. But can there be some heuristics? >> Another thing that I want is that it shall be able to manipulate > Sqrt[x*x+y*y] to x *Sqrt[1+(x/y)^2]. >> One way to do this and many similar examples is: >> Simplify[Sqrt[x^2 + y^2] /. y -> k*x, x >= 0] /. k -> y/x >> x*Sqrt[y^2/x^2 + 1] I have been doing this. But I want a generic way. I feel tedious to > specify the replacement rules each time. Consider the following case > that is buried in some other big expressions that spread pages. > Sqrt[some_complex_expr1^2 + some_complex_expr2^2] > On the other hand, computer algebra programs are not really meant, or at >> least not principally meant, to transform expressions from one form to >> another already known form. Since you already know the answer you want, you >> can do the transforming by writing an appropriate pattern and using >> replacement, which is essentially the same as doing this by hand, but can >> be more efficient in cases where you have to perform many similar >> replacements. The true purpose of functions such as Simplify and >> FullSimplify is to transform complex expressions into canonical, simpler >> forms in situations when you do not already know exactly the form you want >> and only know that you want a form that is simpler than the one you have >> got. It would be a waste of resources to devote much time and energy on >> improving the abilities of Mathematica to give users the answers they >> already know. My question was raised because I had a very complex expression, which > is too long to understand. The case in the title is just one little > sub expression in that I could pinpoint in that long expression. I > don't know the simplest form of the long expression. But it is of > course not the simplest, because I pinpoint the sub expression that > can be made simpler. I could do this by hand, but then why I need Mathematica? > === Subject: Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]? I agree you point. But I don't know the exact algorithm how > Mathematica manipulate expressions, and I don't know how to improve it > algorithmically in a general way. Like suggesting the improvement to all other softwares, users can only > tell the software developers what the users want. Although the users > provide somewhat ambiguous or not exact information, it is up to the > developers to figure out what the users mean. The users' suggestion > might only be some point cases, it is up to the developer to see if > these cases can be generalized. Therefore, the communication between > the developers and the users become important. Of course, but... Do you have any reason to think Mathematica developers do not know it would be a good thing if Mathematica could transform inverse trigonotmetric functions (or other mathematical expressions) into equivelent forms? Do you really think that the reason it can't is because the developer's have not been paying attention to this matter? Similarly, do you think that mathematicians do not know that it would be a good idea to prove the Riemann hypothesis and that the reason it has not yet been done so is their lack of trying? > For right now, I think Mathematica shall at least be able to do all > the elementary manipulations in the following webpage ragarding > inverse trigonometry functions, which I don't see can be done by > Mathematica now (correct me if I'm wrong). http://en.wikipedia.org/wiki/Inverse_trigonometric_function It is completely trivial to implement all these rules in Mathematica using pattern matching and you should be able to do it yourself with just a minimal knowledge of Mathematica. So this is not the problem. The problem is to implement them in such a way that not only expressions that match exactly the ones on this page are transformed but also an infinite class of essentially equivalent expressions which are mathematically equal but do not match the same pattern. For this one needs general mathematical algorithms and finding such algorithms is a problem in mathematics and not a problem in software development. > Another thing that I want is that it shall be able to manipulate > Sqrt[x*x+y*y] to x *Sqrt[1+(x/y)^2]. One way to do this and many similar examples is: Simplify[Sqrt[x^2 + y^2] /. y -> k*x, x >= 0] /. k -> y/x x*Sqrt[y^2/x^2 + 1] On the other hand, computer algebra programs are not really meant, or at least not principally meant, to transform expressions from one form to another already known form. Since you already know the answer you want, you can do the transforming by writing an appropriate pattern and using replacement, which is essentially the same as doing this by hand, but can be more efficient in cases where you have to perform many similar replacements. The true purpose of functions such as Simplify and FullSimplify is to transform complex expressions into canonical, simpler forms in situations when you do not already know exactly the form you want and only know that you want a form that is simpler than the one you have got. It would be a waste of resources to devote much time and energy on improving the abilities of Mathematica to give users the answers they already know. Andrzej Kozlowski === Subject: Re: How to simplify ArcCos[x/Sqrt[x^2+y^2]] to Pi/2-ArcTan[x/Abs[y]]? > I don't think there is a way to simplify one of these expressions > into the > other, but one can use Mathematica as an aid in proving that they > are equal > (for real x and y). One way to do this is: >> If this is case, I therefore might have to rely on hand calculation. >> But I would think Mathematica should be improved so that mathematical >> expressions can be manipulated in more versatile ways. >> Peng I always agree that Mathematica should be improved (although perhaps I > put the limit the point where it would start putting human > mathematicians out of their jobs). However, that is easy to say, the > hard thing is to find the right algorithms and to implement them. > Algorithmic simplification of expressions is a very complex problem > and only for certain types of expressions (like polynomials, rational > functions, exponentials, logs and a few others) sufficiently general > methods exist (and this ignores the not exactly trivial problem of > defining when one expression is to be considered simpler than > another). But the situation is much worse when you wish to convert > from one form to another an expression, when the conversion is only > valid under certain assumptions. If you can suggest a concrete general > algorithm that you think should be implemented in Mathematica and is > not implemented now I am sure WRI will be happy to oblige but just > saying it should be improved isn't very helpful. You can be sure > that there are people who are trying to do that all the time. I agree you point. But I don't know the exact algorithm how Mathematica manipulate expressions, and I don't know how to improve it algorithmically in a general way. Like suggesting the improvement to all other softwares, users can only tell the software developers what the users want. Although the users provide somewhat ambiguous or not exact information, it is up to the developers to figure out what the users mean. The users' suggestion might only be some point cases, it is up to the developer to see if these cases can be generalized. Therefore, the communication between the developers and the users become important. For right now, I think Mathematica shall at least be able to do all the elementary manipulations in the following webpage ragarding inverse trigonometry functions, which I don't see can be done by Mathematica now (correct me if I'm wrong). http://en.wikipedia.org/wiki/Inverse_trigonometric_function Another thing that I want is that it shall be able to manipulate Sqrt[x*x+y*y] to x *Sqrt[1+(x/y)^2]. Peng === Subject: eliminate values while caculating Mean[data] An easy question: I would like to make an average of a data file.I know that we can use Mean function for this. However, I want to eliminate some values from my data.For example if I have data={1,2,3,4,5,0,0,0} Mean[data] would be 15/8 I do not want the zero values in my Mean function (i.e.I want the mean value to be 3 in the above example) How can I do this? Best, Pasha === Subject: Re: eliminate values while caculating Mean[data] Use the Fuctional Programming command Select. data = {1, 2, 3, 4, 5, 0, 0, 0}; data2 = Select[data, # != 0 &] {1, 2, 3, 4, 5} Mean[data2] 3 -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ An easy question: > I would like to make an average of a data file.I know that we can use > Mean function for this. However, I want to eliminate some values from my data.For example if I > have data={1,2,3,4,5,0,0,0} > Mean[data] would be 15/8 I do not want the zero values in my Mean function (i.e.I want the mean > value to be 3 in the above example) How can I do this? Best, > Pasha === Subject: Re: eliminate values while caculating Mean[data] > An easy question: > I would like to make an average of a data file.I know that we can use > Mean function for this. However, I want to eliminate some values from my data.For example if I have data={1,2,3,4,5,0,0,0} > Mean[data] would be 15/8 I do not want the zero values in my Mean function (i.e.I want the mean > value to be 3 in the above example) How can I do this? You could filter the data with *DeleteCases*, for instance. In[1]:= data = {1, 2, 3, 4, 5, 0, 0, 0} sample = DeleteCases[data, 0] Mean[sample] Out[1]= {1, 2, 3, 4, 5, 0, 0, 0} Out[2]= {1, 2, 3, 4, 5} Out[3]= 3 -- Jean-Marc === Subject: Re: eliminate values while caculating Mean[data] An easy question: > I would like to make an average of a data file.I know that we can use > Mean function for this. However, I want to eliminate some values from my data.For example if I have data={1,2,3,4,5,0,0,0} > Mean[data] would be 15/8 I do not want the zero values in my Mean function (i.e.I want the mean > value to be 3 in the above example) How can I do this? > Just filter the data first: Cases[data, Except[0]] (* will only filter 0, but not 0.0 *) Select[data, # != 0 &] data /. 0 -> Sequence[] (* will only filter 0, but not 0.0 *) === Subject: Re: eliminate values while caculating Mean[data] An easy question: > I would like to make an average of a data file.I know that we can use > Mean function for this. However, I want to eliminate some values from my data.For example if I= have data={1,2,3,4,5,0,0,0} > Mean[data] would be 15/8 I do not want the zero values in my Mean function (i.e.I want the mean > value to be 3 in the above example) How can I do this? Best, > Pasha Filter data, i.e. Mean@Select[data, # != 0 &] Vince Virgilio === Subject: Re: eliminate values while caculating Mean[data] Hello Pasha, I would generally recommend you to write your own functions, it's more customizable:) The name of your set of data is Data and looks like in your post, say: Data={1,2,3,4,5}; Value of Summ gives you a sum of all non-zero elements in Data and NonZeroValuesCounter gives you a number of non-zero entries in Data. Average is what you want. Just paste the script below into Mathematica and run: Summ = 0; NonZeroValuesCounter = 0; For[index = 1, index <= Length[Data], index += 1, If[Data[[index]] != 0, Summ += Data[[index]]; NonZeroValuesCounter += 1]; ]; Average = Summ/NonZeroValuesCounter; Print[Summ: , Summ, NonZeroValuesCounter: , NonZeroValuesCounter, Average: , Average] ------------- Have fun, Kazik === Subject: Re: ListContourPlot3D, no output Indeed,I should explain better what is happening. The table I have is a relative large data collection and I am not sure about how to post this here. Concerning your examples of code, I would guess all of it should work, since I could run all the examples that are given on the help page of ListContoutPlot3D. In the end, I tried this: I took my table of the form Basbsselect={{x,y,z,f}, ...} (again, a regular array with equally spaced x, y, and z values, and which contains nx x ny x nz values) and made an array using: Babsarray = Array[Babsselect[[1 + (#1 - 1)*naz*nay + (#2 - 1)*naz + ( #3 - 1), 4]] &, {nax, nay, naz}]; Then I can plot this using ListContourPlot3D. So this sort of solves my problem. But I would still be interested to post the original code, it is unfortunately a rather big table and I do not know if that is possible. Adi === Subject: Re: ListContourPlot3D, no output > Indeed,I should explain better what is happening. The table I have is a relative large data collection and I am not sure about how to post this here. > Concerning your examples of code, I would guess all of it should work, since I could run all the examples that are given on the help page of ListContoutPlot3D. > In the end, I tried this: I took my table of the form Basbsselect={{x,y,z,f}, ...} (again, a regular array with equally spaced x, y, and z values, and which contains nx x ny x nz values) and made an array using: Babsarray = > Array[Babsselect[[1 + (#1 - 1)*naz*nay + (#2 - 1)*naz + ( #3 - 1), > 4]] &, {nax, nay, naz}]; Then I can plot this using ListContourPlot3D. So this sort of solves my problem. > But I would still be interested to post the original code, it is unfortunately a rather big table and I do not know if that is possible. You may already have done so, but, just in case, there are several easy things you could do to be certain that the list of points, say data, is in the right format and holds numeric values only. You must have a list of quadruples, so Dimensions[data] must return something of the form {number of lines, 4} (see below). Also, you could use *MatrixQ* to check that all entries are of the same format, say machine-size numbers. Finally, you could test just a small portion of the dataset and post it on the list if the result is still the same (i.e. no output). In[1]:= data = RandomReal[1, {1000, 4}]; Dimensions[data] MatrixQ[data, MachineNumberQ] data[[1 ;; 3, All]] Out[2]= {1000, 4} Out[3]= True Out[4]= {{0.341631, 0.957932, 0.871985, 0.325795}, {0.875817, 0.267281, 0.557361, 0.55858}, {0.209774, 0.85224, 0.330304, 0.583726}} -- Jean-Marc === Subject: Label style in PieChart? I'm using Mathematica 6.0.3 on OSX 10.5. In a PieChart, is it possible to control the label font size and family? I routinely control this for 'FrameLabel' with ListPLot. But in the following, adding 'LabelStyle -> Directive[12, FontFamily -> Helvetica]', does not change the '21.7%' label, PieLabelStyle is not valid, PieStyle does not accept font information, and I have found nothing information in the Help system or on the web for this. pct = 21.7 pieLab = StringJoin[ToString[pct], %] PieChart[{pct, 100 - pct}, PieLabels -> {pieLab, }, PieStyle -> {Directive[Darker[Blue], Opacity[0.4]], Directive[Gray, Opacity[0.1]]}, ImageSize -> 200] G -- Gordon Robertson B.C. Cancer Agency Genome Sciences Centre Vancouver BC Canada V5Z 4S6 604.707.5900 x5416 www.bcgsc.ca === Subject: Re: Functional programming? >I suggest it might be instructive if some of the functional >programming proponents on this group could provide us DO-looping old >timers with a brief summary or tutorial as to what is really meant >by, or involved in, functional programming? I wouldn't know where to start such a tutorial. Why don't the various tutorials in the online help address your need here? And what about the many books already written on programming in Mathematica? When I first started using Mathematica, like many others I had come with some background in procedural languages C, C++ and FORTRAN. And my initial programming in Mathematica made use of For loops etc. I moved to functional programming after reading a couple of Maeder's books and other books on Mathematica. I gained more familiarity with this style of programming by simply using it. Also, I made a sure to understand code others had written using functional programming worked by looking up the syntax of any unfamiliar command. Using Mathematica on a daily basis in this fashion, I eventually became more comfortable with the functional style. And now, I would have to look up the syntax for For and similar constructs before using them. I simply do not know any better way to learn any programming language other than simply using it to solve real problems. Yes, this takes time. But mastery of anything takes time. There simply are no shortcuts. === Subject: Re: eliminate values while caculating Mean[data] There are probably many strategies. Just a few worth considering ... Mean[Cases[data, Except[0]]] or Mean[Cases[data, x_ /; 1 <= x, Infinity]] or Mean[DeleteCases[data, 0]] or, using Select, Mean@Select[data,#>0&] Tom Dowling An easy question: > I would like to make an average of a data file.I know that we can use > Mean function for this. However, I want to eliminate some values from my data.For example if I > have data={1,2,3,4,5,0,0,0} > Mean[data] would be 15/8 I do not want the zero values in my Mean function (i.e.I want the mean > value to be 3 in the above example) How can I do this? Best, > Pasha > === Subject: Re: eliminate values while caculating Mean[data] >An easy question: I would like to make an average of a data file.I >know that we can use Mean function for this. >However, I want to eliminate some values from my data.For example >if I have >data={1,2,3,4,5,0,0,0} Mean[data] would be 15/8 >I do not want the zero values in my Mean function (i.e.I want the >mean value to be 3 in the above example) How can I do this? Use DeleteCases to omit the unwanted values, i.e., In[2]:= Mean@DeleteCases[data, 0] Out[2]= 3 === Subject: Re: Regressions in Mathematica >But how do I write the command for the case of more than one >explanatory variable? Say that my data matrix is now nx3, so that the >first two columns are the explanatory variables and the last is the >dependent variable. >Regress[data, {x,x}, x] or Regress[data, {1, x,x}, x] gives the >error message Number of coordinates (2) is not equal to the number >of variables (1). I'm not sure how I'm supposed to identify each >explanatory variable. The syntax is Regress[data, basisFunctionList, independentVariableList] So with two independent variables you would do: Regress[data, {1, x, y^2}, {x, y}] where I am fitting the model a + b x + c y^2 to the data. The list of variables in the third argument needs to list them in order they appear in data. === Subject: how to test where a list contains constant(s) or not case1: { a, b, c, Pi } gives true because of Pi case2: { a, b, c, 0.0001} gives true because of 0.0001 case3: { a, b, c, 2 + Pi I } gives ture becase of 2 + Pi I case4: { a, b, c} gives false is this function right ? ComplexQ[z_] := NumericQ[ z ] || ( NumericQ[ z ] && SameQ[ Head[ z ], Complex] ) IsConstantsIn[ lstList_ ] := Module[ { intLength }, intLength = Length@Select[ lstList, ComplexQ[ # ]& ]; If[ intLength > 0, Return[ True ], Return[ False ] ]; Return[ False ]; ] === Subject: A interesting case I have spent work hours with this case. ToString[#,InputForm]&/@{1/a^2,2/a^2,3/a^2} {a^(-2),2/a^2,3/a^2} When the numerator of a rational element is 1, the structure string is diferent. Why? === Subject: Advanced plotting I am wondering is there a possibility in Mathematica 6 to use two different scales on vertical axis- one scale on the left one and the other on the right one (with a horizontal axis being common for both the vertical ones). The thing is I would like to plot two functions that have the same x-domain but completely different y-domain. If I used the standard plotting procedure then if a first function (with values about 100) can be easily seen on the plot, the values of the other are to small (close to zero) to be seen. The solution would be to set two independent Y axes, however I don't know if there is the possibility in Mathematica 6 (I have seen such a plots in scientific papers but maybe done with some other application). The second question is is there a possibility to make breaks in axes. What I mean is that I have a plot with let say X domain [0,50], but I am only interested in two parts of it, say [0,10] and [40,50], so is it possible to set a kind of an option in Plot command? Such a trick is also quite common in scientific papers with characteristic on axis in a place where the break is made (I know for example how to do it in Origin and there is quite an easy task). I have been searching for the staff quite long and haven't found any solution yet so I would be really grateful if someone would help me with the issue. Kazik === Subject: One fundamental Gudermannian identity not verified Hello to all Since I couldn't find a definition of the Gudermannian fonction among Mathematica packages I defined it myself : > In[9]:= Gd= (2 tan^-1(e^#)-[Pi]/2) & Out[9]= 2 ArcTan[[ExponentialE]^#1] - [Pi]/2 & I could verify all the identies with that fonction I thought of , including one involving half-angles ie > In[14]:= FullSimplify[Subtract @@ {#[[1]][Gd[x]/2], #[[2]][x/2]}, > x[Epsilon] Reals] & /@ {{Tan, Tanh}} Out[14]= {0} but not this last one : > In[16]:= FullSimplify[Subtract @@ {#[[1]][x], #[[2]][Tanh x/2]}, > x[Epsilon] Reals] & /@ {{Gd , 2 ArcTan}} Out[16]= {-[Pi]/2 + > 2 ArcTan[[ExponentialE]^x] - (2 ArcTan)[(Tanh x)/2]} Is there another way with Mahematica 6.0 to make this verification? Sigismond Kmiecik === Subject: Re: eliminate values while caculating Mean[data] data = {1, 2, 3, 4, 5, 0, 0, 0}; Mean[DeleteCases[data, 0]] 3 Mean[Cases[data, _?(# != 0 &)]] 3 Mean[Select[data, # != 0 &]] 3 Mean[Complement[data, {0}]] 3 Mean[data /. 0 -> Sequence[]] 3 Mean[Pick[data, Thread[data != 0]]] 3 Bob Hanlon An easy question: I would like to make an average of a data file.I know that we can use Mean function for this. However, I want to eliminate some values from my data.For example if I have data={1,2,3,4,5,0,0,0} Mean[data] would be 15/8 I do not want the zero values in my Mean function (i.e.I want the mean value to be 3 in the above example) How can I do this? Best, Pasha -- Bob Hanlon === Subject: Re: Regressions in Mathematica Needs[LinearRegression`]; data = Table[{x = Random[], y = Random[], 5 x + 17 y + 6 + (2 Random[] - 1)}, {50}]; x =.; y =.; param = FindFit[data, a*x + b*y + c, {a, b, c}, {x, y}] {a->5.17687,b->16.9869,c->5.92077} ({c, a, b} /. param) == (ParameterTable /. Regress[data, {x, y}, {x, y}])[[1, All, 1]] True Bob Hanlon Hello everyone, I'm having trouble understanding the syntax of the Regress command. If data is an nx2 matrix where the first column is the explanatory variable and the second is the dependent variable, then either Regress[data, {1, x}, x] or Regress[data, x, x] performs a standard regression of the second column on the first with a constant thrown in. But how do I write the command for the case of more than one explanatory variable? Say that my data matrix is now nx3, so that the first two columns are the explanatory variables and the last is the dependent variable. Regress[data, {x,x}, x] or Regress[data, {1, x,x}, x] gives the error message Number of coordinates (2) is not equal to the number of variables (1). I'm not sure how I'm supposed to identify each explanatory variable. Gregory -- Bob Hanlon === Subject: Re: Functional programming? Here's my favorite very simple example, for instructional purposes, that employs some functional programming -- hardly real-world, I suspect, in the sense you mean. It's not pure functional programming, in that some arguments are explicitly mentioned in definitions, but it does includes some functional programming. newtonStep::usage=newtonStep[{c, x0}] performs one step of Hero's method to find a better estimate x1 for the square-root of c given estimate x0; the result has the form {c, x1}; newton::usage=newton[c, epsilon, x0] applies Hero's method to find the square-root of c with |error| < epsilon, given the initial estimate x0.; newtonStep[{c_, x_}] := {c,Mean[{x,c/x}]} newton[target_,tolerance_,initialGuess_]:= Last@NestWhile[newtonStep, {target,initialGuess}, Abs[Last@#1-Last@#2]>=tolerance&,2] newton[2, 10.^-13, 1.] // NumberForm[#, 12] & 1.41421356237 I leave to explicit-looping advocates the exercise of coding the same thing in a Do or other explicit loop. Note that I consider array-oriented programming, such as originated in APL and as derivatively and partially incorporated into Mathematica, as a somewhat different programming paradigm from functional programming. > I suggest it might be instructive if some of the functional programming > proponents on this group could provide us DO-looping old timers with a > brief summary or tutorial as to what is really meant by, or involved in, > functional programming? --- especially as this concept might relate to building programs to do > calculations involving multi-stage real-world engineering or technical > problems --- and especially as it might relate to programs that are going to be > developed in an evolutionary process and that in the end, rather than > being built into some long-term library, are maybe only going to be run > or executed a few times before the person involved (e.g., an engineer, > or scientist, or other real-world individual, not a programmer) moves > on to some other totally different task or assignment. > -- Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305 === Subject: Re: Functional programming? as an old-timer myself - I'd be very interested in this too, particularly - as you say - with reference to engineering problems. I'm afraid my favorite construct was the REPEAT - UNTIL loop, which should finally ruin any shreds of credibility that I may once have had... Peter 2008/9/13 AES : > I suggest it might be instructive if some of the functional programming > proponents on this group could provide us DO-looping old timers with a > brief summary or tutorial as to what is really meant by, or involved in, > functional programming? --- especially as this concept might relate to building programs to do > calculations involving multi-stage real-world engineering or technical > problems --- and especially as it might relate to programs that are going to be > developed in an evolutionary process and that in the end, rather than > being built into some long-term library, are maybe only going to be run > or executed a few times before the person involved (e.g., an engineer, > or scientist, or other real-world individual, not a programmer) moves > on to some other totally different task or assignment. -- === Subject: Functional programming? I suggest it might be instructive if some of the functional programming proponents on this group could provide us DO-looping old timers with a brief summary or tutorial as to what is really meant by, or involved in, functional programming? --- especially as this concept might relate to building programs to do calculations involving multi-stage real-world engineering or technical problems --- and especially as it might relate to programs that are going to be developed in an evolutionary process and that in the end, rather than being built into some long-term library, are maybe only going to be run or executed a few times before the person involved (e.g., an engineer, or scientist, or other real-world individual, not a programmer) moves on to some other totally different task or assignment. === Subject: Re: Functional programming? try out these commands. There was another posting today titled 'eliminate values while calculating Mean[data]' by Pasha Karami in which he wanted to eliminate zero values from a list of data. This is very easily done with the Functional Programming Select command. You don't even have to know how long the list is. So why don't you show us how you would do it with the For or Do command, without using any Functional Programming? Certainly it can be done, but after seeing Select are you still always going to do it with Procedural Programming in the future? Suppose you want to select values from a list that are between 1 and 6 in value. How would you do it with Procedural Programming without using any Functional Programming? -- David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ >I suggest it might be instructive if some of the functional programming > proponents on this group could provide us DO-looping old timers with a > brief summary or tutorial as to what is really meant by, or involved in, > functional programming? --- especially as this concept might relate to building programs to do > calculations involving multi-stage real-world engineering or technical > problems --- and especially as it might relate to programs that are going to be > developed in an evolutionary process and that in the end, rather than > being built into some long-term library, are maybe only going to be run > or executed a few times before the person involved (e.g., an engineer, > or scientist, or other real-world individual, not a programmer) moves > on to some other totally different task or assignment. > === Subject: Re: Functional programming? > I suggest it might be instructive if some of the functional programming > proponents on this group could provide us DO-looping old timers with a > brief summary or tutorial as to what is really meant by, or involved in, > functional programming? --- especially as this concept might relate to building programs to do > calculations involving multi-stage real-world engineering or technical > problems --- and especially as it might relate to programs that are going to be > developed in an evolutionary process and that in the end, rather than > being built into some long-term library, are maybe only going to be run > or executed a few times before the person involved (e.g., an engineer, > or scientist, or other real-world individual, not a programmer) moves > on to some other totally different task or assignment. I hazard the opinion that you find many (rudimentary?) examples of functional programming in spreadsheets (any vendor's). Which are also very good examples of 'disposable' code a.k.a. 'engineering' code. Say, the SUM function, which takes a Range of cells to give a total, without requiring a loop index. Very functional. No? Vince Virgilio === Subject: Re: Functional programming? > I suggest it might be instructive if some of the functional programming > proponents on this group could provide us DO-looping old timers with a > brief summary or tutorial as to what is really meant by, or involved in, > functional programming? --- especially as this concept might relate to building programs to do > calculations involving multi-stage real-world engineering or technical > problems --- and especially as it might relate to programs that are going to be > developed in an evolutionary process and that in the end, rather than > being built into some long-term library, are maybe only going to be run > or executed a few times before the person involved (e.g., an engineer, > or scientist, or other real-world individual, not a programmer) moves > on to some other totally different task or assignment. Why asking to reinvent the wheel when Google, Wikipedia, several Usenet newsgroups dedicated to functional programming and languages (and their associated FAQ) can easily answer all these questions? But you have already done that, don't you? So I feel you want to go beyond the mundane stuff; look no further! For the mathematical inclined mind, I would strongly recommend studying _The Haskell Road to Logic, Maths and Programming_ (Texts in Computing [ISBN-13: 978-0954300692]. Admittedly, the book is thicker than a mere tutorial, yet much more slim than The Mathematica Book, 5th Ed., and it has such breadth and depth... All the cutting-edge concepts and superior technics you are going to master will easily translate to Mathematica and dramatically improve your user experience... -- Jean-Marc